Sketcher: Focus solver internal geometry
This commit is contained in:
@@ -66,7 +66,8 @@ enum InternalAlignmentType {
|
||||
EllipseFocus2 = 4,
|
||||
HyperbolaMajor = 5,
|
||||
HyperbolaMinor = 6,
|
||||
HyperbolaFocus = 7
|
||||
HyperbolaFocus = 7,
|
||||
ParabolaFocus = 8
|
||||
};
|
||||
|
||||
/// define if you want to use the end or start point
|
||||
|
||||
@@ -1092,6 +1092,9 @@ int Sketch::addConstraint(const Constraint *constraint)
|
||||
case HyperbolaFocus:
|
||||
rtn = addInternalAlignmentHyperbolaFocus(constraint->First,constraint->Second);
|
||||
break;
|
||||
case ParabolaFocus:
|
||||
rtn = addInternalAlignmentParabolaFocus(constraint->First,constraint->Second);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@@ -2249,6 +2252,32 @@ int Sketch::addInternalAlignmentHyperbolaFocus(int geoId1, int geoId2)
|
||||
return -1;
|
||||
}
|
||||
|
||||
int Sketch::addInternalAlignmentParabolaFocus(int geoId1, int geoId2)
|
||||
{
|
||||
std::swap(geoId1, geoId2);
|
||||
|
||||
geoId1 = checkGeoId(geoId1);
|
||||
geoId2 = checkGeoId(geoId2);
|
||||
|
||||
if (Geoms[geoId1].type != ArcOfParabola)
|
||||
return -1;
|
||||
if (Geoms[geoId2].type != Point)
|
||||
return -1;
|
||||
|
||||
int pointId1 = getPointId(geoId2, start);
|
||||
|
||||
if (pointId1 >= 0 && pointId1 < int(Points.size())) {
|
||||
GCS::Point &p1 = Points[pointId1];
|
||||
|
||||
GCS::ArcOfParabola &a1 = ArcsOfParabola[Geoms[geoId1].index];
|
||||
|
||||
int tag = ++ConstraintsCounter;
|
||||
GCSsys.addConstraintInternalAlignmentParabolaFocus(a1, p1, tag);
|
||||
return ConstraintsCounter;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
double Sketch::calculateAngleViaPoint(int geoId1, int geoId2, double px, double py)
|
||||
{
|
||||
geoId1 = checkGeoId(geoId1);
|
||||
|
||||
@@ -311,6 +311,7 @@ public:
|
||||
int addInternalAlignmentHyperbolaMajorDiameter(int geoId1, int geoId2);
|
||||
int addInternalAlignmentHyperbolaMinorDiameter(int geoId1, int geoId2);
|
||||
int addInternalAlignmentHyperbolaFocus(int geoId1, int geoId2);
|
||||
int addInternalAlignmentParabolaFocus(int geoId1, int geoId2);
|
||||
//@}
|
||||
public:
|
||||
//This func is to be used during angle-via-point constraint creation. It calculates
|
||||
|
||||
@@ -987,6 +987,12 @@ int System::addConstraintInternalAlignmentHyperbolaFocus(Hyperbola &e, Point &p1
|
||||
return addConstraintEqual(e.focus1.y, p1.y, tagId);
|
||||
}
|
||||
|
||||
int System::addConstraintInternalAlignmentParabolaFocus(Parabola &e, Point &p1, int tagId)
|
||||
{
|
||||
addConstraintEqual(e.focus1.x, p1.x, tagId);
|
||||
return addConstraintEqual(e.focus1.y, p1.y, tagId);
|
||||
}
|
||||
|
||||
|
||||
//calculates angle between two curves at point of their intersection p. If two
|
||||
//points are supplied, p is used for first curve and p2 for second, yielding a
|
||||
|
||||
@@ -230,6 +230,7 @@ namespace GCS
|
||||
int addConstraintInternalAlignmentHyperbolaMajorDiameter(Hyperbola &e, Point &p1, Point &p2, int tagId=0);
|
||||
int addConstraintInternalAlignmentHyperbolaMinorDiameter(Hyperbola &e, Point &p1, Point &p2, int tagId=0);
|
||||
int addConstraintInternalAlignmentHyperbolaFocus(Hyperbola &e, Point &p1, int tagId=0);
|
||||
int addConstraintInternalAlignmentParabolaFocus(Parabola &e, Point &p1, int tagId=0);
|
||||
|
||||
double calculateAngleViaPoint(Curve &crv1, Curve &crv2, Point &p);
|
||||
double calculateAngleViaPoint(Curve &crv1, Curve &crv2, Point &p1, Point &p2);
|
||||
|
||||
Reference in New Issue
Block a user