void SketchSolver_ConstraintMultiRotation::getAttributes(
EntityWrapperPtr& theCenter, double& theAngle,
- bool& theFullValue,
- std::list< std::list<EntityWrapperPtr> >& theEntities)
+ bool& theFullValue, std::list<EntityWrapperPtr>& theEntities)
{
DataPtr aData = myBaseConstraint->data();
theAngle = std::dynamic_pointer_cast<ModelAPI_AttributeDouble>(
AttributeStringPtr aMethodTypeAttr = aData->string(SketchPlugin_MultiRotation::ANGLE_TYPE());
theFullValue = aMethodTypeAttr->value() != "SingleAngle";
- getEntitiesAndCopies(theEntities);
+ getEntities(theEntities);
}
void SketchSolver_ConstraintMultiRotation::process()
EntityWrapperPtr aRotationCenter;
bool isFullValue;
- std::list<std::list<EntityWrapperPtr> > anEntitiesAndCopies;
- getAttributes(aRotationCenter, myAngle, isFullValue, anEntitiesAndCopies);
+ std::list<EntityWrapperPtr> aBaseEntities;
+ getAttributes(aRotationCenter, myAngle, isFullValue, aBaseEntities);
if (!myErrorMsg.empty())
return;
BuilderPtr aBuilder = SketchSolver_Manager::instance()->builder();
std::list<ConstraintWrapperPtr> aRotConstraints;
- std::list< std::list<EntityWrapperPtr> >::iterator anEntIt = anEntitiesAndCopies.begin();
- for (; anEntIt != anEntitiesAndCopies.end(); ++anEntIt) {
+ std::list<EntityWrapperPtr>::iterator anEntIt = aBaseEntities.begin();
+ for (; anEntIt != aBaseEntities.end(); ++anEntIt) {
std::list<ConstraintWrapperPtr> aNewConstraints =
aBuilder->createConstraint(myBaseConstraint, myGroupID, mySketchID, myType,
- myAngle, isFullValue, aRotationCenter, EntityWrapperPtr(), *anEntIt);
+ myAngle, isFullValue, aRotationCenter, EntityWrapperPtr(), std::list<EntityWrapperPtr>(1, *anEntIt));
aRotConstraints.insert(aRotConstraints.end(), aNewConstraints.begin(), aNewConstraints.end());
}
myStorage->addConstraint(myBaseConstraint, aRotConstraints);
void SketchSolver_ConstraintMultiRotation::adjustConstraint()
{
+ if (myAdjusted)
+ return;
+
if (fabs(myAngle) < tolerance) {
myStorage->setNeedToResolve(false);
return;
for (; aCIt != aConstraints.end(); ++aCIt)
(*aCIt)->setValue(myAngle);
+ // Obtain coordinates of rotation center
+ EntityWrapperPtr aRotCenter = myStorage->entity(
+ myBaseConstraint->attribute(SketchPlugin_MultiRotation::CENTER_ID()));
+ std::list<ParameterWrapperPtr> aParams = aRotCenter->parameters();
+ myCenterCoord[0] = aParams.front()->value();
+ myCenterCoord[1] = aParams.back()->value();
+
+ myRotationVal[0] = sin(myAngle * PI / 180.0);
+ myRotationVal[1] = cos(myAngle * PI / 180.0);
+
SketchSolver_ConstraintMulti::adjustConstraint();
}
+void SketchSolver_ConstraintMultiRotation::getRelative(
+ double theAbsX, double theAbsY, double& theRelX, double& theRelY)
+{
+ theRelX = theAbsX - myCenterCoord[0];
+ theRelY = theAbsY - myCenterCoord[1];
+}
+
+void SketchSolver_ConstraintMultiRotation::getAbsolute(
+ double theRelX, double theRelY, double& theAbsX, double& theAbsY)
+{
+ theAbsX = theRelX + myCenterCoord[0];
+ theAbsY = theRelY + myCenterCoord[1];
+}
+
+void SketchSolver_ConstraintMultiRotation::transformRelative(double& theX, double& theY)
+{
+ // rotate direction
+ // myRotationVal[0] = sinA, myRotationVal[1] = cosA
+ double aTemp = theX * myRotationVal[1] - theY * myRotationVal[0];
+ theY = theX * myRotationVal[0] + theY * myRotationVal[1];
+ theX = aTemp;
+}
+
const std::string& SketchSolver_ConstraintMultiRotation::nameNbObjects()
{
return SketchPlugin_MultiRotation::NUMBER_OF_OBJECTS_ID();