gmsh-TingyuanDoc  0.1
An Open-Source Timing-driven Analytical Mixed-size FPGA Placer
GEdge.cpp
Go to the documentation of this file.
1 // Gmsh - Copyright (C) 1997-2022 C. Geuzaine, J.-F. Remacle
2 //
3 // See the LICENSE.txt file in the Gmsh root directory for license information.
4 // Please report all issues on https://gitlab.onelab.info/gmsh/gmsh/issues.
5 
6 #include <sstream>
7 #include <algorithm>
8 #include <numeric>
9 #include "GmshConfig.h"
10 #include "GmshDefines.h"
11 #include "GmshMessage.h"
12 #include "GModel.h"
13 #include "GEdge.h"
14 #include "GFace.h"
15 #include "MLine.h"
16 #include "GaussLegendre1D.h"
17 #include "Context.h"
18 #include "closestPoint.h"
19 #include "discreteEdge.h"
20 #include "ExtrudeParams.h"
21 
22 #if defined(HAVE_MESH)
23 #include "meshGEdge.h"
24 #endif
25 
26 GEdge::GEdge(GModel *model, int tag, GVertex *v0, GVertex *v1)
27  : GEntity(model, tag), _length(0.), _tooSmall(false), _cp(nullptr), _v0(v0),
28  _v1(v1), masterOrientation(0), compoundCurve(nullptr)
29 {
30  if(_v0) _v0->addEdge(this);
31  if(_v1 && _v1 != _v0) _v1->addEdge(this);
34 }
35 
36 GEdge::GEdge(GModel *model, int tag)
37  : GEntity(model, tag), _length(0.), _tooSmall(false), _cp(nullptr),
38  _v0(nullptr), _v1(nullptr), masterOrientation(0), compoundCurve(nullptr)
39 {
42 }
43 
45 {
46  if(_v0) _v0->delEdge(this);
47  if(_v1 && _v1 != _v0) _v1->delEdge(this);
48 
49  if(_cp) delete _cp;
51 }
52 
54 {
55  for(std::size_t i = 0; i < mesh_vertices.size(); i++) delete mesh_vertices[i];
56  mesh_vertices.clear();
57  for(std::size_t i = 0; i < lines.size(); i++) delete lines[i];
58  lines.clear();
59  correspondingVertices.clear();
63 }
64 
65 void GEdge::setMeshMaster(GEdge *ge, int ori)
66 {
67  // FIXME: missing computation of affine transformation during setMeshMaster
69  masterOrientation = ori > 0 ? 1 : -1;
70 
71  if(!getBeginVertex() || !ge->getBeginVertex() || !getEndVertex() ||
72  !ge->getEndVertex())
73  return;
74 
75  if(ori < 0) {
80  }
81  else {
86  }
87 }
88 
89 void GEdge::setMeshMaster(GEdge *ge, const std::vector<double> &tfo)
90 {
91  if(!getBeginVertex() || !ge->getBeginVertex() || !getEndVertex() ||
92  !ge->getEndVertex())
93  return;
94 
95  SPoint3 oriXYZ0 = ge->getBeginVertex()->xyz();
96  SPoint3 oriXYZ1 = ge->getEndVertex()->xyz();
97  oriXYZ0.transform(tfo);
98  oriXYZ1.transform(tfo);
99 
100  SPoint3 locXYZ0 = getBeginVertex()->xyz();
101  SPoint3 locXYZ1 = getEndVertex()->xyz();
102 
103  SVector3 d00 = locXYZ0 - oriXYZ0;
104  SVector3 d10 = locXYZ1 - oriXYZ0;
105  SVector3 d01 = locXYZ0 - oriXYZ1;
106  SVector3 d11 = locXYZ1 - oriXYZ1;
107 
108  double tol = CTX::instance()->geom.tolerance * CTX::instance()->lc;
109 
110  bool fwd = (d00.norm() * d11.norm() < d01.norm() * d10.norm());
111 
112  if((d00.norm() < tol) && (d11.norm() < tol)) {
113  GEntity::setMeshMaster(ge, tfo);
114  masterOrientation = 1;
118  getEndVertex()->setMeshMaster(ge->getEndVertex(), tfo);
119  return;
120  }
121 
122  if((d01.norm() < tol) && (d10.norm() < tol)) {
123  GEntity::setMeshMaster(ge, tfo);
124  masterOrientation = -1;
129  return;
130  }
131 
132  Msg::Info("Error in transformation from curve %d (%d-%d) to %d (%d-%d) "
133  "(minimal transformed node distances %g %g, tolerance %g)",
134  ge->tag(), ge->getBeginVertex()->tag(), ge->getEndVertex()->tag(),
135  this->tag(), this->getBeginVertex()->tag(),
136  this->getEndVertex()->tag(), fwd ? d00.norm() : d01.norm(),
137  fwd ? d11.norm() : d10.norm(), tol);
138 }
139 
141 {
142  GVertex *tmp = _v0;
143  _v0 = _v1;
144  _v1 = tmp;
145  for(auto l : lines) l->reverse();
146 }
147 
148 std::size_t GEdge::getNumMeshElementsByType(const int familyType) const
149 {
150  if(familyType == TYPE_LIN) return lines.size();
151 
152  return 0;
153 }
154 
156 {
157  return std::count_if(lines.begin(), lines.end(), [](const MLine *const line) {
158  return line->ownsParent();
159  });
160 }
161 
162 void GEdge::getNumMeshElements(unsigned *const c) const
163 {
164  c[0] += lines.size();
165 }
166 
167 MElement *const *GEdge::getStartElementType(int type) const
168 {
169  if(lines.empty()) return nullptr; // msvc would throw an exception
170  return reinterpret_cast<MElement *const *>(&lines[0]);
171 }
172 
173 MElement *GEdge::getMeshElement(std::size_t index) const
174 {
175  if(index < lines.size()) return lines[index];
176  return nullptr;
177 }
178 
179 MElement *GEdge::getMeshElementByType(const int familyType,
180  const std::size_t index) const
181 {
182  if(familyType == TYPE_LIN) return lines[index];
183 
184  return nullptr;
185 }
186 
188 {
190  meshAttributes.coeffTransfinite = 0.;
191  meshAttributes.nbPointsTransfinite = 0;
192  meshAttributes.typeTransfinite = 0;
193  meshAttributes.extrude = nullptr;
194  meshAttributes.meshSize = MAX_LC;
195  meshAttributes.meshSizeFactor = 1.;
196  meshAttributes.minimumMeshSegments = 1;
197  meshAttributes.reverseMesh = false;
198 }
199 
201 {
202  if(std::find(_faces.begin(), _faces.end(), f) == _faces.end())
203  _faces.push_back(f);
204 }
205 
207 {
208  auto it = std::find(_faces.begin(), _faces.end(), f);
209  if(it != _faces.end()) _faces.erase(it);
210 }
211 
213 {
214  SBoundingBox3d bbox;
216  geomType() != PartitionCurve) {
217  Range<double> tr = parBounds(0);
218  const int N = fast ? 3 : 10;
219  for(int i = 0; i < N; i++) {
220  double t =
221  tr.low() + (double)i / (double)(N - 1) * (tr.high() - tr.low());
222  GPoint p = point(t);
223  bbox += SPoint3(p.x(), p.y(), p.z());
224  }
225  }
226  else {
227  for(std::size_t i = 0; i < getNumMeshElements(); i++)
228  for(std::size_t j = 0; j < getMeshElement(i)->getNumVertices(); j++)
229  bbox += getMeshElement(i)->getVertex(j)->point();
230  }
231  return bbox;
232 }
233 
235 {
236  if(!_obb) {
237  std::vector<SPoint3> vertices;
238  if(getNumMeshVertices() > 0) {
239  int N = getNumMeshVertices();
240  for(int i = 0; i < N; i++) {
241  MVertex *mv = getMeshVertex(i);
242  vertices.push_back(mv->point());
243  }
244  // Don't forget to add the first and last vertices...
245  if(getBeginVertex()) {
246  SPoint3 pt1(getBeginVertex()->x(), getBeginVertex()->y(),
247  getBeginVertex()->z());
248  vertices.push_back(pt1);
249  }
250  if(getEndVertex()) {
251  SPoint3 pt2(getEndVertex()->x(), getEndVertex()->y(),
252  getEndVertex()->z());
253  vertices.push_back(pt2);
254  }
255  }
256  else if(geomType() != DiscreteCurve && geomType() != BoundaryLayerCurve) {
257  Range<double> tr = this->parBounds(0);
258  // N can be choosen arbitrarily, but 10 points seems reasonable
259  int N = 10;
260  for(int i = 0; i < N; i++) {
261  double t =
262  tr.low() + (double)i / (double)(N - 1) * (tr.high() - tr.low());
263  GPoint p = point(t);
264  SPoint3 pt(p.x(), p.y(), p.z());
265  vertices.push_back(pt);
266  }
267  }
268  else {
269  SPoint3 dummy(0, 0, 0);
270  vertices.push_back(dummy);
271  }
273  }
274  return SOrientedBoundingBox(_obb);
275 }
276 
277 void GEdge::setVisibility(char val, bool recursive)
278 {
280  if(recursive) {
281  if(_v0) _v0->setVisibility(val);
282  if(_v1) _v1->setVisibility(val);
283  }
284 }
285 
286 void GEdge::setColor(unsigned int val, bool recursive)
287 {
288  GEntity::setColor(val);
289  if(recursive) {
290  if(_v0) _v0->setColor(val);
291  if(_v1) _v1->setColor(val);
292  }
293 }
294 
295 std::string GEdge::getAdditionalInfoString(bool multline)
296 {
297  std::ostringstream sstream;
298  sstream.precision(12);
299 
300  if(_v0 && _v1) {
301  sstream << "Boundary points: " << _v0->tag() << ", " << _v1->tag();
302  GPoint p0 = _v0->point();
303  GPoint p1 = _v1->point();
304  sstream << " (distance = " << p0.distance(p1) << ")";
305  if(multline)
306  sstream << "\n";
307  else
308  sstream << " ";
309  }
310 
311  if(_faces.size()) {
312  sstream << "On boundary of surfaces: ";
313  for(auto it = _faces.begin(); it != _faces.end(); ++it) {
314  if(it != _faces.begin()) sstream << ", ";
315  sstream << (*it)->tag();
316  }
317  if(multline)
318  sstream << "\n";
319  else
320  sstream << " ";
321  }
322 
323  if(meshAttributes.method == MESH_TRANSFINITE ||
324  (meshAttributes.extrude && meshAttributes.extrude->mesh.ExtrudeMesh) ||
325  meshAttributes.reverseMesh ||
326  (getMeshMaster() && getMeshMaster() != this)) {
327  sstream << "Mesh attributes:";
328  if(meshAttributes.method == MESH_TRANSFINITE) {
329  sstream << " transfinite " << meshAttributes.nbPointsTransfinite;
330  int type = meshAttributes.typeTransfinite;
331  if(std::abs(type) == 1)
332  sstream << ", progression "
333  << gmsh_sign(type) * meshAttributes.coeffTransfinite;
334  else if(std::abs(type) == 2)
335  sstream << ", bump " << meshAttributes.coeffTransfinite;
336  else if(std::abs(type) == 3)
337  sstream << ", beta " << meshAttributes.coeffTransfinite;
338  else if(std::abs(type) == 4)
339  sstream << ", sizemap " << meshAttributes.coeffTransfinite;
340  }
341  if(meshAttributes.extrude && meshAttributes.extrude->mesh.ExtrudeMesh)
342  sstream << " extruded";
343  if(meshAttributes.reverseMesh) sstream << " reversed";
344  if(getMeshMaster() && getMeshMaster() != this)
345  sstream << " periodic copy of curve " << getMeshMaster()->tag();
346  }
347 
348  std::string str = sstream.str();
349  if(str.size() && (str[str.size() - 1] == '\n' || str[str.size() - 1] == ' '))
350  str.resize(str.size() - 1);
351  return str;
352 }
353 
354 void GEdge::writeGEO(FILE *fp)
355 {
356  if(!getBeginVertex() || !getEndVertex() || geomType() == DiscreteCurve ||
358  return;
359 
360  if(geomType() == Line) {
361  fprintf(fp, "Line(%d) = {%d, %d};\n", tag(), getBeginVertex()->tag(),
362  getEndVertex()->tag());
363  }
364  else {
365  // approximate other curves by splines
367  double umin = bounds.low();
368  double umax = bounds.high();
369  fprintf(fp, "p%d = newp;\n", tag());
370  int N = minimumDrawSegments();
371  for(int i = 1; i < N; i++) {
372  double u = umin + (double)i / N * (umax - umin);
373  GPoint p = point(u);
374  fprintf(fp, "Point(p%d + %d) = {%.16g, %.16g, %.16g};\n", tag(), i, p.x(),
375  p.y(), p.z());
376  }
377  fprintf(fp, "Spline(%d) = {%d", tag(), getBeginVertex()->tag());
378  for(int i = 1; i < N; i++) fprintf(fp, ", p%d + %d", tag(), i);
379  fprintf(fp, ", %d};\n", getEndVertex()->tag());
380  }
381 
382  if(meshAttributes.method == MESH_TRANSFINITE) {
383  fprintf(fp, "Transfinite Line {%d} = %d",
384  tag() * (meshAttributes.typeTransfinite > 0 ? 1 : -1),
385  meshAttributes.nbPointsTransfinite);
386  if(meshAttributes.typeTransfinite) {
387  if(std::abs(meshAttributes.typeTransfinite) == 1)
388  fprintf(fp, " Using Progression ");
389  else if(std::abs(meshAttributes.typeTransfinite) == 2)
390  fprintf(fp, " Using Bump ");
391  else if(std::abs(meshAttributes.typeTransfinite) == 3)
392  fprintf(fp, " Using Beta ");
393  else if(std::abs(meshAttributes.typeTransfinite) == 4)
394  fprintf(fp, " Using Sizemap ");
395  else
396  fprintf(fp, " Using Unknown ");
397  fprintf(fp, "%g", meshAttributes.coeffTransfinite);
398  }
399  fprintf(fp, ";\n");
400  }
401 
402  if(meshAttributes.reverseMesh) fprintf(fp, "Reverse Line {%d};\n", tag());
403 }
404 
405 void GEdge::writePY(FILE *fp)
406 {
407  // This is by no means complete - merely a placeholder for a future
408  // implementation
409 
410  if(!getBeginVertex() || !getEndVertex() || geomType() == DiscreteCurve ||
412  return;
413 
414  const char *factory = getNativeType() == OpenCascadeModel ? "occ" : "geo";
415 
416  if(geomType() == Line) {
417  fprintf(fp, "gmsh.model.%s.addLine(%d, %d, %d)\n", factory,
418  getBeginVertex()->tag(), getEndVertex()->tag(), tag());
419  }
420  else {
421  // TODO
422  }
423 }
424 
426 {
427  // as the STL might be non-conforming, we make no effort to have a conformal
428  // mesh - nodes will not be classified on boundaries, and not shared with
429  // adjacent entities
430  if(stl_vertices_xyz.size()) {
431  for(std::size_t i = 0; i < stl_vertices_xyz.size(); i++) {
432  SPoint3 &p(stl_vertices_xyz[i]);
433  mesh_vertices.push_back(new MVertex(p.x(), p.y(), p.z(), this));
434  }
435  }
436  else {
437  return false;
438  }
439  for(std::size_t i = 0; i < mesh_vertices.size() - 1; i++) {
440  lines.push_back(new MLine(mesh_vertices[i], mesh_vertices[i + 1]));
441  }
442  return true;
443 }
444 
445 bool GEdge::containsPoint(const SPoint3 &pt) const
446 {
447  if(geomType() == BoundaryLayerCurve) return false;
448  double t;
449  if(!XYZToU(pt.x(), pt.y(), pt.z(), t, 1, false)) return false;
450  return containsParam(t);
451 }
452 
453 bool GEdge::containsParam(double pt) const
454 {
455  if(geomType() == BoundaryLayerCurve) return false;
456  Range<double> rg = parBounds(0);
457  return (pt >= rg.low() && pt <= rg.high());
458 }
459 
460 SVector3 GEdge::secondDer(double par) const
461 {
462  if(geomType() == BoundaryLayerCurve) return SVector3();
463 
464  // use central differences
465  const double eps = 1.e-3;
466  Range<double> rg = parBounds(0);
467  if(par - eps <= rg.low()) {
468  SVector3 x1 = firstDer(par);
469  SVector3 x2 = firstDer(par + eps);
470  return 1000 * (x2 - x1);
471  }
472  else if(par + eps >= rg.high()) {
473  SVector3 x1 = firstDer(par - eps);
474  SVector3 x2 = firstDer(par);
475  return 1000 * (x2 - x1);
476  }
477  SVector3 x1 = firstDer(par - eps);
478  SVector3 x2 = firstDer(par + eps);
479  return 500 * (x2 - x1);
480 }
481 
482 SPoint2 GEdge::reparamOnFace(const GFace *face, double epar, int dir) const
483 {
484  if(geomType() == BoundaryLayerCurve) return SPoint2();
485 
486  // reparametrize the point onto the given face.
487  const GPoint p3 = point(epar);
488  SPoint3 sp3(p3.x(), p3.y(), p3.z());
489  return face->parFromPoint(sp3);
490 }
491 
492 double GEdge::curvature(double par) const
493 {
494  if(geomType() == Line || geomType() == BoundaryLayerCurve) return 0.;
495 
496  SVector3 const d1 = firstDer(par);
497  return norm(crossprod(d1, secondDer(par))) * std::pow(1.0 / norm(d1), 3);
498 }
499 
500 double GEdge::length(const double &u0, const double &u1, const int nbQuadPoints)
501 {
502  if(geomType() == BoundaryLayerCurve) return 0.;
503 
504  double *t = nullptr, *w = nullptr;
505  gmshGaussLegendre1D(nbQuadPoints, &t, &w);
506  if(!t) {
507  Msg::Error("Gauss-Legendre integration returned no points");
508  return 0;
509  }
510  double L = 0.0;
511  const double rapJ = (u1 - u0) * 0.5;
512  for(int i = 0; i < nbQuadPoints; i++) {
513  const double ui = u0 * 0.5 * (1. - t[i]) + u1 * 0.5 * (1. + t[i]);
514  SVector3 der = firstDer(ui);
515  const double d = norm(der);
516  L += d * w[i] * rapJ;
517  }
518  return L;
519 }
520 
521 /*
522  consider a curve x(t) and a point y
523  use a golden section algorithm that minimizes
524  min_t \|x(t)-y\|
525 */
526 const double GOLDEN = (1.0 + std::sqrt(5.0)) / 2.0;
527 const double GOLDEN2 = 2.0 - GOLDEN;
528 
529 // x1 and x3 are the current bounds; the minimum is between them.
530 // x2 is the center point, which is closer to x1 than to x3
531 
532 double goldenSectionSearch(const GEdge *ge, const SPoint3 &q, double x1,
533  double x2, double x3, double tau)
534 {
535  // Create a new possible center in the area between x2 and x3, closer to x2
536  double x4 = x2 + GOLDEN2 * (x3 - x2);
537 
538  // Evaluate termination criterion
539  if(std::abs(x3 - x1) < tau * (std::abs(x2) + std::abs(x4)))
540  return (x3 + x1) / 2;
541 
542  const SVector3 dp4 = q - ge->position(x4);
543  const SVector3 dp2 = q - ge->position(x2);
544 
545  const double d4 = dp4.norm();
546  const double d2 = dp2.norm();
547 
548  return d4 < d2 ? goldenSectionSearch(ge, q, x2, x4, x3, tau) :
549  goldenSectionSearch(ge, q, x4, x2, x1, tau);
550 }
551 
552 GPoint GEdge::closestPoint(const SPoint3 &q, double &t) const
553 {
554  if(geomType() == BoundaryLayerCurve) return GPoint();
555 
556  // printf("looking for closest point in curve %d to point %g
557  // %g\n",tag(),q.x(),q.y());
558 
559  const int nbSamples = 100;
560 
561  Range<double> interval = parBounds(0);
562 
563  double tMin = std::min(interval.high(), interval.low());
564  double tMax = std::max(interval.high(), interval.low());
565 
566  double DMIN = 1.e22;
567  double topt = tMin;
568  const double DT = (tMax - tMin) / (nbSamples - 1.);
569  for(int i = 0; i < nbSamples; i++) {
570  t = tMin + i * DT;
571  const SVector3 dp = q - position(t);
572  const double D = dp.norm();
573  if(D < DMIN) {
574  topt = t;
575  DMIN = D;
576  }
577  }
578 
579  // printf("parameter %g as an initial guess (dist = %g)\n",topt,DMIN);
580 
581  if(topt == tMin)
582  t = goldenSectionSearch(this, q, topt, topt + DT / 2, topt + DT, 1.e-9);
583  else if(topt == tMax)
584  t = goldenSectionSearch(this, q, topt - DT, topt - DT / 2, topt, 1.e-9);
585  else
586  t = goldenSectionSearch(this, q, topt - DT, topt, topt + DT, 1.e-9);
587 
588  const SVector3 dp = q - position(t);
589  // const double D = dp.norm();
590  // printf("after golden section parameter %g (dist = %g)\n",t,D);
591 
592  return point(t);
593 }
594 
595 double GEdge::parFromPoint(const SPoint3 &P) const
596 {
597  if(geomType() == BoundaryLayerCurve) return 0.;
598 
599  double t;
600  XYZToU(P.x(), P.y(), P.z(), t);
601  return t;
602 }
603 
604 bool GEdge::refineProjection(const SVector3 &Q, double &u, int MaxIter,
605  double relax, double tol, double &err) const
606 {
607  if(geomType() == BoundaryLayerCurve) return false;
608 
609  double maxDist = tol * CTX::instance()->lc;
610 
611  SVector3 P = position(u);
612  SVector3 dPQ = P - Q;
613 
614  Range<double> uu = parBounds(0);
615  double uMin = uu.low();
616  double uMax = uu.high();
617  err = dPQ.norm();
618 
619  int iter = 0;
620  while(iter++ < MaxIter && err > maxDist) {
621  SVector3 der = firstDer(u);
622  double du = dot(dPQ, der) / dot(der, der);
623 
624  if(du < tol && dPQ.norm() > maxDist) du = 1;
625 
626  // if (fabs(du) < tol) break;
627 
628  double uNew = u - relax * du;
629  uNew = std::min(uMax, std::max(uMin, uNew));
630  P = position(uNew);
631 
632  dPQ = P - Q;
633  err = dPQ.norm();
634  // err2 = fabs(uNew - u);
635  u = uNew;
636  }
637  return err <= maxDist;
638 }
639 
640 bool GEdge::XYZToU(const double X, const double Y, const double Z, double &u,
641  const double relax, bool first) const
642 {
643  if(geomType() == BoundaryLayerCurve) return false;
644 
645  const int MaxIter = 25;
646  const int NumInitGuess = 21;
647 
648  std::map<double, double> errorVsParameter;
649 
650  double err;
651  double tol = 1e-8;
652 
653  Range<double> uu = parBounds(0);
654  double uMin = uu.low();
655  double uMax = uu.high();
656 
657  const SVector3 Q(X, Y, Z);
658 
659  double uTry = uMin;
660 
661  for(int i = 0; i < NumInitGuess; i++) {
662  uTry = uMin + (uMax - uMin) / (NumInitGuess - 1) * i;
663  if(refineProjection(Q, uTry, MaxIter, relax, tol, err)) {
664  u = uTry;
665  return true;
666  }
667  errorVsParameter[err] = uTry;
668  }
669 
670  if(relax > 1.e-1) {
671  if(XYZToU(X, Y, Z, uTry, 0.75 * relax, false)) {
672  u = uTry;
673  return true;
674  }
675  SVector3 P = position(uTry);
676  SVector3 dPQ = P - Q;
677  errorVsParameter[dPQ.norm()] = uTry;
678  }
679 
680  u = errorVsParameter.begin()->second;
681  if(first) {
682  Msg::Warning(
683  "Could not converge parametrisation of (%g,%g,%g) on curve %d, "
684  "taking parameter with lowest error",
685  X, Y, Z, tag());
686  }
687 
688  return false;
689 }
690 
691 // regions that bound this entity or that this entity bounds.
692 std::list<GRegion *> GEdge::regions() const
693 {
694  std::vector<GFace *> _faces = faces();
695  std::set<GRegion *> _r;
696  for(auto it = _faces.begin(); it != _faces.end(); ++it) {
697  std::list<GRegion *> temp = (*it)->regions();
698  _r.insert(temp.begin(), temp.end());
699  }
700  std::list<GRegion *> ret;
701  ret.insert(ret.begin(), _r.begin(), _r.end());
702  return ret;
703 }
704 
706 {
707  if(model()->getNumRegions())
708  return regions().empty();
709  else if(model()->getNumFaces())
710  return faces().empty();
711  return false;
712 }
713 
715 {
716  for(std::size_t i = 0; i < mesh_vertices.size(); i++) {
717  MVertex *v = mesh_vertices[i];
718  double u0 = 0;
719  if(v->getParameter(0, u0)) {
720  GPoint p = point(u0);
721  v->x() = p.x();
722  v->y() = p.y();
723  v->z() = p.z();
724  }
725  }
726 }
727 
729 {
730  if(!_cp || _cp->tol() != tolerance) {
731  if(_cp) delete _cp;
732  _cp = new closestPointFinder(this, tolerance);
733  }
734  return (*_cp)(p);
735 }
736 
737 typedef struct {
739  double t;
740  int next;
741 } sortedPoint;
742 
743 static double sqDistPointSegment(const SPoint3 &p, const SPoint3 &s0,
744  const SPoint3 &s1)
745 {
746  SVector3 d(s1 - s0);
747  SVector3 d0(p - s0);
748  SVector3 d1(p - s1);
749  double dn2 = crossprod(d, d0).normSq();
750  double dt2 = std::max(0., std::max(-dot(d, d0), dot(d, d1)));
751  dt2 *= dt2;
752  return (dt2 + dn2) / d.normSq();
753 }
754 
755 static void _discretize(double tol, GEdge *edge, std::vector<sortedPoint> &upts,
756  int pos0)
757 {
758  const int pos1 = upts[pos0].next;
759  const SPoint3 &p0 = upts[pos0].p;
760  const double t0 = upts[pos0].t;
761  const SPoint3 &p1 = upts[pos1].p;
762  const double t1 = upts[pos1].t;
763  const double tmid = 0.5 * (t0 + t1);
764  const SPoint3 pmid(edge->position(tmid));
765  const double d2 = sqDistPointSegment(pmid, p0, p1);
766  if(d2 < tol * tol) return;
767  sortedPoint pnt = {pmid, tmid, pos1};
768  upts.push_back(pnt);
769  const int posmid = upts.size() - 1;
770  upts[pos0].next = posmid;
771  _discretize(tol, edge, upts, pos0);
772  _discretize(tol, edge, upts, posmid);
773 }
774 
775 void GEdge::addElement(int type, MElement *e)
776 {
777  switch(type) {
778  case TYPE_LIN: addLine(reinterpret_cast<MLine *>(e)); break;
779  default:
780  Msg::Error("Trying to add unsupported element in curve %d", tag());
781  }
782 }
783 
784 void GEdge::removeElement(int type, MElement *e)
785 {
786  switch(type) {
787  case TYPE_LIN: {
788  auto it =
789  std::find(lines.begin(), lines.end(), reinterpret_cast<MLine *>(e));
790  if(it != lines.end()) lines.erase(it);
791  } break;
792  default:
793  Msg::Error("Trying to remove unsupported element in curve %d", tag());
794  }
795 }
796 
797 void GEdge::removeElements(int type)
798 {
799  switch(type) {
800  case TYPE_LIN: lines.clear(); break;
801  default:
802  Msg::Error("Trying to remove unsupported elements in curve %d", tag());
803  }
804 }
805 
806 void GEdge::discretize(double tol, std::vector<SPoint3> &dpts,
807  std::vector<double> &ts)
808 {
809  std::vector<sortedPoint> upts;
810  if(getBeginVertex()) {
811  sortedPoint pnt1 = {getBeginVertex()->xyz(), 0., 1};
812  upts.push_back(pnt1);
813  }
814  if(getEndVertex()) {
815  sortedPoint pnt2 = {getEndVertex()->xyz(), 1., -1};
816  upts.push_back(pnt2);
817  }
818  _discretize(tol, this, upts, 0);
819  dpts.clear();
820  dpts.reserve(upts.size());
821  ts.clear();
822  ts.reserve(upts.size());
823  for(int p = 0; p != -1; p = upts[p].next) {
824  dpts.push_back(upts[p].p);
825  ts.push_back(upts[p].t);
826  }
827 }
828 
829 #if defined(HAVE_MESH)
830 
831 static bool recreateConsecutiveElements(GEdge *ge)
832 {
833  std::size_t ss = ge->lines.size();
834  if(!ss) return true;
835 
836  std::vector<MEdge> ed;
837  std::vector<std::vector<MVertex *> > vs;
838  for(std::size_t i = 0; i < ge->lines.size(); i++) {
839  ed.push_back(MEdge(ge->lines[i]->getVertex(0), ge->lines[i]->getVertex(1)));
840  }
841  ge->lines.clear();
842 
843  if(!SortEdgeConsecutive(ed, vs))
844  Msg::Warning("Line elements on curve %d cannot be ordered", ge->tag());
845 
846  if(vs.size() != 1)
847  Msg::Warning("Mesh of curve %d is mutiply connected", ge->tag());
848 
849  std::size_t start = 0;
850  for(; start < vs[0].size(); start++)
851  if(vs[0][start]->onWhat()->dim() == 0) break;
852 
853  if(start == vs[0].size())
854  Msg::Warning("Mesh topology of curve %d is wrong", ge->tag());
855 
856  std::size_t i = start;
857  while(ge->lines.size() != ss) {
858  if(vs[0][i % vs[0].size()] != vs[0][(i + 1) % vs[0].size()])
859  ge->lines.push_back(
860  new MLine(vs[0][i % vs[0].size()], vs[0][(i + 1) % vs[0].size()]));
861  i++;
862  }
863 
864  ge->mesh_vertices.clear();
865  for(std::size_t i = 0; i < ge->lines.size() - 1; ++i) {
866  MVertex *v11 = ge->lines[i]->getVertex(1);
867  if(v11->onWhat() == ge || !v11->onWhat()) {
868  v11->setEntity(ge);
869  ge->mesh_vertices.push_back(v11);
870  }
871  }
872 
873  return true;
874 }
875 
876 static void meshCompound(GEdge *ge)
877 {
878  discreteEdge *de = dynamic_cast<discreteEdge*>
879  (ge->model()->getEdgeByTag(ge->tag() + 100000));
880  if(de) {
881  de->deleteMesh();
882  }
883  else {
884  de = new discreteEdge(ge->model(), ge->tag() + 100000);
885  ge->model()->add(de);
886  }
887 
888  if(CTX::instance()->geom.copyMeshingMethod) {
893  }
894 
895  std::vector<int> phys;
896  for(std::size_t i = 0; i < ge->compound.size(); i++) {
897  auto *c = (GEdge *)ge->compound[i];
898  de->lines.insert(de->lines.end(), c->lines.begin(), c->lines.end());
899  c->compoundCurve = de;
900  phys.insert(phys.end(), c->physicals.begin(), c->physicals.end());
901  c->physicals.clear();
902  }
903 
904  // recreate a 1D mesh with consecutive elements (this creates new MLines)
905  recreateConsecutiveElements(de);
906  // create the geometry
907  de->createGeometry();
908  // delete the MLines just created above
909  for(std::size_t i = 0; i < de->lines.size(); i++) delete de->lines[i];
910  de->lines.clear();
911  de->mesh_vertices.clear();
912  de->mesh(false);
913  de->physicals = phys;
914 }
915 
916 #endif
917 
918 void GEdge::mesh(bool verbose)
919 {
920 #if defined(HAVE_MESH)
921  if(compound.size())
923 
924  meshGEdge mesher;
925  mesher(this);
926 
927  if(compound.size()) { // Some edges are meshed together
928  meshAttributes.meshSizeFactor = 1.0;
929 
930  if(compound[0] == this) { // I'm the one that makes the compound job
931  bool ok = true;
932  for(std::size_t i = 0; i < compound.size(); i++) {
933  auto *ge = (GEdge *)compound[i];
934  ok &= (ge->meshStatistics.status == GEdge::DONE);
935  }
936  if(!ok) { meshStatistics.status = GEdge::PENDING; }
937  else {
938  meshCompound(this);
939  meshStatistics.status = GEdge::DONE;
940  return;
941  }
942  }
943  }
944 #endif
945 }
946 
947 bool GEdge::reorder(const int elementType,
948  const std::vector<std::size_t> &ordering)
949 {
950  if(lines.size() != 0) {
951  if(lines.front()->getTypeForMSH() != elementType) { return false; }
952 
953  if(ordering.size() != lines.size()) return false;
954 
955  for(auto it = ordering.begin(); it != ordering.end(); ++it) {
956  if(*it >= lines.size()) return false;
957  }
958 
959  std::vector<MLine *> newLinesOrder(lines.size());
960  for(std::size_t i = 0; i < ordering.size(); i++) {
961  newLinesOrder[i] = lines[ordering[i]];
962  }
963 
964  lines = std::move(newLinesOrder);
965  return true;
966  }
967 
968  return false;
969 }
970 
971 std::vector<GVertex *> GEdge::vertices() const
972 {
973  std::vector<GVertex *> res;
974  if(getBeginVertex()) res.push_back(getBeginVertex());
975  if(getEndVertex()) res.push_back(getEndVertex());
976  return res;
977 }
978 
980 {
981  if(_lc.empty()) { return MAX_LC; }
982  const auto &it = std::lower_bound(_u_lc.begin(), _u_lc.end(), u);
983  size_t i1 = std::min<size_t>(it - _u_lc.begin(), _u_lc.size() - 1);
984  size_t i0 = std::max<size_t>(1, i1) - 1;
985  double u0 = _u_lc[i0], u1 = _u_lc[i1];
986  double l0 = _lc[i0], l1 = _lc[i1];
987  if(i1 == i0 || u0 == u1) return l0;
988  double alpha = (u - u0) / (u1 - u0);
989  return l0 * (1 - alpha) + l1 * (alpha);
990 }
991 
992 struct vindexsort {
993  const std::vector<double> &v;
994  vindexsort(const std::vector<double> &vp) : v(vp){};
995  bool operator()(size_t i0, size_t i1) { return v[i0] < v[i1]; }
996 };
997 
998 void GEdge::setMeshSizeParametric(const std::vector<double> u,
999  const std::vector<double> lc)
1000 {
1001  if(u.size() != lc.size()) {
1002  Msg::Error("setMeshSizeParametric : number of coordinates and number of "
1003  "mesh size do not match.");
1004  }
1005  std::vector<size_t> index(u.size());
1006  for(size_t i = 0; i < u.size(); ++i) index[i] = i;
1007  std::sort(index.begin(), index.end(), vindexsort(u));
1008  _u_lc.resize(u.size());
1009  _lc.resize(lc.size());
1010  for(size_t i = 0; i < u.size(); ++i) {
1011  _u_lc[i] = u[index[i]];
1012  _lc[i] = lc[index[i]];
1013  }
1014 }
GVertex::addEdge
void addEdge(GEdge *e)
Definition: GVertex.cpp:37
crossprod
SVector3 crossprod(const SVector3 &a, const SVector3 &b)
Definition: SVector3.h:150
GEdge::getStartElementType
MElement *const * getStartElementType(int type) const
Definition: GEdge.cpp:167
D
#define D
Definition: DefaultOptions.h:24
GEdge::setMeshMaster
void setMeshMaster(GEdge *master, const std::vector< double > &)
Definition: GEdge.cpp:89
GaussLegendre1D.h
contextGeometryOptions::tolerance
double tolerance
Definition: Context.h:99
GEdge::setVisibility
virtual void setVisibility(char val, bool recursive=false)
Definition: GEdge.cpp:277
GEdge::regions
virtual std::list< GRegion * > regions() const
Definition: GEdge.cpp:692
gmshGaussLegendre1D
void gmshGaussLegendre1D(int nbQuadPoints, double **t, double **w)
Definition: GaussLegendre1D.h:217
vindexsort::operator()
bool operator()(size_t i0, size_t i1)
Definition: GEdge.cpp:995
gmsh_sign
int gmsh_sign(T const &value)
Definition: Numeric.h:28
MEdge
Definition: MEdge.h:14
GEdge::getMeshElement
MElement * getMeshElement(std::size_t index) const
Definition: GEdge.cpp:173
GEdge::reparamOnFace
virtual SPoint2 reparamOnFace(const GFace *face, double epar, int dir) const
Definition: GEdge.cpp:482
dot
double dot(const SVector3 &a, const SMetric3 &m, const SVector3 &b)
Definition: STensor3.h:71
GEntity::correspondingHighOrderVertices
std::map< MVertex *, MVertex * > correspondingHighOrderVertices
Definition: GEntity.h:409
GPoint::y
double y() const
Definition: GPoint.h:22
GFace.h
vindexsort
Definition: GEdge.cpp:992
SVector3::normSq
double normSq() const
Definition: SVector3.h:34
GEdge::setMeshSizeParametric
void setMeshSizeParametric(const std::vector< double > u, const std::vector< double > lc)
Definition: GEdge.cpp:998
TYPE_LIN
#define TYPE_LIN
Definition: GmshDefines.h:65
GEntity::getMeshVertex
MVertex * getMeshVertex(std::size_t index)
Definition: GEntity.h:379
GEdge::resetMeshAttributes
virtual void resetMeshAttributes()
Definition: GEdge.cpp:187
GFace
Definition: GFace.h:33
Msg::Info
static void Info(const char *fmt,...)
Definition: GmshMessage.cpp:587
GEdge::lines
std::vector< MLine * > lines
Definition: GEdge.h:42
GEntity::model
GModel * model() const
Definition: GEntity.h:277
SPoint2
Definition: SPoint2.h:12
GEdge::minimumDrawSegments
virtual int minimumDrawSegments() const
Definition: GEdge.h:151
GEdge::_faces
std::vector< GFace * > _faces
Definition: GEdge.h:36
contextMeshOptions::compoundLcFactor
double compoundLcFactor
Definition: Context.h:49
GEdge::~GEdge
virtual ~GEdge()
Definition: GEdge.cpp:44
c
static double c(int i, int j, fullMatrix< double > &CA, const std::vector< SPoint3 > &P, const std::vector< SPoint3 > &Q)
Definition: discreteFrechetDistance.cpp:15
MESH_TRANSFINITE
#define MESH_TRANSFINITE
Definition: GmshDefines.h:259
discreteEdge
Definition: discreteEdge.h:12
MVertex
Definition: MVertex.h:24
GEntity::_obb
SOrientedBoundingBox * _obb
Definition: GEntity.h:52
Msg::Warning
static void Warning(const char *fmt,...)
Definition: GmshMessage.cpp:543
GEntity::OpenCascadeModel
@ OpenCascadeModel
Definition: GEntity.h:82
Msg::Error
static void Error(const char *fmt,...)
Definition: GmshMessage.cpp:482
MVertex::z
double z() const
Definition: MVertex.h:62
GEntity::physicals
std::vector< int > physicals
Definition: GEntity.h:65
SPoint3
Definition: SPoint3.h:14
LegendrePolynomials::f
void f(int n, double u, double *val)
Definition: orthogonalBasis.cpp:77
GEdge::XYZToU
virtual bool XYZToU(const double X, const double Y, const double Z, double &U, const double relax=1, bool first=true) const
Definition: GEdge.cpp:640
GEdge::writeGEO
virtual void writeGEO(FILE *fp)
Definition: GEdge.cpp:354
Range::high
T high() const
Definition: Range.h:20
SVector3
Definition: SVector3.h:16
SOrientedBoundingBox
Definition: SOrientedBoundingBox.h:33
GOLDEN
const double GOLDEN
Definition: GEdge.cpp:526
GEntity::getNativeType
virtual ModelType getNativeType() const
Definition: GEntity.h:268
meshGEdge.h
MVertex::onWhat
GEntity * onWhat() const
Definition: MVertex.h:82
GEdge::length
double length() const
Definition: GEdge.h:170
GEdge::addLine
void addLine(MLine *line)
Definition: GEdge.h:266
GEdge::_cp
closestPointFinder * _cp
Definition: GEdge.h:30
MVertex::point
SPoint3 point() const
Definition: MVertex.h:67
GModel::destroyMeshCaches
void destroyMeshCaches()
Definition: GModel.cpp:214
GModel::getEdgeByTag
GEdge * getEdgeByTag(int n) const
Definition: GModel.cpp:336
GmshMessage.h
MLine.h
MAX_LC
#define MAX_LC
Definition: GEntity.h:19
closestPointFinder::tol
double tol() const
Definition: closestPoint.h:31
GEntity
Definition: GEntity.h:31
GPoint
Definition: GPoint.h:13
GEdge::prescribedMeshSizeAtParam
double prescribedMeshSizeAtParam(double u)
Definition: GEdge.cpp:979
GEntity::getNumMeshVertices
std::size_t getNumMeshVertices()
Definition: GEntity.h:376
GEntity::getMeshMaster
GEntity * getMeshMaster() const
Definition: GEntity.h:291
MElement::getNumVertices
virtual std::size_t getNumVertices() const =0
sortedPoint::p
SPoint3 p
Definition: GEdge.cpp:738
GEdge::discretize
virtual void discretize(double tol, std::vector< SPoint3 > &dpts, std::vector< double > &ts)
Definition: GEdge.cpp:806
GEdge::getNumMeshParentElements
std::size_t getNumMeshParentElements()
Definition: GEdge.cpp:155
GEntity::DiscreteCurve
@ DiscreteCurve
Definition: GEntity.h:104
GEntity::PartitionCurve
@ PartitionCurve
Definition: GEntity.h:122
GEdge::addFace
void addFace(GFace *f)
Definition: GEdge.cpp:200
GEntity::setColor
virtual void setColor(unsigned color, bool recursive=false)
Definition: GEntity.h:319
MLine
Definition: MLine.h:21
GPoint::z
double z() const
Definition: GPoint.h:23
GEntity::setVisibility
virtual void setVisibility(char val, bool recursive=false)
Definition: GEntity.h:308
GEdge::getAdditionalInfoString
virtual std::string getAdditionalInfoString(bool multline=false)
Definition: GEdge.cpp:295
_discretize
static void _discretize(double tol, GEdge *edge, std::vector< sortedPoint > &upts, int pos0)
Definition: GEdge.cpp:755
CTX::instance
static CTX * instance()
Definition: Context.cpp:122
vindexsort::vindexsort
vindexsort(const std::vector< double > &vp)
Definition: GEdge.cpp:994
MElement::getVertex
virtual const MVertex * getVertex(int num) const =0
SPoint3::x
double x(void) const
Definition: SPoint3.h:125
vindexsort::v
const std::vector< double > & v
Definition: GEdge.cpp:993
GEdge::getNumMeshElementsByType
std::size_t getNumMeshElementsByType(const int familyType) const
Definition: GEdge.cpp:148
SortEdgeConsecutive
bool SortEdgeConsecutive(const std::vector< MEdge > &e, std::vector< std::vector< MVertex * > > &vs)
Definition: MEdge.cpp:68
GEdge.h
GEdge::delFace
virtual void delFace(GFace *f)
Definition: GEdge.cpp:206
GEdge::firstDer
virtual SVector3 firstDer(double par) const =0
GEdge::storeSTLAsMesh
bool storeSTLAsMesh()
Definition: GEdge.cpp:425
Range
Definition: Range.h:10
GEdge::getOBB
virtual SOrientedBoundingBox getOBB()
Definition: GEdge.cpp:234
GEntity::mesh_vertices
std::vector< MVertex * > mesh_vertices
Definition: GEntity.h:56
meshGEdge
Definition: meshGEdge.h:12
closestPoint.h
GVertex
Definition: GVertex.h:23
tolerance
#define tolerance
Definition: curvature.cpp:11
CTX::lc
double lc
Definition: Context.h:234
MESH_UNSTRUCTURED
#define MESH_UNSTRUCTURED
Definition: GmshDefines.h:260
closestPointFinder
Definition: closestPoint.h:18
norm
void norm(const double *vec, double *norm)
Definition: gmshLevelset.cpp:202
GModel
Definition: GModel.h:44
GEntity::DONE
@ DONE
Definition: GEntity.h:130
GEdge::getBeginVertex
virtual GVertex * getBeginVertex() const
Definition: GEdge.h:63
GEntity::Line
@ Line
Definition: GEntity.h:92
ExtrudeParams.h
sortedPoint::next
int next
Definition: GEdge.cpp:740
discreteEdge::createGeometry
int createGeometry()
Definition: discreteEdge.cpp:152
GFace::parFromPoint
virtual SPoint2 parFromPoint(const SPoint3 &, bool onSurface=true, bool convTestXYZ=false) const
Definition: GFace.cpp:1254
GEntity::geomType
virtual GeomType geomType() const
Definition: GEntity.h:238
GEdge::closestPointWithTol
SPoint3 closestPointWithTol(SPoint3 &p, double tolerance)
Definition: GEdge.cpp:728
GmshDefines.h
GEdge::meshAttributes
struct GEdge::@16 meshAttributes
SVector3::norm
double norm() const
Definition: SVector3.h:33
SPoint3::y
double y(void) const
Definition: SPoint3.h:127
GEdge::refineProjection
virtual bool refineProjection(const SVector3 &Q, double &u, int MaxIter, double relax, double tol, double &err) const
Definition: GEdge.cpp:604
GEntity::compound
std::vector< GEntity * > compound
Definition: GEntity.h:59
GModel::add
bool add(GRegion *r)
Definition: GModel.h:394
CTX::mesh
contextMeshOptions mesh
Definition: Context.h:313
GEntity::tolerance
virtual double tolerance() const
Definition: GEntity.h:262
MElement
Definition: MElement.h:30
GEdge::masterOrientation
int masterOrientation
Definition: GEdge.h:40
sortedPoint::t
double t
Definition: GEdge.cpp:739
GEntity::tag
int tag() const
Definition: GEntity.h:280
GEdge::position
virtual SVector3 position(double p) const
Definition: GEdge.h:128
GEntity::BoundaryLayerCurve
@ BoundaryLayerCurve
Definition: GEntity.h:103
GEdge::coeffTransfinite
double coeffTransfinite
Definition: GEdge.h:251
tMin
#define tMin
Definition: Gmsh.tab.cpp:358
GEdge::isOrphan
virtual bool isOrphan()
Definition: GEdge.cpp:705
GEdge::writePY
virtual void writePY(FILE *fp)
Definition: GEdge.cpp:405
CTX::geom
contextGeometryOptions geom
Definition: Context.h:311
GEdge::stl_vertices_xyz
std::vector< SPoint3 > stl_vertices_xyz
Definition: GEdge.h:50
GEdge::vertices
virtual std::vector< GVertex * > vertices() const
Definition: GEdge.cpp:971
GEdge::faces
virtual std::vector< GFace * > faces() const
Definition: GEdge.h:113
GEdge::typeTransfinite
int typeTransfinite
Definition: GEdge.h:254
GEdge::curvature
virtual double curvature(double par) const
Definition: GEdge.cpp:492
GEdge::_u_lc
std::vector< double > _u_lc
Definition: GEdge.h:32
GEdge::containsPoint
virtual bool containsPoint(const SPoint3 &pt) const
Definition: GEdge.cpp:445
goldenSectionSearch
double goldenSectionSearch(const GEdge *ge, const SPoint3 &q, double x1, double x2, double x3, double tau)
Definition: GEdge.cpp:532
GEdge::status
GEntity::MeshGenerationStatus status
Definition: GEdge.h:263
MVertex::getParameter
virtual bool getParameter(int i, double &par) const
Definition: MVertex.h:97
GEdge::bounds
virtual SBoundingBox3d bounds(bool fast=false)
Definition: GEdge.cpp:212
GEdge::meshStatistics
struct GEdge::@17 meshStatistics
GEdge::closestPoint
virtual GPoint closestPoint(const SPoint3 &queryPoint, double &param) const
Definition: GEdge.cpp:552
discreteEdge.h
GEdge::reorder
virtual bool reorder(const int elementType, const std::vector< std::size_t > &ordering)
Definition: GEdge.cpp:947
Context.h
GEdge::parBounds
virtual Range< double > parBounds(int i) const =0
tMax
#define tMax
Definition: Gmsh.tab.cpp:359
GEdge::containsParam
virtual bool containsParam(double pt) const
Definition: GEdge.cpp:453
GVertex::xyz
virtual SPoint3 xyz() const
Definition: GVertex.h:43
GEdge::_v0
GVertex * _v0
Definition: GEdge.h:35
z
const double z
Definition: GaussQuadratureQuad.cpp:56
GEdge::point
virtual GPoint point(double p) const =0
GVertex::delEdge
void delEdge(GEdge *e)
Definition: GVertex.cpp:43
GEdge::deleteMesh
virtual void deleteMesh()
Definition: GEdge.cpp:53
GEdge::_v1
GVertex * _v1
Definition: GEdge.h:35
GEdge::relocateMeshVertices
void relocateMeshVertices()
Definition: GEdge.cpp:714
discreteEdge::mesh
virtual void mesh(bool verbose)
Definition: discreteEdge.cpp:214
GEdge
Definition: GEdge.h:26
SOrientedBoundingBox::buildOBB
static SOrientedBoundingBox * buildOBB(std::vector< SPoint3 > &vertices)
Definition: SOrientedBoundingBox.cpp:150
GEntity::setMeshMaster
void setMeshMaster(GEntity *)
Definition: GEntity.cpp:128
sqDistPointSegment
static double sqDistPointSegment(const SPoint3 &p, const SPoint3 &s0, const SPoint3 &s1)
Definition: GEdge.cpp:743
GEdge::reverse
void reverse()
Definition: GEdge.cpp:140
GEntity::vertexCounterparts
std::map< GVertex *, GVertex * > vertexCounterparts
Definition: GEntity.h:62
SPoint3::z
double z(void) const
Definition: SPoint3.h:129
GEdge::removeElement
void removeElement(int type, MElement *e)
Definition: GEdge.cpp:784
GEdge::setColor
virtual void setColor(unsigned int val, bool recursive=false)
Definition: GEdge.cpp:286
GModel.h
GEdge::getNumMeshElements
std::size_t getNumMeshElements() const
Definition: GEdge.h:201
MVertex::y
double y() const
Definition: MVertex.h:61
GPoint::distance
double distance(GPoint &p)
Definition: GPoint.h:56
GEdge::getMeshElementByType
MElement * getMeshElementByType(const int familyType, const std::size_t index) const
Definition: GEdge.cpp:179
GEdge::getEndVertex
virtual GVertex * getEndVertex() const
Definition: GEdge.h:64
GEdge::nbPointsTransfinite
int nbPointsTransfinite
Definition: GEdge.h:253
GEdge::_lc
std::vector< double > _lc
Definition: GEdge.h:32
GVertex::point
virtual GPoint point() const =0
Range::low
T low() const
Definition: Range.h:18
line
Definition: shapeFunctions.h:342
GEdge::secondDer
virtual SVector3 secondDer(double par) const
Definition: GEdge.cpp:460
GEdge::addElement
void addElement(int type, MElement *e)
Definition: GEdge.cpp:775
GOLDEN2
const double GOLDEN2
Definition: GEdge.cpp:527
GEdge::GEdge
GEdge(GModel *model, int tag, GVertex *v0, GVertex *v1)
Definition: GEdge.cpp:26
MVertex::setEntity
void setEntity(GEntity *ge)
Definition: MVertex.h:83
GPoint::x
double x() const
Definition: GPoint.h:21
GEntity::correspondingVertices
std::map< MVertex *, MVertex * > correspondingVertices
Definition: GEntity.h:406
GEntity::PENDING
@ PENDING
Definition: GEntity.h:130
GEdge::parFromPoint
virtual double parFromPoint(const SPoint3 &P) const
Definition: GEdge.cpp:595
GEntity::deleteVertexArrays
void deleteVertexArrays()
Definition: GEntity.cpp:27
SBoundingBox3d
Definition: SBoundingBox3d.h:21
sortedPoint
Definition: GEdge.cpp:737
SPoint3::transform
bool transform(const std::vector< double > &tfo)
Definition: SPoint3.h:78
GEdge::mesh
virtual void mesh(bool verbose)
Definition: GEdge.cpp:918
GEdge::method
char method
Definition: GEdge.h:250
GEdge::removeElements
void removeElements(int type)
Definition: GEdge.cpp:797
MVertex::x
double x() const
Definition: MVertex.h:60
DT
Definition: DivideAndConquer.h:50