Sketcher: Extend distance constraint to arcs

This commit is contained in:
Florian Foinant-Willig
2023-09-03 22:29:27 +02:00
committed by abdullahtahiriyo
parent 94eaa7db78
commit d2a579bdc6
4 changed files with 86 additions and 39 deletions

View File

@@ -3178,7 +3178,7 @@ int Sketch::addDistanceConstraint(int geoId, double* value, bool driving)
return ConstraintsCounter;
}
// point to line or circle distance constraint
// point to line or circular distance constraint
int Sketch::addDistanceConstraint(int geoId1,
PointPos pos1,
int geoId2,
@@ -3201,15 +3201,20 @@ int Sketch::addDistanceConstraint(int geoId1,
GCSsys.addConstraintP2LDistance(p1, l2, value, tag, driving);
return ConstraintsCounter;
}
else if (Geoms[geoId2].type == Circle) {
GCS::Circle& c2 = Circles[Geoms[geoId2].index];
int tag = ++ConstraintsCounter;
GCSsys.addConstraintP2CDistance(p1, c2, value, tag, driving);
return ConstraintsCounter;
}
else {
return -1;
GCS::Circle* c2;
if (Geoms[geoId2].type == Circle) {
c2 = &Circles[Geoms[geoId2].index];
}
else if (Geoms[geoId2].type == Arc) {
c2 = &Arcs[Geoms[geoId2].index];
}
else {
return -1;
}
int tag = ++ConstraintsCounter;
GCSsys.addConstraintP2CDistance(p1, *c2, value, tag, driving);
return ConstraintsCounter;
}
}
@@ -3239,7 +3244,7 @@ int Sketch::addDistanceConstraint(int geoId1,
return -1;
}
// circle-(circle or line) distance constraint
// circular-(circular or line) distance constraint
int Sketch::addDistanceConstraint(int geoId1, int geoId2, double* value, bool driving)
{
geoId1 = checkGeoId(geoId1);
@@ -3259,23 +3264,19 @@ int Sketch::addDistanceConstraint(int geoId1, int geoId2, double* value, bool dr
return ConstraintsCounter;
}
else {
if ((Geoms[geoId1].type == Circle) && (Geoms[geoId2].type == Circle)) {
if (Geoms[geoId1].type == Circle) {
c1 = &Circles[Geoms[geoId1].index];
}
else if (Geoms[geoId1].type == Arc) {
c1 = &Arcs[Geoms[geoId1].index];
}
if (Geoms[geoId2].type == Circle) {
c2 = &Circles[Geoms[geoId2].index];
}
else if ((Geoms[geoId1].type == Arc) && (Geoms[geoId2].type == Circle)) {
c1 = &Arcs[Geoms[geoId1].index];
c2 = &Circles[Geoms[geoId2].index];
}
else if ((Geoms[geoId1].type == Circle) && (Geoms[geoId2].type == Arc)) {
c1 = &Circles[Geoms[geoId1].index];
else if (Geoms[geoId2].type == Arc) {
c2 = &Arcs[Geoms[geoId2].index];
}
else if ((Geoms[geoId1].type == Arc) && (Geoms[geoId2].type == Arc)) {
c1 = &Arcs[Geoms[geoId1].index];
c2 = &Arcs[Geoms[geoId2].index];
}
else {
if (c1 == nullptr || c2 == nullptr) {
return -1;
}