1 // Copyright (C) 2007-2008 CEA/DEN, EDF R&D
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License.
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // Lesser General Public License for more details.
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
19 #include "BBTreeTest.hxx"
26 void BBTreeTest::setUp()
31 void BBTreeTest::tearDown()
36 * Test that creates a tree in 2D and check that
37 * the results are correct in three
39 * a non matching search
41 * a bbox overlapping the bboxes of the tree
43 void BBTreeTest::test_BBTree() {
46 double* bbox=new double[4*N*N];
47 for (int i=0; i<N; i++)
48 for (int j=0; j<N; j++)
51 bbox[4*(i*N+j)+1]=i+1;
53 bbox[4*(i*N+j)+3]=j+1;
55 BBTree<2> tree(bbox,0,0,N*N);
56 std::vector <int> elems;
58 //box outside the tree
59 double bbox1[4]={-2.0, -1.0, 0.0, 1.0};
60 tree.getIntersectingElems(bbox1,elems);
61 CPPUNIT_ASSERT_EQUAL(0,(int)elems.size());
64 //box intersecting 4 tree elems
65 double bbox2[4]={2.5, 3.5, 0.5, 1.5};
66 tree.getIntersectingElems(bbox2,elems);
67 CPPUNIT_ASSERT_EQUAL(4,(int)elems.size());
70 //box exactly superimposed to two tree elems
71 double bbox3[4]={5.0,6.0,7.0,9.0};
72 tree.getIntersectingElems(bbox3,elems);
73 CPPUNIT_ASSERT_EQUAL(2,(int)elems.size());
76 double xx[2]={1.0,1.0};
77 tree.getElementsAroundPoint(xx,elems);
78 CPPUNIT_ASSERT_EQUAL(4,(int)elems.size());