- /** \brief Add new parameter to the current group
- * \param[in] theParam SolveSpace parameter
- * \return the ID of added parameter
- */
- Slvs_hParam addParameter(const Slvs_Param& theParam);
- /** \brief Updates parameter in the current group. If the ID of parameter is zero, the new item will be added
- * \param[in] theParam SolveSpace parameter
- * \return the ID of updated/added parameter
- */
- Slvs_hParam updateParameter(const Slvs_Param& theParam);
- /** \brief Removes the parameter by its ID
- * \param[in] theParamID index of parameter to be removed
- * \return \c true if the parameter was successfully removed
- */
- bool removeParameter(const Slvs_hParam& theParamID);
- /// \brief Returns the parameter by its ID
- const Slvs_Param& getParameter(const Slvs_hParam& theParamID) const;
-
- /** \brief Add new entity to the current group
- * \param[in] theEntity SolveSpace entity
- * \return the ID of added entity
- */
- Slvs_hEntity addEntity(const Slvs_Entity& theEntity);
- /** \brief Updates entity in the current group. If the ID of entity is zero, the new item will be added
- * \param[in] theEntity SolveSpace entity
- * \return the ID of updated/added entity
- */
- Slvs_hEntity updateEntity(const Slvs_Entity& theEntity);
- /** \brief Removes the entity by its ID. All parameters used in this entity,
- * and not used in other constraints, will be removed too.
- * \param[in] theEntityID index of entity to be removed
- * \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
- Slvs_hEntity copyEntity(const Slvs_hEntity& theCopied);
- /// \brief Copy one entity to another
- void copyEntity(const Slvs_hEntity& theFrom, const Slvs_hEntity& theTo);
- /// \brief Check the entity is used in constraints
- bool isUsedByConstraints(const Slvs_hEntity& theEntityID) const;
- /// \brief Returns maximal ID of entities in this storage
- const Slvs_hEntity& entityMaxID() const
- { return myEntityMaxID; }
-
- /// \brief Verifies the current point or another coincident one is fixed
- /// \param[in] thePointID entity to be checked fixed
- /// \param[out] theFixed ID of constraint
- /// \param[in] theAccurate if \c true, the calculation will be made for all type of constraints,
- /// if \c false, only the point is verified
- /// \return \c true if the point is fixed
- bool isPointFixed(const Slvs_hEntity& thePointID, Slvs_hConstraint& theFixed, bool theAccurate = false) const;
- /// \brief Verifies the current entity is fully fixed (may not be changed by constraints)
- /// \param[in] theEntityID entity to be checked fixed
- /// \param[in] theAccurate if \c true, the calculation will be made for all type of constraints,
- /// if \c false, only points are verified
- /// \return \c true if the entity is fixed
- bool isEntityFixed(const Slvs_hEntity& theEntityID, bool theAccurate = false) const;
-
- /** \brief Add new constraint to the current group
- * \param[in] theConstraint SolveSpace's constraint
- * \return the ID of added constraint
- */
- Slvs_hConstraint addConstraint(const Slvs_Constraint& theConstraint);
- /** \brief Updates constraint in the current group.
- * If the ID of constraint is zero, the new item will be added
- * \param[in] theConstraint SolveSpace constraint
- * \return the ID of updated/added constraint
- */
- Slvs_hConstraint updateConstraint(const Slvs_Constraint& theConstraint);
- /** \brief Removes the constraint by its ID. All entities and parameters depending on this
- * constraint, which are not used in other constraints, will be removed too.
- * \param[in] theConstraintID index of constraint to be removed
- * \return \c true if the constraint was successfully removed
- */
- bool removeConstraint(const Slvs_hConstraint& theConstraintID);
- /// \brief Returns the constraint by its ID
- const Slvs_Constraint& getConstraint(const Slvs_hConstraint& theConstraintID) const;
- /// \brief Returns list of constraints of specified type
- std::list<Slvs_Constraint> getConstraintsByType(int theConstraintType) const;
- /// \brief Returns quantity of constraints in this storage
- size_t nbConstraints() const
- { return myConstraints.size(); }
-
- /// \brief Attach constraint SLVS_C_WHERE_DRAGGED to this storage. It need to make precise calculations
- void addConstraintWhereDragged(const Slvs_hConstraint& theConstraintID);
-
- /// \brief Add transient constraint
- 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(); }
+public:
+ SketchSolver_Storage(const GroupID& theGroup)
+ : myGroupID(theGroup),
+ mySketchID(EID_UNKNOWN),
+ myNeedToResolve(false),
+ myEventsBlocked(false),
+ myExistArc(false)
+ {}
+
+ /// \brief Change mapping between constraint from SketchPlugin and
+ /// a constraint applicable for corresponding solver.
+ /// \param theConstraint [in] original SketchPlugin constraint
+ /// \param theSolverConstraint [in] solver's constraints
+ SKETCHSOLVER_EXPORT void addConstraint(ConstraintPtr theConstraint,
+ ConstraintWrapperPtr theSolverConstraints);
+ /// \brief Change mapping between constraint from SketchPlugin and
+ /// the list of constraints applicable for corresponding solver.
+ /// \param theConstraint [in] original SketchPlugin constraint
+ /// \param theSolverConstraints [in] list of solver's constraints
+ SKETCHSOLVER_EXPORT virtual
+ void addConstraint(ConstraintPtr theConstraint,
+ std::list<ConstraintWrapperPtr> theSolverConstraints);
+
+ /// \brief Convert feature to the form applicable for specific solver and map it
+ /// \param theFeature [in] feature to convert
+ /// \param theGroup [in] id of the group where the feature should be placed
+ /// \param theForce [in] forced feature creation
+ /// \return \c true if the feature has been created or updated
+ SKETCHSOLVER_EXPORT bool update(FeaturePtr theFeature,
+ const GroupID& theGroup = GID_UNKNOWN, bool theForce = false);
+
+ /// \brief Convert attribute to the form applicable for specific solver and map it
+ /// \param theAttribute [in] attribute to convert
+ /// \param theGroup [in] id of the group where the feature should be placed
+ /// \param theForce [in] forced feature creation
+ /// \return \c true if the attribute has been created or updated
+ SKETCHSOLVER_EXPORT bool update(AttributePtr theAttribute,
+ const GroupID& theGroup = GID_UNKNOWN, bool theForce = false);
+
+ /// \brief Returns constraint related to corresponding constraint
+ SKETCHSOLVER_EXPORT
+ const std::list<ConstraintWrapperPtr>& constraint(const ConstraintPtr& theConstraint) const;
+
+ /// \brief Returns entity related to corresponding feature
+ SKETCHSOLVER_EXPORT const EntityWrapperPtr& entity(const FeaturePtr& theFeature) const;
+ /// \brief Returns entity related to corresponding attribute
+ SKETCHSOLVER_EXPORT const EntityWrapperPtr& entity(const AttributePtr& theAttribute) const;
+
+ /// \brief Return parsed sketch entity
+ const EntityWrapperPtr& sketch() const;
+ /// \brief Set parsed sketch entity.
+ /// Be careful, this method does not update fields of the storage specific for the solver.
+ /// Does not update if the sketch already exists.
+ void setSketch(const EntityWrapperPtr& theSketch);
+
+ /// \brief Mark two points as coincident
+ virtual void addCoincidentPoints(EntityWrapperPtr theMaster, EntityWrapperPtr theSlave) = 0;
+
+ /// \brief Shows the storage has any constraint twice
+ virtual bool hasDuplicatedConstraint() const = 0;
+
+ /// \brief Removes constraint from the storage
+ /// \return \c true if the constraint and all its parameters are removed successfully
+ SKETCHSOLVER_EXPORT bool removeConstraint(ConstraintPtr theConstraint);
+ /// \brief Removes feature from the storage
+ /// \return \c true if the feature and its attributes are removed successfully;
+ /// \c false if the feature or any it attribute is used by remaining constraints.
+ SKETCHSOLVER_EXPORT bool removeEntity(FeaturePtr theFeature);
+ /// \brief Removes attribute from the storage
+ /// \return \c true if the attribute is not used by remaining features and constraints
+ SKETCHSOLVER_EXPORT bool removeEntity(AttributePtr theAttribute);
+
+ /// \brief Remove all features became invalid
+ SKETCHSOLVER_EXPORT void removeInvalidEntities();
+
+ /// \brief Check whether the feature or its attributes are used by this storage
+ /// \param theFeature [in] feature to be checked
+ /// \return \c true if the feature interacts with the storage
+ bool isInteract(const FeaturePtr& theFeature) const;
+ /// \brief Check whether the attribute is used by this storage
+ /// \param theAttribute [in] attribute to be checked
+ /// \return \c true if the attribute interacts with the storage
+ bool isInteract(const AttributePtr& theAttribute) const;
+
+ /// \brief Check the features is not removed
+ bool isConsistent() const;
+
+ /// \brief Check the storage has constraints
+ bool isEmpty() const
+ { return myConstraintMap.empty(); }
+
+ /// \brief Check the entity is fixed.
+ /// If the point is under verification, all coincident points are checked too.
+ SKETCHSOLVER_EXPORT bool isFixed(EntityWrapperPtr theEntity) const;