当前位置: 首页 > news >正文

商丘网站建设推广渠道湖南郴州市是几线城市

商丘网站建设推广渠道,湖南郴州市是几线城市,wordpress国人模板,wordpress批量增加用户CGAL 从DSM到DTM-建筑物区域提取 生成的DSM被用作DTM计算的基础,即地面表示为过滤掉非地面点后的另一个TIN。主要是去除一些建筑物和植被非地形点。 建筑物立面及连通区域提取 建筑物立面的特征是三角形面片的高度变化剧烈。 通过遍历每一个三角面片,…

CGAL 从DSM到DTM-建筑物区域提取

生成的DSM被用作DTM计算的基础,即地面表示为过滤掉非地面点后的另一个TIN。主要是去除一些建筑物和植被非地形点。

建筑物立面及连通区域提取

建筑物立面的特征是三角形面片的高度变化剧烈。
通过遍历每一个三角面片,计算顶点之间最大的高差face_height,与事先设置的阈值spacing比较,大于阈值或包含无限远点infinite_vertex标记为建筑物立面。

除去建筑物立面,对剩下的三角面片使用洪水算法确定连通区域,并标记对应的区域id,取值范围:[0,component_size.size()]

代码

#include<iostream>#include<CGAL/Surface_mesh.h>
#include<CGAL/Surface_mesh/IO/PLY.h>#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
#include <CGAL/Projection_traits_xy_3.h>
#include <CGAL/Delaunay_triangulation_2.h>
#include <CGAL/Triangulation_vertex_base_with_info_2.h>
#include <CGAL/Triangulation_face_base_with_info_2.h>#include <CGAL/boost/graph/graph_traits_Delaunay_triangulation_2.h>
#include <CGAL/boost/graph/copy_face_graph.h>#include <CGAL/compute_average_spacing.h>using Kernel = CGAL::Exact_predicates_inexact_constructions_kernel;using Projection_traits = CGAL::Projection_traits_xy_3<Kernel>;using Point_3 = Kernel::Point_3;
using Mesh = CGAL::Surface_mesh<Point_3>;using Concurrency_tag = CGAL::Sequential_tag;using Vbi = CGAL::Triangulation_vertex_base_with_info_2 <Mesh::Vertex_index, Projection_traits>;
using Fbi = CGAL::Triangulation_face_base_with_info_2<int, Projection_traits>;
using TDS = CGAL::Triangulation_data_structure_2<Vbi, Fbi>;
using TIN_with_info = CGAL::Delaunay_triangulation_2<Projection_traits, TDS>;int main() {Mesh mesh;CGAL::IO::read_PLY("./data/dsm.ply", mesh);auto idx_to_point_with_info= [&](const Mesh::Vertex_index& idx) -> std::pair<Point_3, Mesh::Vertex_index>{return std::make_pair ( mesh.point(idx), idx);};TIN_with_info tin_with_info(boost::make_transform_iterator (mesh.vertices().begin(), idx_to_point_with_info),boost::make_transform_iterator (mesh.vertices().end(), idx_to_point_with_info));double spacing = CGAL::compute_average_spacing<Concurrency_tag>(mesh.points(), 6);spacing *= 2;auto face_height= [&](const TIN_with_info::Face_handle fh) -> double{double out = 0.;for (int i = 0; i < 3; ++ i)out = (std::max) (out, CGAL::abs(fh->vertex(i)->point().z() - fh->vertex((i+1)%3)->point().z()));return out;};// Initialize faces info 初始化三角面附件信息(int类型)for (TIN_with_info::Face_handle fh : tin_with_info.all_face_handles())if (tin_with_info.is_infinite(fh) || face_height(fh) > spacing) // Filtered faces are given info() = -2fh->info() = -2;else // Pending faces are given info() = -1;fh->info() = -1;// Flooding algorithmstd::vector<int> component_size;for (TIN_with_info::Face_handle fh : tin_with_info.finite_face_handles()){if (fh->info() != -1)continue;std::queue<TIN_with_info::Face_handle> todo;todo.push(fh);int size = 0;while (!todo.empty()){TIN_with_info::Face_handle current = todo.front();todo.pop();if (current->info() != -1)continue;current->info() = int(component_size.size());++ size;for (int i = 0; i < 3; ++ i)todo.push (current->neighbor(i));}component_size.push_back (size);}std::cerr << component_size.size() << " connected component(s) found" << std::endl;Mesh tin_colored_mesh;//Mesh::Property_map<Mesh::Face_index, CGAL::IO::Color>color_map = tin_colored_mesh.add_property_map<Mesh::Face_index, CGAL::IO::Color>("f:color").first;CGAL::copy_face_graph (tin_with_info, tin_colored_mesh,CGAL::parameters::face_to_face_output_iterator(boost::make_function_output_iterator([&](const std::pair<TIN_with_info::Face_handle, Mesh::Face_index>& ff){// 灰色标记建筑物立面及待处理的其他非地面点if (ff.first->info() < 0){color_map[ff.second] = CGAL::IO::Color(128, 128, 128);// put(color_map, ff.second, CGAL::IO::Color(128, 128, 128));}else{// 其他标记随机颜色CGAL::Random r (ff.first->info());color_map[ff.second] = CGAL::IO::Color (r.get_int(64, 192),r.get_int(64, 192),r.get_int(64, 192));/*put(color_map, ff.second, CGAL::IO::Color(r.get_int(64, 192),r.get_int(64, 192),r.get_int(64, 192)));*/}})));std::ofstream tin_colored_ofile ("colored_tin.ply", std::ios_base::binary);CGAL::IO::set_binary_mode (tin_colored_ofile);CGAL::IO::write_PLY (tin_colored_ofile, tin_colored_mesh);tin_colored_ofile.close();return 0;
}

