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

added bounding boxes to xml description

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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   
Note: See TracChangeset for help on using the changeset viewer.