15 if(std::abs(v1.
x() - v2.
x()) < tol &&
16 std::abs(v1.
y() - v2.
y()) < tol &&
17 std::abs(v1.
z() - v2.
z()) < tol)
return true;
22 const std::pair<SVector3, int> &b)
24 return (a.second > b.second);
33 const std::vector<int> &numElements,
34 const std::vector<double> &heights,
40 if(numElements.size()) {
61 for(
int i = 0; i < 3; i++) {
79 Msg::Info(
"Volume %d reverse-engineered as extruded from surface %d "
80 "to surface %d along (%g, %g, %g)",
_region->
tag(),
86 const std::vector<double> &heights,
91 std::set<GEdge *, GEntityPtrLessThan> sourceEdges(se.begin(), se.end());
93 std::set<GEdge *, GEntityPtrLessThan> targetEdges(te.begin(), te.end());
101 Msg::Warning(
"Incompatible extrusion parameters on volume %d",
119 Msg::Warning(
"Incompatible extrusion parameters on surface %d",
135 std::set<GFace *, GEntityPtrLessThan> edgeFaces(
f.begin(),
f.end());
136 for(
auto f : regionFaces) {
138 if(edgeFaces.find(
f) != edgeFaces.end()) {
142 if(
f->meshAttributes.extrude) {
144 Msg::Warning(
"Incompatible extrusion parameters on surface %d",
153 f->meshAttributes.extrude = ep;
155 for(
auto fe :
f->edges()) {
156 if(targetEdges.find(fe) != targetEdges.end()) {
159 if(fe->meshAttributes.extrude) {
161 Msg::Warning(
"Incompatible extrusion parameters on curve %d",
170 fe->meshAttributes.extrude = ep;
180 auto ve = v->edges();
181 std::set<GEdge*, GEntityPtrLessThan> vertexEdges(ve.begin(), ve.end());
182 for(
auto e : regionEdges) {
183 if(sourceEdges.find(e) != sourceEdges.end())
continue;
184 if(targetEdges.find(e) != targetEdges.end())
continue;
185 if(vertexEdges.find(e) != vertexEdges.end()) {
188 if(e->meshAttributes.extrude) {
190 Msg::Warning(
"Incompatible extrusion parameters on curve %d",
199 e->meshAttributes.extrude = ep;
209 std::vector<std::pair<SVector3, int>> &count)
211 std::vector<GFace*>
f = gr->
faces();
213 auto f1v = f1->vertices();
214 auto f1e = f1->edges();
215 std::set<GVertex *, GEntityPtrLessThan> v1(f1v.begin(), f1v.end());
216 std::set<GEdge *, GEntityPtrLessThan> e1(f1e.begin(), f1e.end());
219 if(f1 == f2)
continue;
221 Msg::Debug(
"Testing surface pair %d - %d:", f1->tag(), f2->tag());
222 auto f2v = f2->vertices();
223 auto f2e = f2->edges();
224 std::set<GVertex *, GEntityPtrLessThan> v2(f2v.begin(), f2v.end());
225 std::set<GEdge *, GEntityPtrLessThan> e2(f2e.begin(), f2e.end());
227 if((v1.size() != v2.size()) || (e1.size() != e2.size())) {
228 Msg::Debug(
" - incompatible surfaces %d (#points=%lu, #curves=%lu) - "
229 "%d (#points=%lu, #curves=%lu)",
230 f1->tag(), v1.size(), e1.size(),
231 f2->tag(), v2.size(), e2.size());
236 bool translated =
true;
238 std::set<GEdge*> perp;
239 for(
auto e : gr->
edges()) {
241 if(e1.find(e) != e1.end() || e2.find(e) != e2.end()) {
244 if((v1.find(e->getBeginVertex()) != v1.end() ||
245 v1.find(e->getEndVertex()) != v1.end()) &&
246 (v2.find(e->getBeginVertex()) != v2.end() ||
247 v2.find(e->getEndVertex()) != v2.end())) {
252 if(perp.size() != v1.size()) {
253 Msg::Debug(
" - number of extruded curves differs from number of "
254 "source/target surface points (%lu != %lu)",
255 perp.size(), v1.size());
259 if(perp.size() + e1.size() + e2.size() != gr->
edges().size()) {
260 Msg::Debug(
" - extra curves not connected to source/target surfaces");
267 GVertex *vs = e->getBeginVertex(), *vt = e->getEndVertex();
270 if(v1.find(vs) != v1.end() && v2.find(vt) != v2.end()) {
273 else if(v1.find(vt) != v1.end() && v2.find(vs) != v2.end()) {
281 if(t0.
norm() == 0.) t0 = t;
283 Msg::Debug(
" - straight line t=(%g, %g, %g) != t0=(%g, %g, %g)",
284 t.
x(), t.
y(), t.
z(), t0.
x(), t0.
y(), t0.
z());
297 if(translated && t0.
norm() != 0.) {
300 if(v2.find(v) != v2.end())
continue;
303 Msg::Debug(
"Volume %d possible extrusion candidate from surface %d to "
304 "surface %d along (%g, %g, %g)", gr->
tag(), f1->tag(), f2->tag(),
305 t0.
x(), t0.
y(), t0.
z());
309 for(std::size_t i = 0; i < count.size(); i++) {
310 if(
sameDir(count[i].first, t0)) {
316 if(!found) count.push_back(std::make_pair(t0, 1));
323 const std::vector<double> &heights,
324 const bool recombine,
325 const std::vector<int> ®ionTags)
327 std::vector<GRegion *> regs;
328 if(regionTags.empty()) {
332 for(
auto t : regionTags) {
334 if(r) regs.push_back(r);
335 else Msg::Error(
"Unknown volume %d for automatic extrusion constraints");
340 std::vector<extrudeInfo> candidates;
341 std::vector<std::pair<SVector3, int>> dirCount;
344 if(candidates.empty()) {
345 Msg::Info(
"No candidates found for automatic extrusion constraints");
350 std::sort(dirCount.begin(), dirCount.end(),
sortDirCount);
353 std::vector<extrudeInfo> matches;
354 for(
auto c : candidates) {
355 if(
sameDir(
c.getDirection(), dirCount.front().first)) matches.push_back(
c);
359 for(
auto m : matches) {
360 if(m.fillExtrudeParams(numElements, heights, recombine,
true)) {
361 m.fillExtrudeParams(numElements, heights, recombine,
false);