1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
3 // File: SketchSolver_Builder.h
4 // Created: 25 Mar 2015
5 // Author: Artem ZHIDKOV
7 #ifndef SketchSolver_Builder_H_
8 #define SketchSolver_Builder_H_
10 #include <SketchSolver_Constraint.h>
11 #include <SketchPlugin_Constraint.h>
13 #include <GeomAPI_Lin2d.h>
14 #include <GeomAPI_Pnt2d.h>
16 /** \class SketchSolver_Builder
18 * \brief Abstract class for builders of solver's entities
20 class SketchSolver_Builder
23 /// \brief Creates a storage specific for used solver
24 virtual StoragePtr createStorage(const GroupID& theGroup) const = 0;
25 /// \brief Creates specific solver
26 virtual SolverPtr createSolver() const = 0;
28 /// \brief Creates a solver's constraint using given SketchPlugin constraint
29 /// or returns empty pointer if not all attributes are correct
30 SolverConstraintPtr createConstraint(ConstraintPtr theConstraint) const;
32 /// \brief Creates temporary constraint to fix the placement of the feature
33 SolverConstraintPtr createFixedConstraint(FeaturePtr theFixedFeature) const;
35 /// \brief Creates temporary constraint to fix the feature after movement
36 SolverConstraintPtr createMovementConstraint(FeaturePtr theFixedFeature) 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 (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& theGroup,
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 = 0;
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 thePoint1 [in] center for multi-rotation or start point for multi-translation
69 /// \param thePoint2 [in] end point for multi-translation (empty for multi-rotation)
70 /// \param theTrsfEnt [in] list of transformed entities
71 virtual std::list<ConstraintWrapperPtr>
72 createConstraint(ConstraintPtr theConstraint,
73 const GroupID& theGroup,
74 const EntityID& theSketchID,
75 const SketchSolver_ConstraintType& theType,
76 const double& theValue,
77 const bool& theFullValue,
78 const EntityWrapperPtr& thePoint1,
79 const EntityWrapperPtr& thePoint2,
80 const std::list<EntityWrapperPtr>& theTrsfEnt) const = 0;
82 /// \brief Update flags for several kinds of constraints
83 virtual void adjustConstraint(ConstraintWrapperPtr theConstraint) const = 0;
85 /// \brief Creates a feature using list of already created attributes
86 /// \param theFeature [in] feature to create
87 /// \param theAttributes [in] attributes of the feature
88 /// \param theGroupID [in] group the feature belongs to
89 /// \param theSketchID [in] sketch the feature belongs to
90 /// \return Created wrapper of the feature applicable for specific solver
91 virtual EntityWrapperPtr createFeature(FeaturePtr theFeature,
92 const std::list<EntityWrapperPtr>& theAttributes,
93 const GroupID& theGroupID,
94 const EntityID& theSketchID = EID_UNKNOWN) const = 0;
96 /// \brief Creates an attribute
97 /// \param theAttribute [in] attribute to create
98 /// \param theGroup [in] group the attribute belongs to
99 /// \param theSketchID [in] sketch the attribute belongs to
100 /// \return Created wrapper of the attribute applicable for specific solver
101 virtual EntityWrapperPtr createAttribute(AttributePtr theAttribute,
102 const GroupID& theGroup,
103 const EntityID& theSketchID = EID_UNKNOWN) const = 0;
106 /// \brief Convert entity to point
107 /// \return empty pointer if the entity is not a point
108 SKETCHSOLVER_EXPORT std::shared_ptr<GeomAPI_Pnt2d> point(EntityWrapperPtr theEntity) const;
109 /// \brief Convert entity to line
110 /// \return empty pointer if the entity is not a line
111 SKETCHSOLVER_EXPORT std::shared_ptr<GeomAPI_Lin2d> line(EntityWrapperPtr theEntity) const;
114 typedef std::shared_ptr<SketchSolver_Builder> BuilderPtr;