Changeset 361


Ignore:
Timestamp:
10/30/05 15:08:39 (19 years ago)
Author:
mattausch
Message:

implemented finding neighbor routine

Location:
trunk/VUT
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/VUT/GtpVisibilityPreprocessor/scripts/Preprocessor.vcproj

    r338 r361  
    153153                        </File> 
    154154                        <File 
     155                                RelativePath="..\src\Halton.cpp"> 
     156                        </File> 
     157                        <File 
     158                                RelativePath="..\src\Halton.h"> 
     159                        </File> 
     160                        <File 
    155161                                RelativePath="..\src\Intersectable.h"> 
    156162                        </File> 
  • trunk/VUT/GtpVisibilityPreprocessor/scripts/default.env

    r352 r361  
    5656 
    5757Sampling { 
    58         totalSamples    200000 
     58        totalSamples    20000 
    5959        samplesPerPass  2 
    6060} 
     
    6969         
    7070#       filename ../data/atlanta/atlanta_viewcells_large.x3d 
    71 #       filename ../data/vienna/viewcells-25-sel.x3d 
    72         filename ../data/vienna/viewcells-25.x3d 
     71        filename ../data/vienna/viewcells-25-sel.x3d 
     72#       filename ../data/vienna/viewcells-25.x3d 
    7373#       filename ../data/vienna/viewcells-large-sel.x3d 
    7474} 
     
    7777        Construction { 
    7878        #       input fromRays 
    79         #       input fromViewCells 
    80                 input fromSceneGeometry 
    81                 samples 150000 
     79                input fromViewCells 
     80        #       input fromSceneGeometry 
     81                samples 15000 
    8282                sideTolerance 0.005 
    8383        } 
     
    123123                # autopartition 
    124124                maxRays -1 
    125                 maxPolygons 250 
     125                maxPolygons 0 
    126126                maxDepth 100 
    127127                 
  • trunk/VUT/GtpVisibilityPreprocessor/src/Polygon3.cpp

    r360 r361  
    383383        bool onBackSide = false; 
    384384         
    385         int count = 0; 
    386  
    387         // find possible line-plane intersections 
     385        // find intersections 
    388386        for (it = polys.begin(); it != polys.end(); ++ it) 
    389387        { 
    390         int cf = (*it)->ClassifyPlane(plane); 
     388        const int cf = (*it)->ClassifyPlane(plane); 
    391389                 
    392390        if (cf == FRONT_SIDE) 
     
    395393                        onBackSide = true; 
    396394                 
    397                 //TODO: check if split goes through vertex 
    398                 if ((cf == SPLIT) || (onFrontSide && onBackSide)) // split  
    399                 { 
     395                if ((cf == SPLIT) || (cf == COINCIDENT) || (onFrontSide && onBackSide)) 
     396                { 
     397                        Debug << "here" << endl; 
    400398                        return SPLIT; 
    401399                } 
     
    411409        } 
    412410         
    413         return COINCIDENT; // plane and polygon are coincident 
    414 } 
     411        return SPLIT; 
     412} 
  • trunk/VUT/GtpVisibilityPreprocessor/src/SamplingPreprocessor.cpp

    r360 r361  
    620620          Exporter *exporter = Exporter::GetExporter("viewCells.x3d"); 
    621621 
    622           if (exporter) 
     622          // export leaves 
     623          if (0 && exporter) 
    623624          { 
    624           //exporter->ExportLeavesGeometry(mBspTree, leaves);            
    625  
    626                   delete exporter; 
     625                  vector<BspLeaf *> leaves; 
     626                  mBspTree->CollectLeaves(leaves); 
     627                  vector<BspLeaf *> randLeaves; 
     628                  vector<BspLeaf *> neighbors; 
     629 
     630                  for (int k = 0; k < 1; ++ k)  
     631                  { 
     632                          BspLeaf *leaf = leaves[Random((int)leaves.size())]; 
     633                          randLeaves.push_back(leaf); 
     634                          mBspTree->FindNeighbors(leaf, neighbors, false); 
     635                  }      
     636 
     637                  exporter->ExportLeavesGeometry(*mBspTree, randLeaves); 
     638                  exporter->SetWireframe(); 
     639          exporter->ExportLeavesGeometry(*mBspTree, neighbors);  
     640                         
     641          delete exporter; 
    627642          } 
     643 
     644           vector<BspLeaf *> leaves; 
     645           mBspTree->CollectLeaves(leaves); 
     646            
     647           for (int k = 0; k < 100; ++ k)  
     648           { 
     649                   vector<BspLeaf *> randLeaves; 
     650                   vector<BspLeaf *> neighbors; 
     651                    
     652                   char s[64]; sprintf(s, "bsp-vc%04d.x3d", k); 
     653                   Exporter *exporter = Exporter::GetExporter(s); 
     654 
     655                   BspLeaf *leaf = leaves[Random((int)leaves.size())]; 
     656                   Debug << "\noutput leaf " << k << endl; 
     657                   randLeaves.push_back(leaf); 
     658                   mBspTree->FindNeighbors(leaf, neighbors, false); 
     659 
     660                   exporter->ExportLeavesGeometry(*mBspTree, randLeaves); 
     661                   exporter->SetWireframe(); 
     662                   exporter->ExportLeavesGeometry(*mBspTree, neighbors);         
     663                         
     664                   delete exporter; 
     665           }     
    628666 
    629667          for (int j = 0; j < pvsViewCells.size(); ++ j) 
  • trunk/VUT/GtpVisibilityPreprocessor/src/ViewCellBsp.cpp

    r360 r361  
    16861686} 
    16871687 
    1688 void BspTree::ExtractSplitPlanes(BspNode *n, vector<Plane3 *> planes, vector<bool> sides) const 
    1689 { 
    1690         while (!n->IsRoot()) 
    1691         { 
    1692                 if (!n->IsLeaf()) 
    1693                         planes.push_back(dynamic_cast<BspInterior *>(n)->GetPlane()); 
    1694  
    1695                 sides.push_back(n->GetParent()->mFront == n); 
    1696  
     1688void BspTree::ExtractSplitPlanes(BspNode *n, vector<Plane3 *> &planes, vector<bool> &sides) const 
     1689{ 
     1690        BspNode *lastNode; 
     1691        do 
     1692        { 
     1693                lastNode = n; 
    16971694                n = n->GetParent(); 
    1698         } 
     1695                 
     1696                if (n) 
     1697                { 
     1698                        BspInterior *interior = dynamic_cast<BspInterior *>(n); 
     1699 
     1700                        planes.push_back(dynamic_cast<BspInterior *>(interior)->GetPlane()); 
     1701                        sides.push_back(interior->mFront == lastNode); 
     1702                } 
     1703        } 
     1704        while (n); 
    16991705} 
    17001706 
     
    17631769                                                DEL_PTR(frontPoly); 
    17641770                                        } 
     1771                                        inside = true; 
    17651772                                        break; 
    17661773 
    17671774                                case Polygon3::BACK_SIDE: 
    1768                                         if (sides[i])  
     1775                                        if (sides[j])  
    17691776                                                inside = false; 
    17701777                                        break; 
    17711778                                case Polygon3::FRONT_SIDE: 
    1772                                         if (!sides[i]) 
     1779                                        if (!sides[j]) 
    17731780                                                inside = false; 
    17741781                                        break; 
     
    17851792} 
    17861793 
    1787 int BspTree::FindNeighbors(BspNode *n, vector<BspNode *> &neighbors, bool onlyUnmailed) 
     1794int BspTree::FindNeighbors(BspNode *n, vector<BspLeaf *> &neighbors,  
     1795                                                   const bool onlyUnmailed) const 
    17881796{ 
    17891797        PolygonContainer cell; 
     
    17931801        stack<BspNode *> nodeStack; 
    17941802        nodeStack.push(mRoot); 
     1803                 
     1804        // planes needed to verify that we found neighbor leaf. 
     1805        vector<Plane3 *> planes; 
     1806        vector<bool> sides; 
     1807 
     1808        ExtractSplitPlanes(n, planes, sides); 
    17951809 
    17961810        while (!nodeStack.empty())  
     
    17991813                nodeStack.pop(); 
    18001814 
    1801                 if (node->IsLeaf())  
    1802                 { 
    1803                         if (node != n && (!onlyUnmailed || !node->Mailed()))  
    1804                                 neighbors.push_back(node); 
    1805                 }  
     1815                if (node->IsLeaf()) 
     1816                { 
     1817            if (node != n && (!onlyUnmailed || !node->Mailed())) 
     1818                        { 
     1819                                // test all planes of current node on neighbour 
     1820                                PolygonContainer neighborCandidate; 
     1821                                ConstructGeometry(node, neighborCandidate); 
     1822                                 
     1823                                bool isAdjacent = true; 
     1824                                for (int i = 0; (i < planes.size()) && isAdjacent; ++ i) 
     1825                                { 
     1826                                        const int cf =  
     1827                                                Polygon3::ClassifyPlane(neighborCandidate, *planes[i]); 
     1828 
     1829                                        if ((cf == Polygon3::BACK_SIDE) && sides[i]) 
     1830                                                isAdjacent = false; 
     1831                                        else if ((cf == Polygon3::FRONT_SIDE) && !sides[i]) 
     1832                                                isAdjacent = false; 
     1833                                } 
     1834 
     1835                                if (isAdjacent) 
     1836                                        neighbors.push_back(dynamic_cast<BspLeaf *>(node)); 
     1837                        } 
     1838                } 
    18061839                else  
    18071840                { 
     
    18111844 
    18121845                        if (cf == Polygon3::FRONT_SIDE) 
    1813                                 nodeStack.push(interior->mBack); 
     1846                                nodeStack.push(interior->mFront); 
    18141847                        else 
    18151848                                if (cf == Polygon3::BACK_SIDE) 
    1816                                         nodeStack.push(interior->mFront); 
     1849                                        nodeStack.push(interior->mBack); 
    18171850                                else  
    18181851                                { 
     
    18221855                                } 
    18231856                } 
    1824          
    1825         } 
     1857        } 
     1858         
    18261859        return (int)neighbors.size(); 
    18271860} 
  • trunk/VUT/GtpVisibilityPreprocessor/src/ViewCellBsp.h

    r360 r361  
    365365        /** finds neighbouring leaves of this tree node. 
    366366        */ 
    367         int FindNeighbors(BspNode *n, vector<BspNode *> &neighbors, bool onlyUnmailed); 
     367        int FindNeighbors(BspNode *n, vector<BspLeaf *> &neighbors,  
     368                                          const bool onlyUnmailed) const; 
    368369 
    369370        /** Extracts geometry associated with the split plane leading to this node. 
     
    603604        /** Extracts the split planes representing the space bounded by node n. 
    604605        */ 
    605         void ExtractSplitPlanes(BspNode *n, vector<Plane3 *> planes, vector<bool> sides) const; 
     606        void ExtractSplitPlanes(BspNode *n, vector<Plane3 *> &planes, vector<bool> &sides) const; 
    606607 
    607608        /// Pointer to the root of the tree 
Note: See TracChangeset for help on using the changeset viewer.