SketchSolver_Solver::SketchSolver_Solver()
{
+ myGroupID = 0;
// Nullify all elements of the set of equations
myEquationsSystem.param = 0;
myEquationsSystem.params = 0;
// If the set of constraints is inconsistent,
// the failed field will contain wrong constraints
- myEquationsSystem.calculateFaileds = 1;
+ myEquationsSystem.calculateFaileds = 0;
}
SketchSolver_Solver::~SketchSolver_Solver()
{
+ if (myEquationsSystem.constraint)
+ delete[] myEquationsSystem.constraint;
+ myEquationsSystem.constraint = 0;
if (myEquationsSystem.failed)
delete[] myEquationsSystem.failed;
+ myEquationsSystem.failed = 0;
}
void SketchSolver_Solver::setParameters(Slvs_Param* theParameters, int theSize)
void SketchSolver_Solver::setConstraints(Slvs_Constraint* theConstraints, int theSize)
{
- myEquationsSystem.constraint = theConstraints;
- myEquationsSystem.constraints = theSize;
+ if (!myEquationsSystem.constraint) {
+ myEquationsSystem.constraint = new Slvs_Constraint[theSize];
+ myEquationsSystem.constraints = theSize;
+ myEquationsSystem.failed = new Slvs_hConstraint[theSize];
+ }
+ else if (myEquationsSystem.constraints != theSize) {
+ if (theSize > myEquationsSystem.constraints) {
+ delete[] myEquationsSystem.constraint;
+ myEquationsSystem.constraint = new Slvs_Constraint[theSize];
+ if (myEquationsSystem.failed)
+ delete[] myEquationsSystem.failed;
+ myEquationsSystem.failed = new Slvs_hConstraint[theSize];
+ }
+ myEquationsSystem.constraints = theSize;
+ }
+ memcpy(myEquationsSystem.constraint, theConstraints, theSize * sizeof(Slvs_Constraint));
+ memset(myEquationsSystem.failed, SLVS_C_UNKNOWN, theSize * sizeof(Slvs_hConstraint));
}