| http://www.coin3d.org/ http://www.kongsberg.com/kogt/

Block.h
1 /**************************************************************************\
2 * Copyright (c) Kongsberg Oil & Gas Technologies AS
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are
7 * met:
8 *
9 * Redistributions of source code must retain the above copyright notice,
10 * this list of conditions and the following disclaimer.
11 *
12 * Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 *
16 * Neither the name of the copyright holder nor the names of its
17 * contributors may be used to endorse or promote products derived from
18 * this software without specific prior written permission.
19 *
20 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
24 * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 \**************************************************************************/
32
33 #ifndef DIME_BLOCK_H
34 #define DIME_BLOCK_H
35
36 #include <dime/Basic.h>
37 #include <dime/entities/Entity.h>
38 #include <dime/util/Linear.h>
39
40 class dimeInput;
41 class dimeMemHandler;
42 class dimeModel;
43 class dimeOutput;
44
45 class DIME_DLL_API dimeBlock : public dimeEntity
46 {
47 friend class dimeBlocksSection;
48 friend class dimeEntitiesSection;
49 friend class dimeInsert;
50 friend class dimeModel;
51
52 public:
53 dimeBlock(dimeMemHandler * const memhandler);
54 virtual ~dimeBlock();
55
56 const dimeVec3f &getBasePoint() const;
57 void setBasePoint(const dimeVec3f &v);
58 int getNumEntities() const;
59 dimeEntity *getEntity(const int idx);
60 void insertEntity(dimeEntity * const entity, const int idx = -1);
61 void removeEntity(const int idx, const bool deleteIt = true);
62 void fitEntities();
63
64 const char *getName() const;
65 void setName(const char * const name);
66
67 dimeEntity *copy(dimeModel * const model) const;
68 virtual bool getRecord(const int groupcode,
69 dimeParam &param,
70 const int index = 0) const;
71 virtual const char *getEntityName() const;
72
73 virtual bool read(dimeInput * const in);
74 virtual bool write(dimeOutput * const out);
75 virtual int typeId() const;
76 virtual int countRecords() const;
77
78 protected:
79 virtual bool handleRecord(const int groupcode,
80 const dimeParam & param,
81 dimeMemHandler * const memhandler);
82
83 virtual void fixReferences(dimeModel * const model);
84 virtual bool traverse(const dimeState * const state,
85 dimeCallback callback,
86 void *userdata);
87
88 private:
89 int16 flags;
90 const char *name;
91 dimeVec3f basePoint;
92 dimeArray <dimeEntity*> entities;
93 dimeEntity *endblock;
94 dimeMemHandler *memHandler;
95
96 }; // class dimeBlock
97
98 inline const dimeVec3f &
99 dimeBlock::getBasePoint() const
100 {
101 return this->basePoint;
102 }
103
104 inline void
105 dimeBlock::setBasePoint(const dimeVec3f &v)
106 {
107 this->basePoint = v;
108 }
109
110 inline int
111 dimeBlock::getNumEntities() const
112 {
113 return this->entities.count();
114 }
115
116 inline dimeEntity *
117 dimeBlock::getEntity(const int idx)
118 {
119 assert(idx >= 0 && idx < this->entities.count());
120 return this->entities[idx];
121 }
122
123 inline const char *
124 dimeBlock::getName() const
125 {
126 return this->name;
127 }
128
129 inline void
130 dimeBlock::setName(const char * const name)
131 {
132 this->name = name;
133 }
134
135 #endif // ! DIME_BLOCK_H
136
dimeBlock::getBasePoint
const dimeVec3f & getBasePoint() const
Definition: Block.h:99
dimeArray
The dimeArray class is internal / private.
Definition: Array.h:65
dimeState
The dimeState class manages various state variables while the model is traversed. ...
Definition: State.h:40
dimeBlocksSection
The dimeBlocksSection class handles a BLOCKS section.
Definition: BlocksSection.h:39
dimeMemHandler
The dimeMemHandler class is a special-purpose memory manager.
Definition: MemHandler.h:38
dimeBase::typeId
virtual int typeId() const =0
dimeEntity::countRecords
virtual int countRecords() const
Definition: Entity.cpp:526
dimeEntity::copy
virtual dimeEntity * copy(dimeModel *const model) const =0
dimeEntity
The dimeEntity class is the superclass of all entity classes.
Definition: Entity.h:60
dimeBlock::getName
const char * getName() const
Definition: Block.h:124
dimeModel
The dimeModel class organizes a model.
Definition: Model.h:54
dimeEntity::getEntityName
virtual const char * getEntityName() const =0
dimeEntitiesSection
The dimeEntitiesSection class handles an ENTITIES section.
Definition: EntitiesSection.h:39
dimeInput
The dimeInput class offers transparent file I/O for DXF and DXB.
Definition: Input.h:41
dimeVec3f
The dimeVec3f class is for containing and operating on a 3D vector / coordinate.
Definition: Linear.h:61
dimeBlock::setBasePoint
void setBasePoint(const dimeVec3f &v)
Definition: Block.h:105
dimeEntity::fixReferences
virtual void fixReferences(dimeModel *const model)
Definition: Entity.cpp:476
dimeParam
The dimeParam class is a union of the different parameter types.
Definition: Basic.h:102
dimeBlock::getNumEntities
int getNumEntities() const
Definition: Block.h:111
dimeInsert
The dimeInsert class handles an INSERT entity.
Definition: Insert.h:42
dimeEntity::getRecord
virtual bool getRecord(const int groupcode, dimeParam &param, const int index=0) const
Definition: Entity.cpp:715
dimeBlock
The dimeBlock class handles a BLOCK entity.
Definition: Block.h:45
dimeEntity::write
virtual bool write(dimeOutput *const out)
Definition: Entity.cpp:271
dimeEntity::handleRecord
virtual bool handleRecord(const int groupcode, const dimeParam &param, dimeMemHandler *const memhandler)
Definition: Entity.cpp:659
dimeBlock::setName
void setName(const char *const name)
Definition: Block.h:130
dimeOutput
The dimeOutput class handles writing of DXF and DXB files.
Definition: Output.h:41
dimeEntity::read
virtual bool read(dimeInput *const in)
Definition: Entity.cpp:612
dimeEntity::traverse
virtual bool traverse(const dimeState *const state, dimeCallback callback, void *userdata)
Definition: Entity.cpp:541
dimeBlock::getEntity
dimeEntity * getEntity(const int idx)
Definition: Block.h:117

Copyright © by Kongsberg Oil & Gas Technologies. All rights reserved.