int SpaceBoxPointWcs(double dMinPoint[3], double dMaxPoint[3], vector<Point3d> vecPoint, double dWcsXVec[3], double dWcsYVec[3])
{
try
{
if (vecPoint.size() < 2)
{
return 0;
}
double dWcsZVec[3] = { 0.0 };
UF_VEC3_cross(dWcsXVec, dWcsYVec, dWcsZVec);
dMinPoint[0] = vecPoint[0].X;
dMinPoint[1] = vecPoint[0].Y;
dMinPoint[2] = vecPoint[0].Z;
dMaxPoint[0] = vecPoint[1].X;
dMaxPoint[1] = vecPoint[1].Y;
dMaxPoint[2] = vecPoint[1].Z;
/*double dDistX = 0.0;
double dDistY = 0.0;
double dDistZ = 0.0;
UF_VEC3_distance_to_plane(dMinPoint, dMaxPoint, dWcsXVec, 0.001, &dDistX);
UF_VEC3_distance_to_plane(dMinPoint, dMaxPoint, dWcsYVec, 0.001, &dDistY);
UF_VEC3_distance_to_plane(dMinPoint, dMaxPoint, dWcsZVec, 0.001, &dDistZ);
if (dDistX < 0.0 || dDistY < 0.0 || dDistZ < 0.0)
{
double dPointTmp[3] = { 0.0 };
UF_VEC3_copy(dMinPoint, dPointTmp);
UF_VEC3_copy(dMaxPoint, dMinPoint);
UF_VEC3_copy(dPointTmp, dMinPoint);
}*/
for (int i = 0; i < vecPoint.size(); i++)
{
double dPointTmp[3] = { vecPoint[i].X, vecPoint[i].Y, vecPoint[i].Z };
double dMinPntDistX = 0.0;
double dMinPntDistY = 0.0;
double dMinPntDistZ = 0.0;
double dMaxPntDistX = 0.0;
double dMaxPntDistY = 0.0;
double dMaxPntDistZ = 0.0;
UF_VEC3_distance_to_plane(dPointTmp, dMinPoint, dWcsXVec, 0.001, &dMinPntDistX);
UF_VEC3_distance_to_plane(dPointTmp, dMinPoint, dWcsYVec, 0.001, &dMinPntDistY);
UF_VEC3_distance_to_plane(dPointTmp, dMinPoint, dWcsZVec, 0.001, &dMinPntDistZ);
UF_VEC3_distance_to_plane(dPointTmp, dMaxPoint, dWcsXVec, 0.001, &dMaxPntDistX);
UF_VEC3_distance_to_plane(dPointTmp, dMaxPoint, dWcsYVec, 0.001, &dMaxPntDistY);
UF_VEC3_distance_to_plane(dPointTmp, dMaxPoint, dWcsZVec, 0.001, &dMaxPntDistZ);
if (dMinPntDistX < 0.0)
{
MovePoint(dMinPoint, dMinPoint, dMinPntDistX, dWcsXVec);
}
if (dMinPntDistY < 0.0)
{
MovePoint(dMinPoint, dMinPoint, dMinPntDistY, dWcsYVec);
}
if (dMinPntDistZ < 0.0)
{
MovePoint(dMinPoint, dMinPoint, dMinPntDistZ, dWcsZVec);
}
if (dMaxPntDistX > 0.0)
{
MovePoint(dMaxPoint, dMaxPoint, dMaxPntDistX, dWcsXVec);
}
if (dMaxPntDistY > 0.0)
{
MovePoint(dMaxPoint, dMaxPoint, dMaxPntDistY, dWcsYVec);
}
if (dMaxPntDistZ > 0.0)
{
MovePoint(dMaxPoint, dMaxPoint, dMaxPntDistZ, dWcsZVec);
}
}
return 1;
}
catch (const std::exception&)
{
}
}
NX二次开发获取多个点的最小包容盒
于 2024-05-18 19:48:09 首次发布