[Sketcher] Do not use TangentViaPoint for tangent-at-knot
This commit is contained in:
committed by
Chris Hennes
parent
389aaeb138
commit
3bccd6686a
@@ -1722,27 +1722,26 @@ int Sketch::addConstraint(const Constraint *constraint)
|
||||
//simple tangency
|
||||
rtn = addTangentConstraint(constraint->First,constraint->Second);
|
||||
}
|
||||
else {
|
||||
else if (constraint->FirstPos == PointPos::start &&
|
||||
constraint->SecondPos == PointPos::none &&
|
||||
constraint->Third == GeoEnum::GeoUndef) {
|
||||
// check for B-Spline Knot to curve tangency
|
||||
if (constraint->FirstPos == PointPos::none &&
|
||||
constraint->SecondPos == PointPos::none &&
|
||||
constraint->ThirdPos == PointPos::start) {
|
||||
auto knotgeoId = checkGeoId(constraint->Third);
|
||||
if (Geoms[knotgeoId].type == Point) {
|
||||
auto *point = static_cast<const GeomPoint*>(Geoms[knotgeoId].geo);
|
||||
auto knotgeoId = checkGeoId(constraint->First);
|
||||
if (Geoms[knotgeoId].type == Point) {
|
||||
auto *point = static_cast<const GeomPoint*>(Geoms[knotgeoId].geo);
|
||||
|
||||
if (GeometryFacade::isInternalType(point,InternalType::BSplineKnotPoint)) {
|
||||
auto bsplinegeoid = internalAlignmentGeometryMap.at(constraint->Third);
|
||||
if (GeometryFacade::isInternalType(point,InternalType::BSplineKnotPoint)) {
|
||||
auto bsplinegeoid = internalAlignmentGeometryMap.at(constraint->First);
|
||||
|
||||
bsplinegeoid = checkGeoId(bsplinegeoid);
|
||||
bsplinegeoid = checkGeoId(bsplinegeoid);
|
||||
|
||||
auto linegeoid = checkGeoId(constraint->Second);
|
||||
auto linegeoid = checkGeoId(constraint->Second);
|
||||
|
||||
return addTangentLineAtBSplineKnotConstraint(linegeoid, bsplinegeoid, knotgeoId);
|
||||
}
|
||||
rtn = addTangentLineAtBSplineKnotConstraint(linegeoid, bsplinegeoid, knotgeoId);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
else {
|
||||
//any other point-wise tangency (endpoint-to-curve, endpoint-to-endpoint, tangent-via-point)
|
||||
c.value = new double(constraint->getValue());
|
||||
if(c.driving)
|
||||
|
||||
@@ -4226,33 +4226,7 @@ void CmdSketcherConstrainTangent::activated(int iMsg)
|
||||
}
|
||||
|
||||
if (isSimpleVertex(Obj, GeoId1, PosId1)) {
|
||||
if (isBsplineKnot(Obj, GeoId1)) {
|
||||
// find the B-spline and treat as TangentViaPoint
|
||||
openCommand(QT_TRANSLATE_NOOP("Command", "Add tangent constraint"));
|
||||
const std::vector<Constraint *> &constraints = Obj->Constraints.getValues();
|
||||
for (const auto& constraint: constraints) {
|
||||
// TODO: wrap around with try-catch
|
||||
if (constraint->Type == Sketcher::ConstraintType::InternalAlignment &&
|
||||
constraint->First == GeoId1 &&
|
||||
constraint->AlignmentType == Sketcher::InternalAlignmentType::BSplineKnotPoint) {
|
||||
int GeoId3 = constraint->Second;
|
||||
// TODO: ensure C1 continuity at point
|
||||
if(! IsPointAlreadyOnCurve(GeoId2, GeoId1, PosId1, Obj)){
|
||||
Gui::cmdAppObjectArgs(selection[0].getObject(), "addConstraint(Sketcher.Constraint('PointOnObject',%d,%d,%d)) ",
|
||||
GeoId1,static_cast<int>(PosId1),GeoId2);
|
||||
}
|
||||
|
||||
Gui::cmdAppObjectArgs(selection[0].getObject(), "addConstraint(Sketcher.Constraint('TangentViaPoint',%d,%d,%d,%d)) ",
|
||||
GeoId3,GeoId2,GeoId1,static_cast<int>(PosId1));
|
||||
commitCommand();
|
||||
tryAutoRecompute(Obj);
|
||||
|
||||
getSelection().clearSelection();
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (!isBsplineKnot(Obj, GeoId1)) {
|
||||
QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Wrong selection"),
|
||||
QObject::tr("Cannot add a tangency constraint at an unconnected point!"));
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user