]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
[bos #41917][EDF] SHAPER_TestRectangleCentered1.py test failed. Added debug output... kleontev/41917_SHAPER_TestRectangleCentered1_failed
authorKonstantin Leontev <Konstantin.LEONTEV@opencascade.com>
Fri, 14 Jun 2024 13:57:12 +0000 (14:57 +0100)
committerKonstantin Leontev <Konstantin.LEONTEV@opencascade.com>
Fri, 14 Jun 2024 14:00:24 +0000 (15:00 +0100)
22 files changed:
src/GeomData/GeomData_Point2D.cpp
src/PartSet/CMakeLists.txt
src/PartSet/PartSet_SketcherMgr.cpp
src/PythonAddons/macros/rectangle/feature.py
src/SketchPlugin/CMakeLists.txt
src/SketchPlugin/SketchPlugin_ConstraintMiddle.cpp
src/SketchPlugin/SketchPlugin_Line.cpp
src/SketchSolver/CMakeLists.txt
src/SketchSolver/PlaneGCSSolver/PlaneGCSSolver_AttributeBuilder.cpp
src/SketchSolver/PlaneGCSSolver/PlaneGCSSolver_PointWrapper.cpp
src/SketchSolver/PlaneGCSSolver/PlaneGCSSolver_Solver.cpp
src/SketchSolver/PlaneGCSSolver/PlaneGCSSolver_Storage.cpp
src/SketchSolver/PlaneGCSSolver/PlaneGCSSolver_Tools.cpp
src/SketchSolver/PlaneGCSSolver/PlaneGCSSolver_UpdateCoincidence.cpp
src/SketchSolver/PlaneGCSSolver/PlaneGCSSolver_UpdateFeature.cpp
src/SketchSolver/SketchSolver_Constraint.cpp
src/SketchSolver/SketchSolver_ConstraintMiddle.cpp
src/SketchSolver/SketchSolver_ConstraintPerpendicular.cpp
src/SketchSolver/SketchSolver_Group.cpp
src/SketchSolver/SketchSolver_Manager.cpp
src/SketchSolver/SketchSolver_Storage.cpp
src/SketchSolver/SolveSpaceSolver/SolveSpaceSolver_Storage.cpp

index 7f8987a11eaa5181c5c8fbc6d5f2c9a8fc453dc9..255e35106acd2dabffae4d5e3bc7c6fb7807dd94 100644 (file)
@@ -56,6 +56,22 @@ void GeomData_Point2D::setCalculatedValue(const double theX, const double theY)
     myExpression[0]->setValue(theX);
     myExpression[1]->setValue(theY);
     owner()->data()->sendAttributeUpdated(this);
+
+    // Testing moving a point with event
+    // auto anOriginalPosition = std::shared_ptr<GeomAPI_Pnt2d>(new GeomAPI_Pnt2d(x(), y()));
+    // auto aCurrentPosition = std::shared_ptr<GeomAPI_Pnt2d>(new GeomAPI_Pnt2d(theX, theY));
+
+    // AttributePtr aPoint = owner()->data()->attribute(this->id());
+    // const bool isImmutable = aPoint->setImmutable(true);
+
+    // std::shared_ptr<ModelAPI_ObjectMovedMessage> aMessage =
+    //   std::shared_ptr<ModelAPI_ObjectMovedMessage>(new ModelAPI_ObjectMovedMessage(this));
+    // aMessage->setMovedAttribute(aPoint, -1);
+    // aMessage->setOriginalPosition(anOriginalPosition);
+    // aMessage->setCurrentPosition(aCurrentPosition);
+    // Events_Loop::loop()->send(aMessage);
+
+    // aPoint->setImmutable(isImmutable);
   }
 }
 
