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