X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FSketchSolver%2FSketchSolver_ConstraintMulti.cpp;h=bd0a82ad3206962483ae6a6bffa4b5d5fe5b5fa8;hb=176403004ff97696f3c0b5f8bdf48692177fb34a;hp=3994f776fba6829726dac40b550651f04ea588da;hpb=7fc47bce8911891f594ae0f0039cba632076a19f;p=modules%2Fshaper.git diff --git a/src/SketchSolver/SketchSolver_ConstraintMulti.cpp b/src/SketchSolver/SketchSolver_ConstraintMulti.cpp index 3994f776f..bd0a82ad3 100644 --- a/src/SketchSolver/SketchSolver_ConstraintMulti.cpp +++ b/src/SketchSolver/SketchSolver_ConstraintMulti.cpp @@ -1,3 +1,5 @@ +// Copyright (C) 2014-20xx CEA/DEN, EDF R&D + #include #include #include @@ -35,7 +37,8 @@ void SketchSolver_ConstraintMulti::getEntities(std::list& theE FeaturePtr aFeature; std::list anObjectList = aRefList->list(); std::list::iterator anObjIt = anObjectList.begin(); - if ((myNumberOfCopies + 1) * myNumberOfObjects != aRefList->size()) // execute for the feature is not called yet + // execute for the feature is not called yet + if ((myNumberOfCopies + 1) * myNumberOfObjects != aRefList->size()) myNumberOfCopies = aRefList->size() / myNumberOfObjects - 1; while (anObjIt != anObjectList.end()) { @@ -43,7 +46,9 @@ void SketchSolver_ConstraintMulti::getEntities(std::list& theE if (!aFeature) continue; - myStorage->update(aFeature); + // the entity is not created, so it is a copy in "multi" constraint, force its creation + if (!myStorage->update(aFeature)) + myStorage->update(aFeature, myGroupID, true); theEntities.push_back(myStorage->entity(aFeature)); myFeatures.insert(aFeature); for (int i = 0; i < myNumberOfCopies && anObjIt != anObjectList.end(); ++i, ++anObjIt) { @@ -72,7 +77,10 @@ void SketchSolver_ConstraintMulti::update(bool isForce) AttributeRefListPtr anInitialRefList = std::dynamic_pointer_cast( myBaseConstraint->attribute(SketchPlugin_Constraint::ENTITY_A())); AttributeIntegerPtr aNbObjects = myBaseConstraint->integer(nameNbObjects()); - bool isUpdated= anInitialRefList->size() != myNumberOfObjects || aNbObjects->value()-1 != myNumberOfCopies; + if (!anInitialRefList || !aNbObjects) + return; // the "Multi" constraint is in queue to remove + bool isUpdated = + anInitialRefList->size() != myNumberOfObjects || aNbObjects->value()-1 != myNumberOfCopies; if (!isUpdated) { // additional check that the features and their copies are changed AttributeRefListPtr aRefList = std::dynamic_pointer_cast( @@ -131,9 +139,16 @@ void SketchSolver_ConstraintMulti::adjustConstraint() for (; aSIt != aSubs.end(); ++aSIt) { if ((*aSIt)->type() != ENTITY_POINT) continue; - std::list aParameters = (*aSIt)->parameters(); - aXCoord = aParameters.front()->value(); - aYCoord = aParameters.back()->value(); + AttributePoint2DPtr aPoint = + std::dynamic_pointer_cast((*aSIt)->baseAttribute()); + if (aPoint) { + aXCoord = aPoint->x(); + aYCoord = aPoint->y(); + } else { + std::list aParameters = (*aSIt)->parameters(); + aXCoord = aParameters.front()->value(); + aYCoord = aParameters.back()->value(); + } getRelative(aXCoord, aYCoord, aXCoord, aYCoord); aX.push_back(aXCoord); aY.push_back(aYCoord); @@ -197,8 +212,8 @@ void SketchSolver_ConstraintMulti::adjustConstraint() bool SketchSolver_ConstraintMulti::isUsed(FeaturePtr theFeature) const { - return myFeatures.find(theFeature) != myFeatures.end() || - SketchSolver_Constraint::isUsed(theFeature); + return theFeature && (myFeatures.find(theFeature) != myFeatures.end() || + SketchSolver_Constraint::isUsed(theFeature)); } bool SketchSolver_ConstraintMulti::isUsed(AttributePtr theAttribute) const @@ -212,6 +227,8 @@ bool SketchSolver_ConstraintMulti::isUsed(AttributePtr theAttribute) const else anAttribute = aRefAttr->attr(); } + if (!anAttribute) + return false; FeaturePtr anOwner = ModelAPI_Feature::feature(anAttribute->owner()); return myFeatures.find(anOwner) != myFeatures.end();