@@ -86,46 +86,53 @@ bool SolveSpaceUI::PruneGroups(hGroup hg) {
86
86
return true ;
87
87
}
88
88
89
- bool SolveSpaceUI::PruneRequests (hGroup hg) {
90
- const int requests = SK.request .n ;
91
- for (Entity &e : SK.entity ) {
92
- if (e.group != hg) {
93
- continue ;
89
+ bool SolveSpaceUI::PruneRequestsAndConstraints (hGroup hg) {
90
+ auto entityRequestExists = [](hEntity he, bool checkEntity = false ) {
91
+ if (he == Entity::NO_ENTITY) {
92
+ return true ;
93
+ }
94
+
95
+ if (he.isFromRequest ()) {
96
+ if (SK.request .FindByIdNoOops (he.request ()) != nullptr ) {
97
+ return true ;
98
+ }
99
+ } else if (!checkEntity || SK.entity .FindByIdNoOops (he) != nullptr ) {
100
+ return true ;
94
101
}
95
102
96
- if (!e.h .isFromRequest ()) {
103
+ return false ;
104
+ };
105
+
106
+ const int requests = SK.request .n ;
107
+ for (Request &r : SK.request ) {
108
+ if (r.group != hg) {
97
109
continue ;
98
110
}
99
111
100
- if (EntityExists (e .workplane )) {
112
+ if (entityRequestExists (r .workplane )) {
101
113
continue ;
102
114
}
103
115
104
- Request *r = SK.GetRequest (e.h .request ());
105
- r->tag = 1 ;
116
+ r.tag = 1 ;
106
117
}
107
118
SK.request .RemoveTagged ();
108
119
deleted.requests += requests - SK.request .n ;
109
120
110
- return requests > SK.request .n ;
111
- }
112
-
113
- bool SolveSpaceUI::PruneConstraints (hGroup hg) {
114
121
const int constraints = SK.constraint .n ;
115
122
for (Constraint &c : SK.constraint ) {
116
- if (c.group != hg) continue ;
117
-
118
- if (EntityExists (c.workplane ) &&
119
- EntityExists (c.ptA ) &&
120
- EntityExists (c.ptB ) &&
121
- EntityExists (c.entityA ) &&
122
- EntityExists (c.entityB ) &&
123
- EntityExists (c.entityC ) &&
124
- EntityExists (c.entityD )) {
123
+ if (c.group != hg)
124
+ continue ;
125
+
126
+ if (entityRequestExists (c.workplane , true ) &&
127
+ entityRequestExists (c.ptA , true ) &&
128
+ entityRequestExists (c.ptB , true ) &&
129
+ entityRequestExists (c.entityA , true ) &&
130
+ entityRequestExists (c.entityB , true ) &&
131
+ entityRequestExists (c.entityC , true ) &&
132
+ entityRequestExists (c.entityD , true )) {
125
133
continue ;
126
134
}
127
135
128
- (deleted.constraints )++;
129
136
if (c.type != Constraint::Type::POINTS_COINCIDENT &&
130
137
c.type != Constraint::Type::HORIZONTAL &&
131
138
c.type != Constraint::Type::VERTICAL) {
@@ -134,10 +141,10 @@ bool SolveSpaceUI::PruneConstraints(hGroup hg) {
134
141
135
142
c.tag = 1 ;
136
143
}
137
-
138
144
SK.constraint .RemoveTagged ();
145
+ deleted.constraints += constraints - SK.constraint .n ;
139
146
140
- return constraints > SK.constraint .n ;
147
+ return (requests > SK. request . n ) || ( constraints > SK.constraint .n ) ;
141
148
}
142
149
143
150
void SolveSpaceUI::GenerateAll (Generate type, bool andFindFree, bool genForBBox) {
@@ -215,8 +222,7 @@ void SolveSpaceUI::GenerateAll(Generate type, bool andFindFree, bool genForBBox)
215
222
// Remove any requests or constraints that refer to a nonexistent
216
223
// group; can check those immediately, since we know what the list
217
224
// of groups should be.
218
- while (PruneOrphans ())
219
- ;
225
+ PruneOrphans ();
220
226
221
227
// Don't lose our numerical guesses when we regenerate.
222
228
IdList<Param,hParam> prev = {};
@@ -254,7 +260,7 @@ void SolveSpaceUI::GenerateAll(Generate type, bool andFindFree, bool genForBBox)
254
260
255
261
// The requests and constraints depend on stuff in this or the
256
262
// previous group, so check them after generating.
257
- if (PruneRequests (hg) || PruneConstraints (hg))
263
+ if (PruneRequestsAndConstraints (hg))
258
264
goto pruned;
259
265
260
266
// Use the previous values for params that we've seen before, as
0 commit comments