X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FSketchSolver%2FSketchSolver_Builder.h;h=a2d67beb84f2e47bdde2b39f9596575eba5daa42;hb=4f565b2204d3fba046aa8c851abada2a5a17bf6c;hp=e9aa10d9e9fd9d3efbbec702c50d72eeca2e9769;hpb=33b3a43ad2266cb044e4232c902344842adbba7c;p=modules%2Fshaper.git diff --git a/src/SketchSolver/SketchSolver_Builder.h b/src/SketchSolver/SketchSolver_Builder.h index e9aa10d9e..a2d67beb8 100644 --- a/src/SketchSolver/SketchSolver_Builder.h +++ b/src/SketchSolver/SketchSolver_Builder.h @@ -7,68 +7,122 @@ #ifndef SketchSolver_Builder_H_ #define SketchSolver_Builder_H_ -#include "SketchSolver.h" #include - #include -#include +#include +#include /** \class SketchSolver_Builder * \ingroup Plugins - * \brief Create bridges between SketchPlugin constraints and SolveSpace constraints + * \brief Abstract class for builders of solver's entities */ class SketchSolver_Builder { -private: - /// Default constructor - SketchSolver_Builder() {} - public: - /// \brief Returns single instance of builder - static SketchSolver_Builder* getInstance(); + /// \brief Creates a storage specific for used solver + virtual StoragePtr createStorage(const GroupID& theGroup) const = 0; + /// \brief Creates specific solver + virtual SolverPtr createSolver() const = 0; /// \brief Creates a solver's constraint using given SketchPlugin constraint /// or returns empty pointer if not all attributes are correct - SolverConstraintPtr createConstraint(ConstraintPtr theConstraint); + SolverConstraintPtr createConstraint(ConstraintPtr theConstraint) const; /// \brief Creates temporary constraint to fix the placement of the feature - SolverConstraintPtr createRigidConstraint(FeaturePtr theFixedFeature); - - /// \brief Converts sketch parameters to the list of SolveSpace entities. - /// Identifiers of entities and parameters are local. They should be changed while adding into storage. - /// The sketch entity goes last. - /// \param[in] theSketch the element to be converted - /// \param[out] theEntities created list of entities - /// \param[out] theParameters created list of parameters of the entities - /// \return \c true if workplane created - bool createWorkplane(CompositeFeaturePtr theSketch, - std::vector& theEntities, - std::vector& theParameters); - - /// \brief Converts attribute to the list of entities. - /// Identifiers are local (see createWorkplane). - /// The main entity goes last. - bool createEntity(AttributePtr theAttribute, - std::vector& theEntities, - std::vector& theParameters); - /// \brief Converts feature to the list of entities. - /// Identifiers are local (see createWorkplane). - /// The main entity goes last. - bool createEntity(FeaturePtr theFeature, - std::vector& theEntities, - std::vector& theParameters); - - /// \brief Converts normal and OX direction to the list of entities representing a normal in SolveSpace. - /// Identifiers are local (see createWorkplane). - /// The main entity goes last. - bool createNormal(AttributePtr theNormal, - AttributePtr theDirX, - std::vector& theEntities, - std::vector& theParameters); - -private: - static SketchSolver_Builder* mySelf; + SolverConstraintPtr createFixedConstraint(FeaturePtr theFixedFeature) const; + + /// \brief Creates temporary constraint to fix radius of the arc + SolverConstraintPtr createFixedArcRadiusConstraint(FeaturePtr theArc) const; + + /// \brief Creates temporary constraint to fix the feature after movement + SolverConstraintPtr createMovementConstraint(FeaturePtr theFixedFeature) const; + + /// \brief Creates new constraint(s) using given parameters + /// \param theConstraint [in] original constraint + /// \param theGroupID [in] group the constraint belongs to + /// \param theSketchID [in] sketch the constraint belongs to + /// \param theType [in] type of constraint + /// \param theValue [in] numeric characteristic of constraint + /// (e.g. distance or radius) if applicable + /// \param theEntity1 [in] first attribute of constraint + /// \param theEntity2 [in] second attribute of constraint + /// \param theEntity3 [in] third attribute of constraint + /// \param theEntity4 [in] fourth attribute of constraint + /// \return Created list of wrappers of constraints applicable for specific solver. + /// Most of constraint types lead to single constraint, but there are some kind of + /// constraints (e.g. mirror), which may produce couple of constraints. + virtual std::list + createConstraint(ConstraintPtr theConstraint, + const GroupID& theGroup, + const EntityID& theSketchID, + const SketchSolver_ConstraintType& theType, + const double& theValue, + const EntityWrapperPtr& theEntity1, + const EntityWrapperPtr& theEntity2 = EntityWrapperPtr(), + const EntityWrapperPtr& theEntity3 = EntityWrapperPtr(), + const EntityWrapperPtr& theEntity4 = EntityWrapperPtr()) const = 0; + + /// \brief Creates new multi-translation or multi-rotation constraint + /// \param theConstraint [in] original constraint + /// \param theGroupID [in] group the constraint belongs to + /// \param theSketchID [in] sketch the constraint belongs to + /// \param theType [in] type of constraint + /// \param theValue [in] numeric characteristic of constraint (angle for multi-rotation) + /// if applicable + /// \param theFullValue [in] indicates theValue shows full translation delta/rotation angle or + /// delta/angle between neighbor entities + /// \param thePoint1 [in] center for multi-rotation or start point for multi-translation + /// \param thePoint2 [in] end point for multi-translation (empty for multi-rotation) + /// \param theTrsfEnt [in] list of transformed entities + virtual std::list + createConstraint(ConstraintPtr theConstraint, + const GroupID& theGroup, + const EntityID& theSketchID, + const SketchSolver_ConstraintType& theType, + const double& theValue, + const bool theFullValue, + const EntityWrapperPtr& thePoint1, + const EntityWrapperPtr& thePoint2, + const std::list& theTrsfEnt) const = 0; + + /// \brief Update flags for several kinds of constraints + virtual void adjustConstraint(ConstraintWrapperPtr theConstraint) const = 0; + + /// \brief Creates a feature using list of already created attributes + /// \param theFeature [in] feature to create + /// \param theAttributes [in] attributes of the feature + /// \param theGroupID [in] group the feature belongs to + /// \param theSketchID [in] sketch the feature belongs to + /// \return Created wrapper of the feature applicable for specific solver + virtual EntityWrapperPtr createFeature(FeaturePtr theFeature, + const std::list& theAttributes, + const GroupID& theGroupID, + const EntityID& theSketchID = EID_UNKNOWN) const = 0; + + /// \brief Creates an attribute + /// \param theAttribute [in] attribute to create + /// \param theGroup [in] group the attribute belongs to + /// \param theSketchID [in] sketch the attribute belongs to + /// \return Created wrapper of the attribute applicable for specific solver + virtual EntityWrapperPtr createAttribute(AttributePtr theAttribute, + const GroupID& theGroup, + const EntityID& theSketchID = EID_UNKNOWN) const = 0; + + + /// \brief Convert entity to point + /// \return empty pointer if the entity is not a point + SKETCHSOLVER_EXPORT std::shared_ptr point(EntityWrapperPtr theEntity) const; + /// \brief Convert entity to line + /// \return empty pointer if the entity is not a line + SKETCHSOLVER_EXPORT std::shared_ptr line(EntityWrapperPtr theEntity) const; + + /// \brief Check if two connected arcs have centers + /// in same direction relatively to connection point + SKETCHSOLVER_EXPORT virtual bool isArcArcTangencyInternal(EntityWrapperPtr theArc1, + EntityWrapperPtr theArc2) const { return false; } }; +typedef std::shared_ptr BuilderPtr; + #endif