Ignore:
Timestamp:
05/29/06 11:59:07 (18 years ago)
Author:
gumbau
Message:
 
Location:
GTP/trunk/Lib/Geom/shared/GeoTool/src
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • GTP/trunk/Lib/Geom/shared/GeoTool/src/GeoMeshLoader.cpp

    r985 r989  
    1515using   namespace       std; 
    1616 
     17//--------------------------------------------------------------------------- 
    1718//      Jump a chunk. 
     19//--------------------------------------------------------------------------- 
    1820void GeoMeshLoader::jumpChunk(FILE      *f) 
    1921{ 
     
    2426} 
    2527 
     28//--------------------------------------------------------------------------- 
    2629//      Read a chunk. 
     30//--------------------------------------------------------------------------- 
    2731unsigned short GeoMeshLoader::readChunk(FILE    *f) 
    2832{ 
     
    3539} 
    3640 
     41//--------------------------------------------------------------------------- 
    3742//      Read geometry vertex element. 
     43//--------------------------------------------------------------------------- 
    3844void GeoMeshLoader::readGeometryVertexElement(FILE      *f, Mesh        *geoMesh) 
    3945{ 
     
    103109} 
    104110 
     111//--------------------------------------------------------------------------- 
    105112//      Read geometry vertex declaration. 
     113//--------------------------------------------------------------------------- 
    106114void GeoMeshLoader::readGeometryVertexDeclaration(FILE  *f, Mesh        *geoMesh) 
    107115{ 
     
    143151}//     End readGeometryVertexDeclaration. 
    144152 
     153//--------------------------------------------------------------------------- 
    145154//      Read geometry vertex buffer. 
     155//--------------------------------------------------------------------------- 
    146156void GeoMeshLoader::readGeometryVertexBuffer(FILE       *f, Mesh        *geoMesh, int option) 
    147157{ 
     
    270280                cout    <<      "Error: Source not found." 
    271281                                        <<      endl; 
    272         } 
    273  
    274 } 
    275  
     282 
     283                //      Error. 
     284                mError  =       true; 
     285        } 
     286 
     287} 
     288 
     289//--------------------------------------------------------------------------- 
    276290//      Read Geometry. 
     291//--------------------------------------------------------------------------- 
    277292void GeoMeshLoader::readGeometry(FILE   *f, Mesh        *geoMesh, int option) 
    278293{ 
     
    361376} 
    362377 
     378//--------------------------------------------------------------------------- 
    363379//      Read a submesh operation. 
     380//--------------------------------------------------------------------------- 
    364381void GeoMeshLoader::readSubMeshOperation(       FILE    *f, 
    365382                                                                                                                                                                        Mesh    *geoMesh, 
     
    383400} 
    384401 
     402//--------------------------------------------------------------------------- 
    385403//      Read a submesh. 
     404//--------------------------------------------------------------------------- 
    386405void GeoMeshLoader::readSubMesh(FILE    *f, Mesh        *geoMesh, int option) 
    387406{ 
     
    479498                        cout    <<      "Error: Missing mesh geometry." 
    480499                                                <<      endl; 
     500 
     501                        //      Error. 
     502                        mError  =       true; 
    481503                } 
    482504                 
     
    537559} 
    538560 
     561//--------------------------------------------------------------------------- 
    539562//      Read a mesh lod information. 
     563//--------------------------------------------------------------------------- 
    540564void GeoMeshLoader::readMeshLodInfo(FILE        *f, Mesh        *geoMesh) 
    541565{ 
     
    572596} 
    573597 
     598//--------------------------------------------------------------------------- 
    574599//      Read a submesh name table. 
     600//--------------------------------------------------------------------------- 
    575601void GeoMeshLoader::readSubMeshNameTable(FILE   *f, Mesh        *geoMesh) 
    576602{ 
     
    609635} 
    610636 
     637//--------------------------------------------------------------------------- 
    611638//      Read a mesh file. 
     639//--------------------------------------------------------------------------- 
    612640void GeoMeshLoader::readMesh(FILE       *f, Mesh        *geoMesh, int option) 
    613641{ 
     
    741769                        cout    <<      "Error: Reading failure." 
    742770                                                <<      endl; 
    743                 } 
    744         } 
    745  
    746 } 
    747  
    748 /* 
    749                 Allocate memory to the array of strips 
    750 */ 
     771 
     772                        //      Error. 
     773                        mError  =       true; 
     774                } 
     775        } 
     776 
     777} 
     778 
     779 
     780//--------------------------------------------------------------------------- 
     781//      Allocate memory to the array of strips 
     782//--------------------------------------------------------------------------- 
    751783SubMesh* GeoMeshLoader::BuildStripsGeoSubMesh(SubMesh* geoSubMesh) 
    752784{ 
     
    848880} 
    849881 
     882//--------------------------------------------------------------------------- 
    850883//      Remove degenerate triangles of a submesh given. 
     884//--------------------------------------------------------------------------- 
    851885SubMesh *       GeoMeshLoader::removeDegenerateTriangles(SubMesh        *geoSubMesh) 
    852886{ 
     
    951985} 
    952986 
     987//--------------------------------------------------------------------------- 
    953988//      Loads a mesh. 
     989//--------------------------------------------------------------------------- 
    954990Mesh* GeoMeshLoader::load(char  *nameFileMesh)  
    955991{ 
     
    961997        SubMesh                                 *geosubmesh; 
    962998 
    963         //      Initialize the current submesh; 
    964         currentSubMesh  =       -1; 
    965          
    966999        //      Debug. 
    9671000        cout    <<      "---------------------------------" 
     
    9721005                                <<      endl; 
    9731006 
    974         //      Initialize the return value. 
    975         geoMesh =       new     Mesh(); 
     1007        geoMesh =       NULL; 
    9761008 
    9771009        //      Open the mesh file. 
    978         pFile   =       fopen( nameFileMesh, "rb" ); 
    979  
    980   if (!pFile) 
    981   { 
     1010        pFile   =       fopen(nameFileMesh, "rb"); 
     1011 
     1012  if (pFile) 
     1013        { 
     1014                //      Initialize the current submesh; 
     1015                currentSubMesh  =       -1; 
     1016 
     1017                //      Initialize the return value. 
     1018                geoMesh =       new     Mesh(); 
     1019 
     1020                //      Count the submeshes 
     1021                //      and next build the geomesh. 
     1022                for (int option = 0; option < 2;option++) 
     1023                { 
     1024                        //      Initialize Error. 
     1025                        mError  =       false; 
     1026         
     1027                        fread(&uno,sizeof(unsigned short),1,pFile); 
     1028 
     1029                        if (uno != M_HEADER) 
     1030                        { 
     1031                                //      Debug. 
     1032                                cout    <<      "Error: Header not found." 
     1033                                        <<      endl; 
     1034 
     1035                                //      Error. 
     1036                                mError  =       true; 
     1037                        } 
     1038 
     1039                        // Read version. 
     1040                        fgets(version,255,pFile); 
     1041 
     1042                        cout    <<      version <<      endl; 
     1043 
     1044                        if (strcmp(version,"[MeshSerializer_v1.30]\n")) 
     1045                        { 
     1046                                //      Debug. 
     1047                                cout    <<      "Error: Wrong mesh version." 
     1048                                        <<      endl 
     1049                                        <<      "Only version 1.3 or older allowed." 
     1050                                        <<      endl; 
     1051 
     1052                                //      Error. 
     1053                                mError  =       true; 
     1054                        } 
     1055 
     1056                        while(!feof(pFile)) 
     1057                        { 
     1058                                chunkID = readChunk(pFile); 
     1059 
     1060                                switch (chunkID) 
     1061                                { 
     1062                                        case M_MESH: 
     1063                                                readMesh(pFile, geoMesh, option); 
     1064                                                break; 
     1065                                } 
     1066                        } 
     1067 
     1068                        //      Create the submesh array. 
     1069                        if (option == SUBMESH_COUNT) 
     1070                        { 
     1071                                geoMesh->mSubMesh       = new SubMesh[geoMesh->mSubMeshCount]; 
     1072                        } 
     1073 
     1074                        //      Move the curso to the begining of the file. 
     1075                        fseek(pFile,0,SEEK_SET); 
     1076                } 
     1077 
     1078                //      Goes to the end of the file. 
     1079                fseek(pFile,0,SEEK_END); 
     1080 
     1081                //      Gets the size of the file. 
     1082                mFileSize       =       ftell(pFile); 
     1083 
     1084                // Close the mesh file. 
     1085                fclose(pFile); 
     1086 
     1087                //      If no error. 
     1088                if (!mError) 
     1089                { 
     1090                        for (int submesh = 0;   submesh < geoMesh->mSubMeshCount; submesh++) 
     1091                        { 
     1092                                //      Gets the actual submesh. 
     1093                                geosubmesh      =       &geoMesh->mSubMesh[submesh]; 
     1094 
     1095                                if (geosubmesh->mType == Geometry::GEO_TRIANGLE_STRIPS) 
     1096                                { 
     1097                                        //      Fill the strips list. 
     1098                                        geosubmesh      =       BuildStripsGeoSubMesh(geosubmesh); 
     1099                                } 
     1100                        } 
     1101 
     1102                        //      Sets coods between -1 and 1. 
     1103                        normalizeModel(geoMesh); 
     1104                } 
     1105        } 
     1106        else 
     1107        { 
    9821108                //      Debug. 
    983                 cout    <<      "Error: File " 
    984                                         <<      nameFileMesh 
    985                                         <<      " not found." 
     1109                cout    <<      "Error: File not found." 
    9861110                                        <<      endl; 
     1111 
     1112                //      File not found. 
     1113                mError  =       true; 
     1114        } 
     1115 
     1116        //      If an error happens. 
     1117        if (mError) 
     1118        { 
     1119                delete  geoMesh; 
    9871120                 
    988                 exit(0); 
    989   } 
    990  
    991         //      Count the submeshes 
    992         //      and next build the geomesh. 
    993         for (int option = 0; option < 2;option++) 
    994         { 
    995                 fread(&uno,sizeof(unsigned short),1,pFile); 
    996  
    997                 if (uno != M_HEADER) 
    998                 { 
    999                         //      Debug. 
    1000                         cout    <<      "Error: Header not found." 
    1001                                                 <<      endl; 
    1002                 } 
    1003  
    1004                 // Read version. 
    1005                 fgets(version,255,pFile); 
    1006  
    1007                 cout    <<      version <<      endl; 
    1008  
    1009                 if (strcmp(version,"[MeshSerializer_v1.30]\n")) 
    1010                 { 
    1011                         //      Debug. 
    1012                         cout    <<      "Error: Wrong mesh version." 
    1013                                                 <<      endl 
    1014                                                 <<      "Only version 1.3 or older allowed." 
    1015                                                 <<      endl; 
    1016                 } 
    1017  
    1018                 while(!feof(pFile)) 
    1019                 { 
    1020                         chunkID = readChunk(pFile); 
    1021  
    1022                         switch (chunkID) 
    1023                         { 
    1024                                 case M_MESH: 
    1025                                         readMesh(pFile, geoMesh, option); 
    1026                                         break; 
    1027                         } 
    1028                 } 
    1029  
    1030                 //      Create the submesh array 
    1031                 if (option == SUBMESH_COUNT) 
    1032                 {                
    1033                         geoMesh->mSubMesh       = new SubMesh[geoMesh->mSubMeshCount]; 
    1034                 } 
    1035                                                          
    1036                 //      Move the curso to the begining of the file. 
    1037                 fseek(pFile,0,SEEK_SET); 
    1038         } 
    1039  
    1040         //      Goes to the end of the file. 
    1041         fseek(pFile,0,SEEK_END); 
    1042  
    1043         //      Gets the size of the file. 
    1044         mFileSize       =       ftell(pFile); 
    1045          
    1046         // Close the mesh file. 
    1047         fclose(pFile); 
    1048          
    1049         for (int submesh = 0;   submesh < geoMesh->mSubMeshCount; submesh++) 
    1050         { 
    1051                 //      Gets the actual submesh. 
    1052                 geosubmesh      =       &geoMesh->mSubMesh[submesh]; 
    1053                  
    1054                 if (geosubmesh->mType == Geometry::GEO_TRIANGLE_STRIPS) 
    1055                 { 
    1056                         //      Fill the strips list. 
    1057                         geosubmesh      =       BuildStripsGeoSubMesh(geosubmesh); 
    1058                 } 
    1059         } 
    1060          
    1061         //      Sets coods between -1 and 1. 
    1062         normalizeModel(geoMesh); 
    1063  
     1121                geoMesh =       NULL; 
     1122        } 
     1123         
    10641124        return  geoMesh; 
    10651125} 
    10661126 
     1127//--------------------------------------------------------------------------- 
    10671128//      Sets coords between -1 and 1. 
     1129//--------------------------------------------------------------------------- 
    10681130void    GeoMeshLoader::normalizeModel(Mesh      *geoMesh) 
    10691131{ 
     
    11871249} 
    11881250 
     1251//--------------------------------------------------------------------------- 
    11891252//      Get the size in bytes of the file. 
     1253//--------------------------------------------------------------------------- 
    11901254size_t  GeoMeshLoader::getFileSize() 
    11911255{ 
     
    11931257} 
    11941258 
     1259//--------------------------------------------------------------------------- 
    11951260//      Constructor 
     1261//--------------------------------------------------------------------------- 
    11961262GeoMeshLoader::GeoMeshLoader() 
    11971263{ 
     
    12001266} 
    12011267 
     1268//--------------------------------------------------------------------------- 
    12021269//      Destroyer. 
     1270//--------------------------------------------------------------------------- 
    12031271GeoMeshLoader::~GeoMeshLoader() 
    12041272{ 
     
    12061274} 
    12071275 
    1208 //OSCAR 
     1276//--------------------------------------------------------------------------- 
     1277//      Read bones of the submesh. 
     1278//--------------------------------------------------------------------------- 
    12091279void GeoMeshLoader::readSubMeshBoneAssignment(FILE* f, SubMesh* geoSubMesh,int option) 
    12101280{ 
     
    12241294} 
    12251295 
    1226 //OSCAR 
     1296//--------------------------------------------------------------------------- 
     1297//      Read bones of the main mesh. 
     1298//--------------------------------------------------------------------------- 
    12271299void GeoMeshLoader::readMeshBoneAssignment(FILE* f, Mesh* geoMesh,int option) 
    12281300{ 
     
    12431315} 
    12441316 
    1245 //OSCAR 
     1317//--------------------------------------------------------------------------- 
     1318//      Read skeleton link. 
     1319//--------------------------------------------------------------------------- 
    12461320void GeoMeshLoader::readSkeletonLink(FILE* f, Mesh* geoMesh,int option) 
    12471321{ 
     
    12591333} 
    12601334 
     1335//--------------------------------------------------------------------------- 
    12611336//      Read bounding box settings. 
     1337//--------------------------------------------------------------------------- 
    12621338void    GeoMeshLoader::readMeshBounds(FILE      *f, Mesh        *geoMesh,       int     option) 
    12631339{ 
  • GTP/trunk/Lib/Geom/shared/GeoTool/src/GeoMeshSaver.cpp

    r985 r989  
    1 /*      ========================================================================== 
     1/*========================================================================== 
    22 *      (C) 2005 Universitat Jaume I 
    3  *      ========================================================================== 
     3 *========================================================================== 
    44 *      PROYECT:        GAME TOOLS 
    5  *      ==========================================================================*/ 
    6 /**     CONTENT:         
    7         * 
    8         * 
    9         *       @file   GeoMeshSaver.cpp 
    10 /*===========================================================================*/ 
     5 *==========================================================================*/ 
     6/*      CONTENT:         
     7 * 
     8 * 
     9 *      @file   GeoMeshSaver.cpp 
     10 *==========================================================================*/ 
    1111#include        <GeoMeshSaver.h> 
    1212 
     
    1414using   namespace       std; 
    1515 
    16 //------------------------------------------ 
     16//--------------------------------------------------------------------------- 
    1717//              Public: 
    18 //------------------------------------------ 
    19  
    20 //////////////////// 
    21 //      Constructors.   // 
    22 //////////////////// 
     18//--------------------------------------------------------------------------- 
     19 
     20//--------------------------------------------------------------------------- 
     21//      Constructors. 
     22//--------------------------------------------------------------------------- 
    2323GeoMeshSaver::GeoMeshSaver() 
    2424{ 
    2525} 
    2626 
    27 ////////////////// 
    28 //      Destroyer.      // 
    29 ////////////////// 
     27//--------------------------------------------------------------------------- 
     28//      Destroyer. 
     29//--------------------------------------------------------------------------- 
    3030GeoMeshSaver::~GeoMeshSaver() 
    3131{ 
     
    3333} 
    3434 
     35//--------------------------------------------------------------------------- 
    3536//      Saves a Mesh into a file. 
     37//--------------------------------------------------------------------------- 
    3638int     GeoMeshSaver::save(Mesh *geoMesh,       const   char    *fileNameMesh) 
    3739{ 
  • GTP/trunk/Lib/Geom/shared/GeoTool/src/GeoMeshViewUI.cpp

    r988 r989  
    8383//      Save As Callback 
    8484//--------------------------------------------------------------------------- 
    85 inline void GeoMeshViewUI::cb_menuOpenSaveAs_i(fltk::Item*, void*) 
     85inline void GeoMeshViewUI::cb_menuFileSaveAs_i(fltk::Item*, void*) 
    8686{ 
    8787        fltk::FileChooser *fcho; 
    8888        GeoMeshSaver                    *mesh_saver; 
     89        char                                                    file_name[255]; 
     90        char                                                    message[255]; 
     91        char                                                    *ptr; 
     92        int                                                             answer_yes; 
     93         
     94        //      Initialize answer to yes. 
     95        answer_yes      =       1; 
    8996         
    9097        if (mGeoMesh != NULL) 
     
    99106                if (fcho->value()) 
    100107                { 
    101                         mesh_saver      =       new     GeoMeshSaver(); 
    102                         mesh_saver->save(mGeoMesh,filename_name(fcho->value())); 
    103                         delete  mesh_saver; 
     108                        //      Gets file name. 
     109                        strcpy(file_name,fcho->value()); 
     110 
     111                        //      Cut extension. 
     112                        ptr                             =       strtok(file_name,"."); 
     113 
     114                        //      If has extension. 
     115                        if (ptr) 
     116                        { 
     117                                strcpy(file_name,ptr); 
     118                        } 
     119 
     120                        //      Adds mesh extension. 
     121                        strcat(file_name,".mesh"); 
     122 
     123                        //      If File Exists. 
     124                        if (fileExists(file_name)) 
     125                        { 
     126                                //      Compose message. 
     127                                strcpy(message,"Do you want to replace "); 
     128                                strcat(message,file_name); 
     129                                strcat(message,"?"); 
     130 
     131                                //      Question. 
     132                                answer_yes      =       fltk::ask(message); 
     133                        } 
     134 
     135                        //      If answer yes to replace question. 
     136                        //      or if file not exists. 
     137                        if (answer_yes) 
     138                        { 
     139                                mesh_saver      =       new     GeoMeshSaver(); 
     140 
     141 
     142                                mesh_saver->save(mGeoMesh,filename_name(file_name)); 
     143 
     144                                delete  mesh_saver; 
     145                        } 
    104146                } 
    105  
    106147                //      Repaint the window. 
    107148                mMainWindow->redraw(); 
     
    111152} 
    112153 
    113 void GeoMeshViewUI::cb_menuOpenSaveAs(fltk::Item* o, void* v) 
    114 { 
    115   ((GeoMeshViewUI*)     (o->parent()->parent()->parent()->user_data())) 
    116                                                                                 -> 
    117                                                                                 cb_menuOpenSaveAs_i(o,v); 
     154void GeoMeshViewUI::cb_menuFileSaveAs(fltk::Item* o, void* v) 
     155{ 
     156  ((GeoMeshViewUI*)     (o->parent()->parent()->parent()->user_data())) 
     157                                                                                -> 
     158                                                                                cb_menuFileSaveAs_i(o,v); 
    118159} 
    119160 
     
    210251//      Quit Callback 
    211252//--------------------------------------------------------------------------- 
    212 inline void GeoMeshViewUI::cb_menuOpenQuit_i(fltk::Item*, void*) 
     253inline void GeoMeshViewUI::cb_menuFileQuit_i(fltk::Item*, void*) 
    213254{ 
    214255        delete  this; 
    215256} 
    216257 
    217 void GeoMeshViewUI::cb_menuOpenQuit(fltk::Item* o, void* v) 
    218 { 
    219   ((GeoMeshViewUI*)     (o->parent()->parent()->parent()->user_data())) 
    220                                                                                 -> 
    221                                                                                 cb_menuOpenQuit_i(o,v); 
     258void GeoMeshViewUI::cb_menuFileQuit(fltk::Item* o, void* v) 
     259{ 
     260  ((GeoMeshViewUI*)     (o->parent()->parent()->parent()->user_data())) 
     261                                                                                -> 
     262                                                                                cb_menuFileQuit_i(o,v); 
    222263} 
    223264 
     
    710751        openMeshFile(); 
    711752         
    712         //      Show title. 
    713         mProcessTitle->label("Visualize LodStrips"); 
    714753 
    715754        //      If an object is loaded. 
     
    735774                //      Free memory. 
    736775                delete  fcho; 
    737         } 
    738776 
    739777        //      Hide the right panel. 
    740778        hideRightPanel(); 
    741779 
     780        //      Show title. 
     781        mProcessTitle->label("Visualize LodStrips"); 
     782 
    742783        //      Show the Visulize LodStrips panel. 
    743784        showLodStripSlider(); 
     
    745786        //      Repaint the window. 
    746787        mMainWindow->redraw(); 
    747 } 
    748  
     788 
     789        } 
     790} 
    749791 
    750792inline void GeoMeshViewUI::cb_menuLodTreesVisualize_i(fltk::Item*, void*) 
     
    752794        fltk::FileChooser *fcho; 
    753795        const   char                            *lod_file; 
    754          
     796 
    755797        //      Sets menus application state to NONE. 
    756798        mApplicationState       =       NONE; 
     
    762804        //      Loads a mesh file. 
    763805        openMeshFile(); 
    764          
    765         //      Show title. 
    766         mProcessTitle->label("Visualize LodTrees"); 
    767806 
    768807        /*if (geoMeshView->getLeavesSubmesh()==-1) 
    769         { 
     808                { 
    770809                fltk::alert("No se ha seleccionado el submesh de hojas!"); 
    771810                return; 
    772         }*/ 
    773  
    774         // POR AHORA SE SELECCIONA EL PRIMER SUBMESH QUE NO ES STRIPS COMO HOJAS 
    775         int leafsSubMeshID = -1; 
    776         for (int i=0; i<mGeoMesh->mSubMeshCount; i++) 
    777                 if (mGeoMesh->mSubMesh[i].mType==GEO_TRIANGLE_LIST) 
    778                 { 
    779                         leafsSubMeshID=i; 
    780                         break; 
    781                 } 
    782  
    783  
     811                }*/ 
    784812 
    785813        //      If an object is loaded. 
    786814        if (mGeoMesh != NULL) 
    787815        { 
    788                 fcho    =       new fltk::FileChooser("", 
    789                                 "*.lod", 
    790                                 fltk::FileChooser::CREATE, 
    791                                 "Open Lod file"); 
    792  
    793                 fcho->exec(); 
    794  
    795                 //      If a file was selected. 
    796                 if (fcho->value()) 
     816                // POR AHORA SE SELECCIONA EL PRIMER SUBMESH QUE NO ES STRIPS COMO HOJAS 
     817                int leafsSubMeshID = -1; 
     818 
     819                for (int i=0; i<mGeoMesh->mSubMeshCount; i++) 
    797820                { 
    798                         //      Build lod strips library. 
    799  
    800                         std::string lodstripFile(fcho->value()); 
    801                         delete fcho; 
     821                        if (mGeoMesh->mSubMesh[i].mType==GEO_TRIANGLE_LIST) 
     822                        { 
     823                                leafsSubMeshID=i; 
     824                                break; 
     825                        } 
     826                } 
     827 
     828                //      If an object is loaded. 
     829                if (mGeoMesh != NULL) 
     830                { 
    802831                        fcho    =       new fltk::FileChooser("", 
    803                                         "*.leafseq", 
     832                                        "*.lod", 
    804833                                        fltk::FileChooser::CREATE, 
    805                                         "Open LeafSeq file"); 
     834                                        "Open Lod file"); 
    806835 
    807836                        fcho->exec(); 
    808837 
     838                        //      If a file was selected. 
    809839                        if (fcho->value()) 
    810840                        { 
    811                                 std::string leafseqFile(fcho->value()); 
    812  
    813                                 setLodTreesLibrary(lodstripFile, leafseqFile, mGeoMesh, leafsSubMeshID); 
    814  
    815                                 //      Sets the aplication mode. 
    816                                 mApplicationState       =       VISUALIZE_LODTREES; 
     841                                //      Build lod strips library. 
     842 
     843                                std::string lodstripFile(fcho->value()); 
     844                                delete fcho; 
     845                                fcho    =       new fltk::FileChooser("", 
     846                                                "*.leafseq", 
     847                                                fltk::FileChooser::CREATE, 
     848                                                "Open LeafSeq file"); 
     849 
     850                                fcho->exec(); 
     851 
     852                                if (fcho->value()) 
     853                                { 
     854                                        std::string leafseqFile(fcho->value()); 
     855 
     856                                        setLodTreesLibrary(lodstripFile, leafseqFile, mGeoMesh, leafsSubMeshID); 
     857 
     858                                        //      Sets the aplication mode. 
     859                                        mApplicationState       =       VISUALIZE_LODTREES; 
     860                                } 
    817861                        } 
     862 
     863                        //      Free memory. 
     864                        delete  fcho; 
     865 
     866                        //      Hide the right panel. 
     867                        hideRightPanel(); 
     868 
     869                        //      Show title. 
     870                        mProcessTitle->label("Visualize LodTrees"); 
     871 
     872                        //      Show the Visulize LodTree panel. 
     873                        showLodStripSlider(); 
     874                        showLodTreeSlider(); 
     875 
     876                        //      Repaint the window. 
     877                        mMainWindow->redraw(); 
    818878                } 
    819  
    820                 //      Free memory. 
    821                 delete  fcho; 
    822         } 
    823  
    824         //      Hide the right panel. 
    825         hideRightPanel(); 
    826  
    827         //      Show the Visulize LodTree panel. 
    828         showLodStripSlider(); 
    829         showLodTreeSlider(); 
    830          
    831         //      Repaint the window. 
    832         mMainWindow->redraw(); 
    833 } 
     879        } 
     880} 
     881 
    834882void GeoMeshViewUI::cb_menuLodTreesVisualize(fltk::Item *o, void *v) 
    835883{ 
     
    10091057                                                //      Create the simplification sequence. 
    10101058                                                createSimplificationSequence(); 
     1059 
     1060                                                //      Show build process. 
     1061                                                activeBuildProcess(); 
    10111062                                        } 
    10121063 
     
    10541105                                                delete  mMeshSimplifier; 
    10551106                                                geoMeshView->restoreContext(); 
     1107 
     1108                                                //      Show build process. 
     1109                                                activeBuildProcess(); 
    10561110                                        } 
    10571111                                } 
     
    11071161inline void GeoMeshViewUI::cb_mButtonBuild_i(fltk::Button*, void*) 
    11081162{ 
    1109         char                    *file_name=NULL; 
     1163        char                                    *file_name      =       NULL; 
    11101164        GeoMeshSaver    *mesh_saver; 
    11111165        Serializer              *oSerializer; 
    1112          
     1166 
    11131167        //      Sets the progress bar to process bar. 
    11141168        progressBarType =       BUILD; 
     
    11251179                        //      Build the LOD file. 
    11261180                        case    LODTREES_AUTO:                   
    1127                                  
     1181 
    11281182                                //      Open file chooser dialog. 
    11291183                                file_name       =       fltk::file_chooser("Build LOD","*",""); 
     
    11351189                                std::cout << "OK!" << std::endl; 
    11361190 
    1137 /*                              TreeSimplificationSequence * auxTreeSimpSequence = new TreeSimplificationSequence(); 
    1138                                 auxTreeSimpSequence->Load(Serializer("leavesSimplification.txt",Serializer::READ)); 
    1139  
    1140                                 if (auxTreeSimpSequence && mGeoMesh) 
    1141                                 { 
    1142                                         LodTreeConstructor * auxLodTreeConstructor = new LodTreeConstructor(mGeoMesh,auxTreeSimpSequence); 
    1143                                         delete auxLodTreeConstructor; 
    1144                                 } 
    1145                                 else 
    1146                                 { 
    1147                                         fltk::alert("There is no leaf simplification sequence."); 
    1148                                         break; 
    1149                                 } 
    1150  
    1151  
    1152                                 delete auxTreeSimpSequence;*/ 
    1153                                  
     1191                                /*                              TreeSimplificationSequence * auxTreeSimpSequence = new TreeSimplificationSequence(); 
     1192                                                                        auxTreeSimpSequence->Load(Serializer("leavesSimplification.txt",Serializer::READ)); 
     1193 
     1194                                                                        if (auxTreeSimpSequence && mGeoMesh) 
     1195                                                                        { 
     1196                                                                        LodTreeConstructor * auxLodTreeConstructor = new LodTreeConstructor(mGeoMesh,auxTreeSimpSequence); 
     1197                                                                        delete auxLodTreeConstructor; 
     1198                                                                        } 
     1199                                                                        else 
     1200                                                                        { 
     1201                                                                        fltk::alert("There is no leaf simplification sequence."); 
     1202                                                                        break; 
     1203                                                                        } 
     1204 
     1205 
     1206                                                                        delete auxTreeSimpSequence;*/ 
     1207 
    11541208 
    11551209                        case    LODSTRIPS_AUTO: 
     
    13091363 
    13101364//--------------------------------------------------------------------------- 
     1365//      Active Build process. 
     1366//--------------------------------------------------------------------------- 
     1367void    GeoMeshViewUI::activeBuildProcess() 
     1368{ 
     1369        //mButtonBuild->set_visible(); 
     1370        mButtonBuild->activate(); 
     1371 
     1372        //mBuildBar->set_visible(); 
     1373        mBuildBar->activate(); 
     1374} 
     1375 
     1376//--------------------------------------------------------------------------- 
    13111377//      Show the stripify panel 
    13121378//--------------------------------------------------------------------------- 
     
    15721638 
    15731639        mButtonBuild->set_visible(); 
    1574         mButtonBuild->activate(); 
     1640        //mButtonBuild->activate(); 
    15751641 
    15761642        mBuildBar->set_visible(); 
    1577         mBuildBar->activate(); 
     1643        //mBuildBar->activate(); 
    15781644} 
    15791645//--------------------------------------------------------------------------- 
     
    15861652 
    15871653        mButtonBuild->set_visible(); 
    1588         mButtonBuild->activate(); 
     1654        //mButtonBuild->activate(); 
    15891655 
    15901656        mBuildBar->set_visible(); 
    1591         mBuildBar->activate(); 
     1657        //mBuildBar->activate(); 
    15921658} 
    15931659 
     
    23102376void    GeoMeshViewUI::openMeshFile() 
    23112377{ 
     2378        Mesh                                                    *mesh_loaded; 
    23122379        fltk::FileChooser       *fcho; 
    23132380        static  char                    char_value[10]; 
    23142381        static  char                    title[256]; 
    2315  
     2382         
    23162383        fcho    =       new fltk::FileChooser("", 
    23172384                                                                                                                                "*.mesh", 
     
    23262393        if (mFileName) 
    23272394        { 
    2328                 //      Set Window Title. 
    2329                 strcpy(title,mFileName); 
    2330                 mMainWindow->label(strcat(title," - GeoTool")); 
    2331  
    2332                 //      Identify the mesh that stores the leaves 
    2333                 idMeshLeaves    =       -1; 
    2334  
    2335                 //      Stores the name of the mesh. 
    2336                 nombremesh      =       new char[255]; 
    2337                 strcpy(nombremesh,mFileName); 
    2338  
    2339                 //      Delete  the current mesh. 
    2340                 delete  mGeoMesh; 
    2341                 delete  mUndoMesh; 
    2342  
    23432395                //      Loads a new mesh. 
    2344                 mGeoMesh                =       geoMeshLoader->load(mFileName); 
    2345  
    2346                 //      Reset the undo mesh. 
    2347                 mUndoMesh               =       new Mesh(); 
    2348                 *mUndoMesh      =       *mGeoMesh; 
    2349  
    2350                 //      Translate the MB count to a char value. 
    2351                 sprintf(char_value, 
    2352                                 "MB %.3f", 
    2353                                 (float)geoMeshLoader->getFileSize()/1024/1024); 
    2354  
    2355                 mMB->label(char_value); 
    2356  
    2357                 //      Visualize mesh. 
    2358                 geoMeshView->setMesh(mGeoMesh); 
    2359  
    2360                 //      Hide right panel. 
    2361                 hideRightPanel(); 
    2362  
    2363                 //      Quit culling. 
    2364                 menuRenderCW->clear_value(); 
    2365                 menuRenderCCW->clear_value(); 
    2366                 geoMeshView->deactiveCW(); 
    2367                 geoMeshView->deactiveCCW(); 
    2368  
    2369                 //      Deactive solid mode and wire. 
    2370                 menuRenderSolid->clear_value(); 
    2371                 menuRenderWire->clear_value(); 
    2372                 geoMeshView->deactiveSolid(); 
    2373                 geoMeshView->deactiveWire(); 
    2374  
    2375                 //      Fit model in midle. 
    2376                 geoMeshView->fit(); 
    2377  
    2378                 //      Lighting smooth. 
    2379                 menuRenderFlat->clear_value(); 
    2380                 menuRenderSmooth->set_value(); 
    2381                 geoMeshView->smooth(); 
    2382  
    2383                 //      Show title. 
    2384                 mProcessTitle->label("Mesh Info"); 
    2385  
    2386                 //      Shows the mesh info. 
    2387                 showMeshInfo(); 
    2388  
    2389                 //      if the mesh is stripified. 
    2390                 geoMeshView->setStripColors(); 
    2391  
    2392                 //      Refresh geometry attributes. 
    2393                 refreshApplicationBar(); 
    2394         } 
    2395          
     2396                mesh_loaded             =       geoMeshLoader->load(mFileName); 
     2397 
     2398                //      If no error happens. 
     2399                if (mesh_loaded) 
     2400                { 
     2401                        //      Identify the mesh that stores the leaves 
     2402                        idMeshLeaves    =       -1; 
     2403 
     2404                        //      Delete  the current mesh. 
     2405                        delete  mGeoMesh; 
     2406                        delete  mUndoMesh; 
     2407 
     2408                        //      Assigns mesh loaded. 
     2409                        mGeoMesh        =       mesh_loaded; 
     2410                         
     2411                        //      Set Window Title. 
     2412                        strcpy(title,mFileName); 
     2413                        mMainWindow->label(strcat(title," - GeoTool")); 
     2414 
     2415                        //      Stores the name of the mesh. 
     2416                        nombremesh      =       new char[255]; 
     2417                        strcpy(nombremesh,mFileName); 
     2418 
     2419                        //      Reset the undo mesh. 
     2420                        mUndoMesh               =       new Mesh(); 
     2421                        *mUndoMesh      =       *mGeoMesh; 
     2422 
     2423                        //      Translate the MB count to a char value. 
     2424                        sprintf(char_value, 
     2425                                        "MB %.3f", 
     2426                                        (float)geoMeshLoader->getFileSize()/1024/1024); 
     2427 
     2428                        mMB->label(char_value); 
     2429 
     2430                        //      Visualize mesh. 
     2431                        geoMeshView->setMesh(mGeoMesh); 
     2432 
     2433                        //      Hide right panel. 
     2434                        hideRightPanel(); 
     2435 
     2436                        //      Quit culling. 
     2437                        menuRenderCW->clear_value(); 
     2438                        menuRenderCCW->clear_value(); 
     2439                        geoMeshView->deactiveCW(); 
     2440                        geoMeshView->deactiveCCW(); 
     2441 
     2442                        //      Deactive solid mode and wire. 
     2443                        menuRenderSolid->clear_value(); 
     2444                        menuRenderWire->clear_value(); 
     2445                        geoMeshView->deactiveSolid(); 
     2446                        geoMeshView->deactiveWire(); 
     2447 
     2448                        //      Fit model in midle. 
     2449                        geoMeshView->fit(); 
     2450 
     2451                        //      Lighting smooth. 
     2452                        menuRenderFlat->clear_value(); 
     2453                        menuRenderSmooth->set_value(); 
     2454                        geoMeshView->smooth(); 
     2455 
     2456                        //      Show title. 
     2457                        mProcessTitle->label("Mesh Info"); 
     2458 
     2459                        //      Shows the mesh info. 
     2460                        showMeshInfo(); 
     2461 
     2462                        //      if the mesh is stripified. 
     2463                        geoMeshView->setStripColors(); 
     2464 
     2465                        //      Refresh geometry attributes. 
     2466                        refreshApplicationBar(); 
     2467 
     2468                        //      Restore simplification state. 
     2469                        simplificationState     =       NO_SIMPLIFICATION; 
     2470                } 
     2471        } 
    23962472        //      Free memory. 
    23972473        delete  fcho; 
     2474} 
     2475 
     2476//--------------------------------------------------------------------------- 
     2477//      If file exists. 
     2478//--------------------------------------------------------------------------- 
     2479bool    GeoMeshViewUI::fileExists(const char    *fileNameMesh) 
     2480{ 
     2481        FILE    *pFile; 
     2482         
     2483        //      Open the mesh file. 
     2484        pFile   =       fopen(fileNameMesh, "r"); 
     2485 
     2486  if (pFile) 
     2487        { 
     2488                return  true; 
     2489        } 
     2490        else 
     2491        { 
     2492                return  false; 
     2493        } 
    23982494} 
    23992495 
     
    24472543                        { 
    24482544                                fltk::Group* o; 
    2449                                 o = MainView = new fltk::Group(0, 0, 500, 530); 
     2545                                o = MainView = new fltk::Group(0, 0, 570, 530); 
    24502546                                o->begin(); 
    24512547 
    24522548                                { 
    24532549                                        fltk::InvisibleBox* o; 
    2454                                         o = cframe = new fltk::InvisibleBox(0, 0, 500, 530); 
     2550                                        o = cframe = new fltk::InvisibleBox(0, 0, 570, 530); 
    24552551                                        o->box(fltk::FLAT_BOX); 
    24562552                                        o->color((fltk::Color)0xffffff00); 
     
    24602556                                { 
    24612557                                        GeoMeshView* o; 
    2462                                         o = geoMeshView = new GeoMeshView(      0,0,500,530,0,this); 
     2558                                        o = geoMeshView = new GeoMeshView(      0,0,570,530,0,this); 
    24632559                                } 
    24642560 
     
    24712567                        { 
    24722568                                fltk::Group* o; 
    2473                                 o = MainView = new fltk::Group(500, 0, 300, 530); 
     2569                                o = MainView = new fltk::Group(570, 0, 230, 530); 
    24742570                                o->begin(); 
    24752571 
     
    24772573                                        fltk::Button* o; 
    24782574                                        //o = mButtonProcess = new fltk::Button(665, 410, 73, 25, "Process"); 
    2479                                         o = mButtonProcess = new fltk::Button(65, 410, 73, 25, "Process"); 
     2575                                        o = mButtonProcess = new fltk::Button(75, 410, 73, 25, "Process"); 
    24802576                                        o->callback((fltk::Callback*)cb_mButtonProcess); 
    24812577                                        o->hide(); 
     
    24862582                                        fltk::ProgressBar* o; 
    24872583                                        //o = mProcessBar = new fltk::ProgressBar(616, 435, 175, 18); 
    2488                                         o = mProcessBar = new fltk::ProgressBar(16, 435, 175, 18); 
     2584                                        o = mProcessBar = new fltk::ProgressBar(16, 435, 195, 18); 
    24892585                                        o->hide(); 
    24902586                                        o->deactivate(); 
     
    24932589                                { 
    24942590                                        fltk::Button* o; 
    2495                                         o = mButtonSort = new fltk::Button(65, 375, 73, 25, "Sort"); 
     2591                                        o = mButtonSort = new fltk::Button(75, 375, 73, 25, "Sort"); 
    24962592                                        o->callback((fltk::Callback*)cb_mButtonSort); 
    24972593                                        o->hide(); 
     
    25012597                                { 
    25022598                                        fltk::ProgressBar* o; 
    2503                                         o = mSortBar = new fltk::ProgressBar(16, 390, 175, 18); 
     2599                                        o = mSortBar = new fltk::ProgressBar(16, 390, 195, 18); 
    25042600                                        o->hide(); 
    25052601                                        o->deactivate(); 
     
    25082604                                { 
    25092605                                        fltk::Button* o; 
    2510                                         o = mButtonBuild = new fltk::Button(65, 455, 73, 25, "Build"); 
     2606                                        o = mButtonBuild = new fltk::Button(75, 455, 73, 25, "Build"); 
    25112607                                        o->callback((fltk::Callback*)cb_mButtonBuild); 
    25122608                                        o->hide(); 
     
    25162612                                { 
    25172613                                        fltk::ProgressBar* o; 
    2518                                         o = mBuildBar = new fltk::ProgressBar(16, 480, 175, 18); 
     2614                                        o = mBuildBar = new fltk::ProgressBar(16, 480, 195, 18); 
    25192615                                        o->hide(); 
    25202616                                        o->deactivate(); 
     
    25642660 
    25652661                                { 
    2566                                         mProcessTitle           = new fltk::Widget(0, 0, 300, 25, ""); 
     2662                                        mProcessTitle           = new fltk::Widget(0, 0, 230, 25, ""); 
    25672663                                        fltk::Widget* o =       mProcessTitle; 
    25682664                                        o->set_vertical(); 
     
    26292725 
    26302726                                { 
    2631                                         fltk::Browser* o = mMeshInfo = new fltk::Browser(0, 20, 300, 380); 
     2727                                        fltk::Browser* o = mMeshInfo = new fltk::Browser(0, 20, 230, 380); 
    26322728                                        o->set_vertical(); 
    26332729                                        o->callback((fltk::Callback*)cb_mMeshInfo); 
     
    26612757 
    26622758                                { 
    2663                                         fltk::Item* o = menuOpenSaveAs = new fltk::Item("Save As"); 
    2664                                         o->callback((fltk::Callback*)cb_menuOpenSaveAs); 
     2759                                        fltk::Item* o = menuFileSaveAs = new fltk::Item("Save As"); 
     2760                                        o->callback((fltk::Callback*)cb_menuFileSaveAs); 
    26652761                                } 
    26662762 
     
    26762772 
    26772773                                { 
    2678                                         fltk::Item* o = menuOpenQuit = new fltk::Item("Quit"); 
    2679                                         o->callback((fltk::Callback*)cb_menuOpenQuit); 
     2774                                        fltk::Item* o = menuFileQuit = new fltk::Item("Quit"); 
     2775                                        o->callback((fltk::Callback*)cb_menuFileQuit); 
    26802776                                } 
    26812777 
Note: See TracChangeset for help on using the changeset viewer.