From: Konstantin Leontev Date: Fri, 14 Jun 2024 13:57:12 +0000 (+0100) Subject: [bos #41917][EDF] SHAPER_TestRectangleCentered1.py test failed. Added debug output... X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=refs%2Fheads%2Fkleontev%2F41917_SHAPER_TestRectangleCentered1_failed;p=modules%2Fshaper.git [bos #41917][EDF] SHAPER_TestRectangleCentered1.py test failed. Added debug output. Added middle point constraint to rectangle (commented). Added a variant with sending move event from setValue (commented). --- diff --git a/src/GeomData/GeomData_Point2D.cpp b/src/GeomData/GeomData_Point2D.cpp index 7f8987a11..255e35106 100644 --- a/src/GeomData/GeomData_Point2D.cpp +++ b/src/GeomData/GeomData_Point2D.cpp @@ -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(new GeomAPI_Pnt2d(x(), y())); + // auto aCurrentPosition = std::shared_ptr(new GeomAPI_Pnt2d(theX, theY)); + + // AttributePtr aPoint = owner()->data()->attribute(this->id()); + // const bool isImmutable = aPoint->setImmutable(true); + + // std::shared_ptr aMessage = + // std::shared_ptr(new ModelAPI_ObjectMovedMessage(this)); + // aMessage->setMovedAttribute(aPoint, -1); + // aMessage->setOriginalPosition(anOriginalPosition); + // aMessage->setCurrentPosition(aCurrentPosition); + // Events_Loop::loop()->send(aMessage); + + // aPoint->setImmutable(isImmutable); } } diff --git a/src/PartSet/CMakeLists.txt b/src/PartSet/CMakeLists.txt index a09d27086..600d508aa 100644 --- a/src/PartSet/CMakeLists.txt +++ b/src/PartSet/CMakeLists.txt @@ -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 diff --git a/src/PartSet/PartSet_SketcherMgr.cpp b/src/PartSet/PartSet_SketcherMgr.cpp index 1a34c5127..3b0fdbb79 100644 --- a/src/PartSet/PartSet_SketcherMgr.cpp +++ b/src/PartSet/PartSet_SketcherMgr.cpp @@ -120,6 +120,8 @@ #include +#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 aMessage = std::shared_ptr (new ModelAPI_ObjectMovedMessage(this)); aMessage->setMovedAttribute(aPoint, anAttIt->second); diff --git a/src/PythonAddons/macros/rectangle/feature.py b/src/PythonAddons/macros/rectangle/feature.py index d2df54356..acd78b188 100755 --- a/src/PythonAddons/macros/rectangle/feature.py +++ b/src/PythonAddons/macros/rectangle/feature.py @@ -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) diff --git a/src/SketchPlugin/CMakeLists.txt b/src/SketchPlugin/CMakeLists.txt index 742176a05..2935a6849 100644 --- a/src/SketchPlugin/CMakeLists.txt +++ b/src/SketchPlugin/CMakeLists.txt @@ -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 diff --git a/src/SketchPlugin/SketchPlugin_ConstraintMiddle.cpp b/src/SketchPlugin/SketchPlugin_ConstraintMiddle.cpp index ecb882bbc..3e1b3f8d3 100644 --- a/src/SketchPlugin/SketchPlugin_ConstraintMiddle.cpp +++ b/src/SketchPlugin/SketchPlugin_ConstraintMiddle.cpp @@ -30,6 +30,8 @@ #include #include +#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(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( 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(data()->attribute(POINT_REF_ID()))->setValue(1., 1.); AttributeRefAttrPtr aPointRes = std::dynamic_pointer_cast( 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( myPoint->attribute(SketchPlugin_Point::COORD_ID())); aCoord->setValue(aTrPnt->pnt()); + MESSAGE("aCoord:" << aCoord->pnt()->x() << ", " << aCoord->pnt()->y()); myPoint->execute(); } diff --git a/src/SketchPlugin/SketchPlugin_Line.cpp b/src/SketchPlugin/SketchPlugin_Line.cpp index 6f8b21c25..765a9e077 100644 --- a/src/SketchPlugin/SketchPlugin_Line.cpp +++ b/src/SketchPlugin/SketchPlugin_Line.cpp @@ -37,6 +37,8 @@ #include +#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& theMessage) { + MESSAGE("processEvent(): ID" << theMessage->eventID().eventText()); std::string aFilledAttributeName; std::shared_ptr aReentrantMessage = @@ -97,6 +100,7 @@ std::string SketchPlugin_Line::processEvent(const std::shared_ptr aNFData = data(); std::shared_ptr aNPoint = std::dynamic_pointer_cast( 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); } } diff --git a/src/SketchSolver/CMakeLists.txt b/src/SketchSolver/CMakeLists.txt index d0b53cda0..68a29112d 100644 --- a/src/SketchSolver/CMakeLists.txt +++ b/src/SketchSolver/CMakeLists.txt @@ -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 diff --git a/src/SketchSolver/PlaneGCSSolver/PlaneGCSSolver_AttributeBuilder.cpp b/src/SketchSolver/PlaneGCSSolver/PlaneGCSSolver_AttributeBuilder.cpp index 7db117e6d..2222135de 100644 --- a/src/SketchSolver/PlaneGCSSolver/PlaneGCSSolver_AttributeBuilder.cpp +++ b/src/SketchSolver/PlaneGCSSolver/PlaneGCSSolver_AttributeBuilder.cpp @@ -37,6 +37,8 @@ #include #include +#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); } diff --git a/src/SketchSolver/PlaneGCSSolver/PlaneGCSSolver_PointWrapper.cpp b/src/SketchSolver/PlaneGCSSolver/PlaneGCSSolver_PointWrapper.cpp index d90d1258d..045b0c4cb 100644 --- a/src/SketchSolver/PlaneGCSSolver/PlaneGCSSolver_PointWrapper.cpp +++ b/src/SketchSolver/PlaneGCSSolver/PlaneGCSSolver_PointWrapper.cpp @@ -22,6 +22,8 @@ #include +#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 aPoint2D = std::dynamic_pointer_cast(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; } diff --git a/src/SketchSolver/PlaneGCSSolver/PlaneGCSSolver_Solver.cpp b/src/SketchSolver/PlaneGCSSolver/PlaneGCSSolver_Solver.cpp index e327330fa..103ced877 100644 --- a/src/SketchSolver/PlaneGCSSolver/PlaneGCSSolver_Solver.cpp +++ b/src/SketchSolver/PlaneGCSSolver/PlaneGCSSolver_Solver.cpp @@ -20,6 +20,8 @@ #include #include +#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::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; } diff --git a/src/SketchSolver/PlaneGCSSolver/PlaneGCSSolver_Storage.cpp b/src/SketchSolver/PlaneGCSSolver/PlaneGCSSolver_Storage.cpp index aecba9754..123c92fcf 100644 --- a/src/SketchSolver/PlaneGCSSolver/PlaneGCSSolver_Storage.cpp +++ b/src/SketchSolver/PlaneGCSSolver/PlaneGCSSolver_Storage.cpp @@ -44,6 +44,8 @@ #include +#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 aSketchFeature = std::dynamic_pointer_cast(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::iterator anIt = myAuxConstraintMap.begin(); for (; anIt != myAuxConstraintMap.end(); ++anIt) { EdgeWrapperPtr anEdge = std::dynamic_pointer_cast(anIt->first); @@ -627,8 +634,10 @@ void PlaneGCSSolver_Storage::refresh() const std::shared_ptr aPointWrapper = std::dynamic_pointer_cast(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); } diff --git a/src/SketchSolver/PlaneGCSSolver/PlaneGCSSolver_Tools.cpp b/src/SketchSolver/PlaneGCSSolver/PlaneGCSSolver_Tools.cpp index 7e79ee1cc..bc43a8bd8 100644 --- a/src/SketchSolver/PlaneGCSSolver/PlaneGCSSolver_Tools.cpp +++ b/src/SketchSolver/PlaneGCSSolver/PlaneGCSSolver_Tools.cpp @@ -79,6 +79,8 @@ #include +#include "utilities.h" + #define GCS_EDGE_WRAPPER(x) std::dynamic_pointer_cast(x) #define GCS_POINT_WRAPPER(x) std::dynamic_pointer_cast(x) @@ -234,6 +236,7 @@ ConstraintWrapperPtr PlaneGCSSolver_Tools::createConstraint( std::shared_ptr aPoint2 = GCS_POINT_WRAPPER(thePoint2); std::shared_ptr 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 theEntity, std::shared_ptr theAuxParameters) { + MESSAGE("createConstraintMiddlePoint()"); std::list aConstrList; GCSPointPtr aPoint = thePoint->point(); diff --git a/src/SketchSolver/PlaneGCSSolver/PlaneGCSSolver_UpdateCoincidence.cpp b/src/SketchSolver/PlaneGCSSolver/PlaneGCSSolver_UpdateCoincidence.cpp index d2f6a6254..bed4dab4c 100644 --- a/src/SketchSolver/PlaneGCSSolver/PlaneGCSSolver_UpdateCoincidence.cpp +++ b/src/SketchSolver/PlaneGCSSolver/PlaneGCSSolver_UpdateCoincidence.cpp @@ -27,6 +27,8 @@ #include #include +#include "utilities.h" + static bool hasSamePoint(const std::set& 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::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& theCoincidences, diff --git a/src/SketchSolver/PlaneGCSSolver/PlaneGCSSolver_UpdateFeature.cpp b/src/SketchSolver/PlaneGCSSolver/PlaneGCSSolver_UpdateFeature.cpp index 0e59f27a7..2fb1fb110 100644 --- a/src/SketchSolver/PlaneGCSSolver/PlaneGCSSolver_UpdateFeature.cpp +++ b/src/SketchSolver/PlaneGCSSolver/PlaneGCSSolver_UpdateFeature.cpp @@ -20,6 +20,8 @@ #include #include +#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::iterator anIt = myObservers.begin(); for (; anIt != myObservers.end(); ++anIt) + { + MESSAGE("notify constraint: " << (*anIt)->getType()); (*anIt)->notify(theFeature, this); + } } diff --git a/src/SketchSolver/SketchSolver_Constraint.cpp b/src/SketchSolver/SketchSolver_Constraint.cpp index 95877d610..28faf4dad 100644 --- a/src/SketchSolver/SketchSolver_Constraint.cpp +++ b/src/SketchSolver/SketchSolver_Constraint.cpp @@ -53,6 +53,8 @@ #include +#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); diff --git a/src/SketchSolver/SketchSolver_ConstraintMiddle.cpp b/src/SketchSolver/SketchSolver_ConstraintMiddle.cpp index 30f022730..438b4cc2f 100644 --- a/src/SketchSolver/SketchSolver_ConstraintMiddle.cpp +++ b/src/SketchSolver/SketchSolver_ConstraintMiddle.cpp @@ -25,8 +25,11 @@ #include #include +#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 aStorage = std::dynamic_pointer_cast(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(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); diff --git a/src/SketchSolver/SketchSolver_ConstraintPerpendicular.cpp b/src/SketchSolver/SketchSolver_ConstraintPerpendicular.cpp index c7b049c99..494ad2e86 100644 --- a/src/SketchSolver/SketchSolver_ConstraintPerpendicular.cpp +++ b/src/SketchSolver/SketchSolver_ConstraintPerpendicular.cpp @@ -38,6 +38,8 @@ #include +#include "utilities.h" + #define GCS_EDGE_WRAPPER(x) std::dynamic_pointer_cast(x) #define GCS_POINT_WRAPPER(x) std::dynamic_pointer_cast(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 collectCoincidences(FeaturePtr theFeature1, FeaturePtr theFeature2) { + MESSAGE("collectCoincidences()"); const std::set& aRefs1 = theFeature1->data()->refsToMe(); const std::set& aRefs2 = theFeature2->data()->refsToMe(); + MESSAGE("Refs to feature 1: " << aRefs1.size()); + MESSAGE("Refs to feature 2: " << aRefs2.size()); + std::set aCoincidences; std::set::const_iterator anIt; @@ -275,6 +284,8 @@ static std::set 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 aCoincidencesBetweenFeatures; for (anIt = aRefs2.begin(); anIt != aRefs2.end(); ++anIt) { @@ -283,11 +294,13 @@ static std::set collectCoincidences(FeaturePtr theFeature1, FeatureP aCoincidencesBetweenFeatures.insert(aRef); } + MESSAGE("Num of coincidences for both: " << aCoincidencesBetweenFeatures.size()); return aCoincidencesBetweenFeatures; } std::set coincidentBoundaryPoints(FeaturePtr theFeature1, FeaturePtr theFeature2) { + MESSAGE("coincidentBoundaryPoints()"); std::set aCoincidences = collectCoincidences(theFeature1, theFeature2); // collect points only std::set aCoincidentPoints; @@ -307,8 +320,11 @@ std::set 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 refsToFeatureAndResults(FeaturePtr theFeature) const std::set& 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 pointsOnFeature(FeaturePtr theFeature) { + MESSAGE("pointsOnFeature()"); std::set aPoints; std::set aRefs = refsToFeatureAndResults(theFeature); @@ -345,11 +363,13 @@ static std::set pointsOnFeature(FeaturePtr theFeature) } } } + MESSAGE("pointsOnFeature: " << aPoints.size()); return aPoints; } std::set coincidentPoints(FeaturePtr theFeature1, FeaturePtr theFeature2) { + MESSAGE("coincidentPoints()"); std::set aPointsOnF1 = pointsOnFeature(theFeature1); std::set aPointsOnF2 = pointsOnFeature(theFeature2); @@ -358,6 +378,7 @@ std::set 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 anEllipse = PlaneGCSSolver_Tools::ellipse(theCurve1); EntityWrapperPtr aCurve2 = theCurve2; if (!anEllipse) { diff --git a/src/SketchSolver/SketchSolver_Group.cpp b/src/SketchSolver/SketchSolver_Group.cpp index 83fafe3b1..513c0eb2d 100644 --- a/src/SketchSolver/SketchSolver_Group.cpp +++ b/src/SketchSolver/SketchSolver_Group.cpp @@ -35,6 +35,8 @@ #include +#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)) { diff --git a/src/SketchSolver/SketchSolver_Manager.cpp b/src/SketchSolver/SketchSolver_Manager.cpp index 8bebc53c4..153a46196 100644 --- a/src/SketchSolver/SketchSolver_Manager.cpp +++ b/src/SketchSolver/SketchSolver_Manager.cpp @@ -29,6 +29,8 @@ #include #include +#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 anUpdateMsg = std::dynamic_pointer_cast(theMessage); diff --git a/src/SketchSolver/SketchSolver_Storage.cpp b/src/SketchSolver/SketchSolver_Storage.cpp index 12bfdd869..9f6441e3f 100644 --- a/src/SketchSolver/SketchSolver_Storage.cpp +++ b/src/SketchSolver/SketchSolver_Storage.cpp @@ -32,6 +32,8 @@ #include #include +#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); diff --git a/src/SketchSolver/SolveSpaceSolver/SolveSpaceSolver_Storage.cpp b/src/SketchSolver/SolveSpaceSolver/SolveSpaceSolver_Storage.cpp index 1e941558c..7a829ed79 100644 --- a/src/SketchSolver/SolveSpaceSolver/SolveSpaceSolver_Storage.cpp +++ b/src/SketchSolver/SolveSpaceSolver/SolveSpaceSolver_Storage.cpp @@ -36,6 +36,8 @@ #include #include +#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::const_iterator anIt = myAttributeMap.begin();