+ fix issues with angle constraints
This commit is contained in:
parent
da4f1bda47
commit
81bfcc8717
|
@ -23,7 +23,9 @@
|
||||||
|
|
||||||
#include "PreCompiled.h"
|
#include "PreCompiled.h"
|
||||||
#ifndef _PreComp_
|
#ifndef _PreComp_
|
||||||
|
# include <cfloat>
|
||||||
# include <QMessageBox>
|
# include <QMessageBox>
|
||||||
|
# include <Precision.hxx>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <App/Application.h>
|
#include <App/Application.h>
|
||||||
|
@ -1562,8 +1564,8 @@ void CmdSketcherConstrainAngle::activated(int iMsg)
|
||||||
Base::Vector3d p1b = lineSeg1->getEndPoint();
|
Base::Vector3d p1b = lineSeg1->getEndPoint();
|
||||||
Base::Vector3d p2a = lineSeg2->getStartPoint();
|
Base::Vector3d p2a = lineSeg2->getStartPoint();
|
||||||
Base::Vector3d p2b = lineSeg2->getEndPoint();
|
Base::Vector3d p2b = lineSeg2->getEndPoint();
|
||||||
double length = 1e10;
|
double length = DBL_MAX;
|
||||||
for (int i=0; i <= 1; i++)
|
for (int i=0; i <= 1; i++) {
|
||||||
for (int j=0; j <= 1; j++) {
|
for (int j=0; j <= 1; j++) {
|
||||||
double tmp = ((j?p2a:p2b)-(i?p1a:p1b)).Length();
|
double tmp = ((j?p2a:p2b)-(i?p1a:p1b)).Length();
|
||||||
if (tmp < length) {
|
if (tmp < length) {
|
||||||
|
@ -1572,12 +1574,24 @@ void CmdSketcherConstrainAngle::activated(int iMsg)
|
||||||
PosId2 = j ? Sketcher::start : Sketcher::end;
|
PosId2 = j ? Sketcher::start : Sketcher::end;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Base::Vector3d dir1 = ((PosId1 == Sketcher::start) ? 1. : -1.) *
|
Base::Vector3d dir1 = ((PosId1 == Sketcher::start) ? 1. : -1.) *
|
||||||
(lineSeg1->getEndPoint()-lineSeg1->getStartPoint());
|
(lineSeg1->getEndPoint()-lineSeg1->getStartPoint());
|
||||||
Base::Vector3d dir2 = ((PosId2 == Sketcher::start) ? 1. : -1.) *
|
Base::Vector3d dir2 = ((PosId2 == Sketcher::start) ? 1. : -1.) *
|
||||||
(lineSeg2->getEndPoint()-lineSeg2->getStartPoint());
|
(lineSeg2->getEndPoint()-lineSeg2->getStartPoint());
|
||||||
|
|
||||||
|
// check if the two lines are parallel, in this case an angle is not possible
|
||||||
|
Base::Vector3d dir3 = dir1 % dir2;
|
||||||
|
if (dir3.Length() < Precision::Intersection()) {
|
||||||
|
Base::Vector3d dist = (p1a - p2a) % dir1;
|
||||||
|
if (dist.Sqr() > Precision::Intersection()) {
|
||||||
|
QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Parallel lines"),
|
||||||
|
QObject::tr("An angle constraint cannot be set for two parallel lines."));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
double ActAngle = atan2(-dir1.y*dir2.x+dir1.x*dir2.y,
|
double ActAngle = atan2(-dir1.y*dir2.x+dir1.x*dir2.y,
|
||||||
dir1.x*dir2.x+dir1.y*dir2.y);
|
dir1.x*dir2.x+dir1.y*dir2.y);
|
||||||
if (ActAngle < 0) {
|
if (ActAngle < 0) {
|
||||||
|
|
|
@ -441,7 +441,7 @@ void SoDatumLabel::GLRender(SoGLRenderAction * action)
|
||||||
|
|
||||||
SbVec2s size;
|
SbVec2s size;
|
||||||
int nc;
|
int nc;
|
||||||
int srcw, srch;
|
int srcw=1, srch=1;
|
||||||
|
|
||||||
if (hasText) {
|
if (hasText) {
|
||||||
if (!this->glimagevalid) {
|
if (!this->glimagevalid) {
|
||||||
|
|
|
@ -2661,13 +2661,32 @@ Restart:
|
||||||
// line-line intersection
|
// line-line intersection
|
||||||
{
|
{
|
||||||
double det = dir1.x*dir2.y - dir1.y*dir2.x;
|
double det = dir1.x*dir2.y - dir1.y*dir2.x;
|
||||||
if ((det > 0 ? det : -det) < 1e-10)
|
if ((det > 0 ? det : -det) < 1e-10) {
|
||||||
break;
|
// lines are coincident (or parallel) and in this case the center
|
||||||
double c1 = dir1.y*pnt1.x - dir1.x*pnt1.y;
|
// of the point pairs with the shortest distance is used
|
||||||
double c2 = dir2.y*pnt2.x - dir2.x*pnt2.y;
|
Base::Vector3d p1[2], p2[2];
|
||||||
double x = (dir1.x*c2 - dir2.x*c1)/det;
|
p1[0] = lineSeg1->getStartPoint();
|
||||||
double y = (dir1.y*c2 - dir2.y*c1)/det;
|
p1[1] = lineSeg1->getEndPoint();
|
||||||
p0 = SbVec3f(x,y,0);
|
p2[0] = lineSeg2->getStartPoint();
|
||||||
|
p2[1] = lineSeg2->getEndPoint();
|
||||||
|
double length = DBL_MAX;
|
||||||
|
for (int i=0; i <= 1; i++) {
|
||||||
|
for (int j=0; j <= 1; j++) {
|
||||||
|
double tmp = (p2[j]-p1[i]).Length();
|
||||||
|
if (tmp < length) {
|
||||||
|
length = tmp;
|
||||||
|
p0.setValue((p2[j].x+p1[i].x)/2,(p2[j].y+p1[i].y)/2,0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
double c1 = dir1.y*pnt1.x - dir1.x*pnt1.y;
|
||||||
|
double c2 = dir2.y*pnt2.x - dir2.x*pnt2.y;
|
||||||
|
double x = (dir1.x*c2 - dir2.x*c1)/det;
|
||||||
|
double y = (dir1.y*c2 - dir2.y*c1)/det;
|
||||||
|
p0 = SbVec3f(x,y,0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
startangle = atan2(dir1.y,dir1.x);
|
startangle = atan2(dir1.y,dir1.x);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user