GCS/Sketcher: Add equal length line constraint using the new single constraint
This commit is contained in:
committed by
abdullahtahiriyo
parent
1c2e7d74b5
commit
e87c01590f
@@ -2675,16 +2675,9 @@ int Sketch::addEqualConstraint(int geoId1, int geoId2)
|
||||
Geoms[geoId2].type == Line) {
|
||||
GCS::Line &l1 = Lines[Geoms[geoId1].index];
|
||||
GCS::Line &l2 = Lines[Geoms[geoId2].index];
|
||||
double dx1 = (*l1.p2.x - *l1.p1.x);
|
||||
double dy1 = (*l1.p2.y - *l1.p1.y);
|
||||
double dx2 = (*l2.p2.x - *l2.p1.x);
|
||||
double dy2 = (*l2.p2.y - *l2.p1.y);
|
||||
double value = (sqrt(dx1*dx1+dy1*dy1)+sqrt(dx2*dx2+dy2*dy2))/2;
|
||||
// add the parameter for the common length (this is added to Parameters, not FixParameters)
|
||||
Parameters.push_back(new double(value));
|
||||
double *length = Parameters[Parameters.size()-1];
|
||||
|
||||
int tag = ++ConstraintsCounter;
|
||||
GCSsys.addConstraintEqualLength(l1, l2, length, tag);
|
||||
GCSsys.addConstraintEqualLength(l1, l2, tag);
|
||||
return ConstraintsCounter;
|
||||
}
|
||||
|
||||
|
||||
@@ -1045,10 +1045,12 @@ int System::addConstraintArcDiameter(Arc &a, double *radius, int tagId, bool dri
|
||||
return addConstraintProportional(a.rad, radius, 0.5, tagId, driving);
|
||||
}
|
||||
|
||||
int System::addConstraintEqualLength(Line &l1, Line &l2, double *length, int tagId, bool driving)
|
||||
int System::addConstraintEqualLength(Line &l1, Line &l2, int tagId, bool driving)
|
||||
{
|
||||
addConstraintP2PDistance(l1.p1, l1.p2, length, tagId, driving);
|
||||
return addConstraintP2PDistance(l2.p1, l2.p2, length, tagId, driving);
|
||||
Constraint *constr = new ConstraintEqualLineLength(l1, l2);
|
||||
constr->setTag(tagId);
|
||||
constr->setDriving(driving);
|
||||
return addConstraint(constr);
|
||||
}
|
||||
|
||||
int System::addConstraintEqualRadius(Circle &c1, Circle &c2, int tagId, bool driving)
|
||||
@@ -4051,7 +4053,7 @@ SolverReportingManager::Manager().LogToFile("GCS::System::diagnose()\n");
|
||||
// identifyDependentParametersSparseQR(J, jacobianconstraintmap, pdiagnoselist, true)
|
||||
//
|
||||
// Debug:
|
||||
// auto fut = std::async(std::launch::deferred,&System::identifyDependentParametersSparseQR,this,J,jacobianconstraintmap, pdiagnoselist, false);
|
||||
//auto fut = std::async(std::launch::deferred,&System::identifyDependentParametersSparseQR,this,J,jacobianconstraintmap, pdiagnoselist, false);
|
||||
auto fut = std::async(&System::identifyDependentParametersSparseQR,this,J,jacobianconstraintmap, pdiagnoselist, /*silent=*/true);
|
||||
|
||||
makeSparseQRDecomposition( J, jacobianconstraintmap, SqrJT, rank, R, /*transposed=*/true, /*silent=*/false);
|
||||
|
||||
@@ -297,7 +297,7 @@ namespace GCS
|
||||
int addConstraintArcRadius(Arc &a, double *radius, int tagId=0, bool driving = true);
|
||||
int addConstraintCircleDiameter(Circle &c, double *radius, int tagId=0, bool driving = true);
|
||||
int addConstraintArcDiameter(Arc &a, double *radius, int tagId=0, bool driving = true);
|
||||
int addConstraintEqualLength(Line &l1, Line &l2, double *length, int tagId=0, bool driving = true);
|
||||
int addConstraintEqualLength(Line &l1, Line &l2, int tagId=0, bool driving = true);
|
||||
int addConstraintEqualRadius(Circle &c1, Circle &c2, int tagId=0, bool driving = true);
|
||||
int addConstraintEqualRadii(Ellipse &e1, Ellipse &e2, int tagId=0, bool driving = true);
|
||||
int addConstraintEqualRadii(ArcOfHyperbola &a1, ArcOfHyperbola &a2, int tagId=0, bool driving = true);
|
||||
|
||||
Reference in New Issue
Block a user