Changeset 750


Ignore:
Timestamp:
04/12/06 08:18:49 (18 years ago)
Author:
mattausch
Message:
 
Location:
GTP/trunk/Lib/Vis/Preprocessing/src
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • GTP/trunk/Lib/Vis/Preprocessing/src/Mesh.cpp

    r534 r750  
    4949  return box; 
    5050} 
     51 
    5152 
    5253int 
     
    461462  AddFace(new Face(index + 0, index + 1, index + 2, index + 3) ); 
    462463} 
     464 
     465 
     466 
     467Mesh *CreateBox(const AxisAlignedBox3 &box) 
     468{ 
     469        Mesh *mesh = new Mesh; 
     470  // add 8 vertices of the box 
     471  int index = (int)mesh->mVertices.size(); 
     472  for (int i=0; i < 8; i++) { 
     473    Vector3 v; 
     474    box.GetVertex(i, v); 
     475    mesh->mVertices.push_back(v); 
     476  } 
     477   
     478  mesh->AddFace(new Face(index + 0, index + 1, index + 3, index + 2) ); 
     479  mesh->AddFace(new Face(index + 0, index + 2, index + 6, index + 4) ); 
     480  mesh->AddFace(new Face(index + 4, index + 6, index + 7, index + 5) ); 
     481   
     482  mesh->AddFace(new Face(index + 3, index + 1, index + 5, index + 7) ); 
     483  mesh->AddFace(new Face(index + 0, index + 4, index + 5, index + 1) ); 
     484  mesh->AddFace(new Face(index + 2, index + 3, index + 7, index + 6) ); 
     485   
     486  return mesh; 
     487} 
  • GTP/trunk/Lib/Vis/Preprocessing/src/Mesh.h

    r693 r750  
    155155        return s<<"Mesh #vertices="<<(int)mVertices.size()<<" #faces="<<(int)mFaces.size(); 
    156156  } 
    157    
    158  
     157 
     158  friend Mesh *CreateBox(const AxisAlignedBox3 &box); 
    159159}; 
    160160 
  • GTP/trunk/Lib/Vis/Preprocessing/src/Polygon3.h

    r574 r750  
    102102        void Triangulate(vector<Triangle3> &triangles); 
    103103        /** 
    104                 Adds polygon to mesh 
     104                Adds polygon to mesh description as a face 
    105105        */ 
    106106        void AddToMesh(Mesh &mesh); 
  • GTP/trunk/Lib/Vis/Preprocessing/src/Preprocessor.cpp

    r749 r750  
    1515 
    1616Preprocessor *preprocessor; 
     17 
     18 
     19static void AddGeometry(SceneGraph *scene) 
     20{ 
     21        AxisAlignedBox3 sceneBox = scene->GetBox(); 
     22 
     23        int n = 200; 
     24 
     25        if (0){ 
     26        // form figure 
     27        for (int i = 0; i < n; ++ i) 
     28        { 
     29                for (int j = 0; j < n; ++ j) 
     30                { 
     31                        const Vector3 scale2((float)j * 0.8 / n + 0.1,  0.05, (float)i * 0.8  / (float)n + 0.1); 
     32                 
     33                        Vector3 pt2 = sceneBox.Min() + scale2 * (sceneBox.Max() - sceneBox.Min()); 
     34                 
     35                        Vector3 boxSize = sceneBox.Size() * Vector3(0.0025, 0.01, 0.0025); 
     36                        AxisAlignedBox3 box(pt2, pt2 + boxSize); 
     37                        Mesh *mesh = CreateBox(box); 
     38 
     39                        mesh->Preprocess(); 
     40                 
     41                        MeshInstance *mi = new MeshInstance(mesh); 
     42                        scene->mRoot->mGeometry.push_back(mi); 
     43                } 
     44        } 
     45 
     46        for (int i = 0; i < n; ++ i) 
     47        { 
     48                for (int j = 0; j < n; ++ j) 
     49                { 
     50                        const Vector3 scale2(0.15, (float)j * 0.8 / n + 0.1, (float)i * 0.8  / (float)n + 0.1); 
     51                 
     52                        Vector3 pt2 = sceneBox.Min() + scale2 * (sceneBox.Max() - sceneBox.Min()); 
     53                 
     54                        Vector3 boxSize = sceneBox.Size() * Vector3(0.0025, 0.01, 0.0025); 
     55                        AxisAlignedBox3 box(pt2, pt2 + boxSize); 
     56                        Mesh *mesh = CreateBox(box); 
     57 
     58                        mesh->Preprocess(); 
     59                 
     60                        MeshInstance *mi = new MeshInstance(mesh); 
     61                        scene->mRoot->mGeometry.push_back(mi); 
     62                } 
     63        } 
     64 
     65        for (int i = 0; i < n; ++ i) 
     66        { 
     67                const Vector3 scale2(2, 0.2, (float)i * 0.8  / (float)n + 0.1); 
     68                 
     69                Vector3 pt2 = sceneBox.Min() + scale2 * (sceneBox.Max() - sceneBox.Min()); 
     70                 
     71                //Vector3 boxSize = sceneBox.Size() * Vector3(0.0025, 0.01, 0.0025); 
     72                Vector3 boxSize = sceneBox.Size() * Vector3(0.005, 0.02, 0.005); 
     73                AxisAlignedBox3 box(pt2 + 0.1, pt2 + boxSize); 
     74                Mesh *mesh = CreateBox(box); 
     75 
     76                mesh->Preprocess(); 
     77                 
     78                MeshInstance *mi = new MeshInstance(mesh); 
     79                scene->mRoot->mGeometry.push_back(mi); 
     80        } 
     81         
     82        scene->mRoot->UpdateBox(); 
     83        } 
     84// plane separating areas 
     85if(1) 
     86{ 
     87const Vector3 scale(1.0, 0.0, 0); 
     88 
     89    Vector3 pt = sceneBox.Min() + scale * (sceneBox.Max() - sceneBox.Min()); 
     90 
     91        Plane3 cuttingPlane(Vector3(1, 0, 0), pt); 
     92         
     93        Mesh *planeMesh = new Mesh(); 
     94         
     95        Polygon3 *poly = sceneBox.CrossSection(cuttingPlane); 
     96 
     97        poly->AddToMesh(*planeMesh); 
     98 
     99        planeMesh->Preprocess(); 
     100 
     101    MeshInstance *planeMi = new MeshInstance(planeMesh); 
     102    scene->mRoot->mGeometry.push_back(planeMi); 
     103}        
     104} 
     105 
    17106 
    18107Preprocessor::Preprocessor(): 
     
    76165        return (int)filenames.size(); 
    77166} 
     167 
    78168 
    79169bool 
     
    124214 
    125215        if (result) { 
    126            
     216          // HACK  
     217        mSceneGraph->mRoot->UpdateBox(); 
     218        AddGeometry(mSceneGraph); 
    127219          mSceneGraph->AssignObjectIds(); 
    128220          int intersectables, faces; 
     
    132224          cout<<"#NUM_FACES (Total numner of faces)\n"<<faces<<endl; 
    133225          mSceneGraph->CollectObjects(&mObjects); 
    134           mSceneGraph->mRoot->UpdateBox(); 
     226          //mSceneGraph->mRoot->UpdateBox(); 
    135227 
    136228         /* Exporter *exporter = Exporter::GetExporter("testload.x3d"); 
  • GTP/trunk/Lib/Vis/Preprocessing/src/UnigraphicsParser.cpp

    r726 r750  
    184184  fclose(file); 
    185185   
     186   
    186187  *proot = root; 
    187188 
  • GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp

    r746 r750  
    372372                        } 
    373373 
    374                         //exporter->SetWireframe(); 
     374                        exporter->SetWireframe(); 
    375375                        ExportViewCellsForViz(exporter); 
    376376 
  • GTP/trunk/Lib/Vis/Preprocessing/src/VssPreprocessor.cpp

    r712 r750  
    572572          else 
    573573          { 
    574                 // HACK: enlarge in y directon 
    575                 mViewSpaceBox = new AxisAlignedBox3(mKdTree->GetBox()); 
    576  
    577                 if (0) { 
    578                 //Vector3 pmin = mViewSpaceBox->Min(); 
    579                 Vector3 size = mViewSpaceBox->Size(); 
    580                 //size[1] *= 1.25; 
    581                 Vector3 enlarge(size[0] * 0.25f, size[1] * 0.0f, size[2] * 0.25f); 
    582  
    583                 mViewSpaceBox->Enlarge(enlarge); 
    584                 } else { 
    585                   // $$ JB temporary 
    586                   AxisAlignedBox3 box = *mViewSpaceBox; 
    587                   float s = box.Size(0); 
    588                   box.Scale(0.8f); 
    589                   box.SetMax(0, box.Max(0) + s*0.8f); 
    590                   box.SetMin(0, box.Min(0) + s*0.8f); 
    591                   *mViewSpaceBox = box; 
    592                 } 
    593                  
     574                  // HACK: enlarge in y directon 
     575                  mViewSpaceBox = new AxisAlignedBox3(mKdTree->GetBox()); 
     576 
     577                  if (1)  
     578                  { 
     579                          //Vector3 pmin = mViewSpaceBox->Min(); 
     580                          Vector3 size = mViewSpaceBox->Size(); 
     581                          //size[1] *= 1.25; 
     582                          //Vector3 enlarge(size[0] * 0.25f, size[1] * 0.0f, size[2] * 0.25f); 
     583                          Vector3 enlarge(size[0] * 4.0f, 0.0f, 0.0f); 
     584 
     585                          //mViewSpaceBox->Enlarge(enlarge); 
     586                          mViewSpaceBox->SetMax(mViewSpaceBox->Max() + enlarge); 
     587                  }  
     588                  else  
     589                  { 
     590                          // $$ JB temporary 
     591                          AxisAlignedBox3 box = *mViewSpaceBox; 
     592                           
     593                          float s = box.Size(0); 
     594                           
     595                          box.Scale(0.8f); 
     596                          box.SetMax(0, box.Max(0) + s*0.8f); 
     597                          box.SetMin(0, box.Min(0) + s*0.8f); 
     598                          *mViewSpaceBox = box; 
     599                  }              
    594600          } 
    595601          //Debug << "view space box: " << *mViewSpaceBox << endl; 
Note: See TracChangeset for help on using the changeset viewer.