Changeset 658


Ignore:
Timestamp:
02/21/06 09:51:03 (18 years ago)
Author:
mattausch
Message:

added switch for loading polys as meshes

Location:
GTP/trunk/Lib/Vis
Files:
11 edited

Legend:

Unmodified
Added
Removed
  • GTP/trunk/Lib/Vis/Preprocessing/scripts/default.env

    r656 r658  
    1313#;../data/vienna/vienna-plane.x3d 
    1414#       filename ../data/vienna/viewcells-25-sel.x3d 
    15 #       filename ../data/atlanta/atlanta2.x3d 
     15        filename ../data/atlanta/atlanta2.x3d 
    1616#       filename ../data/soda/soda.dat 
    17         filename ../data/soda/soda5.dat 
     17#       filename ../data/soda/soda5.dat 
    1818} 
    1919 
     
    2626#       type rss 
    2727        detectEmptyViewSpace true 
     28        loadPolygonsAsMeshes true 
    2829} 
    2930 
  • GTP/trunk/Lib/Vis/Preprocessing/src/Environment.cpp

    r655 r658  
    15301530                                        "false"); 
    15311531 
     1532        RegisterOption("Preprocessor.loadPolygonsAsMeshes", 
     1533                                        optBool, 
     1534                                        "loadPolygonsAsMeshes=", 
     1535                                        "false"); 
     1536 
    15321537        RegisterOption("Preprocessor.pvsRenderErrorSamples", 
    15331538                                   optInt, 
  • GTP/trunk/Lib/Vis/Preprocessing/src/Parser.h

    r508 r658  
    1414  Parser() {} 
    1515 
    16   virtual bool ParseFile(const string filename, SceneGraphNode **root) {return false;}; 
     16  virtual bool ParseFile(const string filename,  
     17                                                 SceneGraphNode **root,  
     18                                                 const bool loadPolygonsAsMeshes = false) {return false;}; 
    1719         
    1820}; 
  • GTP/trunk/Lib/Vis/Preprocessing/src/Preprocessor.cpp

    r656 r658  
    2828   
    2929  environment->GetBoolValue("Preprocessor.useGlDebugger", mUseGlDebugger); 
     30  environment->GetBoolValue("Preprocessor.loadPolygonsAsMeshes", mLoadPolygonsAsMeshes); 
    3031  environment->GetBoolValue("Preprocessor.quitOnFinish", mQuitOnFinish); 
    3132 
     
    8990 
    9091                cout<<filename<<endl; 
    91                 result = parser->ParseFile(filename, &mSceneGraph->mRoot); 
     92                result = parser->ParseFile(filename, &mSceneGraph->mRoot, mLoadPolygonsAsMeshes); 
    9293 
    9394                delete parser; 
     
    123124          mSceneGraph->CollectObjects(&mObjects); 
    124125          mSceneGraph->mRoot->UpdateBox(); 
     126 
     127                Exporter *exporter = Exporter::GetExporter("testload.x3d"); 
     128 
     129                if (exporter) 
     130                { 
     131                        exporter->ExportGeometry(mObjects); 
     132                        delete exporter; 
     133                } 
     134 
    125135        } 
    126136         
  • GTP/trunk/Lib/Vis/Preprocessing/src/Preprocessor.h

    r599 r658  
    158158 
    159159  bool mQuitOnFinish; 
     160  bool mLoadPolygonsAsMeshes; 
     161 
    160162protected: 
    161163 
  • GTP/trunk/Lib/Vis/Preprocessing/src/UnigraphicsParser.cpp

    r340 r658  
    2626bool 
    2727UnigraphicsParser::ParseFile(const string filename, 
    28                              SceneGraphNode **proot) 
     28                             SceneGraphNode **proot, 
     29                                 const bool loadPolygonsAsMeshese) 
    2930{ 
    3031   
  • GTP/trunk/Lib/Vis/Preprocessing/src/UnigraphicsParser.h

    r162 r658  
    1515  UnigraphicsParser(): Parser() {} 
    1616   
    17   virtual bool ParseFile(const string filename, SceneGraphNode **root); 
     17  virtual bool ParseFile(const string filename, SceneGraphNode **root, const bool loadPolygonsAsMeshes = false); 
    1818   
    1919}; 
  • GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp

    r651 r658  
    10511051                if (exporter) 
    10521052                { 
    1053                          
    10541053                        if (0 && mExportRays) 
    10551054                                exporter->ExportRays(rays, RgbColor(1, 1, 1)); 
    1056  
    10571055                         
    10581056                        if (mExportGeometry) 
  • GTP/trunk/Lib/Vis/Preprocessing/src/X3dParser.cpp

    r657 r658  
    9090X3dParseHandlers::EndShape() 
    9191{ 
    92   if (mCurrentMesh->mFaces.size()) { 
    93     mCurrentMesh->Preprocess(); 
    94     // make an instance of this mesh 
    95     MeshInstance *mi = new MeshInstance(mCurrentMesh); 
    96     mCurrentNode->mGeometry.push_back(mi); 
    97         // set the object id to a unique value 
    98         //mi->SetId(mCurrentObjectId ++); 
    99   } else { 
    100     cout<<"X"; 
    101     delete mCurrentMesh; 
    102   } 
    103   mCurrentMesh = NULL; 
    104 } 
    105  
     92        if (mLoadPolygonsAsMeshes) 
     93        { 
     94                vector<VertexIndexContainer>::const_iterator it, it_end = mCurrentVertexIndices.end(); 
     95 
     96                for (it = mCurrentVertexIndices.begin(); it != it_end; ++ it) 
     97                { 
     98                        // only one face per mesh 
     99                        Mesh *mesh = new Mesh(); 
     100 
     101                        // add vertices 
     102                        for (int i = 0; i < (int)(*it).size(); ++ i) 
     103                        { 
     104                                mesh->mVertices.push_back(mCurrentVertices[(*it)[i]]); 
     105                                 
     106                        } 
     107                         
     108                        mesh->mFaces.push_back(new Face(0,1,2)); 
     109                        mesh->Preprocess(); 
     110                        // make an instance of this mesh 
     111                        MeshInstance *mi = new MeshInstance(mesh); 
     112                        mCurrentNode->mGeometry.push_back(mi); 
     113 
     114                } 
     115 
     116                delete mCurrentMesh; 
     117                mCurrentVertices.clear(); 
     118                mCurrentVertexIndices.clear(); 
     119        } 
     120        else 
     121        { 
     122  
     123                if (mCurrentMesh->mFaces.size())  
     124                { 
     125                        mCurrentMesh->Preprocess(); 
     126                        // make an instance of this mesh 
     127                        MeshInstance *mi = new MeshInstance(mCurrentMesh); 
     128                        mCurrentNode->mGeometry.push_back(mi); 
     129                        // set the object id to a unique value 
     130                        //mi->SetId(mCurrentObjectId ++); 
     131                }  
     132                else  
     133                { 
     134                        cout<<"X"; 
     135                        delete mCurrentMesh; 
     136                } 
     137                mCurrentMesh = NULL; 
     138        } 
     139} 
    106140void 
    107141X3dParseHandlers::StartIndexedFaceSet( 
     
    126160                  Face *face = new Face(vertices); 
    127161 
    128                    mCurrentMesh->mFaces.push_back(face); 
    129  
    130                    // every polygon is a mesh => store in mesh instance and create new mesh 
    131                   if (mLoadPolygonsAsMeshes) 
    132                   { 
    133                           mCurrentMesh->Preprocess(); 
    134  
    135                           // make an instance of this mesh 
    136                           MeshInstance *mi = new MeshInstance(mCurrentMesh); 
    137                           mCurrentNode->mGeometry.push_back(mi); 
    138  
    139                           mCurrentMesh = new Mesh(); 
    140                   } 
    141  
     162                   if (!mLoadPolygonsAsMeshes) 
     163                   { 
     164                           mCurrentMesh->mFaces.push_back(face); 
     165                   } 
     166                   else 
     167                   // every polygon is a mesh 
     168                   { 
     169                           mCurrentVertexIndices.push_back(vertices); 
     170                   } 
    142171          } 
     172 
    143173          vertices.clear(); 
    144174          if (ptr == endptr) 
     
    223253                                vertices.push_back(v); 
    224254                        } 
    225                         mCurrentMesh->mVertices = vertices; 
     255                        if (mLoadPolygonsAsMeshes) 
     256                        { 
     257                                mCurrentVertices = vertices; 
     258                        } 
     259                        else 
     260                        { 
     261                                mCurrentMesh->mVertices = vertices; 
     262                        } 
    226263                } 
    227264        } 
     
    243280  if (element == "Shape") { 
    244281    cout<<"+"; 
    245     mCurrentMesh = new Mesh; 
     282        mCurrentMesh = new Mesh; 
    246283  } 
    247284   
  • GTP/trunk/Lib/Vis/Preprocessing/src/X3dParserXerces.h

    r657 r658  
    6363  SceneGraphNode *mCurrentNode; 
    6464  Mesh *mCurrentMesh; 
     65  vector<VertexIndexContainer> mCurrentVertexIndices; 
     66  VertexContainer mCurrentVertices; 
     67 
    6568  Material *mCurrentMaterial; 
    6669  bool mLoadPolygonsAsMeshes; 
     
    159162 
    160163  VertexIndexContainer mCurrentVertexIndices; 
    161  
     164  
    162165  // Handlers for X3D 
    163166  void 
Note: See TracChangeset for help on using the changeset viewer.