Block.h
1 /**************************************************************************\
2  *
3  * FILE: Block.h
4  *
5  * This source file is part of DIME.
6  * Copyright (C) 1998-1999 by Systems In Motion. All rights reserved.
7  *
8  * This library is free software; you can redistribute it and/or modify it
9  * under the terms of the GNU General Public License, version 2, as
10  * published by the Free Software Foundation.
11  *
12  * This library is distributed in the hope that it will be useful, but
13  * WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15  * General Public License (the accompanying file named COPYING) for more
16  * details.
17  *
18  **************************************************************************
19  *
20  * If you need DIME for a non-GPL project, contact Systems In Motion
21  * to acquire a Professional Edition License:
22  *
23  * Systems In Motion http://www.sim.no/
24  * Prof. Brochs gate 6 sales@sim.no
25  * N-7030 Trondheim Voice: +47 22114160
26  * NORWAY Fax: +47 67172912
27  *
28 \**************************************************************************/
29 
30 #ifndef DIME_BLOCK_H
31 #define DIME_BLOCK_H
32 
33 #include <dime/Basic.h>
34 #include <dime/entities/Entity.h>
35 #include <dime/util/Linear.h>
36 
37 class dimeInput;
38 class dimeMemHandler;
39 class dimeModel;
40 class dimeOutput;
41 
42 class DIME_DLL_API dimeBlock : public dimeEntity
43 {
44  friend class dimeBlocksSection;
45  friend class dimeEntitiesSection;
46  friend class dimeInsert;
47  friend class dimeModel;
48 
49 public:
50  dimeBlock(dimeMemHandler * const memhandler);
51  virtual ~dimeBlock();
52 
53  const dimeVec3f &getBasePoint() const;
54  void setBasePoint(const dimeVec3f &v);
55  int getNumEntities() const;
56  dimeEntity *getEntity(const int idx);
57  void insertEntity(dimeEntity * const entity, const int idx = -1);
58  void removeEntity(const int idx, const bool deleteIt = true);
59  void fitEntities();
60 
61  const char *getName() const;
62  void setName(const char * const name);
63 
64  dimeEntity *copy(dimeModel * const model) const;
65  virtual bool getRecord(const int groupcode,
66  dimeParam &param,
67  const int index = 0) const;
68  virtual const char *getEntityName() const;
69 
70  virtual bool read(dimeInput * const in);
71  virtual bool write(dimeOutput * const out);
72  virtual int typeId() const;
73  virtual int countRecords() const;
74 
75 protected:
76  virtual bool handleRecord(const int groupcode,
77  const dimeParam & param,
78  dimeMemHandler * const memhandler);
79 
80  virtual void fixReferences(dimeModel * const model);
81  virtual bool traverse(const dimeState * const state,
82  dimeCallback callback,
83  void *userdata);
84 
85 private:
86  int16 flags;
87  const char *name;
88  dimeVec3f basePoint;
89  dimeArray <dimeEntity*> entities;
90  dimeEntity *endblock;
91  dimeMemHandler *memHandler;
92 
93 }; // class dimeBlock
94 
95 inline const dimeVec3f &
97 {
98  return this->basePoint;
99 }
100 
101 inline void
103 {
104  this->basePoint = v;
105 }
106 
107 inline int
109 {
110  return this->entities.count();
111 }
112 
113 inline dimeEntity *
114 dimeBlock::getEntity(const int idx)
115 {
116  assert(idx >= 0 && idx < this->entities.count());
117  return this->entities[idx];
118 }
119 
120 inline const char *
122 {
123  return this->name;
124 }
125 
126 inline void
127 dimeBlock::setName(const char * const name)
128 {
129  this->name = name;
130 }
131 
132 #endif // ! DIME_BLOCK_H
133 

Copyright © 1998-1999, Systems In Motion <sales@sim.no>. All rights reserved.
System documentation was generated using doxygen.