Changeset 1577


Ignore:
Timestamp:
10/06/06 08:59:09 (18 years ago)
Author:
mattausch
Message:
 
Location:
GTP/trunk/Lib/Vis/Preprocessing/src
Files:
6 edited

Legend:

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

    r1576 r1577  
    2525#define PROBABILIY_IS_BV_VOLUME 1 
    2626#define USE_FIXEDPOINT_T 0 
     27#define COUNT_ORIGIN_OBJECTS 0 
    2728 
    2829int BvhNode::sMailId = 10000; //2147483647; 
  • GTP/trunk/Lib/Vis/Preprocessing/src/HierarchyManager.cpp

    r1576 r1577  
    201201{ 
    202202        const float costDecr = tData.GetRenderCostDecrease(); 
    203  
     203cout << "here44 " << mHierarchyStats.pvsEntries << endl; 
    204204        AddSubdivisionStats(mHierarchyStats.Leaves(), 
    205205                                                costDecr, 
    206206                                                mTotalCost, 
    207                                                 mTotalPvsEntries 
     207                                                //mPvsEntries 
     208                                                mHierarchyStats.pvsEntries 
    208209                                                ); 
    209210} 
     
    218219                        << "#Splits\n" << splits << endl 
    219220                        << "#RenderCostDecrease\n" << renderCostDecr << endl  
    220                         << "#TotalPvsEntries\n" << pvsEntries << endl 
     221                        << "#TotalEntriesInPvs\n" << pvsEntries << endl 
    221222                        << "#TotalRenderCost\n" << totalRenderCost << endl; 
    222223} 
     
    301302        cout << "\nfinished in " << TimeDiff(startTime, GetTime()) * 1e-3 << " secs" << endl; 
    302303 
    303 /*#if _DEBUG 
    304         cout << "view space: " << GetViewSpaceBox() << endl; 
    305         cout << "object space:  " << GetObjectSpaceBox() << endl; 
    306 #endif*/ 
    307  
    308304        mObjectSpaceSubdivisionType = mSavedObjectSpaceSubdivisionType; 
    309305        mViewSpaceSubdivisionType = mSavedViewSpaceSubdivisionType; 
     
    517513                        // update stats 
    518514                        mHierarchyStats.nodes += 2; 
    519                         mHierarchyStats.pvsEntries += mCurrentCandidate->GetPvsEntriesIncr(); 
     515                        const int pvsEntries = mCurrentCandidate->GetPvsEntriesIncr(); 
     516                        mHierarchyStats.pvsEntries += pvsEntries; 
     517                        cout << "pvs entries: " << pvsEntries << " " << mHierarchyStats.pvsEntries << endl; 
    520518                        mHierarchyStats.memory += 0; // TODO 
    521519                        // subdivision successful 
     
    590588                        // reevaluate candidates affected by the split for view space splits,  
    591589                        // this would be object space splits and other way round 
    592                         if (repairQueue) RepairQueue(); 
     590                        if (repairQueue)  
     591                        { 
     592                                RepairQueue(); 
     593                        } 
    593594                } 
    594595 
  • GTP/trunk/Lib/Vis/Preprocessing/src/UnigraphicsParser.cpp

    r1486 r1577  
    5050  map<string, Vector3, ltstr> cht; // hash table for colors 
    5151   
    52   FILE         *file; 
     52  FILE *file; 
    5353  char str[80]; 
    54   Face     *face; 
    55   //Vector3  *vptr; 
    56    
     54  Face *face; 
     55     
    5756  float x,y,z; 
    58   int i; 
     57  //int i; 
    5958   
    6059  if ((file = fopen(filename.c_str(),"rt")) == NULL) 
     
    6665  Environment::GetSingleton()->GetIntValue("Unigraphics.meshGrouping", 
    6766                           meshGrouping); 
    68    
    69   while(fscanf(file,"%s",str)!=EOF) { 
    70     switch (str[0]) { 
    71        
    72     case 'c': 
    73       if (strcmp(str,"c_rgb")==0) 
    74         { 
    75           cout<<"c"; 
    76           cout.flush(); 
    77           /* vertex */ 
    78           fscanf(file,"%s",str); // label 
    79           fscanf(file,"%f %f %f",&x,&y,&z); 
    80            
    81           cht[str] = Vector3(x,y,z); // swap the file coordinates 
    82         } 
    83       break; 
    84        
    85        
    86     case 'v':            // is it v ? 
    87       cout<<"."; 
    88       cout.flush(); 
    89       /* vertex */ 
    90       fscanf(file,"%s",str); // label 
    91       fscanf(file,"%f %f %f",&x,&y,&z); 
    92        
    93       vht[str] = Vector3(x,z,-y); // swap the file coordinates 
    94       //         vptr = new Vector3C(x,y,z); // swap the file coordinates 
    95       break; 
    96        
    97     case 'f': { 
    98       cout<<"+"; 
    99       vector<Vector3> vertices; 
    100       VertexIndexContainer vertexIndices; 
    101  
    102       /* face */ 
    103       fscanf(file,"%s",str); // label may  be ? 
    104       if (str[0]!='(') 
    105         fscanf(file,"%s",str); 
    106        
    107       i = 0;                              // index of the vertex 
    108        
    109        
    110       map<string, Vector3, ltstr>::const_iterator c = vht.find(&str[1]); 
    111        
    112       if (c == vht.end()) { 
    113         cout<<"error reading file : "<< 
    114           filename<<" ---missing vertex:"<<str<<endl; exit(1); 
    115       } 
    116        
    117       vertices.push_back((*c).second); 
    118        
    119       fscanf(file,"%s",str);      // get the vertex label 
    120        
    121       while(str[0]!=')') { 
    122          
    123         c = vht.find(str); 
    124          
    125         if (c == vht.end()) 
     67 
     68  while(fscanf(file,"%s",str)!=EOF)  
     69  { 
     70          switch (str[0])  
    12671          { 
    127             cout<<"error reading file : "<<filename<<" -- missing vertex\n"; 
    128             exit(1);  } 
    129          
    130         vertices.push_back((*c).second); 
    131         fscanf(file,"%s",str);   // get the next vertex label 
    132       } 
    133  
    134       // add vertices to the mesh vertex list 
    135       int index = (int)currentMesh->mVertices.size(); 
    136       for (i=0; i < vertices.size(); i++, index++) { 
    137                 currentMesh->mVertices.push_back(vertices[i]); 
    138                 vertexIndices.push_back(index); 
    139       } 
    140      
    141       face = new Face(vertexIndices); 
    142        
    143       fscanf(file,"%s",str);   // get the next vertex label 
    144      
    145       if (str[0]!=';') { 
    146         c = cht.find(str); 
    147         if (currentMesh->mMaterial == NULL) { 
    148                 Material *mat = MaterialManager::GetSingleton()->CreateResource(); 
    149           if (c != cht.end()) { 
    150             mat->mDiffuseColor = RgbColor((*c).second.x, (*c).second.y, (*c).second.z); 
    151             currentMesh->mMaterial = mat; 
     72          case 'c': 
     73                  if (strcmp(str,"c_rgb")==0) 
     74                  { 
     75                          cout<<"c"; 
     76                          cout.flush(); 
     77                          // vertex 
     78                          fscanf(file,"%s",str); // label 
     79                          fscanf(file,"%f %f %f",&x,&y,&z); 
     80 
     81                          cht[str] = Vector3(x,y,z); // swap the file coordinates 
     82                  } 
     83                  break; 
     84 
     85 
     86          case 'v':            // is it v ? 
     87                  cout<<"."; 
     88                  cout.flush(); 
     89                  // vertex 
     90                  fscanf(file,"%s",str); // label 
     91                  fscanf(file,"%f %f %f",&x,&y,&z); 
     92 
     93                  vht[str] = Vector3(x,z,-y); // swap the file coordinates 
     94                  // vptr = new Vector3C(x,y,z); // swap the file coordinates 
     95                  break; 
     96 
     97          case 'f':  
     98                  { 
     99                          cout << "+"; 
     100                          vector<Vector3> vertices; 
     101                          VertexIndexContainer vertexIndices; 
     102 
     103                          // face 
     104                          fscanf(file,"%s",str); // label may  be ? 
     105                          if (str[0]!='(') 
     106                                  fscanf(file,"%s",str); 
     107 
     108                           map<string, Vector3, ltstr>::const_iterator c = vht.find(&str[1]); 
     109 
     110                          if (c == vht.end())  
     111                          { 
     112                                  cout<<"error reading file : "<< filename  
     113                                          <<" ---missing vertex:"<<str<<endl; exit(1); 
     114                          } 
     115 
     116                          vertices.push_back((*c).second); 
     117 
     118                          fscanf(file,"%s",str); // get the vertex label 
     119 
     120                          while(str[0]!=')')  
     121                          { 
     122                                  c = vht.find(str); 
     123                                  if (c == vht.end()) 
     124                                  { 
     125                                        cout << "error reading file : " << filename << " -- missing vertex\n"; 
     126                                        exit(1);   
     127                                } 
     128 
     129                                vertices.push_back((*c).second); 
     130                                fscanf(file,"%s",str); // get the next vertex label 
     131                        } 
     132 
     133                        // add vertices to the mesh vertex list 
     134                        int index = (int)currentMesh->mVertices.size(); 
     135 
     136                        for (int i=0; i < (int)vertices.size(); ++ i, ++ index)  
     137                        { 
     138                                currentMesh->mVertices.push_back(vertices[i]); 
     139                                vertexIndices.push_back(index); 
     140                        } 
     141 
     142                        face = new Face(vertexIndices); 
     143 
     144                        fscanf(file,"%s",str);   // get the next vertex label 
     145 
     146                        if (str[0]!=';')  
     147                        { 
     148                                c = cht.find(str); 
     149                                if (currentMesh->mMaterial == NULL)  
     150                                { 
     151                                        Material *mat = MaterialManager::GetSingleton()->CreateResource(); 
     152                                        if (c != cht.end())  
     153                          { 
     154                                  mat->mDiffuseColor = RgbColor((*c).second.x, (*c).second.y, (*c).second.z); 
     155                                  currentMesh->mMaterial = mat; 
     156                          } 
     157                                        else 
     158                          { 
     159                                  currentMesh->AssignRandomMaterial(); 
     160                          } 
     161                                } 
     162                        } 
     163 
     164                        currentMesh->AddFace(face); 
     165                        if (meshGrouping != 0 && currentMesh->mFaces.size() >=  meshGrouping)  
     166                        { 
     167                                if (ROTATE_SCENE) 
     168                                { 
     169                                        RotateMesh(currentMesh); 
     170                                } 
     171 
     172                                currentMesh->Preprocess(); 
     173                                // make an instance of this mesh 
     174                                MeshInstance *mi = new MeshInstance(currentMesh); 
     175                                root->mGeometry.push_back(mi);   
     176                                currentMesh = MeshManager::GetSingleton()->CreateResource(); 
     177                        } 
     178                } 
     179                break; 
     180        }      /* end face */ 
     181 
     182        // get the rest of the line 
     183        fgets(str,80,file); 
     184  } 
     185 
     186  if (!currentMesh->mVertices.empty())  
     187  { 
     188          if (ROTATE_SCENE)  
     189          { 
     190                  RotateMesh(currentMesh); 
    152191          } 
    153           else 
    154             currentMesh->AssignRandomMaterial(); 
    155         } 
    156       } 
    157        
    158       currentMesh->AddFace(face); 
    159       if (meshGrouping != 0 && currentMesh->mFaces.size() >=  meshGrouping) { 
    160                 if (ROTATE_SCENE) 
    161                         RotateMesh(currentMesh); 
    162  
    163                 currentMesh->Preprocess(); 
    164                 // make an instance of this mesh 
    165                 MeshInstance *mi = new MeshInstance(currentMesh); 
    166                 root->mGeometry.push_back(mi);   
    167                 currentMesh = MeshManager::GetSingleton()->CreateResource(); 
    168       } 
    169     } 
    170     break; 
    171     }      /* end face */ 
    172      
    173     // get the rest of the line 
    174     fgets(str,80,file); 
    175   } 
    176    
    177   if (currentMesh->mVertices.size())  
    178   { 
    179           if (ROTATE_SCENE) RotateMesh(currentMesh); 
    180   
     192 
    181193          currentMesh->Preprocess(); 
    182194          MeshInstance *mi = new MeshInstance(currentMesh); 
    183195          root->mGeometry.push_back(mi); 
    184196  } 
    185    
     197 
    186198  fclose(file); 
    187199  return true; 
  • GTP/trunk/Lib/Vis/Preprocessing/src/VspBspTree.cpp

    r1564 r1577  
    2626#define COUNT_ORIGIN_OBJECTS 1 
    2727 
    28          
     28/////////// 
    2929//-- static members 
    3030 
     
    20042004                AddObjToPvs(ray->mTerminationObject, cf, pvsFront, pvsBack, totalPvs); 
    20052005 
    2006                 if (COUNT_ORIGIN_OBJECTS)  
     2006                if (COUNT_ORIGIN_OBJECTS) 
     2007                { 
    20072008                        AddObjToPvs(ray->mOriginObject, cf, pvsFront, pvsBack, totalPvs); 
     2009                } 
    20082010        } 
    20092011 
  • GTP/trunk/Lib/Vis/Preprocessing/src/VspTree.cpp

    r1576 r1577  
    2828 
    2929#define USE_FIXEDPOINT_T 0 
    30  
    31  
     30#define COUNT_ORIGIN_OBJECTS 0 
     31 
     32///////////// 
    3233//-- static members 
    3334 
     
    618619        /////////////// 
    619620        //-- create new view cell 
     621 
    620622        VspLeaf *leaf = tData.mNode; 
    621          
     623 
    622624        VspViewCell *viewCell = new VspViewCell(); 
    623625    leaf->SetViewCell(viewCell); 
     
    643645                /////////// 
    644646                //-- store sampling rays 
     647 
    645648        RayInfoContainer::const_iterator it, it_end = tData.mRays->end(); 
    646649 
     
    793796                        splitCandidate.mParentData.mMaxCostMisses + 1: 
    794797                        splitCandidate.mParentData.mMaxCostMisses); 
    795          
     798 
     799        // compute global decrease in render cost 
    796800        float oldRenderCost; 
    797  
    798         // compute global decrease in render cost 
    799801        const float renderCostDecr = EvalRenderCostDecrease(splitCandidate.mSplitPlane,  
    800802                                                                                                                splitCandidate.mParentData, 
     
    843845 
    844846                UpdatePvsEntriesContribution(*ray, true, cf, fPvsSize, bPvsSize, oldPvsSize); 
     847#if COUNT_ORIGIN_OBJECTS 
     848                UpdatePvsEntriesContribution(*ray, false, cf, fPvsSize, bPvsSize, oldPvsSize); 
     849#endif 
    845850        } 
    846851         
     
    968973        ViewCellLeaf *vc = leaf->GetViewCell(); 
    969974 
    970         // add contributions from samples to the PVS 
     975        // add contributions from samples to the pvs 
    971976        for (it = rays.begin(); it != it_end; ++ it) 
    972977        { 
     
    10401045        RayInfoContainer::const_iterator rit, rit_end = rays.end(); 
    10411046 
     1047        const bool delayMinEvent = false; 
     1048 
     1049        //////////// 
    10421050        //-- insert all queries 
    10431051        for (rit = rays.begin(); rit != rit_end; ++ rit) 
    10441052        { 
    10451053                const bool positive = (*rit).mRay->HasPosDir(axis); 
    1046                 const bool delayMinEvent = false; 
    1047  
     1054                 
    10481055                // origin point 
    10491056                pos = (*rit).ExtrapOrigin(axis); 
     
    10511058 
    10521059                if (delayMinEvent && oType == SortableEntry::ERayMin) 
    1053                         pos += mEpsilon; // for walls 
     1060                        pos += mEpsilon; // could be useful feature for walls 
    10541061 
    10551062                mLocalSubdivisionCandidates->push_back(SortableEntry(oType, pos, (*rit).mRay)); 
     
    10601067 
    10611068                if (delayMinEvent && tType == SortableEntry::ERayMin) 
    1062                         pos += mEpsilon; // for walls 
     1069                        pos += mEpsilon; // could be useful feature for walls 
    10631070 
    10641071                mLocalSubdivisionCandidates->push_back(SortableEntry(tType, pos, (*rit).mRay)); 
     
    14911498                // with respect to the classification 
    14921499                UpdateContributionsToPvs(*ray, true, cf, pvsFront, pvsBack, totalPvs);   
     1500#if COUNT_ORIGIN_OBJECTS 
    14931501                UpdateContributionsToPvs(*ray, false, cf, pvsFront, pvsBack, totalPvs); 
     1502#endif 
    14941503        } 
    14951504 
     
    15851594 
    15861595        return  (mCtDivCi + newCost) / oldCost; 
     1596} 
     1597 
     1598 
     1599void VspTree::UpdateContributionsToPvs(Intersectable *obj, 
     1600                                                                           const int cf, 
     1601                                                                           float &frontPvs, 
     1602                                                                           float &backPvs, 
     1603                                                                           float &totalPvs) const 
     1604{ 
     1605        if (!obj) return; 
     1606 
     1607        //const float renderCost = mViewCellsManager->SimpleRay &raynderCost(obj); 
     1608        const int renderCost = 1; 
     1609 
     1610        // object in no pvs => new 
     1611        if (!obj->Mailed() && !obj->Mailed(1) && !obj->Mailed(2)) 
     1612        { 
     1613                totalPvs += renderCost; 
     1614        } 
     1615 
     1616        // QUESTION matt: is it safe to assume that  
     1617        // the object belongs to no pvs in this case? 
     1618        //if (cf == Ray::COINCIDENT) return; 
     1619 
     1620        if (cf >= 0) // front pvs 
     1621        { 
     1622                if (!obj->Mailed() && !obj->Mailed(2)) 
     1623                { 
     1624                        frontPvs += renderCost; 
     1625                 
     1626                        // already in back pvs => in both pvss 
     1627                        if (obj->Mailed(1)) 
     1628                                obj->Mail(2); 
     1629                        else 
     1630                                obj->Mail(); 
     1631                } 
     1632        } 
     1633 
     1634        if (cf <= 0) // back pvs 
     1635        { 
     1636                if (!obj->Mailed(1) && !obj->Mailed(2)) 
     1637                { 
     1638                        backPvs += renderCost; 
     1639                 
     1640                        // already in front pvs => in both pvss 
     1641                        if (obj->Mailed()) 
     1642                                obj->Mail(2); 
     1643                        else 
     1644                                obj->Mail(1); 
     1645                } 
     1646        } 
    15871647} 
    15881648 
     
    30453105                                                                                   const bool isTermination, 
    30463106                                                                                   const int cf, 
    3047                                                                                    float &frontPvs, 
    3048                                                                                    float &backPvs, 
     3107                                                                                   float &pvsFront, 
     3108                                                                                   float &pvsBack, 
    30493109                                                                                   float &totalPvs) const 
    30503110{ 
    3051         /*ray.GetSampleData(isTermination, pt, &obj, &node); 
    3052         if (!obj) return 0; 
     3111        Intersectable *obj; 
     3112        Vector3 pt; 
     3113        KdNode *node; 
     3114 
     3115        ray.GetSampleData(isTermination, pt, &obj, &node); 
     3116        if (!obj) return; 
    30533117 
    30543118        switch (mHierarchyManager->GetObjectSpaceSubdivisionType()) 
     
    30603124                { 
    30613125                        BvhLeaf *leaf = mHierarchyManager->mBvHierarchy->GetLeaf(obj); 
    3062                         UpdateContributionsToPvs(leaf, true, cf, pvsFront, pvsBack, totalPvs, true);             
     3126                        UpdateContributionsToPvs(leaf, cf, pvsFront, pvsBack, totalPvs, true);           
    30633127                        break; 
    30643128                } 
    30653129        default: 
    3066                 UpdateContributionsToPvs(obj, true, cf, pvsFront, pvsBack, totalPvs, true);      
     3130                UpdateContributionsToPvs(obj, cf, pvsFront, pvsBack, totalPvs);  
    30673131                break; 
    3068         }*/ 
     3132        } 
    30693133} 
    30703134 
  • GTP/trunk/Lib/Vis/Preprocessing/src/VssPreprocessor.cpp

    r1563 r1577  
    1717 
    1818 
     19 
    1920namespace GtpVisibilityPreprocessor { 
     21 
    2022 
    2123bool use2dSampling = false; 
Note: See TracChangeset for help on using the changeset viewer.