From: azv Date: Fri, 16 May 2014 04:17:26 +0000 (+0400) Subject: Constraint solving methods are implemented X-Git-Tag: V_0.2~59^2^2 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=f681e98322405cc5693012b0f939f4332547d2b1;p=modules%2Fshaper.git Constraint solving methods are implemented --- diff --git a/src/PartSet/PartSet_OperationSketchLine.cpp b/src/PartSet/PartSet_OperationSketchLine.cpp index 97fd78c74..ba194d6ba 100644 --- a/src/PartSet/PartSet_OperationSketchLine.cpp +++ b/src/PartSet/PartSet_OperationSketchLine.cpp @@ -229,6 +229,12 @@ void PartSet_OperationSketchLine::createConstraint(boost::shared_ptr aDoc = document(); boost::shared_ptr aFeature = aDoc->addFeature("SketchConstraintCoincidence"); + if (mySketch) { + boost::shared_ptr aSketch = + boost::dynamic_pointer_cast(mySketch); + aSketch->addSub(aFeature); + } + boost::shared_ptr aData = aFeature->data(); boost::shared_ptr aRef1 = diff --git a/src/SketchSolver/SketchSolver_ConstraintManager.cpp b/src/SketchSolver/SketchSolver_ConstraintManager.cpp index 58ca5cf77..68bc58b3c 100644 --- a/src/SketchSolver/SketchSolver_ConstraintManager.cpp +++ b/src/SketchSolver/SketchSolver_ConstraintManager.cpp @@ -15,6 +15,7 @@ #include #include #include +#include #include #include @@ -86,13 +87,22 @@ void SketchSolver_ConstraintManager::processEvent(const Events_Message* theMessa if (aConstraint) { changeConstraint(aConstraint); + + // Solve the set of constraints + ResolveConstraints(); return ; } + /// \todo Implement feature update handling boost::shared_ptr aFeature = boost::dynamic_pointer_cast(aUpdateMsg->feature()); -// if (aFeature) -// updateEntity(aFeature); + if (aFeature) + { + updateEntity(aFeature); + + // Solve the set of constraints + ResolveConstraints(); + } } else if (theMessage->eventID() == Events_Loop::loop()->eventByName(EVENT_FEATURE_DELETED)) { @@ -106,21 +116,24 @@ bool SketchSolver_ConstraintManager::changeWorkplane(boost::shared_ptr::iterator aGroupIter; + std::vector::iterator aGroupIter; for (aGroupIter = myGroups.begin(); aGroupIter != myGroups.end(); aGroupIter++) - if (aGroupIter->isBaseWorkplane(theSketch)) + if ((*aGroupIter)->isBaseWorkplane(theSketch)) { isUpdated = true; - if (!aGroupIter->updateWorkplane()) + if (!(*aGroupIter)->updateWorkplane()) aResult = false; } // If the workplane is not updated, so this is a new workplane if (!isUpdated) { - SketchSolver_ConstraintGroup aNewGroup(theSketch); + SketchSolver_ConstraintGroup* aNewGroup = new SketchSolver_ConstraintGroup(theSketch); // Verify that the group is created successfully - if (!aNewGroup.isBaseWorkplane(theSketch)) + if (!aNewGroup->isBaseWorkplane(theSketch)) + { + delete aNewGroup; return false; + } myGroups.push_back(aNewGroup); } return aResult; @@ -138,19 +151,22 @@ bool SketchSolver_ConstraintManager::changeConstraint( { // There are no groups applicable for this constraint => create new one boost::shared_ptr aWP = findWorkplaneForConstraint(theConstraint); if (!aWP) return false; - SketchSolver_ConstraintGroup aGroup(aWP); - if (!aGroup.changeConstraint(theConstraint)) + SketchSolver_ConstraintGroup* aGroup = new SketchSolver_ConstraintGroup(aWP); + if (!aGroup->changeConstraint(theConstraint)) + { + delete aGroup; return false; + } myGroups.push_back(aGroup); return true; } else if (aGroups.size() == 1) { // Only one group => add constraint into it Slvs_hGroup aGroupId = *(aGroups.begin()); - std::vector::iterator aGroupIter; + std::vector::iterator aGroupIter; for (aGroupIter = myGroups.begin(); aGroupIter != myGroups.end(); aGroupIter++) - if (aGroupIter->getId() == aGroupId) - return aGroupIter->changeConstraint(theConstraint); + if ((*aGroupIter)->getId() == aGroupId) + return (*aGroupIter)->changeConstraint(theConstraint); } else if (aGroups.size() > 1) { // Several groups applicable for this constraint => need to merge them @@ -161,24 +177,59 @@ bool SketchSolver_ConstraintManager::changeConstraint( return false; } +void SketchSolver_ConstraintManager::updateEntity(boost::shared_ptr theFeature) +{ + // Create list of attributes depending on type of the feature + std::vector anAttrList; + // Point + boost::shared_ptr aPoint = + boost::dynamic_pointer_cast(theFeature); + if (aPoint) + anAttrList.push_back(POINT_ATTR_COORD); + // Line + boost::shared_ptr aLine = + boost::dynamic_pointer_cast(theFeature); + if (aLine) + { + anAttrList.push_back(LINE_ATTR_START); + anAttrList.push_back(LINE_ATTR_END); + } + /// \todo Other types of features should be implemented + + // Check changing of feature's attributes (go through the groups and search usage of the attributes) + std::vector::const_iterator anAttrIter; + for (anAttrIter = anAttrList.begin(); anAttrIter != anAttrList.end(); anAttrIter++) + { + std::vector::iterator aGroupIter; + for (aGroupIter = myGroups.begin(); aGroupIter != myGroups.end(); aGroupIter++) + { + boost::shared_ptr anAttribute = + boost::dynamic_pointer_cast(theFeature->data()->attribute(*anAttrIter)); + (*aGroupIter)->updateEntityIfPossible(anAttribute); + } + } +} + void SketchSolver_ConstraintManager::findGroups( boost::shared_ptr theConstraint, std::vector& theGroupIDs) const { - std::vector::const_iterator aGroupIter; + boost::shared_ptr aWP = findWorkplaneForConstraint(theConstraint); + + std::vector::const_iterator aGroupIter; for (aGroupIter = myGroups.begin(); aGroupIter != myGroups.end(); aGroupIter++) - if (aGroupIter->isInteract(theConstraint)) - theGroupIDs.push_back(aGroupIter->getId()); + if (aWP == (*aGroupIter)->getWorkplane() && (*aGroupIter)->isInteract(theConstraint)) + theGroupIDs.push_back((*aGroupIter)->getId()); } boost::shared_ptr SketchSolver_ConstraintManager::findWorkplaneForConstraint( boost::shared_ptr theConstraint) const { - std::vector::const_iterator aGroupIter; + std::vector::const_iterator aGroupIter; for (aGroupIter = myGroups.begin(); aGroupIter != myGroups.end(); aGroupIter++) { - boost::shared_ptr aWP = aGroupIter->getWorkplane(); + boost::shared_ptr aWP = (*aGroupIter)->getWorkplane(); boost::shared_ptr aWPFeatures = boost::dynamic_pointer_cast(aWP->data()->attribute(SKETCH_ATTR_FEATURES)); std::list< boost::shared_ptr > aFeaturesList = aWPFeatures->list(); @@ -191,6 +242,13 @@ boost::shared_ptr SketchSolver_ConstraintManager::findWorkp return boost::shared_ptr(); } +void SketchSolver_ConstraintManager::ResolveConstraints() +{ + std::vector::iterator aGroupIter; + for (aGroupIter = myGroups.begin(); aGroupIter != myGroups.end(); aGroupIter++) + (*aGroupIter)->ResolveConstraints(); +} + // ======================================================== @@ -204,20 +262,15 @@ SketchSolver_ConstraintManager::SketchSolver_ConstraintGroup:: myEntityMaxID(0), myConstrMaxID(0), myConstraintMap(), - myNeedToSolve(false) + myNeedToSolve(false), + myConstrSolver() { myParams.clear(); myEntities.clear(); myConstraints.clear(); - // Nullify all elements of the set of equations - myConstrSet.param = 0; - myConstrSet.entity = 0; - myConstrSet.constraint = 0; - myConstrSet.failed = 0; - // Initialize workplane - myWorkplane.h = 0; + myWorkplane.h = SLVS_E_UNKNOWN; addWorkplane(theWorkplane); } @@ -227,15 +280,6 @@ SketchSolver_ConstraintManager::SketchSolver_ConstraintGroup::~SketchSolver_Cons myEntities.clear(); myConstraints.clear(); myConstraintMap.clear(); - - if (myConstrSet.param) - delete [] myConstrSet.param; - if (myConstrSet.entity) - delete [] myConstrSet.entity; - if (myConstrSet.constraint) - delete [] myConstrSet.constraint; - if (myConstrSet.failed) - delete [] myConstrSet.failed; } bool SketchSolver_ConstraintManager::SketchSolver_ConstraintGroup::isBaseWorkplane( @@ -247,6 +291,10 @@ bool SketchSolver_ConstraintManager::SketchSolver_ConstraintGroup::isBaseWorkpla bool SketchSolver_ConstraintManager::SketchSolver_ConstraintGroup::isInteract( boost::shared_ptr theConstraint) const { + // Check the group is empty + if (myWorkplane.h != SLVS_E_UNKNOWN && myConstraints.empty()) + return true; + /// \todo Should be implemented return false; } @@ -255,12 +303,23 @@ bool SketchSolver_ConstraintManager::SketchSolver_ConstraintGroup::changeConstra boost::shared_ptr theConstraint) { // There is no workplane yet, something wrong - if (myWorkplane.h == 0) + if (myWorkplane.h == SLVS_E_UNKNOWN) return false; + // Search this constraint in the current group to update it + std::map, Slvs_hConstraint>::const_iterator + aConstrMapIter = myConstraintMap.find(theConstraint); + std::vector::iterator aConstrIter; + if (aConstrMapIter != myConstraintMap.end()) + { + int aConstrPos = Search(aConstrMapIter->second, myConstraints); + aConstrIter = myConstraints.begin() + aConstrPos; + } + // Get constraint type and verify the constraint parameters are correct int aConstrType = getConstraintType(theConstraint); - if (aConstrType == SLVS_C_UNKNOWN) + if (aConstrType == SLVS_C_UNKNOWN || + (aConstrMapIter != myConstraintMap.end() && aConstrIter->type != aConstrType)) return false; // Create constraint parameters @@ -268,25 +327,36 @@ bool SketchSolver_ConstraintManager::SketchSolver_ConstraintGroup::changeConstra boost::shared_ptr aDistAttr = boost::dynamic_pointer_cast(theConstraint->data()->attribute(CONSTRAINT_ATTR_VALUE)); if (aDistAttr) + { aDistance = aDistAttr->value(); + if (aConstrMapIter != myConstraintMap.end() && aConstrIter->valA != aDistance) + { + myNeedToSolve = true; + aConstrIter->valA = aDistance; + } + } Slvs_hEntity aConstrEnt[CONSTRAINT_ATTR_SIZE]; // parameters of the constraint for (unsigned int indAttr = 0; indAttr < CONSTRAINT_ATTR_SIZE; indAttr++) { + aConstrEnt[indAttr] = SLVS_E_UNKNOWN; boost::shared_ptr aConstrAttr = boost::dynamic_pointer_cast( theConstraint->data()->attribute(CONSTRAINT_ATTRIBUTES[indAttr]) ); + if (!aConstrAttr) continue; aConstrEnt[indAttr] = changeEntity(aConstrAttr->attr()); } - // Create SolveSpace constraint structure - Slvs_Constraint aConstraint = - Slvs_MakeConstraint(++myConstrMaxID, myID, aConstrType, myWorkplane.h, - aDistance, aConstrEnt[0], aConstrEnt[1], aConstrEnt[2], aConstrEnt[3]); - myConstraints.push_back(aConstraint); - myConstraintMap[theConstraint] = *(myConstraints.rbegin()); - + if (aConstrMapIter == myConstraintMap.end()) + { + // Create SolveSpace constraint structure + Slvs_Constraint aConstraint = + Slvs_MakeConstraint(++myConstrMaxID, myID, aConstrType, myWorkplane.h, + aDistance, aConstrEnt[0], aConstrEnt[1], aConstrEnt[2], aConstrEnt[3]); + myConstraints.push_back(aConstraint); + myConstraintMap[theConstraint] = aConstraint.h; + } return true; } @@ -333,8 +403,8 @@ Slvs_hEntity SketchSolver_ConstraintManager::SketchSolver_ConstraintGroup::chang if (aPoint2D) { // The 2D points are created on workplane. So, if there is no workplane yet, then error - if (myWorkplane.h == 0) - return 0; + if (myWorkplane.h == SLVS_E_UNKNOWN) + return SLVS_E_UNKNOWN; Slvs_hParam aU = changeParameter(aPoint2D->x(), aParamIter); Slvs_hParam aV = changeParameter(aPoint2D->y(), aParamIter); @@ -351,7 +421,7 @@ Slvs_hEntity SketchSolver_ConstraintManager::SketchSolver_ConstraintGroup::chang /// \todo Other types of entities // Unsupported or wrong entity type - return 0; + return SLVS_E_UNKNOWN; } Slvs_hEntity SketchSolver_ConstraintManager::SketchSolver_ConstraintGroup::changeNormal( @@ -366,7 +436,7 @@ Slvs_hEntity SketchSolver_ConstraintManager::SketchSolver_ConstraintGroup::chang if (!aDirX || !aDirY || (fabs(aDirX->x()) + fabs(aDirX->y()) + fabs(aDirX->z()) < tolerance) || (fabs(aDirY->x()) + fabs(aDirY->y()) + fabs(aDirY->z()) < tolerance)) - return 0; + return SLVS_E_UNKNOWN; // quaternion parameters of normal vector double qw, qx, qy, qz; @@ -479,6 +549,7 @@ int SketchSolver_ConstraintManager::SketchSolver_ConstraintGroup::getConstraintT boost::dynamic_pointer_cast( theConstraint->data()->attribute(CONSTRAINT_ATTRIBUTES[indAttr]) ); + if (!anAttr) continue; // Verify the attribute is a 2D point boost::shared_ptr aPoint2D = boost::dynamic_pointer_cast(anAttr->attr()); @@ -511,6 +582,74 @@ int SketchSolver_ConstraintManager::SketchSolver_ConstraintGroup::getConstraintT return SLVS_C_UNKNOWN; } +void SketchSolver_ConstraintManager::SketchSolver_ConstraintGroup::ResolveConstraints() +{ + if (!myNeedToSolve) + return; + + myConstrSolver.setGroupID(myID); + myConstrSolver.setParameters(myParams); + myConstrSolver.setEntities(myEntities); + myConstrSolver.setConstraints(myConstraints); + + if (myConstrSolver.solve() == SLVS_RESULT_OKAY) + { // solution succeeded, store results into correspondent attributes + // Obtain result into the same list of parameters + if (!myConstrSolver.getResult(myParams)) + return; + + std::map, Slvs_hEntity>::iterator + anEntIter = myEntityMap.begin(); + for ( ; anEntIter != myEntityMap.end(); anEntIter++) + updateAttribute(anEntIter->first, anEntIter->second); + } + /// \todo Implement error handling + + myNeedToSolve = false; +} + + +void SketchSolver_ConstraintManager::SketchSolver_ConstraintGroup::updateAttribute( + boost::shared_ptr theAttribute, + const Slvs_hEntity& theEntityID) +{ + // Search the position of the first parameter of the entity + int anEntPos = Search(theEntityID, myEntities); + int aFirstParamPos = Search(myEntities[anEntPos].param[0], myParams); + + // Look over supported types of entities + + // Point in 3D + boost::shared_ptr aPoint = + boost::dynamic_pointer_cast(theAttribute); + if (aPoint) + { + aPoint->setValue(myParams[aFirstParamPos].val, + myParams[aFirstParamPos+1].val, + myParams[aFirstParamPos+2].val); + return ; + } + + // Point in 2D + boost::shared_ptr aPoint2D = + boost::dynamic_pointer_cast(theAttribute); + if (aPoint2D) + { + aPoint2D->setValue(myParams[aFirstParamPos].val, + myParams[aFirstParamPos+1].val); + return ; + } + + /// \todo Support other types of entities +} + +void SketchSolver_ConstraintManager::SketchSolver_ConstraintGroup::updateEntityIfPossible( + boost::shared_ptr theEntity) +{ + if (myEntityMap.find(theEntity) != myEntityMap.end()) + changeEntity(theEntity); +} + // ======================================================== diff --git a/src/SketchSolver/SketchSolver_ConstraintManager.h b/src/SketchSolver/SketchSolver_ConstraintManager.h index 106b9c6c3..95512cf3b 100644 --- a/src/SketchSolver/SketchSolver_ConstraintManager.h +++ b/src/SketchSolver/SketchSolver_ConstraintManager.h @@ -6,14 +6,11 @@ #define SketchSolver_ConstraintManager_Headerfile #include "SketchSolver.h" +#include #include #include -// Need to be defined before including SolveSpace to avoid additional dependances on Windows platform -#if defined(WIN32) && !defined(HAVE_C99_INTEGER_TYPES) -typedef unsigned int UINT32; -#endif #include #include @@ -23,6 +20,8 @@ typedef unsigned int UINT32; // Unknown constraint (for error reporting) #define SLVS_C_UNKNOWN 0 +// Unknown entity +#define SLVS_E_UNKNOWN 0 /** \class SketchSolver_ConstraintManager * \ingroup DataModel @@ -79,9 +78,12 @@ protected: /** \brief Updates entity which is neither workplane nor constraint * \param[in] theFeature entity to be updated - * \return \c true if the entity updated successfully */ - bool updateEntity(boost::shared_ptr theFeature); + void updateEntity(boost::shared_ptr theFeature); + + /** \brief Goes through the list of groups and solve the constraints + */ + void ResolveConstraints(); private: class SketchSolver_ConstraintGroup; @@ -102,7 +104,7 @@ private: private: static SketchSolver_ConstraintManager* _self; ///< Self pointer to implement singleton functionality - std::vector myGroups; ///< Groups of constraints + std::vector myGroups; ///< Groups of constraints }; @@ -155,6 +157,15 @@ public: */ bool updateWorkplane(); + /** \brief If the entity is in this group it will updated + * \param[in] theEntity attribute, which values should update SolveSpace entity + */ + void updateEntityIfPossible(boost::shared_ptr theEntity); + + /** \brief Start solution procedure if necessary and update attributes of features + */ + void ResolveConstraints(); + protected: /** \brief Adds or updates an entity in the group * @@ -199,6 +210,12 @@ protected: */ int getConstraintType(const boost::shared_ptr& theConstraint) const; + /** \brief Change values of attribute by parameters received from SolveSpace solver + * \param[in,out] theAttribute pointer to the attribute to be changed + * \param[in] theEntityID identifier of SolveSpace entity, which contains updated data + */ + void updateAttribute(boost::shared_ptr theAttribute, const Slvs_hEntity& theEntityID); + private: /** \brief Creates a workplane from the sketch parameters * \param[in] theSketch parameters of workplane are the attributes of this sketch @@ -216,12 +233,13 @@ private: Slvs_hEntity myEntityMaxID; ///< Actual maximal ID of entities (not equal to myEntities size) std::vector myConstraints; ///< List of constraints in SolveSpace format Slvs_hConstraint myConstrMaxID; ///< Actual maximal ID of constraints (not equal to myConstraints size) - Slvs_System myConstrSet; ///< SolveSpace's set of equations obtained by constraints bool myNeedToSolve; ///< Indicator that something changed in the group and constraint system need to be rebuilt + SketchSolver_Solver myConstrSolver; ///< Solver for set of equations obtained by constraints + // SketchPlugin entities boost::shared_ptr mySketch; ///< Equivalent to workplane - std::map, Slvs_Constraint> + std::map, Slvs_hConstraint> myConstraintMap; ///< The map between SketchPlugin and SolveSpace constraints std::map, Slvs_hEntity> myEntityMap; ///< The map between parameters of constraints and their equivalent SolveSpace entities diff --git a/src/SketchSolver/SketchSolver_Solver.cpp b/src/SketchSolver/SketchSolver_Solver.cpp index bf86e4d44..f9ed8c372 100644 --- a/src/SketchSolver/SketchSolver_Solver.cpp +++ b/src/SketchSolver/SketchSolver_Solver.cpp @@ -3,3 +3,109 @@ // Author: Artem ZHIDKOV #include "SketchSolver_Solver.h" + +SketchSolver_Solver::SketchSolver_Solver() +{ + // Nullify all elements of the set of equations + myEquationsSystem.param = 0; + myEquationsSystem.params = 0; + myEquationsSystem.entity = 0; + myEquationsSystem.entities = 0; + myEquationsSystem.constraint = 0; + myEquationsSystem.constraints = 0; + myEquationsSystem.failed = 0; + myEquationsSystem.faileds = 0; + + // If the set of constraints is inconsistent, + // the failed field will contain wrong constraints + myEquationsSystem.calculateFaileds = 1; +} + +SketchSolver_Solver::~SketchSolver_Solver() +{ + if (myEquationsSystem.param) + delete [] myEquationsSystem.param; + if (myEquationsSystem.entity) + delete [] myEquationsSystem.entity; + if (myEquationsSystem.constraint) + delete [] myEquationsSystem.constraint; + if (myEquationsSystem.failed) + delete [] myEquationsSystem.failed; +} + +void SketchSolver_Solver::setParameters(const std::vector& theParameters) +{ + if (theParameters.size() != myEquationsSystem.params) // number of parameters was changed => reallocate the memory + { + if (myEquationsSystem.param) + delete [] myEquationsSystem.param; + myEquationsSystem.params = theParameters.size(); + myEquationsSystem.param = new Slvs_Param[theParameters.size()]; + } + + // Copy data + std::vector::const_iterator aParamIter = theParameters.begin(); + for (int i = 0; i < myEquationsSystem.params; i++, aParamIter++) + myEquationsSystem.param[i] = *aParamIter; +} + +void SketchSolver_Solver::setEntities(const std::vector& theEntities) +{ + if (theEntities.size() != myEquationsSystem.entities) // number of entities was changed => reallocate the memory + { + if (myEquationsSystem.entity) + delete [] myEquationsSystem.entity; + myEquationsSystem.entities = theEntities.size(); + myEquationsSystem.entity = new Slvs_Entity[theEntities.size()]; + } + + // Copy data + std::vector::const_iterator aEntIter = theEntities.begin(); + for (int i = 0; i < myEquationsSystem.entities; i++, aEntIter++) + myEquationsSystem.entity[i] = *aEntIter; +} + +void SketchSolver_Solver::setConstraints(const std::vector& theConstraints) +{ + if (theConstraints.size() != myEquationsSystem.constraints) // number of constraints was changed => reallocate the memory + { + if (myEquationsSystem.constraint) + delete [] myEquationsSystem.constraint; + myEquationsSystem.constraints = theConstraints.size(); + myEquationsSystem.constraint = new Slvs_Constraint[theConstraints.size()]; + } + + // Copy data + std::vector::const_iterator aConstrIter = theConstraints.begin(); + for (int i = 0; i < myEquationsSystem.constraints; i++, aConstrIter++) + myEquationsSystem.constraint[i] = *aConstrIter; +} + +int SketchSolver_Solver::solve() +{ + if (myEquationsSystem.constraints <= 0) + return SLVS_RESULT_EMPTY_SET; + + Slvs_Solve(&myEquationsSystem, myGroupID); + + return myEquationsSystem.result; +} + +bool SketchSolver_Solver::getResult(std::vector& theParameters) +{ + if (myEquationsSystem.result != SLVS_RESULT_OKAY) + return false; + + if (theParameters.size() != myEquationsSystem.params) + return false; // number of parameters is not the same + + std::vector::iterator aParamIter = theParameters.begin(); + for (int i = 0; i < myEquationsSystem.params; i++, aParamIter++) + { + if (myEquationsSystem.param[i].h != aParamIter->h) + return false; // sequence of parameters was changed + aParamIter->val = myEquationsSystem.param[i].val; + } + + return true; +} diff --git a/src/SketchSolver/SketchSolver_Solver.h b/src/SketchSolver/SketchSolver_Solver.h index beb2f249f..aeb29ef5e 100644 --- a/src/SketchSolver/SketchSolver_Solver.h +++ b/src/SketchSolver/SketchSolver_Solver.h @@ -7,4 +7,59 @@ #include "SketchSolver.h" +// Need to be defined before including SolveSpace to avoid additional dependances on Windows platform +#if defined(WIN32) && !defined(HAVE_C99_INTEGER_TYPES) +typedef unsigned int UINT32; +#endif +#include +#include + +#include + + +#define SLVS_RESULT_EMPTY_SET -1 + + +class SketchSolver_Solver +{ +public: + SketchSolver_Solver(); + ~SketchSolver_Solver(); + + /** \brief Initialize the ID of the group + */ + inline void setGroupID(Slvs_hGroup theGroupID) + { myGroupID = theGroupID; } + + /** \brief Change array of parameters + * \param[in] theParameters vector of parameters + */ + void setParameters(const std::vector& theParameters); + + /** \brief Change array of entities + * \param[in] theEntities vector of entities + */ + void setEntities(const std::vector& theEntities); + + /** \brief Change array of constraints + * \param[in] theConstraints vector of constraints + */ + void setConstraints(const std::vector& theConstraints); + + /** \brief Solve the set of equations + * \return identifier whether solution succeeded + */ + int solve(); + + /** \brief Updates the list of parameters by calculated values + * \param[in,out] theParameters parameters to be updated + * \return \c true if parameters are updated correctly + */ + bool getResult(std::vector& theParameters); + +private: + Slvs_hGroup myGroupID; ///< identifier of the group to be solved + Slvs_System myEquationsSystem; ///< set of equations for solving in SolveSpace +}; + #endif