Introduce TSPTunnel struct and implement TSPSolver::solveTunnels
for optimizing tunnel order with support for flipping and start/end points.
Expose the new functionality to Python via pybind11, returning tunnel
dictionaries with flipped status.
src/Mod/CAM/App/tsp_solver.cpp:
- Add solveTunnels implementation for tunnel TSP with flipping and route endpoints
src/Mod/CAM/App/tsp_solver.h:
- Define TSPTunnel struct
- Declare solveTunnels static method in TSPSolver
src/Mod/CAM/App/tsp_solver_pybind.cpp:
- Add Python wrapper for solveTunnels
- Expose solveTunnels to Python with argument parsing and result conversion
- Completely re-implemented the TSP algorithm in C++ for better path quality
- Added detailed comments and documentation to clarify each step
- Improved nearest neighbor, 2-opt, and relocation logic
- Enhanced handling of start/end point constraints
- Updated PathUtils.py docstring to accurately describe start point behavior
- Enhanced the C++ TSP solver to accept optional start and end points, so the route can begin and/or end at the closest point to specified coordinates.
- Updated the Python pybind11 wrapper and PathUtils.sort_locations_tsp to support startPoint and endPoint as named parameters.
- Added a new Python test suite (TestTSPSolver.py) to verify correct handling of start/end points and integration with PathUtils.
- Registered the new test in TestCAMApp.py and CMakeLists.txt for automatic test discovery.
This update introduces a new C++ 2-Opt TSP solver with Python bindings.
src/Mod/CAM/App/CMakeLists.txt:
- Add build and install rules for the new pybind11-based tsp_solver Python module
src/Mod/CAM/App/tsp_solver.cpp:
- Add new C++ implementation of a 2-Opt TSP solver with nearest-neighbor initialization
src/Mod/CAM/App/tsp_solver.h:
- Add TSPPoint struct and TSPSolver class with 2-Opt solve method
src/Mod/CAM/App/tsp_solver_pybind.cpp:
- Add pybind11 wrapper exposing the TSP solver to Python as tsp_solver.solve
src/Mod/CAM/PathScripts/PathUtils.py:
- Add sort_locations_tsp Python wrapper for the C++ TSP solver
- Use tsp_solver.solve for TSP-based