OpendTect-6_4  6.4
delaunay3d.h
Go to the documentation of this file.
1 #ifndef delaunay3d_h
2 #define delaunay3d_h
3 
4 /*+
5 ________________________________________________________________________
6 
7  (C) dGB Beheer B.V.; (LICENSE) http://opendtect.org/OpendTect_license.txt
8  Author: Y.C. Liu
9  Date: June 2008
10  RCS: $Id$
11 ________________________________________________________________________
12 
13 -*/
14 
15 #include "algomod.h"
16 #include "coord.h"
17 #include "typeset.h"
18 #include "paralleltask.h"
19 
26 {
27 public:
28  DAGTetrahedraTree();
29  DAGTetrahedraTree(const DAGTetrahedraTree&);
30  virtual ~DAGTetrahedraTree();
31  DAGTetrahedraTree& operator=(const DAGTetrahedraTree&);
32 
33  bool setCoordList(const TypeSet<Coord3>&,bool copy);
34  const TypeSet<Coord3>& coordList() const { return *coordlist_; }
35 
36  bool init();
37  void setInitSizeFactor(float);
38  /*<If the triangulation is not good enough because of
39  the init tetrahedra, we may abjust the size of it.*/
40  float getInitSizeFactor() const { return initsizefactor_; }
41 
42  bool isOK() const { return tetrahedras_.size(); }
43  static bool computeCoordRanges(const TypeSet<Coord3>&,
44  Interval<double>& xrg,
45  Interval<double>& yrg,
46  Interval<double>& zrg);
47  bool setBBox(const Interval<double>& xrg,
48  const Interval<double>& yrg,
49  const Interval<double>& zrg);
50 
51  bool insertPoint(int pointidx, int& dupid);
52  int insertPoint(const Coord3&, int& dupid);
53  char locationToTetrahedra(const Coord3& checkpt,
54  const Coord3* v,char& face,
55  int& dupididx,int& edgeend0idx,
56  int& edgeend1idx,double& dist) const;
57  /*<Find the relative position of checkpt to tetrahedra
58  with verticies v[0], v[1],v[2],v[3]. */
59  char searchTetrahedra(const Coord3&);
60  /*<Check pt is outside, on, or inside the body surface,
61  return -1, 0, 1 respectively. */
62 
63  bool getConnections(int pointidx,TypeSet<int>&) const;
64  bool getTetrahedras(TypeSet<int>&) const;
65  /*<Coord indices are sorted in fours, i.e.
66  ci[0], ci[1], ci[2], ci[3] is the first tetrahedra
67  ci[4], ci[5], ci[6], ci[7] is the second one. */
68  bool getSurfaceTriangles(TypeSet<int>&) const;
69  /*<Coord indices are sorted in threes, i.e.
70  ci[0], ci[1], ci[2] is the first triangle
71  ci[3], ci[4], ci[5] is the second triangle. */
72  void setEpsilon(double err) { epsilon_ = err; }
73  static char cNoVertex() { return -1; }
74 
75 protected:
76 
77  static char cIsInside() { return 0; }
78  static char cIsOnFace() { return 1; }
79  static char cIsOnEdge() { return 2; }
80 
81  static char cEdge01() { return 0; }
82  static char cEdge12() { return 1; }
83  static char cEdge20() { return 2; }
84 
85  static char cIsDuplicate() { return 3; }
86  static char cIsOutside() { return 4; }
87  static char cNotOnEdge() { return 5; }
88  static char cNotOnPlane() { return 6; }
89  static char cError() { return -1; }
90 
91  static char cNoTetrahedra() { return -1; }
92  static char cNoFace() { return -1; }
93  static char cInitVertex0() { return -2; }
94  static char cInitVertex1() { return -3; }
95  static char cInitVertex2() { return -4; }
96  static char cInitVertex3() { return -5; }
97 
98  void splitInitialBox(int ci);
99  void splitTetrahedraInside(int ci,int ti);
100  void splitTetrahedraOnFace(int ci,int ti0,int ti1,char face);
101  void splitTetrahedraOnEdge(int ci,const TypeSet<int>& tis,
102  int& sharedv0,int& sharedv1);
103  void legalizeTetrahedras(TypeSet<int>& v0s,TypeSet<int>& v1s,
104  TypeSet<int>& v2s,TypeSet<int>& tis);
105  char searchTetrahedra(int ci,int start,TypeSet<int>& tis,char& face,
106  int& sharedv0,int& sharedv1,int& dupid) const;
107  int searchFaceOnNeighbor(int a,int b,int c,int ti) const;
108  int searchFaceOnChild(int a,int b,int c,int ti) const;
109  int searchFaceOnList(int ci,int v0,int v1,int rep,
110  const TypeSet<int>& tis) const;
111  char location(int ci,int ti,char& face,int& dupid,
112  int& edgeend0,int& edgeend1,double& dist) const;
113  char isOnEdge(const Coord3& p,const Coord3& a,const Coord3& b,
114  const Coord3 planenormal,bool& duponfirst,
115  double& signedsqdist) const;
116  char locationToTriangle(const Coord3& pt,const Coord3& a,
117  const Coord3& b,const Coord3& c,double& signedsqdist,
118  double& closeedgedist,char& dupid,char& edgeidx) const;
119 
120  char isIntersect(const Coord3& p,const Coord3& q,const Coord3& a,
121  const Coord3& b,const Coord3& c,char& edge) const;
124  void addTriangle(int v0,int v1,int v2,TypeSet<int>& triangles) const;
128  {
129  DAGTetrahedra();
130  bool operator==(const DAGTetrahedra&) const;
131  DAGTetrahedra& operator=(const DAGTetrahedra&);
132 
133  int coordindices_[4];
134  int childindices_[4];
135  int neighbors_[4];
136  };
137 
141  Coord3 initialcoords_[4];
144  double epsilon_;
146 };
147 
148 
154 {
155 public:
157  bool isDataRandom() { return israndom_; }
158  void dataIsRandom(bool yn) { israndom_ = yn; }
159 
160 protected:
161 
162  int maxNrThreads() const { return 1; }
163  od_int64 nrIterations() const;
164  bool doWork(od_int64,od_int64,int);
165  bool doPrepare(int);
166 
168  bool israndom_;
170 };
171 
172 
173 #endif
#define mExpClass(module)
Definition: commondefs.h:160
Coord3 center_
Definition: delaunay3d.h:140
static char cNoVertex()
Definition: delaunay3d.h:73
float initsizefactor_
Definition: delaunay3d.h:145
bool operator==(const ArrayNDInfo &a1, const ArrayNDInfo &a2)
Definition: arrayndinfo.h:53
TypeSet< Coord3 > * coordlist_
Definition: delaunay3d.h:139
#define od_int64
Definition: plftypes.h:36
bool init()
int maxNrThreads() const
Definition: delaunay3d.h:162
DAGTetrahedraTree & tree_
Definition: delaunay3d.h:169
void setEpsilon(double err)
Definition: delaunay3d.h:72
Delaunay triangulation for 3D points. Should make sure all the points are defined.
Definition: delaunay3d.h:25
Generalization of a task that can be run in parallel.
Definition: paralleltask.h:66
Delaunay triangulation for 3D points.
Definition: delaunay3d.h:153
static char cEdge12()
Definition: delaunay3d.h:82
static char cEdge20()
Definition: delaunay3d.h:83
static char cInitVertex0()
Definition: delaunay3d.h:93
static char cIsInside()
Definition: delaunay3d.h:77
Definition: delaunay3d.h:127
TypeSet< DAGTetrahedra > tetrahedras_
Definition: delaunay3d.h:138
double epsilon_
Definition: delaunay3d.h:144
void dataIsRandom(bool yn)
Definition: delaunay3d.h:158
static char cIsOutside()
Definition: delaunay3d.h:86
TypeSet< int > permutation_
Definition: delaunay3d.h:167
static char cNotOnPlane()
Definition: delaunay3d.h:88
static char cNoFace()
Definition: delaunay3d.h:92
static char cNoTetrahedra()
Definition: delaunay3d.h:91
A cartesian coordinate in 3D space.
Definition: coord.h:72
bool isOK() const
Definition: delaunay3d.h:42
static char cEdge01()
Definition: delaunay3d.h:81
const TypeSet< Coord3 > & coordList() const
Definition: delaunay3d.h:34
static char cError()
Definition: delaunay3d.h:89
static char cNotOnEdge()
Definition: delaunay3d.h:87
float getInitSizeFactor() const
Definition: delaunay3d.h:40
static char cInitVertex2()
Definition: delaunay3d.h:95
static char cIsDuplicate()
Definition: delaunay3d.h:85
bool ownscoordlist_
Definition: delaunay3d.h:143
static char cIsOnFace()
Definition: delaunay3d.h:78
void copy(TypeSetBase< T, I > &to, const TypeSetBase< S, I > &from)
Definition: typeset.h:212
static char cInitVertex3()
Definition: delaunay3d.h:96
static char cInitVertex1()
Definition: delaunay3d.h:94
bool isDataRandom()
Definition: delaunay3d.h:157
bool israndom_
Definition: delaunay3d.h:168
static char cIsOnEdge()
Definition: delaunay3d.h:79

Generated at for the OpendTect seismic interpretation project. Copyright (C): dGB Beheer B. V. 2019