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.h"
11 #include <SketchSolver_Constraint.h>
13 #include <SketchPlugin_Constraint.h>
15 #include <ModelAPI_CompositeFeature.h>
17 /** \class SketchSolver_Builder
19 * \brief Create bridges between SketchPlugin constraints and SolveSpace constraints
21 class SketchSolver_Builder
24 /// Default constructor
25 SketchSolver_Builder() {}
28 /// \brief Returns single instance of builder
29 static SketchSolver_Builder* getInstance();
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);
35 /// \brief Creates temporary constraint to fix the placement of the feature
36 SolverConstraintPtr createRigidConstraint(FeaturePtr theFixedFeature);
38 /// \brief Creates temporary constraint to fix the feature after movement
39 SolverConstraintPtr createMovementConstraint(FeaturePtr theFixedFeature);
41 /// \brief Converts sketch parameters to the list of SolveSpace entities.
42 /// Identifiers of entities and parameters are local. They should be changed while adding into storage.
43 /// The sketch entity goes last.
44 /// \param[in] theSketch the element to be converted
45 /// \param[out] theEntities created list of entities
46 /// \param[out] theParameters created list of parameters of the entities
47 /// \return \c true if workplane created
48 bool createWorkplane(CompositeFeaturePtr theSketch,
49 std::vector<Slvs_Entity>& theEntities,
50 std::vector<Slvs_Param>& theParameters);
52 /// \brief Converts attribute to the list of entities.
53 /// Identifiers are local (see createWorkplane).
54 /// The main entity goes last.
55 bool createEntity(AttributePtr theAttribute,
56 std::vector<Slvs_Entity>& theEntities,
57 std::vector<Slvs_Param>& theParameters);
58 /// \brief Converts feature to the list of entities.
59 /// Identifiers are local (see createWorkplane).
60 /// The main entity goes last.
61 bool createEntity(FeaturePtr theFeature,
62 std::vector<Slvs_Entity>& theEntities,
63 std::vector<Slvs_Param>& theParameters);
65 /// \brief Converts normal and OX direction to the list of entities representing a normal in SolveSpace.
66 /// Identifiers are local (see createWorkplane).
67 /// The main entity goes last.
68 bool createNormal(AttributePtr theNormal,
70 std::vector<Slvs_Entity>& theEntities,
71 std::vector<Slvs_Param>& theParameters);
74 static SketchSolver_Builder* mySelf;