OpendTect  6.3
indexedshape.h
Go to the documentation of this file.
1 #pragma once
2 
3 /*+
4 ________________________________________________________________________
5 (C) dGB Beheer B.V.; (LICENSE) http://opendtect.org/OpendTect_license.txt
6 Author: K. Tingdahl
7 Date: September 2007
8 ________________________________________________________________________
9 
10 -*/
11 
12 #include "geometrymod.h"
13 #include "sets.h"
14 #include "thread.h"
15 #include "callback.h"
16 #include "ptrman.h"
17 #include "refcount.h"
18 #include "geometry.h"
19 #include "enums.h"
20 
21 class Coord3List;
22 class TaskRunner;
23 
24 namespace Geometry
25 {
26 
27 mExpClass(Geometry) PrimitiveSet : public RefCount::Referenced
28 {
29 public:
30  enum PrimitiveType{Points,Lines,Triangles,
31  LineStrips,TriangleStrip,TriangleFan,Other};
33 
34  virtual int size() const = 0;
35  virtual int get(int) const = 0;
36  virtual int indexOf(const int) = 0;
37  virtual void append( int ) = 0;
38  virtual void append(const int*,int num) = 0;
39  virtual void setEmpty() = 0;
40  virtual void getAll(TypeSet<int>&,bool) const;
41 
42  virtual PrimitiveType getPrimitiveType() const;
43  virtual void setPrimitiveType(PrimitiveType tp);
44 
45 protected:
46  PrimitiveSet();
48 };
49 
50 
52 {
53 public:
54  static IndexedPrimitiveSet* create(bool large);
57  virtual int pop() = 0;
58  virtual int set(int,int) = 0;
59  virtual void set(const int*,int num) = 0;
60 };
61 
62 
64 {
65 public:
66 
67  virtual int size() const;
68  virtual int get(int) const;
69  virtual int indexOf(const int);
70  virtual void append( int );
71  virtual void append(const int*,int num);
72  virtual void setEmpty();
73  virtual void getAll(TypeSet<int>&,bool) const;
74 
75  virtual int pop();
76  virtual int set(int,int);
77  virtual void set(const int*,int num);
78 
79 protected:
80 
82 };
83 
84 
86 {
87 public:
88  static RangePrimitiveSet* create();
89  virtual void setRange(const Interval<int>&) = 0;
90  virtual Interval<int> getRange() const = 0;
91  virtual int indexOf(const int) = 0;
92  virtual void getAll(TypeSet<int>&,bool) const;
93 };
94 
95 
97 {
98 public:
99  virtual ~PrimitiveSetCreator() {}
100 
101  static PrimitiveSet* create(bool indexed,bool large = false);
104  static void setCreator(PrimitiveSetCreator*);
105 
106 protected:
107  virtual PrimitiveSet* doCreate(bool indexed,bool large) = 0;
108 
110 };
111 
112 
114 {
115 protected:
116  virtual PrimitiveSet* doCreate(bool indexed,bool large);
117 };
118 
119 
124 {
125 public:
126  enum Type { Points, Lines, Triangles, TriangleStrip, TriangleFan };
127  enum SetType { IndexSet = 0, RangeSet };
128 
129  IndexedGeometry(Type,Coord3List* coords=0,Coord3List* normals=0,
130  Coord3List* texturecoords=0,
131  SetType settype =IndexSet, bool large = false);
138  virtual ~IndexedGeometry();
139 
140  void removeAll(bool deep);
143  bool isEmpty() const;
144 
145  bool isHidden() const { return ishidden_; }
146  void hide(bool yn) { ishidden_ = yn; }
147 
148 
149  void appendCoordIndices(const TypeSet<int>&,bool reverse=true);
150  void setCoordIndices(const TypeSet<int>&);
151  PrimitiveSet* getCoordsPrimitiveSet() { return primitiveset_; }
152  Type getPrimitiveType() const { return primitivetype_; }
153  SetType getPrimitiveSetType() const { return primitivesettype_; }
154 
155 
157  mutable bool ischanged_;
158 
161 
162 
163 protected:
164  void appendCoordIndicesAsTriangles(const TypeSet<int>&,bool);
165  void appendCoordIndicesAsTriangleStrips(const TypeSet<int>&);
166  void appendCoordIndicesAsTriangleFan(const TypeSet<int>&);
167 
168  bool ishidden_;
173 };
174 
175 
181 {
182 public:
183  virtual ~IndexedShape();
184 
185  virtual void setCoordList(Coord3List* cl,Coord3List* nl=0,
186  Coord3List* texturecoords=0,
187  bool createnew = true);
188  virtual bool needsUpdate() const { return true; }
189  virtual bool update(bool forceall,TaskRunner* =0) { return true; }
190 
191  virtual void setRightHandedNormals(bool) {}
192  virtual void removeAll(bool deep);
198  virtual bool createsNormals() const { return false; }
199  virtual bool createsTextureCoords() const { return false; }
200 
201  const ObjectSet<IndexedGeometry>& getGeometry() const;
202  ObjectSet<IndexedGeometry>& getGeometry();
203  const Coord3List* coordList() const { return coordlist_; }
204  Coord3List* coordList() { return coordlist_; }
205 
206  const Coord3List* normalCoordList() const { return normallist_; }
207  Coord3List* normalCoordList() { return normallist_; }
208 
209  const Coord3List* textureCoordList() const{ return texturecoordlist_; }
210  Coord3List* textureCoordList() { return texturecoordlist_; }
211 
212  int getVersion() const { return version_; }
213 
214 protected:
215  IndexedShape();
216 
219 
224 
225  void addVersion();
228 private:
229 
230  int version_;
231 };
232 
233 #define mGetIndexedShapeWriteLocker4Geometries() \
234  Threads::Locker lckr( geometrieslock_, Threads::Locker::WriteLock )
235 
236 
238  , public CallBacker
239 {
240 public:
243 
244  const Coord3List* normalCoordList() const { return normallist_; }
245  Coord3List* normalCoordList() { return normallist_; }
246 
247  const Coord3List* textureCoordList() const{ return texturecoordlist_; }
248  Coord3List* textureCoordList() { return texturecoordlist_; }
249 
250  int addGeometry(IndexedGeometry* ig);
251  void removeFromGeometries(const IndexedGeometry* ig);
252  void removeFromGeometries(int geoidx);
253 };
254 
255 
256 }; //namespace
virtual bool update(bool forceall, TaskRunner *=0)
Definition: indexedshape.h:189
#define mExpClass(module)
Definition: commondefs.h:157
Definition: indexedshape.h:180
Inherit from this class to be able to send and/or receive CallBacks.
Definition: callback.h:182
void hide(bool yn)
Definition: indexedshape.h:146
Type getPrimitiveType() const
Definition: indexedshape.h:152
Interface for a list of Coord3 with automatically maintained IDs.
Definition: positionlist.h:70
Definition: indexedshape.h:27
A lock of a type that (hopefully) suits your needs. To use it, you need the Locker class...
Definition: threadlock.h:51
int version_
Definition: indexedshape.h:230
PrimitiveType primitivetype_
Definition: indexedshape.h:47
Coord3List * coordlist_
Definition: indexedshape.h:220
Coord3List * normallist_
Definition: indexedshape.h:171
const Coord3List * textureCoordList() const
Definition: indexedshape.h:247
Definition: indexedshape.h:123
Coord3List * textureCoordList()
Definition: indexedshape.h:210
Definition: odinst.h:40
virtual ~PrimitiveSetCreator()
Definition: indexedshape.h:99
ObjectSet< T >::size_type indexOf(const ObjectSet< T > &os, const S &val)
Locate object in set.
Definition: objectset.h:173
bool isHidden() const
Definition: indexedshape.h:145
bool ischanged_
Definition: indexedshape.h:157
Coord3List * texturecoordlist_
Definition: indexedshape.h:170
#define mDeclareEnumUtils(enm)
Some utilities surrounding the often needed enum <-> string table.
Definition: enums.h:188
ObjectSet< IndexedGeometry > geometries_
Definition: indexedshape.h:218
ExplicitIndexedShape()
Definition: indexedshape.h:241
bool righthandednormals_
Definition: indexedshape.h:223
Definition: indexedshape.h:85
bool append(TypeSetBase< T, I > &to, const TypeSetBase< S, J > &from)
append allowing a different type to be merged into set
Definition: typeset.h:205
const Coord3List * coordList() const
Definition: indexedshape.h:203
Set of pointers to objects.
Definition: commontypes.h:28
void removeAll()
Definition: ptrman.h:115
const Coord3List * normalCoordList() const
Definition: indexedshape.h:244
Class that can execute a task.
Definition: task.h:193
bool ishidden_
Definition: indexedshape.h:168
Coord3List * texturecoordlist_
Definition: indexedshape.h:222
Coord3List * normallist_
Definition: indexedshape.h:221
SetType primitivesettype_
Definition: indexedshape.h:160
Coord3List * coordlist_
Definition: indexedshape.h:169
PrimitiveSet * getCoordsPrimitiveSet()
Definition: indexedshape.h:151
Coord3List * coordList()
Definition: indexedshape.h:204
Coord3List * textureCoordList()
Definition: indexedshape.h:248
TypeSet< int > indexset_
Definition: indexedshape.h:81
Geometry::PrimitiveSet * primitiveset_
Definition: indexedshape.h:172
virtual bool createsTextureCoords() const
Definition: indexedshape.h:199
bool isEmpty(const char *)
static uiHor3DInterpol * create(uiParent *)
Threads::Lock geometrieslock_
Definition: indexedshape.h:217
static PtrMan< PrimitiveSetCreator > creator_
Definition: indexedshape.h:109
Coord3List * normalCoordList()
Definition: indexedshape.h:245
virtual bool needsUpdate() const
Definition: indexedshape.h:188
Definition: indexedshape.h:31
Definition: indexedshape.h:30
Coord3List * normalCoordList()
Definition: indexedshape.h:207
~ExplicitIndexedShape()
Definition: indexedshape.h:242
Definition: indexedshape.h:237
SetType getPrimitiveSetType() const
Definition: indexedshape.h:153
int getVersion() const
Definition: indexedshape.h:212
Definition: indexedshape.h:51
virtual bool createsNormals() const
Definition: indexedshape.h:198
Definition: indexedshape.h:113
Definition: indexedshape.h:96
virtual void setRightHandedNormals(bool)
Definition: indexedshape.h:191
Definition: arraytesselator.h:19
SetType
Definition: indexedshape.h:127
Type primitivetype_
Definition: indexedshape.h:159
Definition: indexedshape.h:63
Threads::Lock lock_
Definition: indexedshape.h:156
const Coord3List * normalCoordList() const
Definition: indexedshape.h:206
PrimitiveType
Definition: indexedshape.h:30
Type
Definition: indexedshape.h:126
const Coord3List * textureCoordList() const
Definition: indexedshape.h:209

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