Changeset 931


Ignore:
Timestamp:
05/08/06 18:57:11 (18 years ago)
Author:
mattausch
Message:

added bounding boxes to xml description

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

Legend:

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

    r925 r931  
    9696        void renderModulativeStencilShadowedQueueGroupObjects(RenderQueueGroup* pGroup, 
    9797                QueuedRenderableCollection::OrganisationMode om); 
    98         void loadVisibilityConfig(const String& filename); 
     98         
    9999        /** Override standard function so octree boxes are always of equal side length. 
    100100                This has advantages for CHC, because terrain tiles are in different octree nodes 
     
    124124        */ 
    125125        void InitVisibilityCulling(Camera *cam); 
    126  
     126#if 0 
    127127        /** Finds object corresponding to this bounding box in the scene. 
    128128        */ 
     
    133133        */ 
    134134        void IdentifyObjects(GtpVisibilityPreprocessor::ObjectContainer &objects); 
    135  
     135#endif 
    136136        /** Loads / unloads pvs of the view cell to set the visibility in the scene. 
    137137        */ 
  • GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/scripts/Plugin_VisibilitySceneManager.vcproj

    r925 r931  
    180180                                Filter="h;hpp;hxx;hm;inl;inc"> 
    181181                                <File 
     182                                        RelativePath="..\include\OgreBoundingBoxConverter.h"> 
     183                                </File> 
     184                                <File 
    182185                                        RelativePath="..\include\OgreMeshInstance.h"> 
    183186                                </File> 
     
    216219                                Name="Source Files" 
    217220                                Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm"> 
     221                                <File 
     222                                        RelativePath="..\src\OgreBoundingBoxConverter.cpp"> 
     223                                </File> 
    218224                                <File 
    219225                                        RelativePath="..\src\OgreMeshInstance.cpp"> 
  • GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/src/OgreOcclusionCullingSceneManager.cpp

    r925 r931  
    1919#include "OgreMeshInstance.h" 
    2020#include "common.h" 
     21#include "OgreBoundingBoxConverter.h" 
    2122 
    2223// normal terrain rendering 
     
    998999   else 
    9991000   { 
    1000            SceneManager::renderModulativeStencilShadowedQueueGroupObjects(pGroup, om); 
     1001           OctreeSceneManager::renderModulativeStencilShadowedQueueGroupObjects(pGroup, om); 
    10011002   } 
    10021003} 
     
    10131014        } 
    10141015} 
    1015 //------------------------------------------------------------------------- 
    1016 void OcclusionCullingSceneManager::loadVisibilityConfig(const String& filename) 
    1017 { 
    1018         // TODO matt 
    1019         // Set up the options 
    1020         ConfigFile config; 
    1021         String val; 
    1022  
    1023         config.load(filename); 
    1024  
    1025         val = config.getSetting("Algorithm"); 
    1026  
    1027     if (!val.empty()) 
    1028         { 
    1029                  VisibilityOptionsManager(mVisibilityManager, mHierarchyInterface).setOption("Algorithm", val.c_str()); 
    1030         } 
    1031  
    1032         val = config.getSetting("UseDepthPass"); 
    1033  
    1034         if (!val.empty()) 
    1035         { 
    1036                  setOption("UseDepthPass", val.c_str()); 
    1037         } 
    1038 } 
    1039 //------------------------------------------------------------------------- 
    1040 inline static AxisAlignedBox EnlargeBox(const AxisAlignedBox &box) 
    1041 { 
    1042         const float eps = 1e-3f; 
    1043         const Vector3 veps(eps, eps, eps); 
    1044         Vector3 max = box.getMaximum(); 
    1045         Vector3 min = box.getMinimum(); 
    1046  
    1047         return AxisAlignedBox(min - veps, max + veps); 
    1048 } 
    1049 //----------------------------------------------------------------------- 
    1050 Entity *OcclusionCullingSceneManager::FindCorrespondingObject(const AxisAlignedBox &box) 
    1051 { 
    1052         list<SceneNode *> sceneNodeList; 
    1053         AxisAlignedBox mybox = EnlargeBox(box); 
    1054         //AxisAlignedBox dummy(Vector3(-50000, -50000, -50000), Vector3(50000, 50000, 50000)); 
    1055          
    1056         // get intersecting scene nodes 
    1057         findNodesIn(mybox, sceneNodeList, NULL); 
    1058          
    1059  
    1060         list<SceneNode *>::const_iterator sit, sit_end = sceneNodeList.end(); 
    1061  
    1062         float overlap = 0;//GtpVisibilityPreprocessor::Limits::Small; 
    1063  
    1064         Entity *bestFittingObj = NULL; 
    1065         float bestFit = overlap; 
    1066  
    1067         // perfect fit threshold 
    1068         const float thresh = 1.0 - GtpVisibilityPreprocessor::Limits::Small; 
    1069  
    1070  
    1071         // find the bbox which is closest to the current bbox 
    1072         for (sit = sceneNodeList.begin(); sit != sceneNodeList.end(); ++ sit) 
    1073         { 
    1074                 SceneNode *sn = *sit; 
    1075                 SceneNode::ObjectIterator oit = sn->getAttachedObjectIterator(); 
    1076  
    1077         while (oit.hasMoreElements()) 
    1078                 { 
    1079                         MovableObject *mo = oit.getNext(); 
    1080  
    1081                         // we are only interested in scene entities 
    1082                         if (mo->getMovableType() != "Entity") 
    1083                         { 
    1084                                 continue; 
    1085                         } 
    1086                           
    1087                         const AxisAlignedBox bbox = EnlargeBox(mo->getWorldBoundingBox()); 
    1088                                          
    1089  
    1090                         // compute measure how much aabbs overlap 
    1091                         overlap = RatioOfOverlap(OgreTypeConverter::ConvertFromOgre(mybox), 
    1092                                                                          OgreTypeConverter::ConvertFromOgre(bbox)); 
    1093          
    1094                          if (overlap > bestFit) 
    1095                          { 
    1096                                  bestFit = overlap; 
    1097                          
    1098                                  bestFittingObj = static_cast<Entity *>(mo); 
    1099  
    1100                                  // perfect fit => object found, eraly exit 
    1101                                  if (overlap >= thresh) 
    1102                                          return bestFittingObj;                          
    1103                          } 
    1104                 } 
    1105         } 
    1106  
    1107         if (0) 
    1108         { 
    1109                 std::stringstream d;  
    1110                 if (bestFittingObj) 
    1111                         d << "best fit: " << bestFit;      
    1112                 else 
    1113                         d << "warning, objects do not fit\n" << box; 
    1114          
    1115                 Ogre::LogManager::getSingleton().logMessage(d.str()); 
    1116         } 
    1117  
    1118         return bestFittingObj; 
    1119 } 
    11201016//----------------------------------------------------------------------- 
    11211017void OcclusionCullingSceneManager::LoadViewCells(string filename) 
     
    11241020        SetObjectsVisible(false); 
    11251021 
    1126         // identify the corresponding Ogre meshes using the bounding boxes 
    1127         IdentifyObjects(mObjects); 
     1022        const string bboxesFilename = mVisibilityManager->GetVisibilityEnvironment()->getViewCellsFileName(); 
     1023 
     1024        GtpVisibilityPreprocessor::IndexedBoundingBoxContainer iboxes; 
     1025        OgreBoundingBoxConverter bconverter(this); 
    11281026 
    11291027        // load the view cells assigning the found objects to the pvss 
    11301028        mViewCellsManager =  
    1131                 GtpVisibilityPreprocessor::ViewCellsManager::LoadViewCells(filename, &mObjects); 
     1029                GtpVisibilityPreprocessor::ViewCellsManager::LoadViewCells(filename, &mObjects, &bconverter); 
    11321030 
    11331031        std::stringstream d; 
    11341032        d << "view cells loaded" << endl; 
    11351033        Ogre::LogManager::getSingleton().logMessage(d.str()); 
    1136 } 
    1137 //----------------------------------------------------------------------- 
    1138 void OcclusionCullingSceneManager::IdentifyObjects(GtpVisibilityPreprocessor::ObjectContainer &objects) 
    1139 { 
    1140         const string bboxesFilename = "boxes.out"; 
    1141  
    1142         GtpVisibilityPreprocessor::IndexedBoundingBoxContainer iboxes; 
    1143         mViewCellsManager->LoadBoundingBoxes(bboxesFilename, iboxes); 
    1144  
    1145         GtpVisibilityPreprocessor::IndexedBoundingBoxContainer:: 
    1146                 const_iterator iit, iit_end = iboxes.end(); 
    1147  
    1148         for (iit = iboxes.begin(); iit != iit_end; ++ iit) 
    1149         { 
    1150                   const GtpVisibilityPreprocessor::AxisAlignedBox3 box = (*iit).second; 
    1151                   const AxisAlignedBox currentBox = OgreTypeConverter::ConvertToOgre(box); 
    1152                   
    1153                   Entity *ent = FindCorrespondingObject(currentBox); 
    1154  
    1155                   // create new mesh instance 
    1156                   OgreMeshInstance *omi = new OgreMeshInstance(ent); 
    1157                   omi->SetId((*iit).first); 
    1158                   objects.push_back(omi); 
    1159         } 
    11601034} 
    11611035//------------------------------------------------------------------------- 
  • GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/src/OgreOcclusionQueriesQueryManager.cpp

    r925 r931  
    2020//----------------------------------------------------------------------- 
    2121void OcclusionQueriesQueryManager::ComputeCameraVisibility(const Camera &camera, 
    22                             GtpVisibility::NodeInfoContainer *visibleNodes, 
    23                             GtpVisibility::MeshInfoContainer *visibleGeometry, 
    24                                 GtpVisibility::PatchInfoContainer *visiblePatches, 
    25                             bool relativeVisibility) 
     22                                                                                                                   GtpVisibility::NodeInfoContainer *visibleNodes, 
     23                                                                                                                   GtpVisibility::MeshInfoContainer *visibleGeometry, 
     24                                                                                                                   GtpVisibility::PatchInfoContainer *visiblePatches, 
     25                                                                                                                   bool relativeVisibility) 
    2626{ 
    2727        // we need access to the scene manager and the rendersystem 
  • GTP/trunk/Lib/Vis/Preprocessing/scripts/Preprocessor.vcproj

    r879 r931  
    123123                        </File> 
    124124                        <File 
     125                                RelativePath="..\src\BoundingBoxConverter.h"> 
     126                        </File> 
     127                        <File 
    125128                                RelativePath="..\src\Camera.cpp"> 
    126129                        </File> 
  • GTP/trunk/Lib/Vis/Preprocessing/src/GlRenderer.cpp

    r904 r931  
    930930        RenderIntersectable(*oi); 
    931931 
    932   ViewCell *viewcell; 
     932  ViewCell *viewcell = NULL; 
    933933 
    934934  QImage im1, im2; 
  • GTP/trunk/Lib/Vis/Preprocessing/src/Preprocessor.cpp

    r925 r931  
    265265{ 
    266266   
    267   mViewCellsManager->ExportViewCells(filename, 
    268                                                                          true); 
     267  mViewCellsManager->ExportViewCells(filename, true, mObjects); 
    269268   
    270269  return true; 
  • GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp

    r904 r931  
    1515#include "VssPreprocessor.h" 
    1616#include "RssPreprocessor.h" 
     17#include "BoundingBoxConverter.h" 
     18 
    1719 
    1820namespace GtpVisibilityPreprocessor { 
     
    18581860 
    18591861 
    1860 bool ViewCellsManager::ExportViewCells(const string filename, const bool exportPvs) 
     1862bool ViewCellsManager::ExportViewCells(const string filename, const bool exportPvs, const ObjectContainer &objects) 
    18611863{ 
    18621864        return false; 
     
    19561958                                                                                 IndexedBoundingBoxContainer &boxes) const 
    19571959{ 
    1958         // HACK: needed only for lower_bound algorithm to find the  
    1959         // intersected objects 
    1960  
    19611960        Vector3 bmin, bmax; 
    19621961        int id; 
     
    20212020} 
    20222021 
     2022 
     2023float ViewCellsManager::GetFilterWidth()  
     2024{ 
     2025        return mFilterWidth; 
     2026} 
     2027 
     2028 
     2029float ViewCellsManager::GetAbsFilterWidth()  
     2030{ 
     2031        return Magnitude(mViewSpaceBox.Size()) * mFilterWidth; 
     2032} 
     2033 
     2034 
     2035bool ViewCellsManager::ExportBoundingBoxes(ofstream &xmlstream,  
     2036                                                                                   const ObjectContainer &objects) const 
     2037{ 
     2038        //-- export the view cells and the pvs 
     2039        xmlstream << "<BoundingBoxes>" << endl; 
     2040 
     2041        ObjectContainer::const_iterator oit, oit_end = objects.end(); 
     2042 
     2043        for (oit = objects.begin(); oit != oit_end; ++ oit) 
     2044        { 
     2045                        MeshInstance *mi = dynamic_cast<MeshInstance *>(*oit); 
     2046                        const AxisAlignedBox3 box = mi->GetBox(); 
     2047 
     2048                        //-- the bounding boxes 
     2049                        xmlstream << "<BoundingBox" << " id=\"" << mi->GetId() << "\"" 
     2050                                      << " min=\"" << box.Min().x << " " << box.Min().y << " " << box.Min().z << "\"" 
     2051                                          << " max=\"" << box.Max().x << " " << box.Max().y << " " << box.Max().z << "\" />" << endl; 
     2052        } 
     2053 
     2054        xmlstream << "</BoundingBoxes>" << endl; 
     2055 
     2056        return true; 
     2057} 
     2058 
     2059 
    20232060/**********************************************************************/ 
    2024 /*                   BspViewCellsManager implementation               */ 
     2061/*                 BspViewCellsManager implementation                 */ 
    20252062/**********************************************************************/ 
    20262063 
     
    22822319                char filename[100]; 
    22832320                environment->GetStringValue("ViewCells.filename", filename); 
    2284                 ExportViewCells(filename, mExportPvs); 
     2321                ExportViewCells(filename, mExportPvs, objects); 
    22852322        } 
    22862323         
    22872324        // export bounding boxes 
    2288         if (mExportBboxesForPvs) 
     2325        if (0 && mExportBboxesForPvs) 
    22892326        { 
    22902327                char filename[100]; 
     
    27292766 
    27302767 
    2731 bool BspViewCellsManager::ExportViewCells(const string filename, const bool exportPvs) 
     2768bool BspViewCellsManager::ExportViewCells(const string filename, const bool exportPvs, const ObjectContainer &objects) 
    27322769{ 
    27332770        cout << "exporting view cells to xml ... "; 
     
    39744011                char filename[100]; 
    39754012                environment->GetStringValue("ViewCells.filename", filename); 
    3976                 ExportViewCells(filename, mExportPvs); 
     4013                ExportViewCells(filename, mExportPvs, objects); 
    39774014        } 
    39784015 
     
    46874724 
    46884725ViewCellsManager *ViewCellsManager::LoadViewCells(const string filename,  
    4689                                                                                                   ObjectContainer *objects) 
     4726                                                                                                  ObjectContainer *objects, 
     4727                                                                                                  BoundingBoxConverter *bconverter) 
    46904728{ 
    46914729        ViewCellsParser parser; 
     
    46954733        Debug << "vc filename: " << filename << endl; 
    46964734 
    4697         if (parser.ParseFile(filename, &vm, objects)) 
     4735        //BoundingBoxConverter bconverter; 
     4736 
     4737        if (parser.ParseFile(filename, &vm, objects, bconverter)) 
    46984738        { 
    46994739                //vm->PrepareLoadedViewCells(); 
     
    47194759 
    47204760 
    4721  
    4722 bool VspBspViewCellsManager::ExportViewCells(const string filename, const bool exportPvs) 
     4761bool VspBspViewCellsManager::ExportViewCells(const string filename,  
     4762                                                                                         const bool exportPvs,  
     4763                                                                                         const ObjectContainer &objects) 
    47234764{ 
    47244765        cout << "exporting view cells to xml ... "; 
     
    47374778                   << " max=\"" << mViewSpaceBox.Max().x << " " << mViewSpaceBox.Max().y << " " << mViewSpaceBox.Max().z << "\" />" << endl; 
    47384779 
    4739  
     4780        ExportBoundingBoxes(stream, objects); 
    47404781 
    47414782        //-- the type of the view cells hierarchy 
     
    47504791 
    47514792 
    4752         //-- export the hierarchy 
     4793        //-- export the spatial hierarchy 
    47534794        stream << "<Hierarchy>" << endl; 
    47544795        mVspBspTree->Export(stream); 
  • GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.h

    r904 r931  
    3232class ViewCellsTree; 
    3333class MergeCandidate; 
     34class BoundingBoxConverter; 
     35 
    3436 
    3537struct BspRay; 
     
    5052}; 
    5153 
    52  
    53 struct IndexedBoundingBox: public std::pair<int, AxisAlignedBox3> 
    54 { 
    55         typedef std::pair<int, AxisAlignedBox3> IndexedBoundingBoxParent; 
    56  
    57         IndexedBoundingBox(int idx, const AxisAlignedBox3 &box): IndexedBoundingBoxParent(idx, box) 
    58         { 
    59  
    60         } 
    61 }; 
    6254 
    6355/**     Manages different higher order operations on the view cells. 
     
    7769        enum {BSP, KD, VSP_KD, VSP_BSP}; 
    7870   
    79         /// view cells evaluation type 
     71        /// render cost evaluation type 
    8072        enum {PER_OBJECT, PER_TRIANGLE}; 
    8173 
     
    308300        /** Writes view cells to disc. 
    309301        */ 
    310         virtual bool ExportViewCells(const string filename, const bool exportPvs); 
     302        virtual bool ExportViewCells(const string filename, const bool exportPvs, const ObjectContainer &objects); 
    311303 
    312304        /** Casts beam to collect view cells. 
     
    418410        float EvalRenderCost(Intersectable *obj) const; 
    419411 
    420     void 
    421         ApplyFilter(KdTree *kdTree, 
    422                                 const float viewSpaceFilterSize, 
    423                                 const float spatialFilterSize 
    424                                 ); 
    425  
    426   void 
    427   ApplySpatialFilter( 
    428                                          KdTree *kdTree, 
    429                                          const float spatialFilterSize, 
    430                                          ObjectPvs &pvs 
    431                                          ); 
     412    
    432413         
    433414        /** Returns bounding box of a view cell. 
     
    438419        */ 
    439420        bool ExportBoundingBoxes(const string filename, const ObjectContainer &objects) const; 
    440  
     421     
    441422        /** Load the bounding boxes into the container. 
    442423        */ 
    443424        bool LoadBoundingBoxes(const string filename, IndexedBoundingBoxContainer &boxes) const; 
    444425 
    445   bool GetExportPvs() const { 
    446         return mExportPvs; 
    447   } 
     426        bool GetExportPvs() const  
     427        { 
     428                return mExportPvs; 
     429        } 
    448430 
    449431        /** Loads view cells from file. The view cells manager is created with  
     
    452434                @returns the view cells manager if loading was successful, false otherwise 
    453435        */ 
    454         static ViewCellsManager *LoadViewCells(const string filename, ObjectContainer *objects); 
    455  
    456   float GetFilterWidth() { 
    457         return mFilterWidth; 
    458   } 
    459  
    460   float GetAbsFilterWidth() { 
    461         return Magnitude(mViewSpaceBox.Size())*mFilterWidth; 
    462   } 
     436        static ViewCellsManager *LoadViewCells(const string filename,  
     437                                                                                   ObjectContainer *objects,  
     438                                                                                   BoundingBoxConverter *bconverter = NULL); 
     439 
     440 
     441        ////////////////////////////////////////////////////////7 
     442        // visiblity filter options 
     443        // TODO: write own visibiltiy filter class 
     444        void ApplyFilter(KdTree *kdTree, 
     445                                         const float viewSpaceFilterSize, 
     446                                         const float spatialFilterSize); 
     447 
     448        void ApplySpatialFilter(KdTree *kdTree, 
     449                                                        const float spatialFilterSize, 
     450                                                        ObjectPvs &pvs); 
     451 
     452         void ApplyFilter(ViewCell *viewCell, 
     453                                          KdTree *kdTree, 
     454                                          const float viewSpaceFilterSize, 
     455                                          const float spatialFilterSize, 
     456                                          ObjectPvs &pvs); 
     457 
     458        float GetFilterWidth(); 
     459 
     460        float GetAbsFilterWidth(); 
     461 
     462         
     463        /** Returns the bounding box of filter width. 
     464        */ 
     465        AxisAlignedBox3 GetFilterBBox(const Vector3 &viewPoint, const float width) const; 
    463466 
    464467protected: 
    465     void 
    466         ApplyFilter(ViewCell *viewCell, 
    467                                 KdTree *kdTree, 
    468                                 const float viewSpaceFilterSize, 
    469                                 const float spatialFilterSize, 
    470                                 ObjectPvs &pvs 
    471                                 ); 
    472  
    473    
    474         /** Returns the bounding box of filter width. 
    475         */ 
    476         AxisAlignedBox3 GetFilterBBox(const Vector3 &viewPoint, const float width) const; 
     468        /** Exports bounding boxes as xml stream 
     469        */ 
     470        bool ExportBoundingBoxes(ofstream &xmlstream, const ObjectContainer &objects) const; 
    477471 
    478472        /** Intersects box with the tree and returns the number of intersected boxes. 
     
    486480        virtual void TestFilter(const ObjectContainer &objects) {}; 
    487481 
    488         /** 
    489                 if the view cells tree was already constructed or not. 
     482        /** If the view cells tree was already constructed or not. 
    490483        */ 
    491484        bool ViewCellsTreeConstructed() const; 
     
    495488                                                VssRayContainer &vssRays) const; 
    496489 
     490        /** Parse the options from the environment file. 
     491        */ 
    497492        void ParseEnvironment(); 
    498493 
     
    700695        void Finalize(ViewCell *viewCell, const bool createMesh); 
    701696 
    702         bool ExportViewCells(const string filename, const bool exportPvs); 
     697        bool ExportViewCells(const string filename, const bool exportPvs, const ObjectContainer &objects); 
    703698 
    704699        /** Constructs merge hierarchy which corresponds to the spatial hierarchy. 
     
    908903        void CreateMesh(ViewCell *vc); 
    909904 
    910         bool ExportViewCells(const string filename, const bool exportPvs); 
     905        bool ExportViewCells(const string filename, const bool exportPvs, const ObjectContainer &objects); 
    911906 
    912907        int CastBeam(Beam &beam); 
  • GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsParser.cpp

    r881 r931  
    6565//  StdInParseHandlers: Constructors and Destructor 
    6666// --------------------------------------------------------------------------- 
    67 ViewCellsParseHandlers::ViewCellsParseHandlers(ObjectContainer *objects): 
     67ViewCellsParseHandlers::ViewCellsParseHandlers(ObjectContainer *objects, BoundingBoxConverter *bconverter): 
    6868  mElementCount(0) 
    6969  , mAttrCount(0) 
     
    7777  , mCurrentViewCell(NULL) 
    7878  , mCurrentBspNode(NULL) 
    79 { 
    80         mObjects = objects; 
     79  , mObjects(objects) 
     80  , mBoundingBoxConverter(bconverter) 
     81{ 
     82        // mObjects = objects; 
    8183} 
    8284 
     
    132134} 
    133135 
     136 
    134137inline static bool vlt(ViewCell *v1, ViewCell *v2) 
    135138{ 
     
    144147} 
    145148 
     149 
     150void ViewCellsParseHandlers::EndBoundingBoxes() 
     151{ 
     152        // bounding boxes gathered: associate object ids with bounding boxes 
     153        if (mBoundingBoxConverter) 
     154                mBoundingBoxConverter->IdentifyObjects(mIBoundingBoxes, *mObjects); 
     155} 
    146156 
    147157 
     
    208218        if (element == "ViewSpaceBox") 
    209219        { 
     220                Debug << "v"; 
     221                StartViewSpaceBox(attributes); 
     222        } 
     223 
     224        // decides the used view cell hierarchy 
     225        if (element == "BoundingBox") 
     226        { 
    210227                Debug << "b"; 
    211                 StartViewSpaceBox(attributes); 
    212         } 
    213  
     228                StartBoundingBox(attributes); 
     229        } 
    214230 
    215231        // use different methods for the given view cell hierarchy types 
     
    379395 
    380396 
     397void ViewCellsParseHandlers::StartBoundingBox(AttributeList& attributes) 
     398{ 
     399        int len = attributes.getLength(); 
     400 
     401        Vector3 bmin, bmax; 
     402        int id; 
     403 
     404        for (int i = 0; i < len; ++ i)  
     405        { 
     406                string attrName(StrX(attributes.getName(i)).LocalForm()); 
     407                StrX attrValue(attributes.getValue(i)); 
     408                const char *ptr = attrValue.LocalForm(); 
     409 
     410 
     411                if (attrName == "id") 
     412                { 
     413                        sscanf(ptr, "%d", &id); 
     414                } 
     415 
     416                if (attrName == "min")  
     417                { 
     418                        sscanf(ptr, "%f %f %f", 
     419                                   &bmin.x, &bmin.y, &bmin.z); 
     420                } 
     421                else if (attrName == "max")  
     422                { 
     423                        sscanf(ptr, "%f %f %f", 
     424                                   &bmax.x, &bmax.y, &bmax.z); 
     425                } 
     426        } 
     427 
     428        AxisAlignedBox3 box(bmin, bmax); 
     429        mIBoundingBoxes.push_back(IndexedBoundingBox(id, box)); 
     430 
     431        Debug << "view space box: " << mViewSpaceBox << endl; 
     432} 
     433 
     434 
    381435void ViewCellsParseHandlers::StartBspLeaf(AttributeList& attributes) 
    382436{ 
     
    637691bool ViewCellsParser::ParseFile(const string filename,  
    638692                                                                ViewCellsManager **viewCells, 
    639                                                                 ObjectContainer *objects) 
     693                                                                ObjectContainer *objects, 
     694                                                                BoundingBoxConverter *bconverter) 
    640695{ 
    641696  // Initialize the XML4C system 
     
    669724  //  to do. 
    670725  // 
    671   ViewCellsParseHandlers handler(objects); 
     726  ViewCellsParseHandlers handler(objects, bconverter); 
    672727  parser->setDocumentHandler(&handler); 
    673728  parser->setErrorHandler(&handler); 
     
    724779  XMLPlatformUtils::Terminate(); 
    725780   
    726    // assign new view cells manager 
     781  //-- assign new view cells manager 
    727782  *viewCells = handler.mViewCellsManager; 
    728783   
  • GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsParser.h

    r860 r931  
    99class ViewCellsManager; 
    1010class VspBspTree; 
     11class BoundingBoxConverter; 
    1112 
    1213class ViewCellsParser : public Parser 
     
    1819  bool ParseFile(const string filename,  
    1920                                 ViewCellsManager **viewCells, 
    20                                  ObjectContainer *objects); 
     21                                 ObjectContainer *objectsm, 
     22                                 BoundingBoxConverter *bconverter); 
    2123}; 
    2224 
  • GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsParserXerces.h

    r860 r931  
    77#include <xercesc/sax/HandlerBase.hpp> 
    88#include "Mesh.h" 
     9#include "BoundingBoxConverter.h" 
    910 
    1011namespace GtpVisibilityPreprocessor { 
     
    2728  //  Constructors and Destructor 
    2829  // ----------------------------------------------------------------------- 
    29   ViewCellsParseHandlers(ObjectContainer *objects); 
     30  ViewCellsParseHandlers(ObjectContainer *objects, BoundingBoxConverter *bconverter); 
    3031  ~ViewCellsParseHandlers(); 
    3132   
     
    7879  ViewCellsManager *mViewCellsManager; 
    7980  ObjectContainer *mObjects; 
     81  BoundingBoxConverter *mBoundingBoxConverter; 
    8082 
    8183  AxisAlignedBox3 mViewSpaceBox; 
     84 
     85  IndexedBoundingBoxContainer mIBoundingBoxes; 
    8286 
    8387  bool mParseViewCells; 
     
    9094  void StartViewCell(ViewCell *viewCell, AttributeList&  attributes); 
    9195  void EndViewCells(); 
     96  void EndBoundingBoxes(); 
    9297         
    9398  void StartHierarchy(AttributeList& attributes); 
     
    96101  void StartViewSpaceBox(AttributeList&  attributes); 
    97102 
     103  void StartBoundingBox(AttributeList& attributes); 
    98104  void StartViewCellLeaf(AttributeList& attributes); 
    99105  void StartViewCellInterior(AttributeList& attributes); 
  • GTP/trunk/Lib/Vis/Preprocessing/src/VssPreprocessor.cpp

    r871 r931  
    627627          VssRayContainer dummies; 
    628628          mViewCellsManager->Visualize(mObjects, dummies); 
    629           mViewCellsManager->ExportViewCells("test.xml", mViewCellsManager->GetExportPvs()); 
     629          mViewCellsManager->ExportViewCells("test.xml", mViewCellsManager->GetExportPvs(), mObjects); 
    630630  } 
    631631 
Note: See TracChangeset for help on using the changeset viewer.