In @routenodes.cpp , implement lineRectOverlap --- Content from referenced files ---…
- User
In @routenodes.cpp , implement
lineRectOverlap--- Content from referenced files --- Content from @C:\routenodes\routenodes.cpp: #include "routenodes.hpp"#include #include
namespace routenodes {
const float FloatTolerance = 1e-7f;
// 两个浮点数是否在浮点误差内相等 bool isClose(float a, float b) { return std::abs(a - b) < FloatTolerance; }
// 两个模块的距离是否小于两者的余量之和 bool rectOverlap(const CompPartInfo& a, const CompPartInfo& b) { if (a.pos.x + a.width + a.margin < b.pos.x - b.margin) { return false; }
codeif (a.pos.x - a.margin > b.pos.x + b.width + b.margin) { return false; } if (a.pos.y + a.height + a.margin < b.pos.y - b.margin) { return false; } if (a.pos.y - a.margin > b.pos.y + b.height + b.margin) { return false; } return true;}
// 线段与模块的距离是否小于余量 // 已知线段一定是水平或竖直 bool lineRectOverlap(const CustomPoint& a, const CustomPoint& b, const CompPartInfo& comp) { // TODO }
// 检验画布中已有的模块与路径是否合理 bool validateCanvas(const CompAndCanvasInfo& wsg) { bool ok = true;
code Assistant
Okay, I will implement the
lineRectOverlapfunction inroutenodes.cpp.First, I'll add the necessary include for
std::minandstd::max.Assistant
Now, I will implement the
lineRectOverlapfunction.Assistant
I have implemented the
lineRectOverlapfunction inC:\routenodes\routenodes.cppas requested.