C++ CGAL教程:4.1 窗口控件与MFC CButton应用详解

需积分: 49 122 下载量 168 浏览量 更新于2024-08-10 收藏 1.02MB PDF 举报
本篇文档主要介绍了Microsoft Foundation Classes (MFC)中的窗口控件,特别是CButton类在Visual C++ MFC环境下的应用。章节四详细探讨了CButton的不同样式,包括: 1. Button Styles: - BS_PUSHBUTTON: 常规按钮,无预设状态,用户点击后响应。 - BS_CHECKBOX: 检查框按钮,用户可以选择或取消选择,通常显示文本在右侧。 - BS_RADIOBUTTON: 单选按钮,选择其中一个后高亮显示,同一组内的其他按钮则取消选择。 - BS_AUTOCHECKBOX: 自动切换的检查框,用户选择后会显示复选标记。 - BS_AUTORADIOBUTTON: 自动切换的圆形选择按钮,类似功能。 - BS_DEFPUSHBUTTON: 默认按钮,具有黑边框,通常用作主选项。 - BS_LEFTTEXT: 文字左对齐,适用于与检查框或单选按钮配合。 2. 消息映射(Messaging): MFC中的窗口过程(newWndProc)是处理Windows消息的关键,通过`ON_WM_CREATE()`来处理窗口创建事件,`ON_COMMAND()`则用于响应命令,如`ID_FONT_DROPDOWN`。 3. 通用开发方法: - 单文档应用:适合读写文件及基本输入输出,使用单文档视图结构SDI。 - 对话框应用:对于简单交互,尤其是文件操作,CFileDialog或CFile可用于简化。 - 复杂交互应用:结合CFormView的SDI,便于文件读写和交互。 - 数据输入:开始时使用对话框获取,进阶后考虑就地输入。 - 单文档多视图:在不需要多文档管理时,可通过分割条实现。 - 多文档应用:在需要跨文档共享数据时,采用MDI模式。 - 子窗口和封装:利用子窗口包含多个控件,增强代码的模块化和复用。 理解这些概念对于熟练运用MFC进行Windows应用程序开发至关重要,它涉及基础控件的使用、消息处理以及应用程序架构设计。通过这些技巧,开发者可以构建出交互性更强、功能更丰富的软件应用。

vector<PointVectorPair> points; for (size_t i = 0; i < input->size(); i++) { float px = input->points[i].x; float py = input->points[i].y; float pz = input->points[i].z; float nx = input->points[i].normal_x; float ny = input->points[i].normal_y; float nz = input->points[i].normal_z; points.push_back(PointVectorPair(Kernel::Point_3(px, py, pz), Kernel::Vector_3(nx, ny, nz))); } // ---------------------------------参数设置--------------------------------- const double s_angle = 25; // 平滑度,值越大越平滑,取值范围[0,90] const double edge_s = 0; // 边缘的敏感性取值范围[0,1] const double n_radius = 0.25; // 邻域点搜索半径 const std::size_t n_out = points.size() * 10; // 上采样后的点数 // ----------------------------------上采样---------------------------------- CGAL::edge_aware_upsample_point_set<CGAL::Parallel_if_available_tag>(points, std::back_inserter(points), CGAL::parameters::point_map(CGAL::First_of_pair_property_map<PointVectorPair>()). normal_map(CGAL::Second_of_pair_property_map<PointVectorPair>()). sharpness_angle(s_angle). // 控制输出结果的平滑度,值越大越平滑,取值范围[0,90]。 edge_sensitivity(edge_s). // 边缘的敏感性取值范围[0,1],边缘敏感度越大,在尖锐边缘处插入点的有限度越高 neighbor_radius(n_radius). // 邻域点的个数,如果提供,查询点的邻域是用一个固定的球面计算的半径 // 而不是固定数量的邻居。在这种情况下,参数k用于限制每个球邻域返回点的数量(避免高密度区域的点过多) number_of_output_points(n_out)); // 上采样后的点数 std::cout << "上采样完毕!!!" << std::endl;将上述代码中的CGAL带有法线的点云数据转换PCL库点云数据PointNormal

2023-07-08 上传

int main(int argc, const char** argv) { //****************************************获取数据***************************************************** const std::string input_filename = (argc > 1) ? argv[1] : CGAL::data_file_path("C:\\Users\\lwc\\source\\repos\\Project4\\x64\\Release\\output.xyz"); const char* output_filename = (argc > 2) ? argv[2] : "C:\\Users\\lwc\\source\\repos\\Project4\\x64\\Release\\113.xyz"; //输出文件名称 std::vector<PointVectorPair> points; if (!CGAL::IO::read_points(input_filename, std::back_inserter(points), CGAL::parameters::point_map(CGAL::First_of_pair_property_map<PointVectorPair>()) .normal_map(CGAL::Second_of_pair_property_map<PointVectorPair>()))) { std::cerr << "Error: cannot read file " << input_filename << std::endl; return EXIT_FAILURE; } //****************************************点云平滑************************************************* unsigned int k = 5; //邻近点数 double offset_radius = 0.01; CGAL::vcm_estimate_normals<std::vector<PointVectorPair>>(points, offset_radius, k, CGAL::parameters::point_map(CGAL::First_of_pair_property_map<PointVectorPair>()) .normal_map(CGAL::Second_of_pair_property_map<PointVectorPair>())); //使用vcm算法来获取每个点的法向量,后面的参数指定了我们的点与法向量对于的部分 //********************************************保存数据************************************************* if (!CGAL::IO::write_points(output_filename, points, CGAL::parameters::point_map(CGAL::First_of_pair_property_map<PointVectorPair>()) .normal_map(CGAL::Second_of_pair_property_map<PointVectorPair>()) .stream_precision(17))) return EXIT_FAILURE; std::cout << "计算结束!" << std::endl; return EXIT_SUCCESS; } 我想将此算法改成遍历文件夹应该怎么写

2023-07-20 上传