00001 #ifndef PCL_OUTOFCORE_OUTOFCORE_CLOUD_H_ 00002 #define PCL_OUTOFCORE_OUTOFCORE_CLOUD_H_ 00003 00004 #include <stdint.h> 00005 00006 // PCL 00007 //#include <pcl/common/time.h> 00008 //#include <pcl/point_cloud.h> 00009 #include <pcl/point_types.h> 00010 00011 // PCL - outofcore 00012 #include <pcl/outofcore/outofcore.h> 00013 #include <pcl/outofcore/outofcore_impl.h> 00014 //#include <pcl/outofcore/impl/monitor_queue.hpp> 00015 #include <pcl/outofcore/impl/lru_cache.hpp> 00016 00017 // PCL 00018 #include "camera.h" 00019 //#include <pcl/outofcore/visualization/object.h> 00020 00021 // VTK 00022 #include <vtkActor.h> 00023 #include <vtkActorCollection.h> 00024 #include <vtkAppendPolyData.h> 00025 #include <vtkDataSetMapper.h> 00026 //#include <vtkCamera.h> 00027 //#include <vtkCameraActor.h> 00028 //#include <vtkHull.h> 00029 //#include <vtkPlanes.h> 00030 #include <vtkPolyData.h> 00031 //#include <vtkPolyDataMapper.h> 00032 //#include <vtkProperty.h> 00033 #include <vtkSmartPointer.h> 00034 00035 //class Camera; 00036 00037 class OutofcoreCloud : public Object 00038 { 00039 // Typedefs 00040 // ----------------------------------------------------------------------------- 00041 typedef pcl::PointXYZ PointT; 00042 // typedef pcl::outofcore::OutofcoreOctreeBase<pcl::outofcore::OutofcoreOctreeDiskContainer<PointT>, PointT> octree_disk; 00043 // typedef pcl::outofcore::OutofcoreOctreeBaseNode<pcl::outofcore::OutofcoreOctreeDiskContainer<PointT>, PointT> octree_disk_node; 00044 00045 typedef pcl::outofcore::OutofcoreOctreeBase<> OctreeDisk; 00046 typedef pcl::outofcore::OutofcoreOctreeBaseNode<> OctreeDiskNode; 00047 // typedef pcl::outofcore::OutofcoreBreadthFirstIterator<> OctreeBreadthFirstIterator; 00048 00049 typedef boost::shared_ptr<OctreeDisk> OctreeDiskPtr; 00050 typedef Eigen::aligned_allocator<PointT> AlignedPointT; 00051 00052 00053 00054 typedef std::map<std::string, vtkSmartPointer<vtkActor> > CloudActorMap; 00055 00056 public: 00057 00058 // typedef std::map<std::string, vtkSmartPointer<vtkPolyData> > CloudDataCache; 00059 // typedef std::map<std::string, vtkSmartPointer<vtkPolyData> >::iterator CloudDataCacheIterator; 00060 00061 00062 static boost::shared_ptr<boost::thread> pcd_reader_thread; 00063 //static MonitorQueue<std::string> pcd_queue; 00064 00065 struct PcdQueueItem 00066 { 00067 PcdQueueItem (std::string pcd_file, float coverage) 00068 { 00069 this->pcd_file = pcd_file; 00070 this->coverage = coverage; 00071 } 00072 00073 bool operator< (const PcdQueueItem& rhs) const 00074 { 00075 if (coverage < rhs.coverage) 00076 { 00077 return true; 00078 } 00079 return false; 00080 } 00081 00082 std::string pcd_file; 00083 float coverage; 00084 }; 00085 00086 typedef std::priority_queue<PcdQueueItem> PcdQueue; 00087 static PcdQueue pcd_queue; 00088 static boost::mutex pcd_queue_mutex; 00089 static boost::condition pcd_queue_ready; 00090 00091 class CloudDataCacheItem : public LRUCacheItem< vtkSmartPointer<vtkPolyData> > 00092 { 00093 public: 00094 00095 CloudDataCacheItem (std::string pcd_file, float coverage, vtkSmartPointer<vtkPolyData> cloud_data, size_t timestamp) 00096 { 00097 this->pcd_file = pcd_file; 00098 this->coverage = coverage; 00099 this->item = cloud_data; 00100 this->timestamp = timestamp; 00101 } 00102 00103 virtual size_t 00104 sizeOf() const 00105 { 00106 return item->GetActualMemorySize(); 00107 } 00108 00109 std::string pcd_file; 00110 float coverage; 00111 }; 00112 00113 00114 // static CloudDataCache cloud_data_map; 00115 // static boost::mutex cloud_data_map_mutex; 00116 typedef LRUCache<std::string, CloudDataCacheItem> CloudDataCache; 00117 static CloudDataCache cloud_data_cache; 00118 static boost::mutex cloud_data_cache_mutex; 00119 00120 static void pcdReaderThread(); 00121 00122 // Operators 00123 // ----------------------------------------------------------------------------- 00124 OutofcoreCloud (std::string name, boost::filesystem::path& tree_root); 00125 00126 // Methods 00127 // ----------------------------------------------------------------------------- 00128 void 00129 updateVoxelData (); 00130 00131 // Accessors 00132 // ----------------------------------------------------------------------------- 00133 OctreeDiskPtr 00134 getOctree () 00135 { 00136 return octree_; 00137 } 00138 00139 inline vtkSmartPointer<vtkActor> 00140 getVoxelActor () const 00141 { 00142 return voxel_actor_; 00143 } 00144 00145 inline vtkSmartPointer<vtkActorCollection> 00146 getCloudActors () const 00147 { 00148 return cloud_actors_; 00149 } 00150 00151 void 00152 setDisplayDepth (int displayDepth) 00153 { 00154 if (displayDepth < 0) 00155 { 00156 displayDepth = 0; 00157 } 00158 else if (displayDepth > octree_->getDepth ()) 00159 { 00160 displayDepth = octree_->getDepth (); 00161 } 00162 00163 if (display_depth_ != displayDepth) 00164 { 00165 display_depth_ = displayDepth; 00166 updateVoxelData (); 00167 //updateCloudData(); 00168 } 00169 } 00170 00171 int 00172 getDisplayDepth () 00173 { 00174 return display_depth_; 00175 } 00176 00177 uint64_t 00178 getPointsLoaded () 00179 { 00180 return points_loaded_; 00181 } 00182 00183 uint64_t 00184 getDataLoaded () 00185 { 00186 return data_loaded_; 00187 } 00188 00189 Eigen::Vector3d 00190 getBoundingBoxMin () 00191 { 00192 return bbox_min_; 00193 } 00194 00195 Eigen::Vector3d 00196 getBoundingBoxMax () 00197 { 00198 return bbox_max_; 00199 } 00200 00201 void 00202 setDisplayVoxels (bool display_voxels) 00203 { 00204 voxel_actor_->SetVisibility (display_voxels); 00205 } 00206 00207 bool 00208 getDisplayVoxels() 00209 { 00210 return voxel_actor_->GetVisibility (); 00211 } 00212 00213 void 00214 setRenderCamera(Camera *render_camera) 00215 { 00216 render_camera_ = render_camera; 00217 } 00218 00219 int 00220 getLodPixelThreshold () 00221 { 00222 return lod_pixel_threshold_; 00223 } 00224 00225 void 00226 setLodPixelThreshold (int lod_pixel_threshold) 00227 { 00228 if (lod_pixel_threshold <= 1000) 00229 lod_pixel_threshold = 1000; 00230 00231 lod_pixel_threshold_ = lod_pixel_threshold; 00232 } 00233 00234 void 00235 increaseLodPixelThreshold () 00236 { 00237 int value = 1000; 00238 00239 if (lod_pixel_threshold_ >= 50000) 00240 value = 10000; 00241 if (lod_pixel_threshold_ >= 10000) 00242 value = 5000; 00243 else if (lod_pixel_threshold_ >= 1000) 00244 value = 100; 00245 00246 lod_pixel_threshold_ += value; 00247 std::cout << "Increasing lod pixel threshold: " << lod_pixel_threshold_ << endl; 00248 } 00249 00250 void 00251 decreaseLodPixelThreshold () 00252 { 00253 int value = 1000; 00254 if (lod_pixel_threshold_ > 50000) 00255 value = 10000; 00256 else if (lod_pixel_threshold_ > 10000) 00257 value = 5000; 00258 else if (lod_pixel_threshold_ > 1000) 00259 value = 100; 00260 00261 lod_pixel_threshold_ -= value; 00262 00263 if (lod_pixel_threshold_ < 100) 00264 lod_pixel_threshold_ = 100; 00265 std::cout << "Decreasing lod pixel threshold: " << lod_pixel_threshold_ << endl; 00266 } 00267 00268 virtual void 00269 render (vtkRenderer* renderer); 00270 00271 private: 00272 00273 // Members 00274 // ----------------------------------------------------------------------------- 00275 OctreeDiskPtr octree_; 00276 00277 uint64_t display_depth_; 00278 uint64_t points_loaded_; 00279 uint64_t data_loaded_; 00280 00281 Eigen::Vector3d bbox_min_, bbox_max_; 00282 00283 Camera *render_camera_; 00284 00285 int lod_pixel_threshold_; 00286 00287 vtkSmartPointer<vtkActor> voxel_actor_; 00288 00289 std::map<std::string, vtkSmartPointer<vtkActor> > cloud_actors_map_; 00290 vtkSmartPointer<vtkActorCollection> cloud_actors_; 00291 00292 public: 00293 EIGEN_MAKE_ALIGNED_OPERATOR_NEW 00294 }; 00295 00296 #endif
Except where otherwise noted, the PointClouds.org web pages are licensed under Creative Commons Attribution 3.0.
Pages generated on Wed Mar 25 00:24:35 2015