X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FSketchSolver%2FSketchSolver_ConstraintLength.cpp;h=36508d28b7352986d0ed5ed23fa47e8a9e3080e0;hb=9afbc5fb015e5ff91689e1ef3f4da286347fbda5;hp=5c3bbc088637187d5ee63c0cd3d746e27c89196f;hpb=37c59d59b17e4a7e304588fb647488457a0c7283;p=modules%2Fshaper.git diff --git a/src/SketchSolver/SketchSolver_ConstraintLength.cpp b/src/SketchSolver/SketchSolver_ConstraintLength.cpp index 5c3bbc088..36508d28b 100644 --- a/src/SketchSolver/SketchSolver_ConstraintLength.cpp +++ b/src/SketchSolver/SketchSolver_ConstraintLength.cpp @@ -1,25 +1,44 @@ +// Copyright (C) 2014-2023 CEA, EDF +// +// 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 +#include + void SketchSolver_ConstraintLength::getAttributes( - double& theValue, + EntityWrapperPtr& theValue, std::vector& theAttributes) { SketchSolver_Constraint::getAttributes(theValue, theAttributes); - if (!myErrorMsg.empty() || !theAttributes[2] || + if (!myErrorMsg.empty() || !theAttributes[2] || theAttributes[2]->type() != ENTITY_LINE) { theAttributes.clear(); return; } - // Get boundary points of line segment and create point-point distance constraint - std::list aSubs = theAttributes[2]->subEntities(); - theAttributes.assign(theAttributes.size(), EntityWrapperPtr()); - std::vector::iterator anAttrIt = theAttributes.begin(); - std::list::const_iterator aSubIt = aSubs.begin(); - for (; aSubIt != aSubs.end(); ++aSubIt, ++anAttrIt) - *anAttrIt = *aSubIt; + AttributeRefAttrPtr aRefAttr = myBaseConstraint->refattr(SketchPlugin_Constraint::ENTITY_A()); + FeaturePtr aLine = ModelAPI_Feature::feature(aRefAttr->object()); + + theAttributes[0] = myStorage->entity(aLine->attribute(SketchPlugin_Line::START_ID())); + theAttributes[1] = myStorage->entity(aLine->attribute(SketchPlugin_Line::END_ID())); myType = CONSTRAINT_PT_PT_DISTANCE; }