[TD]fix V2E DistanceX,Y

This commit is contained in:
wandererfan
2020-08-29 19:39:51 -04:00
committed by WandererFan
parent 5b1343f5a9
commit 247a74d73d

View File

@@ -33,6 +33,7 @@
#include <BRepBuilderAPI_MakeVertex.hxx>
#include <BRepBuilderAPI_MakeEdge.hxx>
#include <BRepExtrema_DistShapeShape.hxx>
#include <BRepBndLib.hxx>
#include <gp_Pnt.hxx>
#include <TopoDS_Shape.hxx>
#include <TopoDS_Edge.hxx>
@@ -885,7 +886,6 @@ pointPair DrawViewDimension::getPointsEdgeVert()
// Base::Console().Message("DVD::getPointsEdgeVert() - %s\n",getNameInDocument());
pointPair result;
const std::vector<std::string> &subElements = References2D.getSubValues();
int idx0 = DrawUtil::getIndexFromName(subElements[0]);
int idx1 = DrawUtil::getIndexFromName(subElements[1]);
TechDraw::BaseGeom* e;
@@ -902,7 +902,29 @@ pointPair DrawViewDimension::getPointsEdgeVert()
Base::Console().Error("Error: DVD - %s - 2D references are corrupt (4)\n",getNameInDocument());
return result;
}
result = closestPoints(e->occEdge,v->occVertex);
// if DistanceX or DistanceY, needs to be closest horizontal or vertical extent of edge
// for Distance the perpendicular distance if fine.
Bnd_Box edgeBox;
BRepBndLib::Add(e->occEdge, edgeBox);
edgeBox.SetGap(0.0);
double minX, minY, minZ, maxX, maxY, maxZ;
edgeBox.Get(minX, minY, minZ, maxX, maxY, maxZ);
gp_Pnt pnt = BRep_Tool::Pnt(v->occVertex);
if (Type.isValue("DistanceX") ) {
gp_Pnt p0(pnt.X(), minY, 0.0);
gp_Pnt p1(pnt.X(), maxY, 0.0);
TopoDS_Edge boundary = BRepBuilderAPI_MakeEdge(p0, p1);
result = closestPoints(e->occEdge, boundary);
} else if (Type.isValue("DistanceY") ) {
gp_Pnt p0(minX, pnt.Y(), 0.0);
gp_Pnt p1(maxX, pnt.Y(), 0.0);
TopoDS_Edge boundary = BRepBuilderAPI_MakeEdge(p0, p1);
result = closestPoints(e->occEdge, boundary);
} else {
result = closestPoints(e->occEdge,v->occVertex);
}
return result;
}