Fix isCircleOrArc usage
This commit is contained in:
committed by
abdullahtahiriyo
parent
b40c2f2491
commit
d4e5c7e966
@@ -4328,11 +4328,10 @@ void CmdSketcherConstrainDistance::activated(int iMsg)
|
||||
|
||||
return;
|
||||
}
|
||||
else if (isCircle(*geom)) {
|
||||
auto circleSeg = static_cast<const Part::GeomCircle*>(geom);
|
||||
Base::Vector3d ct = circleSeg->getCenter();
|
||||
Base::Vector3d d = ct - pnt;
|
||||
double ActDist = std::abs(d.Length() - circleSeg->getRadius());
|
||||
else if (isCircleOrArc(*geom)) { // point to circle distance
|
||||
auto [radius, center] = getRadiusCenterCircleArc(geom);
|
||||
Base::Vector3d d = center - pnt;
|
||||
double ActDist = std::abs(d.Length() - radius);
|
||||
|
||||
openCommand(QT_TRANSLATE_NOOP("Command", "Add point to circle Distance constraint"));
|
||||
Gui::cmdAppObjectArgs(selection[0].getObject(),
|
||||
@@ -4409,17 +4408,15 @@ void CmdSketcherConstrainDistance::activated(int iMsg)
|
||||
|
||||
return;
|
||||
}
|
||||
else if ((isCircle(*geom1) && isLineSegment(*geom2))
|
||||
|| (isLineSegment(*geom1) && isCircle(*geom2))) {// circle to line distance
|
||||
else if ((isCircleOrArc(*geom1) && isLineSegment(*geom2))
|
||||
|| (isLineSegment(*geom1) && isCircleOrArc(*geom2))) {// circle to line distance
|
||||
|
||||
if (isLineSegment(*geom1)) {
|
||||
std::swap(geom1, geom2);// Assume circle is first
|
||||
std::swap(GeoId1, GeoId2);
|
||||
}
|
||||
|
||||
auto circleSeg = static_cast<const Part::GeomCircle*>(geom1);
|
||||
double radius = circleSeg->getRadius();
|
||||
Base::Vector3d center = circleSeg->getCenter();
|
||||
auto [radius, center] = getRadiusCenterCircleArc(geom1);
|
||||
|
||||
auto lineSeg = static_cast<const Part::GeomLineSegment*>(geom2);
|
||||
Base::Vector3d pnt1 = lineSeg->getStartPoint();
|
||||
|
||||
@@ -823,15 +823,16 @@ Restart:
|
||||
pnt2 = geolistfacade.getPoint(Constr->Second, Constr->SecondPos);
|
||||
}
|
||||
else if (Constr->Second != GeoEnum::GeoUndef) {
|
||||
auto geo = geolistfacade.getGeometryFromGeoId(Constr->Second);
|
||||
auto geo1 = geolistfacade.getGeometryFromGeoId(Constr->First);
|
||||
if (isLineSegment(*geo)) {
|
||||
auto geo2 = geolistfacade.getGeometryFromGeoId(Constr->Second);
|
||||
if (isLineSegment(*geo2)) {
|
||||
auto lineSeg = static_cast<const Part::GeomLineSegment*>(geo2);
|
||||
Base::Vector3d l2p1 = lineSeg->getStartPoint();
|
||||
Base::Vector3d l2p2 = lineSeg->getEndPoint();
|
||||
|
||||
if (Constr->SecondPos != Sketcher::PointPos::none) {
|
||||
// point to line distance
|
||||
// NOLINTNEXTLINE
|
||||
auto lineSeg = static_cast<const Part::GeomLineSegment*>(geo);
|
||||
Base::Vector3d l2p1 = lineSeg->getStartPoint();
|
||||
Base::Vector3d l2p2 = lineSeg->getEndPoint();
|
||||
// calculate the projection of p1 onto line2
|
||||
pnt2.ProjectToLine(pnt1 - l2p1, l2p2 - l2p1);
|
||||
pnt2 += pnt1;
|
||||
@@ -839,12 +840,7 @@ Restart:
|
||||
else {
|
||||
if (isCircleOrArc(*geo1)) {
|
||||
// circular to line distance
|
||||
auto lineSeg = static_cast<const Part::GeomLineSegment*>(geo);
|
||||
|
||||
auto [radius, ct] = getRadiusCenterCircleArc(geo1);
|
||||
|
||||
Base::Vector3d l2p1 = lineSeg->getStartPoint();
|
||||
Base::Vector3d l2p2 = lineSeg->getEndPoint();
|
||||
// project on the line translated to origin
|
||||
pnt1.ProjectToLine(ct - l2p1, l2p2 - l2p1);
|
||||
Base::Vector3d dir = pnt1;
|
||||
@@ -854,19 +850,18 @@ Restart:
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (isCircleOrArc(*geo)) {
|
||||
else if (isCircleOrArc(*geo2)) {
|
||||
if (Constr->FirstPos != Sketcher::PointPos::none) {
|
||||
// point to circular distance
|
||||
auto [rad, ct] = getRadiusCenterCircleArc(geo1);
|
||||
auto [rad, ct] = getRadiusCenterCircleArc(geo2);
|
||||
|
||||
pnt1 = geolistfacade.getPoint(Constr->First, Constr->FirstPos);
|
||||
Base::Vector3d v = pnt1 - ct;
|
||||
v = v.Normalize();
|
||||
pnt2 = ct + rad * v;
|
||||
}
|
||||
else if (isCircleOrArc(*geo1)) {
|
||||
// circular to circular distance
|
||||
GetCirclesMinimalDistance(geo1, geo, pnt1, pnt2);
|
||||
GetCirclesMinimalDistance(geo1, geo2, pnt1, pnt2);
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
||||
Reference in New Issue
Block a user