Salome HOME
Fix compilation errors in solvers.
[modules/shaper.git] / src / SketchSolver / SolveSpaceSolver / SolveSpaceSolver_Builder.cpp
index eabf9f6ae0c25d86a33407b2ec22c2961282802f..21bd5f536ca096e45b94513ee4737f5b4ad06965 100644 (file)
@@ -134,6 +134,7 @@ std::list<ConstraintWrapperPtr> SolveSpaceSolver_Builder::createConstraint(
     const EntityID& theSketchID,
     const SketchSolver_ConstraintType& theType,
     const double& theValue,
+    const bool theFullValue,
     const EntityWrapperPtr& thePoint1,
     const EntityWrapperPtr& thePoint2,
     const std::list<EntityWrapperPtr>& theTrsfEnt) const
@@ -156,6 +157,7 @@ std::list<ConstraintWrapperPtr> SolveSpaceSolver_Builder::createConstraint(
 
   ConstraintWrapperPtr aResult(new SolveSpaceSolver_ConstraintWrapper(theConstraint, aConstraint));
   aResult->setValue(theValue);
+  aResult->setIsFullValue(theFullValue);
   aResult->setEntities(aConstrAttrList);
   return std::list<ConstraintWrapperPtr>(1, aResult);
 }
@@ -231,8 +233,7 @@ std::list<ConstraintWrapperPtr> SolveSpaceSolver_Builder::createMirror(
     std::list<EntityWrapperPtr>::const_iterator anIt1 = theEntity1->subEntities().begin();
     std::list<EntityWrapperPtr>::const_iterator anIt2 = theEntity2->subEntities().begin();
     if ((*anIt2)->group() == theGroupID) // mirrored point is not fixed
-      makeMirrorPoints(theEntity1->subEntities().front(),
-          theEntity2->subEntities().front(), theMirrorLine);
+      makeMirrorPoints(*anIt1, *anIt2, theMirrorLine);
 
     // Workaround to avoid problems in SolveSpace.
     // The symmetry of two arcs will be done using symmetry of three points on these arcs:
@@ -313,9 +314,7 @@ EntityWrapperPtr SolveSpaceSolver_Builder::createFeature(
 
     const Slvs_Entity& aSubEnt =
         std::dynamic_pointer_cast<SolveSpaceSolver_EntityWrapper>(aSub)->entity();
-    EntityWrapperPtr aNewEntity(new SolveSpaceSolver_EntityWrapper(theFeature, aSubEnt));
-    aNewEntity->setSubEntities(std::list<EntityWrapperPtr>(1, aSub));
-    return aNewEntity;
+    return EntityWrapperPtr(new SolveSpaceSolver_EntityWrapper(theFeature, aPoint, aSubEnt));
   }
 
   // wrong entity
@@ -815,11 +814,19 @@ void adjustMultiRotation(ConstraintWrapperPtr theConstraint)
 {
   BuilderPtr aBuilder = SolveSpaceSolver_Builder::getInstance();
 
-  double anAngleRad = theConstraint->value() * PI / 180.0;
+  double anAngleValue = theConstraint->value();
+  const std::list<EntityWrapperPtr>& aSubs = theConstraint->entities();
+
+  bool isFullValue = theConstraint->isFullValue();
+  int aNbObjects = aSubs.size()-2;
+  if (isFullValue && aNbObjects > 0) {
+    anAngleValue /= aNbObjects;
+  }
+
+  double anAngleRad = anAngleValue * PI / 180.0;
   double aSin = sin(anAngleRad);
   double aCos = cos(anAngleRad);
 
-  const std::list<EntityWrapperPtr>& aSubs = theConstraint->entities();
   std::list<EntityWrapperPtr>::const_iterator aSIt = aSubs.begin();
 
   std::shared_ptr<GeomAPI_Pnt2d> aCenter = aBuilder->point(*aSIt++);
@@ -839,6 +846,13 @@ void adjustMultiTranslation(ConstraintWrapperPtr theConstraint)
   std::shared_ptr<GeomAPI_Pnt2d> aEndPnt = aBuilder->point(*aSIt++);
   std::shared_ptr<GeomAPI_XY> aDelta = aEndPnt->xy()->decreased(aStartPnt->xy());
 
+  bool isFullValue = theConstraint->isFullValue();
+  int aNbObjects = aSubs.size()-3;
+  if (isFullValue && aNbObjects > 0) {
+    aDelta->setX(aDelta->x()/aNbObjects);
+    aDelta->setY(aDelta->y()/aNbObjects);
+  }
+
   std::list<EntityWrapperPtr>::const_iterator aPrevIt = aSIt++;
   for (; aSIt != aSubs.end(); ++aPrevIt, ++aSIt)
     translate(*aPrevIt, *aSIt, aDelta);