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

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