index a09d270864a0d99619e43977bb0fa39e8fde7901..600d508aaf8a2a585af335c5ef26a325a84c5a6e 100644 (file)
@@ -128,6 +128,7 @@ SET(TEXT_RESOURCES
 )
 
 SET(PROJECT_LIBRARIES
+    ${KERNEL_SALOMELocalTrace}
     ModuleBase
     ModelGeomAlgo
     Config
@@ -163,7 +164,8 @@ ENDIF(${UPDATE_TRANSLATION})
 SOURCE_GROUP ("Generated Files" FILES ${PROJECT_AUTOMOC} ${PROJECT_COMPILED_RESOURCES} ${QM_RESOURCES})
 SOURCE_GROUP ("Resource Files" FILES ${TEXT_RESOURCES} ${PROJECT_RESOURCES})
 
-INCLUDE_DIRECTORIES(${PROJECT_SOURCE_DIR}/src/XGUI
+INCLUDE_DIRECTORIES(${KERNEL_INCLUDE_DIRS}
+                    ${PROJECT_SOURCE_DIR}/src/XGUI
                     ${PROJECT_SOURCE_DIR}/src/Config
                     ${PROJECT_SOURCE_DIR}/src/Events
                     ${PROJECT_SOURCE_DIR}/src/Locale
index 1a34c5127dabb1b31c31351558176b5f1ca1ffcc..3b0fdbb799c9a2024f3a459fa76ad15325a38cf9 100644 (file)
 
 #include <set>
 
+#include "utilities.h"
+
 //#define DEBUG_DO_NOT_BY_ENTER
 //#define DEBUG_SKETCHER_ENTITIES
 //#define DEBUG_SKETCH_ENTITIES_ON_MOVE
@@ -710,13 +712,14 @@ void PartSet_SketcherMgr::onMouseMoved(ModuleBase_IViewWindow* theWnd, QMouseEve
           if (anAttr.get() == NULL)
             continue;
           std::string aAttrId = anAttr->id();
+          MESSAGE("onMouse attr: " << aAttrId);
           DataPtr aData = aFeature->data();
           if (aData->isValid()) {
             AttributePtr aPoint = aData->attribute(aAttrId);
             if (aPoint->attributeType() == GeomDataAPI_Point2D::typeId() ||
                 aPoint->attributeType() == GeomDataAPI_Point2DArray::typeId()) {
               bool isImmutable = aPoint->setImmutable(true);
-
+              MESSAGE("move point " << anOriginalPosition->x() << ", " << anOriginalPosition->y())
               std::shared_ptr<ModelAPI_ObjectMovedMessage> aMessage = std::shared_ptr
                 <ModelAPI_ObjectMovedMessage>(new ModelAPI_ObjectMovedMessage(this));
               aMessage->setMovedAttribute(aPoint, anAttIt->second);
index d2df5435642ab693c5be44bba2a62f0647b692f5..acd78b1886c6ed17d88629defd119dc52e2e6e03 100755 (executable)
@@ -184,6 +184,16 @@ class SketchPlugin_Rectangle(model.Feature):
                 # coincidences between center point and diagonals
                 attr = self.__getPoint2DAttrOfSketchPoint(self.refattr(self.CENTER_REF_ID()))
                 if attr is not None:
+                #     aCoincidence = self.__sketch.addFeature("SketchConstraintMiddle")
+                #     anAlgoType = aCoincidence.string("middle_type")
+                #     anAlgoType.setValue("middle_type_by_line_and_point")
+                #     aCoincidence.refattr("ConstraintEntityA").setAttr(attr)
+                #     aCoincidence.refattr("ConstraintEntityB").setObject(aDiag1.lastResult())
+
+                #     # Debug output
+                #     center_point = GeomDataAPI.geomDataAPI_Point2D(attr).pnt()
+                #     print('center_point: ', center_point.x(), center_point.y())
+
                     for line in [aDiag1.lastResult(), aDiag2.lastResult()]:
                         aCoincidence = self.__sketch.addFeature("SketchConstraintCoincidence")
                         aCoincidence.refattr("ConstraintEntityA").setAttr(attr)
index 742176a0513d23363ba40044ccdb96a9ce918d73..2935a6849b951a4bc39162337b21d4b2d7ad231b 100644 (file)
@@ -136,6 +136,7 @@ SET(PROJECT_SOURCES
 )
 
 SET(PROJECT_LIBRARIES
+    ${KERNEL_SALOMELocalTrace}
     Config
     GeomAPI
     GeomAlgoAPI
@@ -167,6 +168,7 @@ ADD_LIBRARY(SketchPlugin MODULE ${PROJECT_SOURCES} ${PROJECT_HEADERS} ${XML_RESO
 TARGET_LINK_LIBRARIES(SketchPlugin ${PROJECT_LIBRARIES})
 
 INCLUDE_DIRECTORIES(
+  ${KERNEL_INCLUDE_DIRS}
   ../Config
   ../Events
   ../Locale
index ecb882bbc4ddf64240e7c0118fb7d39d3ac729cf..3e1b3f8d38ad84d6857732a8e3f5fef8e96b596a 100644 (file)
@@ -30,6 +30,8 @@
 #include <SketchPlugin_Point.h>
 #include <SketchPlugin_Tools.h>
 
+#include "utilities.h"
+
 
 class RaiiSetBoolFlag {
 public:
@@ -56,6 +58,7 @@ SketchPlugin_ConstraintMiddle::SketchPlugin_ConstraintMiddle()
 // Create new point for Middle constraint
 void SketchPlugin_ConstraintMiddle::CreatePoint()
 {
+  MESSAGE("Create point starts...");
   // Wait all objects being created, then send update events
   static Events_ID anUpdateEvent = Events_Loop::eventByName(EVENT_OBJECT_UPDATED);
   bool isUpdateFlushed = Events_Loop::loop()->isFlushed(anUpdateEvent);
@@ -63,6 +66,7 @@ void SketchPlugin_ConstraintMiddle::CreatePoint()
     Events_Loop::loop()->setFlushed(anUpdateEvent, false);
 
   auto aTrPnt = std::dynamic_pointer_cast<GeomDataAPI_Point2D>(data()->attribute(POINT_REF_ID()));
+  MESSAGE("aTrPnt:" << aTrPnt->pnt()->x() << ", " << aTrPnt->pnt()->y());
 
   if (!myPoint)
   {
@@ -79,6 +83,7 @@ void SketchPlugin_ConstraintMiddle::CreatePoint()
   AttributePoint2DPtr aCoord = std::dynamic_pointer_cast<GeomDataAPI_Point2D>(
     myPoint->attribute(SketchPlugin_Point::COORD_ID()));
   aCoord->setValue(aTrPnt->pnt());
+  MESSAGE("aCoord:" << aCoord->pnt()->x() << ", " << aCoord->pnt()->y());
 
   myPoint->execute();
 
@@ -92,6 +97,9 @@ void SketchPlugin_ConstraintMiddle::CreatePoint()
 
 void SketchPlugin_ConstraintMiddle::initAttributes()
 {
+  MESSAGE("=============== START ==============");
+  MESSAGE("Init middle constraint attributes...");
+  MESSAGE("====================================");
   // To maintain compatibility with older study versions, keep the order of all previously existing attributes:
   //  1) ENTITY_A
   //  2) ENTITY_B
@@ -127,8 +135,10 @@ void SketchPlugin_ConstraintMiddle::initAttributes()
 
 void SketchPlugin_ConstraintMiddle::execute()
 {
+  MESSAGE("Execute(): string(MIDDLE_TYPE())->value(): " << string(MIDDLE_TYPE())->value() << "; MIDDLE_TYPE_BY_LINE(): " << MIDDLE_TYPE_BY_LINE());
   if (string(MIDDLE_TYPE())->value() == MIDDLE_TYPE_BY_LINE())
   {
+    MESSAGE("string(MIDDLE_TYPE())->value() == MIDDLE_TYPE_BY_LINE() is TRUE");
     std::dynamic_pointer_cast<GeomDataAPI_Point2D>(data()->attribute(POINT_REF_ID()))->setValue(1., 1.);
     AttributeRefAttrPtr aPointRes = std::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(
       data()->attribute(SketchPlugin_Constraint::ENTITY_B()));
@@ -145,6 +155,7 @@ void SketchPlugin_ConstraintMiddle::execute()
 
 void SketchPlugin_ConstraintMiddle::attributeChanged(const std::string& theID)
 {
+  MESSAGE("attributeChanged! theID: " << theID);
   if (theID == MIDDLE_TYPE())
   {
     if (!myBlockAttribInit) {
@@ -161,6 +172,7 @@ void SketchPlugin_ConstraintMiddle::attributeChanged(const std::string& theID)
     AttributePoint2DPtr aCoord = std::dynamic_pointer_cast<GeomDataAPI_Point2D>(
       myPoint->attribute(SketchPlugin_Point::COORD_ID()));
     aCoord->setValue(aTrPnt->pnt());
+    MESSAGE("aCoord:" << aCoord->pnt()->x() << ", " << aCoord->pnt()->y());
 
     myPoint->execute();
   }
index 6f8b21c2577d80ebce0ccf6f058c015d87bd2855..765a9e077f8b9d3cbfb83749f58fa31607365427 100644 (file)
@@ -37,6 +37,8 @@
 
 #include <GeomDataAPI_Point2D.h>
 
+#include "utilities.h"
+
 SketchPlugin_Line::SketchPlugin_Line()
     : SketchPlugin_SketchEntity()
 {}
@@ -83,6 +85,7 @@ void SketchPlugin_Line::execute()
 // LCOV_EXCL_START
 std::string SketchPlugin_Line::processEvent(const std::shared_ptr<Events_Message>& theMessage)
 {
+  MESSAGE("processEvent(): ID" << theMessage->eventID().eventText());
   std::string aFilledAttributeName;
 
   std::shared_ptr<ModelAPI_EventReentrantMessage> aReentrantMessage =
@@ -97,6 +100,7 @@ std::string SketchPlugin_Line::processEvent(const std::shared_ptr<Events_Message
     std::shared_ptr<ModelAPI_Data> aNFData = data();
     std::shared_ptr<GeomDataAPI_Point2D> aNPoint = std::dynamic_pointer_cast<GeomDataAPI_Point2D>(
                                                  aNFData->attribute(SketchPlugin_Line::START_ID()));
+    MESSAGE("END: " << aSPoint->x() << ", " << aSPoint->y() << "; START: " << aNPoint->x() << ", " << aNPoint->y());
     aNPoint->setValue(aSPoint->x(), aSPoint->y());
     SketchPlugin_ConstraintCoincidence::createCoincidenceFeature(sketch(), aSPoint, aNPoint);
   }
@@ -115,6 +119,7 @@ bool SketchPlugin_Line::isFixed() {
 }
 
 void SketchPlugin_Line::attributeChanged(const std::string& theID) {
+  MESSAGE("attributeChanged(): " << theID);
   // the second condition for unability to move external segments anywhere
   // isCopy() is checked temporary for case when copied lines stored external id state
   // to be removed after debug
@@ -151,6 +156,8 @@ void SketchPlugin_Line::updateLenghtValue()
       GeomDataAPI_Point2D>(data()->attribute(END_ID()));
   if (aStartAttr->isInitialized() && anEndAttr->isInitialized()) {
     double aDistance = aStartAttr->pnt()->distance(anEndAttr->pnt());
+    MESSAGE("START: " << aStartAttr->pnt()->x() << ", " << aStartAttr->pnt()->y() << "; END: " << anEndAttr->pnt()->x() << ", " << anEndAttr->pnt()->y());
     data()->real(LENGTH_ID())->setValue(aDistance);
+    SCRUTE(aDistance);
   }
 }
index d0b53cda0527e88dd5d794725ca4da7ca26a2ee0..68a29112d7832ddb32af44f3bcba93db86845197 100644 (file)
@@ -86,6 +86,7 @@ SET(SKETCHSOLVER_CONSTRAINT_SOURCES
 )
 
 SET(SKETCHSOLVER_LIBRARIES
+    ${KERNEL_SALOMELocalTrace}
     Config
     Events
     ModelAPI
@@ -99,6 +100,7 @@ SET(SKETCHSOLVER_TEXT_RESOURCES
 )
 
 INCLUDE_DIRECTORIES(
+    ${KERNEL_INCLUDE_DIRS}
     ${PROJECT_SOURCE_DIR}/src/Config
     ${PROJECT_SOURCE_DIR}/src/SketchPlugin
     ${PROJECT_SOURCE_DIR}/src/ModelAPI
index 7db117e6d42265725ac005a725ea494cb202f52a..2222135de9da68b8934faa9b83b333571c649091 100644 (file)
@@ -37,6 +37,8 @@
 #include <SketchPlugin_ConstraintAngle.h>
 #include <SketchPlugin_MultiRotation.h>
 
+#include "utilities.h"
+
 PlaneGCSSolver_AttributeBuilder::PlaneGCSSolver_AttributeBuilder(
     PlaneGCSSolver_Storage* theStorage)
   : PlaneGCSSolver_EntityBuilder(theStorage)
@@ -273,6 +275,6 @@ bool PlaneGCSSolver_AttributeBuilder::updateAttribute(
                     [](double* theParam) { delete theParam; });
     }
   }
-
+  MESSAGE("update for entity attr: " << theAttribute->attributeType());
   return isUpdated || theEntity->update(theAttribute);
 }
index d90d1258d0428c97ae3700ee33a487a105b25c95..045b0c4cb2506c69b5c48671a6af79b78c634965 100644 (file)
@@ -22,6 +22,8 @@
 
 #include <GeomDataAPI_Point2D.h>
 
+#include "utilities.h"
+
 PlaneGCSSolver_PointWrapper::PlaneGCSSolver_PointWrapper(const GCSPointPtr thePoint)
   : myPoint(thePoint)
 {
@@ -33,8 +35,11 @@ bool PlaneGCSSolver_PointWrapper::update(AttributePtr theAttribute)
   std::shared_ptr<GeomDataAPI_Point2D> aPoint2D =
       std::dynamic_pointer_cast<GeomDataAPI_Point2D>(theAttribute);
   if (aPoint2D) {
+    const double x = *(myPoint->x);
+    const double y = *(myPoint->y);
     isUpdated = PlaneGCSSolver_Tools::updateValue(aPoint2D->x(), *(myPoint->x)) || isUpdated;
     isUpdated = PlaneGCSSolver_Tools::updateValue(aPoint2D->y(), *(myPoint->y)) || isUpdated;
+    MESSAGE("a: " << aPoint2D->x() << ", " << aPoint2D->y() << "; my: " << x << ", " << y << "; updated: " << isUpdated);
   }
   return isUpdated;
 }
index e327330faf2db7e02577f9ef6e70d5232b2a6ad7..103ced8774d8fe2369fdef161c137975e4c2648e 100644 (file)
@@ -20,6 +20,8 @@
 #include <PlaneGCSSolver_Solver.h>
 #include <Events_LongOp.h>
 
+#include "utilities.h"
+
 // Multiplier to correlate IDs of SketchPlugin constraint and primitive PlaneGCS constraints
 static const int THE_CONSTRAINT_MULT = 100;
 
@@ -61,6 +63,7 @@ void PlaneGCSSolver_Solver::addConstraint(const ConstraintID& theMultiConstraint
        anIt != theConstraints.end(); ++anIt) {
     GCSConstraintPtr aConstraint = *anIt;
     aConstraint->setTag(anID);
+    MESSAGE("addConstraint, ID: " << anID);
     myEquationSystem->addConstraint(aConstraint.get());
 
     if (anID > CID_UNKNOWN)
@@ -75,6 +78,7 @@ void PlaneGCSSolver_Solver::addConstraint(const ConstraintID& theMultiConstraint
 
 void PlaneGCSSolver_Solver::removeConstraint(const ConstraintID& theID)
 {
+  MESSAGE("removeConstraint, theID: " << theID);
   ConstraintMap::iterator aFound = myConstraints.find(theID);
   if (aFound != myConstraints.end()) {
     for (std::list<GCSConstraintPtr>::iterator anIt = aFound->second.begin();
@@ -106,6 +110,7 @@ double* PlaneGCSSolver_Solver::createParameter()
 
 void PlaneGCSSolver_Solver::addParameters(const GCS::SET_pD& theParams)
 {
+  MESSAGE("addParameters()");
   GCS::SET_pD aParams(theParams);
   // leave new parameters only
   GCS::VEC_pD::iterator anIt = myParameters.begin();
@@ -133,6 +138,7 @@ void PlaneGCSSolver_Solver::removeParameters(const GCS::SET_pD& theParams)
 
 void PlaneGCSSolver_Solver::initialize()
 {
+  MESSAGE("initialize()");
   Events_LongOp::start(this);
   addFictiveConstraintIfNecessary();
   if (myDiagnoseBeforeSolve)
@@ -146,6 +152,7 @@ void PlaneGCSSolver_Solver::initialize()
 
 PlaneGCSSolver_Solver::SolveStatus PlaneGCSSolver_Solver::solve()
 {
+  MESSAGE("solve()");
   // clear list of conflicting constraints
   if (myConfCollected) {
     myConflictingIDs.clear();
@@ -155,15 +162,19 @@ PlaneGCSSolver_Solver::SolveStatus PlaneGCSSolver_Solver::solve()
   if (myParameters.empty())
     return myConstraints.empty() ? STATUS_OK : STATUS_INCONSISTENT;
 
+  if (!myInitilized)
+    initialize();
+
   GCS::SolveStatus aResult = GCS::Success;
   Events_LongOp::start(this);
-  if (myInitilized) {
-    aResult = (GCS::SolveStatus)myEquationSystem->solve();
-  } else {
-    addFictiveConstraintIfNecessary();
-    diagnose();
-    aResult = (GCS::SolveStatus)myEquationSystem->solve(myParameters);
-  }
+  aResult = (GCS::SolveStatus)myEquationSystem->solve();
+  // if (myInitilized) {
+  //   aResult = (GCS::SolveStatus)myEquationSystem->solve();
+  // } else {
+  //   addFictiveConstraintIfNecessary();
+  //   diagnose();
+  //   aResult = (GCS::SolveStatus)myEquationSystem->solve(myParameters);
+  // }
 
   if (aResult == GCS::Failed) {
     // DogLeg solver failed without conflicting constraints, try to use Levenberg-Marquardt solver
@@ -196,6 +207,7 @@ PlaneGCSSolver_Solver::SolveStatus PlaneGCSSolver_Solver::solve()
 
   removeFictiveConstraint();
   myInitilized = false;
+  SCRUTE(aStatus);
   return aStatus;
 }
 
index aecba9754987f43a7145b98660d1222c502e5ae1..123c92fcfb0d2d2d7fa103a2f1383e01412cc650 100644 (file)
@@ -44,6 +44,8 @@
 
 #include <cmath>
 
+#include "utilities.h"
+
 
 static void constraintsToSolver(const ConstraintWrapperPtr& theConstraint,
                                 const SolverPtr& theSolver)
@@ -132,6 +134,7 @@ bool PlaneGCSSolver_Storage::update(FeaturePtr theFeature, bool theForce)
   std::shared_ptr<SketchPlugin_Feature> aSketchFeature =
       std::dynamic_pointer_cast<SketchPlugin_Feature>(theFeature);
   EntityWrapperPtr aRelated = entity(theFeature);
+  MESSAGE("update(): theFeature: " << theFeature->getKind());
   if (aRelated) // send signal to subscribers
     sendNotify = true;
   else { // Feature is not exist, create it
@@ -174,6 +177,7 @@ bool PlaneGCSSolver_Storage::update(FeaturePtr theFeature, bool theForce)
   }
 
   // send notification to listeners due to at least one attribute is changed
+  MESSAGE("sendNotify: " << sendNotify << " ; isUpdated: " << isUpdated);
   if (sendNotify && isUpdated)
     notify(theFeature);
 
@@ -186,6 +190,7 @@ bool PlaneGCSSolver_Storage::update(FeaturePtr theFeature, bool theForce)
 
 bool PlaneGCSSolver_Storage::update(AttributePtr theAttribute, bool theForce)
 {
+  MESSAGE("update attr: " << theAttribute->attributeType());
   if (!theAttribute->isInitialized())
     return false;
 
@@ -213,6 +218,7 @@ bool PlaneGCSSolver_Storage::update(AttributePtr theAttribute, bool theForce)
 
   PlaneGCSSolver_AttributeBuilder aBuilder(aRelated->isExternal() ? 0 : this);
   bool isUpdated = aBuilder.updateAttribute(anAttribute, aRelated);
+  SCRUTE(isUpdated);
   if (isUpdated) {
     setNeedToResolve(true);
     notify(aFeature);
@@ -461,6 +467,7 @@ void adjustArcParametrization(ARCTYPE& theArc, bool theReversed)
 
 void PlaneGCSSolver_Storage::adjustParametrizationOfArcs()
 {
+  MESSAGE("adjustParametrizationOfArcs()!!!");
   std::map<EntityWrapperPtr, ConstraintWrapperPtr>::iterator anIt = myAuxConstraintMap.begin();
   for (; anIt != myAuxConstraintMap.end(); ++anIt) {
     EdgeWrapperPtr anEdge = std::dynamic_pointer_cast<PlaneGCSSolver_EdgeWrapper>(anIt->first);
@@ -627,8 +634,10 @@ void PlaneGCSSolver_Storage::refresh() const
       std::shared_ptr<PlaneGCSSolver_PointWrapper> aPointWrapper =
           std::dynamic_pointer_cast<PlaneGCSSolver_PointWrapper>(anIt->second);
       GCSPointPtr aGCSPoint = aPointWrapper->point();
+      MESSAGE("P1: " << aPoint2D->x() << ", " << aPoint2D->y() << "; P2: " << (*aGCSPoint->x) << ", " << (*aGCSPoint->y));
       if (fabs(aPoint2D->x() - (*aGCSPoint->x)) > aTol ||
           fabs(aPoint2D->y() - (*aGCSPoint->y)) > aTol) {
+        MESSAGE("Set new value!!!");
         aPoint2D->setValue(*aGCSPoint->x, *aGCSPoint->y);
         addOwnerToSet(anIt->first, anUpdatedFeatures);
       }
index 7e79ee1cccad68d01a5e1b09a39c0c12ef377277..bc43a8bd8d840f61d079a7578643c7563aacfbdd 100644 (file)
@@ -79,6 +79,8 @@
 
 #include <cmath>
 
+#include "utilities.h"
+
 
 #define GCS_EDGE_WRAPPER(x)   std::dynamic_pointer_cast<PlaneGCSSolver_EdgeWrapper>(x)
 #define GCS_POINT_WRAPPER(x)  std::dynamic_pointer_cast<PlaneGCSSolver_PointWrapper>(x)
@@ -234,6 +236,7 @@ ConstraintWrapperPtr PlaneGCSSolver_Tools::createConstraint(
   std::shared_ptr<PlaneGCSSolver_PointWrapper> aPoint2 = GCS_POINT_WRAPPER(thePoint2);
   std::shared_ptr<PlaneGCSSolver_EdgeWrapper> anEntity1 = GCS_EDGE_WRAPPER(theEntity1);
 
+  MESSAGE("createConstraint(): " << theType);
   switch (theType) {
   case CONSTRAINT_PT_PT_COINCIDENT:
     aResult = createConstraintCoincidence(aPoint1, aPoint2);
@@ -680,6 +683,7 @@ ConstraintWrapperPtr createConstraintMiddlePoint(
     std::shared_ptr<PlaneGCSSolver_EdgeWrapper> theEntity,
     std::shared_ptr<PlaneGCSSolver_PointWrapper> theAuxParameters)
 {
+  MESSAGE("createConstraintMiddlePoint()");
   std::list<GCSConstraintPtr> aConstrList;
 
   GCSPointPtr aPoint = thePoint->point();
index d2f6a625433fe4c63a41d77ec0b18e4f7f82253a..bed4dab4c5f0566ea624575492c0967281770a17 100644 (file)
@@ -27,6 +27,8 @@
 #include <SketchPlugin_ConstraintCollinear.h>
 #include <SketchPlugin_ConstraintMiddle.h>
 
+#include "utilities.h"
+
 static bool hasSamePoint(const std::set<EntityWrapperPtr>& theList,
                          const EntityWrapperPtr& thePoint);
 
@@ -48,6 +50,7 @@ void PlaneGCSSolver_UpdateCoincidence::attach(SketchSolver_Constraint* theObserv
 
 void PlaneGCSSolver_UpdateCoincidence::update(const FeaturePtr& theFeature)
 {
+  MESSAGE("update() " << theFeature->getKind());
   if (theFeature->getKind() == SketchPlugin_ConstraintCoincidence::ID() ||
       theFeature->getKind() == SketchPlugin_ConstraintCoincidenceInternal::ID() ||
       theFeature->getKind() == SketchPlugin_ConstraintMiddle::ID() ||
@@ -56,9 +59,15 @@ void PlaneGCSSolver_UpdateCoincidence::update(const FeaturePtr& theFeature)
     // notify listeners and stop procesing
     std::list<SketchSolver_Constraint*>::iterator anIt = myObservers.begin();
     for (; anIt != myObservers.end(); ++anIt)
+    {
+      MESSAGE("notify constraint: " << (*anIt)->getType());
       (*anIt)->notify(theFeature, this);
+    }
   } else
+  {
+    MESSAGE("update next...");
     myNext->update(theFeature);
+  }
 }
 
 static bool hasAnotherExternalPoint(const std::set<EntityWrapperPtr>& theCoincidences,
index 0e59f27a74e6aa58bcccd84b8ed10ef8b7c1222c..2fb1fb110dcfadf316c820dae0f0e104963d2c73 100644 (file)
@@ -20,6 +20,8 @@
 #include <PlaneGCSSolver_UpdateFeature.h>
 #include <SketchSolver_Constraint.h>
 
+#include "utilities.h"
+
 void PlaneGCSSolver_UpdateFeature::attach(SketchSolver_Constraint* theObserver,
                                           const std::string& theType)
 {
@@ -31,7 +33,11 @@ void PlaneGCSSolver_UpdateFeature::attach(SketchSolver_Constraint* theObserver,
 
 void PlaneGCSSolver_UpdateFeature::update(const FeaturePtr& theFeature)
 {
+  MESSAGE("update() " << theFeature->getKind());
   std::list<SketchSolver_Constraint*>::iterator anIt = myObservers.begin();
   for (; anIt != myObservers.end(); ++anIt)
+  {
+    MESSAGE("notify constraint: " << (*anIt)->getType());
     (*anIt)->notify(theFeature, this);
+  }
 }
index 95877d61025934a9d862d6767870dad36627dd89..28faf4dadb011fea20de3590b472816c9d135e40 100644 (file)
@@ -53,6 +53,8 @@
 
 #include <math.h>
 
+#include "utilities.h"
+
 SketchSolver_Constraint::SketchSolver_Constraint(
     ConstraintPtr  theConstraint)
   : myBaseConstraint(theConstraint),
@@ -113,6 +115,7 @@ SketchSolver_ConstraintType SketchSolver_Constraint::TYPE(ConstraintPtr theConst
 
 void SketchSolver_Constraint::process()
 {
+  MESSAGE("process()");
   cleanErrorMsg();
   if (!myBaseConstraint || !myStorage) {
     // Not enough parameters are assigned
@@ -189,6 +192,7 @@ void SketchSolver_Constraint::update()
 
 bool SketchSolver_Constraint::remove()
 {
+  MESSAGE("remove()");
   cleanErrorMsg();
   myType = CONSTRAINT_UNKNOWN;
   myStorage->unsubscribeUpdates(this);
index 30f022730ca572c8c0db95b9a015c5e74cb05e85..438b4cc2f0154aa30b7c3dfe35cdf67eced8aa4c 100644 (file)
 #include <PlaneGCSSolver_Tools.h>
 #include <PlaneGCSSolver_UpdateCoincidence.h>
 
+#include "utilities.h"
+
 static bool isArc(EntityWrapperPtr theEntity)
 {
+  MESSAGE("isArc(): SketchSolver_EntityType: " << theEntity->type());
   return theEntity->type() == ENTITY_ARC || theEntity->type() == ENTITY_ELLIPTIC_ARC;
 }
 
@@ -50,6 +53,7 @@ void SketchSolver_ConstraintMiddle::getAttributes(
 
 bool SketchSolver_ConstraintMiddle::remove()
 {
+  MESSAGE("remove()");
   if (myOddPoint) {
     std::shared_ptr<PlaneGCSSolver_Storage> aStorage =
         std::dynamic_pointer_cast<PlaneGCSSolver_Storage>(myStorage);
@@ -65,9 +69,11 @@ bool SketchSolver_ConstraintMiddle::remove()
 void SketchSolver_ConstraintMiddle::notify(const FeaturePtr&      theFeature,
                                            PlaneGCSSolver_Update* theUpdater)
 {
+  MESSAGE("notify()");
   if (theFeature == myBaseConstraint && myInSolver) {
     // the constraint is already being updated,
     // update the middle point parameter if the constraint is "point-on-arc".
+    SCRUTE(myOddPoint);
     if (myOddPoint) {
       EntityWrapperPtr anArcEntity =
           isArc(myAttributes.front()) ? myAttributes.front() : myAttributes.back();
@@ -97,10 +103,13 @@ void SketchSolver_ConstraintMiddle::notify(const FeaturePtr&      theFeature,
   PlaneGCSSolver_UpdateCoincidence* anUpdater =
       static_cast<PlaneGCSSolver_UpdateCoincidence*>(theUpdater);
   bool isAccepted = anUpdater->addCoincidence(myAttributes.front(), myAttributes.back());
+  SCRUTE(isAccepted);
+  SCRUTE(myInSolver);
   if (isAccepted) {
     if (!myInSolver) {
       myInSolver = true;
 
+      SCRUTE(myMiddle);
       if (myMiddle) {
         // remove previously adde constraint
         myStorage->removeConstraint(myBaseConstraint);
index c7b049c99faf6a7c814902f66ff0fbeec5369aa4..494ad2e8628941bf73be931bd29c800f47bfdcb3 100644 (file)
@@ -38,6 +38,8 @@
 
 #include <cmath>
 
+#include "utilities.h"
+
 #define GCS_EDGE_WRAPPER(x) std::dynamic_pointer_cast<PlaneGCSSolver_EdgeWrapper>(x)
 #define GCS_POINT_WRAPPER(x) std::dynamic_pointer_cast<PlaneGCSSolver_PointWrapper>(x)
 
@@ -66,6 +68,7 @@ static void adjustAngleBetweenCurves(const GCSCurvePtr& theCurve1,
 
 void SketchSolver_ConstraintPerpendicular::process()
 {
+  MESSAGE("process()");
   cleanErrorMsg();
   if (!myBaseConstraint || !myStorage) {
     // Not enough parameters are assigned
@@ -87,6 +90,7 @@ void SketchSolver_ConstraintPerpendicular::process()
 
 void SketchSolver_ConstraintPerpendicular::rebuild()
 {
+  MESSAGE("rebuild()");
   if (mySolverConstraint)
     myStorage->removeConstraint(myBaseConstraint);
 
@@ -187,6 +191,7 @@ void SketchSolver_ConstraintPerpendicular::rebuild()
 void SketchSolver_ConstraintPerpendicular::notify(const FeaturePtr&      theFeature,
                                                   PlaneGCSSolver_Update* theUpdater)
 {
+  MESSAGE("notify()");
   if (theFeature->getKind() != SketchPlugin_ConstraintCoincidence::ID())
     return;
 
@@ -262,9 +267,13 @@ void getFeatures(const ConstraintPtr& theConstraint,
 
 static std::set<FeaturePtr> collectCoincidences(FeaturePtr theFeature1, FeaturePtr theFeature2)
 {
+  MESSAGE("collectCoincidences()");
   const std::set<AttributePtr>& aRefs1 = theFeature1->data()->refsToMe();
   const std::set<AttributePtr>& aRefs2 = theFeature2->data()->refsToMe();
 
+  MESSAGE("Refs to feature 1: " << aRefs1.size());
+  MESSAGE("Refs to feature 2: " << aRefs2.size());
+
   std::set<FeaturePtr> aCoincidences;
   std::set<AttributePtr>::const_iterator anIt;
 
@@ -275,6 +284,8 @@ static std::set<FeaturePtr> collectCoincidences(FeaturePtr theFeature1, FeatureP
       aCoincidences.insert(aRef);
   }
 
+  MESSAGE("Num of coincidences for 1: " << aCoincidences.size());
+
   // leave only coincidences referred to the second feature
   std::set<FeaturePtr> aCoincidencesBetweenFeatures;
   for (anIt = aRefs2.begin(); anIt != aRefs2.end(); ++anIt) {
@@ -283,11 +294,13 @@ static std::set<FeaturePtr> collectCoincidences(FeaturePtr theFeature1, FeatureP
       aCoincidencesBetweenFeatures.insert(aRef);
   }
 
+  MESSAGE("Num of coincidences for both: " << aCoincidencesBetweenFeatures.size());
   return aCoincidencesBetweenFeatures;
 }
 
 std::set<AttributePtr> coincidentBoundaryPoints(FeaturePtr theFeature1, FeaturePtr theFeature2)
 {
+  MESSAGE("coincidentBoundaryPoints()");
   std::set<FeaturePtr> aCoincidences = collectCoincidences(theFeature1, theFeature2);
   // collect points only
   std::set<AttributePtr> aCoincidentPoints;
@@ -307,8 +320,11 @@ std::set<AttributePtr> coincidentBoundaryPoints(FeaturePtr theFeature1, FeatureP
         anAttrB->id() != SketchPlugin_Circle::CENTER_ID()) {
       aCoincidentPoints.insert(anAttrA);
       aCoincidentPoints.insert(anAttrB);
+      MESSAGE("Added A / B: " << anAttrA->id() << " / " << anAttrB->id());
     }
   }
+
+  MESSAGE("Collected points: " << aCoincidentPoints.size());
   return aCoincidentPoints;
 }
 
@@ -321,12 +337,14 @@ static std::set<AttributePtr> refsToFeatureAndResults(FeaturePtr theFeature)
     const std::set<AttributePtr>& aResRefs = (*anIt)->data()->refsToMe();
     aRefs.insert(aResRefs.begin(), aResRefs.end());
   }
+  MESSAGE("refsToFeatureAndResults: " << aRefs.size());
   return aRefs;
 }
 
 // collect all points coincident with the feature
 static std::set<AttributePtr> pointsOnFeature(FeaturePtr theFeature)
 {
+  MESSAGE("pointsOnFeature()");
   std::set<AttributePtr> aPoints;
 
   std::set<AttributePtr> aRefs = refsToFeatureAndResults(theFeature);
@@ -345,11 +363,13 @@ static std::set<AttributePtr> pointsOnFeature(FeaturePtr theFeature)
       }
     }
   }
+  MESSAGE("pointsOnFeature: " << aPoints.size());
   return aPoints;
 }
 
 std::set<AttributePtr> coincidentPoints(FeaturePtr theFeature1, FeaturePtr theFeature2)
 {
+  MESSAGE("coincidentPoints()");
   std::set<AttributePtr> aPointsOnF1 = pointsOnFeature(theFeature1);
   std::set<AttributePtr> aPointsOnF2 = pointsOnFeature(theFeature2);
 
@@ -358,6 +378,7 @@ std::set<AttributePtr> coincidentPoints(FeaturePtr theFeature1, FeaturePtr theFe
        anIt != aPointsOnF1.end(); ++anIt)
     if (aPointsOnF2.find(*anIt) != aPointsOnF2.end())
       aCommonPoints.insert(*anIt);
+  MESSAGE("Added common points: " << aCommonPoints.size());
   return aCommonPoints;
 }
 
@@ -380,6 +401,7 @@ void adjustAngleBetweenCurves(const GCSCurvePtr& theCurve1,
 void calculateIntersectionPoint(EntityWrapperPtr theCurve1, EntityWrapperPtr theCurve2,
                                 GCSPointPtr& theIntersectionPoint)
 {
+  MESSAGE("calculateIntersectionPoint()");
   std::shared_ptr<GeomAPI_Ellipse2d> anEllipse = PlaneGCSSolver_Tools::ellipse(theCurve1);
   EntityWrapperPtr aCurve2 = theCurve2;
   if (!anEllipse) {
index 83fafe3b10c22706628056877dc76e4135f86e59..513c0eb2df32937e3d678820d069959f262dccc5 100644 (file)
@@ -35,6 +35,8 @@
 
 #include <Config_Translator.h>
 
+#include "utilities.h"
+
 
 static void sendMessage(const char* theMessageName)
 {
@@ -245,6 +247,7 @@ bool SketchSolver_Group::resolveConstraints()
 
   bool aResolved = false;
   bool isGroupEmpty = isEmpty() && myStorage->isEmpty();
+  MESSAGE("resolveConstraints(): isGroupEmpty: " << isGroupEmpty);
   if (myStorage->isNeedToResolve() &&
       (!isGroupEmpty || !myConflictingConstraints.empty() ||
         myPrevResult == PlaneGCSSolver_Solver::STATUS_FAILED)) {
index 8bebc53c4247037984ef7b9c14fb112e7c6903f4..153a46196242a5edb5f7d7b112ecc093b8322627 100644 (file)
@@ -29,6 +29,8 @@
 #include <ModelAPI_Validator.h>
 #include <SketchPlugin_Sketch.h>
 
+#include "utilities.h"
+
 /// Global constraint manager object
 static SketchSolver_Manager* myManager = SketchSolver_Manager::instance();
 
@@ -166,6 +168,7 @@ void SketchSolver_Manager::processEvent(
     return;
   myIsComputed = true;
 
+  MESSAGE("processEvent(): ID" << theMessage->eventID().eventText());
   if (theMessage->eventID() == aCreatedEvent || theMessage->eventID() == anUpdateEvent) {
     std::shared_ptr<ModelAPI_ObjectUpdatedMessage> anUpdateMsg =
         std::dynamic_pointer_cast<ModelAPI_ObjectUpdatedMessage>(theMessage);
index 12bfdd869c554fe912744586503240ebc9c6f795..9f6441e3f34532c1f1ce7367ddd31073c6cda578 100644 (file)
@@ -32,6 +32,8 @@
 #include <SketchPlugin_ConstraintMirror.h>
 #include <SketchPlugin_ConstraintRigid.h>
 
+#include "utilities.h"
+
 
 SketchSolver_Storage::SketchSolver_Storage(SolverPtr theSolver)
   : mySketchSolver(theSolver),
@@ -109,6 +111,7 @@ void SketchSolver_Storage::addEntity(FeaturePtr       theFeature,
 void SketchSolver_Storage::addEntity(AttributePtr     theAttribute,
                                      EntityWrapperPtr theSolverEntity)
 {
+  MESSAGE("addEntity()")
   if (theSolverEntity) {
     myAttributeMap[theAttribute] = theSolverEntity;
     setNeedToResolve(true);
index 1e941558c1738580b9f5c08d942fc2c00a292723..7a829ed799056e9f02fd678d84ba30fadce6673b 100644 (file)
@@ -36,6 +36,8 @@
 #include <SketchPlugin_Arc.h>
 #include <SketchPlugin_ConstraintMiddle.h>
 
+#include "utilities.h"
+
 /** \brief Search the entity/parameter with specified ID in the list of elements
  *  \param[in] theEntityID unique ID of the element
  *  \param[in] theEntities list of elements
@@ -986,6 +988,7 @@ bool SolveSpaceSolver_Storage::remove(ParameterWrapperPtr theParameter)
 
 void SolveSpaceSolver_Storage::refresh(bool theFixedOnly) const
 {
+  MESSAGE("refresh()");
   //blockEvents(true);
 
   std::map<AttributePtr, EntityWrapperPtr>::const_iterator anIt = myAttributeMap.begin();