Salome HOME
crash fix: mirror (line, axis of sketch), select with rectangle, delete
[modules/shaper.git] / src / SketchSolver / PlaneGCSSolver / PlaneGCSSolver_Builder.h
1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
2
3 // File:    PlaneGCSSolver_Builder.h
4 // Created: 14 Dec 2015
5 // Author:  Artem ZHIDKOV
6
7 #ifndef PlaneGCSSolver_Builder_H_
8 #define PlaneGCSSolver_Builder_H_
9
10 #include <PlaneGCSSolver_Defs.h>
11
12 #include <SketchSolver_Builder.h>
13 #include <SketchSolver_Constraint.h>
14
15 #include <SketchPlugin_Constraint.h>
16
17 #include <ModelAPI_CompositeFeature.h>
18
19 /** \class   PlaneGCSSolver_Builder
20  *  \ingroup Plugins
21  *  \brief   Create bridges between SketchPlugin constraints and PlaneGCS constraints
22  */
23 class PlaneGCSSolver_Builder : public SketchSolver_Builder
24 {
25 private:
26   /// Default constructor
27   PlaneGCSSolver_Builder() {}
28
29 public:
30   /// \brief Returns single instance of builder
31   static BuilderPtr getInstance();
32
33   /// \brief Creates a storage specific for used solver
34   virtual StoragePtr createStorage(const GroupID& theGroup) const;
35   /// \brief Creates specific solver
36   virtual SolverPtr createSolver() const;
37
38   /// \brief Creates new constraint(s) using given parameters
39   /// \param theConstraint [in]  original constraint
40   /// \param theGroupID    [in]  group the constraint belongs to
41   /// \param theSketchID   [in]  sketch the constraint belongs to
42   /// \param theType       [in]  type of constraint
43   /// \param theValue      [in]  numeric characteristic of constraint (e.g. distance or radius) if applicable
44   /// \param theEntity1    [in]  first attribute of constraint
45   /// \param theEntity2    [in]  second attribute of constraint
46   /// \param theEntity3    [in]  third attribute of constraint
47   /// \param theEntity4    [in]  fourth attribute of constraint
48   /// \return Created list of wrappers of constraints applicable for specific solver.
49   ///         Most of constraint types lead to single constraint, but there are some kind of
50   ///         constraints (e.g. mirror), which may produce couple of constraints.
51   virtual std::list<ConstraintWrapperPtr>
52     createConstraint(ConstraintPtr theConstraint,
53                      const GroupID& theGroupID,
54                      const EntityID& theSketchID,
55                      const SketchSolver_ConstraintType& theType,
56                      const double& theValue,
57                      const EntityWrapperPtr& theEntity1,
58                      const EntityWrapperPtr& theEntity2 = EntityWrapperPtr(),
59                      const EntityWrapperPtr& theEntity3 = EntityWrapperPtr(),
60                      const EntityWrapperPtr& theEntity4 = EntityWrapperPtr()) const;
61
62   /// \brief Creates new multi-translation or multi-rotation constraint
63   /// \param theConstraint [in]  original constraint
64   /// \param theGroupID    [in]  group the constraint belongs to
65   /// \param theSketchID   [in]  sketch the constraint belongs to
66   /// \param theType       [in]  type of constraint
67   /// \param theValue      [in]  numeric characteristic of constraint (angle for multi-rotation) if applicable
68   /// \param theFullValue  [in]  indicates theValue shows full translation delta/rotation angle or delta/angle between neighbor entities
69   /// \param thePoint1     [in]  center for multi-rotation or start point for multi-translation
70   /// \param thePoint2     [in]  end point for multi-translation (empty for multi-rotation)
71   /// \param theTrsfEnt    [in]  list of transformed entities
72   virtual std::list<ConstraintWrapperPtr>
73     createConstraint(ConstraintPtr theConstraint,
74                      const GroupID& theGroupID,
75                      const EntityID& theSketchID,
76                      const SketchSolver_ConstraintType& theType,
77                      const double& theValue,
78                      const bool theFullValue,
79                      const EntityWrapperPtr& thePoint1,
80                      const EntityWrapperPtr& thePoint2,
81                      const std::list<EntityWrapperPtr>& theTrsfEnt) const;
82
83   /// \brief Update flags for several kinds of constraints
84   virtual void adjustConstraint(ConstraintWrapperPtr theConstraint) const;
85
86   /// \brief Creates a feature using list of already created attributes
87   /// \param theFeature    [in]  feature to create
88   /// \param theAttributes [in]  attributes of the feature
89   /// \param theGroupID    [in]  group the feature belongs to
90   /// \param theSketchID   [in]  sketch the feature belongs to
91   /// \return Created wrapper of the feature applicable for specific solver
92   virtual EntityWrapperPtr createFeature(FeaturePtr theFeature,
93                                          const std::list<EntityWrapperPtr>& theAttributes,
94                                          const GroupID& theGroupID,
95                                          const EntityID& theSketchID = EID_UNKNOWN) const;
96
97   /// \brief Creates an attribute
98   /// \param theAttribute [in]  attribute to create
99   /// \param theGroup     [in]  group the attribute belongs to
100   /// \param theSketchID  [in]  sketch the attribute belongs to
101   /// \return Created wrapper of the attribute applicable for specific solver
102   virtual EntityWrapperPtr createAttribute(AttributePtr theAttribute,
103                                            const GroupID& theGroup,
104                                            const EntityID& theSketchID = EID_UNKNOWN) const;
105
106   /// \brief Create a parameter
107   /// \param theGroupID [in]  group the parameter belongs to
108   /// \param theValue   [in]  value of the parameter
109   /// \return Created wrapper for parameter
110   ParameterWrapperPtr createParameter(const GroupID& theGroupID, double theValue = 0.0) const;
111
112 private:
113   /// \brief Create necessary constraints to make two object symmetric relatively a given line
114   std::list<ConstraintWrapperPtr> createMirror(ConstraintPtr theConstraint,
115                                                const GroupID& theGroupID,
116                                                const EntityID& theSketchID,
117                                                const EntityWrapperPtr& theEntity1,
118                                                const EntityWrapperPtr& theEntity2,
119                                                const EntityWrapperPtr& theMirrorLine) const;
120
121   /// \brief Converts sketch parameters to the entity applicable for the solver.
122   /// \param theSketch  [in]  the element to be converted
123   /// \param theGroupID [in]  group where the sketch should be created
124   /// \return Entity respective the sketch or empty pointer, it the sketch has incorrect attributes
125   EntityWrapperPtr createSketchEntity(CompositeFeaturePtr theSketch,
126                                       const GroupID& theGroupID) const;
127
128 private:
129   static BuilderPtr mySelf;
130 };
131
132 #endif