Changeset 1415


Ignore:
Timestamp:
09/18/06 18:57:34 (18 years ago)
Author:
mattausch
Message:
 
Location:
GTP/trunk/Lib/Vis/Preprocessing/src
Files:
17 edited

Legend:

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

    r1047 r1415  
    21292129                                                        AxisAlignedBox3 &back) const 
    21302130{ 
    2131         if ( (value >= mMin[axis]) && (value <= mMax[axis]) ) 
     2131        if ((value >= mMin[axis]) && (value <= mMax[axis])) 
    21322132        { 
    21332133                front.mMin = mMin; front.mMax = mMax; 
     
    21392139} 
    21402140 
    2141  
    2142 } 
     2141  
     2142void AxisAlignedBox3::Scale(const float scale)  
     2143{ 
     2144        Vector3 newSize = Size()*(scale*0.5f); 
     2145        Vector3 center = Center(); 
     2146        mMin = center - newSize; 
     2147        mMax = center + newSize; 
     2148} 
     2149 
     2150 
     2151void AxisAlignedBox3::Scale(const Vector3 &scale)  
     2152{ 
     2153        Vector3 newSize = Size()*(scale*0.5f); 
     2154        Vector3 center = Center(); 
     2155        mMin = center - newSize; 
     2156        mMax = center + newSize; 
     2157} 
     2158 
     2159 
     2160void AxisAlignedBox3::Translate(const Vector3 &shift)  
     2161{ 
     2162         mMin += shift; 
     2163         mMax += shift; 
     2164} 
     2165 
     2166 
     2167} 
  • GTP/trunk/Lib/Vis/Preprocessing/src/AxisAlignedBox3.h

    r1414 r1415  
    7272    mMin -= v; 
    7373  } 
    74  
    7574 
    7675  void SetMin(const Vector3 &v) { 
     
    167166  /** Scales the box with the factor. 
    168167  */ 
    169   void Scale(const float scale) { 
    170         Vector3 newSize = Size()*(scale*0.5f); 
    171         Vector3 center = Center(); 
    172         mMin = center - newSize; 
    173         mMax = center + newSize; 
    174   } 
    175  
    176   void Scale(const Vector3 &scale) { 
    177         Vector3 newSize = Size()*(scale*0.5f); 
    178         Vector3 center = Center(); 
    179         mMin = center - newSize; 
    180         mMax = center + newSize; 
    181   } 
    182  
     168  void Scale(const float scale); 
     169 
     170  void Scale(const Vector3 &scale); 
     171         
    183172  /** Translates the box with the factor. 
    184173  */ 
    185   void Translate(const Vector3 &shift) { 
    186         mMin += shift; 
    187         mMax += shift; 
    188   } 
     174  void Translate(const Vector3 &shift); 
    189175 
    190176  /** Returns the square of the minimal and maximal distance to  
  • GTP/trunk/Lib/Vis/Preprocessing/src/BvHierarchy.cpp

    r1414 r1415  
    608608        } 
    609609 
     610#if 0 
    610611        cout << "depth: " << data.mDepth << " objects: " << (int)leaf->mObjects.size()  
    611612                 << " rays: " << data.mNumRays << " rays / objects "  
    612613                 << (float)data.mNumRays / (float)leaf->mObjects.size() << endl; 
     614#endif 
    613615} 
    614616 
     
    14231425        ViewCellContainer viewCells; 
    14241426        CollectViewCells(node->mObjects, viewCells); 
     1427        if (0) cout << "collected " << (int)viewCells.size() << " dirty candidates" << endl; 
    14251428 
    14261429        // split candidates handling  
    14271430        // these view cells  are thrown into dirty list 
    14281431        ViewCellContainer::const_iterator vit, vit_end = viewCells.end(); 
    1429  
    1430         Debug << "collecting " << (int)viewCells.size() << " dirty candidates" << endl; 
    14311432 
    14321433        for (vit = viewCells.begin(); vit != vit_end; ++ vit) 
  • GTP/trunk/Lib/Vis/Preprocessing/src/Environment.cpp

    r1414 r1415  
    17481748                                        "false"); 
    17491749 
    1750  
    1751  
    1752         /************************************************************************************/ 
    1753         /*                   VSS Preprocessor cells related options                         */ 
    1754         /************************************************************************************/ 
     1750        RegisterOption("Preprocessor.kdTreeFilename",  
     1751                                        optString, 
     1752                                        "preprocessor_kd_tree_filename=", 
     1753                                        "vienna_kdtree.bin.gz"); 
     1754         
     1755 
     1756        /*************************************************************************/ 
     1757        /*             VSS Preprocessor cells related options                    */ 
     1758        /*************************************************************************/ 
    17551759 
    17561760        RegisterOption("VssTree.maxDepth", optInt, "kd_depth=", "12"); 
  • GTP/trunk/Lib/Vis/Preprocessing/src/Exporter.cpp

    r1405 r1415  
    3333 
    3434 
    35 bool Exporter::ExportOspTree(const OspTree &ospTree, const int maxPvs) 
     35bool Exporter::ExportOspTree(const OspTree &ospTree,  
     36                                                         const int maxPvs 
     37                                                         ) 
    3638{ 
    3739        vector<KdLeaf *> leaves; 
    3840        ospTree.CollectLeaves(leaves); 
    39  
    4041        mUseForcedMaterial = true; 
    4142 
     
    6970                        SetForcedMaterial(RandomMaterial()); 
    7071                } 
    71  
    7272                if (0) ExportGeometry(leaf->mObjects);   
    7373        } 
     
    8080{ 
    8181        KdNode *node = kdObj.GetItem(); 
    82          
    8382        Intersectable::NewMail(); 
    8483 
     
    106105 
    107106bool Exporter::ExportBvHierarchy(const BvHierarchy &bvHierarchy,  
    108                                                                  const int maxPvs) 
     107                                                                 const int maxPvs, 
     108                                                                 AxisAlignedBox3 *box) 
    109109{ 
    110110        vector<BvhLeaf *> leaves; 
     
    112112 
    113113        mUseForcedMaterial = true; 
    114  
    115114        vector<BvhLeaf *>::const_iterator it, it_end = leaves.end(); 
    116115 
     
    126125                        continue; 
    127126 
     127                if (box && !Overlap(*box, leaf->GetBoundingBox())) 
     128                        continue; 
     129 
    128130                SetWireframe(); 
    129131                SetForcedMaterial(white); 
     
    223225 
    224226void Exporter::ExportGeometry(const ObjectContainer &objects,  
    225                                                           const bool exportSingleMesh) 
     227                                                          const bool exportSingleMesh, 
     228                                                          AxisAlignedBox3 *bbox) 
    226229{ 
    227230        ObjectContainer::const_iterator oit, oit_end = objects.end(); 
     
    231234                for (oit = objects.begin(); oit != oit_end; ++ oit) 
    232235                { 
    233                         if (0) SetForcedMaterial(RandomMaterial()); 
    234                         ExportIntersectable(*oit); 
     236                        if (bbox && Overlap(*bbox, (*oit)->GetBox())) 
     237                        { 
     238                                if (0) SetForcedMaterial(RandomMaterial()); 
     239                                ExportIntersectable(*oit); 
     240                        } 
    235241                } 
    236242 
     
    238244        } 
    239245 
     246         
     247        /////////////////////////////////////////// 
    240248        //-- all objects exported as one mesh 
    241249        //-- hack: currently works only for triangles 
     250 
    242251        PolygonContainer polys; 
    243252 
     
    245254        { 
    246255                Intersectable *obj = *oit; 
     256 
     257                if (bbox && !Overlap(*bbox, (*oit)->GetBox())) 
     258                        continue; 
     259 
    247260                switch (obj->Type()) 
    248261                { 
  • GTP/trunk/Lib/Vis/Preprocessing/src/Exporter.h

    r1404 r1415  
    7373 
    7474  virtual bool 
    75   ExportOspTree(const OspTree &tree, const int maxPvs);// = 0; 
    76  
    77 //    virtual bool 
    78 //    ExportRays(const vector<Ray> &rays, 
    79 //           const float length=1000, 
    80 //           const RgbColor &color = RgbColor(1,1,1) 
    81 //           ) = 0; 
     75  ExportOspTree(const OspTree &tree, const int maxPvs); 
    8276   
    8377  virtual bool 
     
    123117 
    124118  virtual void 
    125   ExportGeometry(const ObjectContainer &objects, const bool exportSingleMesh = false); 
     119  ExportGeometry(const ObjectContainer &objects, const bool exportSingleMesh = false, AxisAlignedBox3 *bbox = NULL); 
    126120 
    127121  virtual void 
     
    153147 
    154148  void ExportKdIntersectable(const KdIntersectable &kdObj); 
    155   bool ExportBvHierarchy(const BvHierarchy &bvHierarchy, const int maxPvs); 
     149  bool ExportBvHierarchy(const BvHierarchy &bvHierarchy, const int maxPvs, AxisAlignedBox3 *box = NULL); 
    156150 
    157151  virtual void ExportMeshInstance(MeshInstance *mi); 
  • GTP/trunk/Lib/Vis/Preprocessing/src/HierarchyManager.cpp

    r1379 r1415  
    309309{ 
    310310        cout << "starting bv hierarchy construction ... " << endl; 
    311  
    312311        mBvHierarchy->CreateRoot(objects); 
    313312 
     
    317316 
    318317        mTotalCost = mBvHierarchy->mTotalCost; 
    319         Debug << "reseting cost, new total cost: " << mTotalCost << endl; 
     318        Debug << "\nreseting cost, new total cost: " << mTotalCost << endl; 
    320319 
    321320    mTQueue.Push(sc); 
     
    373372                } 
    374373        } 
     374 
    375375        return true;//!globalTerminationCriteriaMet; 
    376376} 
     
    458458                } 
    459459                 
    460                 /////////////////////////// 
     460                /////////////////// 
    461461                //-- subdivide leaf node 
     462 
    462463                if (ApplySubdivisionCandidate(mCurrentCandidate)) 
    463464                { 
    464                         cout << "subdividing candidate " << ++ i << " of type " << mCurrentCandidate->Type() << endl; 
     465                        cout << mCurrentCandidate->Type() << " "; 
     466                        if (0) cout << "subdividing candidate " << ++ i << " of type " << mCurrentCandidate->Type() << endl; 
    465467                        mHierarchyStats.nodes += 2; 
    466468 
     
    474476 
    475477                // we use objects for evaluating vsp tree construction until  
    476                 // a certain depth once a certain depth existiert .... 
     478                // a certain depth once a certain depth existiert ... 
    477479                if (StartObjectSpaceSubdivision()) 
    478480                { 
    479481                        mObjectSpaceSubdivisionType = mSavedObjectSpaceSubdivisionType; 
    480482 
    481                         cout << "starting object space subdivision at depth "  
     483                        cout << "\nstarting object space subdivision at depth "  
    482484                                 << mVspTree->mVspStats.maxDepth << " ("  
    483485                                 << mMinDepthForObjectSpaceSubdivion << ") " << endl; 
     
    494496                        mViewSpaceSubdivisionType = mSavedViewSpaceSubdivisionType; 
    495497 
    496                         cout << "starting view space subdivision at depth "  
     498                        cout << "\nstarting view space subdivision at depth "  
    497499                                 << GetObjectSpaceSubdivisionDepth() << " ("  
    498500                                 << mMinDepthForViewSpaceSubdivion << ") " << endl; 
     
    608610        vector<SubdivisionCandidate *> dirtyList; 
    609611        CollectDirtyCandidates(dirtyList); 
    610         cout << "repairing " << (int)dirtyList.size() << " candidates ... "; 
    611          
     612        if (0) cout << "repairing " << (int)dirtyList.size() << " candidates ... "; 
     613         
     614        ///////////////////////////////// 
    612615        //-- reevaluate the dirty list 
     616 
    613617        SubdivisionCandidateContainer::const_iterator sit, sit_end = dirtyList.end(); 
    614618         
     
    638642        mHierarchyStats.repairTime += timeDiff; 
    639643 
    640         cout << "finished in " << timeDiff * 1e-3f << " secs" << endl; 
     644        if (0) cout << "finished in " << timeDiff * 1e-3f << " secs" << endl; 
    641645} 
    642646 
     
    753757        case BV_BASED_OBJ_SUBDIV: 
    754758                { 
    755                         ExportBvHierarchy(exporter, objects); 
     759                        AxisAlignedBox3 bbox = mBvHierarchy->GetBoundingBox(); 
     760                        bbox.Scale(Vector3(0.5, 1, 0.5)); 
     761                         
     762                        ExportBvHierarchy(exporter, objects, &bbox); 
    756763                        break; 
    757764                } 
     
    763770 
    764771void HierarchyManager::ExportBvHierarchy(Exporter *exporter,  
    765                                                                                  const ObjectContainer &objects) const 
     772                                                                                 const ObjectContainer &objects, 
     773                                                                                 AxisAlignedBox3 *bbox) const 
    766774{ 
    767775        exporter->SetWireframe(); 
    768         exporter->ExportBvHierarchy(*mBvHierarchy, 0); 
     776        exporter->ExportBvHierarchy(*mBvHierarchy, 0, bbox); 
    769777} 
    770778 
  • GTP/trunk/Lib/Vis/Preprocessing/src/HierarchyManager.h

    r1379 r1415  
    251251                 
    252252        void ExportOspTree(Exporter *exporter, const ObjectContainer &objects) const; 
    253         void ExportBvHierarchy(Exporter *exporter, const ObjectContainer &objects) const; 
     253 
     254        void ExportBvHierarchy( 
     255                Exporter *exporter,  
     256                const ObjectContainer &objects,  
     257                AxisAlignedBox3 *box) const; 
    254258 
    255259        void PrepareBvHierarchy( 
  • GTP/trunk/Lib/Vis/Preprocessing/src/KdTree.cpp

    r1414 r1415  
    13801380                { 
    13811381                        EvaluateLeafStats(tData); 
    1382                         cout << "l"; 
    1383                 } 
    1384         } 
     1382                        //cout << "l"; 
     1383                } 
     1384        } 
     1385 
    13851386        Debug << mStat << endl; 
    13861387 
  • GTP/trunk/Lib/Vis/Preprocessing/src/OspTree.cpp

    r1315 r1415  
    155155        } 
    156156 
    157         // if not using kd tree root, delete tree (otherwise mKdTree has to do the job) 
     157        // delete hierarchy only if not using the hierarchy from  
     158        // some other kd tree (otherwise the other kd tree has to do the job) 
    158159        if (!mCopyFromKdTree) 
    159160                DEL_PTR(mRoot); 
  • GTP/trunk/Lib/Vis/Preprocessing/src/Preprocessor.cpp

    r1414 r1415  
    154154        char buffer[256]; 
    155155        Environment::GetSingleton()->GetStringValue("Preprocessor.visibilityFile",  buffer); 
     156     
    156157        mVisibilityFileName = buffer; 
    157158        Environment::GetSingleton()->GetBoolValue("Preprocessor.applyVisibilityFilter", mApplyVisibilityFilter ); 
     
    372373  mSceneGraph->CollectObjects(&root->mObjects); 
    373374   
    374   long startTime = GetTime(); 
     375  const long startTime = GetTime(); 
    375376  cout << "building kd tree ... " << endl; 
    376377 
    377378  mKdTree->Construct(); 
    378379 
    379   cout << "construction finished in " << TimeDiff(startTime, GetTime()) * 1e-3 << " secs " << endl; 
     380  cout << "finished kd tree construction in " << TimeDiff(startTime, GetTime()) * 1e-3  
     381           << " secs " << endl; 
    380382 
    381383  return true; 
    382384} 
     385 
    383386 
    384387void 
     
    787790bool Preprocessor::InitRayCast(const string externKdTree) 
    788791{ 
     792        bool loadKdTree, exportKdTree; 
     793 
     794        Environment::GetSingleton()->GetBoolValue("Preprocessor.loadKdTree", loadKdTree); 
     795        Environment::GetSingleton()->GetBoolValue("Preprocessor.exportKdTree", exportKdTree); 
     796 
     797        char kdtreename[100]; 
     798        Environment::GetSingleton()->GetStringValue("Preprocessor.kdTreeFilename", kdtreename); 
     799 
     800         
     801        if (!loadKdTree) 
     802        { 
     803                ///////////////// 
     804                //-- build new kd tree from scene geometry 
     805 
     806                BuildKdTree(); 
     807                KdTreeStatistics(cout); 
     808        } 
     809        else 
     810        { 
     811                const long startTime = GetTime(); 
     812                cout << "loading kd tree file " << kdtreename << " ... "; 
     813 
     814                if (!LoadKdTree(kdtreename)) 
     815                { 
     816                        cout << "error loading kd tree with filename " << kdtreename << endl; 
     817                        return false; 
     818                } 
     819                cout << "finished in " << TimeDiff(startTime, GetTime()) * 1e-3 << " secs" << endl; 
     820 
     821                if (0) 
     822                { 
     823                        Exporter *exporter = Exporter::GetExporter("dummykd.x3d"); 
     824                         
     825                        if (exporter) 
     826                        { 
     827                                exporter->ExportKdTree(*mKdTree, true); 
     828                                delete exporter; 
     829                        } 
     830                } 
     831        } 
     832 
     833        if (exportKdTree) 
     834        { 
     835                const long startTime = GetTime(); 
     836                cout << "exporting kd tree ... "; 
     837                if (!ExportKdTree(kdtreename)) 
     838                { 
     839                        cout << " error exporting kd tree with filename " << kdtreename << endl; 
     840                } 
     841                else 
     842                { 
     843                        cout << "finished in " << TimeDiff(startTime, GetTime()) * 1e-3 << " secs" << endl; 
     844                } 
     845        } 
     846 
    789847        switch (mRayCastMethod) // use intel ray tracing 
    790848        { 
  • GTP/trunk/Lib/Vis/Preprocessing/src/Preprocessor.h

    r1414 r1415  
    280280  ///////////////////////// 
    281281 
    282         int mRayCastMethod; 
     282  int mRayCastMethod; 
    283283  /// samples used for construction of the BSP view cells tree. 
    284284  int mBspConstructionSamples; 
  • GTP/trunk/Lib/Vis/Preprocessing/src/RssPreprocessor.cpp

    r1328 r1415  
    8888 
    8989 
    90 #if 0 //matt: this moved up to preprocessor 
     90#if 0 //matt: this moved up into preprocessor 
    9191int 
    9292RssPreprocessor::CastRay( 
  • GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp

    r1414 r1415  
    19461946} 
    19471947 
    1948  
     1948// matt: todo 
    19491949void ViewCellsManager::ExportViewCellsForViz(Exporter *exporter) const 
    19501950{ 
     
    26402640                mViewCellsTree->SetRoot(root); 
    26412641 
    2642                 // compute pvs 
     2642                // recompute pvs in the whole hierarchy 
    26432643                ObjectPvs pvs; 
    26442644                UpdatePvsForEvaluation(root, pvs); 
    26452645        } 
     2646 
     2647        cout << "finished" << endl; 
     2648        cout << "merged view cells in " 
     2649                 << TimeDiff(startTime, GetTime()) * 1e-3 << " secs" << endl; 
     2650 
     2651        Debug << "Postprocessing: Merged view cells in " 
     2652                << TimeDiff(startTime, GetTime()) * 1e-3 << " secs" << endl << endl; 
     2653 
     2654         
     2655        ///////////////////////////////////////// 
     2656        //-- visualization and statistics 
    26462657 
    26472658        // export statistics after merge 
     
    26532664        } 
    26542665 
    2655         //-- stats and visualizations 
    2656         cout << "finished" << endl; 
    2657         cout << "merged view cells in " 
    2658                  << TimeDiff(startTime, GetTime()) * 1e-3 << " secs" << endl; 
    2659  
    2660         Debug << "Postprocessing: Merged view cells in " 
    2661                 << TimeDiff(startTime, GetTime()) * 1e-3 << " secs" << endl << endl; 
    2662          
    2663  
    2664         //-- visualization and statistics 
    2665     // reset view cells and stats 
    2666         ResetViewCells(); 
     2666        ResetViewCells(); // reset view cells 
    26672667        Debug << "\nView cells after merge:\n" << mCurrentViewCellsStats << endl; 
    26682668 
     
    27632763        { 
    27642764                mColorCode = 1; // hack color code 
    2765                 Exporter *exporter = Exporter::GetExporter("final_view_cells.x3d"); 
     2765                Exporter *exporter = Exporter::GetExporter("final_view_cells.wrl"); 
    27662766         
    27672767                cout << "exporting view cells after merge (pvs size) ... ";      
     
    38153815        SimulationStatistics ss; 
    38163816        dynamic_cast<RenderSimulator *>(mRenderer)->GetStatistics(ss); 
    3817     Debug << "render time before refine\n" << ss << endl; 
     3817    Debug << "render time before refine\n\n" << ss << endl; 
    38183818 
    38193819        const long startTime = GetTime(); 
     
    38983898        //-- render simulation after merge + refine 
    38993899 
    3900         cout << "\nview cells partition render time before compress"; 
     3900        cout << "\nview cells partition render time before compress" << endl << endl;; 
    39013901        dynamic_cast<RenderSimulator *>(mRenderer)->RenderScene(); 
    39023902        SimulationStatistics ss; 
     
    44494449        //    find view cells associated with the samples 
    44504450        //    store the sample pvs with the pvs associated with the view cell 
     4451        // 
    44514452        // for each view cell: 
    44524453        //    compute difference point sampled pvs - view cell pvs 
     
    44904491                m.mDiffuseColor.b = 1.0f; 
    44914492                //exporter->SetForcedMaterial(m); 
    4492  
    4493 //              ExportViewCellGeometry(exporter, vc, mClipPlane); 
    4494  
    4495 /*      // counting the pvss 
    4496         for (rit = samples.begin(); rit != rit_end; ++ rit) 
    4497         { 
    4498                 RenderCostSample sample = *rit; 
    4499  
    4500                 ViewCell *vc = GetViewCell(sample.mPosition); 
    4501                  
    4502                 AxisAlignedBox3 box(sample.mPosition - Vector3(1, 1, 1), sample.mPosition + Vector3(1, 1, 1)); 
    4503                 Mesh *hMesh = CreateMeshFromBox(box); 
    4504                  
    4505                 DEL_PTR(hMesh); 
    4506  
    4507 */ 
     4493                //ExportViewCellGeometry(exporter, vc, mClipPlane); 
     4494 
     4495                /*      // counting the pvss 
     4496                for (rit = samples.begin(); rit != rit_end; ++ rit) 
     4497                { 
     4498                        RenderCostSample sample = *rit; 
     4499                        ViewCell *vc = GetViewCell(sample.mPosition); 
     4500 
     4501                        AxisAlignedBox3 box(sample.mPosition - Vector3(1, 1, 1), sample.mPosition + Vector3(1, 1, 1)); 
     4502                        Mesh *hMesh = CreateMeshFromBox(box); 
     4503 
     4504                        DEL_PTR(hMesh); 
     4505                } 
     4506                */ 
    45084507        } 
    45094508} 
     
    48014800 
    48024801        // print subdivision statistics 
     4802        Debug << endl << endl; 
    48034803        mHierarchyManager->PrintHierarchyStatistics(Debug); 
    48044804 
     
    48154815 
    48164816        const long startTime = GetTime(); 
    4817  
    48184817        cout << "Computing remaining ray contributions ... "; 
    48194818 
     
    48224821                ComputeSampleContributions(savedRays, true, false); 
    48234822 
    4824         cout << "finished" << endl; 
    4825  
    4826         Debug << "Computed remaining ray contribution in " << TimeDiff(startTime, GetTime()) * 1e-3 
     4823        Debug << "finished computing remaining ray contribution in " << TimeDiff(startTime, GetTime()) * 1e-3 
    48274824                  << " secs" << endl; 
    48284825 
    4829         cout << "construction finished" << endl; 
    4830  
    4831         // real meshes are contructed at this stage 
    48324826        if (0) 
    48334827        { 
     4828                // real meshes are constructed at this stage 
    48344829                cout << "finalizing view cells ... "; 
    48354830                FinalizeViewCells(true); 
     
    49084903        //-- render simulation after merge + refine 
    49094904 
    4910         cout << "\nview cells partition render time before compress"; 
     4905        cout << "\nview cells partition render time before compress" << endl << endl; 
    49114906        dynamic_cast<RenderSimulator *>(mRenderer)->RenderScene(); 
    49124907        SimulationStatistics ss; 
     
    50285023         
    50295024        if (clipPlane) 
     5025        { 
    50305026                plane = clipPlane->GetPlane(); 
     5027        } 
     5028 
     5029        AxisAlignedBox3 bbox = GetViewSpaceBox(); 
     5030        bbox.Scale(Vector3(0.5, 1, 0.5));                        
    50315031 
    50325032        for (it = leaves.begin(); it != it_end; ++ it) 
     
    50375037                const AxisAlignedBox3 box = mHierarchyManager->GetVspTree()->GetBoundingBox(vspVc->mLeaf); 
    50385038                 
     5039                if (!Overlap(box, bbox)) 
     5040                        continue; 
     5041 
    50395042                if (clipPlane) 
    50405043                { 
     
    50815084        if (1)  
    50825085        {        
     5086                ///////////////////////////// 
    50835087                //-- export final view cells 
    50845088 
    5085                 // hack pvs 
     5089                // hack color code (show pvs size) 
    50865090                const int savedColorCode = mColorCode; 
    50875091                mColorCode = 0; 
     
    50915095                if (exporter) 
    50925096                { 
    5093                         cout << "exporting view cells after post process ... "; 
     5097                        const long starttime = GetTime(); 
     5098                        cout << "exporting final view cells (after initial construction + post process) ... "; 
    50945099 
    50955100                        if (mExportGeometry) 
     
    51135118                        delete exporter; 
    51145119 
    5115                         cout << "finished" << endl; 
     5120                        cout << "finished in " << TimeDiff(starttime, GetTime()) * 1e-3f << " secs" << endl; 
    51165121                } 
    51175122 
     
    51265131                if (exporter) 
    51275132                { 
     5133                        const long starttime = GetTime(); 
     5134 
    51285135                        cout << "exporting object space hierarchy ... "; 
    51295136                        mHierarchyManager->ExportObjectSpaceHierarchy(exporter, objects); 
    51305137                 
    51315138                        delete exporter; 
    5132                         cout << "finished" << endl; 
     5139                        cout << "finished in " << TimeDiff(starttime, GetTime()) * 1e-3f << " secs" << endl; 
    51335140                } 
    51345141        } 
     
    51535160        const bool sortViewCells = true; 
    51545161 
    5155         // sort view cells to visualize the largest view cells 
    51565162        if (sortViewCells) 
    51575163        { 
    51585164                //stable_sort(mViewCells.begin(), mViewCells.end(), ViewCell::SmallerPvs); 
     5165                // sort view cells to visualize the view cells with highest render cost 
    51595166                stable_sort(mViewCells.begin(), mViewCells.end(), ViewCell::LargerRenderCost); 
    51605167        } 
    51615168 
    51625169        int limit = min(leafOut, (int)mViewCells.size()); 
    5163  
    51645170        int raysOut = 0; 
    51655171 
    5166  
     5172        /////////////////////////// 
    51675173        //-- some rays for output 
    51685174         
     
    52495255                                }        
    52505256                                 
    5251                                 //-- export rays piercing this view cell 
     5257                                // export rays piercing this view cell 
    52525258                                exporter->ExportRays(vcRays, RgbColor(1, 1, 0)); 
    52535259                        } 
    52545260                } 
    52555261 
     5262 
     5263                ///////////////// 
    52565264                //-- export view cell geometry 
    52575265 
     
    52675275 
    52685276#if 0    
     5277                ////////// 
    52695278                //-- export pvs 
    52705279 
     
    53365345                return false; 
    53375346 
     5347        const long starttime = GetTime(); 
    53385348        cout << "exporting view cells to xml ... "; 
    53395349         
     
    53495359        ////////////////////////////////////////////////////////////// 
    53505360        //-- export bounding boxes 
     5361        //-- The bounding boxes are used to identify  
     5362        //-- the objects in the rendering engine 
    53515363 
    53525364        stream << "<BoundingBoxes>" << endl; 
     
    53565368        { 
    53575369                        const AxisAlignedBox3 box = (*oit)->GetBox(); 
    5358  
    5359                         //-- the bounding boxes 
    53605370                        stream << "<BoundingBox" << " id=\"" << (*oit)->GetId() << "\"" 
    53615371                                   << " min=\"" << box.Min().x << " " << box.Min().y << " " << box.Min().z << "\"" 
    53625372                                   << " max=\"" << box.Max().x << " " << box.Max().y << " " << box.Max().z << "\" />" << endl; 
    53635373        } 
    5364  
    53655374        stream << "</BoundingBoxes>" << endl; 
    53665375 
    5367         //////////////////////////////////////////////////////////////// 
     5376 
     5377        ////////////////////////// 
    53685378        //-- export the view cells and the pvs 
    53695379 
     
    53745384        stream << "</ViewCells>" << endl; 
    53755385 
    5376  
     5386        ////////////////////// 
    53775387        //-- export the view space hierarchy 
    53785388         
     
    53845394        stream << "</ViewSpaceHierarchy>" << endl; 
    53855395 
    5386          
     5396        //////////////////////   
    53875397        //-- export the object space partition 
    53885398         
     
    53925402        stream.close(); 
    53935403         
    5394         cout << "finished" << endl; 
    5395  
     5404        cout << "finished in " << TimeDiff(starttime, GetTime()) * 1e-3 << " secs" << endl; 
    53965405        return true; 
    53975406} 
  • GTP/trunk/Lib/Vis/Preprocessing/src/VspTree.cpp

    r1379 r1415  
    9494        app << "#N_LEAVES ( Number of leaves )\n" << Leaves() << "\n"; 
    9595 
    96         app << "#AXIS_ALIGNED_SPLITS (number of axis aligned splits)\n" << splits[0] + splits[1] + splits[2] << endl; 
    97  
    9896        app << "#N_SPLITS ( Number of splits in axes x y z)\n"; 
    9997 
    10098        for (int i = 0; i < 3; ++ i) 
    10199                app << splits[i] << " "; 
     100 
    102101        app << endl; 
    103102 
     
    529528                || (data.mPvs <= mTermMinPvs) 
    530529                || (data.mProbability <= mTermMinProbability) 
    531                 || (data.GetAvgRayContribution() > mTermMaxRayContribution) 
     530                //|| (data.GetAvgRayContribution() > mTermMaxRayContribution) 
    532531                || (data.mDepth >= mTermMaxDepth) 
    533532                ); 
    534533 
    535         if (1 && localTerminationCriteriaMet) 
    536         { 
    537                 Debug << "********local termination *********" << endl; 
     534        if (0 && localTerminationCriteriaMet) 
     535        { 
     536                Debug << "local termination criteria met:" << endl; 
    538537                Debug << "rays: " << (int)data.mRays->size() << "  " << mTermMinRays << endl; 
    539538                Debug << "pvs: " << data.mPvs << " " << mTermMinPvs << endl; 
     
    552551                // || mOutOfMemory 
    553552                || (mVspStats.Leaves() >= mMaxViewCells) 
    554         //|| (mGlobalCostMisses >= mTermGlobalCostMissTolerance)  
     553        || (mGlobalCostMisses >= mTermGlobalCostMissTolerance)  
    555554                ); 
    556555 
    557556        if (0 && terminationCriteriaMet) 
    558557        { 
    559                 Debug << "********* terminationCriteriaMet *********" << endl; 
     558                Debug << "globlal termination criteria met:" << endl; 
    560559                Debug << "cost misses: " << mGlobalCostMisses << " " << mTermGlobalCostMissTolerance << endl; 
    561560                Debug << "leaves: " << mVspStats.Leaves() << " " <<  mMaxViewCells << endl; 
     
    768767        VspLeaf *leaf = dynamic_cast<VspLeaf *>(tData.mNode); 
    769768         
    770         /////////////////////////////////////////////////////////////////// 
    771         //-- the front and back traversal data is filled with the new values 
     769        //////////////////////////////////////////////////////// 
     770        //-- the front and back traversal data are filled with the new values 
    772771 
    773772        frontData.mDepth = tData.mDepth + 1; 
     
    807806        // two more leaves 
    808807        mVspStats.nodes += 2; 
    809  
     808        /// and a new split 
     809        ++ mVspStats.splits[splitPlane.mAxis]; 
    810810 
    811811    /////////////////////////////////////////// 
  • GTP/trunk/Lib/Vis/Preprocessing/src/X3dParser.cpp

    r1404 r1415  
    220220void X3dParseHandlers::EndShape() 
    221221{ 
    222          //-- if shape is merely a definition => don't create particular mesh instance 
    223          if (!mCurrentMesh || mIsMeshDefinition)  
    224          {  
    225                  return; 
    226          } 
    227  
    228          //////////////////////////////////// 
    229          //-- each triangle is one single mesh 
    230  
    231          if (!mLoadMeshes) 
    232          { 
    233                  cout << "m";    
    234                  Mesh tempMesh(*mCurrentMesh); 
    235                  ApplyTransformations(mTransformations, &tempMesh); 
    236  
    237                  FaceContainer::const_iterator fit, fit_end = tempMesh.mFaces.end(); 
    238                  
    239                  for (fit = tempMesh.mFaces.begin(); fit != fit_end; ++ fit) 
    240                  { 
    241                          cout << "f"; 
    242                          // triangulate the faces 
    243                          Face *face = *fit; 
    244                          vector<Triangle3> triangles; 
    245                          Polygon3 poly(face, &tempMesh); 
    246                          poly.Triangulate(triangles); 
    247  
    248                          vector<Triangle3>::const_iterator tit, tit_end = triangles.end(); 
    249  
    250                          for (tit = triangles.begin(); tit != tit_end; ++ tit) 
    251                          { 
    252                                  //cout << "triangle: " << *tit << endl; 
    253                                  TriangleIntersectable *ti = new TriangleIntersectable(*tit); 
    254                                  mCurrentNode->mGeometry.push_back(ti); 
    255                          } 
     222        ////////////// 
     223        //-- shape is only a definition =>  
     224        //-- don't create particular mesh instance 
     225 
     226        if (!mCurrentMesh || mIsMeshDefinition)  
     227        {  
     228                return; 
     229        } 
     230 
     231        if (!mLoadMeshes) 
     232        { 
     233                //////////////////////////////////// 
     234                //-- load data as single triangles instead of whole meshes 
     235 
     236                //cout << "m";   
     237                Mesh tempMesh(*mCurrentMesh); 
     238                ApplyTransformations(mTransformations, &tempMesh); 
     239 
     240                FaceContainer::const_iterator fit, fit_end = tempMesh.mFaces.end(); 
     241 
     242                for (fit = tempMesh.mFaces.begin(); fit != fit_end; ++ fit) 
     243                { 
     244                        //cout << "f"; 
     245                        // triangulate the faces 
     246                        Face *face = *fit; 
     247                        vector<Triangle3> triangles; 
     248                        Polygon3 poly(face, &tempMesh); 
     249                        poly.Triangulate(triangles); 
     250 
     251                        vector<Triangle3>::const_iterator tit, tit_end = triangles.end(); 
     252 
     253                        for (tit = triangles.begin(); tit != tit_end; ++ tit) 
     254                        { 
     255                                //cout << "triangle: " << *tit << endl; 
     256                                TriangleIntersectable *ti = new TriangleIntersectable(*tit); 
     257                                mCurrentNode->mGeometry.push_back(ti); 
     258                        } 
    256259#if 0 
    257                          // we create a new mesh for each face from the current mesh 
    258                          Mesh *mesh = MeshManager::GetSingleton()->CreateResource(); 
    259                          
    260                          VertexIndexContainer::const_iterator vit, vit_end = face->mVertexIndices.end(); 
    261                  
    262                          int i = 0; 
    263                          // dummy vertex indices container 
    264                          VertexIndexContainer vcIndices; 
    265  
    266                          for (vit = face->mVertexIndices.begin(); vit != vit_end; ++ vit, ++ i) 
    267                          { 
    268                                  cout << "i"; 
    269                                  const int index = (*vit); 
    270                                  // add vertices 
    271                                  mesh->mVertices.push_back(mCurrentMesh->mVertices[index]); 
    272                                  // indices don't make much sense if mesh == face, but we need them anyway ... 
    273                                  vcIndices.push_back(i); 
    274                          } 
    275  
    276                          mesh->mFaces.push_back(new Face(vcIndices)); 
    277  
    278                          // write transformations directly into the mesh 
    279                          // note: could be transformed in parent mesh, save some transformations 
    280                          ApplyTransformations(mTransformations, mesh); 
    281  
    282                          mesh->Preprocess(); 
    283                                  
    284                          if (mesh->mFaces.empty()) 
    285                          { 
    286                                  cout << "error: empy mesh" << endl; 
    287                          } 
    288                          else 
    289                          { 
    290                                  // make an instance of this mesh 
    291                                  MeshInstance *mi = new MeshInstance(mesh); 
    292                                  mCurrentNode->mGeometry.push_back(mi); 
    293  
    294                                  if (mCurrentMaterial && !mCurrentMesh->mMaterial) 
    295                                  { 
    296                                          // HACK: add the material to the mesh directly if no material yet 
    297                                          mCurrentMesh->mMaterial = mCurrentMaterial; 
    298                                  } 
    299                          } 
     260                        // we create a new mesh for each face from the current mesh 
     261                        Mesh *mesh = MeshManager::GetSingleton()->CreateResource(); 
     262 
     263                        VertexIndexContainer::const_iterator vit, vit_end = face->mVertexIndices.end(); 
     264 
     265                        int i = 0; 
     266                        // dummy vertex indices container 
     267                        VertexIndexContainer vcIndices; 
     268 
     269                        for (vit = face->mVertexIndices.begin(); vit != vit_end; ++ vit, ++ i) 
     270                        { 
     271                                cout << "i"; 
     272                                const int index = (*vit); 
     273                                // add vertices 
     274                                mesh->mVertices.push_back(mCurrentMesh->mVertices[index]); 
     275                                // indices don't make much sense if mesh == face, but we need them anyway ... 
     276                                vcIndices.push_back(i); 
     277                        } 
     278 
     279                        mesh->mFaces.push_back(new Face(vcIndices)); 
     280 
     281                        // write transformations directly into the mesh 
     282                        // note: could be transformed in parent mesh, save some transformations 
     283                        ApplyTransformations(mTransformations, mesh); 
     284 
     285                        mesh->Preprocess(); 
     286 
     287                        if (mesh->mFaces.empty()) 
     288                        { 
     289                                cout << "error: empy mesh" << endl; 
     290                        } 
     291                        else 
     292                        { 
     293                                // make an instance of this mesh 
     294                                MeshInstance *mi = new MeshInstance(mesh); 
     295                                mCurrentNode->mGeometry.push_back(mi); 
     296 
     297                                if (mCurrentMaterial && !mCurrentMesh->mMaterial) 
     298                                { 
     299                                        // HACK: add the material to the mesh directly if no material yet 
     300                                        mCurrentMesh->mMaterial = mCurrentMaterial; 
     301                                } 
     302                        } 
    300303#endif 
    301                  } 
    302  
    303                  // this mesh is not needed, unless it is used as a definition 
    304                  if (!mUsingMeshDefinition) 
    305                  { 
    306                          MeshManager::GetSingleton()->DestroyEntry(mCurrentMesh->GetId()); 
    307                  } 
     304                } 
     305 
     306                // this mesh is not needed, unless it is used as a definition 
     307                if (!mUsingMeshDefinition) 
     308                { 
     309                        MeshManager::GetSingleton()->DestroyEntry(mCurrentMesh->GetId()); 
     310                } 
    308311        } 
    309312        else // default usage: create a mesh instance from the current mesh 
     
    321324                else 
    322325                { 
    323                          // make an instance of this mesh 
     326                        // make an instance of this mesh 
    324327                        TransformedMeshInstance *tmi = new TransformedMeshInstance(mCurrentMesh); 
    325328 
    326                          // apply transformation on the instance of the mesh  
    327                          ApplyTransformations(mTransformations, tmi); 
    328                          mi = tmi; 
    329                 } 
    330                          
     329                        // apply transformation on the instance of the mesh  
     330                        ApplyTransformations(mTransformations, tmi); 
     331                        mi = tmi; 
     332                } 
     333 
    331334                if (mCurrentMaterial) 
    332335                { 
     
    341344                        } 
    342345                } 
    343                  
     346 
    344347                // create local mesh kd tree 
    345348                mCurrentMesh->Preprocess(); 
     
    368371 
    369372        VertexIndexContainer vertices; 
    370    
     373 
    371374        mIsMeshDefinition = false; 
    372375        mUsingMeshDefinition = false; 
     
    579582  
    580583  if (element == "Shape") { 
    581           cout << "+";  
     584          //cout << "+";  
    582585 
    583586          // reset current shape values 
  • GTP/trunk/Lib/Vis/Preprocessing/src/main.cpp

    r1414 r1415  
    149149        } 
    150150 
    151         //////////////////////////////////////// 
     151 
     152        ///////////// 
    152153        //-- load scene  
    153154 
     
    175176                exit(1); 
    176177        } 
    177  
    178         bool loadKdTree, exportKdTree; 
    179  
    180         Environment::GetSingleton()->GetBoolValue("Preprocessor.loadKdTree", loadKdTree); 
    181  
    182         const string kdtreename("kd.bin.gz"); 
    183  
    184         if (!loadKdTree) 
    185         { 
    186                 //-- build new kd tree from scene geometry 
    187                 preprocessor->BuildKdTree(); 
    188                 preprocessor->KdTreeStatistics(cout); 
    189         } 
    190         else 
    191         { 
    192                 const long startTime = GetTime(); 
    193                 cout << "loading kd tree ... "; 
    194  
    195                 if (!preprocessor->LoadKdTree(kdtreename)) 
    196                 { 
    197                         cout << "error loading kd tree with filename " << kdtreename << endl; 
    198                         Cleanup(); 
    199                         exit(1); 
    200                 } 
    201                 cout << "finished in " << TimeDiff(startTime, GetTime()) * 1e-3 << " secs" << endl; 
    202  
    203                 if (0) 
    204                 { 
    205                         Exporter *exporter = Exporter::GetExporter("dummykd.x3d"); 
    206                          
    207                         if (exporter) 
    208                         { 
    209                                 exporter->ExportKdTree(*preprocessor->mKdTree, true); 
    210                                 delete exporter; 
    211                         } 
    212                 } 
    213         } 
    214  
    215         Environment::GetSingleton()->GetBoolValue("Preprocessor.exportKdTree", exportKdTree); 
    216  
    217         if (exportKdTree) 
    218         { 
    219                 const long startTime = GetTime(); 
    220                 cout << "exporting kd tree ... "; 
    221                 if (!preprocessor->ExportKdTree(kdtreename)) 
    222                 { 
    223                         cout << " error exporting kd tree with filename " << kdtreename << endl; 
    224                 } 
    225                 else 
    226                 { 
    227                         cout << "finished in " << TimeDiff(startTime, GetTime()) * 1e-3 << " secs" << endl; 
    228                 } 
    229         } 
    230  
    231178 
    232179        // parse view cells related options 
     
    301248        } 
    302249         
     250        // release memory 
    303251        Cleanup(); 
    304252         
Note: See TracChangeset for help on using the changeset viewer.