Changeset 2113


Ignore:
Timestamp:
02/12/07 08:37:26 (17 years ago)
Author:
mattausch
Message:

warning: debug version

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

Legend:

Unmodified
Added
Removed
  • GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/include/OgreBoundingBoxConverter.h

    r2111 r2113  
    122122        list<SceneNode *>::const_iterator sit, sit_end = sceneNodeList.end(); 
    123123        // find the bbox which is closest to the current bbox 
    124         for (sit = sceneNodeList.begin(); sit != sceneNodeList.end(); ++ sit) 
     124        for (sit = sceneNodeList.begin(); sit != sit_end; ++ sit) 
    125125        { 
    126126                SceneNode *sn = *sit; 
  • GTP/trunk/Lib/Vis/Preprocessing/src/Intersectable.h

    r2066 r2113  
    5656                 DUMMY_INTERSECTABLE, 
    5757                 ENGINE_INTERSECTABLE, 
     58                 CONTAINER_INTERSECTABLE 
    5859                }; 
    5960   
  • GTP/trunk/Lib/Vis/Preprocessing/src/IntersectableWrapper.h

    r2069 r2113  
    1010 
    1111 
    12 struct VssRayContainer; 
    1312class KdNode; 
    14 //class BvhNode; 
    1513class BvhLeaf; 
    1614class Ray; 
    17  
     15class KdTree; 
     16struct VssRayContainer; 
     17struct Triangle3; 
    1818struct Face; 
    19 struct Triangle3; 
    20  
    21 class KdTree; 
    22  
    23  
    24 /** 
    25         Wrapper used for creating a PVS compliant intersectable. 
     19 
     20/** Wrapper used for creating a PVS compliant intersectable. 
    2621*/ 
    2722template<typename T> 
     
    219214 
    220215 
     216/** Intersectable acting as a proxy. 
     217*/ 
    221218class DummyIntersectable: public IntersectableWrapper<int> 
    222219{ 
    223220public: 
    224   DummyIntersectable(const int item): 
    225         IntersectableWrapper<int>(item) {} 
     221        DummyIntersectable(const int item): 
     222          IntersectableWrapper<int>(item) {} 
    226223 
    227224        int Type() const 
     
    231228}; 
    232229 
     230 
     231/** Intersectable wrapping is a group of objects. 
     232*/ 
     233class ContainerIntersectable: public GtpVisibilityPreprocessor::IntersectableWrapper<ObjectContainer *> 
     234{ 
     235public: 
     236        ContainerIntersectable(ObjectContainer *item): 
     237          IntersectableWrapper<ObjectContainer *>(item) {} 
     238 
     239        // hack 
     240        ContainerIntersectable::~ContainerIntersectable()  
     241        { 
     242                delete mItem; 
     243        } 
     244 
     245        int Type() const 
     246        { 
     247                return Intersectable::CONTAINER_INTERSECTABLE; 
     248        } 
     249}; 
     250 
    233251} 
    234252 
  • GTP/trunk/Lib/Vis/Preprocessing/src/KdTree.h

    r2066 r2113  
    413413 
    414414  void GetBoxIntersections(const AxisAlignedBox3 &box,  
    415                                                   vector<KdLeaf *> &leaves); 
     415                                                   vector<KdLeaf *> &leaves); 
    416416 
    417417  int 
  • GTP/trunk/Lib/Vis/Preprocessing/src/Preprocessor.cpp

    r2111 r2113  
    733733                cout << "loading view cells from " << buf << endl<<flush; 
    734734 
    735                 mViewCellsManager = ViewCellsManager::LoadViewCells(buf, &mObjects, true, NULL); 
     735                mViewCellsManager = ViewCellsManager::LoadViewCells(buf,  
     736                                                                                                                        mObjects,  
     737                                                                                                                        mObjects,  
     738                                                                                                                        true,  
     739                                                                                                                        NULL); 
    736740 
    737741                cout << "view cells loaded." << endl<<flush; 
  • GTP/trunk/Lib/Vis/Preprocessing/src/Preprocessor.vcproj

    r2100 r2113  
    518518                        </File> 
    519519                        <File 
     520                                RelativePath=".\IntersectionBoundingBoxConverter.cpp"> 
     521                        </File> 
     522                        <File 
     523                                RelativePath=".\IntersectionBoundingBoxConverter.h"> 
     524                        </File> 
     525                        <File 
    520526                                RelativePath="..\src\KdTree.cpp"> 
    521527                        </File> 
  • GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp

    r2105 r2113  
    10231023 
    10241024ViewCellsManager *ViewCellsManager::LoadViewCells(const string &filename,  
    1025                                                                                                   ObjectContainer *objects, 
     1025                                                                                                  ObjectContainer &pvsObjects, 
     1026                                                                                                  ObjectContainer &preprocessorObjects, 
    10261027                                                                                                  bool finalizeViewCells, 
    10271028                                                                                                  BoundingBoxConverter *bconverter) 
     
    10321033 
    10331034        const long startTime = GetTime(); 
    1034         bool success = parser.ParseViewCellsFile(filename, &vm, objects, bconverter); 
    1035  
    1036         cout<<"viewcells parsed "<<endl<<flush; 
    1037          
    1038         if (success) 
    1039         { 
    1040                 if (0) 
    1041                 { 
    1042                         vm->ResetViewCells(); 
    1043                 } 
    1044                 else 
    1045                 { 
    1046                         //hack: should work with reset function 
    1047                         ViewCellContainer leaves; 
    1048  
    1049                         vm->mViewCells.clear(); 
    1050                         vm->mViewCellsTree->CollectLeaves(vm->mViewCellsTree->GetRoot(), leaves); 
    1051                  
    1052                         ViewCellContainer::const_iterator it, it_end = leaves.end(); 
    1053  
    1054                         for (it = leaves.begin(); it != it_end; ++ it) 
    1055                         { 
    1056                                 vm->mViewCells.push_back(*it); 
    1057                         } 
    1058                 } 
    1059  
    1060                 vm->mViewCellsFinished = true; 
    1061                 vm->mMaxPvsSize = (int)objects->size(); 
    1062  
    1063                  
    1064                 if (finalizeViewCells) 
    1065                 { 
    1066                         // create the meshes and compute volumes 
    1067                         const bool createMeshes = true; 
    1068                         //const bool createMeshes = false; 
    1069  
    1070                         vm->FinalizeViewCells(createMeshes); 
    1071                 } 
    1072  
    1073                 cout << (int)vm->mViewCells.size() << " view cells loaded in " 
    1074                          << TimeDiff(startTime, GetTime()) * 1e-3f << " secs" << endl; 
    1075  
    1076                 Debug << (int)vm->mViewCells.size() << " view cells loaded in " 
    1077                           << TimeDiff(startTime, GetTime()) * 1e-3f << " secs" << endl; 
    1078         } 
    1079         else 
     1035        const bool success = parser.ParseViewCellsFile(filename,  
     1036                                                                                                   &vm,  
     1037                                                                                                   pvsObjects,  
     1038                                                                                                   preprocessorObjects,  
     1039                                                                                                   bconverter); 
     1040 
     1041        if (!success) 
    10801042        { 
    10811043                Debug << "Error: loading view cells failed!" << endl; 
    10821044                DEL_PTR(vm); 
    1083         } 
    1084  
     1045 
     1046                return NULL; 
     1047        } 
     1048         
     1049        //cout << "viewcells parsed " <<endl; 
     1050 
     1051        if (0) 
     1052        { 
     1053                vm->ResetViewCells(); 
     1054        } 
     1055        else 
     1056        { 
     1057                //hack: should work with reset function 
     1058                ViewCellContainer leaves; 
     1059 
     1060                vm->mViewCells.clear(); 
     1061                vm->mViewCellsTree->CollectLeaves(vm->mViewCellsTree->GetRoot(), leaves); 
     1062                 
     1063                ViewCellContainer::const_iterator it, it_end = leaves.end(); 
     1064 
     1065                for (it = leaves.begin(); it != it_end; ++ it) 
     1066                { 
     1067                        vm->mViewCells.push_back(*it); 
     1068                } 
     1069        } 
     1070 
     1071        vm->mViewCellsFinished = true; 
     1072        vm->mMaxPvsSize = (int)pvsObjects.size(); 
     1073 
     1074        if (finalizeViewCells) 
     1075        { 
     1076                // create the meshes and compute volumes 
     1077                const bool createMeshes = true; 
     1078                //const bool createMeshes = false; 
     1079 
     1080                vm->FinalizeViewCells(createMeshes); 
     1081        } 
     1082 
     1083        cout << (int)vm->mViewCells.size() << " view cells loaded in " 
     1084                 << TimeDiff(startTime, GetTime()) * 1e-3f << " secs" << endl; 
     1085 
     1086        Debug << (int)vm->mViewCells.size() << " view cells loaded in " 
     1087                  << TimeDiff(startTime, GetTime()) * 1e-3f << " secs" << endl; 
     1088         
    10851089        return vm; 
    10861090} 
     
    67816785 
    67826786 
    6783 ViewCellsManager *VspOspViewCellsManager::LoadViewCells(const string &filename,  
    6784                                                                                                                 ObjectContainer *objects, 
    6785                                                                                                                 const bool finalizeViewCells, 
    6786                                                                                                                 BoundingBoxConverter *bconverter) 
    6787                                                                                                   
    6788 { 
    6789         ViewCellsManager *vm =  
    6790                 ViewCellsManager::LoadViewCells(filename, objects, finalizeViewCells, bconverter); 
    6791  
    6792         return vm; 
    6793 } 
    6794  
    6795  
    6796 void 
    6797 VspOspViewCellsManager::CollectObjects(const AxisAlignedBox3 &box, ObjectContainer &objects) 
     6787void VspOspViewCellsManager::CollectObjects(const AxisAlignedBox3 &box,  
     6788                                                                                        ObjectContainer &objects) 
    67986789{ 
    67996790        mHierarchyManager->CollectObjects(box, objects); 
  • GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.h

    r2111 r2113  
    571571        */ 
    572572        static ViewCellsManager *LoadViewCells(const string &filename,  
    573                                                                                    ObjectContainer *objects,  
     573                                                                                   ObjectContainer &pvsObjects, 
     574                                                                                   ObjectContainer &preprocessorObjects, 
    574575                                                                                   bool finalizeViewCells = false, 
    575576                                                                                   BoundingBoxConverter *bconverter = NULL); 
    576577 
    577578 
    578         ////////////////////////////////////////////////////////7 
     579        /////////////////////// 
    579580        // visiblity filter options 
    580581 
     
    12121213public: 
    12131214 
    1214         VspOspViewCellsManager(ViewCellsTree *vcTree, const string &hierarchyType); 
     1215        VspOspViewCellsManager(ViewCellsTree *vcTree,  
     1216                                                   const string &hierarchyType); 
    12151217         
    12161218        ~VspOspViewCellsManager(); 
     
    12451247        float GetProbability(ViewCell *viewCell); 
    12461248         
    1247         ViewCell *GetViewCell(const Vector3 &point, const bool active = false) const; 
     1249        ViewCell *GetViewCell(const Vector3 &point,  
     1250                                                  const bool active = false) const; 
    12481251 
    12491252        bool GetViewPoint(Vector3 &viewPoint) const; 
     
    12601263 
    12611264        void Finalize(ViewCell *viewCell, const bool createMesh); 
    1262  
    1263         ViewCellsManager *LoadViewCells(const string &filename,  
    1264                                                                         ObjectContainer *objects, 
    1265                                                                         const bool finalizeViewCells, 
    1266                                                                         BoundingBoxConverter *bconverter); 
    12671265 
    12681266        void ExportSingleViewCells(const ObjectContainer &objects, 
  • GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsParser.cpp

    r2097 r2113  
    55#include <stdlib.h> 
    66#include <iostream> 
     7//#include <ext/algorithm> 
     8 
    79using namespace std; 
    810#include <xercesc/util/PlatformUtils.hpp> 
     
    7678//  StdInParseHandlers: Constructors and Destructor 
    7779// --------------------------------------------------------------------------- 
    78 ViewCellsParseHandlers::ViewCellsParseHandlers(ObjectContainer *objects,  
    79                                                                                            BoundingBoxConverter *bconverter): 
     80ViewCellsParseHandlers::ViewCellsParseHandlers(ObjectContainer &pvsObjects,  
     81                                                                                           ObjectContainer &preprocessorObjects, 
     82                                                                                           BoundingBoxConverter *bconverter 
     83                                                                                           ): 
    8084  mElementCount(0) 
    8185  , mAttrCount(0) 
     
    9296  , mCurrentOspNode(NULL) 
    9397  , mCurrentBvhNode(NULL) 
    94   , mObjects(objects) 
     98  , mPvsObjects(pvsObjects) 
     99  , mPreprocessorObjects(preprocessorObjects) 
    95100  , mBoundingBoxConverter(bconverter) 
    96101  , mHierarchyManager(NULL) 
     
    98103  , nObjects(0) 
    99104{ 
    100         std::stable_sort(mObjects->begin(), mObjects->end(), ilt); 
     105        mCreatePvsObjects = mPvsObjects.empty(); 
     106 
     107        // sort objects so we can search in them 
     108        //if (!is_sorted(mPvsObjects.begin(), mPvsObjects.end(), ilt)) 
     109                sort(mPvsObjects.begin(), mPvsObjects.end(), ilt); 
     110 
     111        //if (!is_sorted(mPreprocessorObjects.begin(), mPreprocessorObjects.end(), ilt)) 
     112                sort(mPreprocessorObjects.begin(), mPreprocessorObjects.end(), ilt); 
    101113} 
    102114 
     
    165177                // the objects with the leaves, they can be classified geometrically 
    166178                mHierarchyManager->mOspTree-> 
    167                         InsertObjects(mHierarchyManager->mOspTree->mRoot, *mObjects); 
     179                        InsertObjects(mHierarchyManager->mOspTree->mRoot, mPvsObjects); 
    168180        } 
    169181} 
     
    278290        // associate object ids with bounding boxes 
    279291        const long startTime = GetTime(); 
    280         Debug<<"here32232"<<endl; 
     292         
    281293        if (mBoundingBoxConverter) 
    282         {Debug<<"here3772"<<endl; 
    283                 mBoundingBoxConverter->IdentifyObjects(mIBoundingBoxes, *mObjects); 
     294        { 
     295                mBoundingBoxConverter->IdentifyObjects(mIBoundingBoxes, mPvsObjects); 
    284296        } 
    285297 
     
    394406 
    395407 
    396 void ViewCellsParseHandlers::ExchangePvs(ViewCell *vc) 
     408void ViewCellsParseHandlers::ReplaceBvhPvs(ViewCell *vc) 
    397409{ 
    398410        //cout << "exchanging pvs" << endl; 
     
    404416 
    405417        ObjectContainer oldIntersectables; 
     418 
    406419        // output PVS of view cell 
    407420        while (pit.HasMoreEntries()) 
     
    454467        for (vit = mViewCells.begin(); vit != vit_end; ++ vit) 
    455468        { 
    456                 ExchangePvs(*vit); 
     469                ReplaceBvhPvs(*vit); 
    457470        } 
    458471} 
     
    486499        { 
    487500                cout << "\nparsing view cells" << endl; 
     501                Debug << "\nparsing view cells" << endl; 
    488502                 
    489503                mCurrentState = PARSE_VIEWCELLS; 
     
    496510        if (element == "ViewSpaceHierarchy") 
    497511        {                
     512                Debug << "\nparsing view space hierarchy" << endl; 
    498513                cout << "\nparsing view space hierarchy" << endl; 
    499514                mCurrentState = PARSE_VIEWSPACE_HIERARCHY; 
     
    505520        { 
    506521                cout << "\nparsing object space hierarchy" << endl; 
     522                Debug << "\nparsing object space hierarchy" << endl; 
     523 
    507524                mCurrentState = PARSE_OBJECTSPACE_HIERARCHY; 
    508525                StartObjectSpaceHierarchy(attributes); 
     
    574591 
    575592                ObjectContainer::iterator oit =  
    576                                                                 lower_bound(mObjects->begin(),  
    577                                                                                         mObjects->end(),  
     593                                                                lower_bound(mPvsObjects.begin(),  
     594                                                                                        mPvsObjects.end(),  
    578595                                                                                        (Intersectable *)&dummyInst, ilt);       
    579596 
    580                 if ((oit != mObjects->end()) && ((*oit)->GetId() == objId)) 
     597                if ((oit != mPvsObjects.end()) && ((*oit)->GetId() == objId)) 
    581598                { 
    582599                        // $$JB we should store a float a per object which corresponds 
     
    669686                                //std::stable_sort(objects.begin(), objects.end(), ilt); 
    670687                                mHierarchyManager->mOspTree->mBoundingBox.Initialize(); 
    671                                 ObjectContainer::const_iterator oit, oit_end = mObjects->end(); 
     688                                ObjectContainer::const_iterator oit, oit_end = mPvsObjects.end(); 
    672689                                 
    673690                                //-- compute bounding box 
    674                                 for (oit = mObjects->begin(); oit != oit_end; ++ oit) 
     691                                for (oit = mPvsObjects.begin(); oit != oit_end; ++ oit) 
    675692                                { 
    676693                                        Intersectable *obj = *oit; 
     
    13241341 
    13251342                ObjectContainer::iterator oit = 
    1326                         lower_bound(mObjects->begin(),  
    1327                                                 mObjects->end(),  
     1343                        lower_bound(mPvsObjects.begin(),  
     1344                                                mPvsObjects.end(),  
    13281345                                                (Intersectable *)&dummyInst,  
    13291346                                                ilt);    
    13301347                                                         
    1331                 if ((oit != mObjects->end()) && ((*oit)->GetId() == objId)) 
     1348                if ((oit != mPvsObjects.end()) && ((*oit)->GetId() == objId)) 
    13321349                { 
    13331350                        objects.push_back(*oit); 
     1351                        Debug << "x"; 
    13341352                } 
    13351353                else 
    13361354                { 
    1337                         cerr << "StartBvhLeafObjects error: object with id " << objId << " does not exist" << endl; 
     1355                        Debug << "y"; 
     1356                        //cerr << "StartBvhLeafObjects error: object with id " << objId << " does not exist" << endl; 
    13381357                } 
    13391358        } 
     
    14121431 
    14131432 
    1414 bool ViewCellsParser::ParseViewCellsFile(const string filename,  
     1433bool ViewCellsParser::ParseViewCellsFile(const string &filename,  
    14151434                                                                                 ViewCellsManager **viewCells, 
    1416                                                                                  ObjectContainer *objects, 
     1435                                                                                 ObjectContainer &pvsObjects, 
     1436                                                                                 ObjectContainer &preprocessorObjects, 
    14171437                                                                                 BoundingBoxConverter *bconverter) 
    14181438{ 
     
    14481468  //  to do. 
    14491469  // 
    1450   ViewCellsParseHandlers handler(objects, bconverter); 
     1470  ViewCellsParseHandlers handler(pvsObjects, preprocessorObjects, bconverter); 
    14511471  parser->setDocumentHandler(&handler); 
    14521472  parser->setErrorHandler(&handler); 
  • GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsParser.h

    r1344 r2113  
    1717  ViewCellsParser():Parser() {} 
    1818   
    19   bool ParseViewCellsFile( 
    20           const string filename,  
    21           ViewCellsManager **viewCells, 
    22           ObjectContainer *objects, 
    23           BoundingBoxConverter *bconverter); 
     19  bool ParseViewCellsFile(const string &filename,  
     20                                                  ViewCellsManager **viewCells, 
     21                                                  ObjectContainer &pvsObjects, 
     22                                                  ObjectContainer &preprocessorObjects, 
     23                                                  BoundingBoxConverter *bconverter); 
    2424}; 
    2525 
  • GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsParserXerces.h

    r2093 r2113  
    3535  //  Constructors and Destructor 
    3636  // ----------------------------------------------------------------------- 
    37   ViewCellsParseHandlers(ObjectContainer *objects, BoundingBoxConverter *bconverter); 
     37  ViewCellsParseHandlers(ObjectContainer &pvsObjects,  
     38                                                 ObjectContainer &preprocessorObjects,  
     39                                                 BoundingBoxConverter *bconverter); 
    3840  ~ViewCellsParseHandlers(); 
    3941   
     
    7476  void CreateViewCellsManager(/*const char *name*/); 
    7577 
    76   void ExchangeElements(); 
    77   void ExchangePvs(ViewCell *vc); 
     78  void ReplacePvs(); 
     79  void ReplaceBvhPvs(ViewCell *vc); 
    7880 
    7981 
     
    9799  VspNode *mVspRoot; 
    98100  ViewCell *mViewCellRoot; 
    99 int mUniqueObjectId; 
     101   
     102  int mUniqueObjectId; 
    100103  vector<BvhLeaf *> mBvhLeaves; 
    101104  //typedef map<int, ViewCell *> ViewCellsMap; 
     
    104107 
    105108  ViewCellsManager *mViewCellsManager; 
    106   ObjectContainer *mObjects; 
     109 
     110  ObjectContainer &mPvsObjects; 
     111  ObjectContainer &mPreprocessorObjects; 
     112 
     113  bool mCreatePvsObjects; 
     114 
    107115  BoundingBoxConverter *mBoundingBoxConverter; 
    108116  AxisAlignedBox3 mViewSpaceBox; 
Note: See TracChangeset for help on using the changeset viewer.