TECA
teca_2d_component_area.h
1 #ifndef teca_2d_component_area_h
2 #define teca_2d_component_area_h
3 
4 #include "teca_shared_object.h"
5 #include "teca_algorithm.h"
6 #include "teca_metadata.h"
7 
8 #include <string>
9 #include <vector>
10 
11 TECA_SHARED_OBJECT_FORWARD_DECL(teca_2d_component_area)
12 
13 
49 {
50 public:
51  TECA_ALGORITHM_STATIC_NEW(teca_2d_component_area)
52  TECA_ALGORITHM_DELETE_COPY_ASSIGN(teca_2d_component_area)
53  TECA_ALGORITHM_CLASS_NAME(teca_2d_component_area)
55 
56  // report/initialize to/from Boost program options objects.
57  TECA_GET_ALGORITHM_PROPERTIES_DESCRIPTION()
58  TECA_SET_ALGORITHM_PROPERTIES()
59 
60  // set the name of the input array
61  TECA_ALGORITHM_PROPERTY(std::string, component_variable)
62 
63  // set this only if you know for certain that label ids are contiguous and
64  // start at 0. this enables use of a faster implementation.
65  TECA_ALGORITHM_PROPERTY(int, contiguous_component_ids)
66 
67  // set this to override the component label used for background. By default
68  // this is set to -1 to indicate that the value should be obtained from the
69  // metadata key `background_id`. Note that TECA's connected component
70  // labeler uses the id 0 for the background and passes this in a metadata
71  // key and as a result no action is required.
72  TECA_ALGORITHM_PROPERTY(long, background_id)
73 
74 protected:
76 
77  int get_component_variable(std::string &component_var);
78 
79 private:
80  teca_metadata get_output_metadata(
81  unsigned int port,
82  const std::vector<teca_metadata> &input_md) override;
83 
84  std::vector<teca_metadata> get_upstream_request(
85  unsigned int port,
86  const std::vector<teca_metadata> &input_md,
87  const teca_metadata &request) override;
88 
89  const_p_teca_dataset execute(
90  unsigned int port,
91  const std::vector<const_p_teca_dataset> &input_data,
92  const teca_metadata &request) override;
93 
94 private:
95  std::string component_variable;
96  int contiguous_component_ids;
97  long background_id;
98 };
99 
100 #endif
teca_metadata
Definition: teca_metadata.h:17
teca_2d_component_area
an algorithm that computes the area of labeled regions
Definition: teca_2d_component_area.h:49
teca_algorithm
Definition: teca_algorithm.h:25