OpendTect  6.6
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 RCS: $Id$
9 ________________________________________________________________________
10 
11 -*/
12 
13 #include "geometrymod.h"
14 #include "sets.h"
15 #include "thread.h"
16 #include "callback.h"
17 #include "ptrman.h"
18 #include "refcount.h"
19 #include "geometry.h"
20 #include "enums.h"
21 
22 class Coord3List;
23 class TaskRunner;
24 
25 namespace Geometry
26 {
27 
30 
31 public:
33  LineStrips,TriangleStrip,TriangleFan,Other};
35 
36  virtual int size() const = 0;
37  virtual int get(int) const = 0;
38  virtual int indexOf(const int) = 0;
39  virtual void append( int ) = 0;
40  virtual void append(const int*,int num) = 0;
41  virtual void setEmpty() = 0;
42  virtual void getAll(TypeSet<int>&,bool) const;
43 
45  virtual void setPrimitiveType(PrimitiveType tp);
46 
47 protected:
50 };
51 
52 
54 {
55 public:
56  static IndexedPrimitiveSet* create(bool large);
59  virtual int pop() = 0;
60  virtual int set(int,int) = 0;
61  virtual void set(const int*,int num) = 0;
62 };
63 
64 
66 {
67 public:
68 
69  virtual int size() const;
70  virtual int get(int) const;
71  virtual int indexOf(const int);
72  virtual void append( int );
73  virtual void append(const int*,int num);
74  virtual void setEmpty();
75  virtual void getAll(TypeSet<int>&,bool) const;
76 
77  virtual int pop();
78  virtual int set(int,int);
79  virtual void set(const int*,int num);
80 
81 protected:
82 
84 };
85 
86 
88 {
89 public:
91  virtual void setRange(const Interval<int>&) = 0;
92  virtual Interval<int> getRange() const = 0;
93  virtual int indexOf(const int) = 0;
94  virtual void getAll(TypeSet<int>&,bool) const;
95 };
96 
97 
99 {
100 public:
101  virtual ~PrimitiveSetCreator() {}
102 
103  static PrimitiveSet* create(bool indexed,bool large = false);
107 
108 protected:
109  virtual PrimitiveSet* doCreate(bool indexed,bool large) = 0;
110 
112 };
113 
114 
116 {
117 protected:
118  virtual PrimitiveSet* doCreate(bool indexed,bool large);
119 };
120 
121 
126 {
127 public:
128  enum Type { Points, Lines, Triangles, TriangleStrip, TriangleFan };
129  enum SetType { IndexSet = 0, RangeSet };
130 
132  Coord3List* texturecoords=0,
133  SetType settype =IndexSet, bool large = false);
140  virtual ~IndexedGeometry();
141 
142  void removeAll(bool deep);
145  bool isEmpty() const;
146 
147  bool isHidden() const { return ishidden_; }
148  void hide(bool yn) { ishidden_ = yn; }
149 
150 
151  void appendCoordIndices(const TypeSet<int>&,bool reverse=true);
153  PrimitiveSet* getCoordsPrimitiveSet() { return primitiveset_; }
154  Type getPrimitiveType() const { return primitivetype_; }
155  SetType getPrimitiveSetType() const { return primitivesettype_; }
156 
158  mutable bool ischanged_;
159 
162 
163 
164 protected:
168 
169  bool ishidden_;
174 };
175 
176 
182 {
183 public:
184  virtual ~IndexedShape();
185 
186  virtual void setCoordList(Coord3List* cl,Coord3List* nl=0,
187  Coord3List* texturecoords=0,
188  bool createnew = true);
189  virtual bool needsUpdate() const { return true; }
190  virtual bool update(bool forceall,TaskRunner* =0) { return true; }
191 
192  virtual void setRightHandedNormals(bool) {}
193  virtual void removeAll(bool deep);
199  virtual bool createsNormals() const { return false; }
200  virtual bool createsTextureCoords() const { return false; }
201 
204  const Coord3List* coordList() const { return coordlist_; }
205  Coord3List* coordList() { return coordlist_; }
206 
207  const Coord3List* normalCoordList() const { return normallist_; }
208  Coord3List* normalCoordList() { return normallist_; }
209 
210  const Coord3List* textureCoordList() const{ return texturecoordlist_; }
211  Coord3List* textureCoordList() { return texturecoordlist_; }
212 
213  int getVersion() const { return version_; }
214 
215 protected:
217 
220 
225 
226  void addVersion();
229 private:
230 
231  int version_;
232 };
233 
234 #define mGetIndexedShapeWriteLocker4Geometries() \
235  Threads::Locker lckr( geometrieslock_, Threads::Locker::WriteLock )
236 
237 
239  , public CallBacker
240 {
241 public:
244 
245  const Coord3List* normalCoordList() const { return normallist_; }
246  Coord3List* normalCoordList() { return normallist_; }
247 
248  const Coord3List* textureCoordList() const{ return texturecoordlist_; }
249  Coord3List* textureCoordList() { return texturecoordlist_; }
250 
253  void removeFromGeometries(int geoidx);
254 };
255 
256 
257 }; //namespace
258 
Geometry::PrimitiveSet::append
virtual void append(const int *, int num)=0
Geometry::IndexedShape::normallist_
Coord3List * normallist_
Definition: indexedshape.h:222
Geometry::IndexedGeometry::isHidden
bool isHidden() const
Definition: indexedshape.h:147
Geometry::IndexedPrimitiveSetImpl::get
virtual int get(int) const
Geometry::ExplicitIndexedShape::removeFromGeometries
void removeFromGeometries(const IndexedGeometry *ig)
Geometry::RangePrimitiveSet::setRange
virtual void setRange(const Interval< int > &)=0
Geometry::IndexedGeometry::appendCoordIndicesAsTriangleFan
void appendCoordIndicesAsTriangleFan(const TypeSet< int > &)
Geometry::IndexedShape::coordList
const Coord3List * coordList() const
Definition: indexedshape.h:204
Geometry::IndexedShape::removeAll
virtual void removeAll(bool deep)
Geometry::IndexedGeometry::Type
Type
Definition: indexedshape.h:128
Geometry::ExplicitIndexedShape::normalCoordList
const Coord3List * normalCoordList() const
Definition: indexedshape.h:245
Geometry::ExplicitIndexedShape::normalCoordList
Coord3List * normalCoordList()
Definition: indexedshape.h:246
Geometry::IndexedShape::textureCoordList
Coord3List * textureCoordList()
Definition: indexedshape.h:211
Geometry::IndexedGeometry::lock_
Threads::Lock lock_
Definition: indexedshape.h:157
Geometry::IndexedShape::coordList
Coord3List * coordList()
Definition: indexedshape.h:205
Geometry::PrimitiveSetCreatorDefImpl
Definition: indexedshape.h:116
geometry.h
Geometry::IndexedShape::setCoordList
virtual void setCoordList(Coord3List *cl, Coord3List *nl=0, Coord3List *texturecoords=0, bool createnew=true)
ObjectSet
Set of pointers to objects.
Definition: commontypes.h:31
Geometry::IndexedGeometry::normallist_
Coord3List * normallist_
Definition: indexedshape.h:172
Geometry::IndexedShape::createsTextureCoords
virtual bool createsTextureCoords() const
Definition: indexedshape.h:200
Geometry::IndexedGeometry::removeAll
void removeAll(bool deep)
Geometry::IndexedGeometry::setCoordIndices
void setCoordIndices(const TypeSet< int > &)
Geometry
Definition: arraytesselator.h:21
Geometry::IndexedShape::geometrieslock_
Threads::Lock geometrieslock_
Definition: indexedshape.h:218
Geometry::IndexedGeometry
Definition: indexedshape.h:126
Geometry::IndexedShape::setRightHandedNormals
virtual void setRightHandedNormals(bool)
Definition: indexedshape.h:192
Geometry::IndexedShape
Definition: indexedshape.h:182
Geometry::IndexedPrimitiveSetImpl::getAll
virtual void getAll(TypeSet< int > &, bool) const
Geometry::RangePrimitiveSet::getAll
virtual void getAll(TypeSet< int > &, bool) const
mExpClass
#define mExpClass(module)
Definition: commondefs.h:177
Geometry::IndexedGeometry::ishidden_
bool ishidden_
Definition: indexedshape.h:169
Geometry::IndexedShape::needsUpdate
virtual bool needsUpdate() const
Definition: indexedshape.h:189
Geometry::IndexedShape::version_
int version_
Definition: indexedshape.h:231
Geometry::PrimitiveSetCreator::create
static PrimitiveSet * create(bool indexed, bool large=false)
Geometry::IndexedGeometry::texturecoordlist_
Coord3List * texturecoordlist_
Definition: indexedshape.h:171
ODInst::Other
@ Other
Definition: odinst.h:44
Geometry::RangePrimitiveSet
Definition: indexedshape.h:88
Geometry::PrimitiveSet::mDeclareEnumUtils
mDeclareEnumUtils(PrimitiveType)
Geometry::IndexedShape::normalCoordList
Coord3List * normalCoordList()
Definition: indexedshape.h:208
Geometry::ExplicitIndexedShape::~ExplicitIndexedShape
~ExplicitIndexedShape()
Definition: indexedshape.h:243
Geometry::IndexedGeometry::getCoordsPrimitiveSet
PrimitiveSet * getCoordsPrimitiveSet()
Definition: indexedshape.h:153
callback.h
CallBacker
Inherit from this class to be able to send and/or receive CallBacks.
Definition: callback.h:185
Geometry::IndexedGeometry::~IndexedGeometry
virtual ~IndexedGeometry()
Geometry::PrimitiveSet
Definition: indexedshape.h:29
Geometry::IndexedShape::coordlist_
Coord3List * coordlist_
Definition: indexedshape.h:221
Geometry::IndexedGeometry::appendCoordIndices
void appendCoordIndices(const TypeSet< int > &, bool reverse=true)
Geometry::ExplicitIndexedShape
Definition: indexedshape.h:240
Geometry::ExplicitIndexedShape::addGeometry
int addGeometry(IndexedGeometry *ig)
Geometry::RangePrimitiveSet::create
static RangePrimitiveSet * create()
Geometry::IndexedShape::getVersion
int getVersion() const
Definition: indexedshape.h:213
Geometry::PrimitiveSetCreator
Definition: indexedshape.h:99
Geometry::IndexedShape::IndexedShape
IndexedShape()
Geometry::IndexedGeometry::SetType
SetType
Definition: indexedshape.h:129
Geometry::IndexedGeometry::IndexedGeometry
IndexedGeometry(Type, Coord3List *coords=0, Coord3List *normals=0, Coord3List *texturecoords=0, SetType settype=IndexSet, bool large=false)
Geometry::IndexedGeometry::primitivetype_
Type primitivetype_
Definition: indexedshape.h:160
Geometry::PrimitiveSet::TriangleStrip
@ TriangleStrip
Definition: indexedshape.h:33
Geometry::IndexedGeometry::appendCoordIndicesAsTriangles
void appendCoordIndicesAsTriangles(const TypeSet< int > &, bool)
ptrman.h
Geometry::PrimitiveSetCreatorDefImpl::doCreate
virtual PrimitiveSet * doCreate(bool indexed, bool large)
Geometry::ExplicitIndexedShape::textureCoordList
Coord3List * textureCoordList()
Definition: indexedshape.h:249
Geometry::IndexedPrimitiveSetImpl::append
virtual void append(const int *, int num)
Geometry::PrimitiveSet::setEmpty
virtual void setEmpty()=0
Geometry::IndexedPrimitiveSetImpl::pop
virtual int pop()
Geometry::PrimitiveSet::setPrimitiveType
virtual void setPrimitiveType(PrimitiveType tp)
Geometry::IndexedShape::getGeometry
const ObjectSet< IndexedGeometry > & getGeometry() const
Geometry::IndexedShape::addVersion
void addVersion()
Geometry::IndexedGeometry::hide
void hide(bool yn)
Definition: indexedshape.h:148
Geometry::PrimitiveSet::get
virtual int get(int) const =0
PtrMan
Definition: ptrman.h:121
sKey::Lines
FixedString Lines()
Definition: keystrs.h:88
TaskRunner
Class that can execute a task.
Definition: task.h:170
Geometry::IndexedShape::righthandednormals_
bool righthandednormals_
Definition: indexedshape.h:224
Geometry::IndexedPrimitiveSet::pop
virtual int pop()=0
Geometry::PrimitiveSet::getAll
virtual void getAll(TypeSet< int > &, bool) const
Geometry::IndexedShape::geometries_
ObjectSet< IndexedGeometry > geometries_
Definition: indexedshape.h:219
Geometry::PrimitiveSetCreator::creator_
static PtrMan< PrimitiveSetCreator > creator_
Definition: indexedshape.h:111
Geometry::PrimitiveSet::indexOf
virtual int indexOf(const int)=0
Geometry::IndexedGeometry::getPrimitiveSetType
SetType getPrimitiveSetType() const
Definition: indexedshape.h:155
Geometry::PrimitiveSet::append
virtual void append(int)=0
Geometry::IndexedPrimitiveSetImpl
Definition: indexedshape.h:66
Geometry::PrimitiveSet::primitivetype_
PrimitiveType primitivetype_
Definition: indexedshape.h:49
Geometry::IndexedShape::texturecoordlist_
Coord3List * texturecoordlist_
Definition: indexedshape.h:223
Geometry::IndexedShape::textureCoordList
const Coord3List * textureCoordList() const
Definition: indexedshape.h:210
Geometry::PrimitiveSetCreator::doCreate
virtual PrimitiveSet * doCreate(bool indexed, bool large)=0
Geometry::RangePrimitiveSet::indexOf
virtual int indexOf(const int)=0
Geometry::IndexedPrimitiveSetImpl::indexOf
virtual int indexOf(const int)
Geometry::IndexedPrimitiveSet::set
virtual void set(const int *, int num)=0
Geometry::PrimitiveSet::size
virtual int size() const =0
Geometry::IndexedGeometry::coordlist_
Coord3List * coordlist_
Definition: indexedshape.h:170
Geometry::IndexedGeometry::primitiveset_
Geometry::PrimitiveSet * primitiveset_
Definition: indexedshape.h:173
Geometry::PrimitiveSet::Triangles
@ Triangles
Definition: indexedshape.h:32
Geometry::IndexedShape::~IndexedShape
virtual ~IndexedShape()
Geometry::IndexedPrimitiveSetImpl::size
virtual int size() const
Geometry::RangePrimitiveSet::getRange
virtual Interval< int > getRange() const =0
Geometry::IndexedShape::update
virtual bool update(bool forceall, TaskRunner *=0)
Definition: indexedshape.h:190
Geometry::ExplicitIndexedShape::ExplicitIndexedShape
ExplicitIndexedShape()
Definition: indexedshape.h:242
enums.h
Geometry::IndexedPrimitiveSetImpl::set
virtual void set(const int *, int num)
Geometry::PrimitiveSetCreator::~PrimitiveSetCreator
virtual ~PrimitiveSetCreator()
Definition: indexedshape.h:101
Geometry::PrimitiveSet::PrimitiveType
PrimitiveType
Definition: indexedshape.h:32
Geometry::IndexedPrimitiveSetImpl::indexset_
TypeSet< int > indexset_
Definition: indexedshape.h:83
Geometry::ExplicitIndexedShape::removeFromGeometries
void removeFromGeometries(int geoidx)
Geometry::PrimitiveSet::mRefCountImplNoDestructor
mRefCountImplNoDestructor(PrimitiveSet)
Geometry::IndexedPrimitiveSet::create
static IndexedPrimitiveSet * create(bool large)
Geometry::IndexedPrimitiveSet
Definition: indexedshape.h:54
refcount.h
Geometry::PrimitiveSet::PrimitiveSet
PrimitiveSet()
Coord3List
Interface for a list of Coord3 with automatically maintained IDs.
Definition: positionlist.h:72
Geometry::IndexedGeometry::primitivesettype_
SetType primitivesettype_
Definition: indexedshape.h:161
Geometry::ExplicitIndexedShape::textureCoordList
const Coord3List * textureCoordList() const
Definition: indexedshape.h:248
Geometry::IndexedShape::createsNormals
virtual bool createsNormals() const
Definition: indexedshape.h:199
Geometry::IndexedGeometry::getPrimitiveType
Type getPrimitiveType() const
Definition: indexedshape.h:154
Geometry::PrimitiveSetCreator::setCreator
static void setCreator(PrimitiveSetCreator *)
Geometry::IndexedShape::normalCoordList
const Coord3List * normalCoordList() const
Definition: indexedshape.h:207
Geometry::IndexedPrimitiveSetImpl::setEmpty
virtual void setEmpty()
sets.h
Interval< int >
thread.h
Geometry::IndexedPrimitiveSetImpl::set
virtual int set(int, int)
Threads::Lock
A lock of a type that (hopefully) suits your needs. To use it, you need the Locker class.
Definition: threadlock.h:53
Geometry::PrimitiveSet::getPrimitiveType
virtual PrimitiveType getPrimitiveType() const
Geometry::IndexedShape::getGeometry
ObjectSet< IndexedGeometry > & getGeometry()
Geometry::IndexedGeometry::isEmpty
bool isEmpty() const
Geometry::IndexedPrimitiveSetImpl::append
virtual void append(int)
Geometry::IndexedGeometry::appendCoordIndicesAsTriangleStrips
void appendCoordIndicesAsTriangleStrips(const TypeSet< int > &)
TypeSet< int >
Geometry::IndexedPrimitiveSet::set
virtual int set(int, int)=0
Geometry::IndexedGeometry::ischanged_
bool ischanged_
Definition: indexedshape.h:158

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