1 // This is brl/bseg/bvpl/kernels/bvpl_taylor_basis_factory.h 2 #ifndef bvpl_taylor_basis_factory_h 3 #define bvpl_taylor_basis_factory_h 4 //: 5 // \file 6 // \brief A factory that reads from file a taylor-kernel. 7 // \author Isabel Restrepo mir@lems.brown.edu 8 // \date 25-Jan-2011 9 // 10 // \verbatim 11 // Modifications 12 // <none yet> 13 // \endverbatim 14 15 #include <utility> 16 #include <bvpl/kernels/bvpl_kernel_factory.h> 17 #include <vgl/vgl_point_3d.h> 18 19 20 //: This class reads from disk the taylor kernels. 21 class bvpl_taylor_basis_factory: public bvpl_kernel_factory 22 { 23 public: 24 //: Constructor from directory where the kernel files are located. The approximation degree defaults to 2 25 bvpl_taylor_basis_factory(std::string filename); 26 27 //: Identifying string name()28 static std::string name() { return "taylor"; } 29 30 protected: 31 //: Filename containing the kernel 32 std::string filename_; 33 34 //: Creates canonical kernel from file 35 void create_canonical() override; 36 }; 37 38 39 //: Helper class to load taylor kernels, response scenes and hold paths 40 class bvpl_taylor_basis_loader 41 { 42 public: bvpl_taylor_basis_loader()43 bvpl_taylor_basis_loader():path_(""), min_point_(vgl_point_3d<int>()), max_point_(vgl_point_3d<int>()), degree_(0) {} 44 45 bvpl_taylor_basis_loader(std::string path, 46 vgl_point_3d<int> min_point = vgl_point_3d<int>(-2,-2,-2), 47 vgl_point_3d<int> max_point = vgl_point_3d<int>(2,2,2), path_(std::move (path))48 unsigned degree=2): path_(std::move(path)), min_point_(min_point), max_point_(max_point),degree_(degree) {} 49 50 //: Returns a map of kernels and their names 51 void create_basis(std::map<std::string, bvpl_kernel_sptr> &taylor_basis); 52 53 //: List of filenames that should be present in path_ 54 void files(std::vector<std::string> &filenames); 55 56 //: Return main path path()57 std::string path() const { return path_; } 58 59 //: Return the min point of bounding box of this set of kernels min_point()60 vgl_point_3d<int> min_point() const { return min_point_; } 61 62 //: Return the max point of bounding box of this set of kernels max_point()63 vgl_point_3d<int> max_point() const { return max_point_; } 64 65 private: 66 //: Path to all kernels (must be a directory) 67 std::string path_; 68 69 //: Min point of bounding box of these kernels 70 vgl_point_3d<int> min_point_; 71 72 //: Max point of bounding box of these kernels 73 vgl_point_3d<int> max_point_; 74 75 //: The degree of taylor approximation 76 unsigned degree_; 77 }; 78 79 #endif 80