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

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