首页
/ Delaunator-CPP 项目使用教程

Delaunator-CPP 项目使用教程

2024-08-16 08:45:13作者:侯霆垣

1. 项目的目录结构及介绍

Delaunator-CPP 是一个用于 Delaunay 三角剖分的快速 C++ 库。以下是项目的目录结构及其介绍:

delaunator-cpp/
├── bench/            # 包含性能测试文件
├── cmake/            # CMake 配置文件
├── examples/         # 示例代码
├── generate-reference-triangles/  # 生成参考三角形的工具
├── include/          # 头文件
├── scripts/          # 脚本文件
├── test/             # 测试文件
├── .clang-format     # Clang-format 配置文件
├── .gitignore        # Git 忽略文件配置
├── .travis.yml       # Travis CI 配置文件
├── CMakeLists.txt    # CMake 主配置文件
├── CONTRIBUTING.md   # 贡献指南
├── LICENSE           # 许可证文件
├── Makefile          # Makefile
├── README.md         # 项目说明文档
└── THIRD-PARTY-NOTICES  # 第三方通知文件

2. 项目的启动文件介绍

项目的启动文件通常位于 examples 目录下。以下是一个基本的启动文件示例:

#include <delaunator.hpp>
#include <cstdio>

int main() {
    std::vector<double> coords = { -1, 1, 1, 1, 1, -1, -1, -1 };
    delaunator::Delaunator d(coords);

    for(std::size_t i = 0; i < d.triangles.size(); i += 3) {
        printf(
            "Triangle points: [[%f, %f], [%f, %f], [%f, %f]]\n",
            d.coords[2 * d.triangles[i]],     // tx0
            d.coords[2 * d.triangles[i] + 1], // ty0
            d.coords[2 * d.triangles[i + 1]], // tx1
            d.coords[2 * d.triangles[i + 1] + 1], // ty1
            d.coords[2 * d.triangles[i + 2]], // tx2
            d.coords[2 * d.triangles[i + 2] + 1]  // ty2
        );
    }
}

3. 项目的配置文件介绍

项目的配置文件主要包括 CMakeLists.txt.clang-format

CMakeLists.txt

CMakeLists.txt 是 CMake 的主配置文件,用于配置项目的构建过程。以下是部分内容示例:

cmake_minimum_required(VERSION 3.1)
project(delaunator-cpp)

set(CMAKE_CXX_STANDARD 11)

include_directories(include)

add_subdirectory(bench)
add_subdirectory(examples)
add_subdirectory(test)

add_executable(delaunator-example examples/basic.cpp)
target_link_libraries(delaunator-example delaunator)

.clang-format

.clang-format 文件用于配置 Clang-format 的代码格式化规则。以下是部分内容示例:

BasedOnStyle: LLVM
IndentWidth: 4
ColumnLimit: 120

以上是 Delaunator-CPP 项目的基本使用教程,涵盖了项目的目录结构、启动文件和配置文件的介绍。希望对您有所帮助。

登录后查看全文

项目优选

收起
Cangjie-ExamplesCangjie-Examples
本仓将收集和展示高质量的仓颉示例代码,欢迎大家投稿,让全世界看到您的妙趣设计,也让更多人通过您的编码理解和喜爱仓颉语言。
Cangjie
295
1 K
RuoYi-Vue3RuoYi-Vue3
🎉 (RuoYi)官方仓库 基于SpringBoot,Spring Security,JWT,Vue3 & Vite、Element Plus 的前后端分离权限管理系统
Vue
503
397
leetcodeleetcode
🔥LeetCode solutions in any programming language | 多种编程语言实现 LeetCode、《剑指 Offer(第 2 版)》、《程序员面试金典(第 6 版)》题解
Java
51
15
ohos_react_nativeohos_react_native
React Native鸿蒙化仓库
C++
114
199
openGauss-serveropenGauss-server
openGauss kernel ~ openGauss is an open source relational database management system
C++
61
144
openHiTLSopenHiTLS
旨在打造算法先进、性能卓越、高效敏捷、安全可靠的密码套件,通过轻量级、可剪裁的软件技术架构满足各行业不同场景的多样化要求,让密码技术应用更简单,同时探索后量子等先进算法创新实践,构建密码前沿技术底座!
C
97
251
HarmonyOS-ExamplesHarmonyOS-Examples
本仓将收集和展示仓颉鸿蒙应用示例代码,欢迎大家投稿,在仓颉鸿蒙社区展现你的妙趣设计!
Cangjie
357
342
CangjieMagicCangjieMagic
基于仓颉编程语言构建的 LLM Agent 开发框架,其主要特点包括:Agent DSL、支持 MCP 协议,支持模块化调用,支持任务智能规划。
Cangjie
581
41
cherry-studiocherry-studio
🍒 Cherry Studio 是一款支持多个 LLM 提供商的桌面客户端
TypeScript
377
37
杨帆测试平台杨帆测试平台
扬帆测试平台是一款高效、可靠的自动化测试平台,旨在帮助团队提升测试效率、降低测试成本。该平台包括用例管理、定时任务、执行记录等功能模块,支持多种类型的测试用例,目前支持API(http和grpc协议)、性能、CI调用等功能,并且可定制化,灵活满足不同场景的需求。 其中,支持批量执行、并发执行等高级功能。通过用例设置,可以设置用例的基本信息、运行配置、环境变量等,灵活控制用例的执行。
JavaScript
21
2