diff --git a/CMakeLists.txt b/CMakeLists.txt index a1d9083..6f878c2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -6,7 +6,7 @@ cmake_minimum_required(VERSION 3.16) #------------REQUIRED_2 指定项目名及项目版本------------# project( - WireRouting # 项目名称没有什么特别的用处。这里没有添加任何的目标(target) + WireRoutingProject # 项目名称没有什么特别的用处。这里没有添加任何的目标(target) VERSION 1.0 DESCRIPTION "A project for wire routing" # CMake 3.9+ 特性 # 语言可以是 C,CXX,Fortran,ASM,CUDA(CMake 3.8+),CSharp(3.8+),SWIFT(CMake 3.15+ experimental) @@ -42,6 +42,7 @@ elseif (WIN32) list(PREPEND CMAKE_PREFIX_PATH D:/SOURCE/Dependencies) # Windows set(CMAKE_TOOLCHAIN_FILE "D:\\vcpkg\\scripts\\buildsystems\\vcpkg.cmake") # vcpkg include(${CMAKE_TOOLCHAIN_FILE}) + # 指定 CONFIG 模式,查看 /share//cmake/xxxConfig.cmake 文件名决定查找包名 find_package(tinyxml CONFIG REQUIRED) elseif (UNIX) list(PREPEND CMAKE_PREFIX_PATH /home/yony/PROJECTS/Dependencies) # Linux @@ -50,8 +51,6 @@ endif() # 输出 find_package 系统路径和当前指定路径 message(STATUS "CMAKE_SYSTEM_PREFIX_PATH: ${CMAKE_SYSTEM_PREFIX_PATH}") message(STATUS "Self added CMAKE_PREFIX_PATH: ${CMAKE_PREFIX_PATH}") -# 指定 CONFIG 模式,查看 /share//cmake/xxxConfig.cmake 文件名决定查找包名 -# find_package(tinyxml CONFIG REQUIRED) #------------REQUIRED_5.1.2 include 执行.cmake中的ContentFetch模块来引入库------------# # 添加cmake目录到CMAKE_MODULE_PATH,以供 include 方法使用 @@ -63,8 +62,12 @@ message(STATUS "Self added CMAKE_MODULE_PATH: ${CMAKE_MODULE_PATH}") # igl_include(core) # igl_include(core) 默认包含igl::core,此行可注释 # igl_include(glfw) # igl_include_optional(glfw) Enable the target igl::glfw + +add_subdirectory(lib) # 添加子目录,子目录中的CMakeLists.txt将会被执行 + + # 复制DLL文件到可执行文件目录 -file(COPY ${CMAKE_SOURCE_DIR}/lib/VSbuild/x64/Debug/WireRouting_DLL.dll DESTINATION ${PROJECT_BINARY_DIR}/Debug) +# file(COPY ${CMAKE_SOURCE_DIR}/lib/Debug/WireRouting.dll DESTINATION ${PROJECT_BINARY_DIR}/Debug) #------------REQUIRED_3 添加可执行文件------------# @@ -86,7 +89,7 @@ if (WIN32) target_link_libraries( ${PROJECT_NAME} PUBLIC unofficial-tinyxml::unofficial-tinyxml - ${CMAKE_SOURCE_DIR}/lib/VSbuild/x64/Debug/WireRouting_DLL.lib + ${CMAKE_SOURCE_DIR}/lib/Debug/WireRouting.lib ) else() target_link_libraries( diff --git a/WireRouting_DLL.sln b/WireRouting_DLL.sln deleted file mode 100644 index 0cb5948..0000000 --- a/WireRouting_DLL.sln +++ /dev/null @@ -1,31 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio Version 17 -VisualStudioVersion = 17.8.34322.80 -MinimumVisualStudioVersion = 10.0.40219.1 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "WireRouting_DLL", "lib\WireRouting_DLL.vcxproj", "{958F9989-0884-4B91-836A-BCDA97342FCB}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|x64 = Debug|x64 - Debug|x86 = Debug|x86 - Release|x64 = Release|x64 - Release|x86 = Release|x86 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {958F9989-0884-4B91-836A-BCDA97342FCB}.Debug|x64.ActiveCfg = Debug|x64 - {958F9989-0884-4B91-836A-BCDA97342FCB}.Debug|x64.Build.0 = Debug|x64 - {958F9989-0884-4B91-836A-BCDA97342FCB}.Debug|x86.ActiveCfg = Debug|Win32 - {958F9989-0884-4B91-836A-BCDA97342FCB}.Debug|x86.Build.0 = Debug|Win32 - {958F9989-0884-4B91-836A-BCDA97342FCB}.Release|x64.ActiveCfg = Release|x64 - {958F9989-0884-4B91-836A-BCDA97342FCB}.Release|x64.Build.0 = Release|x64 - {958F9989-0884-4B91-836A-BCDA97342FCB}.Release|x86.ActiveCfg = Release|Win32 - {958F9989-0884-4B91-836A-BCDA97342FCB}.Release|x86.Build.0 = Release|Win32 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection - GlobalSection(ExtensibilityGlobals) = postSolution - SolutionGuid = {9AC3C08A-4DBA-4FF9-8DE7-ACE6B546D11B} - EndGlobalSection -EndGlobal diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt new file mode 100644 index 0000000..2256370 --- /dev/null +++ b/lib/CMakeLists.txt @@ -0,0 +1,23 @@ +aux_source_directory(${CMAKE_SOURCE_DIR}/lib/src SRC_FILES_IN_LIB) +message(STATUS "SRC_FILES_IN_LIB: ${SRC_FILES_IN_LIB}") + +add_library(WireRouting SHARED ${SRC_FILES_IN_LIB}) +target_compile_definitions(WireRouting PUBLIC DMY_LIB_SHARED_BUILD) +target_compile_definitions(WireRouting PRIVATE WIREROUTINGDLL_EXPORTS) + +INSTALL(TARGETS WireRouting DESTINATION ${CMAKE_SOURCE_DIR}/lib) + +SET_TARGET_PROPERTIES( + WireRouting PROPERTIES + LINKER_LANGUAGE C + ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/lib + RUNTIME_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/build + LIBRARY_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/lib + OUTPUT_NAME "WireRouting" + PREFIX "" +) + +target_include_directories( + WireRouting PUBLIC + ${CMAKE_SOURCE_DIR}/lib/include +) diff --git a/lib/Debug/WireRouting.exp b/lib/Debug/WireRouting.exp new file mode 100644 index 0000000..1d99ec1 Binary files /dev/null and b/lib/Debug/WireRouting.exp differ diff --git a/lib/Debug/WireRouting.lib b/lib/Debug/WireRouting.lib new file mode 100644 index 0000000..a7453ae Binary files /dev/null and b/lib/Debug/WireRouting.lib differ diff --git a/lib/WireRouting_DLL.vcxproj b/lib/WireRouting_DLL.vcxproj deleted file mode 100644 index d765df7..0000000 --- a/lib/WireRouting_DLL.vcxproj +++ /dev/null @@ -1,194 +0,0 @@ - - - - - Debug - Win32 - - - Release - Win32 - - - Debug - x64 - - - Release - x64 - - - - 17.0 - Win32Proj - {958f9989-0884-4b91-836a-bcda97342fcb} - WireRoutingDLL - 10.0 - - - - DynamicLibrary - true - v143 - Unicode - - - DynamicLibrary - false - v143 - true - Unicode - - - DynamicLibrary - true - v143 - Unicode - - - DynamicLibrary - false - v143 - true - Unicode - - - - - - - - - - - - - - - - - - - - - $(SolutionDir)lib\VSbuild\$(Platform)\$(Configuration)\ - $(SolutionDir)lib\VSbuild\$(Platform)\$(Configuration)\ - $(SolutionDir)lib\include;$(IncludePath) - - - - Level3 - true - WIN32;_DEBUG;WIREROUTINGDLL_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) - true - Use - pch.h - - - Windows - true - false - - - - - Level3 - true - true - true - WIN32;NDEBUG;WIREROUTINGDLL_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) - true - Use - pch.h - - - Windows - true - true - true - false - - - - - Level3 - true - _DEBUG;WIREROUTINGDLL_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) - true - Use - pch.h - - - Windows - true - false - - - - - Level3 - true - true - true - NDEBUG;WIREROUTINGDLL_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) - true - Use - pch.h - - - Windows - true - true - true - false - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Create - Create - Create - Create - - - - - - - - \ No newline at end of file diff --git a/lib/WireRouting_DLL.vcxproj.filters b/lib/WireRouting_DLL.vcxproj.filters deleted file mode 100644 index 3f31ef7..0000000 --- a/lib/WireRouting_DLL.vcxproj.filters +++ /dev/null @@ -1,129 +0,0 @@ - - - - - {4FC737F1-C7A5-4376-A066-2A32D752A2FF} - cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx - - - {93995380-89BD-4b04-88EB-625FBE52EBFB} - h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd - - - {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} - rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms - - - - - 头文件 - - - 头文件 - - - 头文件 - - - 头文件 - - - 头文件 - - - 头文件 - - - 头文件 - - - 头文件 - - - 头文件 - - - 头文件 - - - 头文件 - - - 头文件 - - - 头文件 - - - 头文件 - - - 头文件 - - - 头文件 - - - 头文件 - - - 头文件 - - - - - 源文件 - - - 源文件 - - - 源文件 - - - 源文件 - - - 源文件 - - - 源文件 - - - 源文件 - - - 源文件 - - - 源文件 - - - 源文件 - - - 源文件 - - - 源文件 - - - 源文件 - - - 源文件 - - - 源文件 - - - 源文件 - - - 源文件 - - - 源文件 - - - \ No newline at end of file diff --git a/lib/WireRouting_DLL.vcxproj.user b/lib/WireRouting_DLL.vcxproj.user deleted file mode 100644 index 88a5509..0000000 --- a/lib/WireRouting_DLL.vcxproj.user +++ /dev/null @@ -1,4 +0,0 @@ - - - - \ No newline at end of file diff --git a/lib/dllmain.cpp b/lib/dllmain.cpp deleted file mode 100644 index 5aada3d..0000000 --- a/lib/dllmain.cpp +++ /dev/null @@ -1,17 +0,0 @@ -// dllmain.cpp : 定义 DLL 应用程序的入口点。 -#include "pch.h" - -BOOL APIENTRY DllMain(HMODULE hModule, - DWORD ul_reason_for_call, - LPVOID lpReserved) -{ - switch (ul_reason_for_call) - { - case DLL_PROCESS_ATTACH: - case DLL_THREAD_ATTACH: - case DLL_THREAD_DETACH: - case DLL_PROCESS_DETACH: - break; - } - return TRUE; -} diff --git a/lib/include/framework.h b/lib/include/framework.h deleted file mode 100644 index a71fbd2..0000000 --- a/lib/include/framework.h +++ /dev/null @@ -1,5 +0,0 @@ -#pragma once - -#define WIN32_LEAN_AND_MEAN // 从 Windows 头文件中排除极少使用的内容 -// Windows 头文件 -#include diff --git a/lib/include/pch.h b/lib/include/pch.h deleted file mode 100644 index f4bf08f..0000000 --- a/lib/include/pch.h +++ /dev/null @@ -1,13 +0,0 @@ -// pch.h: 这是预编译标头文件。 -// 下方列出的文件仅编译一次,提高了将来生成的生成性能。 -// 这还将影响 IntelliSense 性能,包括代码完成和许多代码浏览功能。 -// 但是,如果此处列出的文件中的任何一个在生成之间有更新,它们全部都将被重新编译。 -// 请勿在此处添加要频繁更新的文件,这将使得性能优势无效。 - -#ifndef PCH_H -#define PCH_H - -// 添加要在此处预编译的标头 -#include "framework.h" - -#endif // PCH_H diff --git a/lib/pch.cpp b/lib/pch.cpp deleted file mode 100644 index 10b8eaa..0000000 --- a/lib/pch.cpp +++ /dev/null @@ -1,5 +0,0 @@ -// pch.cpp: 与预编译标头对应的源文件 - -#include "pch.h" - -// 当使用预编译的头时,需要使用此源文件,编译才能成功。 diff --git a/lib/Astar.cpp b/lib/src/Astar.cpp similarity index 99% rename from lib/Astar.cpp rename to lib/src/Astar.cpp index 52d4d30..715c9f7 100644 --- a/lib/Astar.cpp +++ b/lib/src/Astar.cpp @@ -1,4 +1,3 @@ -#include "pch.h" // use stdafx.h in Visual Studio 2017 and earlier #include "Astar.h" Astar astar; diff --git a/lib/BVH.cpp b/lib/src/BVH.cpp similarity index 98% rename from lib/BVH.cpp rename to lib/src/BVH.cpp index 2179234..f4649c6 100644 --- a/lib/BVH.cpp +++ b/lib/src/BVH.cpp @@ -1,4 +1,4 @@ -#include "pch.h" // use stdafx.h in Visual Studio 2017 and earlier + #include "BVH.h" BVH bvh; diff --git a/lib/BasicChannel.cpp b/lib/src/BasicChannel.cpp similarity index 99% rename from lib/BasicChannel.cpp rename to lib/src/BasicChannel.cpp index 2bf2f9b..9e552e8 100644 --- a/lib/BasicChannel.cpp +++ b/lib/src/BasicChannel.cpp @@ -1,4 +1,4 @@ -#include "pch.h" // use stdafx.h in Visual Studio 2017 and earlier + #include "BasicChannel.h" BasicChannel basicChannel; diff --git a/lib/BasicEdge.cpp b/lib/src/BasicEdge.cpp similarity index 99% rename from lib/BasicEdge.cpp rename to lib/src/BasicEdge.cpp index b5068b0..bb936ce 100644 --- a/lib/BasicEdge.cpp +++ b/lib/src/BasicEdge.cpp @@ -1,4 +1,4 @@ -#include "pch.h" // use stdafx.h in Visual Studio 2017 and earlier + #include "BasicEdge.h" BasicEdge basicEdge; diff --git a/lib/BranchPoint.cpp b/lib/src/BranchPoint.cpp similarity index 98% rename from lib/BranchPoint.cpp rename to lib/src/BranchPoint.cpp index afd362e..1f684f6 100644 --- a/lib/BranchPoint.cpp +++ b/lib/src/BranchPoint.cpp @@ -1,4 +1,4 @@ -#include "pch.h" // use stdafx.h in Visual Studio 2017 and earlier + #include "BranchPoint.h" BranchPointSet branchPointSet; diff --git a/lib/BranchTree.cpp b/lib/src/BranchTree.cpp similarity index 98% rename from lib/BranchTree.cpp rename to lib/src/BranchTree.cpp index d7080cc..0146449 100644 --- a/lib/BranchTree.cpp +++ b/lib/src/BranchTree.cpp @@ -1,4 +1,4 @@ -#include "pch.h" // use stdafx.h in Visual Studio 2017 and earlier + #include "BranchTree.h" BranchTree branchTree; diff --git a/lib/Bundle.cpp b/lib/src/Bundle.cpp similarity index 98% rename from lib/Bundle.cpp rename to lib/src/Bundle.cpp index 902388b..6e83bc2 100644 --- a/lib/Bundle.cpp +++ b/lib/src/Bundle.cpp @@ -1,4 +1,4 @@ -#include "pch.h" // use stdafx.h in Visual Studio 2017 and earlier + #include "Bundle.h" BundleNode bdNode[MAXPointNum]; diff --git a/lib/Clip.cpp b/lib/src/Clip.cpp similarity index 98% rename from lib/Clip.cpp rename to lib/src/Clip.cpp index e714f46..38840e5 100644 --- a/lib/Clip.cpp +++ b/lib/src/Clip.cpp @@ -1,4 +1,4 @@ -#include "pch.h" // use stdafx.h in Visual Studio 2017 and earlier + #include "Clip.h" ClipSet clipSet; diff --git a/lib/Connector.cpp b/lib/src/Connector.cpp similarity index 64% rename from lib/Connector.cpp rename to lib/src/Connector.cpp index 7f793ea..a5f939d 100644 --- a/lib/Connector.cpp +++ b/lib/src/Connector.cpp @@ -1,4 +1,4 @@ -#include "pch.h" // use stdafx.h in Visual Studio 2017 and earlier + #include "Connector.h" Connector connectors[M]; diff --git a/lib/Const.cpp b/lib/src/Const.cpp similarity index 72% rename from lib/Const.cpp rename to lib/src/Const.cpp index 896917b..68d7a52 100644 --- a/lib/Const.cpp +++ b/lib/src/Const.cpp @@ -1,4 +1,3 @@ -#include "pch.h" // use stdafx.h in Visual Studio 2017 and earlier #include "Const.h" double MAXX = -1e9, MINX = 1e9, MAXY = -1e9, MINY = 1e9, MAXZ = -1e9, MINZ = 1e9; // 卡箍的坐标范围 diff --git a/lib/Geometry.cpp b/lib/src/Geometry.cpp similarity index 91% rename from lib/Geometry.cpp rename to lib/src/Geometry.cpp index 285ca67..bd7c6c8 100644 --- a/lib/Geometry.cpp +++ b/lib/src/Geometry.cpp @@ -1,4 +1,4 @@ -#include "pch.h" // use stdafx.h in Visual Studio 2017 and earlier + #include "Geometry.h" vector vertices; diff --git a/lib/Intersection.cpp b/lib/src/Intersection.cpp similarity index 98% rename from lib/Intersection.cpp rename to lib/src/Intersection.cpp index 77f3fd2..3a3f443 100644 --- a/lib/Intersection.cpp +++ b/lib/src/Intersection.cpp @@ -1,4 +1,4 @@ -#include "pch.h" // use stdafx.h in Visual Studio 2017 and earlier + #include "Intersection.h" TriangleSegmentIntersectRes::TriangleSegmentIntersectRes(bool h, float tt) : hit(h), t(tt) {} // VS2008 diff --git a/lib/KDtree.cpp b/lib/src/KDtree.cpp similarity index 98% rename from lib/KDtree.cpp rename to lib/src/KDtree.cpp index 0560cca..a5f390e 100644 --- a/lib/KDtree.cpp +++ b/lib/src/KDtree.cpp @@ -1,4 +1,4 @@ -#include "pch.h" // use stdafx.h in Visual Studio 2017 and earlier + #include "KDtree.h" KDtree kdtree; diff --git a/lib/Path.cpp b/lib/src/Path.cpp similarity index 96% rename from lib/Path.cpp rename to lib/src/Path.cpp index b07978d..1dddfbf 100644 --- a/lib/Path.cpp +++ b/lib/src/Path.cpp @@ -1,4 +1,4 @@ -#include "pch.h" // use stdafx.h in Visual Studio 2017 and earlier + #include "Path.h" diff --git a/lib/Point.cpp b/lib/src/Point.cpp similarity index 95% rename from lib/Point.cpp rename to lib/src/Point.cpp index 0607a3d..c9b2a94 100644 --- a/lib/Point.cpp +++ b/lib/src/Point.cpp @@ -1,4 +1,4 @@ -#include "pch.h" // use stdafx.h in Visual Studio 2017 and earlier + #include "Point.h" const double eps = 1e-6; diff --git a/lib/ReadXML.cpp b/lib/src/ReadXML.cpp similarity index 99% rename from lib/ReadXML.cpp rename to lib/src/ReadXML.cpp index 46c2394..8b17596 100644 --- a/lib/ReadXML.cpp +++ b/lib/src/ReadXML.cpp @@ -1,4 +1,4 @@ -#include "pch.h" // use stdafx.h in Visual Studio 2017 and earlier + #include "ReadXML.h" string ini = "--"; diff --git a/readme.md b/readme.md new file mode 100644 index 0000000..f378d86 --- /dev/null +++ b/readme.md @@ -0,0 +1,76 @@ +## 项目结构 + +``` +. +│ CMakeLists.txt \\CMake构建配置文件 +│ config.h.in +│ readme.md +├─data +│ ├─demo +│ │ └─ ... +│ └─Tinyroute_test +│ │ connector.csv \\连接器数据 +│ │ result_ALL.txt \\当前数据与参数下应运行出的结果数据 +│ ├─clip2 +│ │ clips_with_dir.xml \\空间中卡箍点集数据 +│ ├─OBJ +│ │ cangti_correct.obj \\输入模型 +│ └─wirexml \\ 连接器间连接关系 +│ 1START_END.xml +│ 2NEAR_END.xml +│ 3NEAR_START.xml +├─include +│ read_xml.h +│ +├─lib \\所用运行库 +│ │ tinyxml.lib +│ │ WireRouting_DLL.dll +│ │ WireRouting_DLL.lib +│ │ +│ └─include \\库相关头文件 +│ Astar.h +│ BasicChannel.h +│ BasicEdge.h +| ... +│ +└─src \\编译目标源文件 + xmlsql.cpp +``` + + + +## 运行环境配置 + +- CMake配置 + - 确认Cmake已安装: [Download CMake](https://cmake.org/download/#latest) + - 添加**cmake.exe**至环境变量 +- 确认编译器已安装,如VS2022、VS2019等环境 + +## 使用CMake构建项目 + +``` +# 进入项目目录 +cd + +# Standard CMake build +# 注意项目所用链接库均为 Debug x64 编译,构建务必使用同规格 +cmake -S . -B build -T host=x64 -A x64 +cmake --build build --config Debug --target ALL_BUILD -j 14 + +``` + +## 运行 + +``` +# 进入可执行文件所在目录 +cd \build\Debug + +# 运行 +.\WireRouting.exe createTinyroute "..\\..\\data\\Tinyroute_test\\clip2" "..\\..\\data\\Tinyroute_test\\wirexml" "..\\..\\data\\Tinyroute_test\\connector.csv" "..\\..\\data\\Tinyroute_test\\OBJ" output +``` + +## 查看结果 + +> 在 **\build\Debug\output_ALL.txt** 目录下查看输出文件 +> +> 可与 **\data\Tinyroute_test\result_ALL.txt** 比较结果 \ No newline at end of file