dime  0.9.1
Portable DXF file library
Loading...
Searching...
No Matches
FaceEntity.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_FACEENTITY_H
34#define DIME_FACEENTITY_H
35
36#include <dime/Basic.h>
37#include <dime/entities/Entity.h>
38#include <dime/util/Linear.h>
39
40class DIME_DLL_API dimeFaceEntity : public dimeEntity
41{
42public:
43 bool isQuad() const;
44
45 virtual bool getRecord(const int groupcode,
46 dimeParam &param,
47 const int index = 0) const;
48
49 void setVertex(const int idx, const dimeVec3f &v);
50 void setTriangle(const dimeVec3f &v0, const dimeVec3f &v1,
51 const dimeVec3f &v2);
52 void setQuad(const dimeVec3f &v0, const dimeVec3f &v1,
53 const dimeVec3f &v2, const dimeVec3f &v3);
54 const dimeVec3f &getVertex(const int idx) const;
55 void getVertices(dimeVec3f &v0, dimeVec3f &v1,
56 dimeVec3f &v2, dimeVec3f &v3) const;
57
58 virtual dxfdouble getThickness() const;
59 virtual void getExtrusionDir(dimeVec3f &ed) const;
60
61 GeometryType extractGeometry(dimeArray <dimeVec3f> &verts,
62 dimeArray <int> &indices,
63 dimeVec3f &extrusionDir,
64 dxfdouble &thickness);
65
66 virtual int typeId() const;
67 virtual bool isOfType(const int thetypeid) const;
68 virtual int countRecords() const;
69
70protected:
71
72 virtual bool swapQuadCoords() const;
73
74 virtual bool handleRecord(const int groupcode,
75 const dimeParam &param,
76 dimeMemHandler * const memhandler);
77 void copyCoords(const dimeFaceEntity * const entity);
78 bool writeCoords(dimeOutput * const file);
79
81 dimeVec3f coords[4];
82
83}; // class dimeFaceEntity
84
85inline const dimeVec3f &
86dimeFaceEntity::getVertex(const int idx) const
87{
88 assert(idx >= 0 && idx < 4);
89 return this->coords[idx];
90}
91
92inline bool
93dimeFaceEntity::isQuad() const
94{
95 return (coords[2] != coords[3]);
96}
97
98inline void
99dimeFaceEntity::setVertex(const int idx, const dimeVec3f &v)
100{
101 assert(idx >= 0 && idx < 4);
102 this->coords[idx] = v;
103}
104
105#endif // ! DIME_FACEENTITY_H
106
virtual int typeId() const =0
The dimeEntity class is the superclass of all entity classes.
Definition Entity.h:61
virtual bool getRecord(const int groupcode, dimeParam &param, const int index=0) const
Definition Entity.cpp:715
virtual bool isOfType(const int thetypeid) const
Definition Entity.cpp:598
virtual int countRecords() const
Definition Entity.cpp:526
virtual bool handleRecord(const int groupcode, const dimeParam &param, dimeMemHandler *const memhandler)
Definition Entity.cpp:659
virtual GeometryType extractGeometry(dimeArray< dimeVec3f > &verts, dimeArray< int > &indices, dimeVec3f &extrusionDir, dxfdouble &thickness)
Definition Entity.cpp:583
The dimeFaceEntity class is an abstract class that handles one-face entity classes.
Definition FaceEntity.h:41
const dimeVec3f & getVertex(const int idx) const
Definition FaceEntity.h:86
The dimeMemHandler class is a special-purpose memory manager.
Definition MemHandler.h:39
The dimeOutput class handles writing of DXF and DXB files.
Definition Output.h:42
The dimeVec3f class is for containing and operating on a 3D vector / coordinate.
Definition Linear.h:62
The dimeParam class is a union of the different parameter types.
Definition Basic.h:102