X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FSketchSolver%2FPlaneGCSSolver%2FPlaneGCSSolver_ConstraintWrapper.cpp;h=b5f452b5a940dac01791f914f61a5f607adf880e;hb=87447545000c44e455431ed0d401f850f373374e;hp=db932e8b03fdae0e004d7ac8eae6794373f97972;hpb=29f1c8ff3eb53f7ba5dd54ead45d3e55775e5968;p=modules%2Fshaper.git diff --git a/src/SketchSolver/PlaneGCSSolver/PlaneGCSSolver_ConstraintWrapper.cpp b/src/SketchSolver/PlaneGCSSolver/PlaneGCSSolver_ConstraintWrapper.cpp index db932e8b0..b5f452b5a 100644 --- a/src/SketchSolver/PlaneGCSSolver/PlaneGCSSolver_ConstraintWrapper.cpp +++ b/src/SketchSolver/PlaneGCSSolver/PlaneGCSSolver_ConstraintWrapper.cpp @@ -1,128 +1,58 @@ -// Copyright (C) 2014-20xx CEA/DEN, EDF R&D - -// File: PlaneGCSSolver_ConstraintWrapper.cpp -// Created: 14 Dec 2015 -// Author: Artem ZHIDKOV +// Copyright (C) 2014-2020 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// #include -#include - PlaneGCSSolver_ConstraintWrapper::PlaneGCSSolver_ConstraintWrapper( - const ConstraintPtr& theOriginal, const GCSConstraintPtr& theConstraint, const SketchSolver_ConstraintType& theType) : myGCSConstraints(1, theConstraint), - myType(theType), - myID(CID_UNKNOWN) + myType(theType) { - myBaseConstraint = theOriginal; - myValue = 0.0; + myID = CID_UNKNOWN; } PlaneGCSSolver_ConstraintWrapper::PlaneGCSSolver_ConstraintWrapper( - const ConstraintPtr& theOriginal, const std::list& theConstraints, const SketchSolver_ConstraintType& theType) : myGCSConstraints(theConstraints), - myType(theType), - myID(CID_UNKNOWN) -{ - myBaseConstraint = theOriginal; - myValue = 0.0; -} - -void PlaneGCSSolver_ConstraintWrapper::setValueParameter(const ParameterWrapperPtr& theValue) -{ - myValueParam = theValue; - myValue = myValueParam->value(); -} - -void PlaneGCSSolver_ConstraintWrapper::setValue(const double& theValue) -{ - myValue = theValue; - myValueParam->setValue(theValue); -} - - -void PlaneGCSSolver_ConstraintWrapper::setGroup(const GroupID& theGroup) + myType(theType) { - myGroup = theGroup; - std::list::iterator aSubsIt = myConstrained.begin(); - for (; aSubsIt != myConstrained.end(); ++aSubsIt) - (*aSubsIt)->setGroup(theGroup); + myID = CID_UNKNOWN; } -bool PlaneGCSSolver_ConstraintWrapper::isUsed(FeaturePtr theFeature) const +void PlaneGCSSolver_ConstraintWrapper::setId(const ConstraintID& theID) { - std::list::const_iterator anIt = myConstrained.begin(); - for (; anIt != myConstrained.end(); ++anIt) - if ((*anIt)->isUsed(theFeature)) - return true; - return false; + myID = theID; } -bool PlaneGCSSolver_ConstraintWrapper::isUsed(AttributePtr theAttribute) const +void PlaneGCSSolver_ConstraintWrapper::setValueParameter(const ScalarWrapperPtr& theValue) { - std::list::const_iterator anIt = myConstrained.begin(); - for (; anIt != myConstrained.end(); ++anIt) - if ((*anIt)->isUsed(theAttribute)) - return true; - return false; + myValueParam = theValue; } -bool PlaneGCSSolver_ConstraintWrapper::isEqual(const ConstraintWrapperPtr& theOther) +void PlaneGCSSolver_ConstraintWrapper::setValue(const double& theValue) { - if (type() != theOther->type()) - return false; -//// const Slvs_Constraint anOtherConstraint = -//// std::dynamic_pointer_cast(theOther)->constraint(); -//// if (mySlvsConstraint.type != anOtherConstraint.type) -//// return false; -//// -//// // Verify SolveSpace entities. If they are equal, no need additional checking of parameters. -//// if (mySlvsConstraint.group == anOtherConstraint.group && -//// mySlvsConstraint.ptA == anOtherConstraint.ptA && -//// mySlvsConstraint.ptB == anOtherConstraint.ptB && -//// mySlvsConstraint.entityA == anOtherConstraint.entityA && -//// mySlvsConstraint.entityB == anOtherConstraint.entityB && -//// mySlvsConstraint.entityC == anOtherConstraint.entityC && -//// mySlvsConstraint.entityD == anOtherConstraint.entityD && -//// fabs(mySlvsConstraint.valA - anOtherConstraint.valA) < tolerance) { -//// return true; -//// } - - // Verify equality of values - if (fabs(myValue - theOther->value()) > tolerance) - return false; - - // Verify equality of entities - const std::list& anOtherSubs = theOther->entities(); - if (myConstrained.size() != anOtherSubs.size()) - return false; - std::list::const_iterator aMySubsIt = myConstrained.begin(); - std::list::const_iterator anOtherSubsIt = anOtherSubs.begin(); - for (; aMySubsIt != myConstrained.end(); ++aMySubsIt, ++anOtherSubsIt) - if (!(*aMySubsIt)->isEqual(*anOtherSubsIt)) - return false; - return true; + myValueParam->setValue(theValue); } -bool PlaneGCSSolver_ConstraintWrapper::update(const ConstraintWrapperPtr& theOther) +double PlaneGCSSolver_ConstraintWrapper::value() const { - bool isUpdated = false; - - std::list aMySubs = entities(); - std::list anOtherSubs = theOther->entities(); - std::list::const_iterator aMySubsIt = aMySubs.begin(); - std::list::const_iterator anOtherSubsIt = anOtherSubs.begin(); - for (; aMySubsIt != aMySubs.end() && anOtherSubsIt != anOtherSubs.end(); - ++aMySubsIt, ++anOtherSubsIt) - isUpdated = (*aMySubsIt)->update(*anOtherSubsIt) || isUpdated; - - if (fabs(value() - theOther->value()) > tolerance) { - myValue = theOther->value(); - isUpdated = true; - } - return isUpdated; + return myValueParam ? myValueParam->value() : 0.0; }