Salome HOME
Using test for testing number of sub-shapes.
[modules/shaper.git] / src / SketchSolver / SketchSolver_Builder.h
1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
2
3 // File:    SketchSolver_Builder.h
4 // Created: 25 Mar 2015
5 // Author:  Artem ZHIDKOV
6
7 #ifndef SketchSolver_Builder_H_
8 #define SketchSolver_Builder_H_
9
10 #include <SketchSolver_Constraint.h>
11 #include <SketchPlugin_Constraint.h>
12
13 #include <GeomAPI_Lin2d.h>
14 #include <GeomAPI_Pnt2d.h>
15
16 /** \class   SketchSolver_Builder
17  *  \ingroup Plugins
18  *  \brief   Abstract class for builders of solver's entities
19  */
20 class SketchSolver_Builder
21 {
22 public:
23   /// \brief Creates a storage specific for used solver
24   virtual StoragePtr createStorage(const GroupID& theGroup) const = 0;
25   /// \brief Creates specific solver
26   virtual SolverPtr createSolver() const = 0;
27
28   /// \brief Creates a solver's constraint using given SketchPlugin constraint
29   ///        or returns empty pointer if not all attributes are correct
30   SolverConstraintPtr createConstraint(ConstraintPtr theConstraint) const;
31
32   /// \brief Creates temporary constraint to fix the placement of the feature
33   SolverConstraintPtr createFixedConstraint(FeaturePtr theFixedFeature) const;
34
35   /// \brief Creates temporary constraint to fix radius of the arc
36   SolverConstraintPtr createFixedArcRadiusConstraint(FeaturePtr theArc) const;
37
38   /// \brief Creates temporary constraint to fix the feature after movement
39   SolverConstraintPtr createMovementConstraint(FeaturePtr theFixedFeature) const;
40
41   /// \brief Creates new constraint(s) using given parameters
42   /// \param theConstraint [in]  original constraint
43   /// \param theGroupID    [in]  group the constraint belongs to
44   /// \param theSketchID   [in]  sketch the constraint belongs to
45   /// \param theType       [in]  type of constraint
46   /// \param theValue      [in]  numeric characteristic of constraint
47   /// (e.g. distance or radius) if applicable
48   /// \param theEntity1    [in]  first attribute of constraint
49   /// \param theEntity2    [in]  second attribute of constraint
50   /// \param theEntity3    [in]  third attribute of constraint
51   /// \param theEntity4    [in]  fourth attribute of constraint
52   /// \return Created list of wrappers of constraints applicable for specific solver.
53   ///         Most of constraint types lead to single constraint, but there are some kind of
54   ///         constraints (e.g. mirror), which may produce couple of constraints.
55   virtual std::list<ConstraintWrapperPtr>
56     createConstraint(ConstraintPtr theConstraint,
57                      const GroupID& theGroup,
58                      const EntityID& theSketchID,
59                      const SketchSolver_ConstraintType& theType,
60                      const double& theValue,
61                      const EntityWrapperPtr& theEntity1,
62                      const EntityWrapperPtr& theEntity2 = EntityWrapperPtr(),
63                      const EntityWrapperPtr& theEntity3 = EntityWrapperPtr(),
64                      const EntityWrapperPtr& theEntity4 = EntityWrapperPtr()) const = 0;
65
66   /// \brief Creates new multi-translation or multi-rotation constraint
67   /// \param theConstraint [in]  original constraint
68   /// \param theGroupID    [in]  group the constraint belongs to
69   /// \param theSketchID   [in]  sketch the constraint belongs to
70   /// \param theType       [in]  type of constraint
71   /// \param theValue      [in]  numeric characteristic of constraint (angle for multi-rotation)
72   ///                            if applicable
73   /// \param theFullValue  [in]  indicates theValue shows full translation delta/rotation angle or
74   ///  delta/angle between neighbor entities
75   /// \param thePoint1     [in]  center for multi-rotation or start point for multi-translation
76   /// \param thePoint2     [in]  end point for multi-translation (empty for multi-rotation)
77   /// \param theTrsfEnt    [in]  list of transformed entities
78   virtual std::list<ConstraintWrapperPtr>
79     createConstraint(ConstraintPtr theConstraint,
80                      const GroupID& theGroup,
81                      const EntityID& theSketchID,
82                      const SketchSolver_ConstraintType& theType,
83                      const double& theValue,
84                      const bool theFullValue,
85                      const EntityWrapperPtr& thePoint1,
86                      const EntityWrapperPtr& thePoint2,
87                      const std::list<EntityWrapperPtr>& theTrsfEnt) const = 0;
88
89   /// \brief Update flags for several kinds of constraints
90   virtual void adjustConstraint(ConstraintWrapperPtr theConstraint) const = 0;
91
92   /// \brief Creates a feature using list of already created attributes
93   /// \param theFeature    [in]  feature to create
94   /// \param theAttributes [in]  attributes of the feature
95   /// \param theGroupID    [in]  group the feature belongs to
96   /// \param theSketchID   [in]  sketch the feature belongs to
97   /// \return Created wrapper of the feature applicable for specific solver
98   virtual EntityWrapperPtr createFeature(FeaturePtr theFeature,
99                                          const std::list<EntityWrapperPtr>& theAttributes,
100                                          const GroupID& theGroupID,
101                                          const EntityID& theSketchID = EID_UNKNOWN) const = 0;
102
103   /// \brief Creates an attribute
104   /// \param theAttribute [in]  attribute to create
105   /// \param theGroup     [in]  group the attribute belongs to
106   /// \param theSketchID  [in]  sketch the attribute belongs to
107   /// \return Created wrapper of the attribute applicable for specific solver
108   virtual EntityWrapperPtr createAttribute(AttributePtr theAttribute,
109                                            const GroupID& theGroup,
110                                            const EntityID& theSketchID = EID_UNKNOWN) const = 0;
111
112
113   /// \brief Convert entity to point
114   /// \return empty pointer if the entity is not a point
115   SKETCHSOLVER_EXPORT std::shared_ptr<GeomAPI_Pnt2d> point(EntityWrapperPtr theEntity) const;
116   /// \brief Convert entity to line
117   /// \return empty pointer if the entity is not a line
118   SKETCHSOLVER_EXPORT std::shared_ptr<GeomAPI_Lin2d> line(EntityWrapperPtr theEntity) const;
119
120   /// \brief Check if two connected arcs have centers
121   ///        in same direction relatively to connection point
122   SKETCHSOLVER_EXPORT virtual bool isArcArcTangencyInternal(EntityWrapperPtr theArc1,
123     EntityWrapperPtr theArc2) const { return false; }
124 };
125
126 typedef std::shared_ptr<SketchSolver_Builder> BuilderPtr;
127
128 #endif