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