Changeset 2127


Ignore:
Timestamp:
02/19/07 09:16:59 (17 years ago)
Author:
gumbau
Message:
 
Location:
GTP/trunk/Lib/Geom/shared
Files:
2 added
2 deleted
28 edited

Legend:

Unmodified
Added
Removed
  • GTP/trunk/Lib/Geom/shared/GTGeometry/include/GeoMeshSimplifier.h

    r2090 r2127  
    9090                        void    JoinVertices(Mesh *mesh); 
    9191 
    92                         MeshSimplificationSequence * 
    93                                 WriteRealSimpSeq(MeshSimplificationSequence *simpseq); 
    94  
    9592                        Mesh    *GetMesh(); 
    9693        }; 
  • GTP/trunk/Lib/Geom/shared/GTGeometry/src/GeoLodStripsConstructor.cpp

    r2079 r2127  
    289289{ 
    290290        unsigned long int i; 
    291         unsigned long int j; 
    292291        unsigned long int t; 
    293292        unsigned long int v; 
     
    301300 
    302301        tipoOrden                       Orden; 
    303         tipoOrden                       *Ord; 
    304302        bool                                    bEncontrado; 
    305303 
  • GTP/trunk/Lib/Geom/shared/GTGeometry/src/GeoMeshLoader.cpp

    r1526 r2127  
    1 /*========================================================================== 
     1/*======================================================================== 
    22 *      (C) 2005 Universitat Jaume I 
    3  *========================================================================== 
     3 *======================================================================== 
    44 *      PROYECT:        GAME TOOLS 
    5  *==========================================================================*/ 
     5 *========================================================================*/ 
    66/*      CONTENT:         
    77 * 
    88 * 
    99 *      @file   GeoMeshLoader.cpp 
    10  *==========================================================================*/ 
     10 *========================================================================*/ 
    1111 
    1212#include        "GeoMeshLoader.h" 
     
    1818using   namespace       std; 
    1919 
    20 //--------------------------------------------------------------------------- 
     20//------------------------------------------------------------------------- 
    2121//      Jump a chunk. 
    22 //--------------------------------------------------------------------------- 
     22//------------------------------------------------------------------------- 
    2323void GeoMeshLoader::jumpChunk(FILE      *f) 
    2424{ 
     
    2929} 
    3030 
    31 //--------------------------------------------------------------------------- 
     31//------------------------------------------------------------------------- 
    3232//      Read a chunk. 
    33 //--------------------------------------------------------------------------- 
     33//------------------------------------------------------------------------- 
    3434unsigned short GeoMeshLoader::readChunk(FILE    *f) 
    3535{ 
     
    4242} 
    4343 
    44 //--------------------------------------------------------------------------- 
     44//------------------------------------------------------------------------- 
    4545//      Read geometry vertex element. 
    46 //--------------------------------------------------------------------------- 
     46//------------------------------------------------------------------------- 
    4747void GeoMeshLoader::readGeometryVertexElement(FILE      *f, Mesh        *geoMesh) 
    4848{ 
     
    112112} 
    113113 
    114 //--------------------------------------------------------------------------- 
     114//------------------------------------------------------------------------- 
    115115//      Read geometry vertex declaration. 
    116 //--------------------------------------------------------------------------- 
     116//------------------------------------------------------------------------- 
    117117void GeoMeshLoader::readGeometryVertexDeclaration(FILE  *f, Mesh        *geoMesh) 
    118118{ 
     
    154154}//     End readGeometryVertexDeclaration. 
    155155 
    156 //--------------------------------------------------------------------------- 
     156//------------------------------------------------------------------------- 
    157157//      Read geometry vertex buffer. 
    158 //--------------------------------------------------------------------------- 
    159 void GeoMeshLoader::readGeometryVertexBuffer(FILE       *f, Mesh        *geoMesh, int option) 
     158//------------------------------------------------------------------------- 
     159void GeoMeshLoader::readGeometryVertexBuffer(   FILE    *f, 
     160                                                                                                                                                                                        Mesh    *geoMesh, 
     161                                                                                                                                                                                        int option) 
    160162{ 
    161163        unsigned        short   bindIndex; 
     
    287289                mError  =       true; 
    288290        } 
    289  
    290 } 
    291  
    292 //--------------------------------------------------------------------------- 
     291} 
     292 
     293//------------------------------------------------------------------------- 
    293294//      Read Geometry. 
    294 //--------------------------------------------------------------------------- 
     295//------------------------------------------------------------------------- 
    295296void GeoMeshLoader::readGeometry(FILE   *f, Mesh        *geoMesh, int option) 
    296297{ 
     
    379380} 
    380381 
    381 //--------------------------------------------------------------------------- 
     382//------------------------------------------------------------------------- 
    382383//      Read a submesh operation. 
    383 //--------------------------------------------------------------------------- 
     384//------------------------------------------------------------------------- 
    384385void GeoMeshLoader::readSubMeshOperation(       FILE    *f, 
    385386                                                                                                                                                                        Mesh    *geoMesh, 
     
    403404} 
    404405 
    405 //--------------------------------------------------------------------------- 
     406//------------------------------------------------------------------------- 
    406407//      Read a submesh. 
    407 //--------------------------------------------------------------------------- 
     408//------------------------------------------------------------------------- 
    408409void GeoMeshLoader::readSubMesh(FILE    *f, Mesh        *geoMesh, int option) 
    409410{ 
     
    563564} 
    564565 
    565 //--------------------------------------------------------------------------- 
     566//------------------------------------------------------------------------- 
    566567//      Read a mesh lod information. 
    567 //--------------------------------------------------------------------------- 
     568//------------------------------------------------------------------------- 
    568569void GeoMeshLoader::readMeshLodInfo(FILE        *f, Mesh        *geoMesh) 
    569570{ 
     
    600601} 
    601602 
    602 //--------------------------------------------------------------------------- 
     603//------------------------------------------------------------------------- 
    603604//      Read a submesh name table. 
    604 //--------------------------------------------------------------------------- 
     605//------------------------------------------------------------------------- 
    605606void GeoMeshLoader::readSubMeshNameTable(FILE   *f, Mesh        *geoMesh) 
    606607{ 
     
    639640} 
    640641 
    641 //--------------------------------------------------------------------------- 
     642//------------------------------------------------------------------------- 
    642643//      Read a mesh file. 
    643 //--------------------------------------------------------------------------- 
     644//------------------------------------------------------------------------- 
    644645 
    645646#include "GeoLodStripsLibrary.h" 
     
    869870 
    870871 
    871 //--------------------------------------------------------------------------- 
     872//------------------------------------------------------------------------- 
    872873//      Allocate memory to the array of strips 
    873 //--------------------------------------------------------------------------- 
     874//------------------------------------------------------------------------- 
    874875SubMesh* GeoMeshLoader::BuildStripsGeoSubMesh(SubMesh* geoSubMesh) 
    875876{ 
     
    969970} 
    970971 
    971 //--------------------------------------------------------------------------- 
     972//------------------------------------------------------------------------- 
    972973//      Remove degenerate triangles of a submesh given. 
    973 //--------------------------------------------------------------------------- 
     974//------------------------------------------------------------------------- 
    974975SubMesh *       GeoMeshLoader::removeDegenerateTriangles(SubMesh        *geoSubMesh) 
    975976{ 
     
    10741075} 
    10751076 
    1076 //--------------------------------------------------------------------------- 
     1077//------------------------------------------------------------------------- 
    10771078//      Loads a mesh. 
    1078 //--------------------------------------------------------------------------- 
     1079//------------------------------------------------------------------------- 
    10791080Mesh* GeoMeshLoader::load(char  *nameFileMesh)  
    10801081{ 
     
    10831084        char            version[255]; 
    10841085        FILE            *pFile; 
    1085         SubMesh         *geosubmesh; 
     1086        SubMesh *geosubmesh; 
    10861087 
    10871088        //      Debug. 
     
    11061107         
    11071108        geoMesh =       NULL; 
     1109 
    11081110        if (lodstripsdata) 
     1111        { 
    11091112                delete lodstripsdata; 
    1110         lodstripsdata=NULL; 
     1113        } 
     1114 
     1115        lodstripsdata   =       NULL; 
    11111116 
    11121117        if (treesimpseq) 
     1118        { 
    11131119                delete treesimpseq; 
    1114         treesimpseq=NULL; 
     1120        } 
     1121 
     1122        treesimpseq     =       NULL; 
    11151123 
    11161124        //      Open the mesh file. 
     
    11251133                geoMesh =       new     Mesh(); 
    11261134 
    1127                 if (fileExt==std::string("OBJ")) 
     1135                if (fileExt == std::string("OBJ")) 
    11281136                { 
    11291137                        mError  =       false; 
     
    11551163 
    11561164                                cout    <<      version <<      endl; 
    1157  
    1158                                 /*if (strcmp(version,"[MeshSerializer_v1.30]\n")) 
    1159                                 { 
    1160                                         //      Debug. 
    1161                                         cout    <<      "Error: Wrong mesh version." 
    1162                                                 <<      endl 
    1163                                                 <<      "Only version 1.3 or older allowed." 
    1164                                                 <<      endl; 
    1165  
    1166                                         //      Error. 
    1167                                         mError  =       true; 
    1168                                 }*/ 
    11691165 
    11701166                                while(!feof(pFile)) 
     
    12401236} 
    12411237 
    1242 //--------------------------------------------------------------------------- 
     1238//------------------------------------------------------------------------- 
    12431239//      Sets coords between -1 and 1. 
    1244 //--------------------------------------------------------------------------- 
     1240//------------------------------------------------------------------------- 
    12451241void    GeoMeshLoader::normalizeModel(Mesh      *geoMesh) 
    12461242{ 
     
    13901386} 
    13911387 
    1392 //--------------------------------------------------------------------------- 
     1388//------------------------------------------------------------------------- 
    13931389//      Get the size in bytes of the file. 
    1394 //--------------------------------------------------------------------------- 
     1390//------------------------------------------------------------------------- 
    13951391size_t  GeoMeshLoader::getFileSize() 
    13961392{ 
     
    13981394} 
    13991395 
    1400 //--------------------------------------------------------------------------- 
     1396//------------------------------------------------------------------------- 
    14011397//      Constructor 
    1402 //--------------------------------------------------------------------------- 
     1398//------------------------------------------------------------------------- 
    14031399GeoMeshLoader::GeoMeshLoader() 
    14041400{ 
     
    14091405} 
    14101406 
    1411 //--------------------------------------------------------------------------- 
     1407//------------------------------------------------------------------------- 
    14121408//      Destroyer. 
    1413 //--------------------------------------------------------------------------- 
     1409//------------------------------------------------------------------------- 
    14141410GeoMeshLoader::~GeoMeshLoader() 
    14151411{ 
     
    14301426} 
    14311427 
    1432 //--------------------------------------------------------------------------- 
     1428//------------------------------------------------------------------------- 
    14331429//      Read bones of the submesh. 
    1434 //--------------------------------------------------------------------------- 
     1430//------------------------------------------------------------------------- 
    14351431void GeoMeshLoader::readSubMeshBoneAssignment(FILE              *f, 
    14361432                                                                                                                                                                                        SubMesh *geoSubMesh, 
     
    14521448} 
    14531449 
    1454 //--------------------------------------------------------------------------- 
     1450//------------------------------------------------------------------------- 
    14551451//      Read bones of the main mesh. 
    1456 //--------------------------------------------------------------------------- 
     1452//------------------------------------------------------------------------- 
    14571453void GeoMeshLoader::readMeshBoneAssignment(FILE *f, Mesh        *geoMesh,       int option) 
    14581454{ 
     
    14721468} 
    14731469 
    1474 //--------------------------------------------------------------------------- 
     1470//------------------------------------------------------------------------- 
    14751471//      Read skeleton link. 
    1476 //--------------------------------------------------------------------------- 
     1472//------------------------------------------------------------------------- 
    14771473void GeoMeshLoader::readSkeletonLink(FILE       *f, Mesh        *geoMesh,       int option) 
    14781474{ 
     
    14901486} 
    14911487 
    1492 //--------------------------------------------------------------------------- 
     1488//------------------------------------------------------------------------- 
    14931489//      Read bounding box settings. 
    1494 //--------------------------------------------------------------------------- 
     1490//------------------------------------------------------------------------- 
    14951491void    GeoMeshLoader::readMeshBounds(FILE      *f, Mesh        *geoMesh,       int     option) 
    14961492{ 
  • GTP/trunk/Lib/Geom/shared/GTGeometry/src/GeoMeshSaver.cpp

    r1526 r2127  
    1 /*========================================================================== 
     1/*======================================================================== 
    22 *      (C) 2005 Universitat Jaume I 
    3  *========================================================================== 
     3 *======================================================================== 
    44 *      PROYECT:        GAME TOOLS 
    5  *==========================================================================*/ 
     5 *=======================================================================*/ 
    66/*      CONTENT:         
    77 * 
    88 * 
    99 *      @file   GeoMeshSaver.cpp 
    10  *==========================================================================*/ 
     10 *=======================================================================*/ 
    1111#include        <GeoMeshSaver.h> 
    1212 
     
    1414using   namespace       std; 
    1515 
    16 //--------------------------------------------------------------------------- 
     16//------------------------------------------------------------------------- 
    1717//              Public: 
    18 //--------------------------------------------------------------------------- 
    19  
    20 //--------------------------------------------------------------------------- 
     18//------------------------------------------------------------------------- 
     19 
     20//------------------------------------------------------------------------- 
    2121//      Constructors. 
    22 //--------------------------------------------------------------------------- 
     22//------------------------------------------------------------------------- 
    2323GeoMeshSaver::GeoMeshSaver() 
    2424{ 
     
    2929} 
    3030 
    31 //--------------------------------------------------------------------------- 
    32 //      Destroyer. 
    33 //--------------------------------------------------------------------------- 
     31//------------------------------------------------------------------------- 
     32//      Destructor. 
     33//------------------------------------------------------------------------- 
    3434GeoMeshSaver::~GeoMeshSaver() 
    3535{ 
     
    3737} 
    3838 
    39 //--------------------------------------------------------------------------- 
     39//------------------------------------------------------------------------- 
    4040//      Saves a Mesh into a file. 
    41 //--------------------------------------------------------------------------- 
     41//------------------------------------------------------------------------- 
    4242size_t  GeoMeshSaver::save(Mesh *geoMesh,       const   char    *fileNameMesh) 
    4343{ 
     
    147147} 
    148148 
    149 //------------------------------------------ 
     149//------------------------------------------------------------------------- 
    150150//              Private: 
    151 //------------------------------------------ 
    152  
     151//------------------------------------------------------------------------- 
     152 
     153//------------------------------------------------------------------------- 
    153154//      Write the main mesh. 
     155//------------------------------------------------------------------------- 
    154156void    GeoMeshSaver::writeMesh(Mesh    *geoMesh) 
    155157{ 
     
    226228}//     End write mesh. 
    227229 
     230//------------------------------------------------------------------------- 
    228231//      Write a submesh. 
     232//------------------------------------------------------------------------- 
    229233void    GeoMeshSaver::writeSubMesh(SubMesh      *geoSubMesh) 
    230234{ 
     
    345349} 
    346350 
     351//------------------------------------------------------------------------- 
    347352//      Write the submesh operation chunk and data. 
     353//------------------------------------------------------------------------- 
    348354void GeoMeshSaver::writeSubMeshOperation(const  SubMesh *geoSubMesh) 
    349355{ 
     
    374380} 
    375381 
     382//------------------------------------------------------------------------- 
    376383//      Write geometry. 
     384//------------------------------------------------------------------------- 
    377385void    GeoMeshSaver::writeGeometry(VertexBuffer        *vertexBuffer) 
    378386{ 
     
    581589} 
    582590 
     591//------------------------------------------------------------------------- 
    583592//      Write Mesh Bounds. 
     593//------------------------------------------------------------------------- 
    584594void    GeoMeshSaver::writeMeshBounds(Mesh      *geoMesh) 
    585595{ 
     
    605615} 
    606616 
     617//------------------------------------------------------------------------- 
    607618//      Calculate the mesh size in bytes. 
     619//------------------------------------------------------------------------- 
    608620size_t GeoMeshSaver::calcMeshSize(const Mesh    *geoMesh) 
    609621{ 
     
    650662} 
    651663 
     664//------------------------------------------------------------------------- 
    652665//      Calc the size in bytes for the submesh. 
     666//------------------------------------------------------------------------- 
    653667size_t GeoMeshSaver::calcSubMeshSize(const SubMesh      *geoSubMesh) 
    654668{ 
     
    677691} 
    678692 
     693//------------------------------------------------------------------------- 
    679694//      Calculate the geometry size in bytes. 
     695//------------------------------------------------------------------------- 
    680696size_t GeoMeshSaver::calcGeometrySize(const VertexBuffer* vertexBuffer) 
    681697{ 
     
    709725} 
    710726 
     727//------------------------------------------------------------------------- 
    711728//      Calculate the skeleton link size in bytes. 
     729//------------------------------------------------------------------------- 
    712730size_t  GeoMeshSaver::calcSkeletonLinkSize(const Mesh   *geoMesh) 
    713731{ 
     
    723741} 
    724742 
     743//------------------------------------------------------------------------- 
    725744//      Write the file header. 
     745//------------------------------------------------------------------------- 
    726746void GeoMeshSaver::writeFileHeader(void) 
    727747{ 
     
    734754} 
    735755 
     756//------------------------------------------------------------------------- 
    736757//      Write a header chunk given. 
     758//------------------------------------------------------------------------- 
    737759void GeoMeshSaver::writeChunkHeader(unsigned short      id, 
    738760                                                                                                                                                unsigned long           size) 
     
    742764} 
    743765 
     766//------------------------------------------------------------------------- 
    744767//      Write integers into the file. 
     768//------------------------------------------------------------------------- 
    745769void    GeoMeshSaver::writeInts(unsigned long   id, 
    746770                                                                                                                        unsigned long   count) 
     
    749773} 
    750774 
     775//------------------------------------------------------------------------- 
    751776//      Write shorts into the file 
     777//------------------------------------------------------------------------- 
    752778void    GeoMeshSaver::writeShorts(unsigned short        id, 
    753779                                                                                                                                unsigned long           count) 
     
    756782} 
    757783 
     784//------------------------------------------------------------------------- 
    758785//      Write float into the file. 
     786//------------------------------------------------------------------------- 
    759787void    GeoMeshSaver::writeFloats(float                                         id, 
    760788                                                                                                                                unsigned long           count) 
     
    763791} 
    764792 
     793//------------------------------------------------------------------------- 
    765794//      Write a string into the file. 
     795//------------------------------------------------------------------------- 
    766796void GeoMeshSaver::writeString(const    String  &string) 
    767797{ 
     
    769799} 
    770800 
     801//------------------------------------------------------------------------- 
    771802//      Write booleans into the file. 
     803//------------------------------------------------------------------------- 
    772804void    GeoMeshSaver::writeBools(       const bool id, 
    773805                                                                                                                                unsigned        long            count) 
     
    776808} 
    777809 
     810//------------------------------------------------------------------------- 
     811//      Write skeleton filename. 
     812//------------------------------------------------------------------------- 
    778813void GeoMeshSaver::writeSkeletonLink(const String& skelName) 
    779814{        
     
    788823} 
    789824 
     825//------------------------------------------------------------------------- 
     826//      Write bones assignmets. 
     827//------------------------------------------------------------------------- 
    790828void GeoMeshSaver::writeMeshBoneAssignment(const VertexBoneAssignment& assign) 
    791829{ 
     
    802840} 
    803841 
     842//------------------------------------------------------------------------- 
     843//      Write bones assignmets. 
     844//------------------------------------------------------------------------- 
    804845void GeoMeshSaver::writeSubMeshBoneAssignment(const VertexBoneAssignment& assign) 
    805846{ 
     
    816857} 
    817858 
     859//------------------------------------------------------------------------- 
    818860//      unnormalize geometry model. 
     861//------------------------------------------------------------------------- 
    819862void    GeoMeshSaver::unnormalizeModel(Mesh     *geoMesh) 
    820863{ 
     
    859902                        continue; 
    860903                } 
    861                          
     904 
    862905                //      For each index of the strip. 
    863906                for (size_t i = 0; i < vertex_buffer->mVertexCount; i++) 
  • GTP/trunk/Lib/Geom/shared/GTGeometry/src/GeoMeshSimplifier.cpp

    r2103 r2127  
    158158        mGeoMesh        =       m_qslim->GetMesh(); 
    159159 
    160         //      Debug. 
    161         cout    <<      "Number of bone assignaments: " 
    162                                 <<      mGeoMesh->mBones.size() 
    163                                 <<      endl; 
    164  
    165         // if the initial mesh had shared vertex, 
    166         // convert the mesh to shared vertex 
    167         //Mesh *sharedMesh = mGeoMesh->toSharedVertex(); 
    168         //delete mGeoMesh; 
    169         //mGeoMesh = sharedMesh; 
    170  
    171         //      Sort bones. 
    172         //sortBones(); 
    173  
    174160        delete  m_qslim; 
    175161} 
     
    191177        mGeoMesh        =       m_qslim->GetMesh(); 
    192178 
    193         // if the initial mesh had shared vertex, 
    194         // convert the mesh to shared vertex 
    195         //Mesh *sharedMesh = mGeoMesh->toSharedVertex(); 
    196         //delete mGeoMesh; 
    197         //mGeoMesh = sharedMesh; 
    198          
    199         //      Sort bones. 
    200         //sortBones(); 
    201          
    202179        delete m_qslim; 
    203180} 
     
    453430                vmi_mesh->vertices[i].y = vertex_buffer->mPosition[i].y; 
    454431                vmi_mesh->vertices[i].z = vertex_buffer->mPosition[i].z; 
    455                  
     432 
    456433                vmi_mesh->vertices[i].numTriangles = 0; 
    457434                vmi_mesh->vertices[i].triangles = NULL; 
     435                vmi_mesh->vertices[i].numEdges = 0; 
     436                vmi_mesh->vertices[i].edges = NULL; 
    458437                vmi_mesh->vertices[i].enable    = GL_TRUE; 
    459438                vmi_mesh->vertices[i].movable = GL_TRUE; 
     
    503482 
    504483                                // Reallocate memory for the new adjacent triangle. 
    505                                 vmi_mesh->vertices[v1].triangles = (GLuint *)realloc(vmi_mesh->vertices[v1].triangles, (vmi_mesh->vertices[v1].numTriangles + 1) * sizeof(GLuint)); 
     484                                vmi_mesh->vertices[v1].triangles = (int *)realloc(vmi_mesh->vertices[v1].triangles, (vmi_mesh->vertices[v1].numTriangles + 1) * sizeof(int)); 
    506485 
    507486                                VMI::addItem(   (int *)vmi_mesh->vertices[v1].triangles, 
     
    548527                        vmi_mesh->edges[n].u                                            =       v1; 
    549528                        vmi_mesh->edges[n].v                                            =       v2; 
    550                         vmi_mesh->edges[n].triangles    = NULL; 
    551                         vmi_mesh->edges[n].numTriangles = 0; 
    552529                        vmi_mesh->edges[n].enable                       =       GL_TRUE; 
    553530 
    554                         // Reallocate memory for the new adjacent triangle 
    555                         vmi_mesh->edges[n].triangles = (GLuint *)realloc(vmi_mesh->edges[n].triangles, (vmi_mesh->edges[n].numTriangles + 1) * sizeof(GLuint)); 
    556  
    557                         // Adding triangle i adjacent to edge n 
    558                         VMI::addItem(   (int *)vmi_mesh->edges[n].triangles, 
    559                                                                                 (int *)&vmi_mesh->edges[n].numTriangles, 
    560                                                                                 i); 
    561  
    562                         // Adding edge n adjacent to triangle i 
    563                         VMI::addItem((int *)vmi_mesh->triangles[i].edges, (int *)&t, n); 
    564531                        n++; 
    565                 } 
    566                 else 
    567                 { 
    568                         // Reallocate memory for the new adjacent triangle. 
    569                         vmi_mesh->edges[e].triangles = (GLuint *)realloc(vmi_mesh->edges[e].triangles, (vmi_mesh->edges[e].numTriangles + 1) * sizeof(GLuint)); 
    570  
    571                         // Adding triangle i adjacent to edge e 
    572                         VMI::addItem(   (int *)vmi_mesh->edges[e].triangles, 
    573                                                                                 (int *)&vmi_mesh->edges[e].numTriangles, 
    574                                                                                 i); 
    575  
    576                         // Adding edge e adjacent to triangle i 
    577                         VMI::addItem((int *)vmi_mesh->triangles[i].edges, (int *)&t, e); 
    578532                } 
    579533 
     
    582536                        vmi_mesh->edges[n].u                                            = v2; 
    583537                        vmi_mesh->edges[n].v                                            = v3; 
    584                         vmi_mesh->edges[n].triangles    = NULL; 
    585                         vmi_mesh->edges[n].numTriangles = 0; 
    586538                        vmi_mesh->edges[n].enable                       = GL_TRUE; 
    587539 
    588                         // Reallocate memory for the new adjacent triangle 
    589                         vmi_mesh->edges[n].triangles = (GLuint *)realloc(vmi_mesh->edges[n].triangles, (vmi_mesh->edges[n].numTriangles + 1) * sizeof(GLuint)); 
    590  
    591                         // Adding triangle i adjacent to edge n 
    592                         VMI::addItem((int *)vmi_mesh->edges[n].triangles, (int *)&vmi_mesh->edges[n].numTriangles, i); 
    593                         vmi_mesh->edges[n].triangles    = NULL; 
    594                         vmi_mesh->edges[n].numTriangles = 0; 
    595  
    596                         // Adding edge n adjacent to triangle i 
    597                         VMI::addItem((int *)vmi_mesh->triangles[i].edges, (int *)&t, n); 
    598540                        n++; 
    599                 } 
    600                 else 
    601                 { 
    602                         // Reallocate memory for the new adjacent triangle 
    603                         vmi_mesh->edges[e].triangles = (GLuint *)realloc(vmi_mesh->edges[e].triangles, (vmi_mesh->edges[e].numTriangles + 1) * sizeof(GLuint)); 
    604  
    605                         // Adding triangle i adjacent to edge e 
    606                         VMI::addItem(   (int *)vmi_mesh->edges[e].triangles, 
    607                                                                                 (int *)&vmi_mesh->edges[e].numTriangles, 
    608                                                                                 i); 
    609  
    610                         // Adding edge e adjacent to triangle i 
    611                         VMI::addItem((int *)vmi_mesh->triangles[i].edges, (int *)&t, e); 
    612541                } 
    613542                 
     
    616545                        vmi_mesh->edges[n].u                                            = v3; 
    617546                        vmi_mesh->edges[n].v                                            = v1; 
    618                         vmi_mesh->edges[n].triangles    = NULL; 
    619                         vmi_mesh->edges[n].numTriangles = 0; 
    620547                        vmi_mesh->edges[n].enable                       = GL_TRUE; 
    621548 
    622                         // Reallocate memory for the new adjacent triangle. 
    623                         vmi_mesh->edges[n].triangles = (GLuint *)realloc(vmi_mesh->edges[n].triangles, (vmi_mesh->edges[n].numTriangles + 1) * sizeof(GLuint)); 
    624  
    625                         // Adding triangle i adjacent to edge n 
    626                         VMI::addItem(   (int *)vmi_mesh->edges[n].triangles, 
    627                                                                                 (int *)&vmi_mesh->edges[n].numTriangles, 
    628                                                                                 i); 
    629  
    630                         // Adding edge n adjacent to triangle i 
    631                         VMI::addItem((int *)vmi_mesh->triangles[i].edges, (int *)&t, n); 
    632549                        n++; 
    633                 } 
    634                 else 
    635                 { 
    636                         // Reallocate memory for the new adjacent triangle 
    637                         vmi_mesh->edges[e].triangles = (GLuint *)realloc(vmi_mesh->edges[e].triangles, (vmi_mesh->edges[e].numTriangles + 1) * sizeof(GLuint)); 
    638  
    639                         // Adding triangle i adjacent to edge e 
    640                         VMI::addItem((int *)vmi_mesh->edges[e].triangles, (int *)&vmi_mesh->edges[e].numTriangles, i); 
    641  
    642                         // Adding edge e adjacent to triangle i 
    643                         VMI::addItem((int *)vmi_mesh->triangles[i].edges, (int *)&t, e); 
    644550                } 
    645551        } 
     
    647553        printf("Ok\n"); 
    648554        vmi_mesh->numEdges = n; 
     555 
     556        for (i=0; i<vmi_mesh->numEdges; i++) { 
     557                v1 = vmi_mesh->edges[i].u; 
     558                v2 = vmi_mesh->edges[i].v; 
     559 
     560                vmi_mesh->vertices[v1].edges =  
     561                        (int *)realloc(vmi_mesh->vertices[v1].edges, (vmi_mesh->vertices[v1].numEdges + 1) * sizeof(int)); 
     562                // Adding edge i adjacent to vertex v1 
     563                VMI::addItem(vmi_mesh->vertices[v1].edges, &vmi_mesh->vertices[v1].numEdges, i); 
     564 
     565                vmi_mesh->vertices[v2].edges =  
     566                        (int *)realloc(vmi_mesh->vertices[v2].edges, (vmi_mesh->vertices[v2].numEdges + 1) * sizeof(int)); 
     567                // Adding edge i adjacent to vertex v2 
     568                VMI::addItem(vmi_mesh->vertices[v2].edges, &vmi_mesh->vertices[v2].numEdges, i); 
     569        } 
    649570 
    650571        //      Creates vertex multimap. 
     
    11331054 
    11341055//------------------------------------------------------------------------- 
    1135 //      Modify the joined vertices sequento to an split. 
    1136 //------------------------------------------------------------------------- 
    1137 MeshSimplificationSequence * 
    1138 TextureConserver::WriteRealSimpSeq(MeshSimplificationSequence *simpseq) 
    1139 { 
    1140         bool    edge_found; 
    1141  
    1142         size_t  v0; 
    1143         size_t  v1; 
    1144         size_t  vertex_count; 
    1145         size_t  i,j; 
    1146  
    1147         VertexBuffer    *mVB; 
    1148         GeoVertex                       new_vertex; 
    1149  
    1150         multimap<int, int>::iterator    lb0; 
    1151         multimap<int, int>::iterator    ub0; 
    1152         multimap<int, int>::iterator    lb1; 
    1153         multimap<int, int>::iterator    ub1; 
    1154         multimap<int, int>::iterator    it0; 
    1155  
    1156         MeshSimplificationSequence                              *real_seq; 
    1157         MeshSimplificationSequence::Step        current_step; 
    1158  
    1159         //      Initialize vertex count. 
    1160         vertex_count    =       mGeoMesh->mVertexBuffer->mVertexCount; 
    1161  
    1162         //      Creates new simplification sequence. 
    1163         real_seq        =       new     MeshSimplificationSequence(); 
    1164  
    1165         //      For each simplification step. 
    1166         for (i = 0; i < simpseq->mSteps.size(); i++) 
    1167         { 
    1168                 lb0     =       mVertices.lower_bound(simpseq->mSteps[i].mV0); 
    1169                 ub0     =       mVertices.upper_bound(simpseq->mSteps[i].mV0); 
    1170                 lb1     =       mVertices.lower_bound(simpseq->mSteps[i].mV1); 
    1171                 ub1     =       mVertices.upper_bound(simpseq->mSteps[i].mV1); 
    1172  
    1173                 //      Removed vertex. 
    1174                 while (lb1 != ub1) 
    1175                 { 
    1176                         //      Real index. 
    1177                         v1      =       (*lb1).second; 
    1178  
    1179                         //      Begin of iteration v0. 
    1180                         it0     =       lb0; 
    1181  
    1182                         edge_found      =       false; 
    1183  
    1184                         //      Remaining vertex. 
    1185                         while (it0 != ub0) 
    1186                         { 
    1187                                 //      Real index. 
    1188                                 v0      =       (*it0).second; 
    1189  
    1190                                 //      If edge exists. 
    1191                                 if (mEdges->exists(v0,v1)) 
    1192                                 { 
    1193                                         mEdges->contract(v1,v0); 
    1194  
    1195                                         //      Simplification sequence. 
    1196                                         current_step.mV0        =       v0; 
    1197                                         current_step.mV1        =       v1; 
    1198  
    1199                                         real_seq->mSteps.push_back(current_step); 
    1200  
    1201                                         edge_found      =       true; 
    1202                                 } 
    1203  
    1204                                 it0++; 
    1205                         } 
    1206  
    1207                         //      If not found a valid edge. 
    1208                         if (!edge_found) 
    1209                         { 
    1210                                 //      Id new vertex. 
    1211                                 new_vertex.id                                   =       vertex_count; 
    1212                                 new_vertex.bonefrom             =       v0; 
    1213  
    1214                                 //      Simplification sequence. 
    1215                                 current_step.mV0        =       new_vertex.id; 
    1216                                 current_step.mV1        =       v1; 
    1217  
    1218                                 real_seq->mSteps.push_back(current_step); 
    1219  
    1220                                 //      Contracts lonely vertex. 
    1221                                 mEdges->contract(v1,new_vertex.id); 
    1222  
    1223                                 //      New vertex adquires position of v0. 
    1224                                 new_vertex.position.x   =       mGeoMesh->mVertexBuffer->mPosition[v0].x; 
    1225                                 new_vertex.position.y   =       mGeoMesh->mVertexBuffer->mPosition[v0].y; 
    1226                                 new_vertex.position.z   =       mGeoMesh->mVertexBuffer->mPosition[v0].z; 
    1227  
    1228                                 //      New vertex adquires normal of lonely one. 
    1229                                 new_vertex.normal.x     =       mGeoMesh->mVertexBuffer->mNormal[v1].x; 
    1230                                 new_vertex.normal.y     =       mGeoMesh->mVertexBuffer->mNormal[v1].y; 
    1231                                 new_vertex.normal.z     =       mGeoMesh->mVertexBuffer->mNormal[v1].z; 
    1232  
    1233                                 //      New vertex adquires the texture cood of the lonely one. 
    1234                                 new_vertex.texcoord.x   =       mGeoMesh->mVertexBuffer->mTexCoords[v1].x; 
    1235                                 new_vertex.texcoord.y   =       mGeoMesh->mVertexBuffer->mTexCoords[v1].y; 
    1236  
    1237                                 //      New vertex stored. 
    1238                                 real_seq->mNewVertices.push_back(new_vertex); 
    1239  
    1240                                 //      New vertex added. 
    1241                                 vertex_count++; 
    1242                         } 
    1243  
    1244                         lb1++; 
    1245                 } 
    1246         } 
    1247  
    1248         //      Assigns new simplification sequence. 
    1249         delete  simpseq; 
    1250  
    1251         return  real_seq; 
    1252         /* 
    1253         //      New vertex buffer to add new vertices. 
    1254         mVB     =       new VertexBuffer(); 
    1255  
    1256         mVB->mPosition  =       new Vector3[vertex_count]; 
    1257         mVB->mNormal            =       new Vector3[vertex_count]; 
    1258         mVB->mTexCoords =       new Vector2[vertex_count]; 
    1259  
    1260         mVB->mVertexInfo        =       mGeoMesh->mVertexBuffer->mVertexInfo; 
    1261  
    1262         //      Copy original vertices. 
    1263         for (i = 0; i < mGeoMesh->mVertexBuffer->mVertexCount; i++) 
    1264         { 
    1265                 mVB->mPosition[i].x     =       mGeoMesh->mVertexBuffer->mPosition[i].x; 
    1266                 mVB->mPosition[i].y     =       mGeoMesh->mVertexBuffer->mPosition[i].y; 
    1267                 mVB->mPosition[i].z     =       mGeoMesh->mVertexBuffer->mPosition[i].z; 
    1268  
    1269                 mVB->mNormal[i].x       =       mGeoMesh->mVertexBuffer->mNormal[i].x; 
    1270                 mVB->mNormal[i].y       =       mGeoMesh->mVertexBuffer->mNormal[i].y; 
    1271                 mVB->mNormal[i].z       =       mGeoMesh->mVertexBuffer->mNormal[i].z; 
    1272  
    1273                 mVB->mTexCoords[i].x    =       mGeoMesh->mVertexBuffer->mTexCoords[i].x; 
    1274                 mVB->mTexCoords[i].y    =       mGeoMesh->mVertexBuffer->mTexCoords[i].y; 
    1275         } 
    1276  
    1277         //      Add new vertices. 
    1278         j       =       mGeoMesh->mVertexBuffer->mVertexCount; 
    1279  
    1280         for (i = 0; i < new_vertices.size(); i++) 
    1281         { 
    1282                 mVB->mPosition[j].x     =       new_vertices[i].position.x; 
    1283                 mVB->mPosition[j].y     =       new_vertices[i].position.y; 
    1284                 mVB->mPosition[j].z     =       new_vertices[i].position.z; 
    1285  
    1286                 mVB->mNormal[j].x       =       new_vertices[i].normal.x; 
    1287                 mVB->mNormal[j].y       =       new_vertices[i].normal.y; 
    1288                 mVB->mNormal[j].z       =       new_vertices[i].normal.z; 
    1289  
    1290                 mVB->mTexCoords[j].x    =       new_vertices[i].texcoord.x; 
    1291                 mVB->mTexCoords[j].y    =       new_vertices[i].texcoord.y; 
    1292         } 
    1293  
    1294         //      Free memory. 
    1295         delete  []mGeoMesh->mVertexBuffer; 
    1296  
    1297         //      Reassigns main vertex buffer with new vertices. 
    1298         mGeoMesh->mVertexBuffer = mVB; 
    1299  
    1300         //      Reassign submesh vertex buffers. 
    1301         for (i = 0; i < mGeoMesh->mSubMeshCount; i++) 
    1302         { 
    1303                 mGeoMesh->mSubMesh[i].mVertexBuffer     =       mVB; 
    1304         } 
    1305         */ 
    1306 } 
    1307  
    1308 //------------------------------------------------------------------------- 
    13091056//      Return  mesh that may have repeated vertices for texture aparence. 
    13101057//------------------------------------------------------------------------- 
  • GTP/trunk/Lib/Geom/shared/GTGeometry/src/libs/vmi/include/camera.h

    r2090 r2127  
    1818} Camera; 
    1919 
    20 extern Camera *loadCameras(GLdouble radius, char* filename, GLuint *numCameras); 
    21 extern void saveCameras(char* filename, Camera *cameras, GLuint numCameras); 
     20extern Camera *loadCameras(GLdouble radius, char* filename, int *numCameras); 
     21extern void saveCameras(char* filename, Camera *cameras, int numCameras); 
    2222extern void copyToCameras(Camera *cameras, int numVertices, GLdouble vertices[][3]); 
    23 extern void setCameraWeights(Camera *cameras, GLuint numCameras, GLdouble *weights); 
    24 extern Camera *setCameras(GLdouble radius, GLuint type, GLuint *numCameras); 
    25 extern void printCameras(Camera *cameras, GLuint numCameras); 
     23extern void setCameraWeights(Camera *cameras, int numCameras, GLdouble *weights); 
     24extern Camera *setCameras(GLdouble radius, int type, int *numCameras); 
     25extern void printCameras(Camera *cameras, int numCameras); 
    2626 
    2727extern void drawSphere(Camera *cameras, GLdouble radius, int slices, int stacks); 
  • GTP/trunk/Lib/Geom/shared/GTGeometry/src/libs/vmi/include/change.h

    r2090 r2127  
    6868        extern void modifyTriangle(Triangle *t, int c, int p); 
    6969        extern int isATriangleToModify(Triangle *t, int c); 
    70         extern Triangle *getTrianglesToModify(Mesh *mesh, Change *c, GLuint *numMod); 
     70        extern Triangle *getTrianglesToModify(Mesh *mesh, Change *c, int *numMod); 
    7171        extern int isATriangleToDelete(Triangle *t, int c, int p); 
    72         extern Triangle *getTrianglesToDelete(Mesh *mesh, Change *c, GLuint *numDel); 
     72        extern Triangle *getTrianglesToDelete(Mesh *mesh, Change *c, int *numDel); 
    7373 
    7474        extern void modifyTriangles(Mesh *mesh, Change *c); 
     
    8585 
    8686        extern void modifyEdges(Mesh *mesh, Change *c); 
    87   extern void deleteEdges(Mesh *mesh, Change *c); 
     87  extern int find(int *edges, int num, int v_); 
     88        extern void updateEdgeAdj(Mesh *mesh, Change *c) ; 
    8889 
    8990        //      Save simplification sequence in Geometry Game Tools format. 
     
    9293        //extern std::map<int, INTVECTOR> inversemap; 
    9394        extern void swap(int *i, int *j); 
    94         extern int hasEdge(Triangle *t, int e); 
    95         extern void getEdges(Triangle *t, Change *c, int *d, int *a); 
     95 
    9696} 
    9797#endif 
  • GTP/trunk/Lib/Geom/shared/GTGeometry/src/libs/vmi/include/color.h

    r2090 r2127  
    1414} Color; 
    1515 
    16 extern Color *initColors(GLuint numColors); 
    17 extern void fillAllColors(Color *colors, GLuint numColors, GLuint begin, GLuint end, GLubyte color); 
    18 extern void setColors(Color *colors, GLuint numPasses, GLuint begin, GLuint end); 
    19 extern void setColors2(Color *colors, GLuint numColors, GLuint begin, GLuint end); 
    20 extern void setColors3(Color *colors, GLuint numColors, GLubyte color); 
    21 extern void setColors4(Color *colors, GLuint numColors); 
    22 extern void viewColors(Color *colors, GLuint numColors); 
     16extern Color *initColors(int numColors); 
     17extern void fillAllColors(Color *colors, int numColors, int begin, int end, GLubyte color); 
     18extern void setColors(Color *colors, int numPasses, int begin, int end); 
     19extern void setColors2(Color *colors, int numColors, int begin, int end); 
     20extern void setColors3(Color *colors, int numColors, GLubyte color); 
     21extern void setColors4(Color *colors, int numColors); 
     22extern void viewColors(Color *colors, int numColors); 
    2323 
    2424} 
  • GTP/trunk/Lib/Geom/shared/GTGeometry/src/libs/vmi/include/global.h

    r2090 r2127  
    6060//#define SALIENCY 
    6161 
     62#define CHECK_LOCAL_INVERSION 
     63 
    6264// Extension added into the filename 
    6365#ifdef KL // Kullback-Leibler 
     
    7375#define EXT "VCS" 
    7476#endif 
    75  
    76 //#define USE_EDGE_ADJACENCY 
    7777 
    7878#define CHECK_OPENGL_ERROR( cmd ) \ 
     
    109109 
    110110extern Camera *cameras; 
    111 extern GLuint numCameras; 
     111extern int numCameras; 
    112112 
    113113extern Color *colors; 
    114114 
    115 extern GLuint **histogram, 
    116               *queries; 
     115extern int **histogram; 
     116extern GLuint *queries; 
    117117 
    118118extern Mesh *mesh; 
     
    122122extern GLdouble  radius; 
    123123extern GLdouble  fov; 
    124 extern GLuint    numDemandedTriangles, 
     124extern int    numDemandedTriangles, 
    125125                 cameraType; 
    126126extern GLboolean bBeQuiet, 
     
    138138extern void init(void); 
    139139 
    140 extern void renderScene(GLuint **histogram, GLuint numCameras); 
    141 extern void renderSceneWin(GLuint **histogram, GLuint numCameras, Change *c); 
     140extern void resetProjectedAreas(int **histogram, int numCameras); 
     141extern void getProjectedAreas(int **histogram, int numCameras); 
     142extern void getProjectedAreasWin(int **histogram, int numCameras, Change *c); 
    142143 
    143144extern void renderGeometry(void); 
     
    150151 
    151152extern void applyHWAcceleration(void); 
     153extern void updateHWAcceleration(Change *c); 
    152154extern void setOrthographicProjection(void); 
    153155extern void resetPerspectiveProjection(void); 
  • GTP/trunk/Lib/Geom/shared/GTGeometry/src/libs/vmi/include/histogram.h

    r2090 r2127  
    1111{ 
    1212 
    13 extern void getSubHistogram(GLuint subHistoGram[][4]); 
    14 extern void copySubHistogram(Color *colors, GLuint *histogram, GLuint begin, GLuint end, GLuint subHistoGram[][4]); 
    15 extern void printHistogram(GLuint histoGram[][4]); 
    16 extern void plotHistogram(GLuint histoGram[][4]); 
     13extern void getSubHistogram(int subHistoGram[][4]); 
     14extern void copySubHistogram(Color *colors, int *histogram, int begin, int end, int subHistoGram[][4]); 
     15extern void printHistogram(int histoGram[][4]); 
     16extern void plotHistogram(int histoGram[][4]); 
    1717 
    18 extern GLuint **initHistogram(GLuint numTriangles, GLuint numCameras); 
    19 extern void deleteHistogram(GLuint **histogram, GLuint numCameras); 
    20 extern void printFullHistogram(GLuint **histogram, GLuint numCameras, GLuint numTriangles); 
    21 extern void getSWHistogram(GLuint *histogram, GLubyte *pixels); 
    22 extern void getSWHistogramWin(GLuint *histogram, GLubyte *pixels, GLfloat min[3], GLfloat max[3], Change *c); 
    23 extern void getSWHistoByOcclusionQuery(Mesh *mesh, Color *colors, GLuint *histogram); 
     18extern int **initHistogram(int numTriangles, int numCameras); 
     19extern void deleteHistogram(int **histogram, int numCameras); 
     20extern void printFullHistogram(int **histogram, int numCameras, int numTriangles); 
     21extern void getSWHistogram(int *histogram, GLubyte *pixels); 
     22extern void getSWHistogramWin(int *histogram, GLubyte *pixels, GLfloat min[3], GLfloat max[3], Change *c); 
     23extern void getSWHistoByOcclusionQuery(Mesh *mesh, Color *colors, int *histogram); 
    2424 
    25 extern void resetSWHistogram(GLuint *histogram, GLuint numTriangles); 
     25extern void resetSWHistogram(int *histogram, int numTriangles); 
    2626extern void getBoundingBox(Change *c, GLfloat min[3], GLfloat max[3]); 
    2727extern void getWindow(GLfloat min[3], GLfloat max[3], int minw[2], int maxw[2]); 
  • GTP/trunk/Lib/Geom/shared/GTGeometry/src/libs/vmi/include/mesh.h

    r2090 r2127  
    77 
    88typedef struct _Vertex { 
    9     GLfloat x, y, z;     // Vertex coordinates 
    10     GLuint numTriangles; // Number of triangles  
    11     GLuint *triangles;   // List of triangles 
     9    float x, y, z;     // Vertex coordinates 
     10    int numTriangles; // Number of triangles  
     11    int *triangles;   // List of triangles 
     12                int numEdges; 
     13          int *edges; 
    1214    int enable; 
    1315                int     movable;        //      If vertex is part of a border. 
     
    1517 
    1618typedef struct _Edge { 
    17     GLuint u, v;         // Edge vertices 
    18     GLuint *triangles;   // Edge triangles 
    19     GLuint numTriangles; // Number of triangles 
     19    int u, v;         // Edge vertices 
    2020    int enable; 
    2121} Edge; 
    2222 
    2323typedef struct _Triangle { 
    24     GLuint              id;         // Triangle id 
    25     GLuint  group;        // Triangle group 
    26                 GLuint          submesh;                // Triangle submesh      
    27     GLuint              indices[3]; // Triangle vertices 
    28     GLuint              edges[3];   // Triangle edges 
    29     GLfloat             normal[3];  // Triangle normal 
    30     GLdouble    area;       // Triangle area 
    31     GLdouble    saliency;   // Triangle saliency 
     24    int         id;         // Triangle id 
     25    int  group;        // Triangle group 
     26                int             submesh;                // Triangle submesh      
     27    int         indices[3]; // Triangle vertices 
     28    float               normal[3];  // Triangle normal 
     29    double      area;       // Triangle area 
     30    double      saliency;   // Triangle saliency 
    3231    int                         enable; 
    3332} Triangle; 
     
    3534typedef struct _Mesh { 
    3635    Vertex *vertices;           // Mesh vertices 
    37     GLuint numVertices;         // Number of vertices 
    38     GLuint currentNumVertices;  // Current number of vertices 
     36    int numVertices;         // Number of vertices 
     37    int currentNumVertices;  // Current number of vertices 
    3938    Edge *edges;                // Mesh edges 
    40     GLuint numEdges;            // Number of edges 
     39    int numEdges;            // Number of edges 
    4140    Triangle *triangles;        // Mesh triangles 
    42     GLuint numTriangles;        // Number of triangles 
    43     GLuint currentNumTriangles; // Current number of triangles 
     41    int numTriangles;        // Number of triangles 
     42    int currentNumTriangles; // Current number of triangles 
    4443} Mesh; 
    4544 
    4645extern GLdouble computeTriangleArea(Vertex *vertices, Triangle *t); 
     46extern double computeEdgeLength(Vertex *vertices, int u, int v); 
    4747extern void computeTriangleNormal(Vertex *vertices, Triangle *t); 
     48extern double computeTriangleVolume(Vertex *vertices, Triangle *t); 
    4849 
    4950extern Vertex *addVertex(Vertex *list, int *n, float x, float y, float z, int *pos); 
    50 extern int findEdge(Edge *e, GLuint num, GLuint _u, GLuint _v); 
     51extern int findEdge(Edge *e, int num, int _u, int _v); 
    5152extern Edge *addEdge(Edge *list, int *n, int u, int v, int *pos); 
    52 extern GLboolean findVertex(GLfloat *vertices, GLuint num, GLfloat x, GLfloat y, GLfloat z, int *pos); 
     53extern GLboolean findVertex(float *vertices, int num, float x, float y, float z, int *pos); 
    5354 
    5455extern Mesh *initMesh(GLMmodel* pmodel); 
     
    5657extern void printMesh(Mesh *mesh); 
    5758extern void saveModel(char *filename, GLMmodel* pmodel, Mesh *mesh); 
    58 extern void updateModel(GLMmodel* pmodel, Mesh *mesh, GLuint numVertices, GLuint numTriangles); 
     59extern void updateModel(GLMmodel* pmodel, Mesh *mesh, int numVertices, int numTriangles); 
    5960 
    6061extern int *trianglesAdjToEdge(Mesh *mesh, int e, int *n); 
    6162extern int *verticesAdjToVertex(Mesh *mesh, int v, int *n); 
    62 extern int *edgesAdjToVertex(Mesh *mesh, int v, int *n); 
    6363extern int *edgesAdjToVertices(Mesh *mesh, int *vertices, int numVertices, int *n); 
    6464 
  • GTP/trunk/Lib/Geom/shared/GTGeometry/src/libs/vmi/include/metrics.h

    r2090 r2127  
    88namespace       VMI 
    99{ 
    10 extern GLdouble computeMI(Mesh *mesh, GLuint **histogram, GLuint numCameras, GLuint cam); 
    11 extern GLdouble decMI(GLdouble I, GLuint **histogram, GLuint numCameras, GLuint cam, Change *c); 
    12 extern GLdouble incMI(GLdouble I, GLuint **histogram, GLuint numCameras, GLuint cam, Change *c); 
     10extern GLdouble computeMI(Mesh *mesh, int **histogram, int numCameras, int cam); 
     11extern GLdouble decMI(GLdouble I, int **histogram, int numCameras, int cam, Change *c); 
     12extern GLdouble incMI(GLdouble I, int **histogram, int numCameras, int cam, Change *c); 
    1313 
    14 extern GLdouble computeHE(Mesh *mesh, GLuint *histogram); 
    15 extern GLdouble computeKL(Mesh *mesh, GLuint *histogram); 
    16 extern GLdouble computeCS(Mesh *mesh, GLuint *histogram); 
     14extern GLdouble computeHE(Mesh *mesh, int *histogram); 
     15extern GLdouble computeKL(Mesh *mesh, int *histogram); 
     16extern GLdouble computeCS(Mesh *mesh, int *histogram); 
    1717 
    18 extern GLdouble computeMeanProjArea(GLuint **histogram, GLuint numCameras, int t); 
    19 extern GLdouble computeJS(GLuint **histogram, GLuint numCameras, GLuint j, GLuint k); 
    20 extern GLdouble computeEntropy(GLuint **histogram, GLuint numCameras, GLuint k); 
    21 extern GLdouble computeMixedEntropy(GLdouble *mixed, GLuint numCameras); 
    22 extern GLdouble computeMeanProjAreaNoBG(GLuint **histogram, GLuint numCameras, int t); 
     18extern GLdouble computeMeanProjArea(int **histogram, int numCameras, int t); 
     19extern GLdouble computeJS(int **histogram, int numCameras, int j, int k); 
     20extern GLdouble computeEntropy(int **histogram, int numCameras, int k); 
     21extern GLdouble computeMixedEntropy(GLdouble *mixed, int numCameras); 
     22extern GLdouble computeMeanProjAreaNoBG(int **histogram, int numCameras, int t); 
    2323 
    24 extern void getProjectedAreas(GLuint **histogram, GLuint numCameras); 
    25 extern void getProjectedAreasWin(GLuint **histogram, GLuint numCameras, Change *c); 
    26 extern void resetProjectedAreas(GLuint **histogram, GLuint numCameras); 
    27  
    28 extern GLdouble *initIs(GLuint numCameras); 
    29 extern void computeCameraIs(GLuint **histogram, GLuint numCameras, GLdouble *mis); 
    30 extern void printIs(GLdouble *mis, GLuint numCameras); 
     24extern GLdouble *initIs(int numCameras); 
     25extern void computeCameraIs(int **histogram, int numCameras, GLdouble *mis); 
     26extern void printIs(GLdouble *mis, int numCameras); 
    3127} 
    3228#endif 
  • GTP/trunk/Lib/Geom/shared/GTGeometry/src/libs/vmi/include/saliency.h

    r2090 r2127  
    1313extern double percentile; 
    1414 
    15 extern void computeSaliency(Mesh *mesh, GLuint **histogram, GLuint numCameras); 
    16 extern void updateTriangleSaliency(Mesh *mesh, GLuint **histogram, GLuint numCameras, int v); 
     15extern void computeSaliency(Mesh *mesh, int **histogram, int numCameras); 
     16extern void updateTriangleSaliency(Mesh *mesh, int **histogram, int numCameras, int v); 
    1717 
    18 extern double computeTriangleSaliency(Mesh *mesh, GLuint **histogram, GLuint numCameras, GLuint k); 
     18extern double computeTriangleSaliency(Mesh *mesh, int **histogram, int numCameras, int k); 
    1919 
    2020extern double computeEdgeSaliency(Mesh *mesh, Change *c, double p); 
  • GTP/trunk/Lib/Geom/shared/GTGeometry/src/libs/vmi/include/simplify.h

    r2090 r2127  
    1919        extern bheap_t *updateHeap(bheap_t *h, Mesh *mesh, Change *c); 
    2020 
    21         extern void simplifyModel(Mesh *mesh, GLuint numDemandedTri); 
     21        extern void simplifyModel(Mesh *mesh, int numDemandedTri); 
    2222 
    2323 
    2424        extern void bh_mydump(Mesh *mesh, bheap_t *h); 
    25         extern GLdouble computeEdgeLength(Vertex *vertices, int u, int v); 
    2625 
    2726        extern void chooseBestEndPoints(Mesh *mesh, int e); 
  • GTP/trunk/Lib/Geom/shared/GTGeometry/src/libs/vmi/include/vmi_simplifier.h

    r983 r2127  
    1313#include "saliency.h" 
    1414#include "simplify.h" 
    15 #include "interleave.h" 
     15#include "buffers.h" 
    1616 
  • GTP/trunk/Lib/Geom/shared/GTGeometry/src/libs/vmi/src/camera.cpp

    r2090 r2127  
    1414//#define DRAW_DEBUG // just for debugging not necessary 
    1515 
    16 Camera *VMI::loadCameras(GLdouble radius, char* filename, GLuint *numCameras) { 
     16Camera *VMI::loadCameras(GLdouble radius, char* filename, int *numCameras) { 
    1717    FILE *fp; 
    1818    Camera *cameras; 
    19     GLuint num, i; 
     19    int num, i; 
    2020    GLfloat eyeX, eyeY, eyeZ, 
    2121        centerX, centerY, centerZ, 
     
    118118} 
    119119 
    120 void VMI::saveCameras(char* filename, Camera *cameras, GLuint numCameras) { 
     120void VMI::saveCameras(char* filename, Camera *cameras, int numCameras) { 
    121121    FILE *fp; 
    122     GLuint i; 
     122    int i; 
    123123 
    124124    if((fp= fopen(filename, "wt"))== NULL) { 
     
    170170} 
    171171 
    172 Camera *VMI::setCameras(GLdouble radius, GLuint type, GLuint *numCameras) { 
     172Camera *VMI::setCameras(GLdouble radius, int type, int *numCameras) { 
    173173    Camera *cameras = NULL; 
    174174 
     
    221221} 
    222222 
    223 void VMI::setCameraWeights(Camera *cameras, GLuint numCameras, GLdouble *weights) { 
    224     GLuint i; 
     223void VMI::setCameraWeights(Camera *cameras, int numCameras, GLdouble *weights) { 
     224    int i; 
    225225 
    226226    for (i = 0; i<numCameras; i++) { 
     
    229229} 
    230230 
    231 void VMI::printCameras(Camera *cameras, GLuint numCameras) { 
    232     GLuint i; 
     231void VMI::printCameras(Camera *cameras, int numCameras) { 
     232    int i; 
    233233     
    234234    printf("\n"); 
  • GTP/trunk/Lib/Geom/shared/GTGeometry/src/libs/vmi/src/change.cpp

    r2090 r2127  
    157157  if (c->numMod > 0) { 
    158158      mesh->vertices[c->v].triangles =  
    159           (GLuint *)realloc(mesh->vertices[c->v].triangles,  
    160           (mesh->vertices[c->v].numTriangles + mesh->vertices[c->u].numTriangles) * sizeof(GLuint)); 
     159          (int *)realloc(mesh->vertices[c->v].triangles,  
     160          (mesh->vertices[c->v].numTriangles + mesh->vertices[c->u].numTriangles) * sizeof(int)); 
    161161  } 
    162162 
     
    193193} 
    194194 
    195 int VMI::hasEdge(Triangle *t, int e) { 
    196     int e0 = t->edges[0], 
    197         e1 = t->edges[1], 
    198         e2 = t->edges[2]; 
    199      
    200     if ((e == e0) || (e == e1) || (e == e2)) return TRUE; 
    201  
    202     return FALSE; 
    203 } 
    204  
    205 void VMI::getEdges(Triangle *t, Change *c, int *l, int *r) { 
    206  
    207     // Default edges 
    208     *l = -1; 
    209     *r = -1; 
    210  
    211     // Set edge l and r 
    212     if ((int)t->edges[0] == c->e) { 
    213         *l = t->edges[1]; 
    214         *r = t->edges[2]; 
    215         if ((int)mesh->edges[*l].u == c->v || (int)mesh->edges[*l].v == c->v) 
    216             swap(l, r); 
    217     } else if ((int)t->edges[1] == c->e) { 
    218         *l = t->edges[0]; 
    219         *r = t->edges[2]; 
    220         if ((int)mesh->edges[*l].u == c->v || (int)mesh->edges[*l].v == c->v) 
    221             swap(l, r); 
    222     } else if ((int)t->edges[2] == c->e) { 
    223         *l = t->edges[0]; 
    224         *r = t->edges[1]; 
    225         if ((int)mesh->edges[*l].u == c->v || (int)mesh->edges[*l].v == c->v) 
    226             swap(l, r); 
    227     } 
    228 } 
    229  
    230195void VMI::swap(int *i, int *j) { 
    231196    int t; 
     
    238203void VMI::deleteTriangles(Mesh *mesh, Change *c) 
    239204{ 
    240             int i, j, t, v; 
    241 #ifdef USE_EDGE_ADJACENCY 
    242     int t1, l, r; 
    243 #endif 
     205          int i, j, t, v; 
    244206     
    245207    for (i=0; i<c->numDel; i++) { 
     
    255217        } 
    256218 
    257 #ifdef USE_EDGE_ADJACENCY 
    258         // Update triangle edge adjancency 
    259         // The modified triangles have to be calculated before 
    260         // Set edge l and r 
    261         getEdges(&c->deleted[i], c, &l, &r); 
    262         //printf("e%d(%d,%d): l:%d r:%d\n", c->e, c->u, c->v, l, r); 
    263         // Find triangle that contains edge l 
    264         for (j=0; j<c->numMod; j++) 
    265             if (hasEdge(&c->modified[j], l)) { 
    266                 // Change edge l by r in the Mesh 
    267                 t1 = c->modified[j].id; 
    268                 //printf("t:%d %d %d %d\n", t1, mesh->triangles[t1].edges[0], mesh->triangles[t1].edges[1] ,mesh->triangles[t1].edges[2]); 
    269                 if (mesh->triangles[t1].edges[0] == (GLuint)l) mesh->triangles[t1].edges[0] = r; 
    270                 if (mesh->triangles[t1].edges[1] == (GLuint)l) mesh->triangles[t1].edges[1] = r; 
    271                 if (mesh->triangles[t1].edges[2] == (GLuint)l) mesh->triangles[t1].edges[2] = r; 
    272                 //printf("t:%d %d %d %d\n", t1, mesh->triangles[t1].edges[0], mesh->triangles[t1].edges[1] ,mesh->triangles[t1].edges[2]); 
    273                 break; 
    274             } 
    275  
    276         // Delete edge l 
    277         if (l != -1) mesh->edges[l].enable = FALSE; 
    278 #endif 
    279219        mesh->triangles[t].enable = FALSE; 
    280220        mesh->currentNumTriangles--; 
     
    301241            addItem((int *)mesh->vertices[v].triangles,(int *)&mesh->vertices[v].numTriangles,t); 
    302242        } 
    303 #ifdef USE_EDGE_ADJACENCY 
    304         // Enable adjacent edges 
    305         for (j=0; j<3; j++) { 
    306             mesh->edges[mesh->triangles[t].edges[j]].enable = TRUE; 
    307         } 
    308 #endif 
     243 
    309244        mesh->triangles[t].enable = TRUE; 
    310245        mesh->currentNumTriangles++; 
     
    312247} 
    313248 
    314 Triangle *VMI::getTrianglesToModify(Mesh *mesh, Change *c, GLuint *numMod) { 
     249Triangle *VMI::getTrianglesToModify(Mesh *mesh, Change *c, int *numMod) { 
    315250  int i, t; 
    316251  Triangle *modified = NULL; 
     
    336271} 
    337272 
    338 Triangle *VMI::getTrianglesToDelete(Mesh *mesh, Change *c, GLuint *numDel) { 
     273Triangle *VMI::getTrianglesToDelete(Mesh *mesh, Change *c, int *numDel) { 
    339274  int i, t; 
    340275  Triangle *deleted = NULL; 
     
    359294} 
    360295 
    361 void VMI::deleteEdges(Mesh *mesh, Change *c) { 
     296void VMI::modifyEdges(Mesh *mesh, Change *c) { 
    362297    int i, e; 
    363 #ifndef USE_EDGE_ADJACENCY 
    364     int n0, n1, n2; 
    365 #else 
    366     int j, u, v; 
    367 #endif 
    368  
    369 #ifdef USE_EDGE_ADJACENCY 
    370     for (i=0; i<c->numDel; i++) { 
     298 
     299        for(i = 0; i < mesh->vertices[c->v].numEdges; i++) { 
    371300         
    372         for (j=0; j<3; j++) { 
    373             e = c->deleted[i].edges[j]; 
    374             if (e != c->e) { 
    375                 u = mesh->edges[e].u; 
    376                 v = mesh->edges[e].v; 
    377                 if (u == c->u || v == c->u) { 
    378                     //printf("%d\n",j); 
    379                     mesh->edges[e].enable = FALSE; 
    380                 } 
    381             } 
    382         } 
    383         //getchar(); 
    384     } 
    385 #else 
    386     for (i=0; i<c->numDel; i++) { 
    387  
    388         n0 = c->deleted[i].indices[0]; 
    389         n1 = c->deleted[i].indices[1]; 
    390         n2 = c->deleted[i].indices[2]; 
    391  
    392         if ((n0 == c->u && n1 != c->v) || (n1 == c->u && n0 != c->v)) { 
    393             e = findEdge(mesh->edges, mesh->numEdges, n0, n1); 
    394  
    395             //printf("a\n"); 
    396             if (e != -1) 
    397                 mesh->edges[e].enable = FALSE; 
    398         } 
    399  
    400         if ((n1 == c->u && n2 != c->v) || (n2 == c->u && n1 != c->v)) { 
    401             e = findEdge(mesh->edges, mesh->numEdges, n1, n2); 
    402              
    403             //printf("b\n"); 
    404             if (e != -1) 
    405                 mesh->edges[e].enable = FALSE; 
    406         } 
    407  
    408         if ((n0 == c->u && n2 != c->v) || (n2 == c->u && n0 != c->v)) { 
    409             e = findEdge(mesh->edges, mesh->numEdges, n0, n2); 
    410              
    411             //printf("c\n"); 
    412             if (e != -1) 
    413                 mesh->edges[e].enable = FALSE; 
    414         } 
    415         //getchar(); 
    416     } 
    417 #endif 
    418 } 
    419  
    420 void VMI::modifyEdges(Mesh *mesh, Change *c) { 
    421     int e, u, v; 
    422      
    423     // Update mesh and heap 
    424     for(e = 0; e < (int)mesh->numEdges; e++) { 
    425          
     301                e = mesh->vertices[c->v].edges[i]; 
     302 
    426303        if (mesh->edges[e].enable == TRUE) { 
    427304             
    428305            // Modify edge 
    429             if ((int)mesh->edges[e].u == c->u) 
     306            if (mesh->edges[e].u == c->u) 
    430307                mesh->edges[e].u = c->v; 
    431308             
    432             if ((int)mesh->edges[e].v == c->u) 
     309            if (mesh->edges[e].v == c->u) 
    433310                mesh->edges[e].v = c->v; 
    434              
    435             // Check edge 
    436             u = mesh->edges[e].u; 
    437             v = mesh->edges[e].v; 
    438              
    439             // if the edge is not valid, we simply delete it 
    440             if ((u == v) ||  
    441                 (u == c->u) || (v == c->u))  
    442                  
    443                 mesh->edges[e].enable = FALSE; 
    444311        } 
    445312    } 
    446313} 
    447314 
     315int VMI::find(int *edges, int num, int v_) { 
     316        int i; 
     317 
     318        int u, v; 
     319 
     320 
     321        for(i=0; i<num; i++) { 
     322 
     323                u = mesh->edges[edges[i]].u; 
     324 
     325                v = mesh->edges[edges[i]].v; 
     326 
     327                if (u == v_ || v == v_) return TRUE; 
     328 
     329        } 
     330 
     331        return FALSE; 
     332} 
     333void VMI::updateEdgeAdj(Mesh *mesh, Change *c) { 
     334        int i; 
     335 
     336        int v, e; 
     337 
     338        mesh->vertices[c->v].edges =  
     339            (int *)realloc(mesh->vertices[c->v].edges,  
     340            (mesh->vertices[c->v].numEdges + mesh->vertices[c->u].numEdges) * sizeof(int)); 
     341 
     342        for (i=0; i<mesh->vertices[c->u].numEdges; i++) { 
     343         
     344                e = mesh->vertices[c->u].edges[i]; 
     345                if (mesh->edges[e].u == c->u) v =mesh->edges[e].v; 
     346                else v = mesh->edges[e].u; 
     347                 
     348                if (!find(mesh->vertices[c->v].edges, mesh->vertices[c->v].numEdges, v)) 
     349                        addItem(mesh->vertices[c->v].edges, &mesh->vertices[c->v].numEdges, e); 
     350                else mesh->edges[e].enable = FALSE; 
     351        } 
     352 
     353        delItem(mesh->vertices[c->v].edges, &mesh->vertices[c->v].numEdges, c->e); 
     354} 
     355 
    448356/////////////////////////////////////////////////////////////////////////////// 
    449357 
    450358// Compute the triangle mesh changes due to a heap node simplification 
    451359void VMI::computeChange(Mesh *mesh, Change *c) { 
    452   GLuint numMod, numDel; 
     360  int numMod, numDel; 
    453361  Triangle *m = getTrianglesToModify(mesh, c, &numMod), 
    454362            *d = getTrianglesToDelete(mesh, c, &numDel); 
  • GTP/trunk/Lib/Geom/shared/GTGeometry/src/libs/vmi/src/color.cpp

    r2090 r2127  
    77using namespace VMI; 
    88 
    9 Color *VMI::initColors(GLuint numColors) { 
     9Color *VMI::initColors(int numColors) { 
    1010    Color *colors; 
    1111 
     
    2525} 
    2626 
    27 void VMI::fillAllColors(Color *colors, GLuint numColors, GLuint begin, GLuint end, GLubyte color) { 
    28     GLuint i; 
     27void VMI::fillAllColors(Color *colors, int numColors, int begin, int end, GLubyte color) { 
     28    int i; 
    2929 
    3030    if (end > numColors) return; 
     
    4040} 
    4141 
    42 void VMI::setColors(Color *colors, GLuint numPasses, GLuint begin, GLuint end) { 
    43     GLuint i, step = numPasses * MAX_NUM_COLORS; 
     42void VMI::setColors(Color *colors, int numPasses, int begin, int end) { 
     43    int i, step = numPasses * MAX_NUM_COLORS; 
    4444    GLubyte r = 1, 
    4545            g = 1, 
     
    8686} 
    8787 
    88 void VMI::setColors2(Color *colors, GLuint numColors, GLuint begin, GLuint end) { 
    89     GLuint i,  
     88void VMI::setColors2(Color *colors, int numColors, int begin, int end) { 
     89    int i,  
    9090        channel = 0, 
    9191        step = (numColors < MAX_NUM_COLORS) ? (MAX_NUM_COLORS / numColors) : 1; 
     
    133133} 
    134134 
    135 void VMI::setColors3(Color *colors, GLuint numColors, GLubyte color) { 
    136     GLuint i; 
     135void VMI::setColors3(Color *colors, int numColors, GLubyte color) { 
     136    int i; 
    137137     
    138138    for (i = 0; i < numColors; i++) { 
     
    148148} 
    149149 
    150 void VMI::setColors4(Color *colors, GLuint numColors) { 
    151     GLuint i, c = 1; 
     150void VMI::setColors4(Color *colors, int numColors) { 
     151    int i, c = 1; 
    152152     
    153153    for (i = 0; i < numColors; i++) { 
     
    164164} 
    165165 
    166 void VMI::viewColors(Color *colors, GLuint numColors) { 
    167     GLuint i; 
     166void VMI::viewColors(Color *colors, int numColors) { 
     167    int i; 
    168168 
    169169    printf("\n"); 
  • GTP/trunk/Lib/Geom/shared/GTGeometry/src/libs/vmi/src/histogram.cpp

    r2090 r2127  
    1414using namespace VMI; 
    1515 
    16 void VMI::printHistogram(GLuint histoGram[][4]) { 
     16void VMI::printHistogram(int histoGram[][4]) { 
    1717    int i; 
    1818    
     
    2323} 
    2424 
    25 void VMI::plotHistogram(GLuint histoGram[][4]) { 
     25void VMI::plotHistogram(int histoGram[][4]) { 
    2626    int i; 
    27     GLuint iLargest = 0;  // Largest histogram value 
     27    int iLargest = 0;  // Largest histogram value 
    2828    GLfloat maxHeight = height / 2.0f; 
    2929         
     
    7272} 
    7373 
    74 GLuint **VMI::initHistogram(GLuint numTriangles, GLuint numCameras) { 
    75     GLuint i; 
    76     GLuint **histogram; 
    77  
    78     histogram = (GLuint **)malloc(sizeof(GLuint *) * numCameras); 
     74int **VMI::initHistogram(int numTriangles, int numCameras) { 
     75    int i; 
     76    int **histogram; 
     77 
     78    histogram = (int **)malloc(sizeof(int *) * numCameras); 
    7979 
    8080    if (histogram == NULL) { 
     
    8484 
    8585    for (i=0; i<numCameras; i++) 
    86     histogram[i] = (GLuint *)malloc(sizeof(GLuint) * (numTriangles + 1)); // + 1 because the last is the numPixels of the background 
     86    histogram[i] = (int *)malloc(sizeof(int) * (numTriangles + 1)); // + 1 because the last is the numPixels of the background 
    8787 
    8888    // Fill the histogram buffer with 0 
    8989    for (i=0; i<numCameras; i++) 
    90     memset(histogram[i], 0, sizeof(GLuint) * (numTriangles + 1)); 
     90    memset(histogram[i], 0, sizeof(int) * (numTriangles + 1)); 
    9191 
    9292    return histogram; 
    9393} 
    9494 
    95 void VMI::deleteHistogram(GLuint **histogram, GLuint numCameras) { 
    96     GLuint i; 
     95void VMI::deleteHistogram(int **histogram, int numCameras) { 
     96    int i; 
    9797     
    9898    for (i=0;i<numCameras;i++) 
     
    102102} 
    103103 
    104 void VMI::printFullHistogram(GLuint **histogram, GLuint numCameras, GLuint numTriangles) { 
    105     GLuint i, j; 
     104void VMI::printFullHistogram(int **histogram, int numCameras, int numTriangles) { 
     105    int i, j; 
    106106     
    107107    printf("\n"); 
     
    116116} 
    117117 
    118 void VMI::getSubHistogram(GLuint subHistoGram[][4]) { 
     118void VMI::getSubHistogram(int subHistoGram[][4]) { 
    119119    //printf("Computing histogram...\n"); 
    120120    // Define the histogram 
     
    137137} 
    138138 
    139 void VMI::copySubHistogram(Color *colors, GLuint *histogram, GLuint begin, GLuint end, GLuint subHistoGram[][4]) { 
    140     GLuint i; 
     139void VMI::copySubHistogram(Color *colors, int *histogram, int begin, int end, int subHistoGram[][4]) { 
     140    int i; 
    141141    GLubyte r, g, b, a; 
    142     GLuint h = 0; 
     142    int h = 0; 
    143143 
    144144    for (i=begin; i<end; i++) { 
     
    165165} 
    166166 
    167 void VMI::getSWHistogram(GLuint *histogram, GLubyte *pixels) { 
     167void VMI::getSWHistogram(int *histogram, GLubyte *pixels) { 
    168168    GLubyte r, g, b, a; 
    169     GLuint i, t, p, numPixels = width * height; 
     169    int i, t, p, numPixels = width * height; 
    170170 
    171171    glReadPixels(0, 0, width, height, GL_RGBA, GL_UNSIGNED_BYTE, pixels); 
     
    188188 
    189189void VMI::getBoundingBox(Change *c, GLfloat min[3], GLfloat max[3]) { 
    190     GLuint  i, j, t, v; 
     190    int  i, j, t, v; 
    191191    GLfloat maxx = 0.0f, minx = 0.0f,  
    192192            maxy = 0.0f, miny = 0.0f, 
     
    194194     
    195195    /* get the max/mins */ 
    196     for (i=0; i<(GLuint)c->numMod; i++) { 
     196    for (i=0; i<c->numMod; i++) { 
    197197        t = c->modified[i].id; 
    198198         
     
    217217    } 
    218218 
    219     for (i=0; i<(GLuint)c->numDel; i++) { 
     219    for (i=0; i<c->numDel; i++) { 
    220220        t = c->deleted[i].id; 
    221221         
     
    322322} 
    323323 
    324 void VMI::getSWHistogramWin(GLuint *histogram, GLubyte *pixels, GLfloat min[3], GLfloat max[3], Change *c) { 
     324void VMI::getSWHistogramWin(int *histogram, GLubyte *pixels, GLfloat min[3], GLfloat max[3], Change *c) { 
    325325    GLubyte r, g, b, a; 
    326     GLuint i, t, p, numPixels, 
    327           *histoAux = (GLuint *)calloc(mesh->numTriangles + 1, sizeof(GLuint)); 
     326    int i, t, p, numPixels, 
     327          *histoAux = (int *)calloc(mesh->numTriangles + 1, sizeof(int)); 
    328328    GLint minw[2], maxw[2], ox, oy, h, w; 
    329329 
     
    369369    } 
    370370 
    371     for (i=0; i<(GLuint)c->numMod; i++) { 
    372         t = (GLuint)c->modified[i].id; 
     371    for (i=0; i<c->numMod; i++) { 
     372        t = c->modified[i].id; 
    373373 
    374374        histogram[t + 1] = histoAux[t + 1];  
     
    379379} 
    380380 
    381 void VMI::getSWHistoByOcclusionQuery(Mesh *mesh, Color *colors, GLuint *histogram) { 
    382     GLuint i, v1, v2, v3; 
     381void VMI::getSWHistoByOcclusionQuery(Mesh *mesh, Color *colors, int *histogram) { 
     382    int i, v1, v2, v3; 
    383383    GLint area, totalArea = 0; 
    384384 
     
    432432} 
    433433 
    434 void VMI::resetSWHistogram(GLuint *histogram, GLuint numTriangles) { 
     434void VMI::resetSWHistogram(int *histogram, int numTriangles) { 
    435435 
    436436    // Fill the histogram buffer with 0 
    437     memset(histogram, 0, sizeof(GLuint) * (numTriangles + 1)); 
    438 } 
     437    memset(histogram, 0, sizeof(int) * (numTriangles + 1)); 
     438} 
  • GTP/trunk/Lib/Geom/shared/GTGeometry/src/libs/vmi/src/main.cpp

    r2090 r2127  
    88 
    99Camera *cameras = NULL; 
    10 GLuint numCameras = 0; 
     10int numCameras = 0; 
    1111 
    1212Color *colors = NULL; 
    1313 
    14 GLuint **histogram = NULL, 
    15         *queries = NULL; 
     14int **histogram = NULL; 
     15GLuint *queries = NULL; 
    1616 
    1717Mesh *mesh = NULL; 
     
    2828          bRemoveRedundantVertices = GL_TRUE; 
    2929 
    30 GLuint cameraType = 0, 
     30int cameraType = 0, 
    3131       numDemandedTriangles = 0; 
    3232 
     
    174174} 
    175175 
     176void VMI::updateHWAcceleration(Change *c) { 
     177    
     178#ifdef VERTEX_ARRAY_INTERLEAVE 
     179    if (interleave != NULL) free(interleave); 
     180    interleave = setupInterleave(mesh, colors); 
     181#endif 
     182#ifdef VERTEX_ARRAY 
     183    updateVertexArray(mesh, c); 
     184#endif 
     185#ifdef VERTEX_BUFFER_OBJECTS 
     186    updateVertexBufferObjects(mesh, c); 
     187#endif 
     188 
     189} 
     190 
    176191void VMI::setOrthographicProjection(void) { 
    177192    // Switch to projection mode 
     
    208223void VMI::renderGeometry(void) { 
    209224#ifdef IMMEDIATE_MODE 
    210     GLuint i, v1, v2, v3; 
     225    int i, v1, v2, v3; 
    211226 
    212227    // Immediate mode 
     
    228243#else 
    229244#ifdef VERTEX_ARRAY 
    230     glDrawArrays(GL_TRIANGLES, 0, mesh->currentNumTriangles * 3); 
     245    glDrawArrays(GL_TRIANGLES, 0, mesh->numTriangles * 3); 
    231246#endif 
    232247#ifdef VERTEX_ARRAY_INTERLEAVE 
     
    235250#endif 
    236251#ifdef VERTEX_BUFFER_OBJECTS 
    237     glDrawArrays(GL_TRIANGLES, 0, mesh->currentNumTriangles * 3); 
     252    glDrawArrays(GL_TRIANGLES, 0, mesh->numTriangles * 3); 
    238253#endif 
    239254 
     
    264279    glutSwapBuffers(); 
    265280} 
    266 void VMI::renderScene(GLuint **histogram, GLuint numCameras) 
    267 { 
    268     GLuint i; 
     281 
     282void VMI::resetProjectedAreas(int **histogram, int numCameras) { 
     283    int i = 0; 
     284 
     285    // Reset the projected areas for all cameras 
     286    for (i=0; i<numCameras; i++) 
     287        resetSWHistogram(histogram[i], mesh->numTriangles); 
     288} 
     289 
     290void VMI::getProjectedAreas(int **histogram, int numCameras) 
     291{ 
     292    int i; 
    269293 
    270294    // draw to the frame buffer 
    271295    glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, fb); 
    272          
    273     // Apply HW acceleration OpenGL Technique 
    274     applyHWAcceleration();  
    275  
    276     glDrawBuffer(GL_BACK); 
    277     glReadBuffer(GL_BACK); 
     296 
     297    //glDrawBuffer(GL_BACK); 
     298    //glReadBuffer(GL_BACK); 
    278299 
    279300    // Get the projected areas for all cameras 
     
    312333    /////////////////////////////////////////////////////////////////////////// 
    313334} 
    314 void VMI::renderSceneWin(GLuint **histogram, GLuint numCameras, Change *c) 
    315 { 
    316     GLuint i, j, t, background; 
     335void VMI::getProjectedAreasWin(int **histogram, int numCameras, Change *c) 
     336{ 
     337    int i, j, t, background; 
    317338    int del_area, mod_area; 
    318339    GLfloat min[3], max[3]; 
     
    325346    //printf("\n(%f,%f,%f)-(%f,%f,%f)\n", min[0], min[1], min[2], max[0], max[1], max[2]); 
    326347     
    327     // Apply HW acceleration OpenGL Technique 
    328     applyHWAcceleration();  
    329  
    330     glDrawBuffer(GL_BACK); 
    331     glReadBuffer(GL_BACK); 
     348    // Update HW acceleration OpenGL Technique 
     349    updateHWAcceleration(c); 
     350 
     351    //glDrawBuffer(GL_BACK); 
     352    //glReadBuffer(GL_BACK); 
    332353 
    333354    // Get the projected areas for all cameras 
     
    355376        mod_area = 0; 
    356377 
    357         for (j=0; j<( GLuint)c->numDel; j++) { 
     378        for (j=0; j<c->numDel; j++) { 
    358379            t = c->deleted[j].id; 
    359380            del_area += histogram[i][t + 1]; 
     
    362383        } 
    363384 
    364         for (j=0; j<( GLuint)c->numMod; j++) { 
     385        for (j=0; j<c->numMod; j++) { 
    365386            t = c->modified[j].id; 
    366387            del_area += histogram[i][t + 1]; 
     
    371392        getSWHistogramWin(histogram[i], pixels, min, max, c);  
    372393 
    373         for (j=0; j<( GLuint)c->numMod; j++) { 
     394        for (j=0; j<c->numMod; j++) { 
    374395            t = c->modified[j].id; 
    375396            mod_area += histogram[i][t + 1]; 
     
    425446     
    426447    glDeleteBuffersARB(1, &color_buf); 
     448 
     449    //free(pbuf_vertices); 
     450    //free(pbuf_colors); 
     451 
     452                buf_vertices = NULL; 
     453    buf_colors = NULL; 
     454 
     455#endif 
     456#ifdef VERTEX_ARRAY 
     457    //free(pbuf_vertices); 
     458    //free(pbuf_colors); 
     459 
     460                buf_vertices = NULL; 
     461    buf_colors = NULL; 
    427462#endif 
    428463 
     
    457492 
    458493        start = clock(); 
     494 
     495        // Apply HW acceleration OpenGL Technique 
     496  applyHWAcceleration(); 
    459497 
    460498        getProjectedAreas(histogram, numCameras); 
  • GTP/trunk/Lib/Geom/shared/GTGeometry/src/libs/vmi/src/mesh.cpp

    r2090 r2127  
    5353/////////////////////////////////////////////////////////////////////////////// 
    5454 
    55 int VMI::findEdge(Edge *e, GLuint num, GLuint _u, GLuint _v) { 
    56     GLuint i, u, v; 
     55int VMI::findEdge(Edge *e, int num, int _u, int _v) { 
     56    int i, u, v; 
    5757    int found = -1;  
    5858 
     
    8585                newList[*n].u = u; 
    8686    newList[*n].v = v; 
    87  
    88                 // This edge has no triangle adjancency 
    89                 newList[*n].numTriangles = 0; 
    90                 newList[*n].triangles = NULL; 
    9187                 
    9288                // Enable the new edge 
     
    10298} 
    10399 
     100double VMI::computeEdgeLength(Vertex *vertices, int u, int v) { 
     101    float ux, uy, uz, vx, vy ,vz, rx, ry, rz; 
     102     
     103    ux = vertices[u].x; 
     104    uy = vertices[u].y; 
     105    uz = vertices[u].z; 
     106 
     107    vx = vertices[v].x; 
     108    vy = vertices[v].y; 
     109    vz = vertices[v].z; 
     110 
     111    rx = ux - vx; 
     112    ry = uy - vy; 
     113    rz = uz - vz; 
     114 
     115    return sqrt((rx * rx) + (ry * ry) + (rz * rz)); 
     116} 
     117 
     118double VMI::computeTriangleVolume(Vertex *vertices, Triangle *t) { 
     119    int i; 
     120    double m[3][3], vol; 
     121     
     122    // Compute triangle Volume 
     123    i = t->indices[0]; 
     124    m[0][0] = mesh->vertices[i].x; 
     125    m[0][1] = mesh->vertices[i].y; 
     126    m[0][2] = mesh->vertices[i].z; 
     127     
     128    i = t->indices[1]; 
     129    m[1][0] = mesh->vertices[i].x; 
     130    m[1][1] = mesh->vertices[i].y; 
     131    m[1][2] = mesh->vertices[i].z; 
     132 
     133    i = t->indices[2]; 
     134    m[2][0] = mesh->vertices[i].x; 
     135    m[2][1] = mesh->vertices[i].y; 
     136    m[2][2] = mesh->vertices[i].z; 
     137     
     138    vol = computeMatDet(m); 
     139     
     140    //printf("Triangle Volume: %f\n", vol) 
     141    return vol;   
     142} 
     143 
    104144GLdouble VMI::computeTriangleArea(Vertex *vertices, Triangle *t) { 
    105     GLuint i; 
     145    int i; 
    106146    GLdouble v0[3], v1[3], v2[3], a; 
    107147     
     
    129169 
    130170void VMI::computeTriangleNormal(Vertex *vertices, Triangle *t) { 
    131     GLuint i; 
     171    int i; 
    132172    GLfloat x0, y0, z0, 
    133173            x1, y1, z1, 
     
    175215Mesh *VMI::initMesh(GLMmodel* pmodel) { 
    176216 
    177     GLuint i, j, curGroup, v1, v2, v3, n, m, t; 
     217    int i, j, curGroup, v1, v2, v3, n, m, t; 
    178218    int e; 
    179219    Mesh *mesh; 
     
    202242     
    203243    printf("Adding vertices..."); 
    204     for (i=1; i<=pmodel->numvertices; i++) { // Vertices start at 1 
     244    for (i=1; i<=(int)pmodel->numvertices; i++) { // Vertices start at 1 
    205245        mesh->vertices[i - 1].x = pmodel->vertices[3 * i + 0]; 
    206246        mesh->vertices[i - 1].y = pmodel->vertices[3 * i + 1]; 
     
    208248        mesh->vertices[i - 1].numTriangles = 0; 
    209249        mesh->vertices[i - 1].triangles = NULL; 
     250                                mesh->vertices[i - 1].numEdges = 0; 
     251        mesh->vertices[i - 1].edges = NULL; 
    210252        mesh->vertices[i - 1].enable = GL_TRUE; 
    211253    } 
     
    221263    while(group) { 
    222264         
    223         for (i=0; i<group->numtriangles; i++) { 
     265        for (i=0; i<(int)group->numtriangles; i++) { 
    224266             
    225267            t = group->triangles[i]; 
     
    244286                // Reallocate memory for the new adjacent triangle 
    245287                mesh->vertices[v1].triangles =  
    246                                         (GLuint *)realloc(mesh->vertices[v1].triangles, (mesh->vertices[v1].numTriangles + 1) * sizeof(GLuint)); 
     288                                        (int *)realloc(mesh->vertices[v1].triangles, (mesh->vertices[v1].numTriangles + 1) * sizeof(int)); 
    247289                addItem((int *)mesh->vertices[v1].triangles, (int *)&mesh->vertices[v1].numTriangles, t); 
    248290            } 
     
    254296    for (i=0; i<pmodel->numtriangles; i++) { 
    255297        mesh->triangles[i].id = i; 
    256         mesh->triangles[i].indices[0] = pmodel->triangles[i].vindices[0] - 1; 
    257         mesh->triangles[i].indices[1] = pmodel->triangles[i].vindices[1] - 1; 
    258         mesh->triangles[i].indices[2] = pmodel->triangles[i].vindices[2] - 1; 
     298        mesh->triangles[i].indices[0] = (int)pmodel->triangles[i].vindices[0] - 1; 
     299        mesh->triangles[i].indices[1] = (int)pmodel->triangles[i].vindices[1] - 1; 
     300        mesh->triangles[i].indices[2] = (int)pmodel->triangles[i].vindices[2] - 1; 
    259301        mesh->triangles[i].area = computeTriangleArea(mesh->vertices, &mesh->triangles[i]); 
    260302        //printf("\n%d a: %f",i , mesh->triangles[i].area); 
     
    271313            // Reallocate memory for the new adjacent triangle 
    272314            mesh->vertices[v1].triangles =  
    273                             (GLuint *)realloc(mesh->vertices[v1].triangles, (mesh->vertices[v1].numTriangles + 1) * sizeof(GLuint)); 
     315                            (int *)realloc(mesh->vertices[v1].triangles, (mesh->vertices[v1].numTriangles + 1) * sizeof(int)); 
    274316            addItem((int *)mesh->vertices[v1].triangles, (int *)&mesh->vertices[v1].numTriangles, i); 
    275317        } 
     
    304346            mesh->edges[n].u = v1; 
    305347            mesh->edges[n].v = v2; 
    306                                                 mesh->edges[n].triangles    = NULL; 
    307                         mesh->edges[n].numTriangles = 0; 
    308348            mesh->edges[n].enable = GL_TRUE; 
    309349            m = n; 
    310350            n++; 
    311351        } else m = e; 
    312                 // Reallocate memory for the new adjacent triangle 
    313         mesh->edges[m].triangles =  
    314                         (GLuint *)realloc(mesh->edges[m].triangles, (mesh->edges[m].numTriangles + 1) * sizeof(GLuint)); 
    315         // Adding triangle i adjacent to edge m 
    316         addItem((int *)mesh->edges[m].triangles, (int *)&mesh->edges[m].numTriangles, i); 
    317         //printf("n:%d i:%d\n", m, i); 
    318          
    319         // Adding edge m adjacent to triangle i 
    320         addItem((int *)mesh->triangles[i].edges, (int *)&t, m); 
    321352 
    322353        ///////////////////////////////////////////////////////////////////////////////// 
     
    325356            mesh->edges[n].u = v2; 
    326357            mesh->edges[n].v = v3; 
    327                                                 mesh->edges[n].triangles    = NULL; 
    328                         mesh->edges[n].numTriangles = 0; 
    329358            mesh->edges[n].enable = GL_TRUE; 
    330359            m = n; 
    331360            n++; 
    332361        } else m = e; 
    333                 // Reallocate memory for the new adjacent triangle 
    334         mesh->edges[m].triangles =  
    335                         (GLuint *)realloc(mesh->edges[m].triangles, (mesh->edges[m].numTriangles + 1) * sizeof(GLuint)); 
    336         // Adding triangle i adjacent to edge m 
    337         addItem((int *)mesh->edges[m].triangles, (int *)&mesh->edges[m].numTriangles, i); 
    338         //printf("n:%d i:%d\n", m, i); 
    339          
    340         // Adding edge m adjacent to triangle i 
    341         addItem((int *)mesh->triangles[i].edges, (int *)&t, m); 
    342362 
    343363        ///////////////////////////////////////////////////////////////////////////////// 
     
    346366            mesh->edges[n].u = v3; 
    347367            mesh->edges[n].v = v1; 
    348                                                 mesh->edges[n].triangles    = NULL; 
    349                         mesh->edges[n].numTriangles = 0; 
    350368            mesh->edges[n].enable = GL_TRUE; 
    351369            m = n; 
    352370            n++; 
    353371        } else m = e; 
    354                 // Reallocate memory for the new adjacent triangle 
    355         mesh->edges[m].triangles =  
    356                         (GLuint *)realloc(mesh->edges[m].triangles, (mesh->edges[m].numTriangles + 1) * sizeof(GLuint)); 
    357         // Adding triangle i adjacent to edge m 
    358         addItem((int *)mesh->edges[m].triangles, (int *)&mesh->edges[m].numTriangles, i); 
    359         //printf("n:%d i:%d\n", m, i); 
    360          
    361         // Adding edge m adjacent to triangle i 
    362         addItem((int *)mesh->triangles[i].edges, (int *)&t, m); 
    363372    } 
    364373    printf("Ok\n"); 
    365374    mesh->numEdges = n; 
    366375 
     376                for (i=0; i<mesh->numEdges; i++) { 
     377                        v1 = mesh->edges[i].u; 
     378                        v2 = mesh->edges[i].v; 
     379 
     380                        mesh->vertices[v1].edges =  
     381                                (int *)realloc(mesh->vertices[v1].edges, (mesh->vertices[v1].numEdges + 1) * sizeof(int)); 
     382                        // Adding edge i adjacent to vertex v1 
     383                        addItem(mesh->vertices[v1].edges, &mesh->vertices[v1].numEdges, i); 
     384 
     385                        mesh->vertices[v2].edges =  
     386                                (int *)realloc(mesh->vertices[v2].edges, (mesh->vertices[v2].numEdges + 1) * sizeof(int)); 
     387                        // Adding edge i adjacent to vertex v2 
     388                        addItem(mesh->vertices[v2].edges, &mesh->vertices[v2].numEdges, i); 
     389                } 
     390 
    367391    return mesh; 
    368392} 
    369393 
    370394void VMI::printMesh(Mesh *mesh) { 
    371     GLuint i, j; 
     395    int i, j; 
    372396 
    373397    printf("Vertices (%d)\n", mesh->numVertices); 
     
    385409        } 
    386410        printf("]\n"); 
     411 
     412                                        printf("  e(%d)[", mesh->vertices[i].numEdges); 
     413        if (mesh->vertices[i].edges != NULL) { 
     414            printf("%d", mesh->vertices[i].edges[0]); 
     415            for (j=1; j<mesh->vertices[i].numEdges; j++) { 
     416                printf(",%d", mesh->vertices[i].edges[j]); 
     417            } 
     418        } 
     419        printf("]\n"); 
    387420    } 
    388421 
     
    391424    for (i=0; i<mesh->numEdges; i++) { 
    392425        printf("e%d (%d,%d) %d\n", i, mesh->edges[i].u, mesh->edges[i].v, mesh->edges[i].enable); 
    393         printf("  t(%d)[", mesh->edges[i].numTriangles); 
    394         if (mesh->edges[i].triangles != NULL) { 
    395             printf("%d", mesh->edges[i].triangles[0]); 
    396             for (j=1; j<mesh->edges[i].numTriangles; j++) { 
    397                 printf(",%d", mesh->edges[i].triangles[j]); 
    398             } 
    399                                 } 
    400         printf("]\n"); 
    401426    } 
    402427 
     
    406431        printf("t%d (%d,%d,%d) %d\n", i, mesh->triangles[i].indices[0], mesh->triangles[i].indices[1], 
    407432                                     mesh->triangles[i].indices[2],  mesh->triangles[i].enable); 
    408         printf("  e(3)["); 
    409         printf("%d", mesh->triangles[i].edges[0]); 
    410         for (j=1; j<3; j++) { 
    411             printf(",%d", mesh->triangles[i].edges[j]); 
    412         } 
    413         printf("]\n"); 
    414433 
    415434        printf("  n(3)["); 
     
    425444 
    426445void VMI::deleteMesh(Mesh *mesh) { 
    427         GLuint i; 
     446        int i; 
    428447 
    429448        if (NULL != mesh) { 
     
    432451                                free(mesh->vertices[i].triangles); 
    433452 
     453                        if (mesh->vertices[i].edges != NULL) 
     454                                free(mesh->vertices[i].edges); 
     455 
    434456                } 
    435457                if (mesh->vertices != NULL) free(mesh->vertices); 
    436458                mesh->numVertices = 0; 
    437459 
    438                 for (i=0; i<mesh->numEdges; i++) { 
    439                         if (mesh->edges[i].triangles != NULL) 
    440                                 free(mesh->edges[i].triangles); 
    441                 } 
    442460                if (mesh->edges != NULL) free(mesh->edges); 
    443461                mesh->numEdges = 0; 
     
    525543} 
    526544 
    527 int *VMI::edgesAdjToVertex(Mesh *mesh, int v, int *n) { 
    528     int *edges = NULL; 
    529     int i, t, e; 
    530 #ifndef USE_EDGE_ADJACENCY 
    531     int n0, n1, n2; 
    532 #else 
    533     int j; 
    534 #endif 
    535     int num = 0; 
    536  
    537         if (mesh->vertices[v].numTriangles > 0)  
    538                 edges = (int*)malloc(sizeof(int) * mesh->vertices[v].numTriangles * 2); 
    539  
    540     for (i=0; i<(int)mesh->vertices[v].numTriangles; i++) { 
    541  
    542         t = mesh->vertices[v].triangles[i]; 
    543  
    544 #ifdef USE_EDGE_ADJACENCY 
    545         for (j=0; j<3; j++) { 
    546             e = mesh->triangles[t].edges[j]; 
    547              
    548             if ((int)mesh->edges[e].u == v || (int)mesh->edges[e].v == v) 
    549                  
    550                 addItem(edges, &num, e); 
    551         } 
    552 #else 
    553         n0 = mesh->triangles[t].indices[0]; 
    554         n1 = mesh->triangles[t].indices[1]; 
    555         n2 = mesh->triangles[t].indices[2]; 
    556          
    557         if (((n0 == v) || (n1 == v)) && 
    558             ((e = findEdge(mesh->edges, mesh->numEdges, n0, n1)) != -1)) addItem(edges, &num, e); 
    559   
    560         if (((n1 == v) || (n2 == v)) && 
    561             ((e = findEdge(mesh->edges, mesh->numEdges, n1, n2)) != -1)) addItem(edges, &num, e); 
    562          
    563         if (((n0 == v) || (n2 == v)) && 
    564             ((e = findEdge(mesh->edges, mesh->numEdges, n0, n2)) != -1)) addItem(edges, &num, e); 
    565  
    566 #endif 
    567     } 
    568     *n = num; 
    569  
    570     return edges; 
    571 } 
    572  
    573545int *VMI::edgesAdjToVertices(Mesh *mesh, int *vertices, int numVertices, int *n) { 
    574546    int *edges = NULL; 
     
    578550    if (numVertices > 0) { 
    579551        // Add the first 
    580         list = edgesAdjToVertex(mesh, vertices[0], &numEdges); 
     552                list = mesh->vertices[vertices[0]].edges; 
     553                numEdges = mesh->vertices[vertices[0]].numEdges; 
    581554 
    582555        // Allocate memory 
     
    585558        memcpy(edges, list, sizeof(int) * numEdges); 
    586559 
    587         free(list); 
    588  
    589560        num = numEdges; 
    590561 
     
    592563        for (i=1; i<numVertices; i++) { 
    593564 
    594             list = edgesAdjToVertex(mesh, vertices[i], &numEdges); 
     565                        list = mesh->vertices[vertices[i]].edges; 
     566                    numEdges = mesh->vertices[vertices[i]].numEdges; 
    595567 
    596568            // Reallocate memory 
    597                         if (numEdges > 0) { 
     569            if (numEdges > 0) { 
    598570 
    599571                edges = (int *)realloc(edges, (num + numEdges + 1) * sizeof(int)); 
     
    601573                for (j=0; j<numEdges; j++) 
    602574                    addItem(edges, &num, list[j]); 
    603                         } 
    604             free(list); 
     575            } 
    605576        } 
    606577    } 
     
    610581} 
    611582 
    612 GLboolean VMI::findVertex(GLfloat *vertices, GLuint num, GLfloat x, GLfloat y, GLfloat z, int *pos) { 
    613     GLuint i; 
    614     GLfloat _x, _y, _z; 
     583GLboolean VMI::findVertex(float *vertices, int num, float x, float y, float z, int *pos) { 
     584    int i; 
     585    float _x, _y, _z; 
    615586    GLboolean found = GL_FALSE;  
    616587     
     
    648619                newList[*n].numTriangles = 0; 
    649620                newList[*n].triangles = NULL; 
     621 
     622                newList[*n].numEdges= 0; 
     623                newList[*n].edges = NULL; 
    650624         
    651625    // Enable the new vertex 
     
    663637 
    664638 
    665 void VMI::updateModel(GLMmodel* pmodel, Mesh *mesh, GLuint numVertices, GLuint numTriangles) { 
    666     GLuint i , v1, v2 ,v3, numV = 1, numT = 0; 
     639void VMI::updateModel(GLMmodel* pmodel, Mesh *mesh, int numVertices, int numTriangles) { 
     640    int i , v1, v2 ,v3, numV = 1, numT = 0; 
    667641    int pos; 
    668     GLfloat x, y, z; 
     642    float x, y, z; 
    669643     
    670644    if (pmodel->vertices != NULL) free(pmodel->vertices); 
     
    726700 
    727701void VMI::saveModel(char *filename, GLMmodel* pmodel, Mesh *mesh) { 
    728     GLuint i, j, g, numT = 0; 
     702    int i, j, g, numT = 0; 
    729703    GLMgroup *group; 
    730704 
  • GTP/trunk/Lib/Geom/shared/GTGeometry/src/libs/vmi/src/metrics.cpp

    r2090 r2127  
    1313using namespace VMI; 
    1414 
    15 GLdouble VMI::computeMeanProjAreaNoBG(GLuint **histogram, GLuint numCameras, int t) { 
    16     GLuint i; 
     15GLdouble VMI::computeMeanProjAreaNoBG(int **histogram, int numCameras, int t) { 
     16    int i; 
    1717    GLdouble mean_proj_area = 0.0; 
    1818 
     
    2424} 
    2525 
    26 GLdouble VMI::computeMeanProjArea(GLuint **histogram, GLuint numCameras, int t) { 
    27         GLuint i; 
     26GLdouble VMI::computeMeanProjArea(int **histogram, int numCameras, int t) { 
     27        int i; 
    2828        GLdouble mean_proj_area = 0.0, total_proj_area, resolution = width * height; 
    2929 
     
    3838/////////////////////////////////////////////////////////////////////////////// 
    3939// Mutual Information 
    40 GLdouble VMI::computeMI(Mesh *mesh, GLuint **histogram, GLuint numCameras, GLuint cam) { 
     40GLdouble VMI::computeMI(Mesh *mesh, int **histogram, int numCameras, int cam) { 
    4141    GLdouble I = 0.0, pov, po, total_proj_area = width * height; 
    42     GLuint i; 
     42    int i; 
    4343     
    4444    for (i=0; i<mesh->numTriangles; i++) {  
     
    6666} 
    6767 
    68 GLdouble VMI::decMI(GLdouble I, GLuint **histogram, GLuint numCameras, GLuint cam, Change *c) { 
     68GLdouble VMI::decMI(GLdouble I, int **histogram, int numCameras, int cam, Change *c) { 
    6969    GLdouble newI = I * numCameras,  
    7070             pov = 0.0, po; 
     
    109109} 
    110110 
    111 GLdouble VMI::incMI(GLdouble I, GLuint **histogram, GLuint numCameras, GLuint cam, Change *c) { 
     111GLdouble VMI::incMI(GLdouble I, int **histogram, int numCameras, int cam, Change *c) { 
    112112    GLdouble newI = I * numCameras,  
    113113             pov = 0.0, po; 
    114114    GLsizei total_proj_area = width * height; 
    115     GLuint i, t; 
     115    int i, t; 
    116116 
    117117    // increase entropy of modified triangles 
    118     for (i=0; i<(GLuint)c->numMod; i++) {  
     118    for (i=0; i<c->numMod; i++) {  
    119119         
    120120        t = c->modified[i].id; 
     
    140140/////////////////////////////////////////////////////////////////////////////// 
    141141// Kullback-Leibler divergence 
    142 GLdouble VMI::computeKL(Mesh *mesh, GLuint *histogram) { 
     142GLdouble VMI::computeKL(Mesh *mesh, int *histogram) { 
    143143    GLdouble I = 0.0,  
    144144             total_real_area = 0.0, pi, tri_area; 
    145145    GLsizei  total_proj_area = (width * height) - histogram[0]; 
    146     GLuint   i; 
     146    int   i; 
    147147 
    148148    // Compute total real area of all triangles 
     
    169169 
    170170// Hellinger divergence (square root) 
    171 GLdouble VMI::computeHE(Mesh *mesh, GLuint *histogram) { 
     171GLdouble VMI::computeHE(Mesh *mesh, int *histogram) { 
    172172    GLdouble I = 0.0, temp,  
    173173             total_real_area = 0.0, pi, qi; 
    174174    GLsizei  total_proj_area = (width * height) - histogram[0]; 
    175     GLuint i; 
     175    int i; 
    176176     
    177177    // Compute total real area of all triangles 
     
    203203 
    204204// Chi-Square divergence (square root) 
    205 GLdouble VMI::computeCS(Mesh *mesh, GLuint *histogram) { 
     205GLdouble VMI::computeCS(Mesh *mesh, int *histogram) { 
    206206    GLdouble I = 0.0,  
    207207             total_real_area = 0.0, pi, qi; 
    208208    GLsizei  total_proj_area = (width * height) - histogram[0]; 
    209     GLuint i; 
     209    int i; 
    210210     
    211211    /// Compute total real area of all triangles 
     
    231231} 
    232232/////////////////////////////////////////////////////////////////////////////// 
    233 GLdouble VMI::computeEntropy(GLuint **histogram, GLuint numCameras, GLuint k) { 
     233GLdouble VMI::computeEntropy(int **histogram, int numCameras, int k) { 
    234234        GLdouble H = 0.0, POk, pi, 
    235235                                         total_proj_area, resolution = width * height, pv = 1.0 / (GLdouble)numCameras; 
    236         GLuint i; 
     236        int i; 
    237237 
    238238        for (i=0; i<numCameras; i++) { 
     
    253253} 
    254254 
    255 GLdouble VMI::computeMixedEntropy(GLdouble *mixed, GLuint numCameras) { 
     255GLdouble VMI::computeMixedEntropy(GLdouble *mixed, int numCameras) { 
    256256    GLdouble H = 0.0, pi; 
    257     GLuint i; 
     257    int i; 
    258258     
    259259    for (i=0; i<numCameras; i++) { 
     
    269269/////////////////////////////////////////////////////////////////////////////// 
    270270// Jensen-Shannon divergence 
    271 GLdouble VMI::computeJS(GLuint **histogram, GLuint numCameras, GLuint j, GLuint k) { 
     271GLdouble VMI::computeJS(int **histogram, int numCameras, int j, int k) { 
    272272        GLdouble js, Wj = 0.0, Wk = 0.0, POj, POk, pj, pk, total_proj_area, 
    273273                                         resolution = width * height, pv = 1.0 / (GLdouble)numCameras, 
    274274                                         *mixing = (GLdouble *)malloc(numCameras * sizeof(GLdouble)); 
    275         GLuint i; 
     275        int i; 
    276276 
    277277        POj = computeMeanProjArea(histogram, numCameras, j + 1); 
     
    311311} 
    312312/////////////////////////////////////////////////////////////////////////////// 
    313 void VMI::getProjectedAreas(GLuint **histogram, GLuint numCameras) { 
    314  
    315     renderScene(histogram, numCameras); 
    316 } 
    317  
    318 void VMI::getProjectedAreasWin(GLuint **histogram, GLuint numCameras, Change *c) { 
    319  
    320     renderSceneWin(histogram, numCameras, c); 
    321 } 
    322  
    323 void VMI::resetProjectedAreas(GLuint **histogram, GLuint numCameras) { 
    324     GLuint i = 0; 
    325  
    326     // Reset the projected areas for all cameras 
    327     for (i=0; i<numCameras; i++) 
    328         resetSWHistogram(histogram[i], mesh->numTriangles); 
    329 } 
    330  
    331 GLdouble *VMI::initIs(GLuint numCameras) { 
     313 
     314GLdouble *VMI::initIs(int numCameras) { 
    332315    GLdouble *initialIs; 
    333316 
     
    346329} 
    347330 
    348 void VMI::computeCameraIs(GLuint **histogram, GLuint numCameras, GLdouble *mis) { 
    349     GLuint i = 0; 
     331void VMI::computeCameraIs(int **histogram, int numCameras, GLdouble *mis) { 
     332    int i = 0; 
    350333    GLdouble meanI = 0.0; 
    351334 
     
    374357} 
    375358 
    376 void VMI::printIs(GLdouble *mis, GLuint numCameras) { 
    377     GLuint i; 
     359void VMI::printIs(GLdouble *mis, int numCameras) { 
     360    int i; 
    378361 
    379362    printf("\n"); 
  • GTP/trunk/Lib/Geom/shared/GTGeometry/src/libs/vmi/src/saliency.cpp

    r2090 r2127  
    2222using namespace VMI; 
    2323 
    24 void VMI::computeSaliency(Mesh *mesh, GLuint **histogram, GLuint numCameras) { 
    25         GLuint i = 0; 
     24void VMI::computeSaliency(Mesh *mesh, int **histogram, int numCameras) { 
     25        int i = 0; 
    2626        double sal; 
    2727 
     
    4646} 
    4747 
    48 void updateTriangleSaliency(Mesh *mesh, GLuint **histogram, GLuint numCameras, int v) { 
     48void updateTriangleSaliency(Mesh *mesh, int **histogram, int numCameras, int v) { 
    4949        int i, t; 
    5050 
     
    5757} 
    5858 
    59 double VMI::computeTriangleSaliency(Mesh *mesh, GLuint **histogram, GLuint numCameras, GLuint k) { 
    60      GLuint i, l, v0, v1, v2; 
     59double VMI::computeTriangleSaliency(Mesh *mesh, int **histogram, int numCameras, int k) { 
     60    int i, l, v0, v1, v2; 
    6161    int *triangles = NULL, n = 0; 
    6262    double sal = 0.0; 
     
    9494    //printItemList(triangles, n); 
    9595     
    96     for(i=0; i<(GLuint)n; i++) { 
     96    for(i=0; i<n; i++) { 
    9797        //printf("\n%d %d", k, triangles[i]); 
    9898        //sal += computeJS(histogram, numCameras, k, triangles[i]); 
     
    137137void VMI::saveSaliencyMap(Mesh *mesh, char* filename) { 
    138138    FILE *fp; 
    139     GLuint i; 
     139    int i; 
    140140 
    141141 
     
    162162void VMI::loadSaliencyMap(Mesh *mesh, char* filename) { 
    163163    FILE *fp; 
    164     unsigned int i, num; 
     164    int i, num; 
    165165    float s; 
    166166 
     
    202202 
    203203void VMI::viewSaliency(Mesh *mesh, Camera *cameras, int cam) { 
    204     GLuint i, v1, v2, v3; 
     204    int i, v1, v2, v3; 
    205205    float r, g, b; 
    206206     
  • GTP/trunk/Lib/Geom/shared/GTGeometry/src/libs/vmi/src/simplify.cpp

    r2103 r2127  
    1010#include "../include/saliency.h" 
    1111#include "../include/histogram.h" 
     12#include "../include/buffers.h" 
    1213 
    1314//#define RECOMPUTE_THE_WHOLE_HEAP 
     
    5960 
    6061bheap_t *VMI::initHeap(Mesh *mesh) { 
    61         GLuint i; 
     62        int i; 
    6263        double cost; 
    6364        bheap_t *h = NULL; 
     
    152153 
    153154        return h; 
    154 } 
    155  
    156 GLdouble VMI::computeEdgeLength(Vertex *vertices, int u, int v) { 
    157         GLfloat ux, uy, uz, vx, vy ,vz, rx, ry, rz; 
    158  
    159         ux = vertices[u].x; 
    160         uy = vertices[u].y; 
    161         uz = vertices[u].z; 
    162  
    163         vx = vertices[v].x; 
    164         vy = vertices[v].y; 
    165         vz = vertices[v].z; 
    166  
    167         rx = ux - vx; 
    168         ry = uy - vy; 
    169         rz = uz - vz; 
    170  
    171         return sqrt((rx * rx) + (ry * ry) + (rz * rz)); 
    172155} 
    173156 
     
    243226/////////////////////////////////////////////////////////////////////////////// 
    244227 
    245 void saveProjectedAreas(GLuint **histogram, GLuint numCameras, Change *c, GLuint *dest) { 
    246         GLuint i, j, t, n = 0; 
    247  
    248         for (j=0; j<(GLuint)c->numDel; j++) { 
     228void saveProjectedAreas(int **histogram, int numCameras, Change *c, int *dest) { 
     229        int i, j, t, n = 0; 
     230 
     231        for (j=0; j<c->numDel; j++) { 
    249232 
    250233                t = c->deleted[j].id; 
     
    257240        } 
    258241 
    259         for (j=0; j<(GLuint)c->numMod; j++) {  
     242        for (j=0; j<c->numMod; j++) {  
    260243 
    261244                t = c->modified[j].id; 
     
    276259} 
    277260 
    278 void loadProjectedAreas(GLuint *src, GLuint numCameras, Change *c, GLuint **histogram) { 
    279         GLuint i, j, t, n = 0; 
    280  
    281         for (j=0; j<(GLuint)c->numDel; j++) {  
     261void loadProjectedAreas(int *src, int numCameras, Change *c, int **histogram) { 
     262        int i, j, t, n = 0; 
     263 
     264        for (j=0; j<c->numDel; j++) {  
    282265 
    283266                t = c->deleted[j].id; 
     
    290273        } 
    291274 
    292         for (j=0; j<(GLuint)c->numMod; j++) {  
     275        for (j=0; j<c->numMod; j++) {  
    293276 
    294277                t = c->modified[j].id; 
     
    308291        } 
    309292} 
    310  
    311293/////////////////////////////////////////////////////////////////////////////// 
     294#ifdef CHECK_LOCAL_INVERSION 
     295int check_local_inversion(Mesh *mesh, Change *c) { 
     296    int i, t; 
     297    int v0, v1, v2; 
     298    double vol_before; 
     299    double vol_after; 
     300    Triangle tri; 
     301     
     302    for(i=0; i<mesh->vertices[c->u].numTriangles; i++) { 
     303         
     304        t = mesh->vertices[c->u].triangles[i]; 
     305         
     306        v0 = mesh->triangles[t].indices[0]; 
     307        v1 = mesh->triangles[t].indices[1]; 
     308        v2 = mesh->triangles[t].indices[2]; 
     309         
     310        if ((v0 != c->v) && (v1 != c->v) && (v2 != c->v)) { 
     311             
     312            //printf("%d\n", t); 
     313            memcpy(&tri, &mesh->triangles[t], sizeof(Triangle)); 
     314             
     315            vol_before = computeTriangleVolume(mesh->vertices, &tri); 
     316 
     317            //printf("t:[%d,%d,%d]\n", tri.indices[0], tri.indices[1], tri.indices[2]); 
     318            //printf("v:%f\n", vol_before); 
     319           
     320            if (tri.indices[0] == c->u) tri.indices[0] = c->v; 
     321            if (tri.indices[1] == c->u) tri.indices[1] = c->v; 
     322            if (tri.indices[2] == c->u) tri.indices[2] = c->v; 
     323             
     324            vol_after = computeTriangleVolume(mesh->vertices, &tri); 
     325 
     326            //printf("t:[%d,%d,%d]\n", tri.indices[0], tri.indices[1], tri.indices[2]); 
     327            //printf("v:%f\n", vol_after); 
     328 
     329            if (((vol_before > 0) && (vol_after < 0)) ||  
     330                ((vol_before < 0) && (vol_after > 0))) 
     331 
     332                return TRUE; 
     333        } 
     334    } 
     335    return FALSE; 
     336} 
     337#endif 
    312338 
    313339GLdouble VMI::computeEdgeCost(Mesh *mesh, int e) { 
     
    318344        GLdouble newI; 
    319345#endif 
    320         GLuint i, *histoAux = NULL; 
     346        int i, *histoAux = NULL; 
    321347        Change *c; 
     348#if defined(VERTEX_BUFFER_OBJECTS) || defined(VERTEX_ARRAY) 
     349    VertexIL *vb = NULL; 
     350#endif 
     351#ifdef CHECK_LOCAL_INVERSION 
     352    int penalized; 
     353#endif 
    322354 
    323355        chooseBestEndPoints(mesh, e); 
     
    327359 
    328360        // Compute cost only for boundary or manifold edges 
    329         if (c->numDel == 2 
    330                         /*(c->numDel <3) && (c->numDel > 0)*/) { 
     361        if (/*c->numDel == 2*/ 
     362                        (c->numDel <3) && (c->numDel > 0)) { 
     363 
     364#ifdef CHECK_LOCAL_INVERSION 
     365        penalized = check_local_inversion(mesh, c); 
     366#endif 
    331367                // Allocate memory 
    332                 histoAux = (GLuint *)malloc((c->numDel + c->numMod + 1) * numCameras * sizeof(GLuint)); 
     368                histoAux = (int *)malloc((c->numDel + c->numMod + 1) * numCameras * sizeof(int)); 
     369 
     370#if defined(VERTEX_BUFFER_OBJECTS) || defined(VERTEX_ARRAY) 
     371        vb = (VertexIL *)malloc((c->numDel + c->numMod + 1) * 3 * sizeof(VertexIL)); 
     372 
     373        saveVertexBuffer(c, vb); 
     374#endif 
    333375 
    334376#ifdef MI // Mutual Information 
     
    365407                        //printf("  I0:%f Is: %f\n", auxE[i], initialIs[i]); 
    366408 
    367                         cost += (ABS(auxIs[i] - initialIs[i]) * cameras[i].weight * sal); 
     409                        cost += (ABS(auxIs[i] - initialIs[i]) * cameras[i].weight); 
    368410 
    369411                        // Restore old informations 
     
    405447                        newI = computeCS(mesh, histogram[i]); 
    406448#endif 
    407                         cost += (ABS(initialIs[i] - newI) * cameras[i].weight * sal); 
     449                        cost += (ABS(initialIs[i] - newI) * cameras[i].weight); 
    408450                } 
    409451                undoChange(mesh, c); 
     
    417459                // Free memory 
    418460                free(histoAux); 
     461#if defined(VERTEX_BUFFER_OBJECTS) || defined(VERTEX_ARRAY) 
     462        loadVertexBuffer(vb, c); 
     463        free(vb); 
     464#endif 
     465#ifdef CHECK_LOCAL_INVERSION 
     466        if (penalized) cost *= 5; 
     467#endif 
    419468 
    420469        } else cost = FLT_MAX; 
     
    422471        deleteChange(c); 
    423472 
    424         return cost; 
    425 } 
     473        return (cost * sal); 
     474} 
     475 
     476int isValidEdge_(Mesh *mesh, int e) { 
     477    int u , v; 
     478 
     479    if (mesh->edges[e].enable == FALSE) return FALSE; 
     480    else { 
     481        u = mesh->edges[e].u; 
     482        v = mesh->edges[e].v; 
     483 
     484        if (u == v) { 
     485 
     486            mesh->edges[e].enable = FALSE; 
     487            return FALSE; 
     488        } 
     489    } 
     490 
     491    return TRUE; 
     492} 
     493 
    426494/* Get a valid edge from the heap */ 
    427495int getMinValidEdge(Mesh *mesh, bheap_t *h) { 
     
    431499        e = bh_min(h); 
    432500 
    433         while (mesh->edges[e].enable == FALSE) { 
     501        while (!isValidEdge_(mesh, e)) { 
    434502                /* delete invalid edge */ 
    435503                bh_delete(h, e); 
     
    473541 
    474542/////////////////////////////////////////////////////////////////////////// 
    475 void VMI::simplifyModel(Mesh *mesh, GLuint numDemandedTri) 
     543void VMI::simplifyModel(Mesh *mesh, int numDemandedTri) 
    476544{ 
    477545        int                     e; 
     
    558626                bh_delete(h, e); 
    559627 
     628                updateHWAcceleration(c); 
     629 
    560630                // Get projected areas after the edge collapse 
    561631                getProjectedAreas(histogram, numCameras); 
     
    563633                computeCameraIs(histogram, numCameras, initialIs); 
    564634 
    565                 deleteEdges(mesh, c); 
    566                 modifyEdges(mesh, c); 
     635                updateEdgeAdj(mesh, c); 
     636 
     637    modifyEdges(mesh, c); 
    567638 
    568639                // Update the heap according to the edge collapse 
     
    751822 
    752823        Edge            *econ; 
    753         float           x,y,z; 
    754824        int                     *lv1; 
    755825        int                     v0; 
     
    797867                        v1      =       (*lb1).second; 
    798868 
    799                         lv1     =       edgesAdjToVertex(mesh,v1,&num_edges); 
     869                        lv1     =       mesh->vertices[v1].edges; 
     870                        num_edges = mesh->vertices[v1].numEdges; 
    800871 
    801872                        //      Edje iterator. 
     
    857928 
    858929                        deleteVertexOfMap(mesh, c->u); 
    859                         deleteEdges(mesh, c); 
    860                         modifyEdges(mesh, c); 
     930                        updateEdgeAdj(mesh, c); 
     931      modifyEdges(mesh, c); 
    861932                        deleteChange(c); 
    862933 
     
    910981                        lonely_vert     =       (*it).second; 
    911982 
    912                         le      =       edgesAdjToVertex(mesh,lonely_vert,&num_edges); 
     983                        le      =       mesh->vertices[lonely_vert].edges; 
     984 
     985                        num_edges = mesh->vertices[lonely_vert].numEdges; 
    913986 
    914987                        //      Find an edge width v coordinates. 
     
    9771050 
    9781051                                deleteVertexOfMap(mesh, c->u); 
    979                                 deleteEdges(mesh, c); 
    980                                 modifyEdges(mesh, c); 
     1052                                updateEdgeAdj(mesh, c); 
     1053        modifyEdges(mesh, c); 
    9811054                                deleteChange(c); 
    9821055                        } 
     
    10691142 
    10701143                                deleteVertexOfMap(mesh, c->u); 
    1071                                 deleteEdges(mesh, c); 
    1072                                 modifyEdges(mesh, c); 
     1144                                updateEdgeAdj(mesh, c); 
     1145        modifyEdges(mesh, c); 
    10731146                                deleteChange(c); 
    10741147                        } 
  • GTP/trunk/Lib/Geom/shared/GeoTool/include/GeoMeshView.h

    r2090 r2127  
    3737        bool            mCW; 
    3838        bool            mCCW; 
     39        bool            mBBox; 
     40        bool            mAxes; 
    3941        bool            mPan; 
    4042        bool            mRotate; 
     
    116118        void    activeRotate(){mRotate  =       true;} 
    117119        void    deactiveRotate(){mRotate        =       false;} 
     120 
     121        //      Counter Clockwise mode. 
     122        void    activeAxes(){mAxes      =       true;} 
     123        void    deactiveAxes(){mAxes    =       false;} 
     124 
     125        //      Counter Clockwise mode. 
     126        void    activeBoundingBox(){mBBox       =       true;} 
     127        void    deactiveBoundingBox(){mBBox     =       false;} 
    118128 
    119129        //      LodStrip mode. 
     
    170180        void draw(); 
    171181 
    172         //      Gets the bounding box. 
    173         //Geometry::GeometryBounds      getBoundingBox(); 
    174  
    175182        //      Store one random color to each strip. 
    176183        void    setStripColors(); 
     
    211218        int findLeavesSubMesh(void); 
    212219 
     220        //      Draw coordinates axes. 
     221        void    drawAxes(); 
     222 
     223        //      Draw bounding box. 
     224        void    drawBoundingBox(); 
     225 
    213226        private: 
    214227        /* Draw the cube boundaries 
     
    242255        float           zMed; 
    243256 
     257        float           xMax; 
     258        float           yMax; 
     259        float           zMax; 
     260        float           xMin; 
     261        float           yMin; 
     262        float           zMin; 
     263 
    244264        int                     leavesSubMesh; 
    245265         
     
    257277 
    258278        virtual int     handle(int event); 
     279 
     280        //      Gets the bounding box. 
     281        void    getBoundingBox(); 
    259282 
    260283        //      Paint the mesh object. 
  • GTP/trunk/Lib/Geom/shared/GeoTool/include/GeoMeshViewUI.h

    r2090 r2127  
    215215        inline void cb_menuRenderTextures_i(fltk::Item*, void*); 
    216216        static void cb_menuRenderTextures(fltk::Item*, void*); 
     217        inline void cb_menuRenderBoundingBox_i(fltk::Item*, void*); 
     218        static void cb_menuRenderBoundingBox(fltk::Item*, void*); 
     219        inline void cb_menuRenderAxes_i(fltk::Item*, void*); 
     220        static void cb_menuRenderAxes(fltk::Item*, void*); 
    217221        inline void cb_menuStripify_i(fltk::Item*, void*); 
    218222        static void cb_menuStripify(fltk::Item*, void*); 
  • GTP/trunk/Lib/Geom/shared/GeoTool/src/GeoMeshView.cpp

    r2090 r2127  
    55using   namespace       std; 
    66 
    7 //--------------------------------------------------------------------------- 
     7//------------------------------------------------------------------------- 
    88//      Handle events. 
    9 //--------------------------------------------------------------------------- 
     9//------------------------------------------------------------------------- 
    1010int     GeoMeshView::handle(int event) 
    1111{ 
     
    3333                case    fltk::DRAG: 
    3434                         
    35                         button  =       fltk::event_state(); 
     35                        button  =       fltk::event_key(); 
    3636                        x                               =       fltk::event_x(); 
    3737                        y                               =       fltk::event_y(); 
    3838                         
     39 
    3940                        switch (button) 
    4041                        { 
    4142                                //      Button 1 Pushed. 
    42                                 case    0x01100000: 
     43                                case    1: 
    4344                         
    4445                                        if (x > mMouseX) 
     
    104105                                        return  1; 
    105106                                 
    106                                 case    0x04100000: 
     107                                //      Button 3 pushed. 
     108                                case    2: 
     109                                case    3: 
    107110 
    108111                                        if (y   > mSizeY) 
     
    124127                                        return 1; 
    125128 
    126                         }                        
     129                        } 
    127130                         
    128131                case    fltk::MOUSEWHEEL: 
     
    172175} 
    173176 
    174 //--------------------------------------------------------------------------- 
     177//------------------------------------------------------------------------- 
    175178//      Enable color strips. 
    176 //--------------------------------------------------------------------------- 
     179//------------------------------------------------------------------------- 
    177180void    GeoMeshView::enableColorStrips() 
    178181{ 
     
    180183} 
    181184 
    182 //--------------------------------------------------------------------------- 
     185//------------------------------------------------------------------------- 
    183186//      Disable color strips. 
    184 //--------------------------------------------------------------------------- 
     187//------------------------------------------------------------------------- 
    185188void    GeoMeshView::disableColorStrips() 
    186189{ 
     
    188191} 
    189192 
    190 //--------------------------------------------------------------------------- 
     193//------------------------------------------------------------------------- 
    191194//      Gets the color strips state. 
    192 //--------------------------------------------------------------------------- 
     195//------------------------------------------------------------------------- 
    193196bool    GeoMeshView::getColorStrips() 
    194197{ 
     
    196199} 
    197200 
    198 //--------------------------------------------------------------------------- 
     201//------------------------------------------------------------------------- 
    199202//      Set the color to the submesh sumbmeshIndex 
    200 //--------------------------------------------------------------------------- 
     203//------------------------------------------------------------------------- 
    201204void    GeoMeshView::setSubMeshSelected(int submeshIndex) 
    202205{ 
     
    204207} 
    205208 
    206 //--------------------------------------------------------------------------- 
     209//------------------------------------------------------------------------- 
    207210//      Sets the leaves submesh index. 
    208 //--------------------------------------------------------------------------- 
     211//------------------------------------------------------------------------- 
    209212void    GeoMeshView::setLeavesSubMesh(int submeshIndex) 
    210213{ 
     
    212215} 
    213216 
    214 //--------------------------------------------------------------------------- 
     217//------------------------------------------------------------------------- 
    215218//      Gets the leaves submesh index. 
    216 //--------------------------------------------------------------------------- 
     219//------------------------------------------------------------------------- 
    217220int     GeoMeshView::getLeavesSubMesh() 
    218221{ 
     
    220223} 
    221224 
    222 //--------------------------------------------------------------------------- 
     225//------------------------------------------------------------------------- 
    223226//      Set the list of strip colors. 
    224 //--------------------------------------------------------------------------- 
     227//------------------------------------------------------------------------- 
    225228void    GeoMeshView::setStripColors() 
    226229{ 
     
    253256                } 
    254257        } 
    255  
    256258         
    257259        //      Sets random colors to each strip. 
    258260        for (int submesh        = 0; submesh < geoMesh->mSubMeshCount; submesh++) 
    259         { 
     261        {        
    260262                //      Gets the actual submesh. 
    261263                geosubmesh      =       &geoMesh->mSubMesh[submesh]; 
     
    265267                        for     (int strip = 0; strip   <       geosubmesh->mStripCount; strip++) 
    266268                        { 
    267                                 mStripColors[submesh][strip].r  =       rand()/((float)RAND_MAX); 
    268                                 mStripColors[submesh][strip].g  =       rand()/((float)RAND_MAX); 
    269                                 mStripColors[submesh][strip].b  =       rand()/((float)RAND_MAX); 
     269                                mStripColors[submesh][strip].r  =       (0.6 * rand() + 0.4 * (float)RAND_MAX)/((float)RAND_MAX); 
     270                                mStripColors[submesh][strip].g  =       (0.6 * rand() + 0.4 * (float)RAND_MAX)/((float)RAND_MAX); 
     271                                mStripColors[submesh][strip].b  =       (0.6 * rand() + 0.4 * (float)RAND_MAX)/((float)RAND_MAX); 
    270272                        } 
    271273                } 
     
    276278} 
    277279 
    278 /* 
    279 //--------------------------------------------------------------------------- 
     280//------------------------------------------------------------------------- 
    280281//      Get the bounding box of the object. 
    281 //--------------------------------------------------------------------------- 
    282 GeometryBounds  GeoMeshView::getBoundingBox() 
    283 { 
    284         SubMesh                                 *geosubmesh; 
    285         Index                                           position; 
    286         Vector3                                 vector3; 
    287         GeometryBounds  bounds; 
    288         float                                           x,y,z; 
    289         float                                           xMin,yMin,zMin; 
    290         float                                           xMax,yMax,zMax; 
    291                  
    292         //      For each submesh. 
    293         for (int submesh = 0; submesh < geoMesh->mSubMeshCount; submesh++) 
    294         { 
    295                 //      Gets the actual submesh. 
    296                 geosubmesh      =       &geoMesh->mSubMesh[submesh]; 
    297  
    298                 //      For each index of the strip. 
    299                 for (int index = 0; index < geosubmesh->mIndexCount; index++) 
    300                 { 
    301                         position        =       geosubmesh->mIndex[index]; 
    302  
    303                         //      Gets the vertex coordinates. 
    304                         vector3 =       geosubmesh->mVertexBuffer->mPosition[position]; 
    305                                  
    306                         x                                       =       vector3[0]; 
    307                         y                                       =       vector3[1]; 
    308                         z                                       =       vector3[2]; 
    309                                  
    310                         //      If is the first iteation. 
    311                         if ((submesh    == 0)   &&      (index  ==      0)) 
    312                         { 
    313                                 xMin    =       xMax    =       x; 
    314                                 yMin    =       yMax    =       y; 
    315                                 zMin    =       zMax    =       z; 
    316                         } 
    317                         else 
    318                         { 
    319                                 if (x < xMin) 
    320                                 { 
    321                                         xMin    =       x; 
    322                                 } 
    323                                 else if (x > xMax) 
    324                                 { 
    325                                         xMax    =       x; 
    326                                 } 
    327  
    328                                 if (y < yMin) 
    329                                 { 
    330                                         yMin    =       y; 
    331                                 } 
    332                                 else if (y > yMax) 
    333                                 { 
    334                                         yMax    =       y; 
    335                                 } 
    336  
    337                                 if (z < zMin) 
    338                                 { 
    339                                         zMin    =       z; 
    340                                 } 
    341                                 else if (z > zMax) 
    342                                 { 
    343                                         zMax    =       z; 
    344                                 } 
    345                         } 
    346                 } 
    347         } 
    348  
    349         xMed    =       (xMax + xMin)   /       2; 
    350         yMed    =       (yMax + yMin)   /       2; 
    351         zMed    =       (zMax + zMin)   /       2; 
    352  
    353  
    354         if ((xMax - xMin) > (yMax - yMin)) 
    355         { 
    356                 if ((xMax - xMin) > (zMax - zMin)) 
    357                 { 
    358                         mScaleFactor    =       xMax - xMin; 
    359                 } 
    360                 else 
    361                 { 
    362                         mScaleFactor    =       zMax - zMin; 
    363                 } 
    364         } 
    365         else 
    366         { 
    367                 if ((yMax - yMin) > (zMax - zMin)) 
    368                 { 
    369                         mScaleFactor    =       yMax - yMin; 
    370                 } 
    371                 else 
    372                 { 
    373                         mScaleFactor    =       zMax - zMin; 
    374                 } 
    375         } 
    376  
    377         //      Set the bounds. 
    378         bounds.minx             =       xMin; 
    379         bounds.miny             =       yMin; 
    380         bounds.minz             =       zMin; 
    381         bounds.maxx             =       xMax; 
    382         bounds.maxy             =       yMax; 
    383         bounds.maxz             =       zMax; 
    384         bounds.radius   =       mScaleFactor; 
    385  
    386         return  bounds; 
    387 } 
    388 */ 
    389  
    390 //--------------------------------------------------------------------------- 
     282//------------------------------------------------------------------------- 
     283void    GeoMeshView::getBoundingBox() 
     284{ 
     285        float   cx; 
     286        float   cy; 
     287        float   cz; 
     288        float   scale; 
     289 
     290        xMax    =       geoMesh->mMeshBounds.maxX; 
     291        yMax    =       geoMesh->mMeshBounds.maxY; 
     292        zMax    =       geoMesh->mMeshBounds.maxZ; 
     293        xMin    =       geoMesh->mMeshBounds.minX; 
     294        yMin    =       geoMesh->mMeshBounds.minY; 
     295        zMin    =       geoMesh->mMeshBounds.minZ; 
     296        scale   =       geoMesh->mMeshBounds.scaleFactor; 
     297         
     298        //      Calculate center of the model. 
     299        cx = (xMax + xMin) / 2.0f; 
     300        cy = (yMax + yMin) / 2.0f; 
     301        cz = (zMax + zMin) / 2.0f; 
     302 
     303        xMax    -=      cx; 
     304        yMax    -=      cy; 
     305        zMax    -=      cz; 
     306        xMin    -=      cx; 
     307        yMin    -=      cy; 
     308        zMin    -=      cz; 
     309 
     310        xMax    *=      scale; 
     311        yMax    *=      scale; 
     312        zMax    *=      scale; 
     313        xMin    *=      scale; 
     314        yMin    *=      scale; 
     315        zMin    *=      scale; 
     316} 
     317 
     318//------------------------------------------------------------------------- 
    391319//      Constructor. 
    392 //--------------------------------------------------------------------------- 
     320//------------------------------------------------------------------------- 
    393321GeoMeshView::GeoMeshView(       int                                             x, 
    394322                                                                                                        int                                             y, 
     
    446374#define ALPHA 0.5 
    447375 
    448 //--------------------------------------------------------------------------- 
     376//------------------------------------------------------------------------- 
    449377//      Sets the Mesh to display. 
    450 //--------------------------------------------------------------------------- 
     378//------------------------------------------------------------------------- 
    451379void GeoMeshView::setMesh(Mesh  *geomesh) 
    452380{ 
     
    458386        mScaleFactor                    =       geomesh->mMeshBounds.scaleFactor; 
    459387         
     388        //      Gets boundings of mesh. 
     389        getBoundingBox(); 
     390 
    460391        //      Refresh vertices to the vertex array. 
    461392        refreshVertices(geomesh); 
     
    478409} 
    479410 
    480 //--------------------------------------------------------------------------- 
     411//------------------------------------------------------------------------- 
    481412//       Refresh vertices to the vertex array. 
    482 //--------------------------------------------------------------------------- 
     413//------------------------------------------------------------------------- 
    483414void    GeoMeshView::refreshVertices(Mesh       *geomesh) 
    484415{ 
     
    603534} 
    604535 
    605 //--------------------------------------------------------------------------- 
     536//------------------------------------------------------------------------- 
    606537//      Gets the triangle count of the current lod. 
    607 //--------------------------------------------------------------------------- 
     538//------------------------------------------------------------------------- 
    608539size_t  GeoMeshView::getLodStripsTriangleCount() 
    609540{ 
     
    618549} 
    619550 
    620 //--------------------------------------------------------------------------- 
     551//------------------------------------------------------------------------- 
    621552//      Repaint the Mesh. 
    622 //--------------------------------------------------------------------------- 
     553//------------------------------------------------------------------------- 
    623554void GeoMeshView::drawGeoMesh(bool      paintWire) 
    624555{ 
     
    667598}//     End drawGeoMesh. 
    668599 
    669 //--------------------------------------------------------------------------- 
     600//------------------------------------------------------------------------- 
    670601//      Paint eah strip separately. 
    671 //--------------------------------------------------------------------------- 
     602//------------------------------------------------------------------------- 
    672603void GeoMeshView::drawTriangleStrip(int submesh) 
    673604{ 
     
    745676                } 
    746677 
    747  
    748678                //VERTEX ARRAYS 
    749679                glEnableClientState(GL_VERTEX_ARRAY); 
     
    780710}//End drawTriangleStrip. 
    781711 
    782 //--------------------------------------------------------------------------- 
    783 //      Paint the array of idices. 
    784 //--------------------------------------------------------------------------- 
     712//------------------------------------------------------------------------- 
     713//      Paint the array of indices. 
     714//------------------------------------------------------------------------- 
    785715void GeoMeshView::drawTriangleList(     int                     submesh, 
    786716                                                                                                                                                bool            selectedSubMesh, 
     
    895825}//End drawTriangleList 
    896826 
    897 //--------------------------------------------------------------------------- 
     827//------------------------------------------------------------------------- 
    898828//      Paint lodstrip object. 
    899 //--------------------------------------------------------------------------- 
     829//------------------------------------------------------------------------- 
    900830void GeoMeshView::drawLodStrip() 
    901831{ 
     
    970900}//End drawTriangleStrip. 
    971901 
    972 //--------------------------------------------------------------------------- 
     902//------------------------------------------------------------------------- 
    973903//      Paint lodtree object. 
    974 //--------------------------------------------------------------------------- 
     904//------------------------------------------------------------------------- 
    975905void GeoMeshView::drawLodTree() 
    976906{ 
     
    10901020} 
    10911021 
    1092 //--------------------------------------------------------------------------- 
     1022//------------------------------------------------------------------------- 
    10931023//      Sets the lodstripslibrary object. 
    1094 //--------------------------------------------------------------------------- 
     1024//------------------------------------------------------------------------- 
    10951025void    GeoMeshView::setLodStripsLibrary(LodStripsLibrary *lodstrips) 
    10961026{ 
     
    10991029} 
    11001030 
    1101 //--------------------------------------------------------------------------- 
     1031//------------------------------------------------------------------------- 
    11021032//      Sets the lodtreeslibrary object. 
    1103 //--------------------------------------------------------------------------- 
     1033//------------------------------------------------------------------------- 
    11041034void    GeoMeshView::setLodTreesLibrary(LodTreeLibrary *lodtrees) 
    11051035{ 
     
    11081038} 
    11091039 
    1110 //--------------------------------------------------------------------------- 
     1040//------------------------------------------------------------------------- 
    11111041//      Change de Level of detail of the object. 
    1112 //--------------------------------------------------------------------------- 
     1042//------------------------------------------------------------------------- 
    11131043void    GeoMeshView::GoToLod_LodStrip(float     lod) 
    11141044{ 
     
    11261056} 
    11271057 
    1128 //--------------------------------------------------------------------------- 
     1058//------------------------------------------------------------------------- 
    11291059//      Change de Level of detail of the object. 
    1130 //--------------------------------------------------------------------------- 
     1060//------------------------------------------------------------------------- 
    11311061void    GeoMeshView::GoToLod_LodTree(float      lod) 
    11321062{ 
     
    11391069} 
    11401070 
    1141 //--------------------------------------------------------------------------- 
     1071//------------------------------------------------------------------------- 
     1072//      Draw axes. 
     1073//------------------------------------------------------------------------- 
     1074void    GeoMeshView::drawAxes() 
     1075{ 
     1076        float   max; 
     1077 
     1078        max     =       xMax; 
     1079 
     1080        if (yMax > max) 
     1081        { 
     1082                max = yMax; 
     1083        } 
     1084 
     1085        if (zMax > max) 
     1086        { 
     1087                max = zMax; 
     1088        } 
     1089 
     1090        glDisable(GL_LIGHTING); 
     1091        glPolygonMode (GL_FRONT_AND_BACK, GL_LINE); 
     1092        glDisable(GL_CULL_FACE); 
     1093 
     1094        //      Set white color to the object. 
     1095        glColor3d(1.0, 0.0, 0.0); 
     1096 
     1097        //      X axis. 
     1098        glBegin(GL_LINES); 
     1099        glVertex3f(0.0f,0.0f,0.0f); 
     1100        glVertex3f(max,0.0f,0.0f); 
     1101        glEnd(); 
     1102 
     1103        //      Set white color to the object. 
     1104        glColor3d(0.0, 1.0, 0.0); 
     1105 
     1106        //      Y axis. 
     1107        glBegin(GL_LINES); 
     1108        glVertex3f(0.0f,0.0f,0.0f); 
     1109        glVertex3f(0.0f,max,0.0f); 
     1110        glEnd(); 
     1111 
     1112        //      Set white color to the object. 
     1113        glColor3d(0.0, 0.0, 1.0); 
     1114 
     1115        //      Z axis. 
     1116        glBegin(GL_LINES); 
     1117        glVertex3f(0.0f,0.0f,0.0f); 
     1118        glVertex3f(0.0f,0.0f,max); 
     1119        glEnd(); 
     1120} 
     1121 
     1122//------------------------------------------------------------------------- 
     1123//      Draw bounding box. 
     1124//------------------------------------------------------------------------- 
     1125void    GeoMeshView::drawBoundingBox() 
     1126{ 
     1127        glDisable(GL_LIGHTING); 
     1128        glPolygonMode (GL_FRONT_AND_BACK, GL_LINE); 
     1129        glDisable(GL_CULL_FACE); 
     1130 
     1131        //      Set white color to the object. 
     1132        glColor3d(0.0, 0.0, 0.0); 
     1133 
     1134        glBegin(GL_QUADS); 
     1135        glVertex3f(xMin,yMin,zMin); 
     1136        glVertex3f(xMin,yMax,zMin); 
     1137        glVertex3f(xMax,yMax,zMin); 
     1138        glVertex3f(xMax,yMin,zMin); 
     1139 
     1140        glVertex3f(xMin,yMin,zMin); 
     1141        glVertex3f(xMin,yMax,zMin); 
     1142        glVertex3f(xMin,yMax,zMax); 
     1143        glVertex3f(xMin,yMin,zMax); 
     1144 
     1145        glVertex3f(xMax,yMin,zMin); 
     1146        glVertex3f(xMax,yMax,zMin); 
     1147        glVertex3f(xMax,yMax,zMax); 
     1148        glVertex3f(xMax,yMin,zMax); 
     1149 
     1150        glVertex3f(xMax,yMin,zMax); 
     1151        glVertex3f(xMax,yMax,zMax); 
     1152        glVertex3f(xMin,yMax,zMax); 
     1153        glVertex3f(xMin,yMin,zMax); 
     1154 
     1155        glVertex3f(xMin,yMin,zMax); 
     1156        glVertex3f(xMax,yMin,zMax); 
     1157        glVertex3f(xMax,yMin,zMin); 
     1158        glVertex3f(xMin,yMin,zMin); 
     1159 
     1160        glVertex3f(xMin,yMax,zMax); 
     1161        glVertex3f(xMax,yMax,zMax); 
     1162        glVertex3f(xMax,yMax,zMin); 
     1163        glVertex3f(xMin,yMax,zMin); 
     1164 
     1165        glEnd(); 
     1166} 
     1167 
     1168//------------------------------------------------------------------------- 
    11421169//      Draw the object in the window. 
    1143 //--------------------------------------------------------------------------- 
     1170//------------------------------------------------------------------------- 
    11441171void GeoMeshView::draw() 
    11451172{ 
     
    11821209        //glTranslatef(-xMed,-yMed,-zMed); 
    11831210 
     1211        GLfloat color_blanco[]  =       {1.0f,1.0f,1.0f,1.0f}; 
     1212 
     1213        glMaterialfv(GL_FRONT_AND_BACK,GL_DIFFUSE,color_blanco); 
     1214 
     1215        glClearColor(0.3,0.3,0.3,0); 
     1216         
     1217        if ((geoMesh != NULL) && mAxes) 
     1218        { 
     1219                //      Draw coordinates axes. 
     1220                drawAxes(); 
     1221        } 
     1222 
     1223        if ((geoMesh != NULL) && mBBox) 
     1224        { 
     1225                //      Draw bounding box. 
     1226                drawBoundingBox(); 
     1227        } 
     1228 
    11841229        //      Set white color to the object. 
    11851230        glColor3d(1.0, 1.0, 1.0); 
    11861231 
    1187         GLfloat color_blanco[]  =       {1.0f,1.0f,1.0f,1.0f}; 
    1188  
    1189         glMaterialfv(GL_FRONT_AND_BACK,GL_DIFFUSE,color_blanco); 
    1190  
    1191         glClearColor(0.3,0.3,0.3,0); 
    1192          
     1232        if (mLighting) 
     1233        { 
     1234                glEnable(GL_LIGHTING); 
     1235        } 
     1236        else 
     1237        { 
     1238                glDisable(GL_LIGHTING); 
     1239        } 
     1240 
    11931241        if (mCW) 
    11941242        { 
     
    12141262                glPolygonMode (GL_FRONT_AND_BACK, GL_FILL); 
    12151263                drawGeoMesh(false); 
    1216         } 
    1217  
    1218         if (mLighting) 
    1219         { 
    1220                 glEnable(GL_LIGHTING); 
    1221         } 
    1222         else 
    1223         { 
    1224                 glDisable(GL_LIGHTING); 
    12251264        } 
    12261265 
     
    12641303 
    12651304        swap_buffers(); 
    1266  
    1267         //      Calculate the FPS. 
    1268         //calcFPS(); 
    12691305} 
    12701306 
  • GTP/trunk/Lib/Geom/shared/GeoTool/src/GeoMeshViewUI.cpp

    r2103 r2127  
    653653                                                                                -> 
    654654                                                                                cb_menuRenderTextures_i(o,v); 
     655} 
     656 
     657//------------------------------------------------------------------------- 
     658//      Bounding Box callback 
     659//------------------------------------------------------------------------- 
     660inline void GeoMeshViewUI::cb_menuRenderBoundingBox_i(fltk::Item        *item, 
     661                                                                                                                                                                                                                        void    *v) 
     662{ 
     663        //      If the item is activated. 
     664        if (item->value()) 
     665        { 
     666                geoMeshView->activeBoundingBox(); 
     667        } 
     668        else 
     669        { 
     670                geoMeshView->deactiveBoundingBox(); 
     671        } 
     672 
     673        //      Repaint the main window. 
     674        mMainWindow->redraw(); 
     675} 
     676 
     677void GeoMeshViewUI::cb_menuRenderBoundingBox(fltk::Item* o, void* v) 
     678{ 
     679  ((GeoMeshViewUI*)     (o->parent()->parent()->parent()->user_data())) 
     680                                                                                -> 
     681                                                                                cb_menuRenderBoundingBox_i(o,v); 
     682} 
     683 
     684//------------------------------------------------------------------------- 
     685//      Axes callback 
     686//------------------------------------------------------------------------- 
     687inline void GeoMeshViewUI::cb_menuRenderAxes_i(fltk::Item       *item, 
     688                                                                                                                                                                                                                        void    *v) 
     689{ 
     690        //      If the item is activated. 
     691        if (item->value()) 
     692        { 
     693                geoMeshView->activeAxes(); 
     694        } 
     695        else 
     696        { 
     697                geoMeshView->deactiveAxes(); 
     698        } 
     699 
     700        //      Repaint the main window. 
     701        mMainWindow->redraw(); 
     702} 
     703 
     704void GeoMeshViewUI::cb_menuRenderAxes(fltk::Item* o, void* v) 
     705{ 
     706  ((GeoMeshViewUI*)     (o->parent()->parent()->parent()->user_data())) 
     707                                                                                -> 
     708                                                                                cb_menuRenderAxes_i(o,v); 
    655709} 
    656710 
     
    24682522        static  char                    title[256]; 
    24692523         
    2470         fcho    =       new fltk::FileChooser("", "*.{mesh,obj}", fltk::FileChooser::CREATE, "Open a mesh"); 
     2524        fcho    =       new fltk::FileChooser("", 
     2525                                                                                                                                "*.{mesh,obj}", 
     2526                                                                                                                                fltk::FileChooser::CREATE, 
     2527                                                                                                                                "Open a mesh"); 
    24712528 
    24722529        fcho->exec(); 
     
    25602617                } 
    25612618        } 
     2619 
    25622620        //      Free memory. 
    25632621        delete  fcho; 
     
    29933051 
    29943052                                { 
    2995                                         fltk::Item* o = menuRenderTextures = new fltk::Item("Texture mapping"); 
     3053                                        fltk::Item* o = new fltk::Item("Texture mapping"); 
    29963054                                        o->type(fltk::Item::RADIO); 
    29973055                                        o->set_value(); 
    29983056                                        o->callback((fltk::Callback*)cb_menuRenderTextures); 
     3057                                } 
     3058 
     3059                                new fltk::Divider(); 
     3060 
     3061                                { 
     3062                                        fltk::Item* o = new fltk::Item("Axis"); 
     3063                                        o->type(fltk::Item::RADIO); 
     3064                                        o->set_value(); 
     3065                                        o->callback((fltk::Callback*)cb_menuRenderAxes); 
     3066                                } 
     3067 
     3068                                { 
     3069                                        fltk::Item* o = new fltk::Item("Bounding Box"); 
     3070                                        o->type(fltk::Item::RADIO); 
     3071                                        o->set_value(); 
     3072                                        o->callback((fltk::Callback*)cb_menuRenderBoundingBox); 
    29993073                                } 
    30003074 
     
    31413215GeoMeshViewUI::~GeoMeshViewUI() 
    31423216{ 
    3143         delete  geoMeshLoader; 
     3217        //delete        geoMeshLoader; 
    31443218        mMainWindow->destroy(); 
    31453219} 
Note: See TracChangeset for help on using the changeset viewer.