1 #ifndef boxm2_export_oriented_point_cloud_function_h
2 #define boxm2_export_oriented_point_cloud_function_h
3 //:
4 // \file
5 
6 #include <sstream>
7 #include <iostream>
8 #include <iomanip>
9 #include <boxm2/boxm2_data_base.h>
10 #include <boxm2/boxm2_data_traits.h>
11 #include <boxm2/boxm2_block.h>
12 #include <boxm2/boxm2_data.h>
13 #include <boct/boct_bit_tree.h>
14 
15 #include "boxm2_mog3_grey_processor.h"
16 #include "boxm2_gauss_rgb_processor.h"
17 
18 #include "boxm2/boxm2_util.h"
19 
20 class boxm2_export_oriented_point_cloud_function
21 {
22  public:
23   static void exportPointCloudXYZ(const boxm2_scene_sptr& scene, const boxm2_block_metadata& data, boxm2_block* blk,
24                                       boxm2_data_base* alpha, boxm2_data_base* vis, boxm2_data_base* vis_sum, boxm2_data_base* exp,boxm2_data_base* nobs,
25                                       boxm2_data_base* points, boxm2_data_base* normals,
26                                       boxm2_data_base* ray_dir_sum, std::ofstream& file,
27                                       bool output_aux, float vis_t, float nmag_t, float prob_t, float exp_t, vgl_box_3d<double> bb);
28   static void exportPointCloudPLY(const boxm2_scene_sptr& scene, const boxm2_block_metadata& data, boxm2_block* blk,
29                                       boxm2_data_base* alpha, boxm2_data_base* vis,
30                                       boxm2_data_base* points, boxm2_data_base* normals,
31                                       std::ofstream& file,
32                                       bool output_aux, float vis_t, float nmag_t, float prob_t, vgl_box_3d<double> bb, unsigned& num_vertices);
33   static void exportColorPointCloudPLY(const boxm2_scene_sptr& scene, const boxm2_block_metadata& data, boxm2_block* blk,
34                                        boxm2_data_base* mog, boxm2_data_base* alpha,const std::string& datatype,
35                                        boxm2_data_base* points,std::ofstream& file,float prob_t,vgl_box_3d<double> bb, unsigned& num_vertices);
36 
37   static bool calculateProbOfPoint(const boxm2_scene_sptr& scene, boxm2_block * blk,
38                                    const vnl_vector_fixed<float, 4>& point,
39                                    const float& alpha, float& prob);
40 
41   static void writePLYHeader(std::ofstream& file, unsigned num_vertices, std::stringstream& ss, bool output_aux);
42   static void writePLYHeaderOnlyPoints(std::ofstream& file, unsigned num_vertices, std::stringstream& ss);
43 
44   //:Reads a bounding box from a .PLY. the box is created such that all points in the .PLY file are contained in the box
45   static void readBBFromPLY(const std::string& filename, vgl_box_3d<double>& box);
46 
47   //: Use covariance estimate to export a point cloud
48   //  return points for which prob is greater than prob_t and LE is less than LE_t and CE is less than LE_t
49   static void exportPointCloudPLY(const boxm2_scene_sptr& scene, const boxm2_block_metadata& data, boxm2_block* blk,
50                                   boxm2_data_base* mog, boxm2_data_base* alpha, boxm2_data_base* points, boxm2_data_base* covariances, std::ofstream& file,
51                                   float prob_t, float LE_t, float CE_t, vgl_box_3d<double> bb, unsigned& num_vertices, const std::string& datatype);
52 
53   static bool calculateProbOfPoint(const boxm2_scene_sptr& scene, boxm2_block * blk,
54                                    const vnl_vector_fixed<float, 4>& point,
55                                    const vnl_vector_fixed<float, 9>& cov,
56                                    const float& alpha,
57                                    float& prob, double& color,
58                                    vnl_vector_fixed<double, 3>& axes, double& LE, double& CE);
59   static bool calculateLECEofPoint(const vnl_vector_fixed<float, 9>& cov,vnl_vector_fixed<double, 3>&axes, double& LE, double& CE);
60 
61 };
62 
63 
64 
65 #endif
66