Go to the documentation of this file.00001
00002 #ifndef bmdl_mesh_h_
00003 #define bmdl_mesh_h_
00004
00005
00006
00007
00008
00009
00010
00011 #include <vcl_cstddef.h>
00012
00013 #include <vil/vil_image_view.h>
00014 #include <imesh/imesh_mesh.h>
00015
00016 struct bmdl_edge
00017 {
00018 bmdl_edge(unsigned int b1, unsigned int b2)
00019 : building1(b1), building2(b2) {}
00020
00021 unsigned int building1;
00022 unsigned int building2;
00023 unsigned int joint1;
00024 unsigned int joint2;
00025 vcl_vector<vgl_point_2d<double> > pts;
00026 };
00027
00028
00029 struct bmdl_region
00030 {
00031 vcl_vector<unsigned int> edge_idxs;
00032 vcl_vector<vcl_vector<unsigned int> > hole_edge_idxs;
00033 };
00034
00035
00036 class bmdl_mesh
00037 {
00038 public:
00039
00040 static bool next_trace_point(unsigned int& i, unsigned int& j, int& dir,
00041 const unsigned int* &p, unsigned int value,
00042 unsigned int ni, unsigned int nj,
00043 vcl_ptrdiff_t istep, vcl_ptrdiff_t jstep);
00044
00045
00046 static bool trace_boundary(vcl_vector<vgl_point_2d<double> >& pts,
00047 unsigned int value,
00048 const vil_image_view<unsigned int>& labels,
00049 vil_image_view<bool>& visited,
00050 unsigned int i, unsigned int j);
00051
00052
00053
00054 static vcl_vector<vgl_polygon<double> >
00055 trace_boundaries(const vil_image_view<unsigned int>& labels, bool drop_clipped = true);
00056
00057
00058
00059 static unsigned int link_boundary_edges(const vil_image_view<unsigned int>& labels,
00060 const vcl_vector<vgl_polygon<double> >& polygons,
00061 vcl_vector<bmdl_edge>& edges,
00062 vcl_vector<bmdl_region>& regions);
00063
00064
00065
00066 static bool is_clipped(const vcl_vector<vgl_point_2d<double> >& poly,
00067 unsigned ni, unsigned nj);
00068
00069
00070
00071 static void simplify_polygon( vcl_vector<vgl_point_2d<double> >& polygon, double tol);
00072
00073
00074 static void simplify_boundaries( vcl_vector<vgl_polygon<double> >& boundaries );
00075
00076
00077
00078 static void simplify_edge( vcl_vector<vgl_point_2d<double> >& pts, double tol );
00079
00080
00081 static void simplify_edges( vcl_vector<bmdl_edge>& edges );
00082
00083
00084 static void roof_subtract_hole(const imesh_vertex_array<3>& verts,
00085 vcl_vector<unsigned int>& face,
00086 const vcl_vector<unsigned int>& hole);
00087
00088
00089
00090
00091 static void mesh_lidar(const vcl_vector<vgl_polygon<double> >& boundaries,
00092 const vil_image_view<unsigned int>& labels,
00093 const vil_image_view<double>& heights,
00094 const vil_image_view<double>& ground,
00095 imesh_mesh& mesh);
00096
00097
00098
00099
00100 static void mesh_lidar(const vcl_vector<bmdl_edge>& edges,
00101 const vcl_vector<bmdl_region>& regions,
00102 unsigned int num_joints,
00103 const vil_image_view<unsigned int>& labels,
00104 const vil_image_view<double>& heights,
00105 const vil_image_view<double>& ground,
00106 imesh_mesh& mesh);
00107 };
00108
00109 #endif // bmdl_mesh_h_