X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FSketchSolver%2FSketchSolver_ConstraintGroup.cpp;h=f311546396df5e0c87daf3ab05c3ab0fad49e324;hb=2d309adb3c465a840e8f5ceeba28ec145e5a45a2;hp=7eff7e79bbab58a89e0d69f4eddabaa26e48494c;hpb=1b2cab75aa9df76d3fe6f791e2ddb2a065c8cf03;p=modules%2Fshaper.git diff --git a/src/SketchSolver/SketchSolver_ConstraintGroup.cpp b/src/SketchSolver/SketchSolver_ConstraintGroup.cpp index 7eff7e79b..f31154639 100644 --- a/src/SketchSolver/SketchSolver_ConstraintGroup.cpp +++ b/src/SketchSolver/SketchSolver_ConstraintGroup.cpp @@ -1,3 +1,5 @@ +// Copyright (C) 2014-20xx CEA/DEN, EDF R&D + // File: SketchSolver_ConstraintGroup.cpp // Created: 27 May 2014 // Author: Artem ZHIDKOV @@ -68,7 +70,7 @@ static int Search(const uint32_t& theEntityID, const std::vector& theEntities // ======================================================== SketchSolver_ConstraintGroup::SketchSolver_ConstraintGroup( - boost::shared_ptr theWorkplane) + std::shared_ptr theWorkplane) : myID(++myGroupIndexer), myParamMaxID(0), myEntityMaxID(0), @@ -116,7 +118,7 @@ SketchSolver_ConstraintGroup::~SketchSolver_ConstraintGroup() // Purpose: verify the group is based on the given workplane // ============================================================================ bool SketchSolver_ConstraintGroup::isBaseWorkplane( - boost::shared_ptr theWorkplane) const + std::shared_ptr theWorkplane) const { return theWorkplane == mySketch; } @@ -127,38 +129,46 @@ bool SketchSolver_ConstraintGroup::isBaseWorkplane( // Purpose: verify are there any entities in the group used by given constraint // ============================================================================ bool SketchSolver_ConstraintGroup::isInteract( - boost::shared_ptr theFeature) const + std::shared_ptr theFeature) const { // Check the group is empty if (isEmpty()) return true; + // Check if the feature is already in the group + if (myEntityFeatMap.find(theFeature) != myEntityFeatMap.end()) + return true; + std::shared_ptr aConstr = + std::dynamic_pointer_cast(theFeature); + if (aConstr && myConstraintMap.find(aConstr) != myConstraintMap.end()) + return true; + // Go through the attributes and verify if some of them already in the group - std::list> + std::list> anAttrList = theFeature->data()->attributes(std::string()); - std::list>::const_iterator + std::list>::const_iterator anAttrIter = anAttrList.begin(); for ( ; anAttrIter != anAttrList.end(); anAttrIter++) { - boost::shared_ptr aCAttrRef = - boost::dynamic_pointer_cast(*anAttrIter); + std::shared_ptr aCAttrRef = + std::dynamic_pointer_cast(*anAttrIter); if (!aCAttrRef || !aCAttrRef->isObject()) { - boost::shared_ptr anAttr = + std::shared_ptr anAttr = aCAttrRef ? aCAttrRef->attr() : *anAttrIter; if (myEntityAttrMap.find(anAttr) != myEntityAttrMap.end()) return true; } else { - ResultConstructionPtr aRC = boost::dynamic_pointer_cast( + ResultConstructionPtr aRC = std::dynamic_pointer_cast( aCAttrRef->object()); if (!aRC) continue; - boost::shared_ptr aDoc = aRC->document(); + std::shared_ptr aDoc = aRC->document(); FeaturePtr aFeature = aDoc->feature(aRC); if (myEntityFeatMap.find(aFeature) != myEntityFeatMap.end()) return true; // search attributes of a feature to be parameters of constraint - std::list > aFeatAttrList = + std::list > aFeatAttrList = aFeature->data()->attributes(std::string()); - std::list >::const_iterator aFAIter = aFeatAttrList + std::list >::const_iterator aFAIter = aFeatAttrList .begin(); for (; aFAIter != aFeatAttrList.end(); aFAIter++) if (myEntityAttrMap.find(*aFAIter) != myEntityAttrMap.end()) @@ -183,18 +193,18 @@ void SketchSolver_ConstraintGroup::checkConstraintConsistence(Slvs_Constraint& t // point coordinates int aPtPos = Search(theConstraint.ptA, myEntities); int aPtParamPos = Search(myEntities[aPtPos].param[0], myParams); - boost::shared_ptr aPoint( + std::shared_ptr aPoint( new GeomAPI_XY(myParams[aPtParamPos].val, myParams[aPtParamPos + 1].val)); // line coordinates int aLnPos = Search(theConstraint.entityA, myEntities); aPtPos = Search(myEntities[aLnPos].point[0], myEntities); aPtParamPos = Search(myEntities[aPtPos].param[0], myParams); - boost::shared_ptr aStart( + std::shared_ptr aStart( new GeomAPI_XY(-myParams[aPtParamPos].val, -myParams[aPtParamPos + 1].val)); aPtPos = Search(myEntities[aLnPos].point[1], myEntities); aPtParamPos = Search(myEntities[aPtPos].param[0], myParams); - boost::shared_ptr aEnd( + std::shared_ptr aEnd( new GeomAPI_XY(myParams[aPtParamPos].val, myParams[aPtParamPos + 1].val)); aEnd = aEnd->added(aStart); @@ -210,7 +220,7 @@ void SketchSolver_ConstraintGroup::checkConstraintConsistence(Slvs_Constraint& t // Purpose: create/update the constraint in the group // ============================================================================ bool SketchSolver_ConstraintGroup::changeConstraint( - boost::shared_ptr theConstraint) + std::shared_ptr theConstraint) { // There is no workplane yet, something wrong if (myWorkplane.h == SLVS_E_UNKNOWN) @@ -237,10 +247,14 @@ bool SketchSolver_ConstraintGroup::changeConstraint( // Create constraint parameters double aDistance = 0.0; // scalar value of the constraint - AttributeDoublePtr aDistAttr = boost::dynamic_pointer_cast( + AttributeDoublePtr aDistAttr = std::dynamic_pointer_cast( theConstraint->data()->attribute(SketchPlugin_Constraint::VALUE())); if (aDistAttr) { aDistance = aDistAttr->value(); + // Issue #196: checking the positivity of the distance constraint + if (aDistance < tolerance && + (aConstrType == SLVS_C_PT_PT_DISTANCE || aConstrType == SLVS_C_PT_LINE_DISTANCE)) + return false; // SketchPlugin circle defined by its radius, but SolveSpace uses constraint for diameter if (aConstrType == SLVS_C_DIAMETER) aDistance *= 2.0; @@ -255,7 +269,7 @@ bool SketchSolver_ConstraintGroup::changeConstraint( Slvs_hEntity aConstrEnt[CONSTRAINT_ATTR_SIZE]; // parameters of the constraint for (unsigned int indAttr = 0; indAttr < CONSTRAINT_ATTR_SIZE; indAttr++) { aConstrEnt[indAttr] = SLVS_E_UNKNOWN; - boost::shared_ptr aConstrAttr = boost::dynamic_pointer_cast< + std::shared_ptr aConstrAttr = std::dynamic_pointer_cast< ModelAPI_AttributeRefAttr>( theConstraint->data()->attribute(aConstraintAttributes[indAttr])); if (!aConstrAttr) @@ -264,18 +278,18 @@ bool SketchSolver_ConstraintGroup::changeConstraint( // Convert the object of the attribute to the feature FeaturePtr aFeature; if (aConstrAttr->isObject() && aConstrAttr->object()) { - ResultConstructionPtr aRC = boost::dynamic_pointer_cast( + ResultConstructionPtr aRC = std::dynamic_pointer_cast( aConstrAttr->object()); if (!aRC) continue; - boost::shared_ptr aDoc = aRC->document(); + std::shared_ptr aDoc = aRC->document(); aFeature = aDoc->feature(aRC); } // For the length constraint the start and end points of the line should be added to the entities list instead of line if (aConstrType == SLVS_C_PT_PT_DISTANCE && theConstraint->getKind().compare(SketchPlugin_ConstraintLength::ID()) == 0) { - Slvs_hEntity aLineEnt = changeEntity(aFeature); + Slvs_hEntity aLineEnt = changeEntityFeature(aFeature); int aEntPos = Search(aLineEnt, myEntities); aConstrEnt[indAttr++] = myEntities[aEntPos].point[0]; aConstrEnt[indAttr++] = myEntities[aEntPos].point[1]; @@ -283,7 +297,7 @@ bool SketchSolver_ConstraintGroup::changeConstraint( aConstrEnt[indAttr++] = 0; break; // there should be no other entities } else if (aConstrAttr->isObject()) - aConstrEnt[indAttr] = changeEntity(aFeature); + aConstrEnt[indAttr] = changeEntityFeature(aFeature); else aConstrEnt[indAttr] = changeEntity(aConstrAttr->attr()); } @@ -384,7 +398,7 @@ bool SketchSolver_ConstraintGroup::changeConstraint( // Purpose: create/update the "Rigid" constraint in the group // ============================================================================ bool SketchSolver_ConstraintGroup::changeRigidConstraint( - boost::shared_ptr theConstraint) + std::shared_ptr theConstraint) { // Search this constraint in the current group to update it ConstraintMap::const_iterator aConstrMapIter = myConstraintMap.find(theConstraint); @@ -403,7 +417,7 @@ bool SketchSolver_ConstraintGroup::changeRigidConstraint( const std::vector& aConstraintAttributes = aConstraint.getAttributes(); Slvs_hEntity aConstrEnt = SLVS_E_UNKNOWN; - boost::shared_ptr aConstrAttr = boost::dynamic_pointer_cast< + std::shared_ptr aConstrAttr = std::dynamic_pointer_cast< ModelAPI_AttributeRefAttr>( theConstraint->data()->attribute(aConstraintAttributes[0])); if (!aConstrAttr) @@ -412,24 +426,24 @@ bool SketchSolver_ConstraintGroup::changeRigidConstraint( // Convert the object of the attribute to the feature FeaturePtr aFeature; if (aConstrAttr->isObject() && aConstrAttr->object()) { - ResultConstructionPtr aRC = boost::dynamic_pointer_cast( + ResultConstructionPtr aRC = std::dynamic_pointer_cast( aConstrAttr->object()); if (!aRC) return false; - boost::shared_ptr aDoc = aRC->document(); + std::shared_ptr aDoc = aRC->document(); aFeature = aDoc->feature(aRC); } - aConstrEnt = aConstrAttr->isObject() ? changeEntity(aFeature) : changeEntity(aConstrAttr->attr()); + aConstrEnt = aConstrAttr->isObject() ? changeEntityFeature(aFeature) : changeEntity(aConstrAttr->attr()); if (aConstrMapIter == myConstraintMap.end()) { // Add new constraint // Check the fixed entity is not a point. - boost::shared_ptr aConstrAttr = boost::dynamic_pointer_cast< + std::shared_ptr aConstrAttr = std::dynamic_pointer_cast< ModelAPI_AttributeRefAttr>(theConstraint->data()->attribute(aConstraintAttributes[0])); - boost::shared_ptr aPoint = - boost::dynamic_pointer_cast(aConstrAttr->attr()); - boost::shared_ptr aPoint2D = - boost::dynamic_pointer_cast(aConstrAttr->attr()); + std::shared_ptr aPoint = + std::dynamic_pointer_cast(aConstrAttr->attr()); + std::shared_ptr aPoint2D = + std::dynamic_pointer_cast(aConstrAttr->attr()); if (aPoint || aPoint2D) { // Create SolveSpace constraint structure Slvs_Constraint aConstraint = Slvs_MakeConstraint( @@ -451,16 +465,16 @@ bool SketchSolver_ConstraintGroup::changeRigidConstraint( bool isCircle = false; if (aFeature) { if (aFeature->getKind() == SketchPlugin_Arc::ID()) { - boost::shared_ptr aCenter = - boost::dynamic_pointer_cast( + std::shared_ptr aCenter = + std::dynamic_pointer_cast( aFeature->data()->attribute(SketchPlugin_Arc::CENTER_ID())); - boost::shared_ptr aStart = - boost::dynamic_pointer_cast( + std::shared_ptr aStart = + std::dynamic_pointer_cast( aFeature->data()->attribute(SketchPlugin_Arc::START_ID())); aRadius = aStart->pnt()->distance(aCenter->pnt()); isArc = true; } else if (aFeature->getKind() == SketchPlugin_Circle::ID()) { - aRadius = boost::dynamic_pointer_cast( + aRadius = std::dynamic_pointer_cast( aFeature->data()->attribute(SketchPlugin_Circle::RADIUS_ID()))->value(); isCircle = true; } @@ -532,10 +546,10 @@ bool SketchSolver_ConstraintGroup::changeRigidConstraint( // Purpose: create/update the element affected by any constraint // ============================================================================ Slvs_hEntity SketchSolver_ConstraintGroup::changeEntity( - boost::shared_ptr theEntity) + std::shared_ptr theEntity) { // If the entity is already in the group, try to find it - std::map, Slvs_hEntity>::const_iterator aEntIter = + std::map, Slvs_hEntity>::const_iterator aEntIter = myEntityAttrMap.find(theEntity); int aEntPos; std::vector::const_iterator aParamIter; // looks at first parameter of already existent entity or at the end of vector otherwise @@ -577,7 +591,7 @@ Slvs_hEntity SketchSolver_ConstraintGroup::changeEntity( aNewEntity.h = SLVS_E_UNKNOWN; // Point in 3D - boost::shared_ptr aPoint = boost::dynamic_pointer_cast( + std::shared_ptr aPoint = std::dynamic_pointer_cast( theEntity); if (aPoint) { Slvs_hParam aX = changeParameter(aPoint->x(), aParamIter); @@ -591,8 +605,8 @@ Slvs_hEntity SketchSolver_ConstraintGroup::changeEntity( return SLVS_E_UNKNOWN; // Point in 2D - boost::shared_ptr aPoint2D = - boost::dynamic_pointer_cast(theEntity); + std::shared_ptr aPoint2D = + std::dynamic_pointer_cast(theEntity); if (aPoint2D) { Slvs_hParam aU = changeParameter(aPoint2D->x(), aParamIter); Slvs_hParam aV = changeParameter(aPoint2D->y(), aParamIter); @@ -600,7 +614,7 @@ Slvs_hEntity SketchSolver_ConstraintGroup::changeEntity( aNewEntity = Slvs_MakePoint2d(++myEntityMaxID, myID, myWorkplane.h, aU, aV); } else { // Scalar value (used for the distance entities) - AttributeDoublePtr aScalar = boost::dynamic_pointer_cast(theEntity); + AttributeDoublePtr aScalar = std::dynamic_pointer_cast(theEntity); if (aScalar) { Slvs_hParam aValue = changeParameter(aScalar->value(), aParamIter); if (!isEntExists) // New entity @@ -634,7 +648,7 @@ Slvs_hEntity SketchSolver_ConstraintGroup::changeEntity( // Class: SketchSolver_ConstraintGroup // Purpose: create/update the element defined by the feature affected by any constraint // ============================================================================ -Slvs_hEntity SketchSolver_ConstraintGroup::changeEntity(FeaturePtr theEntity) +Slvs_hEntity SketchSolver_ConstraintGroup::changeEntityFeature(FeaturePtr theEntity) { if (!theEntity->data()->isValid()) return SLVS_E_UNKNOWN; @@ -647,7 +661,7 @@ Slvs_hEntity SketchSolver_ConstraintGroup::changeEntity(FeaturePtr theEntity) aNewEntity.h = SLVS_E_UNKNOWN; // SketchPlugin features - boost::shared_ptr aFeature = boost::dynamic_pointer_cast< + std::shared_ptr aFeature = std::dynamic_pointer_cast< SketchPlugin_Feature>(theEntity); if (aFeature) { // Verify the feature by its kind const std::string& aFeatureKind = aFeature->getKind(); @@ -736,11 +750,11 @@ Slvs_hEntity SketchSolver_ConstraintGroup::changeEntity(FeaturePtr theEntity) // Purpose: create/update the normal of workplane // ============================================================================ Slvs_hEntity SketchSolver_ConstraintGroup::changeNormal( - boost::shared_ptr theDirX, boost::shared_ptr theDirY, - boost::shared_ptr theNorm) + std::shared_ptr theDirX, std::shared_ptr theDirY, + std::shared_ptr theNorm) { - boost::shared_ptr aDirX = boost::dynamic_pointer_cast(theDirX); - boost::shared_ptr aDirY = boost::dynamic_pointer_cast(theDirY); + std::shared_ptr aDirX = std::dynamic_pointer_cast(theDirX); + std::shared_ptr aDirY = std::dynamic_pointer_cast(theDirY); if (!aDirX || !aDirY || (fabs(aDirX->x()) + fabs(aDirX->y()) + fabs(aDirX->z()) < tolerance) || (fabs(aDirY->x()) + fabs(aDirY->y()) + fabs(aDirY->z()) < tolerance)) return SLVS_E_UNKNOWN; @@ -752,7 +766,7 @@ Slvs_hEntity SketchSolver_ConstraintGroup::changeNormal( double aNormCoord[4] = { qw, qx, qy, qz }; // Try to find existent normal - std::map, Slvs_hEntity>::const_iterator aEntIter = + std::map, Slvs_hEntity>::const_iterator aEntIter = myEntityAttrMap.find(theNorm); std::vector::const_iterator aParamIter; // looks to the first parameter of already existent entity or to the end of vector otherwise if (aEntIter == myEntityAttrMap.end()) // no such entity => should be created @@ -785,7 +799,7 @@ Slvs_hEntity SketchSolver_ConstraintGroup::changeNormal( // Class: SketchSolver_ConstraintGroup // Purpose: create workplane for the group // ============================================================================ -bool SketchSolver_ConstraintGroup::addWorkplane(boost::shared_ptr theSketch) +bool SketchSolver_ConstraintGroup::addWorkplane(std::shared_ptr theSketch) { if (myWorkplane.h || theSketch->getKind().compare(SketchPlugin_Sketch::ID()) != 0) return false; // the workplane already exists or the function parameter is not Sketch @@ -805,13 +819,13 @@ bool SketchSolver_ConstraintGroup::updateWorkplane() if (!mySketch->data()) return false; // case sketch is deleted // Get parameters of workplane - boost::shared_ptr aDirX = mySketch->data()->attribute( + std::shared_ptr aDirX = mySketch->data()->attribute( SketchPlugin_Sketch::DIRX_ID()); - boost::shared_ptr aDirY = mySketch->data()->attribute( + std::shared_ptr aDirY = mySketch->data()->attribute( SketchPlugin_Sketch::DIRY_ID()); - boost::shared_ptr aNorm = mySketch->data()->attribute( + std::shared_ptr aNorm = mySketch->data()->attribute( SketchPlugin_Sketch::NORM_ID()); - boost::shared_ptr anOrigin = mySketch->data()->attribute( + std::shared_ptr anOrigin = mySketch->data()->attribute( SketchPlugin_Sketch::ORIGIN_ID()); // Transform them into SolveSpace format Slvs_hEntity aNormalWP = changeNormal(aDirX, aDirY, aNorm); @@ -881,7 +895,7 @@ bool SketchSolver_ConstraintGroup::resolveConstraints() return true; // We should go through the attributes map, because only attributes have valued parameters - std::map, Slvs_hEntity>::iterator anEntIter = + std::map, Slvs_hEntity>::iterator anEntIter = myEntityAttrMap.begin(); for (; anEntIter != myEntityAttrMap.end(); anEntIter++) if (updateAttribute(anEntIter->first, anEntIter->second)) @@ -926,7 +940,7 @@ void SketchSolver_ConstraintGroup::mergeGroups(const SketchSolver_ConstraintGrou if (myTempPointWhereDragged.empty()) myTempPointWhereDragged = theGroup.myTempPointWhereDragged; else if (!theGroup.myTempPointWhereDragged.empty()) { // Need to create additional transient constraint - std::map, Slvs_hEntity>::const_iterator aFeatureIter = + std::map, Slvs_hEntity>::const_iterator aFeatureIter = theGroup.myEntityAttrMap.begin(); for (; aFeatureIter != theGroup.myEntityAttrMap.end(); aFeatureIter++) if (aFeatureIter->second == myTempPointWDrgdID) { @@ -963,9 +977,11 @@ void SketchSolver_ConstraintGroup::splitGroup(std::vectorfind(aConstrEnt[i]) != aGrEntIter->end()); // Also we need to check sub-entities int aEntPos = Search(aConstrEnt[i], myEntities); - Slvs_hEntity* aSub = myEntities[aEntPos].point; - for (int j = 0; *aSub != 0 && j < 4 && !isFound; aSub++, j++) - isFound = (aGrEntIter->find(*aSub) != aGrEntIter->end()); + if (aEntPos != myEntities.size()) { // MPV: to fix the crash on close + Slvs_hEntity* aSub = myEntities[aEntPos].point; + for (int j = 0; *aSub != 0 && j < 4 && !isFound; aSub++, j++) + isFound = (aGrEntIter->find(*aSub) != aGrEntIter->end()); + } } if (isFound) anIndexes.push_back(aGrEntIter - aGroupsEntities.begin()); @@ -977,9 +993,11 @@ void SketchSolver_ConstraintGroup::splitGroup(std::vector aNewGrConstr; aNewGrConstr.insert(aConstrIter->h); @@ -994,9 +1012,11 @@ void SketchSolver_ConstraintGroup::splitGroup(std::vectorinsert(aConstrEnt[i]); int aEntPos = Search(aConstrEnt[i], myEntities); - Slvs_hEntity* aSub = myEntities[aEntPos].point; - for (int j = 0; *aSub != 0 && j < 4; aSub++, j++) - aGrEntIter->insert(*aSub); + if (aEntPos != myEntities.size()) { // MPV: to fix the crash on close + Slvs_hEntity* aSub = myEntities[aEntPos].point; + for (int j = 0; *aSub != 0 && j < 4; aSub++, j++) + aGrEntIter->insert(*aSub); + } } aGroupsConstr[anIndexes.front()].insert(aConstrIter->h); if (aGrEntIter->size() > aGroupsEntities[aMaxNbEntities].size()) @@ -1088,13 +1108,13 @@ bool SketchSolver_ConstraintGroup::updateGroup() // Check if some entities are invalid too std::set anEntToRemove; - std::map, Slvs_hEntity>::iterator + std::map, Slvs_hEntity>::iterator anAttrIter = myEntityAttrMap.begin(); while (anAttrIter != myEntityAttrMap.end()) { if (!anAttrIter->first->owner() || !anAttrIter->first->owner()->data() || !anAttrIter->first->owner()->data()->isValid()) { anEntToRemove.insert(anAttrIter->second); - std::map, Slvs_hEntity>::iterator + std::map, Slvs_hEntity>::iterator aRemovedIter = anAttrIter; anAttrIter++; myEntityAttrMap.erase(aRemovedIter); @@ -1117,10 +1137,10 @@ bool SketchSolver_ConstraintGroup::updateGroup() // Probably, need to update coincidence constraints if (isCCRemoved && !myExtraCoincidence.empty()) { // Make a copy, because the new list of unused constrtaints will be generated - std::set > anExtraCopy = myExtraCoincidence; + std::set > anExtraCopy = myExtraCoincidence; myExtraCoincidence.clear(); - std::set >::iterator aCIter = anExtraCopy.begin(); + std::set >::iterator aCIter = anExtraCopy.begin(); for (; aCIter != anExtraCopy.end(); aCIter++) if ((*aCIter)->data() && (*aCIter)->data()->isValid()) changeConstraint(*aCIter); @@ -1135,7 +1155,7 @@ bool SketchSolver_ConstraintGroup::updateGroup() // Purpose: update features of sketch after resolving constraints // ============================================================================ bool SketchSolver_ConstraintGroup::updateAttribute( - boost::shared_ptr theAttribute, const Slvs_hEntity& theEntityID) + std::shared_ptr theAttribute, const Slvs_hEntity& theEntityID) { // Search the position of the first parameter of the entity int anEntPos = Search(theEntityID, myEntities); @@ -1144,7 +1164,7 @@ bool SketchSolver_ConstraintGroup::updateAttribute( // Look over supported types of entities // Point in 3D - boost::shared_ptr aPoint = boost::dynamic_pointer_cast( + std::shared_ptr aPoint = std::dynamic_pointer_cast( theAttribute); if (aPoint) { if (fabs(aPoint->x() - myParams[aFirstParamPos].val) > tolerance @@ -1158,8 +1178,8 @@ bool SketchSolver_ConstraintGroup::updateAttribute( } // Point in 2D - boost::shared_ptr aPoint2D = - boost::dynamic_pointer_cast(theAttribute); + std::shared_ptr aPoint2D = + std::dynamic_pointer_cast(theAttribute); if (aPoint2D) { if (fabs(aPoint2D->x() - myParams[aFirstParamPos].val) > tolerance || fabs(aPoint2D->y() - myParams[aFirstParamPos + 1].val) > tolerance) { @@ -1170,7 +1190,7 @@ bool SketchSolver_ConstraintGroup::updateAttribute( } // Scalar value - AttributeDoublePtr aScalar = boost::dynamic_pointer_cast(theAttribute); + AttributeDoublePtr aScalar = std::dynamic_pointer_cast(theAttribute); if (aScalar) { if (fabs(aScalar->value() - myParams[aFirstParamPos].val) > tolerance) { aScalar->setValue(myParams[aFirstParamPos].val); @@ -1189,7 +1209,7 @@ bool SketchSolver_ConstraintGroup::updateAttribute( // Purpose: search the entity in this group and update it // ============================================================================ void SketchSolver_ConstraintGroup::updateEntityIfPossible( - boost::shared_ptr theEntity) + std::shared_ptr theEntity) { if (myEntityAttrMap.find(theEntity) != myEntityAttrMap.end()) { // If the attribute is a point and it is changed (the group needs to rebuild), @@ -1205,9 +1225,9 @@ void SketchSolver_ConstraintGroup::updateEntityIfPossible( if (myNeedToSolve) // the entity is changed { // Verify the entity is a point and add temporary constraint of permanency - boost::shared_ptr aPoint = boost::dynamic_pointer_cast( + std::shared_ptr aPoint = std::dynamic_pointer_cast( theEntity); - boost::shared_ptr aPoint2D = boost::dynamic_pointer_cast< + std::shared_ptr aPoint2D = std::dynamic_pointer_cast< GeomDataAPI_Point2D>(theEntity); if (aPoint || aPoint2D) addTemporaryConstraintWhereDragged(theEntity); @@ -1228,11 +1248,11 @@ void SketchSolver_ConstraintGroup::updateEntityIfPossible( // which was moved by user // ============================================================================ void SketchSolver_ConstraintGroup::addTemporaryConstraintWhereDragged( - boost::shared_ptr theEntity, + std::shared_ptr theEntity, bool theAllowToFit) { // Find identifier of the entity - std::map, Slvs_hEntity>::const_iterator anEntIter = + std::map, Slvs_hEntity>::const_iterator anEntIter = myEntityAttrMap.find(theEntity); if (anEntIter == myEntityAttrMap.end()) return; @@ -1320,7 +1340,7 @@ void SketchSolver_ConstraintGroup::removeTemporaryConstraints( // Purpose: remove constraint and all unused entities // ============================================================================ void SketchSolver_ConstraintGroup::removeConstraint( - boost::shared_ptr theConstraint) + std::shared_ptr theConstraint) { ConstraintMap::iterator anIterToRemove = myConstraintMap.find(theConstraint); if (anIterToRemove == myConstraintMap.end()) @@ -1374,11 +1394,11 @@ void SketchSolver_ConstraintGroup::removeConstraint( return; // Remove unused entities - std::map, Slvs_hEntity>::iterator anEntAttrIter = + std::map, Slvs_hEntity>::iterator anEntAttrIter = myEntityAttrMap.begin(); while (anEntAttrIter != myEntityAttrMap.end()) { if (anEntToRemove.find(anEntAttrIter->second) != anEntToRemove.end()) { - std::map, Slvs_hEntity>::iterator aRemovedIter = + std::map, Slvs_hEntity>::iterator aRemovedIter = anEntAttrIter; anEntAttrIter++; myEntityAttrMap.erase(aRemovedIter); @@ -1485,17 +1505,17 @@ bool SketchSolver_ConstraintGroup::addCoincidentPoints(const Slvs_hEntity& thePo // Purpose: emit the signal to update constraints // ============================================================================ void SketchSolver_ConstraintGroup::updateRelatedConstraints( - boost::shared_ptr theEntity) const + std::shared_ptr theEntity) const { ConstraintMap::const_iterator aConstrIter = myConstraintMap.begin(); for (; aConstrIter != myConstraintMap.end(); aConstrIter++) { - std::list > anAttributes = aConstrIter->first->data() + std::list > anAttributes = aConstrIter->first->data() ->attributes(std::string()); - std::list >::iterator anAttrIter = anAttributes.begin(); + std::list >::iterator anAttrIter = anAttributes.begin(); for (; anAttrIter != anAttributes.end(); anAttrIter++) { bool isUpd = (*anAttrIter == theEntity); - boost::shared_ptr aRefAttr = boost::dynamic_pointer_cast< + std::shared_ptr aRefAttr = std::dynamic_pointer_cast< ModelAPI_AttributeRefAttr>(*anAttrIter); if (aRefAttr && !aRefAttr->isObject() && aRefAttr->attr() == theEntity) isUpd = true; @@ -1509,17 +1529,17 @@ void SketchSolver_ConstraintGroup::updateRelatedConstraints( } } -void SketchSolver_ConstraintGroup::updateRelatedConstraints( - boost::shared_ptr theFeature) const +void SketchSolver_ConstraintGroup::updateRelatedConstraintsFeature( + std::shared_ptr theFeature) const { ConstraintMap::const_iterator aConstrIter = myConstraintMap.begin(); for (; aConstrIter != myConstraintMap.end(); aConstrIter++) { - std::list > anAttributes = aConstrIter->first->data() + std::list > anAttributes = aConstrIter->first->data() ->attributes(std::string()); - std::list >::iterator anAttrIter = anAttributes.begin(); + std::list >::iterator anAttrIter = anAttributes.begin(); for (; anAttrIter != anAttributes.end(); anAttrIter++) { - boost::shared_ptr aRefAttr = boost::dynamic_pointer_cast< + std::shared_ptr aRefAttr = std::dynamic_pointer_cast< ModelAPI_AttributeRefAttr>(*anAttrIter); if (aRefAttr && aRefAttr->isObject() && aRefAttr->object() == theFeature) { static Events_ID anEvent = Events_Loop::eventByName(EVENT_OBJECT_UPDATED);