Sketcher: Arc to arc or circle distance constraint

This commit is contained in:
Florian Foinant-Willig
2023-11-29 20:36:26 +01:00
committed by abdullahtahiriyo
parent 5ae3a5da9d
commit 838802e28d
6 changed files with 530 additions and 469 deletions

View File

@@ -3178,7 +3178,7 @@ int Sketch::addDistanceConstraint(int geoId, double* value, bool driving)
return ConstraintsCounter;
}
// point to line distance constraint
// point to line or circle distance constraint
int Sketch::addDistanceConstraint(int geoId1,
PointPos pos1,
int geoId2,
@@ -3245,23 +3245,44 @@ int Sketch::addDistanceConstraint(int geoId1, int geoId2, double* value, bool dr
geoId1 = checkGeoId(geoId1);
geoId2 = checkGeoId(geoId2);
if (Geoms[geoId1].type == Circle) {
if (Geoms[geoId2].type == Circle) {
GCS::Circle& c1 = Circles[Geoms[geoId1].index];
GCS::Circle& c2 = Circles[Geoms[geoId2].index];
int tag = ++ConstraintsCounter;
GCSsys.addConstraintC2CDistance(c1, c2, value, tag, driving);
return ConstraintsCounter;
GCS::Circle *c1, *c2;
if (Geoms[geoId2].type == Line) {
if (Geoms[geoId1].type == Circle) {
c1 = &Circles[Geoms[geoId1].index];
}
else if (Geoms[geoId2].type == Line) {
GCS::Circle& c = Circles[Geoms[geoId1].index];
GCS::Line& l = Lines[Geoms[geoId2].index];
int tag = ++ConstraintsCounter;
GCSsys.addConstraintC2LDistance(c, l, value, tag, driving);
return ConstraintsCounter;
else if (Geoms[geoId1].type == Arc) {
c1 = &Arcs[Geoms[geoId1].index];
}
GCS::Line* l = &Lines[Geoms[geoId2].index];
int tag = ++ConstraintsCounter;
GCSsys.addConstraintC2LDistance(*c1, *l, value, tag, driving);
return ConstraintsCounter;
}
else {
if ((Geoms[geoId1].type == Circle) && (Geoms[geoId2].type == Circle)) {
c1 = &Circles[Geoms[geoId1].index];
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];
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 {
return -1;
}
int tag = ++ConstraintsCounter;
GCSsys.addConstraintC2CDistance(*c1, *c2, value, tag, driving);
return ConstraintsCounter;
}
return -1;
}