libopencad
cadfile.h
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 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 
32 #ifndef CADFILE_H
33 #define CADFILE_H
34 
35 #include "cadfileio.h"
36 #include "cadclasses.h"
37 #include "cadtables.h"
38 
39 
43 class OCAD_EXTERN CADFile
44 {
45  friend class CADTables;
46  friend class CADLayer;
47 public:
52  {
55  READ_FASTEST
56  };
57 
58 public:
59  CADFile (CADFileIO* poFileIO);
60  virtual ~CADFile();
61 
62 public:
63  const CADHeader& getHeader() const;
64  const CADClasses& getClasses() const;
65  const CADTables& getTables() const;
66 
67 public:
68  virtual int parseFile(enum OpenOptions eOptions);
69  virtual size_t getLayersCount() const;
70  virtual CADLayer &getLayer(size_t index);
71 // virtual size_t GetBlocksCount();
72 // virtual CADBlockObject * GetBlock( size_t index );
73 
74 protected:
81  virtual CADObject * getObject( long index, bool bHandlesOnly = false ) = 0;
82 
88  virtual CADGeometry * getGeometry( long index ) = 0;
89 
94  virtual int readSectionLocator() = 0;
95 
101  virtual int readHeader(enum OpenOptions eOptions) = 0;
102 
108  virtual int readClasses(enum OpenOptions eOptions) = 0;
109 
114  virtual int createFileMap() = 0;
115 
121  virtual int readTables(enum OpenOptions eOptions);
122 
123 protected:
124  CADFileIO* fileIO;
125  CADHeader header;
126  CADClasses classes;
127  CADTables tables;
128 
129 protected:
130  std::map<long, long> objectsMap; // object index <-> file offset
131 };
132 
133 
134 #endif // CADFILE_H
Definition: cadfile.h:54
Base CAD geometry class.
Definition: cadgeometry.h:46
Definition: cadlayer.h:40
OpenOptions
The CAD file open options enum.
Definition: cadfile.h:51
The base CAD object class.
Definition: cadobjects.h:82
Definition: cadfile.h:53
Definition: cadclasses.h:54
The common CAD header class.
Definition: cadheader.h:105
The CADFileIO class provides in/out file operations as read, write, seek, etc. This is abstract class...
Definition: cadfileio.h:40
The abstact CAD file class.
Definition: cadfile.h:43
The CAD tables class. Store tables.
Definition: cadtables.h:44