X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FSketchSolver%2FSketchSolver_Storage.h;h=2d1e1cd12f3ee0c74bf0e8d0e4eb7d870c55392c;hb=07ff3c02f47a2efa7b51a661716262291fd5ccfd;hp=80fce4563c8911e1d6370ed1c25a1fe5cd2c4b4c;hpb=394ab282ef36885ebe6e2473019d994ef1b17652;p=modules%2Fshaper.git diff --git a/src/SketchSolver/SketchSolver_Storage.h b/src/SketchSolver/SketchSolver_Storage.h index 80fce4563..2d1e1cd12 100644 --- a/src/SketchSolver/SketchSolver_Storage.h +++ b/src/SketchSolver/SketchSolver_Storage.h @@ -58,6 +58,9 @@ public: * \return \c true if the entity was successfully removed */ bool removeEntity(const Slvs_hEntity& theEntityID); + /** \brief Remove all entities, which are not used in constraints + */ + void removeUnusedEntities(); /// \brief Returns the entity by its ID const Slvs_Entity& getEntity(const Slvs_hEntity& theEntityID) const; /// \brief Makes a full copy of the given entity @@ -108,12 +111,22 @@ public: void addTemporaryConstraint(const Slvs_hConstraint& theConstraintID); /// \brief Remove all transient constraints void removeTemporaryConstraints(); + /// \brief Remove one temporary constraint. Preferable to remove the points under Point-on-Line constraint + /// \return Number of remaining temporary constraints + int deleteTemporaryConstraint(); /// \brief Checks the constraint is temporary bool isTemporary(const Slvs_hConstraint& theConstraintID) const; + /// \brief Number of temporary constraints + int numberTemporary() const + { return (int)myTemporaryConstraints.size(); } /// \brief Shows the sketch should be resolved bool isNeedToResolve() const - { return myNeedToResolve; } + { return myNeedToResolve && !myConstraints.empty(); } + + /// \brief Shows the storage has the same constraint twice + bool hasDuplicatedConstraint() const + { return myDuplicatedConstraint; } /// \brief Changes the flag of group to be resolved void setNeedToResolve(bool theFlag) @@ -137,6 +150,41 @@ public: /// \brief Check two points are coincident bool isCoincident(const Slvs_hEntity& thePoint1, const Slvs_hEntity& thePoint2) const; + /// \brief Check two points are coincident or have same coordinates + bool isEqual(const Slvs_hEntity& thePoint1, const Slvs_hEntity& thePoint2) const; + + /// \brief Check the entity is horizontal of vertical + bool isAxisParallel(const Slvs_hEntity& theEntity) const; + + /// \brief Verifies the entity is used in any equal constraint + /// \param[in] theEntity entity to be found + /// \param[out] theEqual constraint, which uses the entity + /// \return \c true, if the Equal constrait is found + bool isUsedInEqual(const Slvs_hEntity& theEntity, Slvs_Constraint& theEqual) const; + + /// \brief Fixes specified entity + /// \param theEntity ID of the entity to be fixed + /// \return List of created constraints + std::vector fixEntity(const Slvs_hEntity& theEntity); + +private: + /// \brief Fixes specified point + /// \param [in] thePoint point to be fixed + /// \param [out] theCreated list of the Fixed constraints created + void fixPoint(const Slvs_Entity& thePoint, std::vector& theCreated); + /// \brief Fixes specified line + /// \param [in] theLine line to be fixed + /// \param [out] theCreated list of the Fixed constraints created + void fixLine(const Slvs_Entity& theLine, std::vector& theCreated); + /// \brief Fixes specified circle + /// \param [in] theCircle circle to be fixed + /// \param [out] theCreated list of the Fixed constraints created + void fixCircle(const Slvs_Entity& theCircle, std::vector& theCreated); + /// \brief Fixes specified arc + /// \param [in] theArc arc to be fixed + /// \param [out] theCreated list of the Fixed constraints created + void fixArc(const Slvs_Entity& theArc, std::vector& theCreated); + private: Slvs_hParam myParamMaxID; ///< current parameter index (may differs with the number of parameters) std::vector myParameters; ///< list of parameters used in the current group of constraints (sorted by the identifier) @@ -149,6 +197,7 @@ private: Slvs_hConstraint myFixed; ///< identifier of one of temporary constraints to fix separate point bool myNeedToResolve; ///< parameters are changed and group needs to be resolved + bool myDuplicatedConstraint; ///< shows the storage has same constraint twice std::set myTemporaryConstraints; ///< list of transient constraints std::set myRemovedParameters; ///< list of just removed parameters (cleared when returning to applicant)