-
- if (myBaseConstraint)
- myStorage->addConstraint(myBaseConstraint, myConstraint);
- else
- myStorage->addTemporaryConstraint(myConstraint);
-}
-
-void SketchSolver_ConstraintFixed::getAttributes(EntityWrapperPtr& theBaseEntity,
- EntityWrapperPtr& theFixedEntity)
-{
- if (myBaseFeature) {
- // if the feature is copy, do not move it
- std::shared_ptr<SketchPlugin_Feature> aSketchFeature =
- std::dynamic_pointer_cast<SketchPlugin_Feature>(myBaseFeature);
- if (aSketchFeature && aSketchFeature->isCopy()) {
- myStorage->setNeedToResolve(true);
- return;
- }
-
- bool fixFullFeature = false;
- theBaseEntity = EntityWrapperPtr();
- theFixedEntity = EntityWrapperPtr();
-
- // The feature is fixed.
- PlaneGCSSolver_FeatureBuilder aBuilder;
- std::list<AttributePtr> aBaseAttr = myBaseFeature->data()->attributes(std::string());
- std::list<AttributePtr>::const_iterator anIt = aBaseAttr.begin();
- for (; anIt != aBaseAttr.end(); ++anIt) {
- EntityWrapperPtr anEntity = aBuilder.createAttribute(*anIt);
- EntityWrapperPtr aBaseEntity = myStorage->entity(*anIt);
- if (!anEntity || !aBaseEntity)
- continue;
-
- if (!fixFullFeature && anEntity->type() == ENTITY_POINT &&
- !isEqual(anEntity, aBaseEntity)) {
- if (theFixedEntity)
- fixFullFeature = true;
- theFixedEntity = anEntity;
- theBaseEntity = aBaseEntity;
- }
- }
-
- if (fixFullFeature) {
- theFixedEntity = aBuilder.createFeature(myBaseFeature);
- theBaseEntity = myStorage->entity(myBaseFeature);
- if (isEqual(theBaseEntity, theFixedEntity))
- theBaseEntity = EntityWrapperPtr(); // do not want to fix already fixed entity
- }
-
- } else if (myBaseConstraint) {
- // Constraint Fixed is added by user.
- // Get the attribute of constraint (it should be alone in the list of constraints).
- EntityWrapperPtr aValue;
- std::vector<EntityWrapperPtr> anAttributes;
- SketchSolver_Constraint::getAttributes(aValue, anAttributes);
- std::vector<EntityWrapperPtr>::const_iterator anIt = anAttributes.begin();
- for (; anIt != anAttributes.end(); ++anIt)
- if (*anIt)
- theBaseEntity = *anIt;
- } else
- myErrorMsg = SketchSolver_Error::NOT_INITIALIZED();