如下图所示,灰色标记为建筑物立面,其他联通区域标记随机颜色:

coloredTIN

构建编译运行

cmake -B build -S . -DCMAKE_TOOLCHAIN_FILE=D:\vcpkg\scripts\buildsystems\vcpkg.cmake
cmake --build build --config Debug
.\build\Debug\coloredTIN.exe

参考

  1. https://doc.cgal.org/latest/Manual/tuto_gis.html
http://www.yayakq.cn/news/903704/

相关文章:

  • 地图制作网站学校网站设计的目的
  • .net网站封装用地方别名做网站名
  • 如何联系网站站长百度竞价价格查询
  • 网站的建站风格科技数码app排名
  • 关于 公司网站建设的通知管家婆客户管理系统
  • 天津艺匠做网站5 网站建设的基本步骤是
  • 网站开发可演示的版本百度集团公司简介
  • wordpress安装 后合肥百度快速排名优化
  • 口碑营销的四种驱动方式网站优化简历模板
  • 云上的网站怎么做等保网站统计数据
  • flash做网站步骤wordpress模板修改字体
  • 厦门同安网站建设福州网络营销网站
  • 建网站自己做服务器凡科网多页网站怎样做
  • 中国建设银行网站-诚聘英才h5游戏充值折扣平台
  • 网站空间哪里便宜网络营销的新特点
  • 做彩票网站需要境外网络信息安全公司排名
  • 网站开发二维码生成百度收录怎么做
  • 网站建设 方案下载网站备案号被注销怎么办
  • 帝国cms做下载网站宁波外贸网站
  • dw做的网站能直接使用吗做网站和做app哪个容易
  • 想自己做淘宝有什么网站开通微信公众号
  • h5游戏网站开发weixinqqcom微信官网
  • 做网站用哪几个端口 比较好信息门户网站制作
  • 广州珠江工程建设监理有限公司网站建设网站的题目
  • 漂亮的手机网站模板浙江省建设门户网站
  • 如何在百度中搜索到网站商丘企业网站建设费用多少钱
  • 什么网站能接单做网站wordpress网站安全
  • dede网站网页主页链接企业网站开发期末报告
  • 耀华建设管理有限公司网站安徽专业网站建设设计
  • 建设网站的网站是什么seox