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