-// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+// 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 <SketchSolver_ConstraintMultiTranslation.h>
#include <SketchSolver_Error.h>
// add owner of start and end points of Multi-Translation to the list of monitored features
FeaturePtr anOwner = ModelAPI_Feature::feature(aStartPointAttr->attr()->owner());
if (anOwner)
- myFeatures.insert(anOwner);
+ myOriginalFeatures.insert(anOwner);
anOwner = ModelAPI_Feature::feature(aEndPointAttr->attr()->owner());
if (anOwner)
- myFeatures.insert(anOwner);
+ myOriginalFeatures.insert(anOwner);
}
void SketchSolver_ConstraintMultiTranslation::process()
}
EntityWrapperPtr aStartPoint, aEndPoint;
- bool aFullValue;
std::list<EntityWrapperPtr> aBaseEntities;
- getAttributes(aStartPoint, aEndPoint, aFullValue, aBaseEntities);
+ getAttributes(aStartPoint, aEndPoint, myIsFullValue, aBaseEntities);
if (!myErrorMsg.empty())
return;
return;
// Obtain delta between start and end points of translation
- std::shared_ptr<PlaneGCSSolver_PointWrapper> aStartWrapper =
- std::dynamic_pointer_cast<PlaneGCSSolver_PointWrapper>(myStorage->entity(
- myBaseConstraint->attribute(SketchPlugin_MultiTranslation::START_POINT_ID())));
- std::shared_ptr<PlaneGCSSolver_PointWrapper> aEndWrapper =
- std::dynamic_pointer_cast<PlaneGCSSolver_PointWrapper>(myStorage->entity(
- myBaseConstraint->attribute(SketchPlugin_MultiTranslation::END_POINT_ID())));
-
- GCSPointPtr aStart = aStartWrapper->point();
- GCSPointPtr aEnd = aEndWrapper->point();
-
- myDelta[0] = *(aEnd->x) - *(aStart->x);
- myDelta[1] = *(aEnd->y) - *(aStart->y);
+ AttributeRefAttrPtr aStartEnd[2] = {
+ myBaseConstraint->refattr(SketchPlugin_MultiTranslation::START_POINT_ID()),
+ myBaseConstraint->refattr(SketchPlugin_MultiTranslation::END_POINT_ID())
+ };
+ double aCoords[2][2];
+ for (int i = 0; i < 2; ++i)
+ {
+ std::shared_ptr<PlaneGCSSolver_PointWrapper> aPointWrapper =
+ std::dynamic_pointer_cast<PlaneGCSSolver_PointWrapper>(
+ myStorage->entity(AttributePtr(aStartEnd[i])));
+ if (aPointWrapper)
+ {
+ GCSPointPtr aPnt = aPointWrapper->point();
+ aCoords[i][0] = *(aPnt->x);
+ aCoords[i][1] = *(aPnt->y);
+ }
+ else
+ {
+ AttributePoint2DPtr aPnt =
+ std::dynamic_pointer_cast<GeomDataAPI_Point2D>(aStartEnd[i]->attr());
+ aCoords[i][0] = aPnt->x();
+ aCoords[i][1] = aPnt->y();
+ }
+ }
+
+ myDelta[0] = aCoords[1][0] - aCoords[0][0];
+ myDelta[1] = aCoords[1][1] - aCoords[0][1];
if (myIsFullValue && myNumberOfCopies > 0) {
myDelta[0] /= myNumberOfCopies;