X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FSketchSolver%2FPlaneGCSSolver%2FPlaneGCSSolver_Solver.h;h=c9ee4655502edae7266d368bbaa968c7d74fe3d4;hb=50a8df0c6a66da8067b16155e5ae39f8f26a7ebc;hp=b1dcd50f991c91a3dbcae21edc10baa6acc622f3;hpb=6ea1bd3c759d8726063a1af11075374f1205ade9;p=modules%2Fshaper.git diff --git a/src/SketchSolver/PlaneGCSSolver/PlaneGCSSolver_Solver.h b/src/SketchSolver/PlaneGCSSolver/PlaneGCSSolver_Solver.h index b1dcd50f9..c9ee46555 100644 --- a/src/SketchSolver/PlaneGCSSolver/PlaneGCSSolver_Solver.h +++ b/src/SketchSolver/PlaneGCSSolver/PlaneGCSSolver_Solver.h @@ -1,82 +1,117 @@ -// Copyright (C) 2014-20xx CEA/DEN, EDF R&D - -// File: PlaneGCSSolver_Solver.h -// Created: 14 Dec 2014 -// Author: Artem ZHIDKOV +// Copyright (C) 2014-2020 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// #ifndef PlaneGCSSolver_Solver_H_ #define PlaneGCSSolver_Solver_H_ -#include #include +#include #include -/** - * The main class that performs the high-level operations for connection to the PlaneGCS. - */ -class PlaneGCSSolver_Solver : public SketchSolver_ISolver +/// \brief The main class that performs the high-level operations for connection to the PlaneGCS. +class PlaneGCSSolver_Solver { public: - PlaneGCSSolver_Solver() {} + /// The result of constraints solution + enum SolveStatus { + STATUS_OK, + STATUS_INCONSISTENT, + STATUS_EMPTYSET, + STATUS_DEGENERATED, + STATUS_FAILED, // set if no one other status is applicable + STATUS_UNKNOWN // set for newly created groups + }; + + PlaneGCSSolver_Solver(); ~PlaneGCSSolver_Solver(); /// \brief Clear system of equations void clear(); /// \brief Add constraint to the system of equations - void addConstraint(GCSConstraintPtr theConstraint); - - /// \brief Remove constraint from the system of equations - void removeConstraint(GCSConstraintPtr theConstraint); + /// \param[in] theMultiConstraintID ID of the multi constraint which may consists of + /// several primitive constraints + /// \param[in] theConstraints list of primitive constraints + void addConstraint(const ConstraintID& theMultiConstraintID, + const std::list& theConstraints); + + /// \brief Remove constraints from the system of equations + void removeConstraint(const ConstraintID& theID); + + /// \brief Initialize memory for new solver's parameter + double* createParameter(); + /// \brief Add parameters created elsewhere + void addParameters(const GCS::SET_pD& theParams); + /// \brief Release memory occupied by parameters + void removeParameters(const GCS::SET_pD& theParams); + + /// \brief Preliminary initialization of solver (useful for moving a feature). + /// When called, the solve() method does not reinitialize a set of constraints. + void initialize(); + + /// \brief Solve the set of equations + /// \return identifier whether solution succeeded + SolveStatus solve(); - /// \brief Initialize list of unknowns - void setParameters(const GCS::VEC_pD& theParams) - { myParameters = theParams; } + /// \brief Revert solution to initial values + void undo(); - /// \brief Set list of IDs of tangent constraints - /// - /// Workaround to avoid incorrect report about redundant constraints - /// if an arc is already smoothly connected to a line. - void setTangent(const GCS::SET_I& theTangentIDs) - { myTangent = theTangentIDs; } + /// \brief Check the constraint is conflicted with others + bool isConflicting(const ConstraintID& theConstraint) const; - /** \brief Solve the set of equations - * \return identifier whether solution succeeded - */ - virtual SketchSolver_SolveStatus solve(); + /// \brief Check conflicting/redundant constraints and DoF + void diagnose(const GCS::Algorithm& theAlgo = GCS::DogLeg); - /// \brief Prepare for solving. Store initial values of parameters for undo - virtual void prepare() - { /* do nothing */ } + /// \brief Return the list of modifiable parameters + void getFreeParameters(GCS::SET_pD& theFreeParams); - /// \brief Revert solution to initial values - virtual void undo(); + /// \brief Degrees of freedom + int dof(); - /// \brief Check the constraint is conflicted with others - virtual bool isConflicting(const ConstraintID& theConstraint) const; +private: + void collectConflicting(bool withRedundant = true); - /// \brief Degrees of freedom - virtual int dof() const; + /// \brief Add fictive constraint if the sketch contains temporary constraints only + void addFictiveConstraintIfNecessary(); + /// \brief Remove previously added fictive constraint + void removeFictiveConstraint(); private: - void collectConflicting(); + typedef std::map > ConstraintMap; - /// \brief Remove constraint from the system of equations - void removeConstraint(GCS::Constraint* theConstraint); + GCS::VEC_pD myParameters; ///< list of unknowns + ConstraintMap myConstraints; ///< list of constraints - /// \brief Remove redundant tangent constraints and try to solve the system again - SketchSolver_SolveStatus solveWithoutTangent(); + std::shared_ptr myEquationSystem; ///< set of equations for solving in FreeGCS + bool myDiagnoseBeforeSolve; ///< is the diagnostic necessary + bool myInitilized; ///< is the system already initialized -private: - GCS::VEC_pD myParameters; ///< list of unknowns - std::set myConstraints; ///< list of constraints already processed by the system - GCS::System myEquationSystem; ///< set of equations for solving in FreeGCS + GCS::SET_I myConflictingIDs; ///< list of IDs of conflicting constraints + /// specifies the conflicting constraints are already collected + bool myConfCollected; - GCS::VEC_I myConflictingIDs; ///< list of IDs of conflicting constraints - bool myConfCollected; ///< specifies the conflicting constraints are already collected + int myDOF; ///< degrees of freedom - GCS::SET_I myTangent; ///< list of tangent IDs to check incorrect redundant constraints + GCS::Constraint* myFictiveConstraint; }; +typedef std::shared_ptr SolverPtr; + #endif