Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040 #ifndef PCL_OUTOFCORE_RAM_CONTAINER_IMPL_H_
00041 #define PCL_OUTOFCORE_RAM_CONTAINER_IMPL_H_
00042
00043
00044 #include <sstream>
00045
00046
00047 #include <pcl/outofcore/octree_ram_container.h>
00048
00049 namespace pcl
00050 {
00051 namespace outofcore
00052 {
00053
00054 template<typename PointT>
00055 boost::mutex OutofcoreOctreeRamContainer<PointT>::rng_mutex_;
00056
00057 template<typename PointT>
00058 boost::mt19937 OutofcoreOctreeRamContainer<PointT>::rand_gen_ (static_cast<unsigned int>(std::time( NULL)));
00059
00060 template<typename PointT> void
00061 OutofcoreOctreeRamContainer<PointT>::convertToXYZ (const boost::filesystem::path& path)
00062 {
00063 if (!container_.empty ())
00064 {
00065 FILE* fxyz = fopen (path.string ().c_str (), "w");
00066
00067 boost::uint64_t num = size ();
00068 for (boost::uint64_t i = 0; i < num; i++)
00069 {
00070 const PointT& p = container_[i];
00071
00072 std::stringstream ss;
00073 ss << std::fixed;
00074 ss.precision (16);
00075 ss << p.x << "\t" << p.y << "\t" << p.z << "\n";
00076
00077 fwrite (ss.str ().c_str (), 1, ss.str ().size (), fxyz);
00078 }
00079
00080 assert ( fclose (fxyz) == 0 );
00081 }
00082 }
00083
00085
00086 template<typename PointT> void
00087 OutofcoreOctreeRamContainer<PointT>::insertRange (const PointT* start, const boost::uint64_t count)
00088 {
00089 container_.insert (container_.end (), start, start + count);
00090 }
00091
00093
00094 template<typename PointT> void
00095 OutofcoreOctreeRamContainer<PointT>::insertRange (const PointT* const * start, const boost::uint64_t count)
00096 {
00097 AlignedPointTVector temp;
00098 temp.resize (count);
00099 for (boost::uint64_t i = 0; i < count; i++)
00100 {
00101 temp[i] = *start[i];
00102 }
00103 container_.insert (container_.end (), temp.begin (), temp.end ());
00104 }
00105
00107
00108 template<typename PointT> void
00109 OutofcoreOctreeRamContainer<PointT>::readRange (const boost::uint64_t start, const boost::uint64_t count,
00110 AlignedPointTVector& v)
00111 {
00112 v.resize (count);
00113 memcpy (v.data (), container_.data () + start, count * sizeof(PointT));
00114 }
00115
00117
00118 template<typename PointT> void
00119 OutofcoreOctreeRamContainer<PointT>::readRangeSubSample (const boost::uint64_t start,
00120 const boost::uint64_t count,
00121 const double percent,
00122 AlignedPointTVector& v)
00123 {
00124 boost::uint64_t samplesize = static_cast<boost::uint64_t> (percent * static_cast<double> (count));
00125
00126 boost::mutex::scoped_lock lock (rng_mutex_);
00127
00128 boost::uniform_int < boost::uint64_t > buffdist (start, start + count);
00129 boost::variate_generator<boost::mt19937&, boost::uniform_int<boost::uint64_t> > buffdie (rand_gen_, buffdist);
00130
00131 for (boost::uint64_t i = 0; i < samplesize; i++)
00132 {
00133 boost::uint64_t buffstart = buffdie ();
00134 v.push_back (container_[buffstart]);
00135 }
00136 }
00137
00139
00140 }
00141 }
00142
00143 #endif //PCL_OUTOFCORE_RAM_CONTAINER_IMPL_H_