Salome HOME
Fix for solids color changing after sketch modification
[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.h"
11 #include <SketchSolver_Constraint.h>
12
13 #include <SketchPlugin_Constraint.h>
14
15 #include <ModelAPI_CompositeFeature.h>
16
17 /** \class   SketchSolver_Builder
18  *  \ingroup Plugins
19  *  \brief   Create bridges between SketchPlugin constraints and SolveSpace constraints
20  */
21 class SketchSolver_Builder
22 {
23 private:
24   /// Default constructor
25   SketchSolver_Builder() {}
26
27 public:
28   /// \brief Returns single instance of builder
29   static SketchSolver_Builder* getInstance();
30
31   /// \brief Creates a solver's constraint using given SketchPlugin constraint
32   ///        or returns empty pointer if not all attributes are correct
33   SolverConstraintPtr createConstraint(ConstraintPtr theConstraint);
34
35   /// \brief Creates temporary constraint to fix the placement of the feature
36   SolverConstraintPtr createRigidConstraint(FeaturePtr theFixedFeature);
37
38   /// \brief Creates temporary constraint to fix the feature after movement
39   SolverConstraintPtr createMovementConstraint(FeaturePtr theFixedFeature);
40
41   /// \brief Creates constraint for parametrically given attribute
42   SolverConstraintPtr createParametricConstraint(AttributePtr theAttribute);
43
44   /// \brief Converts sketch parameters to the list of SolveSpace entities.
45   ///        Identifiers of entities and parameters are local. They should be changed while adding into storage.
46   ///        The sketch entity goes last.
47   /// \param[in]  theSketch     the element to be converted
48   /// \param[out] theEntities   created list of entities
49   /// \param[out] theParameters created list of parameters of the entities
50   /// \return \c true if workplane created
51   bool createWorkplane(CompositeFeaturePtr theSketch,
52                        std::vector<Slvs_Entity>& theEntities,
53                        std::vector<Slvs_Param>& theParameters);
54
55   /// \brief Converts attribute to the list of entities.
56   ///        Identifiers are local (see createWorkplane).
57   ///        The main entity goes last.
58   bool createEntity(AttributePtr theAttribute,
59                     std::vector<Slvs_Entity>& theEntities,
60                     std::vector<Slvs_Param>& theParameters);
61   /// \brief Converts feature to the list of entities.
62   ///        Identifiers are local (see createWorkplane).
63   ///        The main entity goes last.
64   bool createEntity(FeaturePtr theFeature,
65                     std::vector<Slvs_Entity>& theEntities,
66                     std::vector<Slvs_Param>& theParameters);
67
68   /// \brief Converts normal and OX direction to the list of entities representing a normal in SolveSpace.
69   ///        Identifiers are local (see createWorkplane).
70   ///        The main entity goes last.
71   bool createNormal(AttributePtr theNormal,
72                     AttributePtr theDirX,
73                     std::vector<Slvs_Entity>& theEntities,
74                     std::vector<Slvs_Param>& theParameters);
75
76 private:
77   static SketchSolver_Builder* mySelf;
78 };
79
80 #endif