]> SALOME platform Git repositories - modules/shaper.git/blobdiff - src/SketchSolver/SketchSolver_Solver.cpp
Salome HOME
Add tools
[modules/shaper.git] / src / SketchSolver / SketchSolver_Solver.cpp
index 0e7b1761cc51e62b2aeeede9ce12c1c952d9f51c..36979d7474e67dceab857105e0fdd64155b1a5c4 100644 (file)
@@ -9,6 +9,7 @@
 
 SketchSolver_Solver::SketchSolver_Solver()
 {
+  myGroupID = 0;
   // Nullify all elements of the set of equations
   myEquationsSystem.param = 0;
   myEquationsSystem.params = 0;
@@ -26,15 +27,17 @@ SketchSolver_Solver::SketchSolver_Solver()
 
   // 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)
@@ -61,13 +64,20 @@ void SketchSolver_Solver::setConstraints(Slvs_Constraint* theConstraints, int th
   if (!myEquationsSystem.constraint) {
     myEquationsSystem.constraint = new Slvs_Constraint[theSize];
     myEquationsSystem.constraints = theSize;
+    myEquationsSystem.failed = new Slvs_hConstraint[theSize];
   }
   else if (myEquationsSystem.constraints != theSize) {
-    delete[] myEquationsSystem.constraint;
-    myEquationsSystem.constraint = new Slvs_Constraint[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));
 }