template<typename PointT> void OutofcoreOctreeRamContainer<PointT>::readRange (const boost::uint64_t start, const boost::uint64_t count, AlignedPointTVector& v) { v.resize (count); memcpy (v.data (), container_.data () + start, count * sizeof(PointT)); }
template<typename PointT> void OutofcoreOctreeRamContainer<PointT>::insertRange (const PointT* const * start, const boost::uint64_t count) { AlignedPointTVector temp; temp.resize (count); for (boost::uint64_t i = 0; i < count; i++) { temp[i] = *start[i]; } container_.insert (container_.end (), temp.begin (), temp.end ()); }
TEST (PCL, Outofcore_Octree_Build) { boost::filesystem::remove_all (filename_otreeA.parent_path ()); boost::filesystem::remove_all (filename_otreeB.parent_path ()); Eigen::Vector3d min (-32.0, -32.0, -32.0); Eigen::Vector3d max (32.0, 32.0, 32.0); // Build two trees using each constructor // depth of treeA will be same as B because 1/2^3 > .1 and 1/2^4 < .1 // depth really affects performance octree_disk treeA (min, max, .1, filename_otreeA, "ECEF"); octree_disk treeB (4, min, max, filename_otreeB, "ECEF"); // Equidistributed uniform pseudo-random number generator boost::mt19937 rng(rngseed); // For testing sparse //boost::uniform_real<double> dist(0,1); // For testing less sparse boost::normal_distribution<float> dist (0.5f, .1f); // Create a point PointT p; points.resize (numPts); //ignore these fields from the UR point for now // p.r = p.g = p.b = 0; // p.nx = p.ny = p.nz = 1; // p.cameraCount = 0; // p.error = 0; // p.triadID = 0; // Radomize it's position in space for (size_t i = 0; i < numPts; i++) { p.x = dist (rng); p.y = dist (rng); p.z = dist (rng); points[i] = p; } // Add to tree treeA.addDataToLeaf (points); // Add to tree treeB.addDataToLeaf (points); }
TEST (PCL, Outofcore_Octree_Build_LOD) { boost::filesystem::remove_all (filename_otreeA_LOD.parent_path ()); boost::filesystem::remove_all (filename_otreeB_LOD.parent_path ()); Eigen::Vector3d min (0.0, 0.0, 0.0); Eigen::Vector3d max (1.0, 1.0, 1.0); // Build two trees using each constructor octree_disk treeA (min, max, .1, filename_otreeA_LOD, "ECEF"); octree_disk treeB (4, min, max, filename_otreeB_LOD, "ECEF"); // Equidistributed uniform pseudo-random number generator boost::mt19937 rng (rngseed); // For testing sparse //boost::uniform_real<double> dist(0,1); // For testing less sparse boost::normal_distribution<float> dist (0.5f, .1f); // Create a point PointT p; /* p.r = p.g = p.b = 0; p.nx = p.ny = p.nz = 1; p.cameraCount = 0; p.error = 0; p.triadID = 0; */ points.resize (numPts); // Radomize it's position in space for (size_t i = 0; i < numPts; i++) { p.x = dist (rng); p.y = dist (rng); p.z = dist (rng); points[i] = p; } // Add to tree treeA.addDataToLeaf_and_genLOD (points); // Add to tree treeB.addDataToLeaf_and_genLOD (points); }
TEST (PCL, Outofcore_Ram_Tree) { Eigen::Vector3d min (0.0,0.0,0.0); Eigen::Vector3d max (1.0, 1.0, 1.0); const boost::filesystem::path filename_otreeA = "ram_tree/ram_tree.oct_idx"; octree_ram t (min, max, .1, filename_otreeA, "ECEF"); boost::mt19937 rng (rngseed); //boost::uniform_real<double> dist(0,1);//for testing sparse boost::normal_distribution<float> dist (0.5f, .1f);//for testing less sparse PointT p; points.resize (numPts); for (size_t i = 0; i < numPts; i++) { p.x = dist(rng); p.y = dist(rng); p.z = dist(rng); points[i] = p; } t.addDataToLeaf_and_genLOD (points); //t.addDataToLeaf(points); Eigen::Vector3d qboxmin; Eigen::Vector3d qboxmax; for (int i = 0; i < 10; i++) { //std::cout << "query test round " << i << std::endl; for (int j = 0; j < 3; j++) { qboxmin[j] = dist (rng); qboxmax[j] = dist (rng); if (qboxmax[j] < qboxmin[j]) { std::swap (qboxmin[j], qboxmax[j]); } } //query the trees AlignedPointTVector p_ot1; t.queryBBIncludes (qboxmin, qboxmax, t.getDepth (), p_ot1); //query the list AlignedPointTVector pointsinregion; BOOST_FOREACH(const PointT& p, points) { if ((qboxmin[0] <= p.x) && (p.x <= qboxmax[0]) && (qboxmin[1] <= p.y) && (p.y <= qboxmax[1]) && (qboxmin[2] <= p.z) && (p.z <= qboxmax[2])) { pointsinregion.push_back (p); } } EXPECT_EQ (p_ot1.size (), pointsinregion.size ()); //very slow exhaustive comparison while (!p_ot1.empty ()) { AlignedPointTVector::iterator it; it = std::find_first_of (p_ot1.begin (), p_ot1.end (), pointsinregion.begin (), pointsinregion.end (), compPt); if (it != p_ot1.end ()) { p_ot1.erase(it); } else { break; FAIL () << "Dropped Point from tree1!" << std::endl; } } EXPECT_TRUE (p_ot1.empty ()); } }