X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FSketchSolver%2FSketchSolver_ConstraintMultiRotation.cpp;h=bd53679d9ae635b2882bc62374c5703e5b936a76;hb=383021cb51c4720904096ca851db5ee79255b402;hp=5fc487e120e199815f7fae6f6b9486fbbaa03603;hpb=29f1c8ff3eb53f7ba5dd54ead45d3e55775e5968;p=modules%2Fshaper.git diff --git a/src/SketchSolver/SketchSolver_ConstraintMultiRotation.cpp b/src/SketchSolver/SketchSolver_ConstraintMultiRotation.cpp index 5fc487e12..bd53679d9 100644 --- a/src/SketchSolver/SketchSolver_ConstraintMultiRotation.cpp +++ b/src/SketchSolver/SketchSolver_ConstraintMultiRotation.cpp @@ -10,8 +10,7 @@ void SketchSolver_ConstraintMultiRotation::getAttributes( EntityWrapperPtr& theCenter, double& theAngle, - bool& theFullValue, - std::list< std::list >& theEntities) + bool& theFullValue, std::list& theEntities) { DataPtr aData = myBaseConstraint->data(); theAngle = std::dynamic_pointer_cast( @@ -25,13 +24,13 @@ void SketchSolver_ConstraintMultiRotation::getAttributes( myType = CONSTRAINT_MULTI_ROTATION; - myStorage->update(aCenterAttr, GID_OUTOFGROUP); + myStorage->update(aCenterAttr); theCenter = myStorage->entity(aCenterAttr); AttributeStringPtr aMethodTypeAttr = aData->string(SketchPlugin_MultiRotation::ANGLE_TYPE()); theFullValue = aMethodTypeAttr->value() != "SingleAngle"; - getEntitiesAndCopies(theEntities); + getEntities(theEntities); } void SketchSolver_ConstraintMultiRotation::process() @@ -44,19 +43,19 @@ void SketchSolver_ConstraintMultiRotation::process() EntityWrapperPtr aRotationCenter; bool isFullValue; - std::list > anEntitiesAndCopies; - getAttributes(aRotationCenter, myAngle, isFullValue, anEntitiesAndCopies); + std::list aBaseEntities; + getAttributes(aRotationCenter, myAngle, isFullValue, aBaseEntities); if (!myErrorMsg.empty()) return; BuilderPtr aBuilder = SketchSolver_Manager::instance()->builder(); std::list aRotConstraints; - std::list< std::list >::iterator anEntIt = anEntitiesAndCopies.begin(); - for (; anEntIt != anEntitiesAndCopies.end(); ++anEntIt) { + std::list::iterator anEntIt = aBaseEntities.begin(); + for (; anEntIt != aBaseEntities.end(); ++anEntIt) { std::list aNewConstraints = aBuilder->createConstraint(myBaseConstraint, myGroupID, mySketchID, myType, - myAngle, isFullValue, aRotationCenter, EntityWrapperPtr(), *anEntIt); + myAngle, isFullValue, aRotationCenter, EntityWrapperPtr(), std::list(1, *anEntIt)); aRotConstraints.insert(aRotConstraints.end(), aNewConstraints.begin(), aNewConstraints.end()); } myStorage->addConstraint(myBaseConstraint, aRotConstraints); @@ -124,6 +123,9 @@ void SketchSolver_ConstraintMultiRotation::updateLocal() void SketchSolver_ConstraintMultiRotation::adjustConstraint() { + if (myAdjusted) + return; + if (fabs(myAngle) < tolerance) { myStorage->setNeedToResolve(false); return; @@ -134,9 +136,46 @@ void SketchSolver_ConstraintMultiRotation::adjustConstraint() 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 aParams = aRotCenter->parameters(); + myCenterCoord[0] = aParams.front()->value(); + myCenterCoord[1] = aParams.back()->value(); + + double anAngleValue = myAngle; + if (myIsFullValue && myNumberOfCopies > 0) + anAngleValue /= myNumberOfCopies; + + myRotationVal[0] = sin(anAngleValue * PI / 180.0); + myRotationVal[1] = cos(anAngleValue * 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();