- }
-
- // Fix given list of parameters
- std::list<GCSConstraintPtr> aConstraints;
- myFixedValues.reserve(aParameters.size());
- GCS::VEC_pD::const_iterator anIt = aParameters.begin();
- for (int i = 0; anIt != aParameters.end(); ++anIt, ++i) {
- myFixedValues.push_back(**anIt);
- aConstraints.push_back(
- GCSConstraintPtr(new GCS::ConstraintEqual(*anIt, &myFixedValues[i])));
- }
-
- myConstraint = ConstraintWrapperPtr(
- new PlaneGCSSolver_ConstraintWrapper(aConstraints, getType()));
-
- if (myBaseConstraint)
- myStorage->addConstraint(myBaseConstraint, myConstraint);
- else
- myStorage->addTemporaryConstraint(myConstraint);
-}
-
-void SketchSolver_ConstraintFixed::getAttributes(
- EntityWrapperPtr& theValue,
- std::vector<EntityWrapperPtr>& theAttributes)
-{
- if (myBaseFeature) {
- // The feature is fixed.
- EntityWrapperPtr aSolverEntity = getChangedEntity(myBaseFeature, myStorage);
- myStorage->update(myBaseFeature);
- if (aSolverEntity)
- theAttributes.push_back(aSolverEntity);
- } else if (myBaseConstraint) {
- // Constraint Fixed is added by user.
- // Get the attribute of constraint (it should be alone in the list of constraints).
- std::vector<EntityWrapperPtr> anAttributes;
- SketchSolver_Constraint::getAttributes(theValue, anAttributes);
- std::vector<EntityWrapperPtr>::const_iterator anIt = anAttributes.begin();
- for (; anIt != anAttributes.end(); ++anIt)
- if (*anIt)
- theAttributes.push_back(*anIt);
- } else
- myErrorMsg = SketchSolver_Error::NOT_INITIALIZED();
-}
-
-
-
-
-// ==================== Auxiliary functions ===============================
-static bool isSameCoordinates(const AttributePoint2DPtr& thePointAttr,
- const PointWrapperPtr& thePointWrapper)
-{
- GCSPointPtr aGCSPoint = thePointWrapper->point();
- return fabs(*aGCSPoint->x - thePointAttr->x()) < tolerance &&
- fabs(*aGCSPoint->y - thePointAttr->y()) < tolerance;
-}
-
-EntityWrapperPtr getChangedEntity(const FeaturePtr& theFeature,
- const StoragePtr& theStorage)
-{
- std::list<AttributePtr> aPoints = theFeature->data()->attributes(GeomDataAPI_Point2D::typeId());
- std::list<EntityWrapperPtr> aChangedPoints;
-
- std::list<AttributePtr>::const_iterator aPIt = aPoints.begin();
- for (; aPIt != aPoints.end(); ++aPIt) {
- AttributePoint2DPtr aPnt = std::dynamic_pointer_cast<GeomDataAPI_Point2D>(*aPIt);
- EntityWrapperPtr anEnt = theStorage->entity(*aPIt);
- if (anEnt) {
- PointWrapperPtr aPW = std::dynamic_pointer_cast<PlaneGCSSolver_PointWrapper>(anEnt);
- if (!isSameCoordinates(aPnt, aPW))
- aChangedPoints.push_back(anEnt);
- } else {
- theStorage->update(*aPIt);
- aChangedPoints.push_back(theStorage->entity(*aPIt));