Improve readability of DrawUtil.cpp

This commit is contained in:
Benjamin Bræstrup Sayoc
2023-03-31 01:49:11 +02:00
committed by WandererFan
parent 9bb92be8ba
commit 5329cede7f

View File

@@ -137,10 +137,7 @@ bool DrawUtil::isSamePoint(TopoDS_Vertex v1, TopoDS_Vertex v2, double tolerance)
{
gp_Pnt p1 = BRep_Tool::Pnt(v1);
gp_Pnt p2 = BRep_Tool::Pnt(v2);
if (p1.IsEqual(p2, tolerance)) {
return true;
}
return false;
return p1.IsEqual(p2, tolerance);
}
bool DrawUtil::isZeroEdge(TopoDS_Edge e, double tolerance)
@@ -264,27 +261,18 @@ double DrawUtil::incidenceAngleAtVertex(TopoDS_Edge e, TopoDS_Vertex v, double t
bool DrawUtil::isFirstVert(TopoDS_Edge e, TopoDS_Vertex v, double tolerance)
{
TopoDS_Vertex first = TopExp::FirstVertex(e);
if (isSamePoint(first, v, tolerance)) {
return true;
}
return false;
return isSamePoint(first, v, tolerance);
}
bool DrawUtil::isLastVert(TopoDS_Edge e, TopoDS_Vertex v, double tolerance)
{
TopoDS_Vertex last = TopExp::LastVertex(e);
if (isSamePoint(last, v, tolerance)) {
return true;
}
return false;
return isSamePoint(last, v, tolerance);
}
bool DrawUtil::fpCompare(const double& d1, const double& d2, double tolerance)
{
if (std::fabs(d1 - d2) < tolerance) {
return true;
}
return false;
return std::fabs(d1 - d2) < tolerance;
}
//brute force intersection points of line(point, dir) with box(xRange, yRange)
@@ -600,10 +588,7 @@ bool DrawUtil::checkParallel(const Base::Vector3d v1, Base::Vector3d v2, double
{
double dot = fabs(v1.Dot(v2));
double mag = v1.Length() * v2.Length();
if (DrawUtil::fpCompare(dot, mag, tolerance)) {
return true;
}
return false;
return DrawUtil::fpCompare(dot, mag, tolerance);
}
//! rotate vector by angle radians around axis through org
@@ -1197,8 +1182,8 @@ std::list<TopoDS_Edge> DrawUtil::sort_Edges(double tol3d, std::list<TopoDS_Edge>
}
}
if ((itEdgePoint == edge_points.end())
|| (gpChainLast.SquareDistance(gpChainFirst) <= tol3d)) {
if (itEdgePoint == edge_points.end()
|| gpChainLast.SquareDistance(gpChainFirst) <= tol3d) {
// no adjacent edge found or polyline is closed
return sorted;
}
@@ -1245,7 +1230,7 @@ double DrawUtil::angleDifference(double fi1, double fi2, bool reflex)
fi1 -= fi2;
if (((fi1 > +M_PI) || (fi1 <= -M_PI)) != reflex) {
if ((fi1 > +M_PI || fi1 <= -M_PI) != reflex) {
fi1 += fi1 > 0.0 ? -M_2PI : +M_2PI;
}