gmsh-TingyuanDoc  0.1
An Open-Source Timing-driven Analytical Mixed-size FPGA Placer
intersectCurveSurface.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 
7 #include "Numeric.h"
8 #include "fullMatrix.h"
9 
10 static bool _kaboom(fullVector<double> &uvt, fullVector<double> &res,
11  void *_data);
12 
14  const curveFunctor &c;
15  const surfaceFunctor &s;
16  const double epsilon;
18  const double &eps)
19  : c(_c), s(_s), epsilon(eps)
20  {
21  }
22  bool apply(double newPoint[3])
23  {
24  try {
25  fullVector<double> uvt(3);
26  uvt(0) = newPoint[0];
27  uvt(1) = newPoint[1];
28  uvt(2) = newPoint[2];
29  fullVector<double> res(3);
30  _kaboom(uvt, res, this);
31  // printf("start with %12.5E\n",res.norm());
32  if(res.norm() < epsilon) return true;
33 
34  if(newton_fd(_kaboom, uvt, this)) {
35  // printf("--- CONVERGED -----------\n");
36  newPoint[0] = uvt(0);
37  newPoint[1] = uvt(1);
38  newPoint[2] = uvt(2);
39  // printf("newton done\n");
40  return true;
41  }
42  } catch(...) {
43  // printf("intersect curve surface failed !\n");
44  }
45  // printf("newton failed\n");
46  return false;
47  }
48 };
49 
51  void *_data)
52 {
54  SPoint3 s = data->s(uvt(0), uvt(1));
55  SPoint3 c = data->c(uvt(2));
56  res(0) = s.x() - c.x();
57  res(1) = s.y() - c.y();
58  res(2) = s.z() - c.z();
59  return true;
60 }
61 
63  double epsilon)
64 {
66  return data.apply(uvt);
67 }
curveFunctor
Definition: intersectCurveSurface.h:23
fullVector< double >
newton_fd
bool newton_fd(bool(*func)(fullVector< double > &, fullVector< double > &, void *), fullVector< double > &x, void *data, double relax, double tolx)
Definition: Numeric.cpp:685
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
fullVector::norm
scalar norm() const
SPoint3
Definition: SPoint3.h:14
robustPredicates::epsilon
static REAL epsilon
Definition: robustPredicates.cpp:371
intersectCurveSurfaceData::epsilon
const double epsilon
Definition: intersectCurveSurface.cpp:16
intersectCurveSurfaceData::c
const curveFunctor & c
Definition: intersectCurveSurface.cpp:14
SPoint3::x
double x(void) const
Definition: SPoint3.h:125
intersectCurveSurfaceData::intersectCurveSurfaceData
intersectCurveSurfaceData(const curveFunctor &_c, const surfaceFunctor &_s, const double &eps)
Definition: intersectCurveSurface.cpp:17
_kaboom
static bool _kaboom(fullVector< double > &uvt, fullVector< double > &res, void *_data)
Definition: intersectCurveSurface.cpp:50
intersectCurveSurfaceData::s
const surfaceFunctor & s
Definition: intersectCurveSurface.cpp:15
Numeric.h
SPoint3::y
double y(void) const
Definition: SPoint3.h:127
surfaceFunctor
Definition: intersectCurveSurface.h:17
intersectCurveSurface.h
intersectCurveSurfaceData::apply
bool apply(double newPoint[3])
Definition: intersectCurveSurface.cpp:22
intersectCurveSurfaceData
Definition: intersectCurveSurface.cpp:13
SPoint3::z
double z(void) const
Definition: SPoint3.h:129
fullMatrix.h
intersectCurveSurface
int intersectCurveSurface(curveFunctor &c, surfaceFunctor &s, double uvt[3], double epsilon)
Definition: intersectCurveSurface.cpp:62