cleanup: remove dead code in cam_advanced.cpp (clamp_angle, unused ray_cast overload, build_contour_at_z)
Build & Test / build-and-test (push) Canceled after 0s
VDE Build & Test / build-and-test (push) Canceled after 0s
Build & Test / python-bindings (push) Canceled after 0s

This commit is contained in:
hm
2026-08-05 13:37:34 +08:00
parent b5954c467d
commit d40bf9268d
-53
View File
@@ -31,13 +31,6 @@ inline double dist(const Point3D& a, const Point3D& b) {
return (a - b).norm();
}
/// 夹紧角度到 [0, 180]
double clamp_angle(double a) {
while (a > 180.0) a -= 360.0;
while (a < 0.0) a += 360.0;
return a;
}
/// 判断 AABB 是否相交(含膨胀)
bool aabb_intersect_expanded(
const Point3D& min1, const Point3D& max1,
@@ -58,32 +51,6 @@ void get_model_aabb(const brep::BrepModel& body, Point3D& bmin, Point3D& bmax) {
bmax = bb.max();
}
/// 射线投射:统计从点沿X+方向穿过的面数
void model_ray_cast(const brep::BrepModel& body, const Point3D& origin, int& hits) {
hits = 0;
auto mesh = body.to_mesh();
Vector3D dir(1, 0, 0);
for (size_t fi = 0; fi < mesh.num_faces(); ++fi) {
auto verts = mesh.face_vertices(static_cast<int>(fi));
if (verts.size() < 3) continue;
auto v0 = mesh.vertex(verts[0]), v1 = mesh.vertex(verts[1]), v2 = mesh.vertex(verts[2]);
// Simple ray-triangle intersection
auto e1 = v1 - v0, e2 = v2 - v0;
auto pvec = dir.cross(e2);
double det = e1.dot(pvec);
if (std::abs(det) < 1e-12) continue;
double inv_det = 1.0 / det;
auto tvec = origin - v0;
double u = tvec.dot(pvec) * inv_det;
if (u < 0.0 || u > 1.0) continue;
auto qvec = tvec.cross(e1);
double v = dir.dot(qvec) * inv_det;
if (v < 0.0 || u + v > 1.0) continue;
double t = e2.dot(qvec) * inv_det;
if (t > 1e-9) hits++;
}
}
/// 模型与射线求交
bool model_ray_cast(const brep::BrepModel& body,
const Point3D& origin, const Vector3D& dir,
@@ -116,26 +83,6 @@ bool model_ray_cast(const brep::BrepModel& body,
return hit;
}
/// 在 Z 高度构建二维轮廓
void build_contour_at_z(const brep::BrepModel& body, double z,
std::vector<Point2D>& contour) {
// 简化:使用包围盒在 Z 处的截面
Point3D bmin, bmax;
get_model_aabb(body, bmin, bmax);
if (z < bmin.z() || z > bmax.z()) return;
double margin = 2.0;
double x0 = bmin.x() - margin;
double y0 = bmin.y() - margin;
double x1 = bmax.x() + margin;
double y1 = bmax.y() + margin;
contour = {
Point2D(x0, y0), Point2D(x1, y0),
Point2D(x1, y1), Point2D(x0, y1)
};
}
} // anonymous namespace
// ═══════════════════════════════════════════════════════════════════════════