X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FSketchSolver%2FSketchSolver_Manager.cpp;h=80f1f98ef7349e26fcc46d12c48a5fec78a01b5e;hb=9dc1fc2ff6f4143369cdb2042a5e01e8e737c635;hp=2449d61c0bede9df7f75cc92cb5cb3d47de24e0d;hpb=876df3f1e552699e9bea75c48245e92e1bedd81e;p=modules%2Fshaper.git diff --git a/src/SketchSolver/SketchSolver_Manager.cpp b/src/SketchSolver/SketchSolver_Manager.cpp index 2449d61c0..80f1f98ef 100644 --- a/src/SketchSolver/SketchSolver_Manager.cpp +++ b/src/SketchSolver/SketchSolver_Manager.cpp @@ -116,7 +116,8 @@ void SketchSolver_Manager::processEvent( const std::shared_ptr& theMessage) { static const Events_ID aSketchPreparedEvent = Events_Loop::eventByName(EVENT_SKETCH_PREPARED); - // sketch is prepared for resolve: all the needed events are collected and must be processed by the solver + // sketch is prepared for resolve: all the needed events + // are collected and must be processed by the solver if (theMessage->eventID() == aSketchPreparedEvent) { flushGrouped(anUpdateEvent); return; @@ -145,7 +146,7 @@ void SketchSolver_Manager::processEvent( if (isMovedEvt) { std::set::iterator aFeatIter; for (aFeatIter = aFeatures.begin(); aFeatIter != aFeatures.end(); aFeatIter++) { - std::shared_ptr aSFeature = + std::shared_ptr aSFeature = std::dynamic_pointer_cast(*aFeatIter); if (aSFeature && moveEntity(aSFeature)) { // Want to avoid recalculation of DoF too frequently. @@ -153,21 +154,23 @@ void SketchSolver_Manager::processEvent( hasProperFeature = true; } } - if (!hasProperFeature) // in this iteration it will compute nothing, so, no problem with recursion - // it is important that solver flushes signal updated after processing move signal as there is - // optimization that relies on this update, might be found by key "optimization" + if (!hasProperFeature) + // in this iteration it will compute nothing, so, no problem with recursion + // it is important that solver flushes signal updated after processing move signal as there + // is optimization that relies on this update, might be found by key "optimization" myIsComputed = false; } else { - std::list aSketchFeatures = SketchSolver_Group::selectApplicableFeatures(aFeatures); + std::list aSketchFeatures = + SketchSolver_Group::selectApplicableFeatures(aFeatures); std::list::iterator aFeatIter = aSketchFeatures.begin(); for (; aFeatIter != aSketchFeatures.end(); ++aFeatIter) { if ((*aFeatIter)->getKind() == SketchPlugin_Sketch::ID()) { - std::shared_ptr aSketch = + std::shared_ptr aSketch = std::dynamic_pointer_cast(*aFeatIter); hasProperFeature = changeWorkplane(aSketch) || hasProperFeature; continue; } - std::shared_ptr aFeature = + std::shared_ptr aFeature = std::dynamic_pointer_cast(*aFeatIter); if (!aFeature) continue; @@ -195,7 +198,8 @@ void SketchSolver_Manager::processEvent( std::dynamic_pointer_cast(theMessage); const std::set& aFeatureGroups = aDeleteMsg->groups(); - // Find SketchPlugin_Sketch::ID() in groups. The constraint groups should be updated when an object removed from Sketch + // Find SketchPlugin_Sketch::ID() in groups. + // The constraint groups should be updated when an object removed from Sketch std::set::const_iterator aFGrIter; for (aFGrIter = aFeatureGroups.begin(); aFGrIter != aFeatureGroups.end(); aFGrIter++) if (aFGrIter->compare(ModelAPI_ResultConstruction::group()) == 0 || @@ -214,7 +218,8 @@ void SketchSolver_Manager::processEvent( myGroups.erase(aRemoveIt); continue; } - if (!(*aGroupIter)->isConsistent()) { // some constraints were removed, try to split the group + if (!(*aGroupIter)->isConsistent()) { + // some constraints were removed, try to split the group (*aGroupIter)->splitGroup(aSeparatedGroups); if (!(*aGroupIter)->getWorkplane()->string( SketchPlugin_Sketch::SOLVER_ERROR())->value().empty() || @@ -239,7 +244,8 @@ void SketchSolver_Manager::processEvent( degreesOfFreedom(); } -void SketchSolver_Manager::checkConflictingConstraints(const std::shared_ptr& theMessage) +void SketchSolver_Manager:: + checkConflictingConstraints(const std::shared_ptr& theMessage) { if (theMessage->eventID() == Events_Loop::loop()->eventByName(EVENT_SOLVER_REPAIRED)) { std::shared_ptr aMessage = @@ -312,7 +318,7 @@ bool SketchSolver_Manager::changeFeature(std::shared_ptr t std::set aGroups; findGroups(theFeature, aGroups); - std::shared_ptr aConstraint = + std::shared_ptr aConstraint = std::dynamic_pointer_cast(theFeature); // Process the groups list @@ -340,7 +346,8 @@ bool SketchSolver_Manager::changeFeature(std::shared_ptr t return (*aGroupIter)->updateFeature(theFeature); return (*aGroupIter)->changeConstraint(aConstraint); } - } else if (aGroups.size() > 1) { // Several groups applicable for this feature => need to merge them + } else if (aGroups.size() > 1) { + // Several groups applicable for this feature => need to merge them std::set::const_iterator aGroupsIter = aGroups.begin(); // Search first group @@ -490,7 +497,8 @@ std::shared_ptr SketchSolver_Manager bool SketchSolver_Manager::resolveConstraints(const std::list& theGroups) { bool needToUpdate = false; - const std::list& aGroupsToResolve = theGroups.empty() ? myGroups : theGroups; + const std::list& aGroupsToResolve = theGroups.empty() ? + myGroups : theGroups; std::list::const_iterator aGroupIter = aGroupsToResolve.begin(); for (; aGroupIter != aGroupsToResolve.end(); aGroupIter++) if ((*aGroupIter)->resolveConstraints()) @@ -500,7 +508,8 @@ bool SketchSolver_Manager::resolveConstraints(const std::list >& thePoints) +static void collectPointsAndCopies(FeaturePtr theConstraint, + std::list >& thePoints) { typedef std::list strlist; static strlist aPointAttributes(1, SketchPlugin_Point::COORD_ID()); @@ -625,7 +634,8 @@ void SketchSolver_Manager::degreesOfFreedom() if (isSketchValid) { std::shared_ptr aNormal = - std::dynamic_pointer_cast(aSketch->data()->attribute(SketchPlugin_Sketch::NORM_ID())); + std::dynamic_pointer_cast( + aSketch->data()->attribute(SketchPlugin_Sketch::NORM_ID())); isSketchValid = aNormal && aNormal->isInitialized(); } @@ -711,7 +721,8 @@ void SketchSolver_Manager::degreesOfFreedom() } else { aDoF -= 1; if (aCoincPoint[0] && aCoincLine) { - // if the point is already coincident to a line (by middle point constraint), do not decrease DoF + // if the point is already coincident to a line + // (by middle point constraint), do not decrease DoF std::map >::iterator aPtFound = aPointOnLine.find(aCoincPoint[0]); if (aPtFound != aPointOnLine.end() && @@ -765,7 +776,8 @@ void SketchSolver_Manager::degreesOfFreedom() if (isExternal(anAttr)) continue; // feature is already fixed since it is external aDoF -= aDoFDelta[anAttr->getKind()]; - std::list aPtAttrs = anAttr->data()->attributes(GeomDataAPI_Point2D::typeId()); + std::list aPtAttrs = + anAttr->data()->attributes(GeomDataAPI_Point2D::typeId()); aPoints.insert(aPtAttrs.begin(), aPtAttrs.end()); } } @@ -811,9 +823,11 @@ void SketchSolver_Manager::degreesOfFreedom() anAttrName = SketchPlugin_Constraint::ENTITY_B(); else { if (aFeature->getKind() == SketchPlugin_MultiRotation::ID()) - aNbCopies = aFeature->integer(SketchPlugin_MultiRotation::NUMBER_OF_OBJECTS_ID())->value() - 1; + aNbCopies = + aFeature->integer(SketchPlugin_MultiRotation::NUMBER_OF_OBJECTS_ID())->value() - 1; else if (aFeature->getKind() == SketchPlugin_MultiTranslation::ID()) - aNbCopies = aFeature->integer(SketchPlugin_MultiTranslation::NUMBER_OF_OBJECTS_ID())->value() - 1; + aNbCopies = + aFeature->integer(SketchPlugin_MultiTranslation::NUMBER_OF_OBJECTS_ID())->value() - 1; anAttrName = SketchPlugin_Constraint::ENTITY_A(); }