[TechDraw] Use templates instead of duplicate code: toGp

This commit is contained in:
Benjamin Bræstrup Sayoc
2024-10-08 00:35:25 +02:00
parent 20ac96f4c8
commit 1d7e7c86a0
13 changed files with 63 additions and 76 deletions

View File

@@ -1131,8 +1131,8 @@ arcPoints DrawViewDimension::arcPointsFromEdge(TopoDS_Edge occEdge)
if (pts.isArc) {
// part of circle
gp_Ax1 axis = circle.Axis();
gp_Vec startVec = DrawUtil::togp_Vec(pts.arcEnds.first() - pts.center);
gp_Vec endVec = DrawUtil::togp_Vec(pts.arcEnds.second() - pts.center);
gp_Vec startVec = DrawUtil::to<gp_Vec>(pts.arcEnds.first() - pts.center);
gp_Vec endVec = DrawUtil::to<gp_Vec>(pts.arcEnds.second() - pts.center);
double angle = startVec.AngleWithRef(endVec, axis.Direction().XYZ());
pts.arcCW = (angle < 0.0);
}
@@ -1151,8 +1151,8 @@ arcPoints DrawViewDimension::arcPointsFromEdge(TopoDS_Edge occEdge)
if (pts.isArc) {
// part of ellipse
gp_Ax1 axis = ellipse.Axis();
gp_Vec startVec = DrawUtil::togp_Vec(pts.arcEnds.first() - pts.center);
gp_Vec endVec = DrawUtil::togp_Vec(pts.arcEnds.second() - pts.center);
gp_Vec startVec = DrawUtil::to<gp_Vec>(pts.arcEnds.first() - pts.center);
gp_Vec endVec = DrawUtil::to<gp_Vec>(pts.arcEnds.second() - pts.center);
double angle = startVec.AngleWithRef(endVec, axis.Direction().XYZ());
pts.arcCW = (angle < 0.0);
}
@@ -1180,8 +1180,8 @@ arcPoints DrawViewDimension::arcPointsFromEdge(TopoDS_Edge occEdge)
if (pts.isArc) {
// part of circle
gp_Ax1 axis = circle.Axis();
gp_Vec startVec = DrawUtil::togp_Vec(pts.arcEnds.first() - pts.center);
gp_Vec endVec = DrawUtil::togp_Vec(pts.arcEnds.second() - pts.center);
gp_Vec startVec = DrawUtil::to<gp_Vec>(pts.arcEnds.first() - pts.center);
gp_Vec endVec = DrawUtil::to<gp_Vec>(pts.arcEnds.second() - pts.center);
double angle = startVec.AngleWithRef(endVec, axis.Direction().XYZ());
pts.arcCW = (angle < 0.0);
}
@@ -1317,7 +1317,7 @@ anglePoints DrawViewDimension::getAnglePointsTwoEdges(ReferenceVector references
if (!haveIntersection) {
throw Base::RuntimeError("Geometry for 3d angle dimension does not intersect");
}
gp_Pnt gApex = DrawUtil::togp_Pnt(vApex);
gp_Pnt gApex = DrawUtil::to<gp_Pnt>(vApex);
gp_Pnt gFar0 = gEnd0;
if (gStart0.Distance(gApex) > gEnd0.Distance(gApex)) {
@@ -1717,9 +1717,9 @@ double DrawViewDimension::getArcAngle(Base::Vector3d center, Base::Vector3d star
auto leg0 = startPoint - center;
auto leg1 = endPoint - startPoint;
auto referenceDirection = leg0.Cross(leg1);
gp_Ax1 axis{DU::togp_Pnt(center), DU::togp_Vec(referenceDirection)};
gp_Vec startVec = DrawUtil::togp_Vec(leg0);
gp_Vec endVec = DrawUtil::togp_Vec(leg1);
gp_Ax1 axis{DU::to<gp_Pnt>(center), DU::to<gp_Vec>(referenceDirection)};
gp_Vec startVec = DrawUtil::to<gp_Vec>(leg0);
gp_Vec endVec = DrawUtil::to<gp_Vec>(leg1);
double angle = startVec.AngleWithRef(endVec, axis.Direction().XYZ());
return angle;
}