SHAPER 9.16.0
SketchSolver_Group.h
1// Copyright (C) 2014-2026 CEA, EDF
2//
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.
7//
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.
12//
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
16//
17// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18//
19
20#ifndef SketchSolver_Group_H_
21#define SketchSolver_Group_H_
22
23#include <SketchSolver_Constraint.h>
24#include <SketchSolver_Storage.h>
25
26#include <PlaneGCSSolver_Solver.h>
27
28#include <SketchPlugin_Constraint.h>
29
30#include <memory>
31#include <map>
32
33class GeomAPI_Dir;
34class GeomAPI_Pnt;
35class GeomAPI_Pnt2d;
36
37typedef std::map<ConstraintPtr, SolverConstraintPtr> ConstraintConstraintMap;
38
44{
45 public:
50 SketchSolver_Group(const CompositeFeaturePtr& theWorkplane);
51
52 virtual ~SketchSolver_Group();
53
55 inline bool isEmpty() const
56 {
57 return myConstraints.empty() && myTempConstraints.empty();
58 }
59
61 inline bool isWorkplaneValid() const
62 {
63 return mySketch->data() && mySketch->data()->isValid();
64 }
65
70 bool changeConstraint(std::shared_ptr<SketchPlugin_Constraint> theConstraint);
71
74 bool updateSketch(CompositeFeaturePtr theSketch);
75
79 bool updateFeature(FeaturePtr theFeature);
80
88 bool moveFeature(FeaturePtr theFeature,
89 const std::shared_ptr<GeomAPI_Pnt2d>& theFrom,
90 const std::shared_ptr<GeomAPI_Pnt2d>& theTo);
99 bool movePoint(AttributePtr thePointOrArray,
100 const int thePointIndex,
101 const std::shared_ptr<GeomAPI_Pnt2d>& theFrom,
102 const std::shared_ptr<GeomAPI_Pnt2d>& theTo);
103
105 inline const CompositeFeaturePtr& getWorkplane() const
106 {
107 return mySketch;
108 }
109
113 void repairConsistency();
114
118 bool resolveConstraints();
119
121 void underconstrainedFeatures(std::set<ObjectPtr>& theFeatures) const;
122
124 void blockEvents(bool isBlocked);
125
126private:
128 bool areConstraintsValid() const;
129
133 void removeConstraint(ConstraintPtr theConstraint);
134
136 void removeTemporaryConstraints();
137
139 void setTemporary(SolverConstraintPtr theConstraint);
140
142 void computeDoF();
143
144private:
145 CompositeFeaturePtr mySketch;
146 std::shared_ptr<GeomAPI_Pnt> mySketchOrigin;
147 std::shared_ptr<GeomAPI_Dir> mySketchNormal;
148 std::shared_ptr<GeomAPI_Dir> mySketchXDir;
149
150 ConstraintConstraintMap myConstraints;
151 std::set<SolverConstraintPtr> myTempConstraints;
152
153 StoragePtr myStorage;
154 SolverPtr mySketchSolver;
155
158 std::set<ObjectPtr> myConflictingConstraints;
159
160 int myDOF;
161
162 bool myIsEventsBlocked;
163
164 int myMultiConstraintUpdateStack;
165};
166
167typedef std::shared_ptr<SketchSolver_Group> SketchGroupPtr;
168
169#endif
3D direction defined by three normalized coordinates
Definition: GeomAPI_Dir.h:34
2D point defined by two coordinates
Definition: GeomAPI_Pnt2d.h:36
3D point defined by three coordinates
Definition: GeomAPI_Pnt.h:38
SolveStatus
The result of constraints solution.
Definition: PlaneGCSSolver_Solver.h:33
Keeps the group of constraints which placed in the same sketch.
Definition: SketchSolver_Group.h:44
bool resolveConstraints()
Start solution procedure if necessary and update attributes of features.
Definition: SketchSolver_Group.cpp:232
SketchSolver_Group(const CompositeFeaturePtr &theWorkplane)
New group based on specified workplane.
Definition: SketchSolver_Group.cpp:77
bool moveFeature(FeaturePtr theFeature, const std::shared_ptr< GeomAPI_Pnt2d > &theFrom, const std::shared_ptr< GeomAPI_Pnt2d > &theTo)
Updates the data corresponding the specified feature moved in GUI.
Definition: SketchSolver_Group.cpp:196
void repairConsistency()
Searches invalid features and constraints in the group and removes them.
Definition: SketchSolver_Group.cpp:423
bool isEmpty() const
Returns true if the group has no constraints yet.
Definition: SketchSolver_Group.h:55
void underconstrainedFeatures(std::set< ObjectPtr > &theFeatures) const
Find the list of features, which are not fully constrained.
Definition: SketchSolver_Group.cpp:528
bool updateSketch(CompositeFeaturePtr theSketch)
Updates the sketch feature.
Definition: SketchSolver_Group.cpp:128
void blockEvents(bool isBlocked)
Block or unblock events sent by features in this group.
Definition: SketchSolver_Group.cpp:502
bool isWorkplaneValid() const
Check for valid sketch data.
Definition: SketchSolver_Group.h:61
bool changeConstraint(std::shared_ptr< SketchPlugin_Constraint > theConstraint)
Adds or updates a constraint in the group.
Definition: SketchSolver_Group.cpp:103
bool movePoint(AttributePtr thePointOrArray, const int thePointIndex, const std::shared_ptr< GeomAPI_Pnt2d > &theFrom, const std::shared_ptr< GeomAPI_Pnt2d > &theTo)
Updates the data corresponding the specified point moved in GUI.
Definition: SketchSolver_Group.cpp:207
bool updateFeature(FeaturePtr theFeature)
Updates the data corresponding the specified feature.
Definition: SketchSolver_Group.cpp:156
const CompositeFeaturePtr & getWorkplane() const
Returns the current workplane.
Definition: SketchSolver_Group.h:105