Line data Source code
1 : /*******************************************************************************
2 : * Project: libopencad
3 : * Purpose: OpenSource CAD formats support library
4 : * Author: Alexandr Borzykh, mush3d at gmail.com
5 : * Author: Dmitry Baryshnikov, bishop.dev@gmail.com
6 : * Language: C++
7 : *******************************************************************************
8 : * The MIT License (MIT)
9 : *
10 : * Copyright (c) 2016 Alexandr Borzykh
11 : * Copyright (c) 2016-2018 NextGIS, <info@nextgis.com>
12 : *
13 : * Permission is hereby granted, free of charge, to any person obtaining a copy
14 : * of this software and associated documentation files (the "Software"), to deal
15 : * in the Software without restriction, including without limitation the rights
16 : * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
17 : * copies of the Software, and to permit persons to whom the Software is
18 : * furnished to do so, subject to the following conditions:
19 : *
20 : * The above copyright notice and this permission notice shall be included in all
21 : * copies or substantial portions of the Software.
22 : *
23 : * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
24 : * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
25 : * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
26 : * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
27 : * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
28 : * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
29 : * SOFTWARE.
30 : *******************************************************************************/
31 : #ifndef DWG_R2000_H_H
32 : #define DWG_R2000_H_H
33 :
34 : #include "cadfile.h"
35 : #include "io.h"
36 :
37 : struct SectionLocatorRecord
38 : {
39 : char byRecordNumber = 0;
40 : int dSeeker = 0;
41 : int dSize = 0;
42 : };
43 :
44 : struct DWG2000Ced
45 : {
46 : long dLength;
47 : short dType;
48 : int dObjSizeInBits;
49 : CADHandle hHandle;
50 : CADEedArray eEED;
51 : bool bGraphicPresentFlag;
52 :
53 : char dEntMode;
54 : int dNumReactors;
55 :
56 : bool bNoLinks;
57 : short dCMColorIndex;
58 : double dfLtypeScale;
59 :
60 : char ltype_flags;
61 : char plotstyle_flags;
62 :
63 : short dInvisibility;
64 : char cLineWeight;
65 : };
66 :
67 : struct DWG2000Cehd
68 : {
69 : CADHandle hOwner;
70 : CADHandle hReactors;
71 : CADHandle hxdibobjhandle;
72 : CADHandle hprev_entity, hnext_entity;
73 : CADHandle hlayer;
74 : CADHandle hltype;
75 : CADHandle hplotstyle;
76 : };
77 :
78 : class DWGFileR2000 : public CADFile
79 : {
80 : public:
81 : explicit DWGFileR2000( CADFileIO * poFileIO );
82 16 : virtual ~DWGFileR2000() = default;
83 :
84 : protected:
85 : virtual int ReadSectionLocators() override;
86 : virtual int ReadHeader( enum OpenOptions eOptions ) override;
87 : virtual int ReadClasses( enum OpenOptions eOptions ) override;
88 : virtual int CreateFileMap() override;
89 :
90 : CADObject * GetObject( long dHandle, bool bHandlesOnly = false ) override;
91 : CADGeometry * GetGeometry( size_t iLayerIndex, long dHandle,
92 : long dBlockRefHandle = 0 ) override;
93 :
94 : CADDictionary GetNOD() override;
95 : protected:
96 : CADBlockObject * getBlock(unsigned int dObjectSize,
97 : const CADCommonED& stCommonEntityData,
98 : CADBuffer& buffer);
99 : CADEllipseObject * getEllipse(unsigned int dObjectSize,
100 : const CADCommonED& stCommonEntityData,
101 : CADBuffer &buffer);
102 : CADSolidObject * getSolid( unsigned int dObjectSize,
103 : const CADCommonED& stCommonEntityData,
104 : CADBuffer& buffer);
105 : CADPointObject * getPoint(unsigned int dObjectSize,
106 : const CADCommonED& stCommonEntityData,
107 : CADBuffer &buffer);
108 : CADPolyline3DObject * getPolyLine3D(unsigned int dObjectSize,
109 : const CADCommonED& stCommonEntityData,
110 : CADBuffer &buffer);
111 : CADRayObject * getRay( unsigned int dObjectSize,
112 : const CADCommonED& stCommonEntityData,
113 : CADBuffer &buffer);
114 : CADXLineObject * getXLine( unsigned int dObjectSize,
115 : const CADCommonED& stCommonEntityData,
116 : CADBuffer &buffer );
117 : CADLineObject * getLine( unsigned int dObjectSize,
118 : const CADCommonED& stCommonEntityData,
119 : CADBuffer &buffer );
120 : CADTextObject * getText( unsigned int dObjectSize,
121 : const CADCommonED& stCommonEntityData,
122 : CADBuffer &buffer );
123 : CADVertex3DObject * getVertex3D( unsigned int dObjectSize,
124 : const CADCommonED& stCommonEntityData,
125 : CADBuffer &buffer );
126 : CADCircleObject * getCircle( unsigned int dObjectSize,
127 : const CADCommonED& stCommonEntityData,
128 : CADBuffer &buffer );
129 : CADEndblkObject * getEndBlock( unsigned int dObjectSize,
130 : const CADCommonED& stCommonEntityData,
131 : CADBuffer &buffer );
132 : CADPolyline2DObject * getPolyline2D( unsigned int dObjectSize,
133 : const CADCommonED& stCommonEntityData,
134 : CADBuffer &buffer );
135 : CADAttribObject * getAttributes( unsigned int dObjectSize,
136 : const CADCommonED& stCommonEntityData,
137 : CADBuffer &buffer );
138 : CADAttdefObject * getAttributesDefn( unsigned int dObjectSize,
139 : const CADCommonED& stCommonEntityData,
140 : CADBuffer &buffer );
141 : CADLWPolylineObject * getLWPolyLine( unsigned int dObjectSize,
142 : const CADCommonED& stCommonEntityData,
143 : CADBuffer &buffer );
144 : CADArcObject * getArc( unsigned int dObjectSize,
145 : const CADCommonED& stCommonEntityData,
146 : CADBuffer &buffer );
147 : CADSplineObject * getSpline( unsigned int dObjectSize,
148 : const CADCommonED& stCommonEntityData,
149 : CADBuffer &buffer );
150 : CADEntityObject * getEntity( int dObjectType, unsigned int dObjectSize,
151 : const CADCommonED& stCommonEntityData,
152 : CADBuffer &buffer );
153 : CADInsertObject * getInsert( int dObjectType, unsigned int dObjectSize,
154 : const CADCommonED& stCommonEntityData,
155 : CADBuffer &buffer );
156 : CADDictionaryObject * getDictionary( unsigned int dObjectSize,
157 : CADBuffer &buffer );
158 : CADXRecordObject * getXRecord( unsigned int dObjectSize,
159 : CADBuffer &buffer );
160 : CADLayerObject * getLayerObject( unsigned int dObjectSize,
161 : CADBuffer &buffer );
162 : CADLayerControlObject * getLayerControl( unsigned int dObjectSize,
163 : CADBuffer &buffer );
164 : CADBlockControlObject * getBlockControl( unsigned int dObjectSize,
165 : CADBuffer &buffer );
166 : CADBlockHeaderObject * getBlockHeader( unsigned int dObjectSize,
167 : CADBuffer &buffer );
168 : CADLineTypeControlObject * getLineTypeControl( unsigned int dObjectSize,
169 : CADBuffer &buffer );
170 : CADLineTypeObject * getLineType1( unsigned int dObjectSize,
171 : CADBuffer &buffer );
172 : CADMLineObject * getMLine( unsigned int dObjectSize,
173 : const CADCommonED& stCommonEntityData,
174 : CADBuffer &buffer );
175 : CADPolylinePFaceObject * getPolylinePFace( unsigned int dObjectSize,
176 : const CADCommonED& stCommonEntityData,
177 : CADBuffer &buffer );
178 : CADImageObject * getImage( unsigned int dObjectSize,
179 : const CADCommonED& stCommonEntityData,
180 : CADBuffer &buffer );
181 : CAD3DFaceObject * get3DFace( unsigned int dObjectSize,
182 : const CADCommonED& stCommonEntityData,
183 : CADBuffer &buffer );
184 : CADVertexMeshObject * getVertexMesh( unsigned int dObjectSize,
185 : const CADCommonED& stCommonEntityData,
186 : CADBuffer &buffer );
187 : CADVertexPFaceObject * getVertexPFace( unsigned int dObjectSize,
188 : const CADCommonED& stCommonEntityData,
189 : CADBuffer &buffer );
190 : CADDimensionObject * getDimension( short dObjectType, unsigned int dObjectSize,
191 : const CADCommonED& stCommonEntityData,
192 : CADBuffer &buffer );
193 : CADMTextObject * getMText( unsigned int dObjectSize,
194 : const CADCommonED& stCommonEntityData,
195 : CADBuffer &buffer );
196 : CADImageDefObject * getImageDef( unsigned int dObjectSize,
197 : CADBuffer &buffer );
198 : CADImageDefReactorObject * getImageDefReactor( unsigned int dObjectSize,
199 : CADBuffer &buffer );
200 : void fillCommonEntityHandleData(CADEntityObject * pEnt, CADBuffer &buffer);
201 : unsigned short validateEntityCRC(CADBuffer& buffer, unsigned int dObjectSize,
202 : const char * entityName = "ENTITY",
203 : bool bSwapEndianness = false );
204 : bool readBasicData(CADBaseControlObject * pBaseControlObject,
205 : unsigned int dObjectSize,
206 : CADBuffer &buffer);
207 : protected:
208 : int imageSeeker;
209 : std::vector<SectionLocatorRecord> sectionLocatorRecords;
210 : };
211 :
212 : #endif // DWG_R2000_H_H
|