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

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