if (!myErrorMsg.empty() || theAttributes[0] == SLVS_E_UNKNOWN)
return;
- if (theAttributes[1] != SLVS_E_UNKNOWN)
+ if (theAttributes[1] != SLVS_E_UNKNOWN) {
myType = SLVS_C_POINTS_COINCIDENT;
+
+ // set coordinates of slave (second) point equal to the master (first) point
+ Slvs_Entity aFirst = myStorage->getEntity(theAttributes[0]);
+ Slvs_Entity aSecond = myStorage->getEntity(theAttributes[1]);
+ for (int i = 0; i < 4; i++)
+ if (aFirst.param[i] != SLVS_E_UNKNOWN && aSecond.param[i] != SLVS_E_UNKNOWN) {
+ Slvs_Param aPar1 = myStorage->getParameter(aFirst.param[i]);
+ Slvs_Param aPar2 = myStorage->getParameter(aSecond.param[i]);
+ aPar2.val = aPar1.val;
+ myStorage->updateParameter(aPar2);
+ }
+ }
else if (theAttributes[2] != SLVS_E_UNKNOWN) {
// check the type of entity (line or circle)
Slvs_Entity anEnt = myStorage->getEntity(theAttributes[2]);
#include <SketchSolver_Error.h>
#include <SketchSolver_Group.h>
-#include <GeomDataAPI_Point2D.h>
-
SketchSolver_ConstraintMovement::SketchSolver_ConstraintMovement(FeaturePtr theFeature)
: SketchSolver_ConstraintRigid(theFeature)
{
std::vector<Slvs_hEntity>& theAttributes,
bool& theIsFullyMoved)
{
+ bool isComplexFeature = false;
theValue = 0.0;
theIsFullyMoved = true;
int aType = SLVS_E_UNKNOWN; // type of created entity
// Check the entity is complex
Slvs_Entity anEntity = myStorage->getEntity(anEntityID);
- if (anEntity.point[0] != SLVS_E_UNKNOWN) {
- for (int i = 0; i < 4 && anEntity.point[i]; i++)
- theAttributes.push_back(anEntity.point[i]);
- } else // simple entity
+ if (anEntity.point[0] != SLVS_E_UNKNOWN)
+ isComplexFeature = true;
+ else // simple entity
theAttributes.push_back(anEntityID);
}
else {
myFeatureMap[myBaseFeature] = anEntityID;
+ isComplexFeature = true;
+ }
+ if (isComplexFeature) {
std::list<AttributePtr> aPoints =
myBaseFeature->data()->attributes(GeomDataAPI_Point2D::typeId());
std::list<AttributePtr>::iterator anIt = aPoints.begin();
Slvs_hEntity anAttr = myGroup->getAttributeId(*anIt);
// Check the attribute changes coordinates
- Slvs_Entity anAttrEnt = myStorage->getEntity(anAttr);
- double aDeltaX = myStorage->getParameter(anAttrEnt.param[0]).val;
- double aDeltaY = myStorage->getParameter(anAttrEnt.param[1]).val;
std::shared_ptr<GeomDataAPI_Point2D> aPt =
std::dynamic_pointer_cast<GeomDataAPI_Point2D>(*anIt);
- aDeltaX -= aPt->x();
- aDeltaY -= aPt->y();
- if (aDeltaX * aDeltaX + aDeltaY * aDeltaY >= tolerance * tolerance) {
+ if (isMoved(aPt, anAttr)) {
theAttributes.push_back(anAttr);
// update point coordinates
+ Slvs_Entity anAttrEnt = myStorage->getEntity(anAttr);
double aNewPos[2] = {aPt->x(), aPt->y()};
for (int i = 0; i < 2; i++) {
Slvs_Param aParam = myStorage->getParameter(anAttrEnt.param[i]);
}
}
+bool SketchSolver_ConstraintMovement::isMoved(
+ std::shared_ptr<GeomDataAPI_Point2D> thePoint, Slvs_hEntity theEntity)
+{
+ Slvs_Entity anAttrEnt = myStorage->getEntity(theEntity);
+ double aDeltaX = myStorage->getParameter(anAttrEnt.param[0]).val;
+ double aDeltaY = myStorage->getParameter(anAttrEnt.param[1]).val;
+ aDeltaX -= thePoint->x();
+ aDeltaY -= thePoint->y();
+ return aDeltaX * aDeltaX + aDeltaY * aDeltaY >= tolerance * tolerance;
+}
#include "SketchSolver.h"
#include <SketchSolver_ConstraintRigid.h>
+#include <GeomDataAPI_Point2D.h>
+
/** \class SketchSolver_ConstraintMovement
* \ingroup Plugins
* \brief Stores data of Rigid (Fixed) constraint for the moved feature only
/// \param[out] theAttributes list of attributes to be filled
/// \param[out] theIsFullyMoved shows that the feature is moved, in other case only one point of the feature is shifted
virtual void getAttributes(double& theValue, std::vector<Slvs_hEntity>& theAttributes, bool& theIsFullyMoved);
+
+private:
+ /// \brief Check the coordinates of point are differ than coordinates of correponding SolveSpace entity
+ bool isMoved(std::shared_ptr<GeomDataAPI_Point2D> thePoint, Slvs_hEntity theEntity);
};
#endif