gmsh-TingyuanDoc  0.1
An Open-Source Timing-driven Analytical Mixed-size FPGA Placer
intersectCurveSurface.h
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 #ifndef INTERSECT_CURVE_SURFACE
7 #define INTERSECT_CURVE_SURFACE
8 
9 // Intersection of a curve and a surface using newton's method
10 // FD are used to compute derivatives of the parametrizations
11 #include <cmath>
12 #include "SPoint3.h"
13 #include "SVector3.h"
14 #include "GFace.h"
15 #include "GEdge.h"
16 
18 public:
19  virtual ~surfaceFunctor() {}
20  virtual SPoint3 operator()(double u, double v) const = 0;
21 };
22 
23 class curveFunctor {
24 public:
25  virtual ~curveFunctor() {}
26  virtual SPoint3 operator()(double t) const = 0;
27 };
28 
30  const GFace *gf;
31 
32 public:
33  surfaceFunctorGFace(const GFace *_gf) : gf(_gf) {}
34  virtual SPoint3 operator()(double u, double v) const
35  {
36  GPoint gp = gf->point(u, v);
37  return SPoint3(gp.x(), gp.y(), gp.z());
38  }
39 };
40 
42  const GEdge *ge;
43 
44 public:
45  curveFunctorGEdge(const GEdge *_ge) : ge(_ge) {}
46  virtual SPoint3 operator()(double t) const
47  {
48  GPoint gp = ge->point(t);
49  return SPoint3(gp.x(), gp.y(), gp.z());
50  }
51 };
52 
56  double d;
57 
58 public:
59  curveFunctorCircle(const SVector3 &_n1, const SVector3 &_n2,
60  const SVector3 &_middle, const double &_d)
61  : n1(_n1), n2(_n2), middle(_middle), d(_d)
62  {
63  }
64  virtual SPoint3 operator()(double t) const
65  {
66  SVector3 dir = (n1 * cos(t) + n2 * sin(t)) * d;
67  return SPoint3(middle.x() + dir.x(), middle.y() + dir.y(),
68  middle.z() + dir.z());
69  }
70 };
71 
73  const SPoint3 p;
74  const SVector3 v1, v2;
75 
76 public:
77  surfaceFunctorPlane(const SPoint3 &_p, const SVector3 &_v1,
78  const SVector3 &_v2)
79  : p(_p), v1(_v1), v2(_v2)
80  {
81  }
82  virtual SPoint3 operator()(double u, double v) const
83  {
84  return SPoint3(p.x() + u * v1.x() + v * v2.x(),
85  p.y() + u * v1.y() + v * v2.y(),
86  p.z() + u * v1.z() + v * v2.z());
87  }
88 };
89 
90 // intersects the curve and the surface using Newton.
91 // the initial guess should be a good guess
92 // returns 1 --> OK
93 // returns 0 --> NOT CONVERGED
94 int intersectCurveSurface(curveFunctor &c, surfaceFunctor &s, double uvt[3],
95  double epsilon);
96 
97 #endif
surfaceFunctor::operator()
virtual SPoint3 operator()(double u, double v) const =0
surfaceFunctorPlane::surfaceFunctorPlane
surfaceFunctorPlane(const SPoint3 &_p, const SVector3 &_v1, const SVector3 &_v2)
Definition: intersectCurveSurface.h:77
curveFunctor
Definition: intersectCurveSurface.h:23
surfaceFunctorPlane::v1
const SVector3 v1
Definition: intersectCurveSurface.h:74
curveFunctor::operator()
virtual SPoint3 operator()(double t) const =0
GPoint::y
double y() const
Definition: GPoint.h:22
GFace.h
surfaceFunctorPlane::v2
const SVector3 v2
Definition: intersectCurveSurface.h:74
surfaceFunctorPlane::p
const SPoint3 p
Definition: intersectCurveSurface.h:73
curveFunctorCircle::d
double d
Definition: intersectCurveSurface.h:56
GFace
Definition: GFace.h:33
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
surfaceFunctor::~surfaceFunctor
virtual ~surfaceFunctor()
Definition: intersectCurveSurface.h:19
surfaceFunctorPlane
Definition: intersectCurveSurface.h:72
SPoint3
Definition: SPoint3.h:14
surfaceFunctorGFace::surfaceFunctorGFace
surfaceFunctorGFace(const GFace *_gf)
Definition: intersectCurveSurface.h:33
robustPredicates::epsilon
static REAL epsilon
Definition: robustPredicates.cpp:371
GFace::point
virtual GPoint point(double par1, double par2) const =0
SVector3
Definition: SVector3.h:16
SVector3.h
GPoint
Definition: GPoint.h:13
surfaceFunctorGFace::operator()
virtual SPoint3 operator()(double u, double v) const
Definition: intersectCurveSurface.h:34
surfaceFunctorGFace
Definition: intersectCurveSurface.h:29
intersectCurveSurface
int intersectCurveSurface(curveFunctor &c, surfaceFunctor &s, double uvt[3], double epsilon)
Definition: intersectCurveSurface.cpp:62
curveFunctorGEdge::curveFunctorGEdge
curveFunctorGEdge(const GEdge *_ge)
Definition: intersectCurveSurface.h:45
GPoint::z
double z() const
Definition: GPoint.h:23
curveFunctor::~curveFunctor
virtual ~curveFunctor()
Definition: intersectCurveSurface.h:25
SPoint3::x
double x(void) const
Definition: SPoint3.h:125
GEdge.h
curveFunctorCircle::operator()
virtual SPoint3 operator()(double t) const
Definition: intersectCurveSurface.h:64
curveFunctorCircle::n1
SVector3 n1
Definition: intersectCurveSurface.h:54
curveFunctorCircle::middle
SVector3 middle
Definition: intersectCurveSurface.h:55
curveFunctorGEdge::operator()
virtual SPoint3 operator()(double t) const
Definition: intersectCurveSurface.h:46
SPoint3::y
double y(void) const
Definition: SPoint3.h:127
SVector3::x
double x(void) const
Definition: SVector3.h:30
surfaceFunctor
Definition: intersectCurveSurface.h:17
curveFunctorCircle::n2
SVector3 n2
Definition: intersectCurveSurface.h:54
curveFunctorCircle::curveFunctorCircle
curveFunctorCircle(const SVector3 &_n1, const SVector3 &_n2, const SVector3 &_middle, const double &_d)
Definition: intersectCurveSurface.h:59
SVector3::y
double y(void) const
Definition: SVector3.h:31
GEdge::point
virtual GPoint point(double p) const =0
curveFunctorGEdge::ge
const GEdge * ge
Definition: intersectCurveSurface.h:42
GEdge
Definition: GEdge.h:26
SVector3::z
double z(void) const
Definition: SVector3.h:32
surfaceFunctorPlane::operator()
virtual SPoint3 operator()(double u, double v) const
Definition: intersectCurveSurface.h:82
SPoint3::z
double z(void) const
Definition: SPoint3.h:129
surfaceFunctorGFace::gf
const GFace * gf
Definition: intersectCurveSurface.h:30
curveFunctorGEdge
Definition: intersectCurveSurface.h:41
SPoint3.h
GPoint::x
double x() const
Definition: GPoint.h:21
curveFunctorCircle
Definition: intersectCurveSurface.h:53