1 // Copyright (C) 2014-2019 CEA/DEN, EDF R&D
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // Lesser General Public License for more details.
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 #ifndef PlaneGCSSolver_Tools_H_
21 #define PlaneGCSSolver_Tools_H_
23 #include <SketchSolver_Constraint.h>
24 #include <SketchSolver_ConstraintMovement.h>
25 #include <SketchPlugin_Constraint.h>
28 class GeomAPI_Ellipse2d;
32 /** \namespace PlaneGCSSolver_Tools
34 * \brief Converter tools
36 namespace PlaneGCSSolver_Tools
38 /// \brief Creates a solver's constraint using given SketchPlugin constraint
39 /// or returns empty pointer if not all attributes are correct
40 SolverConstraintPtr createConstraint(ConstraintPtr theConstraint);
42 /// \brief Creates temporary constraint to fix the feature after movement
43 std::shared_ptr<SketchSolver_ConstraintMovement>
44 createMovementConstraint(FeaturePtr theMovedFeature);
45 /// \brief Creates temporary constraint to fix the attribute after movement
46 std::shared_ptr<SketchSolver_ConstraintMovement>
47 createMovementConstraint(AttributePtr theMovedAttribute);
48 /// \brief Creates temporary constraint to fix the point in array after movement
49 std::shared_ptr<SketchSolver_ConstraintMovement>
50 createMovementConstraint(const std::pair<AttributePtr, int>& theMovedPointInArray);
52 /// \brief Creates new constraint using given parameters
53 /// \param theConstraint [in] original constraint
54 /// \param theType [in] type of constraint
55 /// \param theValue [in] numeric characteristic of constraint
56 /// (e.g. distance or radius) if applicable
57 /// \param theEntity1 [in] first attribute of constraint
58 /// \param theEntity2 [in] second attribute of constraint
59 /// \param theEntity3 [in] third attribute of constraint
60 /// \param theEntity4 [in] fourth attribute of constraint
61 /// \return Created wrapper of constraints applicable for specific solver.
62 ConstraintWrapperPtr createConstraint(ConstraintPtr theConstraint,
63 const SketchSolver_ConstraintType& theType,
64 const EntityWrapperPtr& theValue,
65 const EntityWrapperPtr& theEntity1,
66 const EntityWrapperPtr& theEntity2 = EntityWrapperPtr(),
67 const EntityWrapperPtr& theEntity3 = EntityWrapperPtr(),
68 const EntityWrapperPtr& theEntity4 = EntityWrapperPtr());
70 /// \brief Convert entity to point
71 /// \return empty pointer if the entity is not a point
72 std::shared_ptr<GeomAPI_Pnt2d> point(EntityWrapperPtr theEntity);
73 /// \brief Convert entity to line
74 /// \return empty pointer if the entity is not a line
75 std::shared_ptr<GeomAPI_Lin2d> line(EntityWrapperPtr theEntity);
76 /// \brief Convert entity to circle
77 /// \return empty pointer if the entity is not a circle
78 std::shared_ptr<GeomAPI_Circ2d> circle(EntityWrapperPtr theEntity);
79 /// \brief Convert entity to ellipse
80 /// \return empty pointer if the entity is not an ellipse
81 std::shared_ptr<GeomAPI_Ellipse2d> ellipse(EntityWrapperPtr theEntity);
83 /// \brief Convert entity to line
84 /// \return empty pointer if the entity is not a line
85 std::shared_ptr<GeomAPI_Lin2d> line(FeaturePtr theFeature);
87 /// \brief Update start and end parameters of circular and elliptic arcs
88 /// respectively to start and end points on the arc.
89 /// For the circular arc, the radius is calculated too.
90 void recalculateArcParameters(EntityWrapperPtr theArc);
92 /// brief Return list of parameters for the given entity
93 GCS::SET_pD parameters(const EntityWrapperPtr& theEntity);