Remove dwg support.
--HG-- branch : develop
This commit is contained in:
parent
e6eb9c756b
commit
490ccbe60a
|
@ -1,5 +1,4 @@
|
|||
/******************************************************************************
|
||||
** dwg2dxf - Program to convert dwg/dxf to dxf(ascii & binary) **
|
||||
** **
|
||||
** Copyright (C) 2015 José F. Soriano, rallazz@gmail.com **
|
||||
** **
|
||||
|
@ -11,7 +10,6 @@
|
|||
******************************************************************************/
|
||||
|
||||
#include "dxiface.h"
|
||||
#include "libdxfrw/libdwgr.h"
|
||||
#include "libdxfrw/libdxfrw.h"
|
||||
#include "../vmisc/vabstractapplication.h"
|
||||
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
/******************************************************************************
|
||||
** dwg2dxf - Program to convert dwg/dxf to dxf(ascii & binary) **
|
||||
** **
|
||||
** Copyright (C) 2015 José F. Soriano, rallazz@gmail.com **
|
||||
** **
|
||||
|
@ -55,7 +54,7 @@ public:
|
|||
};
|
||||
|
||||
|
||||
//container class to store full dwg/dxf data.
|
||||
//container class to store full dxf data.
|
||||
class dx_data {
|
||||
public:
|
||||
dx_data()
|
||||
|
|
|
@ -387,26 +387,6 @@ private:
|
|||
DRW_Coord vdata;
|
||||
};
|
||||
|
||||
//! Class to handle dwg handles
|
||||
/*!
|
||||
* Class to handle dwg handles
|
||||
* @author Rallaz
|
||||
*/
|
||||
class dwgHandle{
|
||||
public:
|
||||
dwgHandle()
|
||||
: code(0),
|
||||
size(0),
|
||||
ref(0)
|
||||
{}
|
||||
|
||||
~dwgHandle() = default;
|
||||
|
||||
duint8 code;
|
||||
duint8 size;
|
||||
duint32 ref;
|
||||
};
|
||||
|
||||
//! Class to convert between line width and integer
|
||||
/*!
|
||||
* Class to convert between line width and integer
|
||||
|
@ -508,10 +488,6 @@ public:
|
|||
return -3;
|
||||
}
|
||||
|
||||
static int lineWidth2dwgInt(enum lineWidth lw){
|
||||
return static_cast<int> (lw);
|
||||
}
|
||||
|
||||
static enum lineWidth dxfInt2lineWidth(int i){
|
||||
if (i<0) {
|
||||
if (i==-1)
|
||||
|
@ -572,14 +548,6 @@ public:
|
|||
//default by default
|
||||
return widthDefault;
|
||||
}
|
||||
|
||||
static enum lineWidth dwgInt2lineWidth(int i){
|
||||
if ( (i>-1 && i<24) || (i>28 && i<32) ) {
|
||||
return static_cast<lineWidth> (i);
|
||||
}
|
||||
//default by default
|
||||
return widthDefault;
|
||||
}
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -13,7 +13,6 @@
|
|||
#include "drw_classes.h"
|
||||
#include "intern/dxfreader.h"
|
||||
#include "intern/dxfwriter.h"
|
||||
#include "intern/dwgbuffer.h"
|
||||
#include "intern/drw_dbg.h"
|
||||
|
||||
void DRW_Class::parseCode(int code, dxfReader *reader){
|
||||
|
@ -44,42 +43,6 @@ void DRW_Class::parseCode(int code, dxfReader *reader){
|
|||
}
|
||||
}
|
||||
|
||||
bool DRW_Class::parseDwg(DRW::Version version, dwgBuffer *buf, dwgBuffer *strBuf){
|
||||
DRW_DBG("\n***************************** parsing Class *********************************************\n");
|
||||
|
||||
classNum = buf->getBitShort();
|
||||
DRW_DBG("Class number: "); DRW_DBG(classNum);
|
||||
proxyFlag = buf->getBitShort(); //in dwg specs says "version"
|
||||
|
||||
appName = strBuf->getVariableText(version, false);
|
||||
className = strBuf->getVariableText(version, false);
|
||||
recName = strBuf->getVariableText(version, false);
|
||||
|
||||
DRW_DBG("\napp name: "); DRW_DBG(appName.c_str());
|
||||
DRW_DBG("\nclass name: "); DRW_DBG(className.c_str());
|
||||
DRW_DBG("\ndxf rec name: "); DRW_DBG(recName.c_str());
|
||||
wasaProxyFlag = buf->getBit(); //in dwg says wasazombie
|
||||
entityFlag = buf->getBitShort();
|
||||
entityFlag = entityFlag == 0x1F2 ? 1: 0;
|
||||
|
||||
DRW_DBG("\nProxy capabilities flag: "); DRW_DBG(proxyFlag);
|
||||
DRW_DBG(", proxy flag (280): "); DRW_DBG(wasaProxyFlag);
|
||||
DRW_DBG(", entity flag: "); DRW_DBGH(entityFlag);
|
||||
|
||||
if (version > DRW::AC1015) {//2004+
|
||||
instanceCount = buf->getBitLong();
|
||||
DRW_DBG("\nInstance Count: "); DRW_DBG(instanceCount);
|
||||
duint32 dwgVersion = buf->getBitLong();
|
||||
DRW_DBG("\nDWG version: "); DRW_DBG(dwgVersion);
|
||||
DRW_DBG("\nmaintenance version: "); DRW_DBG(buf->getBitLong());
|
||||
DRW_DBG("\nunknown 1: "); DRW_DBG(buf->getBitLong());
|
||||
DRW_DBG("\nunknown 2: "); DRW_DBG(buf->getBitLong());
|
||||
}
|
||||
DRW_DBG("\n");
|
||||
toDwgType();
|
||||
return buf->isGood();
|
||||
}
|
||||
|
||||
void DRW_Class::write(dxfWriter *writer, DRW::Version ver){
|
||||
if (ver > DRW::AC1009) {
|
||||
writer->writeString(0, "CLASS");
|
||||
|
@ -94,22 +57,3 @@ void DRW_Class::write(dxfWriter *writer, DRW::Version ver){
|
|||
writer->writeInt16(281, entityFlag);
|
||||
}
|
||||
}
|
||||
|
||||
void DRW_Class::toDwgType(){
|
||||
if (recName == "LWPOLYLINE")
|
||||
dwgType = 77;
|
||||
else if (recName == "HATCH")
|
||||
dwgType = 78;
|
||||
else if (recName == "GROUP")
|
||||
dwgType = 72;
|
||||
/* else if (recName == "GROUP")
|
||||
dwgType = 72;*/
|
||||
else if (recName == "LAYOUT")
|
||||
dwgType = 82;
|
||||
else if (recName == "IMAGE")
|
||||
dwgType = 101;
|
||||
else if (recName == "IMAGEDEF")
|
||||
dwgType = 102;
|
||||
else
|
||||
dwgType =0;
|
||||
}
|
||||
|
|
|
@ -15,11 +15,9 @@
|
|||
|
||||
|
||||
#include "drw_base.h"
|
||||
//#include "libdwgr.h"
|
||||
|
||||
class dxfReader;
|
||||
class dxfWriter;
|
||||
class dwgBuffer;
|
||||
|
||||
//! Class to handle classes entries
|
||||
/*!
|
||||
|
@ -36,19 +34,14 @@ public:
|
|||
proxyFlag(),
|
||||
instanceCount(),
|
||||
wasaProxyFlag(),
|
||||
entityFlag(),
|
||||
classNum(),
|
||||
dwgType()
|
||||
entityFlag()
|
||||
{}
|
||||
|
||||
~DRW_Class() = default;
|
||||
|
||||
void parseCode(int code, dxfReader *reader);
|
||||
void write(dxfWriter *writer, DRW::Version ver);
|
||||
bool parseDwg(DRW::Version version, dwgBuffer *buf, dwgBuffer *strBuf);
|
||||
|
||||
private:
|
||||
void toDwgType();
|
||||
public:
|
||||
UTF8STRING recName; /*!< record name, code 1 */
|
||||
UTF8STRING className; /*!< C++ class name, code 2 */
|
||||
|
@ -57,9 +50,6 @@ public:
|
|||
int instanceCount; /*!< number of instances for a custom class, code 91*/
|
||||
int wasaProxyFlag; /*!< proxy flag (app loaded on save), code 280 */
|
||||
int entityFlag; /*!< entity flag, code 281 (0 object, 1 entity)*/
|
||||
public: //only for read dwg
|
||||
duint16 classNum;
|
||||
int dwgType;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -21,7 +21,6 @@
|
|||
#include "drw_base.h"
|
||||
|
||||
class dxfReader;
|
||||
class dwgBuffer;
|
||||
class DRW_Polyline;
|
||||
|
||||
namespace DRW {
|
||||
|
@ -88,8 +87,7 @@ namespace DRW {
|
|||
//only in DWG: MINSERT, 5 types of vertex, 4 types of polylines: 2d, 3d, pface & mesh
|
||||
//shape, dictionary, MLEADER, MLEADERSTYLE
|
||||
|
||||
#define SETENTFRIENDS friend class dxfRW; \
|
||||
friend class dwgReader;
|
||||
#define SETENTFRIENDS friend class dxfRW;
|
||||
|
||||
//! Base class for entities
|
||||
/*!
|
||||
|
@ -122,20 +120,6 @@ public:
|
|||
shadow(DRW::CastAndReceieveShadows),
|
||||
haveExtrusion(false),
|
||||
extData(),
|
||||
haveNextLinks(),
|
||||
plotFlags(),
|
||||
ltFlags(),
|
||||
materialFlag(),
|
||||
shadowFlag(),
|
||||
lTypeH(),
|
||||
layerH(),
|
||||
nextEntLink(0),
|
||||
prevEntLink(0),
|
||||
ownerHandle(false),
|
||||
xDictFlag(0),
|
||||
numReactors(0),
|
||||
objSize(),
|
||||
oType(),
|
||||
extAxisX(),
|
||||
extAxisY(),
|
||||
curr(nullptr)
|
||||
|
@ -163,20 +147,6 @@ public:
|
|||
shadow(e.shadow),
|
||||
haveExtrusion(e.haveExtrusion),
|
||||
extData(),
|
||||
haveNextLinks(),
|
||||
plotFlags(),
|
||||
ltFlags(),
|
||||
materialFlag(),
|
||||
shadowFlag(),
|
||||
lTypeH(),
|
||||
layerH(),
|
||||
nextEntLink(e.nextEntLink),
|
||||
prevEntLink(e.prevEntLink),
|
||||
ownerHandle(false),
|
||||
xDictFlag(e.xDictFlag),
|
||||
numReactors(e.numReactors),
|
||||
objSize(),
|
||||
oType(),
|
||||
extAxisX(),
|
||||
extAxisY(),
|
||||
curr(nullptr/*e.curr*/)
|
||||
|
@ -217,11 +187,6 @@ protected:
|
|||
void calculateAxis(DRW_Coord extPoint);
|
||||
//apply extrusion to @extPoint and return data in @point
|
||||
void extrudePoint(DRW_Coord extPoint, DRW_Coord *point) const;
|
||||
virtual bool parseDwg(DRW::Version version, dwgBuffer *buf, duint32 bs=0)=0;
|
||||
//parses dwg common start part to read entity
|
||||
bool parseDwg(DRW::Version version, dwgBuffer *buf, dwgBuffer* strBuf, duint32 bs=0);
|
||||
//parses dwg common handles part to read entity
|
||||
bool parseDwgEntHandle(DRW::Version version, dwgBuffer *buf);
|
||||
|
||||
//parses dxf 102 groups to read entity
|
||||
bool parseDxfGroups(int code, dxfReader *reader);
|
||||
|
@ -249,23 +214,6 @@ public:
|
|||
bool haveExtrusion; /*!< set to true if the entity have extrusion*/
|
||||
std::vector<DRW_Variant*> extData; /*!< FIFO list of extended data, codes 1000 to 1071*/
|
||||
|
||||
protected: //only for read dwg
|
||||
duint8 haveNextLinks; //aka nolinks //B
|
||||
duint8 plotFlags; //presence of plot style //BB
|
||||
duint8 ltFlags; //presence of linetype handle //BB
|
||||
duint8 materialFlag; //presence of material handle //BB
|
||||
duint8 shadowFlag; //presence of shadow handle ?? (in dwg may be plotflag)//RC
|
||||
dwgHandle lTypeH;
|
||||
dwgHandle layerH;
|
||||
duint32 nextEntLink;
|
||||
duint32 prevEntLink;
|
||||
bool ownerHandle;
|
||||
|
||||
duint8 xDictFlag;
|
||||
dint32 numReactors; //
|
||||
duint32 objSize; //RL 32bits object data size in bits
|
||||
dint16 oType;
|
||||
|
||||
private:
|
||||
DRW_Entity &operator=(const DRW_Entity &) Q_DECL_EQ_DELETE;
|
||||
DRW_Coord extAxisX;
|
||||
|
@ -294,7 +242,6 @@ public:
|
|||
|
||||
protected:
|
||||
void parseCode(int code, dxfReader *reader);
|
||||
virtual bool parseDwg(DRW::Version version, dwgBuffer *buf, duint32 bs=0);
|
||||
|
||||
public:
|
||||
DRW_Coord basePoint; /*!< base point, code 10, 20 & 30 */
|
||||
|
@ -322,7 +269,6 @@ public:
|
|||
|
||||
protected:
|
||||
void parseCode(int code, dxfReader *reader);
|
||||
virtual bool parseDwg(DRW::Version version, dwgBuffer *buf, duint32 bs=0);
|
||||
|
||||
public:
|
||||
DRW_Coord secPoint; /*!< second point, code 11, 21 & 31 */
|
||||
|
@ -339,8 +285,6 @@ public:
|
|||
DRW_Ray() {
|
||||
eType = DRW::RAY;
|
||||
}
|
||||
protected:
|
||||
virtual bool parseDwg(DRW::Version version, dwgBuffer *buf, duint32 bs=0);
|
||||
};
|
||||
|
||||
//! Class to handle xline entity
|
||||
|
@ -373,7 +317,6 @@ public:
|
|||
|
||||
protected:
|
||||
void parseCode(int code, dxfReader *reader);
|
||||
virtual bool parseDwg(DRW::Version version, dwgBuffer *buf, duint32 bs=0);
|
||||
|
||||
public:
|
||||
double radious; /*!< radius, code 40 */
|
||||
|
@ -413,8 +356,6 @@ public:
|
|||
protected:
|
||||
//! interpret code in dxf reading process or dispatch to inherited class
|
||||
void parseCode(int code, dxfReader *reader);
|
||||
//! interpret dwg data (was already determined to be part of this object)
|
||||
virtual bool parseDwg(DRW::Version version, dwgBuffer *buf, duint32 bs=0);
|
||||
|
||||
public:
|
||||
double staangle; /*!< start angle, code 50 in radians*/
|
||||
|
@ -447,8 +388,6 @@ public:
|
|||
protected:
|
||||
//! interpret code in dxf reading process or dispatch to inherited class
|
||||
void parseCode(int code, dxfReader *reader);
|
||||
//! interpret dwg data (was already determined to be part of this object)
|
||||
virtual bool parseDwg(DRW::Version version, dwgBuffer *buf, duint32 bs=0);
|
||||
|
||||
private:
|
||||
void correctAxis();
|
||||
|
@ -479,7 +418,6 @@ public:
|
|||
|
||||
protected:
|
||||
void parseCode(int code, dxfReader *reader);
|
||||
virtual bool parseDwg(DRW::Version version, dwgBuffer *buf, duint32 bs=0);
|
||||
|
||||
public:
|
||||
DRW_Coord thirdPoint; /*!< third point, code 12, 22 & 32 */
|
||||
|
@ -501,8 +439,6 @@ public:
|
|||
protected:
|
||||
//! interpret code in dxf reading process or dispatch to inherited class
|
||||
void parseCode(int code, dxfReader *reader);
|
||||
//! interpret dwg data (was already determined to be part of this object)
|
||||
virtual bool parseDwg(DRW::Version v, dwgBuffer *buf, duint32 bs=0);
|
||||
|
||||
public:
|
||||
//! first corner (2D)
|
||||
|
@ -561,8 +497,6 @@ public:
|
|||
protected:
|
||||
//! interpret code in dxf reading process or dispatch to inherited class
|
||||
void parseCode(int code, dxfReader *reader);
|
||||
//! interpret dwg data (was already determined to be part of this object)
|
||||
virtual bool parseDwg(DRW::Version v, dwgBuffer *buf, duint32 bs=0);
|
||||
|
||||
public:
|
||||
int invisibleflag; /*!< invisible edge flag, code 70 */
|
||||
|
@ -579,8 +513,7 @@ class DRW_Block : public DRW_Point {
|
|||
public:
|
||||
DRW_Block()
|
||||
: name("*U0"),
|
||||
flags(0),
|
||||
isEnd(false)
|
||||
flags(0)
|
||||
{
|
||||
eType = DRW::BLOCK;
|
||||
layer = "0";
|
||||
|
@ -590,13 +523,10 @@ public:
|
|||
|
||||
protected:
|
||||
void parseCode(int code, dxfReader *reader);
|
||||
virtual bool parseDwg(DRW::Version version, dwgBuffer *buf, duint32 bs=0);
|
||||
|
||||
public:
|
||||
UTF8STRING name; /*!< block name, code 2 */
|
||||
int flags; /*!< block type, code 70 */
|
||||
private:
|
||||
bool isEnd; //for dwg parsing
|
||||
};
|
||||
|
||||
|
||||
|
@ -617,9 +547,7 @@ public:
|
|||
colcount(1),
|
||||
rowcount(1),
|
||||
colspace(0),
|
||||
rowspace(0),
|
||||
blockRecH(),
|
||||
seqendH()
|
||||
rowspace(0)
|
||||
{
|
||||
eType = DRW::INSERT;
|
||||
}
|
||||
|
@ -628,7 +556,6 @@ public:
|
|||
|
||||
protected:
|
||||
void parseCode(int code, dxfReader *reader);
|
||||
virtual bool parseDwg(DRW::Version version, dwgBuffer *buf, duint32 bs=0);
|
||||
|
||||
public:
|
||||
UTF8STRING name; /*!< block name, code 2 */
|
||||
|
@ -640,9 +567,6 @@ public:
|
|||
int rowcount; /*!< row count, code 71 */
|
||||
double colspace; /*!< column space, code 44 */
|
||||
double rowspace; /*!< row space, code 45 */
|
||||
public: //only for read dwg
|
||||
dwgHandle blockRecH;
|
||||
dwgHandle seqendH; //RLZ: on implement attrib remove this handle from obj list (see pline/vertex code)
|
||||
};
|
||||
|
||||
//! Class to handle lwpolyline entity
|
||||
|
@ -706,7 +630,6 @@ public:
|
|||
|
||||
protected:
|
||||
void parseCode(int code, dxfReader *reader);
|
||||
bool parseDwg(DRW::Version version, dwgBuffer *buf, duint32 bs=0);
|
||||
|
||||
public:
|
||||
int vertexnum; /*!< number of vertex, code 90 */
|
||||
|
@ -756,8 +679,7 @@ public:
|
|||
style("STANDARD"),
|
||||
textgen(0),
|
||||
alignH(HLeft),
|
||||
alignV(VBaseLine),
|
||||
styleH()
|
||||
alignV(VBaseLine)
|
||||
{
|
||||
eType = DRW::TEXT;
|
||||
}
|
||||
|
@ -766,7 +688,6 @@ public:
|
|||
|
||||
protected:
|
||||
void parseCode(int code, dxfReader *reader);
|
||||
virtual bool parseDwg(DRW::Version version, dwgBuffer *buf, duint32 bs=0);
|
||||
|
||||
public:
|
||||
double height; /*!< height text, code 40 */
|
||||
|
@ -778,7 +699,6 @@ public:
|
|||
int textgen; /*!< text generation, code 71 */
|
||||
enum HAlign alignH; /*!< horizontal align, code 72 */
|
||||
enum VAlign alignV; /*!< vertical align, code 73 */
|
||||
dwgHandle styleH; /*!< handle for text style */
|
||||
};
|
||||
|
||||
//! Class to handle insert entries
|
||||
|
@ -814,7 +734,6 @@ public:
|
|||
protected:
|
||||
void parseCode(int code, dxfReader *reader);
|
||||
void updateAngle(); //recalculate angle if 'haveXAxis' is true
|
||||
virtual bool parseDwg(DRW::Version version, dwgBuffer *buf, duint32 bs=0);
|
||||
|
||||
public:
|
||||
double interlin; /*!< width factor, code 44 */
|
||||
|
@ -864,9 +783,6 @@ public:
|
|||
|
||||
protected:
|
||||
void parseCode(int code, dxfReader *reader);
|
||||
bool parseDwg(DRW::Version version, dwgBuffer *buf, duint32 bs=0, double el=0);
|
||||
virtual bool parseDwg(DRW::Version version, dwgBuffer* buf, duint32 bs=0){
|
||||
DRW_UNUSED(version); DRW_UNUSED(buf); DRW_UNUSED(bs); return true;}
|
||||
|
||||
public:
|
||||
double stawidth; /*!< Start width, code 40 */
|
||||
|
@ -902,8 +818,7 @@ public:
|
|||
vertlist(),
|
||||
hadlesList(),
|
||||
firstEH(),
|
||||
lastEH(),
|
||||
seqEndH()
|
||||
lastEH()
|
||||
{
|
||||
eType = DRW::POLYLINE;
|
||||
basePoint.x = basePoint.y = 0.0;
|
||||
|
@ -922,8 +837,7 @@ public:
|
|||
vertlist(),
|
||||
hadlesList(),
|
||||
firstEH(),
|
||||
lastEH(),
|
||||
seqEndH()
|
||||
lastEH()
|
||||
{
|
||||
for (unsigned i=0; i<p.vertlist.size(); i++)// RLZ ok or new
|
||||
this->vertlist.push_back( new DRW_Vertex( *(p.vertlist.at(i)) ) );
|
||||
|
@ -948,7 +862,6 @@ public:
|
|||
|
||||
protected:
|
||||
void parseCode(int code, dxfReader *reader);
|
||||
virtual bool parseDwg(DRW::Version version, dwgBuffer *buf, duint32 bs=0);
|
||||
|
||||
public:
|
||||
int flags; /*!< polyline flag, code 70, default 0 */
|
||||
|
@ -967,7 +880,6 @@ private:
|
|||
std::list<duint32>hadlesList; //list of handles, only in 2004+
|
||||
duint32 firstEH; //handle of first entity, only in pre-2004
|
||||
duint32 lastEH; //handle of last entity, only in pre-2004
|
||||
dwgHandle seqEndH; //handle of SEQEND entity
|
||||
};
|
||||
|
||||
|
||||
|
@ -1037,7 +949,6 @@ public:
|
|||
|
||||
protected:
|
||||
void parseCode(int code, dxfReader *reader);
|
||||
virtual bool parseDwg(DRW::Version version, dwgBuffer *buf, duint32 bs=0);
|
||||
|
||||
public:
|
||||
// double ex; /*!< normal vector x coordinate, code 210 */
|
||||
|
@ -1068,7 +979,9 @@ public:
|
|||
|
||||
private:
|
||||
DRW_Spline &operator=(const DRW_Spline &) Q_DECL_EQ_DELETE;
|
||||
// cppcheck-suppress unsafeClassCanLeak
|
||||
DRW_Coord *controlpoint; /*!< current control point to add data */
|
||||
// cppcheck-suppress unsafeClassCanLeak
|
||||
DRW_Coord *fitpoint; /*!< current fit point to add data */
|
||||
};
|
||||
|
||||
|
@ -1150,7 +1063,6 @@ public:
|
|||
|
||||
protected:
|
||||
void parseCode(int code, dxfReader *reader);
|
||||
virtual bool parseDwg(DRW::Version version, dwgBuffer *buf, duint32 bs=0);
|
||||
|
||||
public:
|
||||
UTF8STRING name; /*!< hatch pattern name, code 2 */
|
||||
|
@ -1245,7 +1157,6 @@ public:
|
|||
|
||||
protected:
|
||||
void parseCode(int code, dxfReader *reader);
|
||||
virtual bool parseDwg(DRW::Version version, dwgBuffer *buf, duint32 bs=0);
|
||||
|
||||
public:
|
||||
duint32 ref; /*!< Hard reference to imagedef object, code 340 */
|
||||
|
@ -1294,9 +1205,7 @@ public:
|
|||
arcPoint(),
|
||||
length(0.0),
|
||||
hasActual(false),
|
||||
actual(0.0),
|
||||
dimStyleH(),
|
||||
blockH()
|
||||
actual(0.0)
|
||||
{
|
||||
eType = DRW::DIMENSION;
|
||||
}
|
||||
|
@ -1324,9 +1233,7 @@ public:
|
|||
arcPoint(d.arcPoint),
|
||||
length(d.length),
|
||||
hasActual(d.hasActual),
|
||||
actual(d.actual),
|
||||
dimStyleH(),
|
||||
blockH()
|
||||
actual(d.actual)
|
||||
{
|
||||
eType = DRW::DIMENSION;
|
||||
//RLZ needed a def value for this: hdir = ???
|
||||
|
@ -1337,9 +1244,6 @@ public:
|
|||
|
||||
protected:
|
||||
void parseCode(int code, dxfReader *reader);
|
||||
bool parseDwg(DRW::Version version, dwgBuffer *buf, dwgBuffer *sBuf);
|
||||
virtual bool parseDwg(DRW::Version version, dwgBuffer* buf, duint32 bs=0){
|
||||
DRW_UNUSED(version); DRW_UNUSED(buf); DRW_UNUSED(bs); return true;}
|
||||
|
||||
public:
|
||||
DRW_Coord getDefPoint() const {return defPoint;} /*!< Definition point, code 10, 20 & 30 */
|
||||
|
@ -1412,10 +1316,6 @@ private:
|
|||
double length; /*!< Leader length, code 40 */
|
||||
bool hasActual; /*!< Actual measurement has been read, code 42 */
|
||||
double actual; /*!< Actual measurement (optional; read-only value), code 42 */
|
||||
|
||||
protected:
|
||||
dwgHandle dimStyleH;
|
||||
dwgHandle blockH;
|
||||
};
|
||||
|
||||
|
||||
|
@ -1447,8 +1347,6 @@ public:
|
|||
DRW_Coord getDef2Point() const {return getPt4();} /*!< Definition point 2, code 14, 24 & 34 */
|
||||
void setDef2Point(const DRW_Coord &p) {setPt4(p);}
|
||||
|
||||
protected:
|
||||
virtual bool parseDwg(DRW::Version version, dwgBuffer *buf, duint32 bs=0);
|
||||
};
|
||||
|
||||
//! Class to handle linear or rotated dimension entity
|
||||
|
@ -1499,8 +1397,6 @@ public:
|
|||
double getLeaderLength() const {return getRa40();} /*!< Leader length, code 40 */
|
||||
void setLeaderLength(const double d) {setRa40(d);}
|
||||
|
||||
protected:
|
||||
virtual bool parseDwg(DRW::Version version, dwgBuffer *buf, duint32 bs=0);
|
||||
};
|
||||
|
||||
//! Class to handle radial dimension entity
|
||||
|
@ -1528,8 +1424,6 @@ public:
|
|||
double getLeaderLength() const {return getRa40();} /*!< Leader length, code 40 */
|
||||
void setLeaderLength(const double d) {setRa40(d);}
|
||||
|
||||
protected:
|
||||
virtual bool parseDwg(DRW::Version version, dwgBuffer *buf, duint32 bs=0);
|
||||
};
|
||||
|
||||
//! Class to handle angular dimension entity
|
||||
|
@ -1560,8 +1454,6 @@ public:
|
|||
DRW_Coord getDimPoint() const {return getPt6();} /*!< Dimension definition point, code 16, 26 & 36 */
|
||||
void setDimPoint(const DRW_Coord &p) {setPt6(p);}
|
||||
|
||||
protected:
|
||||
virtual bool parseDwg(DRW::Version version, dwgBuffer *buf, duint32 bs=0);
|
||||
};
|
||||
|
||||
|
||||
|
@ -1591,8 +1483,6 @@ public:
|
|||
DRW_Coord getDimPoint() const {return getDefPoint();} /*!< Dimension definition point, code 10, 20 & 30 */
|
||||
void setDimPoint(const DRW_Coord &p) {setDefPoint(p);}
|
||||
|
||||
protected:
|
||||
virtual bool parseDwg(DRW::Version version, dwgBuffer *buf, duint32 bs=0);
|
||||
};
|
||||
|
||||
//! Class to handle ordinate dimension entity
|
||||
|
@ -1620,8 +1510,6 @@ public:
|
|||
DRW_Coord getSecondLine() const {return getPt4();} /*!< Leader end point, code 14, 24 & 34 */
|
||||
void setSecondLine(const DRW_Coord &p) {setPt4(p);}
|
||||
|
||||
protected:
|
||||
virtual bool parseDwg(DRW::Version version, dwgBuffer *buf, duint32 bs=0);
|
||||
};
|
||||
|
||||
|
||||
|
@ -1650,9 +1538,7 @@ public:
|
|||
offsetblock(),
|
||||
offsettext(),
|
||||
vertexlist(),
|
||||
vertexpoint(),
|
||||
dimStyleH(),
|
||||
AnnotH()
|
||||
vertexpoint()
|
||||
{
|
||||
eType = DRW::LEADER;
|
||||
}
|
||||
|
@ -1664,7 +1550,6 @@ public:
|
|||
|
||||
protected:
|
||||
void parseCode(int code, dxfReader *reader);
|
||||
virtual bool parseDwg(DRW::Version version, dwgBuffer *buf, duint32 bs=0);
|
||||
|
||||
public:
|
||||
UTF8STRING style; /*!< Dimension style name, code 3 */
|
||||
|
@ -1687,9 +1572,8 @@ public:
|
|||
|
||||
private:
|
||||
Q_DISABLE_COPY(DRW_Leader)
|
||||
// cppcheck-suppress unsafeClassCanLeak
|
||||
DRW_Coord *vertexpoint; /*!< current control point to add data */
|
||||
dwgHandle dimStyleH;
|
||||
dwgHandle AnnotH;
|
||||
};
|
||||
|
||||
//! Class to handle viewport entity
|
||||
|
@ -1728,7 +1612,6 @@ public:
|
|||
|
||||
protected:
|
||||
void parseCode(int code, dxfReader *reader);
|
||||
virtual bool parseDwg(DRW::Version version, dwgBuffer *buf, duint32 bs=0);
|
||||
|
||||
public:
|
||||
double pswidth; /*!< Width in paper space units, code 40 */
|
||||
|
|
|
@ -14,7 +14,6 @@
|
|||
#include "intern/dxfreader.h"
|
||||
#include "intern/dxfwriter.h"
|
||||
#include "intern/drw_dbg.h"
|
||||
#include "intern/dwgbuffer.h"
|
||||
|
||||
DRW_Header::DRW_Header()
|
||||
: vars(),
|
||||
|
@ -1797,699 +1796,3 @@ bool DRW_Header::getCoord(std::string key, DRW_Coord *varCoord){
|
|||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
bool DRW_Header::parseDwg(DRW::Version version, dwgBuffer *buf, dwgBuffer *hBbuf, duint8 mv){
|
||||
bool result = true;
|
||||
duint32 size = buf->getRawLong32();
|
||||
duint32 endBitPos = 160; //start bit: 16 sentinel + 4 size
|
||||
DRW_DBG("\nbyte size of data: "); DRW_DBG(size);
|
||||
if (version > DRW::AC1021 && mv > 3) { //2010+
|
||||
duint32 hSize = buf->getRawLong32();
|
||||
endBitPos += 32; //start bit: + 4 hight size
|
||||
DRW_DBG("\n2010+ & MV> 3, higth 32b: "); DRW_DBG(hSize);
|
||||
}
|
||||
//RLZ TODO add $ACADVER var & $DWGCODEPAGE & $MEASUREMENT
|
||||
//RLZ TODO EN 2000 falta $CELWEIGHT, $ENDCAPS, $EXTNAMES $JOINSTYLE $LWDISPLAY $PSTYLEMODE $TDUCREATE $TDUUPDATE $XEDIT
|
||||
|
||||
//bit size of data needed to locate start of string stream in 2007+
|
||||
//and mark the start of handle stream
|
||||
//header is one object reads data and continue read strings ???
|
||||
if (version > DRW::AC1018) {//2007+
|
||||
duint32 bitSize = buf->getRawLong32();
|
||||
DRW_DBG("\nsize in bits: "); DRW_DBG(bitSize);
|
||||
endBitPos += bitSize;
|
||||
hBbuf->setPosition(endBitPos >>3);
|
||||
hBbuf->setBitPos(endBitPos&7);
|
||||
}
|
||||
|
||||
if (version > DRW::AC1024) {//2013+
|
||||
duint64 requiredVersions = buf->getBitLongLong();
|
||||
DRW_DBG("\nREQUIREDVERSIONS var: "); DRW_DBG(requiredVersions);
|
||||
}
|
||||
DRW_DBG("\nUnknown1: "); DRW_DBG(buf->getBitDouble());
|
||||
DRW_DBG("\nUnknown2: "); DRW_DBG(buf->getBitDouble());
|
||||
DRW_DBG("\nUnknown3: "); DRW_DBG(buf->getBitDouble());
|
||||
DRW_DBG("\nUnknown4: "); DRW_DBG(buf->getBitDouble());
|
||||
if (version < DRW::AC1021) {//2007-
|
||||
DRW_DBG("\nUnknown text1: "); DRW_DBG(buf->getCP8Text());
|
||||
DRW_DBG("\nUnknown text2: "); DRW_DBG(buf->getCP8Text());
|
||||
DRW_DBG("\nUnknown text3: "); DRW_DBG(buf->getCP8Text());
|
||||
DRW_DBG("\nUnknown text4: "); DRW_DBG(buf->getCP8Text());
|
||||
}
|
||||
DRW_DBG("\nUnknown long1 (24L): "); DRW_DBG(buf->getBitLong());
|
||||
DRW_DBG("\nUnknown long2 (0L): "); DRW_DBG(buf->getBitLong());
|
||||
if (version < DRW::AC1015) {//pre 2000
|
||||
DRW_DBG("\nUnknown short (0): "); DRW_DBG(buf->getBitShort());
|
||||
}
|
||||
if (version < DRW::AC1018) {//pre 2004
|
||||
dwgHandle hcv = hBbuf->getHandle();
|
||||
DRW_DBG("\nhandle of current view: "); DRW_DBGHL(hcv.code, hcv.size, hcv.ref);
|
||||
}
|
||||
vars["DIMASO"]=new DRW_Variant(70, buf->getBit());
|
||||
vars["DIMSHO"]=new DRW_Variant(70, buf->getBit());
|
||||
if (version < DRW::AC1015) {//pre 2000
|
||||
vars["DIMSAV"]=new DRW_Variant(70, buf->getBit());
|
||||
}
|
||||
vars["PLINEGEN"]=new DRW_Variant(70, buf->getBit());
|
||||
vars["ORTHOMODE"]=new DRW_Variant(70, buf->getBit());
|
||||
vars["REGENMODE"]=new DRW_Variant(70, buf->getBit());
|
||||
vars["FILLMODE"]=new DRW_Variant(70, buf->getBit());
|
||||
vars["QTEXTMODE"]=new DRW_Variant(70, buf->getBit());
|
||||
vars["PSLTSCALE"]=new DRW_Variant(70, buf->getBit());
|
||||
vars["LIMCHECK"]=new DRW_Variant(70, buf->getBit());
|
||||
if (version < DRW::AC1015) {//pre 2000
|
||||
vars["BLIPMODE"]=new DRW_Variant(70, buf->getBit());
|
||||
}
|
||||
if (version > DRW::AC1015) {//2004+
|
||||
DRW_DBG("\nUndocumented: "); DRW_DBG(buf->getBit());
|
||||
}
|
||||
vars["USRTIMER"]=new DRW_Variant(70, buf->getBit());
|
||||
vars["SKPOLY"]=new DRW_Variant(70, buf->getBit());
|
||||
vars["ANGDIR"]=new DRW_Variant(70, buf->getBit());
|
||||
vars["SPLFRAME"]=new DRW_Variant(70, buf->getBit());
|
||||
if (version < DRW::AC1015) {//pre 2000
|
||||
vars["ATTREQ"]=new DRW_Variant(70, buf->getBit());
|
||||
vars["ATTDIA"]=new DRW_Variant(70, buf->getBit());
|
||||
}
|
||||
vars["MIRRTEXT"]=new DRW_Variant(70, buf->getBit());
|
||||
vars["WORLDVIEW"]=new DRW_Variant(70, buf->getBit());
|
||||
if (version < DRW::AC1015) {//pre 2000
|
||||
vars["WIREFRAME"]=new DRW_Variant(70, buf->getBit());
|
||||
}
|
||||
vars["TILEMODE"]=new DRW_Variant(70, buf->getBit());
|
||||
vars["PLIMCHECK"]=new DRW_Variant(70, buf->getBit());
|
||||
vars["VISRETAIN"]=new DRW_Variant(70, buf->getBit());
|
||||
if (version < DRW::AC1015) {//pre 2000
|
||||
vars["DELOBJ"]=new DRW_Variant(70, buf->getBit());
|
||||
}
|
||||
vars["DISPSILH"]=new DRW_Variant(70, buf->getBit());
|
||||
vars["PELLIPSE"]=new DRW_Variant(70, buf->getBit());
|
||||
vars["PROXIGRAPHICS"]=new DRW_Variant(70, buf->getBitShort());//RLZ short or bit??
|
||||
if (version < DRW::AC1015) {//pre 2000
|
||||
vars["DRAGMODE"]=new DRW_Variant(70, buf->getBitShort());//RLZ short or bit??
|
||||
}
|
||||
vars["TREEDEPTH"]=new DRW_Variant(70, buf->getBitShort());//RLZ short or bit??
|
||||
vars["LUNITS"]=new DRW_Variant(70, buf->getBitShort());
|
||||
vars["LUPREC"]=new DRW_Variant(70, buf->getBitShort());
|
||||
vars["AUNITS"]=new DRW_Variant(70, buf->getBitShort());
|
||||
vars["AUPREC"]=new DRW_Variant(70, buf->getBitShort());
|
||||
if (version < DRW::AC1015) {//pre 2000
|
||||
vars["OSMODE"]=new DRW_Variant(70, buf->getBitShort());
|
||||
}
|
||||
vars["ATTMODE"]=new DRW_Variant(70, buf->getBitShort());
|
||||
if (version < DRW::AC1015) {//pre 2000
|
||||
vars["COORDS"]=new DRW_Variant(70, buf->getBitShort());
|
||||
}
|
||||
vars["PDMODE"]=new DRW_Variant(70, buf->getBitShort());
|
||||
if (version < DRW::AC1015) {//pre 2000
|
||||
vars["PICKSTYLE"]=new DRW_Variant(70, buf->getBitShort());
|
||||
}
|
||||
if (version > DRW::AC1015) {//2004+
|
||||
DRW_DBG("\nUnknown long 1: "); DRW_DBG(buf->getBitLong());
|
||||
DRW_DBG("\nUnknown long 2: "); DRW_DBG(buf->getBitLong());
|
||||
DRW_DBG("\nUnknown long 3: "); DRW_DBG(buf->getBitLong());
|
||||
}
|
||||
vars["USERI1"]=new DRW_Variant(70, buf->getBitShort());
|
||||
vars["USERI2"]=new DRW_Variant(70, buf->getBitShort());
|
||||
vars["USERI3"]=new DRW_Variant(70, buf->getBitShort());
|
||||
vars["USERI4"]=new DRW_Variant(70, buf->getBitShort());
|
||||
vars["USERI5"]=new DRW_Variant(70, buf->getBitShort());
|
||||
vars["SPLINESEGS"]=new DRW_Variant(70, buf->getBitShort());
|
||||
vars["SURFU"]=new DRW_Variant(70, buf->getBitShort());
|
||||
vars["SURFV"]=new DRW_Variant(70, buf->getBitShort());
|
||||
vars["SURFTYPE"]=new DRW_Variant(70, buf->getBitShort());
|
||||
vars["SURFTAB1"]=new DRW_Variant(70, buf->getBitShort());
|
||||
vars["SURFTAB2"]=new DRW_Variant(70, buf->getBitShort());
|
||||
vars["SPLINETYPE"]=new DRW_Variant(70, buf->getBitShort());
|
||||
vars["SHADEDGE"]=new DRW_Variant(70, buf->getBitShort());
|
||||
vars["SHADEDIF"]=new DRW_Variant(70, buf->getBitShort());
|
||||
vars["UNITMODE"]=new DRW_Variant(70, buf->getBitShort());
|
||||
vars["MAXACTVP"]=new DRW_Variant(70, buf->getBitShort());
|
||||
vars["ISOLINES"]=new DRW_Variant(70, buf->getBitShort());//////////////////
|
||||
vars["CMLJUST"]=new DRW_Variant(70, buf->getBitShort());
|
||||
vars["TEXTQLTY"]=new DRW_Variant(70, buf->getBitShort());/////////////////////
|
||||
vars["LTSCALE"]=new DRW_Variant(40, buf->getBitDouble());
|
||||
vars["TEXTSIZE"]=new DRW_Variant(40, buf->getBitDouble());
|
||||
vars["TRACEWID"]=new DRW_Variant(40, buf->getBitDouble());
|
||||
vars["SKETCHINC"]=new DRW_Variant(40, buf->getBitDouble());
|
||||
vars["FILLETRAD"]=new DRW_Variant(40, buf->getBitDouble());
|
||||
vars["THICKNESS"]=new DRW_Variant(40, buf->getBitDouble());
|
||||
vars["ANGBASE"]=new DRW_Variant(50, buf->getBitDouble());
|
||||
vars["PDSIZE"]=new DRW_Variant(40, buf->getBitDouble());
|
||||
vars["PLINEWID"]=new DRW_Variant(40, buf->getBitDouble());
|
||||
vars["USERR1"]=new DRW_Variant(40, buf->getBitDouble());
|
||||
vars["USERR2"]=new DRW_Variant(40, buf->getBitDouble());
|
||||
vars["USERR3"]=new DRW_Variant(40, buf->getBitDouble());
|
||||
vars["USERR4"]=new DRW_Variant(40, buf->getBitDouble());
|
||||
vars["USERR5"]=new DRW_Variant(40, buf->getBitDouble());
|
||||
vars["CHAMFERA"]=new DRW_Variant(40, buf->getBitDouble());
|
||||
vars["CHAMFERB"]=new DRW_Variant(40, buf->getBitDouble());
|
||||
vars["CHAMFERC"]=new DRW_Variant(40, buf->getBitDouble());
|
||||
vars["CHAMFERD"]=new DRW_Variant(40, buf->getBitDouble());
|
||||
vars["FACETRES"]=new DRW_Variant(40, buf->getBitDouble());/////////////////////////
|
||||
vars["CMLSCALE"]=new DRW_Variant(40, buf->getBitDouble());
|
||||
vars["CELTSCALE"]=new DRW_Variant(40, buf->getBitDouble());
|
||||
if (version < DRW::AC1021) {//2004-
|
||||
vars["MENU"]=new DRW_Variant(1, buf->getCP8Text());
|
||||
}
|
||||
ddouble64 msec, day;
|
||||
day = buf->getBitLong();
|
||||
msec = buf->getBitLong();
|
||||
while (msec > 0)
|
||||
msec /=10;
|
||||
vars["TDCREATE"]=new DRW_Variant(40, day+msec);//RLZ: TODO convert to day.msec
|
||||
// vars["TDCREATE"]=new DRW_Variant(40, buf->getBitLong());//RLZ: TODO convert to day.msec
|
||||
// vars["TDCREATE"]=new DRW_Variant(40, buf->getBitLong());
|
||||
day = buf->getBitLong();
|
||||
msec = buf->getBitLong();
|
||||
while (msec > 0)
|
||||
msec /=10;
|
||||
vars["TDUPDATE"]=new DRW_Variant(40, day+msec);//RLZ: TODO convert to day.msec
|
||||
// vars["TDUPDATE"]=new DRW_Variant(40, buf->getBitLong());//RLZ: TODO convert to day.msec
|
||||
// vars["TDUPDATE"]=new DRW_Variant(40, buf->getBitLong());
|
||||
if (version > DRW::AC1015) {//2004+
|
||||
DRW_DBG("\nUnknown long 4: "); DRW_DBG(buf->getBitLong());
|
||||
DRW_DBG("\nUnknown long 5: "); DRW_DBG(buf->getBitLong());
|
||||
DRW_DBG("\nUnknown long 6: "); DRW_DBG(buf->getBitLong());
|
||||
}
|
||||
day = buf->getBitLong();
|
||||
msec = buf->getBitLong();
|
||||
while (msec > 0)
|
||||
msec /=10;
|
||||
vars["TDINDWG"]=new DRW_Variant(40, day+msec);//RLZ: TODO convert to day.msec
|
||||
// vars["TDINDWG"]=new DRW_Variant(40, buf->getBitLong());//RLZ: TODO convert to day.msec
|
||||
// vars["TDINDWG"]=new DRW_Variant(40, buf->getBitLong());//RLZ: TODO convert to day.msec
|
||||
day = buf->getBitLong();
|
||||
msec = buf->getBitLong();
|
||||
while (msec > 0)
|
||||
msec /=10;
|
||||
vars["TDUSRTIMER"]=new DRW_Variant(40, day+msec);//RLZ: TODO convert to day.msec
|
||||
// vars["TDUSRTIMER"]=new DRW_Variant(40, buf->getBitLong());//RLZ: TODO convert to day.msec
|
||||
// vars["TDUSRTIMER"]=new DRW_Variant(40, buf->getBitLong());//RLZ: TODO convert to day.msec
|
||||
vars["CECOLOR"]=new DRW_Variant(62, buf->getCmColor(version));//RLZ: TODO read CMC or EMC color
|
||||
dwgHandle HANDSEED = buf->getHandle();//allways present in data stream
|
||||
DRW_DBG("\nHANDSEED: "); DRW_DBGHL(HANDSEED.code, HANDSEED.size, HANDSEED.ref);
|
||||
dwgHandle CLAYER = hBbuf->getHandle();
|
||||
DRW_DBG("\nCLAYER: "); DRW_DBGHL(CLAYER.code, CLAYER.size, CLAYER.ref);
|
||||
dwgHandle TEXTSTYLE = hBbuf->getHandle();
|
||||
DRW_DBG("\nTEXTSTYLE: "); DRW_DBGHL(TEXTSTYLE.code, TEXTSTYLE.size, TEXTSTYLE.ref);
|
||||
dwgHandle CELTYPE = hBbuf->getHandle();
|
||||
DRW_DBG("\nCELTYPE: "); DRW_DBGHL(CELTYPE.code, CELTYPE.size, CELTYPE.ref);
|
||||
if (version > DRW::AC1018) {//2007+
|
||||
dwgHandle CMATERIAL = hBbuf->getHandle();
|
||||
DRW_DBG("\nCMATERIAL: "); DRW_DBGHL(CMATERIAL.code, CMATERIAL.size, CMATERIAL.ref);
|
||||
}
|
||||
dwgHandle DIMSTYLE = hBbuf->getHandle();
|
||||
DRW_DBG("\nDIMSTYLE: "); DRW_DBGHL(DIMSTYLE.code, DIMSTYLE.size, DIMSTYLE.ref);
|
||||
dwgHandle CMLSTYLE = hBbuf->getHandle();
|
||||
DRW_DBG("\nCMLSTYLE: "); DRW_DBGHL(CMLSTYLE.code, CMLSTYLE.size, CMLSTYLE.ref);
|
||||
if (version > DRW::AC1014) {//2000+
|
||||
vars["PSVPSCALE"]=new DRW_Variant(40, buf->getBitDouble());
|
||||
}
|
||||
vars["PINSBASE"]=new DRW_Variant(10, buf->get3BitDouble());
|
||||
vars["PEXTMIN"]=new DRW_Variant(10, buf->get3BitDouble());
|
||||
vars["PEXTMAX"]=new DRW_Variant(10, buf->get3BitDouble());
|
||||
vars["PLIMMIN"]=new DRW_Variant(10, buf->get2RawDouble());
|
||||
vars["PLIMMAX"]=new DRW_Variant(10, buf->get2RawDouble());
|
||||
vars["PELEVATION"]=new DRW_Variant(40, buf->getBitDouble());
|
||||
vars["PUCSORG"]=new DRW_Variant(10, buf->get3BitDouble());
|
||||
vars["PUCSXDIR"]=new DRW_Variant(10, buf->get3BitDouble());
|
||||
vars["PUCSYDIR"]=new DRW_Variant(10, buf->get3BitDouble());
|
||||
dwgHandle PUCSNAME = hBbuf->getHandle();
|
||||
DRW_DBG("\nPUCSNAME: "); DRW_DBGHL(PUCSNAME.code, PUCSNAME.size, PUCSNAME.ref);
|
||||
if (version > DRW::AC1014) {//2000+
|
||||
dwgHandle PUCSORTHOREF = hBbuf->getHandle();
|
||||
DRW_DBG("\nPUCSORTHOREF: "); DRW_DBGHL(PUCSORTHOREF.code, PUCSORTHOREF.size, PUCSORTHOREF.ref);
|
||||
vars["PUCSORTHOVIEW"]=new DRW_Variant(70, buf->getBitShort());
|
||||
dwgHandle PUCSBASE = hBbuf->getHandle();
|
||||
DRW_DBG("\nPUCSBASE: "); DRW_DBGHL(PUCSBASE.code, PUCSBASE.size, PUCSBASE.ref);
|
||||
vars["PUCSORGTOP"]=new DRW_Variant(10, buf->get3BitDouble());
|
||||
vars["PUCSORGBOTTOM"]=new DRW_Variant(10, buf->get3BitDouble());
|
||||
vars["PUCSORGLEFT"]=new DRW_Variant(10, buf->get3BitDouble());
|
||||
vars["PUCSORGRIGHT"]=new DRW_Variant(10, buf->get3BitDouble());
|
||||
vars["PUCSORGFRONT"]=new DRW_Variant(10, buf->get3BitDouble());
|
||||
vars["PUCSORGBACK"]=new DRW_Variant(10, buf->get3BitDouble());
|
||||
}
|
||||
vars["INSBASE"]=new DRW_Variant(10, buf->get3BitDouble());
|
||||
vars["EXTMIN"]=new DRW_Variant(10, buf->get3BitDouble());
|
||||
vars["EXTMAX"]=new DRW_Variant(10, buf->get3BitDouble());
|
||||
vars["LIMMIN"]=new DRW_Variant(10, buf->get2RawDouble());
|
||||
vars["LIMMAX"]=new DRW_Variant(10, buf->get2RawDouble());
|
||||
vars["ELEVATION"]=new DRW_Variant(40, buf->getBitDouble());
|
||||
vars["UCSORG"]=new DRW_Variant(10, buf->get3BitDouble());
|
||||
vars["UCSXDIR"]=new DRW_Variant(10, buf->get3BitDouble());
|
||||
vars["UCSYDIR"]=new DRW_Variant(10, buf->get3BitDouble());
|
||||
dwgHandle UCSNAME = hBbuf->getHandle();
|
||||
DRW_DBG("\nUCSNAME: "); DRW_DBGHL(UCSNAME.code, UCSNAME.size, UCSNAME.ref);
|
||||
if (version > DRW::AC1014) {//2000+
|
||||
dwgHandle UCSORTHOREF = hBbuf->getHandle();
|
||||
DRW_DBG("\nUCSORTHOREF: "); DRW_DBGHL(UCSORTHOREF.code, UCSORTHOREF.size, UCSORTHOREF.ref);
|
||||
vars["UCSORTHOVIEW"]=new DRW_Variant(70, buf->getBitShort());
|
||||
dwgHandle UCSBASE = hBbuf->getHandle();
|
||||
DRW_DBG("\nUCSBASE: "); DRW_DBGHL(UCSBASE.code, UCSBASE.size, UCSBASE.ref);
|
||||
vars["UCSORGTOP"]=new DRW_Variant(10, buf->get3BitDouble());
|
||||
vars["UCSORGBOTTOM"]=new DRW_Variant(10, buf->get3BitDouble());
|
||||
vars["UCSORGLEFT"]=new DRW_Variant(10, buf->get3BitDouble());
|
||||
vars["UCSORGRIGHT"]=new DRW_Variant(10, buf->get3BitDouble());
|
||||
vars["UCSORGFRONT"]=new DRW_Variant(10, buf->get3BitDouble());
|
||||
vars["UCSORGBACK"]=new DRW_Variant(10, buf->get3BitDouble());
|
||||
if (version < DRW::AC1021) {//2004-
|
||||
vars["DIMPOST"]=new DRW_Variant(1, buf->getCP8Text());
|
||||
vars["DIMAPOST"]=new DRW_Variant(1, buf->getCP8Text());
|
||||
}
|
||||
}
|
||||
if (version < DRW::AC1015) {//r14-
|
||||
vars["DIMTOL"]=new DRW_Variant(70, buf->getBit());
|
||||
vars["DIMLIM"]=new DRW_Variant(70, buf->getBit());
|
||||
vars["DIMTIH"]=new DRW_Variant(70, buf->getBit());
|
||||
vars["DIMTOH"]=new DRW_Variant(70, buf->getBit());
|
||||
vars["DIMSE1"]=new DRW_Variant(70, buf->getBit());
|
||||
vars["DIMSE2"]=new DRW_Variant(70, buf->getBit());
|
||||
vars["DIMALT"]=new DRW_Variant(70, buf->getBit());
|
||||
vars["DIMTOFL"]=new DRW_Variant(70, buf->getBit());
|
||||
vars["DIMSAH"]=new DRW_Variant(70, buf->getBit());
|
||||
vars["DIMTIX"]=new DRW_Variant(70, buf->getBit());
|
||||
vars["DIMSOXD"]=new DRW_Variant(70, buf->getBit());
|
||||
vars["DIMALTD"]=new DRW_Variant(70, buf->getRawChar8());
|
||||
vars["DIMZIN"]=new DRW_Variant(70, buf->getRawChar8());
|
||||
vars["DIMSD1"]=new DRW_Variant(70, buf->getBit());
|
||||
vars["DIMSD2"]=new DRW_Variant(70, buf->getBit());
|
||||
vars["DIMTOLJ"]=new DRW_Variant(70, buf->getRawChar8());
|
||||
vars["DIMJUST"]=new DRW_Variant(70, buf->getRawChar8());
|
||||
vars["DIMFIT"]=new DRW_Variant(70, buf->getRawChar8());///////////
|
||||
vars["DIMUPT"]=new DRW_Variant(70, buf->getBit());
|
||||
vars["DIMTZIN"]=new DRW_Variant(70, buf->getRawChar8());
|
||||
vars["DIMALTZ"]=new DRW_Variant(70, buf->getRawChar8());
|
||||
vars["DIMALTTZ"]=new DRW_Variant(70, buf->getRawChar8());
|
||||
vars["DIMTAD"]=new DRW_Variant(70, buf->getRawChar8());
|
||||
vars["DIMUNIT"]=new DRW_Variant(70, buf->getBitShort());///////////
|
||||
vars["DIMAUNIT"]=new DRW_Variant(70, buf->getBitShort());
|
||||
vars["DIMDEC"]=new DRW_Variant(70, buf->getBitShort());
|
||||
vars["DIMTDEC"]=new DRW_Variant(70, buf->getBitShort());
|
||||
vars["DIMALTU"]=new DRW_Variant(70, buf->getBitShort());
|
||||
vars["DIMALTTD"]=new DRW_Variant(70, buf->getBitShort());
|
||||
dwgHandle DIMTXSTY = hBbuf->getHandle();
|
||||
DRW_DBG("\nDIMTXSTY: "); DRW_DBGHL(DIMTXSTY.code, DIMTXSTY.size, DIMTXSTY.ref);
|
||||
}
|
||||
vars["DIMSCALE"]=new DRW_Variant(40, buf->getBitDouble());
|
||||
vars["DIMASZ"]=new DRW_Variant(40, buf->getBitDouble());
|
||||
vars["DIMEXO"]=new DRW_Variant(40, buf->getBitDouble());
|
||||
vars["DIMDLI"]=new DRW_Variant(40, buf->getBitDouble());
|
||||
vars["DIMEXE"]=new DRW_Variant(40, buf->getBitDouble());
|
||||
vars["DIMRND"]=new DRW_Variant(40, buf->getBitDouble());
|
||||
vars["DIMDLE"]=new DRW_Variant(40, buf->getBitDouble());
|
||||
vars["DIMTP"]=new DRW_Variant(40, buf->getBitDouble());
|
||||
vars["DIMTM"]=new DRW_Variant(40, buf->getBitDouble());
|
||||
if (version > DRW::AC1018) {//2007+
|
||||
vars["DIMFXL"]=new DRW_Variant(40, buf->getBitDouble());//////////////////
|
||||
vars["DIMJOGANG"]=new DRW_Variant(40, buf->getBitDouble());///////////////
|
||||
vars["DIMTFILL"]=new DRW_Variant(70, buf->getBitShort());
|
||||
vars["DIMTFILLCLR"]=new DRW_Variant(62, buf->getCmColor(version));
|
||||
}
|
||||
if (version > DRW::AC1014) {//2000+
|
||||
vars["DIMTOL"]=new DRW_Variant(70, buf->getBit());
|
||||
vars["DIMLIM"]=new DRW_Variant(70, buf->getBit());
|
||||
vars["DIMTIH"]=new DRW_Variant(70, buf->getBit());
|
||||
vars["DIMTOH"]=new DRW_Variant(70, buf->getBit());
|
||||
vars["DIMSE1"]=new DRW_Variant(70, buf->getBit());
|
||||
vars["DIMSE2"]=new DRW_Variant(70, buf->getBit());
|
||||
vars["DIMTAD"]=new DRW_Variant(70, buf->getBitShort());
|
||||
vars["DIMZIN"]=new DRW_Variant(70, buf->getBitShort());
|
||||
vars["DIMAZIN"]=new DRW_Variant(70, buf->getBitShort());
|
||||
}
|
||||
if (version > DRW::AC1018) {//2007+
|
||||
vars["DIMARCSYM"]=new DRW_Variant(70, buf->getBitShort());
|
||||
}
|
||||
vars["DIMTXT"]=new DRW_Variant(40, buf->getBitDouble());
|
||||
vars["DIMCEN"]=new DRW_Variant(40, buf->getBitDouble());
|
||||
vars["DIMTSZ"]=new DRW_Variant(40, buf->getBitDouble());
|
||||
vars["DIMALTF"]=new DRW_Variant(40, buf->getBitDouble());
|
||||
vars["DIMLFAC"]=new DRW_Variant(40, buf->getBitDouble());
|
||||
vars["DIMTVP"]=new DRW_Variant(40, buf->getBitDouble());
|
||||
vars["DIMTFAC"]=new DRW_Variant(40, buf->getBitDouble());
|
||||
vars["DIMGAP"]=new DRW_Variant(40, buf->getBitDouble());
|
||||
if (version < DRW::AC1015) {//r14-
|
||||
vars["DIMPOST"]=new DRW_Variant(1, buf->getCP8Text());
|
||||
vars["DIMAPOST"]=new DRW_Variant(1, buf->getCP8Text());
|
||||
vars["DIMBLK"]=new DRW_Variant(1, buf->getCP8Text());
|
||||
vars["DIMBLK1"]=new DRW_Variant(1, buf->getCP8Text());
|
||||
vars["DIMBLK2"]=new DRW_Variant(1, buf->getCP8Text());
|
||||
}
|
||||
if (version > DRW::AC1014) {//2000+
|
||||
vars["DIMALTRND"]=new DRW_Variant(40, buf->getBitDouble());
|
||||
vars["DIMALT"]=new DRW_Variant(70, buf->getBit());
|
||||
vars["DIMALTD"]=new DRW_Variant(70, buf->getBitShort());
|
||||
vars["DIMTOFL"]=new DRW_Variant(70, buf->getBit());
|
||||
vars["DIMSAH"]=new DRW_Variant(70, buf->getBit());
|
||||
vars["DIMTIX"]=new DRW_Variant(70, buf->getBit());
|
||||
vars["DIMSOXD"]=new DRW_Variant(70, buf->getBit());
|
||||
}
|
||||
vars["DIMCLRD"]=new DRW_Variant(70, buf->getCmColor(version));//RLZ: TODO read CMC or EMC color
|
||||
vars["DIMCLRE"]=new DRW_Variant(70, buf->getCmColor(version));//RLZ: TODO read CMC or EMC color
|
||||
vars["DIMCLRT"]=new DRW_Variant(70, buf->getCmColor(version));//RLZ: TODO read CMC or EMC color
|
||||
if (version > DRW::AC1014) {//2000+
|
||||
vars["DIAMDEC"]=new DRW_Variant(70, buf->getBitShort());
|
||||
vars["DIMDEC"]=new DRW_Variant(70, buf->getBitShort());
|
||||
vars["DIMTDEC"]=new DRW_Variant(70, buf->getBitShort());
|
||||
vars["DIMALTU"]=new DRW_Variant(70, buf->getBitShort());
|
||||
vars["DIMALTTD"]=new DRW_Variant(70, buf->getBitShort());
|
||||
vars["DIMAUNIT"]=new DRW_Variant(70, buf->getBitShort());
|
||||
vars["DIMFAC"]=new DRW_Variant(70, buf->getBitShort());///////////////// DIMFAC O DIMFRAC
|
||||
vars["DIMLUNIT"]=new DRW_Variant(70, buf->getBitShort());
|
||||
vars["DIMDSEP"]=new DRW_Variant(70, buf->getBitShort());
|
||||
vars["DIMTMOVE"]=new DRW_Variant(70, buf->getBitShort());
|
||||
vars["DIMJUST"]=new DRW_Variant(70, buf->getBitShort());
|
||||
vars["DIMSD1"]=new DRW_Variant(70, buf->getBit());
|
||||
vars["DIMSD2"]=new DRW_Variant(70, buf->getBit());
|
||||
vars["DIMTOLJ"]=new DRW_Variant(70, buf->getBitShort());
|
||||
vars["DIMTZIN"]=new DRW_Variant(70, buf->getBitShort());
|
||||
vars["DIMALTZ"]=new DRW_Variant(70, buf->getBitShort());
|
||||
vars["DIMALTTZ"]=new DRW_Variant(70, buf->getBitShort());
|
||||
vars["DIMUPT"]=new DRW_Variant(70, buf->getBit());
|
||||
vars["DIMATFIT"]=new DRW_Variant(70, buf->getBitShort());
|
||||
}
|
||||
if (version > DRW::AC1018) {//2007+
|
||||
vars["DIMFXLON"]=new DRW_Variant(70, buf->getBit());////////////////
|
||||
}
|
||||
if (version > DRW::AC1021) {//2010+
|
||||
vars["DIMTXTDIRECTION"]=new DRW_Variant(70, buf->getBit());////////////////
|
||||
vars["DIMALTMZF"]=new DRW_Variant(40, buf->getBitDouble());////////////////
|
||||
vars["DIMMZF"]=new DRW_Variant(40, buf->getBitDouble());////////////////
|
||||
}
|
||||
if (version > DRW::AC1014) {//2000+
|
||||
dwgHandle DIMTXSTY = hBbuf->getHandle();
|
||||
DRW_DBG("\nDIMTXSTY: "); DRW_DBGHL(DIMTXSTY.code, DIMTXSTY.size, DIMTXSTY.ref);
|
||||
dwgHandle DIMLDRBLK = hBbuf->getHandle();
|
||||
DRW_DBG("\nDIMLDRBLK: "); DRW_DBGHL(DIMLDRBLK.code, DIMLDRBLK.size, DIMLDRBLK.ref);
|
||||
dwgHandle DIMBLK = hBbuf->getHandle();
|
||||
DRW_DBG("\nDIMBLK: "); DRW_DBGHL(DIMBLK.code, DIMBLK.size, DIMBLK.ref);
|
||||
dwgHandle DIMBLK1 = hBbuf->getHandle();
|
||||
DRW_DBG("\nDIMBLK1: "); DRW_DBGHL(DIMBLK1.code, DIMBLK1.size, DIMBLK1.ref);
|
||||
dwgHandle DIMBLK2 = hBbuf->getHandle();
|
||||
DRW_DBG("\nDIMBLK2: "); DRW_DBGHL(DIMBLK2.code, DIMBLK2.size, DIMBLK2.ref);
|
||||
}
|
||||
if (version > DRW::AC1018) {//2007+
|
||||
dwgHandle DIMLTYPE = hBbuf->getHandle();
|
||||
DRW_DBG("\nDIMLTYPE: "); DRW_DBGHL(DIMLTYPE.code, DIMLTYPE.size, DIMLTYPE.ref);
|
||||
dwgHandle DIMLTEX1 = hBbuf->getHandle();
|
||||
DRW_DBG("\nDIMLTEX1: "); DRW_DBGHL(DIMLTEX1.code, DIMLTEX1.size, DIMLTEX1.ref);
|
||||
dwgHandle DIMLTEX2 = hBbuf->getHandle();
|
||||
DRW_DBG("\nDIMLTEX2: "); DRW_DBGHL(DIMLTEX2.code, DIMLTEX2.size, DIMLTEX2.ref);
|
||||
}
|
||||
if (version > DRW::AC1014) {//2000+
|
||||
vars["DIMLWD"]=new DRW_Variant(70, buf->getBitShort());
|
||||
vars["DIMLWE"]=new DRW_Variant(70, buf->getBitShort());
|
||||
}
|
||||
dwgHandle CONTROL = hBbuf->getHandle();
|
||||
DRW_DBG("\nBLOCK CONTROL: "); DRW_DBGHL(CONTROL.code, CONTROL.size, CONTROL.ref);
|
||||
blockCtrl = CONTROL.ref;
|
||||
CONTROL = hBbuf->getHandle();
|
||||
DRW_DBG("\nLAYER CONTROL: "); DRW_DBGHL(CONTROL.code, CONTROL.size, CONTROL.ref);
|
||||
layerCtrl = CONTROL.ref;
|
||||
CONTROL = hBbuf->getHandle();
|
||||
DRW_DBG("\nSTYLE CONTROL: "); DRW_DBGHL(CONTROL.code, CONTROL.size, CONTROL.ref);
|
||||
styleCtrl = CONTROL.ref;
|
||||
CONTROL = hBbuf->getHandle();
|
||||
DRW_DBG("\nLINETYPE CONTROL: "); DRW_DBGHL(CONTROL.code, CONTROL.size, CONTROL.ref);
|
||||
linetypeCtrl = CONTROL.ref;
|
||||
CONTROL = hBbuf->getHandle();
|
||||
DRW_DBG("\nVIEW CONTROL: "); DRW_DBGHL(CONTROL.code, CONTROL.size, CONTROL.ref);
|
||||
viewCtrl = CONTROL.ref;
|
||||
CONTROL = hBbuf->getHandle();
|
||||
DRW_DBG("\nUCS CONTROL: "); DRW_DBGHL(CONTROL.code, CONTROL.size, CONTROL.ref);
|
||||
ucsCtrl = CONTROL.ref;
|
||||
CONTROL = hBbuf->getHandle();
|
||||
DRW_DBG("\nVPORT CONTROL: "); DRW_DBGHL(CONTROL.code, CONTROL.size, CONTROL.ref);
|
||||
vportCtrl = CONTROL.ref;
|
||||
CONTROL = hBbuf->getHandle();
|
||||
DRW_DBG("\nAPPID CONTROL: "); DRW_DBGHL(CONTROL.code, CONTROL.size, CONTROL.ref);
|
||||
appidCtrl = CONTROL.ref;
|
||||
CONTROL = hBbuf->getHandle();
|
||||
DRW_DBG("\nDIMSTYLE CONTROL: "); DRW_DBGHL(CONTROL.code, CONTROL.size, CONTROL.ref);
|
||||
dimstyleCtrl = CONTROL.ref;
|
||||
if (version < DRW::AC1018) {//r2000-
|
||||
CONTROL = hBbuf->getHandle();
|
||||
DRW_DBG("\nVIEWPORT ENTITY HEADER CONTROL: "); DRW_DBGHL(CONTROL.code, CONTROL.size, CONTROL.ref);
|
||||
vpEntHeaderCtrl = CONTROL.ref; //RLZ: only in R13-R15 ????
|
||||
}
|
||||
CONTROL = hBbuf->getHandle();
|
||||
DRW_DBG("\nDICT ACAD_GROUP: "); DRW_DBGHL(CONTROL.code, CONTROL.size, CONTROL.ref);
|
||||
CONTROL = hBbuf->getHandle();
|
||||
DRW_DBG("\nDICT ACAD_MLINESTYLE: "); DRW_DBGHL(CONTROL.code, CONTROL.size, CONTROL.ref);
|
||||
CONTROL = hBbuf->getHandle();
|
||||
DRW_DBG("\nDICT NAMED OBJS: "); DRW_DBGHL(CONTROL.code, CONTROL.size, CONTROL.ref);
|
||||
|
||||
if (version > DRW::AC1014) {//2000+
|
||||
vars["TSTACKALIGN"]=new DRW_Variant(70, buf->getBitShort());
|
||||
vars["TSTACKSIZE"]=new DRW_Variant(70, buf->getBitShort());
|
||||
if (version < DRW::AC1021) {//2004-
|
||||
vars["HYPERLINKBASE"]=new DRW_Variant(1, buf->getCP8Text());
|
||||
vars["STYLESHEET"]=new DRW_Variant(1, buf->getCP8Text());
|
||||
}
|
||||
CONTROL = hBbuf->getHandle();
|
||||
DRW_DBG("\nDICT LAYOUTS: "); DRW_DBGHL(CONTROL.code, CONTROL.size, CONTROL.ref);
|
||||
CONTROL = hBbuf->getHandle();
|
||||
DRW_DBG("\nDICT PLOTSETTINGS: "); DRW_DBGHL(CONTROL.code, CONTROL.size, CONTROL.ref);
|
||||
CONTROL = hBbuf->getHandle();
|
||||
DRW_DBG("\nDICT PLOTSTYLES: "); DRW_DBGHL(CONTROL.code, CONTROL.size, CONTROL.ref);
|
||||
}
|
||||
if (version > DRW::AC1015) {//2004+
|
||||
CONTROL = hBbuf->getHandle();
|
||||
DRW_DBG("\nDICT MATERIALS: "); DRW_DBGHL(CONTROL.code, CONTROL.size, CONTROL.ref);
|
||||
CONTROL = hBbuf->getHandle();
|
||||
DRW_DBG("\nDICT COLORS: "); DRW_DBGHL(CONTROL.code, CONTROL.size, CONTROL.ref);
|
||||
}
|
||||
if (version > DRW::AC1018) {//2007+
|
||||
CONTROL = hBbuf->getHandle();
|
||||
DRW_DBG("\nDICT VISUALSTYLE: "); DRW_DBGHL(CONTROL.code, CONTROL.size, CONTROL.ref);
|
||||
}
|
||||
if (version > DRW::AC1024) {//2013+
|
||||
CONTROL = hBbuf->getHandle();
|
||||
DRW_DBG("\nUNKNOWN HANDLE: "); DRW_DBGHL(CONTROL.code, CONTROL.size, CONTROL.ref);
|
||||
}
|
||||
if (version > DRW::AC1014) {//2000+
|
||||
DRW_DBG("\nFlags: "); DRW_DBGH(buf->getBitLong());//RLZ TODO change to 8 vars
|
||||
vars["INSUNITS"]=new DRW_Variant(70, buf->getBitShort());
|
||||
duint16 cepsntype = buf->getBitShort();
|
||||
vars["CEPSNTYPE"]=new DRW_Variant(70, cepsntype);
|
||||
if (cepsntype == 3){
|
||||
CONTROL = hBbuf->getHandle();
|
||||
DRW_DBG("\nCPSNID HANDLE: "); DRW_DBGHL(CONTROL.code, CONTROL.size, CONTROL.ref);
|
||||
}
|
||||
if (version < DRW::AC1021) {//2004-
|
||||
vars["FINGERPRINTGUID"]=new DRW_Variant(1, buf->getCP8Text());
|
||||
vars["VERSIONGUID"]=new DRW_Variant(1, buf->getCP8Text());
|
||||
}
|
||||
}
|
||||
if (version > DRW::AC1015) {//2004+
|
||||
vars["SORTENTS"]=new DRW_Variant(70, buf->getRawChar8());
|
||||
vars["INDEXCTL"]=new DRW_Variant(70, buf->getRawChar8());
|
||||
vars["HIDETEXT"]=new DRW_Variant(70, buf->getRawChar8());
|
||||
vars["XCLIPFRAME"]=new DRW_Variant(70, buf->getRawChar8());
|
||||
vars["DIMASSOC"]=new DRW_Variant(70, buf->getRawChar8());
|
||||
vars["HALOGAP"]=new DRW_Variant(70, buf->getRawChar8());
|
||||
vars["OBSCUREDCOLOR"]=new DRW_Variant(70, buf->getBitShort());
|
||||
vars["INTERSECTIONCOLOR"]=new DRW_Variant(70, buf->getBitShort());
|
||||
vars["OBSCUREDLTYPE"]=new DRW_Variant(70, buf->getRawChar8());
|
||||
vars["INTERSECTIONDISPLAY"]=new DRW_Variant(70, buf->getRawChar8());
|
||||
if (version < DRW::AC1021) {//2004-
|
||||
vars["PROJECTNAME"]=new DRW_Variant(1, buf->getCP8Text());
|
||||
}
|
||||
}
|
||||
CONTROL = hBbuf->getHandle();
|
||||
DRW_DBG("\nBLOCK PAPER_SPACE: "); DRW_DBGHL(CONTROL.code, CONTROL.size, CONTROL.ref);
|
||||
CONTROL = hBbuf->getHandle();
|
||||
DRW_DBG("\nBLOCK MODEL_SPACE: "); DRW_DBGHL(CONTROL.code, CONTROL.size, CONTROL.ref);
|
||||
CONTROL = hBbuf->getHandle();
|
||||
DRW_DBG("\nLTYPE BYLAYER: "); DRW_DBGHL(CONTROL.code, CONTROL.size, CONTROL.ref);
|
||||
CONTROL = hBbuf->getHandle();
|
||||
DRW_DBG("\nLTYPE BYBLOCK: "); DRW_DBGHL(CONTROL.code, CONTROL.size, CONTROL.ref);
|
||||
CONTROL = hBbuf->getHandle();
|
||||
DRW_DBG("\nLTYPE CONTINUOUS: "); DRW_DBGHL(CONTROL.code, CONTROL.size, CONTROL.ref);
|
||||
if (version > DRW::AC1018) {//2007+
|
||||
vars["CAMERADISPLAY"]=new DRW_Variant(70, buf->getBit());
|
||||
DRW_DBG("\nUnknown 2007+ long1: "); DRW_DBG(buf->getBitLong());
|
||||
DRW_DBG("\nUnknown 2007+ long2: "); DRW_DBG(buf->getBitLong());
|
||||
DRW_DBG("\nUnknown 2007+ double2: "); DRW_DBG(buf->getBitDouble());
|
||||
vars["STEPSPERSEC"]=new DRW_Variant(40, buf->getBitDouble());
|
||||
vars["STEPSIZE"]=new DRW_Variant(40, buf->getBitDouble());
|
||||
vars["3DDWFPREC"]=new DRW_Variant(40, buf->getBitDouble());
|
||||
vars["LENSLENGTH"]=new DRW_Variant(40, buf->getBitDouble());
|
||||
vars["CAMERAHEIGHT"]=new DRW_Variant(40, buf->getBitDouble());
|
||||
vars["SOLIDHIST"]=new DRW_Variant(70, buf->getRawChar8());
|
||||
vars["SHOWHIST"]=new DRW_Variant(70, buf->getRawChar8());
|
||||
vars["PSOLWIDTH"]=new DRW_Variant(40, buf->getBitDouble());
|
||||
vars["PSOLHEIGHT"]=new DRW_Variant(40, buf->getBitDouble());
|
||||
vars["LOFTANG1"]=new DRW_Variant(40, buf->getBitDouble());
|
||||
vars["LOFTANG2"]=new DRW_Variant(40, buf->getBitDouble());
|
||||
vars["LOFTMAG1"]=new DRW_Variant(40, buf->getBitDouble());
|
||||
vars["LOFTMAG2"]=new DRW_Variant(40, buf->getBitDouble());
|
||||
vars["LOFTPARAM"]=new DRW_Variant(70, buf->getBitShort());
|
||||
vars["LOFTNORMALS"]=new DRW_Variant(40, buf->getRawChar8());
|
||||
vars["LATITUDE"]=new DRW_Variant(40, buf->getBitDouble());
|
||||
vars["LONGITUDE"]=new DRW_Variant(40, buf->getBitDouble());
|
||||
vars["NORTHDIRECTION"]=new DRW_Variant(40, buf->getBitDouble());
|
||||
vars["TIMEZONE"]=new DRW_Variant(70, buf->getBitLong());
|
||||
vars["LIGHTGLYPHDISPLAY"]=new DRW_Variant(70, buf->getRawChar8());
|
||||
vars["TILEMODELIGHTSYNCH"]=new DRW_Variant(70, buf->getRawChar8());
|
||||
vars["DWFFRAME"]=new DRW_Variant(70, buf->getRawChar8());
|
||||
vars["DGNFRAME"]=new DRW_Variant(70, buf->getRawChar8());
|
||||
DRW_DBG("\nUnknown 2007+ BIT: "); DRW_DBG(buf->getBit());
|
||||
vars["INTERFERECOLOR"]=new DRW_Variant(70, buf->getCmColor(version));
|
||||
CONTROL = hBbuf->getHandle();
|
||||
DRW_DBG("\nINTERFEREOBJVS: "); DRW_DBGHL(CONTROL.code, CONTROL.size, CONTROL.ref);
|
||||
CONTROL = hBbuf->getHandle();
|
||||
DRW_DBG("\nINTERFEREVPVS: "); DRW_DBGHL(CONTROL.code, CONTROL.size, CONTROL.ref);
|
||||
CONTROL = hBbuf->getHandle();
|
||||
DRW_DBG("\nDRAGVS: "); DRW_DBGHL(CONTROL.code, CONTROL.size, CONTROL.ref);
|
||||
vars["CSHADOW"]=new DRW_Variant(70, buf->getRawChar8());
|
||||
DRW_DBG("\nUnknown 2007+ double2: "); DRW_DBG(buf->getBitDouble());
|
||||
}
|
||||
if (version > DRW::AC1012) {//R14+
|
||||
DRW_DBG("\nUnknown R14+ short1: "); DRW_DBG(buf->getBitShort());
|
||||
DRW_DBG("\nUnknown R14+ short2: "); DRW_DBG(buf->getBitShort());
|
||||
DRW_DBG("\nUnknown R14+ short3: "); DRW_DBG(buf->getBitShort());
|
||||
DRW_DBG("\nUnknown R14+ short4: "); DRW_DBG(buf->getBitShort());
|
||||
}
|
||||
|
||||
DRW_DBG("\nbuf position: "); DRW_DBG(buf->getPosition());
|
||||
DRW_DBG(" buf bit position: "); DRW_DBG(buf->getBitPos());
|
||||
|
||||
|
||||
/**** RLZ: disabled, pending to read all data ***/
|
||||
//Start reading string stream for 2007 and further
|
||||
if (version > DRW::AC1018) {//2007+
|
||||
duint32 strStartPos = endBitPos -1;
|
||||
buf->setPosition(strStartPos >>3);
|
||||
buf->setBitPos(strStartPos&7);
|
||||
if (buf->getBit() == 1){
|
||||
strStartPos -= 16;
|
||||
buf->setPosition(strStartPos >>3);
|
||||
buf->setBitPos(strStartPos&7);
|
||||
duint32 strDataSize = buf->getRawShort16();
|
||||
if (strDataSize & 0x8000) {
|
||||
strStartPos -= 16;//decrement 16 bits
|
||||
strDataSize &= 0x7FFF; //strip 0x8000;
|
||||
buf->setPosition(strStartPos >> 3);
|
||||
buf->setBitPos(strStartPos & 7);
|
||||
duint32 hiSize = buf->getRawShort16();
|
||||
strDataSize |= (hiSize << 15);
|
||||
}
|
||||
strStartPos -= strDataSize;
|
||||
buf->setPosition(strStartPos >> 3);
|
||||
buf->setBitPos(strStartPos & 7);
|
||||
|
||||
DRW_DBG("\nstring buf position: "); DRW_DBG(buf->getPosition());
|
||||
DRW_DBG("\nstring buf bit position: "); DRW_DBG(buf->getBitPos());
|
||||
}
|
||||
DRW_DBG("\nUnknown text1: "); DRW_DBG(buf->getUCSText(false));
|
||||
DRW_DBG("\nUnknown text2: "); DRW_DBG(buf->getUCSText(false));
|
||||
DRW_DBG("\nUnknown text3: "); DRW_DBG(buf->getUCSText(false));
|
||||
DRW_DBG("\nUnknown text4: "); DRW_DBG(buf->getUCSText(false));
|
||||
vars["MENU"]=new DRW_Variant(1, buf->getUCSText(false));
|
||||
vars["DIMPOST"]=new DRW_Variant(1, buf->getUCSText(false));
|
||||
vars["DIMAPOST"]=new DRW_Variant(1, buf->getUCSText(false));
|
||||
if (version > DRW::AC1021) {//2010+
|
||||
vars["DIMALTMZS"]=new DRW_Variant(70, buf->getUCSText(false));//RLZ: pending to verify//////////////
|
||||
vars["DIMMZS"]=new DRW_Variant(70, buf->getUCSText(false));//RLZ: pending to verify//////////////
|
||||
}
|
||||
vars["HYPERLINKBASE"]=new DRW_Variant(1, buf->getUCSText(false));
|
||||
vars["STYLESHEET"]=new DRW_Variant(1, buf->getUCSText(false));
|
||||
vars["FINGERPRINTGUID"]=new DRW_Variant(1, buf->getUCSText(false));
|
||||
DRW_DBG("\nstring buf position: "); DRW_DBG(buf->getPosition());
|
||||
DRW_DBG(" string buf bit position: "); DRW_DBG(buf->getBitPos());
|
||||
vars["VERSIONGUID"]=new DRW_Variant(1, buf->getUCSText(false));
|
||||
DRW_DBG("\nstring buf position: "); DRW_DBG(buf->getPosition());
|
||||
DRW_DBG(" string buf bit position: "); DRW_DBG(buf->getBitPos());
|
||||
vars["PROJECTNAME"]=new DRW_Variant(1, buf->getUCSText(false));
|
||||
}
|
||||
/*** ****/
|
||||
DRW_DBG("\nstring buf position: "); DRW_DBG(buf->getPosition());
|
||||
DRW_DBG(" string buf bit position: "); DRW_DBG(buf->getBitPos());
|
||||
|
||||
if (DRW_DBGGL == DRW_dbg::DEBUG){
|
||||
for (std::map<std::string,DRW_Variant*>::iterator it=vars.begin(); it!=vars.end(); ++it){
|
||||
DRW_DBG("\n"); DRW_DBG(it->first); DRW_DBG(": ");
|
||||
switch (it->second->type){
|
||||
case DRW_Variant::INTEGER:
|
||||
DRW_DBG(it->second->content.i);
|
||||
break;
|
||||
case DRW_Variant::DOUBLE:
|
||||
DRW_DBG(it->second->content.d);
|
||||
break;
|
||||
case DRW_Variant::STRING:
|
||||
DRW_DBG(it->second->content.s->c_str());
|
||||
break;
|
||||
case DRW_Variant::COORD:
|
||||
DRW_DBG("x= "); DRW_DBG(it->second->content.v->x);
|
||||
DRW_DBG(", y= "); DRW_DBG(it->second->content.v->y);
|
||||
DRW_DBG(", z= "); DRW_DBG(it->second->content.v->z);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
DRW_DBG(" code: ");DRW_DBG(it->second->code);
|
||||
}
|
||||
}
|
||||
|
||||
buf->setPosition(size+16+4); //readed size +16 start sentinel + 4 size
|
||||
if (version > DRW::AC1021 && mv > 3) { //2010+
|
||||
buf->getRawLong32();//advance 4 bytes (hisize)
|
||||
}
|
||||
DRW_DBG("\nseting position to: "); DRW_DBG(buf->getPosition());
|
||||
DRW_DBG("\nHeader CRC: "); DRW_DBGH(buf->getRawShort16());
|
||||
DRW_DBG("\nbuf position: "); DRW_DBG(buf->getPosition());
|
||||
DRW_DBG("\ndwg header end sentinel= ");
|
||||
for (int i=0; i<16;i++) {
|
||||
DRW_DBGH(buf->getRawChar8()); DRW_DBG(" ");
|
||||
}
|
||||
|
||||
//temporary code to show header end sentinel
|
||||
duint64 sz= buf->size()-1;
|
||||
if (version < DRW::AC1018) {//pre 2004
|
||||
sz= buf->size()-16;
|
||||
buf->setPosition(sz);
|
||||
DRW_DBG("\nseting position to: "); DRW_DBG(buf->getPosition());
|
||||
DRW_DBG("\ndwg header end sentinel= ");
|
||||
for (int i=0; i<16;i++) {
|
||||
DRW_DBGH(buf->getRawChar8()); DRW_DBG(" ");
|
||||
}
|
||||
} else if (version == DRW::AC1018) {//2004
|
||||
// sz= buf->size()-132;
|
||||
// buf->setPosition(sz);
|
||||
buf->moveBitPos(-128);
|
||||
DRW_DBG("\nseting position to: "); DRW_DBG(buf->getPosition());
|
||||
DRW_DBG("\ndwg header end sentinel= ");
|
||||
for (int i=0; i<16;i++) {
|
||||
DRW_DBGH(buf->getRawChar8()); DRW_DBG(" ");
|
||||
}
|
||||
} else if (version == DRW::AC1021) {//2007
|
||||
sz= buf->size()-16;
|
||||
buf->setPosition(sz);
|
||||
DRW_DBG("\nseting position to: "); DRW_DBG(buf->getPosition());
|
||||
DRW_DBG("\ndwg header end sentinel= ");
|
||||
for (int i=0; i<16;i++) {
|
||||
DRW_DBGH(buf->getRawChar8()); DRW_DBG(" ");
|
||||
}
|
||||
} else if (version == DRW::AC1024) {//2010
|
||||
// sz= buf->size()-93;
|
||||
// buf->setPosition(sz);
|
||||
buf->moveBitPos(-128);
|
||||
DRW_DBG("\nseting position to: "); DRW_DBG(buf->getPosition());
|
||||
DRW_DBG("\ndwg header end sentinel= ");
|
||||
for (int i=0; i<16;i++) {
|
||||
DRW_DBGH(buf->getRawChar8()); DRW_DBG(" ");
|
||||
}
|
||||
} else if (version == DRW::AC1027) {//2013
|
||||
// sz= buf->size()-76;
|
||||
// buf->setPosition(sz);
|
||||
buf->moveBitPos(-128);
|
||||
DRW_DBG("\nseting position to: "); DRW_DBG(buf->getPosition());
|
||||
DRW_DBG("\ndwg header end sentinel= ");
|
||||
for (int i=0; i<16;i++) {
|
||||
DRW_DBGH(buf->getRawChar8()); DRW_DBG(" ");
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
|
|
@ -19,10 +19,8 @@
|
|||
|
||||
class dxfReader;
|
||||
class dxfWriter;
|
||||
class dwgBuffer;
|
||||
|
||||
#define SETHDRFRIENDS friend class dxfRW; \
|
||||
friend class dwgReader;
|
||||
#define SETHDRFRIENDS friend class dxfRW;
|
||||
|
||||
//! Class to handle header entries
|
||||
/*!
|
||||
|
@ -87,7 +85,6 @@ public:
|
|||
|
||||
protected:
|
||||
void parseCode(int code, dxfReader *reader);
|
||||
bool parseDwg(DRW::Version version, dwgBuffer *buf, dwgBuffer *hBbuf, duint8 mv=0);
|
||||
private:
|
||||
bool getDouble(std::string key, double *varDouble);
|
||||
bool getInt(std::string key, int *varInt);
|
||||
|
|
|
@ -15,9 +15,7 @@
|
|||
#include "drw_objects.h"
|
||||
#include "intern/dxfreader.h"
|
||||
#include "intern/dxfwriter.h"
|
||||
#include "intern/dwgbuffer.h"
|
||||
#include "intern/drw_dbg.h"
|
||||
#include "intern/dwgutil.h"
|
||||
|
||||
//! Base class for tables entries
|
||||
/*!
|
||||
|
@ -85,98 +83,6 @@ void DRW_TableEntry::parseCode(int code, dxfReader *reader){
|
|||
}
|
||||
}
|
||||
|
||||
bool DRW_TableEntry::parseDwg(DRW::Version version, dwgBuffer *buf, dwgBuffer *strBuf, duint32 bs){
|
||||
DRW_DBG("\n***************************** parsing table entry *********************************************\n");
|
||||
objSize=0;
|
||||
oType = buf->getObjType(version);
|
||||
DRW_DBG("Object type: "); DRW_DBG(oType); DRW_DBG(", "); DRW_DBGH(oType);
|
||||
if (version > DRW::AC1014 && version < DRW::AC1024) {//2000 to 2007
|
||||
objSize = buf->getRawLong32(); //RL 32bits object size in bits
|
||||
DRW_DBG(" Object size: "); DRW_DBG(objSize); DRW_DBG("\n");
|
||||
}
|
||||
if (version > DRW::AC1021) {//2010+
|
||||
duint32 ms =static_cast<duint32>(buf->size());
|
||||
objSize = ms*8 - bs;
|
||||
DRW_DBG(" Object size: "); DRW_DBG(objSize); DRW_DBG("\n");
|
||||
}
|
||||
if (strBuf != NULL && version > DRW::AC1018) {//2007+
|
||||
strBuf->moveBitPos(objSize-1);
|
||||
DRW_DBG(" strBuf strbit pos 2007: "); DRW_DBG(strBuf->getPosition()); DRW_DBG(" strBuf bpos 2007: ");
|
||||
DRW_DBG(strBuf->getBitPos()); DRW_DBG("\n");
|
||||
if (strBuf->getBit() == 1){
|
||||
DRW_DBG("DRW_TableEntry::parseDwg string bit is 1\n");
|
||||
strBuf->moveBitPos(-17);
|
||||
duint16 strDataSize = strBuf->getRawShort16();
|
||||
DRW_DBG("\nDRW_TableEntry::parseDwg string strDataSize: "); DRW_DBGH(strDataSize); DRW_DBG("\n");
|
||||
if ( (strDataSize& 0x8000) == 0x8000){
|
||||
DRW_DBG("\nDRW_TableEntry::parseDwg string 0x8000 bit is set");
|
||||
strBuf->moveBitPos(-33);//RLZ pending to verify
|
||||
duint16 hiSize = strBuf->getRawShort16();
|
||||
strDataSize = static_cast<duint16>((strDataSize&0x7fff) | (hiSize<<15));
|
||||
}
|
||||
strBuf->moveBitPos( -strDataSize -16); //-14
|
||||
DRW_DBG("strBuf start strDataSize pos 2007: "); DRW_DBG(strBuf->getPosition()); DRW_DBG(" strBuf bpos 2007: "); DRW_DBG(strBuf->getBitPos()); DRW_DBG("\n");
|
||||
} else
|
||||
DRW_DBG("\nDRW_TableEntry::parseDwg string bit is 0");
|
||||
DRW_DBG("strBuf start pos 2007: "); DRW_DBG(strBuf->getPosition()); DRW_DBG(" strBuf bpos 2007: "); DRW_DBG(strBuf->getBitPos()); DRW_DBG("\n");
|
||||
}
|
||||
|
||||
dwgHandle ho = buf->getHandle();
|
||||
handle = ho.ref;
|
||||
DRW_DBG("TableEntry Handle: "); DRW_DBGHL(ho.code, ho.size, ho.ref);
|
||||
dint16 extDataSize = buf->getBitShort(); //BS
|
||||
DRW_DBG(" ext data size: "); DRW_DBG(extDataSize);
|
||||
while (extDataSize>0 && buf->isGood()) {
|
||||
/* RLZ: TODO */
|
||||
dwgHandle ah = buf->getHandle();
|
||||
DRW_DBG("App Handle: "); DRW_DBGHL(ah.code, ah.size, ah.ref);
|
||||
duint8 *tmpExtData = new duint8[extDataSize];
|
||||
buf->getBytes(tmpExtData, extDataSize);
|
||||
dwgBuffer tmpExtDataBuf(tmpExtData, extDataSize, buf->decoder);
|
||||
int pos = static_cast<int>(tmpExtDataBuf.getPosition());
|
||||
int bpos = tmpExtDataBuf.getBitPos();
|
||||
DRW_DBG("ext data pos: "); DRW_DBG(pos); DRW_DBG("."); DRW_DBG(bpos); DRW_DBG("\n");
|
||||
duint8 dxfCode = tmpExtDataBuf.getRawChar8();
|
||||
DRW_DBG(" dxfCode: "); DRW_DBG(dxfCode);
|
||||
switch (dxfCode){
|
||||
case 0:{
|
||||
duint8 strLength = tmpExtDataBuf.getRawChar8();
|
||||
DRW_DBG(" strLength: "); DRW_DBG(strLength);
|
||||
duint16 cp = tmpExtDataBuf.getBERawShort16();
|
||||
DRW_DBG(" str codepage: "); DRW_DBG(cp);
|
||||
for (int i=0;i< strLength+1;i++) {//string length + null terminating char
|
||||
duint8 dxfChar = tmpExtDataBuf.getRawChar8();
|
||||
DRW_DBG(" dxfChar: "); DRW_DBG(dxfChar);
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
/* RLZ: TODO */
|
||||
break;
|
||||
}
|
||||
DRW_DBG("ext data pos: "); DRW_DBG(tmpExtDataBuf.getPosition()); DRW_DBG("."); DRW_DBG(tmpExtDataBuf.getBitPos()); DRW_DBG("\n");
|
||||
delete[]tmpExtData;
|
||||
extDataSize = buf->getBitShort(); //BS
|
||||
DRW_DBG(" ext data size: "); DRW_DBG(extDataSize);
|
||||
} //end parsing extData (EED)
|
||||
if (version < DRW::AC1015) {//14-
|
||||
objSize = buf->getRawLong32(); //RL 32bits size in bits
|
||||
}
|
||||
DRW_DBG(" objSize in bits: "); DRW_DBG(objSize);
|
||||
|
||||
numReactors = buf->getBitLong(); //BL
|
||||
DRW_DBG(", numReactors: "); DRW_DBG(numReactors); DRW_DBG("\n");
|
||||
if (version > DRW::AC1015) {//2004+
|
||||
xDictFlag = buf->getBit();
|
||||
DRW_DBG("xDictFlag: "); DRW_DBG(xDictFlag);
|
||||
}
|
||||
if (version > DRW::AC1024) {//2013+
|
||||
duint8 bd = buf->getBit();
|
||||
DRW_DBG(" Have binary data: "); DRW_DBG(bd); DRW_DBG("\n");
|
||||
}
|
||||
return buf->isGood();
|
||||
}
|
||||
|
||||
//! Class to handle dimstyle entries
|
||||
/*!
|
||||
* Class to handle ldim style symbol table entries
|
||||
|
@ -400,26 +306,6 @@ void DRW_Dimstyle::parseCode(int code, dxfReader *reader){
|
|||
}
|
||||
}
|
||||
|
||||
bool DRW_Dimstyle::parseDwg(DRW::Version version, dwgBuffer *buf, duint32 bs){
|
||||
dwgBuffer sBuff = *buf;
|
||||
dwgBuffer *sBuf = buf;
|
||||
if (version > DRW::AC1018) {//2007+
|
||||
sBuf = &sBuff; //separate buffer for strings
|
||||
}
|
||||
bool ret = DRW_TableEntry::parseDwg(version, buf, sBuf, bs);
|
||||
DRW_DBG("\n***************************** parsing dimension style **************************************\n");
|
||||
if (!ret)
|
||||
return ret;
|
||||
name = sBuf->getVariableText(version, false);
|
||||
DRW_DBG("dimension style name: "); DRW_DBG(name.c_str()); DRW_DBG("\n");
|
||||
|
||||
// handleObj = shpControlH.ref;
|
||||
DRW_DBG("\n Remaining bytes: "); DRW_DBG(buf->numRemainingBytes()); DRW_DBG("\n");
|
||||
// RS crc; //RS */
|
||||
return buf->isGood();
|
||||
}
|
||||
|
||||
|
||||
//! Class to handle line type entries
|
||||
/*!
|
||||
* Class to handle line type symbol table entries
|
||||
|
@ -466,108 +352,6 @@ void DRW_LType::update(){
|
|||
length = d;
|
||||
}
|
||||
|
||||
bool DRW_LType::parseDwg(DRW::Version version, dwgBuffer *buf, duint32 bs){
|
||||
dwgBuffer sBuff = *buf;
|
||||
dwgBuffer *sBuf = buf;
|
||||
if (version > DRW::AC1018) {//2007+
|
||||
sBuf = &sBuff; //separate buffer for strings
|
||||
}
|
||||
bool ret = DRW_TableEntry::parseDwg(version, buf, sBuf, bs);
|
||||
DRW_DBG("\n***************************** parsing line type *********************************************\n");
|
||||
if (!ret)
|
||||
return ret;
|
||||
name = sBuf->getVariableText(version, false);
|
||||
DRW_DBG("linetype name: "); DRW_DBG(name.c_str()); DRW_DBG("\n");
|
||||
flags = buf->getBit()<< 6;
|
||||
DRW_DBG("flags: "); DRW_DBG(flags);
|
||||
if (version > DRW::AC1018) {//2007+
|
||||
} else {//2004- //RLZ: verify in 2004, 2010 &2013
|
||||
dint16 xrefindex = buf->getBitShort();
|
||||
DRW_DBG(" xrefindex: "); DRW_DBG(xrefindex);
|
||||
}
|
||||
duint8 xdep = buf->getBit();
|
||||
DRW_DBG(" xdep: "); DRW_DBG(xdep);
|
||||
flags |= xdep<< 4;
|
||||
DRW_DBG(" flags: "); DRW_DBG(flags);
|
||||
desc = sBuf->getVariableText(version, false);
|
||||
DRW_DBG(" desc: "); DRW_DBG(desc.c_str());
|
||||
length = buf->getBitDouble();
|
||||
DRW_DBG(" pattern length: "); DRW_DBG(length);
|
||||
char align = buf->getRawChar8();
|
||||
DRW_DBG(" align: "); DRW_DBG(std::string(&align, 1));
|
||||
size = buf->getRawChar8();
|
||||
DRW_DBG(" num dashes, size: "); DRW_DBG(size);
|
||||
DRW_DBG("\n dashes:\n");
|
||||
bool haveStrArea = false;
|
||||
for (int i=0; i< size; i++){
|
||||
path.push_back(buf->getBitDouble());
|
||||
/*int bs1 =*/ buf->getBitShort();
|
||||
/*double d1= */buf->getRawDouble();
|
||||
/*double d2=*/ buf->getRawDouble();
|
||||
/*double d3= */buf->getBitDouble();
|
||||
/*double d4= */buf->getBitDouble();
|
||||
int bs2 = buf->getBitShort();
|
||||
if((bs2 & 2) !=0) haveStrArea = true;
|
||||
}
|
||||
for (unsigned i=0; i<path.size() ; i++){
|
||||
DRW_DBG(", "); DRW_DBG(path[i]); DRW_DBG("\n");
|
||||
}
|
||||
DRW_DBG("\n Remaining bytes: "); DRW_DBG(buf->numRemainingBytes()); DRW_DBG("\n");
|
||||
if (version < DRW::AC1021) { //2004-
|
||||
duint8 strarea[256];
|
||||
buf->getBytes(strarea, 256);
|
||||
DRW_DBG("string area 256 bytes:\n"); DRW_DBG(reinterpret_cast<char*>(strarea)); DRW_DBG("\n");
|
||||
} else { //2007+
|
||||
//first verify flag
|
||||
if (haveStrArea) {
|
||||
duint8 strarea[512];
|
||||
buf->getBytes(strarea, 512);
|
||||
DRW_DBG("string area 512 bytes:\n"); DRW_DBG(reinterpret_cast<char*>(strarea)); DRW_DBG("\n");
|
||||
} else
|
||||
DRW_DBG("string area 512 bytes not present\n");
|
||||
}
|
||||
|
||||
if (version > DRW::AC1021) {//2007+ skip string area
|
||||
DRW_DBG(" ltype end of object data pos 2010: "); DRW_DBG(buf->getPosition()); DRW_DBG(" strBuf bpos 2007: "); DRW_DBG(buf->getBitPos()); DRW_DBG("\n");
|
||||
}
|
||||
if (version > DRW::AC1018) {//2007+ skip string area
|
||||
buf->setPosition(objSize >> 3);
|
||||
buf->setBitPos(objSize & 7);
|
||||
}
|
||||
|
||||
if (version > DRW::AC1021) {//2007+ skip string area
|
||||
DRW_DBG(" ltype start of handles data pos 2010: "); DRW_DBG(buf->getPosition()); DRW_DBG(" strBuf bpos 2007: "); DRW_DBG(buf->getBitPos()); DRW_DBG("\n");
|
||||
}
|
||||
|
||||
DRW_DBG("\n Remaining bytes: "); DRW_DBG(buf->numRemainingBytes()); DRW_DBG("\n");
|
||||
dwgHandle ltControlH = buf->getHandle();
|
||||
DRW_DBG("linetype control Handle: "); DRW_DBGHL(ltControlH.code, ltControlH.size, ltControlH.ref);
|
||||
parentHandle = ltControlH.ref;
|
||||
DRW_DBG("\n Remaining bytes: "); DRW_DBG(buf->numRemainingBytes()); DRW_DBG("\n");
|
||||
for (int i=0; i< numReactors;++i) {
|
||||
dwgHandle reactorsH = buf->getHandle();
|
||||
DRW_DBG(" reactorsH control Handle: "); DRW_DBGHL(reactorsH.code, reactorsH.size, reactorsH.ref); DRW_DBG("\n");
|
||||
}
|
||||
if (xDictFlag !=1){//linetype in 2004 seems not have XDicObjH or NULL handle
|
||||
dwgHandle XDicObjH = buf->getHandle();
|
||||
DRW_DBG(" XDicObj control Handle: "); DRW_DBGHL(XDicObjH.code, XDicObjH.size, XDicObjH.ref); DRW_DBG("\n");
|
||||
DRW_DBG("\n Remaining bytes: "); DRW_DBG(buf->numRemainingBytes()); DRW_DBG("\n");
|
||||
}
|
||||
if(size>0){
|
||||
dwgHandle XRefH = buf->getHandle();
|
||||
DRW_DBG(" XRefH control Handle: "); DRW_DBGHL(XRefH.code, XRefH.size, XRefH.ref); DRW_DBG("\n");
|
||||
dwgHandle shpHandle = buf->getHandle();
|
||||
DRW_DBG(" shapeFile Handle: "); DRW_DBGHL(shpHandle.code, shpHandle.size, shpHandle.ref);
|
||||
DRW_DBG("\n Remaining bytes: "); DRW_DBG(buf->numRemainingBytes()); DRW_DBG("\n");
|
||||
}
|
||||
dwgHandle shpHandle = buf->getHandle();
|
||||
DRW_DBG(" shapeFile +1 Handle ??: "); DRW_DBGHL(shpHandle.code, shpHandle.size, shpHandle.ref); DRW_DBG("\n");
|
||||
|
||||
DRW_DBG("\n Remaining bytes: "); DRW_DBG(buf->numRemainingBytes()); DRW_DBG("\n");
|
||||
// RS crc; //RS */
|
||||
return buf->isGood();
|
||||
}
|
||||
|
||||
//! Class to handle layer entries
|
||||
/*!
|
||||
* Class to handle layer symbol table entries
|
||||
|
@ -602,201 +386,6 @@ void DRW_Layer::parseCode(int code, dxfReader *reader){
|
|||
}
|
||||
}
|
||||
|
||||
bool DRW_Layer::parseDwg(DRW::Version version, dwgBuffer *buf, duint32 bs){
|
||||
dwgBuffer sBuff = *buf;
|
||||
dwgBuffer *sBuf = buf;
|
||||
if (version > DRW::AC1018) {//2007+
|
||||
sBuf = &sBuff; //separate buffer for strings
|
||||
}
|
||||
bool ret = DRW_TableEntry::parseDwg(version, buf, sBuf, bs);
|
||||
DRW_DBG("\n***************************** parsing layer *********************************************\n");
|
||||
if (!ret)
|
||||
return ret;
|
||||
name = sBuf->getVariableText(version, false);
|
||||
DRW_DBG("layer name: "); DRW_DBG(name.c_str());
|
||||
|
||||
flags |= buf->getBit()<< 6;//layer have entity
|
||||
if (version < DRW::AC1021) {//2004-
|
||||
DRW_DBG(", xrefindex = "); DRW_DBG(buf->getBitShort()); DRW_DBG("\n");
|
||||
//dint16 xrefindex = buf->getBitShort();
|
||||
}
|
||||
flags |= buf->getBit() << 4;//is refx dependent
|
||||
if (version < DRW::AC1015) {//14-
|
||||
flags |= buf->getBit(); //layer frozen
|
||||
/*flags |=*/ buf->getBit(); //unused, negate the color
|
||||
flags |= buf->getBit() << 1;//frozen in new
|
||||
flags |= buf->getBit()<< 3;//locked
|
||||
}
|
||||
if (version > DRW::AC1014) {//2000+
|
||||
dint16 f = buf->getSBitShort();//bit2 are layer on
|
||||
DRW_DBG(", flags 2000+: "); DRW_DBG(f); DRW_DBG("\n");
|
||||
flags |= f & 0x0001; //layer frozen
|
||||
flags |= ( f>> 1) & 0x0002;//frozen in new
|
||||
flags |= ( f>> 1) & 0x0004;//locked
|
||||
plotF = ( f>> 4) & 0x0001;
|
||||
lWeight = DRW_LW_Conv::dwgInt2lineWidth( (f & 0x03E0) >> 5 );
|
||||
}
|
||||
color = buf->getCmColor(version); //BS or CMC //ok for R14 or negate
|
||||
DRW_DBG(", entity color: "); DRW_DBG(color); DRW_DBG("\n");
|
||||
|
||||
if (version > DRW::AC1018) {//2007+ skip string area
|
||||
buf->setPosition(objSize >> 3);
|
||||
buf->setBitPos(objSize & 7);
|
||||
}
|
||||
dwgHandle layerControlH = buf->getHandle();
|
||||
DRW_DBG("layer control Handle: "); DRW_DBGHL(layerControlH.code, layerControlH.size, layerControlH.ref);
|
||||
parentHandle = layerControlH.ref;
|
||||
|
||||
if (xDictFlag !=1){//linetype in 2004 seems not have XDicObjH or NULL handle
|
||||
dwgHandle XDicObjH = buf->getHandle();
|
||||
DRW_DBG(" XDicObj control Handle: "); DRW_DBGHL(XDicObjH.code, XDicObjH.size, XDicObjH.ref); DRW_DBG("\n");
|
||||
}
|
||||
dwgHandle XRefH = buf->getHandle();
|
||||
DRW_DBG(" XRefH control Handle: "); DRW_DBGHL(XRefH.code, XRefH.size, XRefH.ref); DRW_DBG("\n");
|
||||
if (version > DRW::AC1014) {//2000+
|
||||
dwgHandle plotStyH = buf->getHandle();
|
||||
DRW_DBG(" PLot style control Handle: "); DRW_DBGHL(plotStyH.code, plotStyH.size, plotStyH.ref); DRW_DBG("\n");
|
||||
handlePlotS = DRW::toHexStr(plotStyH.ref);// std::string(plotStyH.ref);//RLZ: verify conversion
|
||||
}
|
||||
if (version > DRW::AC1018) {//2007+
|
||||
dwgHandle materialH = buf->getHandle();
|
||||
DRW_DBG(" Material control Handle: "); DRW_DBGHL(materialH.code, materialH.size, materialH.ref); DRW_DBG("\n");
|
||||
handleMaterialS = DRW::toHexStr(materialH.ref);//RLZ: verify conversion
|
||||
}
|
||||
//lineType handle
|
||||
DRW_DBG("Remaining bytes: "); DRW_DBG(buf->numRemainingBytes()); DRW_DBG("\n");
|
||||
lTypeH = buf->getHandle();
|
||||
DRW_DBG("line type Handle: "); DRW_DBGHL(lTypeH.code, lTypeH.size, lTypeH.ref);
|
||||
DRW_DBG("\n Remaining bytes: "); DRW_DBG(buf->numRemainingBytes()); DRW_DBG("\n");
|
||||
// RS crc; //RS */
|
||||
return buf->isGood();
|
||||
}
|
||||
|
||||
bool DRW_Block_Record::parseDwg(DRW::Version version, dwgBuffer *buf, duint32 bs){
|
||||
dwgBuffer sBuff = *buf;
|
||||
dwgBuffer *sBuf = buf;
|
||||
if (version > DRW::AC1018) {//2007+
|
||||
sBuf = &sBuff; //separate buffer for strings
|
||||
}
|
||||
bool ret = DRW_TableEntry::parseDwg(version, buf, sBuf, bs);
|
||||
DRW_DBG("\n***************************** parsing block record ******************************************\n");
|
||||
if (!ret)
|
||||
return ret;
|
||||
duint32 insertCount = 0;//only 2000+
|
||||
duint32 objectCount = 0; //only 2004+
|
||||
|
||||
name = sBuf->getVariableText(version, false);
|
||||
DRW_DBG("block record name: "); DRW_DBG(name.c_str()); DRW_DBG("\n");
|
||||
|
||||
flags |= buf->getBit()<< 6;//referenced external reference, block code 70, bit 7 (64)
|
||||
if (version > DRW::AC1018) {//2007+
|
||||
} else {//2004- //RLZ: verify in 2004, 2010 &2013
|
||||
dint16 xrefindex = buf->getBitShort();
|
||||
DRW_DBG(" xrefindex: "); DRW_DBG(xrefindex); DRW_DBG("\n");
|
||||
}
|
||||
flags |= buf->getBit() << 4;//is refx dependent, block code 70, bit 5 (16)
|
||||
flags |= buf->getBit(); //if is anonimous block (*U) block code 70, bit 1 (1)
|
||||
flags |= buf->getBit() << 1; //if block contains attdefs, block code 70, bit 2 (2)
|
||||
bool blockIsXref = buf->getBit(); //if is a Xref, block code 70, bit 3 (4)
|
||||
bool xrefOverlaid = buf->getBit(); //if is a overlaid Xref, block code 70, bit 4 (8)
|
||||
flags |= blockIsXref << 2; //if is a Xref, block code 70, bit 3 (4)
|
||||
flags |= xrefOverlaid << 3; //if is a overlaid Xref, block code 70, bit 4 (8)
|
||||
if (version > DRW::AC1014) {//2000+
|
||||
flags |= buf->getBit() << 5; //if is a loaded Xref, block code 70, bit 6 (32)
|
||||
}
|
||||
DRW_DBG("flags: "); DRW_DBG(flags); DRW_DBG(", ");
|
||||
if (version > DRW::AC1015) {//2004+ fails in 2007
|
||||
objectCount = buf->getBitLong(); //Number of objects owned by this block
|
||||
entMap.reserve(objectCount);
|
||||
}
|
||||
basePoint.x = buf->getBitDouble();
|
||||
basePoint.y = buf->getBitDouble();
|
||||
basePoint.z = buf->getBitDouble();
|
||||
DRW_DBG("insertion point: "); DRW_DBGPT(basePoint.x, basePoint.y, basePoint.z); DRW_DBG("\n");
|
||||
UTF8STRING path = sBuf->getVariableText(version, false);
|
||||
DRW_DBG("XRef path name: "); DRW_DBG(path.c_str()); DRW_DBG("\n");
|
||||
|
||||
if (version > DRW::AC1014) {//2000+
|
||||
insertCount = 0;
|
||||
while (duint8 i = buf->getRawChar8() != 0)
|
||||
insertCount +=i;
|
||||
UTF8STRING bkdesc = sBuf->getVariableText(version, false);
|
||||
DRW_DBG("Block description: "); DRW_DBG(bkdesc.c_str()); DRW_DBG("\n");
|
||||
|
||||
duint32 prevData = buf->getBitLong();
|
||||
for (unsigned int j= 0; j < prevData; ++j)
|
||||
buf->getRawChar8();
|
||||
}
|
||||
if (version > DRW::AC1018) {//2007+
|
||||
duint16 insUnits = buf->getBitShort();
|
||||
bool canExplode = buf->getBit(); //if block can be exploded
|
||||
duint8 bkScaling = buf->getRawChar8();
|
||||
|
||||
DRW_UNUSED(insUnits);
|
||||
DRW_UNUSED(canExplode);
|
||||
DRW_UNUSED(bkScaling);
|
||||
}
|
||||
|
||||
if (version > DRW::AC1018) {//2007+ skip string area
|
||||
buf->setPosition(objSize >> 3);
|
||||
buf->setBitPos(objSize & 7);
|
||||
}
|
||||
|
||||
dwgHandle blockControlH = buf->getHandle();
|
||||
DRW_DBG("block control Handle: "); DRW_DBGHL(blockControlH.code, blockControlH.size, blockControlH.ref); DRW_DBG("\n");
|
||||
parentHandle = blockControlH.ref;
|
||||
|
||||
for (int i=0; i<numReactors; i++){
|
||||
dwgHandle reactorH = buf->getHandle();
|
||||
DRW_DBG(" reactor Handle #"); DRW_DBG(i); DRW_DBG(": "); DRW_DBGHL(reactorH.code, reactorH.size, reactorH.ref); DRW_DBG("\n");
|
||||
}
|
||||
if (xDictFlag !=1) {//R14+ //seems present in 2000
|
||||
dwgHandle XDicObjH = buf->getHandle();
|
||||
DRW_DBG(" XDicObj control Handle: "); DRW_DBGHL(XDicObjH.code, XDicObjH.size, XDicObjH.ref); DRW_DBG("\n");
|
||||
}
|
||||
if (version != DRW::AC1021) {//2007+ XDicObjH or NullH not present
|
||||
}
|
||||
dwgHandle NullH = buf->getHandle();
|
||||
DRW_DBG(" NullH control Handle: "); DRW_DBGHL(NullH.code, NullH.size, NullH.ref); DRW_DBG("\n");
|
||||
dwgHandle blockH = buf->getOffsetHandle(handle);
|
||||
DRW_DBG(" blockH Handle: "); DRW_DBGHL(blockH.code, blockH.size, blockH.ref); DRW_DBG("\n");
|
||||
block = blockH.ref;
|
||||
|
||||
if (version > DRW::AC1015) {//2004+
|
||||
for (unsigned int i=0; i< objectCount; i++){
|
||||
dwgHandle entityH = buf->getHandle();
|
||||
DRW_DBG(" entityH Handle #"); DRW_DBG(i); DRW_DBG(": "); DRW_DBGHL(entityH.code, entityH.size, entityH.ref); DRW_DBG("\n");
|
||||
entMap.push_back(entityH.ref);
|
||||
}
|
||||
} else {//2000-
|
||||
if(!blockIsXref && !xrefOverlaid){
|
||||
dwgHandle firstH = buf->getHandle();
|
||||
DRW_DBG(" firstH entity Handle: "); DRW_DBGHL(firstH.code, firstH.size, firstH.ref); DRW_DBG("\n");
|
||||
firstEH = firstH.ref;
|
||||
dwgHandle lastH = buf->getHandle();
|
||||
DRW_DBG(" lastH entity Handle: "); DRW_DBGHL(lastH.code, lastH.size, lastH.ref); DRW_DBG("\n");
|
||||
lastEH = lastH.ref;
|
||||
}
|
||||
}
|
||||
DRW_DBG("Remaining bytes: "); DRW_DBG(buf->numRemainingBytes()); DRW_DBG("\n");
|
||||
dwgHandle endBlockH = buf->getOffsetHandle(handle);
|
||||
DRW_DBG(" endBlockH Handle: "); DRW_DBGHL(endBlockH.code, endBlockH.size, endBlockH.ref); DRW_DBG("\n");
|
||||
endBlock = endBlockH.ref;
|
||||
|
||||
if (version > DRW::AC1014) {//2000+
|
||||
for (unsigned int i=0; i< insertCount; i++){
|
||||
dwgHandle insertsH = buf->getHandle();
|
||||
DRW_DBG(" insertsH Handle #"); DRW_DBG(i); DRW_DBG(": "); DRW_DBGHL(insertsH.code, insertsH.size, insertsH.ref); DRW_DBG("\n");
|
||||
}
|
||||
DRW_DBG("Remaining bytes: "); DRW_DBG(buf->numRemainingBytes()); DRW_DBG("\n");
|
||||
dwgHandle layoutH = buf->getHandle();
|
||||
DRW_DBG(" layoutH Handle: "); DRW_DBGHL(layoutH.code, layoutH.size, layoutH.ref); DRW_DBG("\n");
|
||||
}
|
||||
DRW_DBG("Remaining bytes: "); DRW_DBG(buf->numRemainingBytes()); DRW_DBG("\n\n");
|
||||
// RS crc; //RS */
|
||||
return buf->isGood();
|
||||
}
|
||||
|
||||
//! Class to handle text style entries
|
||||
/*!
|
||||
* Class to handle text style symbol table entries
|
||||
|
@ -834,51 +423,6 @@ void DRW_Textstyle::parseCode(int code, dxfReader *reader){
|
|||
}
|
||||
}
|
||||
|
||||
bool DRW_Textstyle::parseDwg(DRW::Version version, dwgBuffer *buf, duint32 bs){
|
||||
dwgBuffer sBuff = *buf;
|
||||
dwgBuffer *sBuf = buf;
|
||||
if (version > DRW::AC1018) {//2007+
|
||||
sBuf = &sBuff; //separate buffer for strings
|
||||
}
|
||||
bool ret = DRW_TableEntry::parseDwg(version, buf, sBuf, bs);
|
||||
DRW_DBG("\n***************************** parsing text style *********************************************\n");
|
||||
if (!ret)
|
||||
return ret;
|
||||
name = sBuf->getVariableText(version, false);
|
||||
DRW_DBG("text style name: "); DRW_DBG(name.c_str()); DRW_DBG("\n");
|
||||
flags |= buf->getBit()<< 6;//style are referenced for a entity, style code 70, bit 7 (64)
|
||||
/*dint16 xrefindex =*/ buf->getBitShort();
|
||||
flags |= buf->getBit() << 4; //is refx dependent, style code 70, bit 5 (16)
|
||||
flags |= buf->getBit() << 2; //vertical text, stile code 70, bit 3 (4)
|
||||
flags |= buf->getBit(); //if is a shape file instead of text, style code 70, bit 1 (1)
|
||||
height = buf->getBitDouble();
|
||||
width = buf->getBitDouble();
|
||||
oblique = buf->getBitDouble();
|
||||
genFlag = buf->getRawChar8();
|
||||
lastHeight = buf->getBitDouble();
|
||||
font = sBuf->getVariableText(version, false);
|
||||
bigFont = sBuf->getVariableText(version, false);
|
||||
if (version > DRW::AC1018) {//2007+ skip string area
|
||||
buf->setPosition(objSize >> 3);
|
||||
buf->setBitPos(objSize & 7);
|
||||
}
|
||||
dwgHandle shpControlH = buf->getHandle();
|
||||
DRW_DBG(" parentControlH Handle: "); DRW_DBGHL(shpControlH.code, shpControlH.size, shpControlH.ref); DRW_DBG("\n");
|
||||
parentHandle = shpControlH.ref;
|
||||
DRW_DBG("Remaining bytes: "); DRW_DBG(buf->numRemainingBytes()); DRW_DBG("\n");
|
||||
if (xDictFlag !=1){//linetype in 2004 seems not have XDicObjH or NULL handle
|
||||
dwgHandle XDicObjH = buf->getHandle();
|
||||
DRW_DBG(" XDicObj control Handle: "); DRW_DBGHL(XDicObjH.code, XDicObjH.size, XDicObjH.ref); DRW_DBG("\n");
|
||||
DRW_DBG("Remaining bytes: "); DRW_DBG(buf->numRemainingBytes()); DRW_DBG("\n");
|
||||
}
|
||||
/*RLZ: fails verify this part*/ dwgHandle XRefH = buf->getHandle();
|
||||
DRW_DBG(" XRefH control Handle: "); DRW_DBGHL(XRefH.code, XRefH.size, XRefH.ref); DRW_DBG("\n");
|
||||
|
||||
DRW_DBG("Remaining bytes: "); DRW_DBG(buf->numRemainingBytes()); DRW_DBG("\n\n");
|
||||
// RS crc; //RS */
|
||||
return buf->isGood();
|
||||
}
|
||||
|
||||
//! Class to handle vport entries
|
||||
/*!
|
||||
* Class to handle vport symbol table entries
|
||||
|
@ -991,140 +535,6 @@ void DRW_Vport::parseCode(int code, dxfReader *reader){
|
|||
}
|
||||
}
|
||||
|
||||
bool DRW_Vport::parseDwg(DRW::Version version, dwgBuffer *buf, duint32 bs){
|
||||
dwgBuffer sBuff = *buf;
|
||||
dwgBuffer *sBuf = buf;
|
||||
if (version > DRW::AC1018) {//2007+
|
||||
sBuf = &sBuff; //separate buffer for strings
|
||||
}
|
||||
bool ret = DRW_TableEntry::parseDwg(version, buf, sBuf, bs);
|
||||
DRW_DBG("\n***************************** parsing VPort ************************************************\n");
|
||||
if (!ret)
|
||||
return ret;
|
||||
name = sBuf->getVariableText(version, false);
|
||||
DRW_DBG("vport name: "); DRW_DBG(name.c_str()); DRW_DBG("\n");
|
||||
flags |= buf->getBit()<< 6;// code 70, bit 7 (64)
|
||||
if (version < DRW::AC1021) { //2004-
|
||||
/*dint16 xrefindex =*/ buf->getBitShort();
|
||||
}
|
||||
flags |= buf->getBit() << 4; //is refx dependent, style code 70, bit 5 (16)
|
||||
height = buf->getBitDouble();
|
||||
ratio = buf->getBitDouble();
|
||||
DRW_DBG("flags: "); DRW_DBG(flags); DRW_DBG(" height: "); DRW_DBG(height);
|
||||
DRW_DBG(" ratio: "); DRW_DBG(ratio);
|
||||
center = buf->get2RawDouble();
|
||||
DRW_DBG("\nview center: "); DRW_DBGPT(center.x, center.y, center.z);
|
||||
viewTarget.x = buf->getBitDouble();
|
||||
viewTarget.y = buf->getBitDouble();
|
||||
viewTarget.z = buf->getBitDouble();
|
||||
DRW_DBG("\nview target: "); DRW_DBGPT(viewTarget.x, viewTarget.y, viewTarget.z);
|
||||
viewDir.x = buf->getBitDouble();
|
||||
viewDir.y = buf->getBitDouble();
|
||||
viewDir.z = buf->getBitDouble();
|
||||
DRW_DBG("\nview dir: "); DRW_DBGPT(viewDir.x, viewDir.y, viewDir.z);
|
||||
twistAngle = buf->getBitDouble();
|
||||
lensHeight = buf->getBitDouble();
|
||||
frontClip = buf->getBitDouble();
|
||||
backClip = buf->getBitDouble();
|
||||
DRW_DBG("\ntwistAngle: "); DRW_DBG(twistAngle); DRW_DBG(" lensHeight: "); DRW_DBG(lensHeight);
|
||||
DRW_DBG(" frontClip: "); DRW_DBG(frontClip); DRW_DBG(" backClip: "); DRW_DBG(backClip);
|
||||
viewMode = buf->getBit(); //view mode, code 71, bit 0 (1)
|
||||
viewMode |= buf->getBit() << 1; //view mode, code 71, bit 1 (2)
|
||||
viewMode |= buf->getBit() << 2; //view mode, code 71, bit 2 (4)
|
||||
viewMode |= buf->getBit() << 4; //view mode, code 71, bit 4 (16)
|
||||
if (version > DRW::AC1014) { //2000+
|
||||
//duint8 renderMode = buf->getRawChar8();
|
||||
DRW_DBG("\n renderMode: "); DRW_DBG(buf->getRawChar8());
|
||||
if (version > DRW::AC1018) { //2007+
|
||||
DRW_DBG("\n use default lights: "); DRW_DBG(buf->getBit());
|
||||
DRW_DBG(" default lighting type: "); DRW_DBG(buf->getRawChar8());
|
||||
DRW_DBG(" brightness: "); DRW_DBG(buf->getBitDouble());
|
||||
DRW_DBG("\n contrast: "); DRW_DBG(buf->getBitDouble()); DRW_DBG("\n");
|
||||
DRW_DBG(" ambient color CMC: "); DRW_DBG(buf->getCmColor(version));
|
||||
}
|
||||
}
|
||||
lowerLeft = buf->get2RawDouble();
|
||||
DRW_DBG("\nlowerLeft: "); DRW_DBGPT(lowerLeft.x, lowerLeft.y, lowerLeft.z);
|
||||
UpperRight = buf->get2RawDouble();
|
||||
DRW_DBG("\nUpperRight: "); DRW_DBGPT(UpperRight.x, UpperRight.y, UpperRight.z);
|
||||
viewMode |= buf->getBit() << 3; //UCSFOLLOW, view mode, code 71, bit 3 (8)
|
||||
circleZoom = buf->getBitShort();
|
||||
fastZoom = buf->getBit();
|
||||
DRW_DBG("\nviewMode: "); DRW_DBG(viewMode); DRW_DBG(" circleZoom: ");
|
||||
DRW_DBG(circleZoom); DRW_DBG(" fastZoom: "); DRW_DBG(fastZoom);
|
||||
ucsIcon = buf->getBit(); //ucs Icon, code 74, bit 0 (1)
|
||||
ucsIcon |= buf->getBit() << 1; //ucs Icon, code 74, bit 1 (2)
|
||||
grid = buf->getBit();
|
||||
DRW_DBG("\nucsIcon: "); DRW_DBG(ucsIcon); DRW_DBG(" grid: "); DRW_DBG(grid);
|
||||
gridSpacing = buf->get2RawDouble();
|
||||
DRW_DBG("\ngrid Spacing: "); DRW_DBGPT(gridSpacing.x, gridSpacing.y, gridSpacing.z);
|
||||
snap = buf->getBit();
|
||||
snapStyle = buf->getBit();
|
||||
DRW_DBG("\nsnap on/off: "); DRW_DBG(snap); DRW_DBG(" snap Style: "); DRW_DBG(snapStyle);
|
||||
snapIsopair = buf->getBitShort();
|
||||
snapAngle = buf->getBitDouble();
|
||||
DRW_DBG("\nsnap Isopair: "); DRW_DBG(snapIsopair); DRW_DBG(" snap Angle: "); DRW_DBG(snapAngle);
|
||||
snapBase = buf->get2RawDouble();
|
||||
DRW_DBG("\nsnap Base: "); DRW_DBGPT(snapBase.x, snapBase.y, snapBase.z);
|
||||
snapSpacing = buf->get2RawDouble();
|
||||
DRW_DBG("\nsnap Spacing: "); DRW_DBGPT(snapSpacing.x, snapSpacing.y, snapSpacing.z);
|
||||
if (version > DRW::AC1014) { //2000+
|
||||
DRW_DBG("\n Unknown: "); DRW_DBG(buf->getBit());
|
||||
DRW_DBG(" UCS per Viewport: "); DRW_DBG(buf->getBit());
|
||||
DRW_DBG("\nUCS origin: "); DRW_DBGPT(buf->getBitDouble(), buf->getBitDouble(), buf->getBitDouble());
|
||||
DRW_DBG("\nUCS X Axis: "); DRW_DBGPT(buf->getBitDouble(), buf->getBitDouble(), buf->getBitDouble());
|
||||
DRW_DBG("\nUCS Y Axis: "); DRW_DBGPT(buf->getBitDouble(), buf->getBitDouble(), buf->getBitDouble());
|
||||
DRW_DBG("\nUCS elevation: "); DRW_DBG(buf->getBitDouble());
|
||||
DRW_DBG(" UCS Orthographic type: "); DRW_DBG(buf->getBitShort());
|
||||
if (version > DRW::AC1018) { //2007+
|
||||
gridBehavior = buf->getBitShort();
|
||||
DRW_DBG(" gridBehavior (flags): "); DRW_DBG(gridBehavior);
|
||||
DRW_DBG(" Grid major: "); DRW_DBG(buf->getBitShort());
|
||||
}
|
||||
}
|
||||
|
||||
//common handles
|
||||
if (version > DRW::AC1018) {//2007+ skip string area
|
||||
buf->setPosition(objSize >> 3);
|
||||
buf->setBitPos(objSize & 7);
|
||||
}
|
||||
dwgHandle vpControlH = buf->getHandle();
|
||||
DRW_DBG("\n parentControlH Handle: "); DRW_DBGHL(vpControlH.code, vpControlH.size, vpControlH.ref); DRW_DBG("\n");
|
||||
parentHandle = vpControlH.ref;
|
||||
DRW_DBG("Remaining bytes: "); DRW_DBG(buf->numRemainingBytes()); DRW_DBG("\n");
|
||||
if (xDictFlag !=1){
|
||||
dwgHandle XDicObjH = buf->getHandle();
|
||||
DRW_DBG(" XDicObj control Handle: "); DRW_DBGHL(XDicObjH.code, XDicObjH.size, XDicObjH.ref); DRW_DBG("\n");
|
||||
DRW_DBG("Remaining bytes: "); DRW_DBG(buf->numRemainingBytes()); DRW_DBG("\n");
|
||||
}
|
||||
/*RLZ: fails verify this part*/ dwgHandle XRefH = buf->getHandle();
|
||||
DRW_DBG(" XRefH control Handle: "); DRW_DBGHL(XRefH.code, XRefH.size, XRefH.ref);
|
||||
|
||||
if (version > DRW::AC1014) { //2000+
|
||||
DRW_DBG("\nRemaining bytes: "); DRW_DBG(buf->numRemainingBytes());
|
||||
if (version > DRW::AC1018) { //2007+
|
||||
dwgHandle bkgrdH = buf->getHandle();
|
||||
DRW_DBG(" background Handle: "); DRW_DBGHL(bkgrdH.code, bkgrdH.size, bkgrdH.ref);
|
||||
DRW_DBG("\nRemaining bytes: "); DRW_DBG(buf->numRemainingBytes());
|
||||
dwgHandle visualStH = buf->getHandle();
|
||||
DRW_DBG(" visual style Handle: "); DRW_DBGHL(visualStH.code, visualStH.size, visualStH.ref);
|
||||
DRW_DBG("\nRemaining bytes: "); DRW_DBG(buf->numRemainingBytes());
|
||||
dwgHandle sunH = buf->getHandle();
|
||||
DRW_DBG(" sun Handle: "); DRW_DBGHL(sunH.code, sunH.size, sunH.ref);
|
||||
DRW_DBG("\nRemaining bytes: "); DRW_DBG(buf->numRemainingBytes());
|
||||
}
|
||||
dwgHandle namedUCSH = buf->getHandle();
|
||||
DRW_DBG(" named UCS Handle: "); DRW_DBGHL(namedUCSH.code, namedUCSH.size, namedUCSH.ref);
|
||||
DRW_DBG("\nRemaining bytes: "); DRW_DBG(buf->numRemainingBytes());
|
||||
dwgHandle baseUCSH = buf->getHandle();
|
||||
DRW_DBG(" base UCS Handle: "); DRW_DBGHL(baseUCSH.code, baseUCSH.size, baseUCSH.ref);
|
||||
}
|
||||
|
||||
DRW_DBG("\n Remaining bytes: "); DRW_DBG(buf->numRemainingBytes()); DRW_DBG("\n");
|
||||
// RS crc; //RS */
|
||||
return buf->isGood();
|
||||
}
|
||||
|
||||
void DRW_ImageDef::parseCode(int code, dxfReader *reader){
|
||||
switch (code) {
|
||||
case 1:
|
||||
|
@ -1158,80 +568,3 @@ void DRW_ImageDef::parseCode(int code, dxfReader *reader){
|
|||
break;
|
||||
}
|
||||
}
|
||||
|
||||
bool DRW_ImageDef::parseDwg(DRW::Version version, dwgBuffer *buf, duint32 bs){
|
||||
dwgBuffer sBuff = *buf;
|
||||
dwgBuffer *sBuf = buf;
|
||||
if (version > DRW::AC1018) {//2007+
|
||||
sBuf = &sBuff; //separate buffer for strings
|
||||
}
|
||||
bool ret = DRW_TableEntry::parseDwg(version, buf, sBuf, bs);
|
||||
DRW_DBG("\n***************************** parsing Image Def *********************************************\n");
|
||||
if (!ret)
|
||||
return ret;
|
||||
dint32 imgVersion = buf->getBitLong();
|
||||
DRW_DBG("class Version: "); DRW_DBG(imgVersion);
|
||||
DRW_Coord size = buf->get2RawDouble();
|
||||
(void)size;
|
||||
fileName = sBuf->getVariableText(version, false);
|
||||
DRW_DBG("appId name: "); DRW_DBG(fileName.c_str()); DRW_DBG("\n");
|
||||
loaded = buf->getBit();
|
||||
resolution = buf->getRawChar8();
|
||||
up = buf->getRawDouble();
|
||||
vp = buf->getRawDouble();
|
||||
|
||||
dwgHandle parentH = buf->getHandle();
|
||||
DRW_DBG(" parentH Handle: "); DRW_DBGHL(parentH.code, parentH.size, parentH.ref); DRW_DBG("\n");
|
||||
parentHandle = parentH.ref;
|
||||
DRW_DBG("Remaining bytes: "); DRW_DBG(buf->numRemainingBytes()); DRW_DBG("\n");
|
||||
//RLZ: Reactors handles
|
||||
if (xDictFlag !=1){
|
||||
dwgHandle XDicObjH = buf->getHandle();
|
||||
DRW_DBG(" XDicObj control Handle: "); DRW_DBGHL(XDicObjH.code, XDicObjH.size, XDicObjH.ref); DRW_DBG("\n");
|
||||
DRW_DBG("Remaining bytes: "); DRW_DBG(buf->numRemainingBytes()); DRW_DBG("\n");
|
||||
}
|
||||
/*RLZ: fails verify this part*/ dwgHandle XRefH = buf->getHandle();
|
||||
DRW_DBG(" XRefH control Handle: "); DRW_DBGHL(XRefH.code, XRefH.size, XRefH.ref); DRW_DBG("\n");
|
||||
|
||||
DRW_DBG("Remaining bytes: "); DRW_DBG(buf->numRemainingBytes()); DRW_DBG("\n\n");
|
||||
// RS crc; //RS */
|
||||
return buf->isGood();
|
||||
}
|
||||
|
||||
bool DRW_AppId::parseDwg(DRW::Version version, dwgBuffer *buf, duint32 bs){
|
||||
dwgBuffer sBuff = *buf;
|
||||
dwgBuffer *sBuf = buf;
|
||||
if (version > DRW::AC1018) {//2007+
|
||||
sBuf = &sBuff; //separate buffer for strings
|
||||
}
|
||||
bool ret = DRW_TableEntry::parseDwg(version, buf, sBuf, bs);
|
||||
DRW_DBG("\n***************************** parsing app Id *********************************************\n");
|
||||
if (!ret)
|
||||
return ret;
|
||||
name = sBuf->getVariableText(version, false);
|
||||
DRW_DBG("appId name: "); DRW_DBG(name.c_str()); DRW_DBG("\n");
|
||||
flags |= buf->getBit()<< 6;// code 70, bit 7 (64)
|
||||
/*dint16 xrefindex =*/ buf->getBitShort();
|
||||
flags |= buf->getBit() << 4; //is refx dependent, style code 70, bit 5 (16)
|
||||
duint8 unknown = buf->getRawChar8(); // unknown code 71
|
||||
DRW_DBG("unknown code 71: "); DRW_DBG(unknown); DRW_DBG("\n");
|
||||
if (version > DRW::AC1018) {//2007+ skip string area
|
||||
buf->setPosition(objSize >> 3);
|
||||
buf->setBitPos(objSize & 7);
|
||||
}
|
||||
dwgHandle appIdControlH = buf->getHandle();
|
||||
DRW_DBG(" parentControlH Handle: "); DRW_DBGHL(appIdControlH.code, appIdControlH.size, appIdControlH.ref); DRW_DBG("\n");
|
||||
parentHandle = appIdControlH.ref;
|
||||
DRW_DBG("Remaining bytes: "); DRW_DBG(buf->numRemainingBytes()); DRW_DBG("\n");
|
||||
if (xDictFlag !=1){//linetype in 2004 seems not have XDicObjH or NULL handle
|
||||
dwgHandle XDicObjH = buf->getHandle();
|
||||
DRW_DBG(" XDicObj control Handle: "); DRW_DBGHL(XDicObjH.code, XDicObjH.size, XDicObjH.ref); DRW_DBG("\n");
|
||||
DRW_DBG("Remaining bytes: "); DRW_DBG(buf->numRemainingBytes()); DRW_DBG("\n");
|
||||
}
|
||||
/*RLZ: fails verify this part*/ dwgHandle XRefH = buf->getHandle();
|
||||
DRW_DBG(" XRefH control Handle: "); DRW_DBGHL(XRefH.code, XRefH.size, XRefH.ref); DRW_DBG("\n");
|
||||
|
||||
DRW_DBG("Remaining bytes: "); DRW_DBG(buf->numRemainingBytes()); DRW_DBG("\n\n");
|
||||
// RS crc; //RS */
|
||||
return buf->isGood();
|
||||
}
|
||||
|
|
|
@ -22,7 +22,6 @@
|
|||
|
||||
class dxfReader;
|
||||
class dxfWriter;
|
||||
class dwgBuffer;
|
||||
|
||||
namespace DRW {
|
||||
|
||||
|
@ -46,8 +45,7 @@ namespace DRW {
|
|||
//SPATIAL_INDEX, SPATIAL_FILTER, TABLEGEOMETRY, TABLESTYLES,VISUALSTYLE,
|
||||
}
|
||||
|
||||
#define SETOBJFRIENDS friend class dxfRW; \
|
||||
friend class dwgReader;
|
||||
#define SETOBJFRIENDS friend class dxfRW;
|
||||
|
||||
//! Base class for tables entries
|
||||
/*!
|
||||
|
@ -64,11 +62,7 @@ public:
|
|||
name(),
|
||||
flags(0),
|
||||
extData(),
|
||||
curr(nullptr),
|
||||
oType(),
|
||||
xDictFlag(0),
|
||||
numReactors(0),
|
||||
objSize()
|
||||
curr(nullptr)
|
||||
{}
|
||||
|
||||
virtual~DRW_TableEntry() {
|
||||
|
@ -85,11 +79,7 @@ public:
|
|||
name(e.name),
|
||||
flags(e.flags),
|
||||
extData(),
|
||||
curr(e.curr),
|
||||
oType(),
|
||||
xDictFlag(e.xDictFlag),
|
||||
numReactors(e.numReactors),
|
||||
objSize()
|
||||
curr(e.curr)
|
||||
{
|
||||
for (std::vector<DRW_Variant*>::const_iterator it=e.extData.begin(); it!=e.extData.end(); ++it){
|
||||
extData.push_back(new DRW_Variant(*(*it)));
|
||||
|
@ -98,8 +88,6 @@ public:
|
|||
|
||||
protected:
|
||||
void parseCode(int code, dxfReader *reader);
|
||||
virtual bool parseDwg(DRW::Version version, dwgBuffer *buf, duint32 bs=0) = 0;
|
||||
bool parseDwg(DRW::Version version, dwgBuffer *buf, dwgBuffer* strBuf, duint32 bs=0);
|
||||
void reset(){
|
||||
flags = 0;
|
||||
for (std::vector<DRW_Variant*>::iterator it=extData.begin(); it!=extData.end(); ++it)
|
||||
|
@ -117,14 +105,8 @@ public:
|
|||
|
||||
private:
|
||||
DRW_TableEntry &operator=(const DRW_TableEntry &) Q_DECL_EQ_DELETE;
|
||||
// cppcheck-suppress unsafeClassCanLeak
|
||||
DRW_Variant* curr;
|
||||
|
||||
//***** dwg parse ********/
|
||||
protected:
|
||||
dint16 oType;
|
||||
duint8 xDictFlag;
|
||||
dint32 numReactors; //
|
||||
duint32 objSize; //RL 32bits object data size in bits
|
||||
};
|
||||
|
||||
|
||||
|
@ -239,7 +221,6 @@ public:
|
|||
|
||||
protected:
|
||||
void parseCode(int code, dxfReader *reader);
|
||||
bool parseDwg(DRW::Version version, dwgBuffer *buf, duint32 bs=0);
|
||||
|
||||
public:
|
||||
//V12
|
||||
|
@ -343,7 +324,6 @@ public:
|
|||
|
||||
protected:
|
||||
void parseCode(int code, dxfReader *reader);
|
||||
bool parseDwg(DRW::Version version, dwgBuffer *buf, duint32 bs=0);
|
||||
void update();
|
||||
|
||||
public:
|
||||
|
@ -373,8 +353,7 @@ public:
|
|||
plotF(),
|
||||
lWeight(),
|
||||
handlePlotS(),
|
||||
handleMaterialS(),
|
||||
lTypeH()
|
||||
handleMaterialS()
|
||||
{ reset();}
|
||||
|
||||
void reset() {
|
||||
|
@ -389,7 +368,6 @@ public:
|
|||
|
||||
protected:
|
||||
void parseCode(int code, dxfReader *reader);
|
||||
bool parseDwg(DRW::Version version, dwgBuffer *buf, duint32 bs=0);
|
||||
|
||||
public:
|
||||
UTF8STRING lineType; /*!< line type, code 6 */
|
||||
|
@ -399,8 +377,6 @@ public:
|
|||
enum DRW_LW_Conv::lineWidth lWeight; /*!< layer lineweight, code 370 */
|
||||
std::string handlePlotS; /*!< Hard-pointer ID/handle of plotstyle, code 390 */
|
||||
std::string handleMaterialS; /*!< Hard-pointer ID/handle of materialstyle, code 347 */
|
||||
/*only used for read dwg*/
|
||||
dwgHandle lTypeH;
|
||||
};
|
||||
|
||||
//! Class to handle block record entries
|
||||
|
@ -412,38 +388,21 @@ class DRW_Block_Record : public DRW_TableEntry {
|
|||
SETOBJFRIENDS
|
||||
public:
|
||||
DRW_Block_Record()
|
||||
: insUnits(),
|
||||
basePoint(),
|
||||
block(),
|
||||
endBlock(),
|
||||
firstEH(),
|
||||
lastEH(),
|
||||
entMap()
|
||||
: insUnits()
|
||||
{ reset();}
|
||||
|
||||
void reset() {
|
||||
tType = DRW::BLOCK_RECORD;
|
||||
flags = 0;
|
||||
firstEH = lastEH = DRW::NoHandle;
|
||||
DRW_TableEntry::reset();
|
||||
}
|
||||
|
||||
protected:
|
||||
//protected:
|
||||
// void parseCode(int code, dxfReader *reader);
|
||||
bool parseDwg(DRW::Version version, dwgBuffer *buf, duint32 bs=0);
|
||||
|
||||
public:
|
||||
//Note: int DRW_TableEntry::flags; contains code 70 of block
|
||||
int insUnits; /*!< block insertion units, code 70 of block_record*/
|
||||
DRW_Coord basePoint; /*!< block insertion base point dwg only */
|
||||
protected:
|
||||
//dwg parser
|
||||
private:
|
||||
duint32 block; //handle for block entity
|
||||
duint32 endBlock;//handle for end block entity
|
||||
duint32 firstEH; //handle of first entity, only in pre-2004
|
||||
duint32 lastEH; //handle of last entity, only in pre-2004
|
||||
std::vector<duint32>entMap;
|
||||
};
|
||||
|
||||
//! Class to handle text style entries
|
||||
|
@ -477,7 +436,6 @@ public:
|
|||
|
||||
protected:
|
||||
void parseCode(int code, dxfReader *reader);
|
||||
bool parseDwg(DRW::Version version, dwgBuffer *buf, duint32 bs=0);
|
||||
|
||||
public:
|
||||
double height; /*!< Fixed text height (0 not set), code 40 */
|
||||
|
@ -547,7 +505,6 @@ public:
|
|||
|
||||
protected:
|
||||
void parseCode(int code, dxfReader *reader);
|
||||
bool parseDwg(DRW::Version version, dwgBuffer *buf, duint32 bs=0);
|
||||
|
||||
public:
|
||||
DRW_Coord lowerLeft; /*!< Lower left corner, code 10 & 20 */
|
||||
|
@ -613,7 +570,6 @@ public:
|
|||
|
||||
protected:
|
||||
void parseCode(int code, dxfReader *reader);
|
||||
bool parseDwg(DRW::Version version, dwgBuffer *buf, duint32 bs=0);
|
||||
|
||||
public:
|
||||
// std::string handle; /*!< entity identifier, code 5 */
|
||||
|
@ -647,7 +603,6 @@ public:
|
|||
|
||||
protected:
|
||||
void parseCode(int code, dxfReader *reader){DRW_TableEntry::parseCode(code, reader);}
|
||||
bool parseDwg(DRW::Version version, dwgBuffer *buf, duint32 bs=0);
|
||||
};
|
||||
|
||||
namespace DRW {
|
||||
|
|
|
@ -1,925 +0,0 @@
|
|||
/******************************************************************************
|
||||
** libDXFrw - Library to read/write DXF files (ascii & binary) **
|
||||
** **
|
||||
** Copyright (C) 2011-2015 José F. Soriano, rallazz@gmail.com **
|
||||
** **
|
||||
** This library is free software, licensed under the terms of the GNU **
|
||||
** General Public License as published by the Free Software Foundation, **
|
||||
** either version 2 of the License, or (at your option) any later version. **
|
||||
** You should have received a copy of the GNU General Public License **
|
||||
** along with this program. If not, see <http://www.gnu.org/licenses/>. **
|
||||
******************************************************************************/
|
||||
|
||||
|
||||
#include "dwgbuffer.h"
|
||||
#include "../libdwgr.h"
|
||||
#include "drw_textcodec.h"
|
||||
#include "drw_dbg.h"
|
||||
//#include <bitset>
|
||||
/*#include <fstream>
|
||||
#include <algorithm>
|
||||
#include <sstream>
|
||||
#include "dwgreader.h"*/
|
||||
//#include "dxfwriter.h"
|
||||
|
||||
|
||||
//#define FIRSTHANDLE 48
|
||||
|
||||
/*enum sections {
|
||||
secUnknown,
|
||||
secHeader,
|
||||
secTables,
|
||||
secBlocks,
|
||||
secEntities,
|
||||
secObjects
|
||||
};*/
|
||||
|
||||
static unsigned int crctable[256]= {
|
||||
0x0000,0xC0C1,0xC181,0x0140,0xC301,0x03C0,0x0280,0xC241,
|
||||
0xC601,0x06C0,0x0780,0xC741,0x0500,0xC5C1,0xC481,0x0440,
|
||||
0xCC01,0x0CC0,0x0D80,0xCD41,0x0F00,0xCFC1,0xCE81,0x0E40,
|
||||
0x0A00,0xCAC1,0xCB81,0x0B40,0xC901,0x09C0,0x0880,0xC841,
|
||||
0xD801,0x18C0,0x1980,0xD941,0x1B00,0xDBC1,0xDA81,0x1A40,
|
||||
0x1E00,0xDEC1,0xDF81,0x1F40,0xDD01,0x1DC0,0x1C80,0xDC41,
|
||||
0x1400,0xD4C1,0xD581,0x1540,0xD701,0x17C0,0x1680,0xD641,
|
||||
0xD201,0x12C0,0x1380,0xD341,0x1100,0xD1C1,0xD081,0x1040,
|
||||
0xF001,0x30C0,0x3180,0xF141,0x3300,0xF3C1,0xF281,0x3240,
|
||||
0x3600,0xF6C1,0xF781,0x3740,0xF501,0x35C0,0x3480,0xF441,
|
||||
0x3C00,0xFCC1,0xFD81,0x3D40,0xFF01,0x3FC0,0x3E80,0xFE41,
|
||||
0xFA01,0x3AC0,0x3B80,0xFB41,0x3900,0xF9C1,0xF881,0x3840,
|
||||
0x2800,0xE8C1,0xE981,0x2940,0xEB01,0x2BC0,0x2A80,0xEA41,
|
||||
0xEE01,0x2EC0,0x2F80,0xEF41,0x2D00,0xEDC1,0xEC81,0x2C40,
|
||||
0xE401,0x24C0,0x2580,0xE541,0x2700,0xE7C1,0xE681,0x2640,
|
||||
0x2200,0xE2C1,0xE381,0x2340,0xE101,0x21C0,0x2080,0xE041,
|
||||
0xA001,0x60C0,0x6180,0xA141,0x6300,0xA3C1,0xA281,0x6240,
|
||||
0x6600,0xA6C1,0xA781,0x6740,0xA501,0x65C0,0x6480,0xA441,
|
||||
0x6C00,0xACC1,0xAD81,0x6D40,0xAF01,0x6FC0,0x6E80,0xAE41,
|
||||
0xAA01,0x6AC0,0x6B80,0xAB41,0x6900,0xA9C1,0xA881,0x6840,
|
||||
0x7800,0xB8C1,0xB981,0x7940,0xBB01,0x7BC0,0x7A80,0xBA41,
|
||||
0xBE01,0x7EC0,0x7F80,0xBF41,0x7D00,0xBDC1,0xBC81,0x7C40,
|
||||
0xB401,0x74C0,0x7580,0xB541,0x7700,0xB7C1,0xB681,0x7640,
|
||||
0x7200,0xB2C1,0xB381,0x7340,0xB101,0x71C0,0x7080,0xB041,
|
||||
0x5000,0x90C1,0x9181,0x5140,0x9301,0x53C0,0x5280,0x9241,
|
||||
0x9601,0x56C0,0x5780,0x9741,0x5500,0x95C1,0x9481,0x5440,
|
||||
0x9C01,0x5CC0,0x5D80,0x9D41,0x5F00,0x9FC1,0x9E81,0x5E40,
|
||||
0x5A00,0x9AC1,0x9B81,0x5B40,0x9901,0x59C0,0x5880,0x9841,
|
||||
0x8801,0x48C0,0x4980,0x8941,0x4B00,0x8BC1,0x8A81,0x4A40,
|
||||
0x4E00,0x8EC1,0x8F81,0x4F40,0x8D01,0x4DC0,0x4C80,0x8C41,
|
||||
0x4400,0x84C1,0x8581,0x4540,0x8701,0x47C0,0x4680,0x8641,
|
||||
0x8201,0x42C0,0x4380,0x8341,0x4100,0x81C1,0x8081,0x4040 };
|
||||
|
||||
static unsigned int crc32Table[256] ={
|
||||
0x00000000, 0x77073096, 0xee0e612c, 0x990951ba, 0x076dc419, 0x706af48f, 0xe963a535, 0x9e6495a3,
|
||||
0x0edb8832, 0x79dcb8a4, 0xe0d5e91e, 0x97d2d988, 0x09b64c2b, 0x7eb17cbd, 0xe7b82d07, 0x90bf1d91,
|
||||
0x1db71064, 0x6ab020f2, 0xf3b97148, 0x84be41de, 0x1adad47d, 0x6ddde4eb, 0xf4d4b551, 0x83d385c7,
|
||||
0x136c9856, 0x646ba8c0, 0xfd62f97a, 0x8a65c9ec, 0x14015c4f, 0x63066cd9, 0xfa0f3d63, 0x8d080df5,
|
||||
0x3b6e20c8, 0x4c69105e, 0xd56041e4, 0xa2677172, 0x3c03e4d1, 0x4b04d447, 0xd20d85fd, 0xa50ab56b,
|
||||
0x35b5a8fa, 0x42b2986c, 0xdbbbc9d6, 0xacbcf940, 0x32d86ce3, 0x45df5c75, 0xdcd60dcf, 0xabd13d59,
|
||||
0x26d930ac, 0x51de003a, 0xc8d75180, 0xbfd06116, 0x21b4f4b5, 0x56b3c423, 0xcfba9599, 0xb8bda50f,
|
||||
0x2802b89e, 0x5f058808, 0xc60cd9b2, 0xb10be924, 0x2f6f7c87, 0x58684c11, 0xc1611dab, 0xb6662d3d,
|
||||
0x76dc4190, 0x01db7106, 0x98d220bc, 0xefd5102a, 0x71b18589, 0x06b6b51f, 0x9fbfe4a5, 0xe8b8d433,
|
||||
0x7807c9a2, 0x0f00f934, 0x9609a88e, 0xe10e9818, 0x7f6a0dbb, 0x086d3d2d, 0x91646c97, 0xe6635c01,
|
||||
0x6b6b51f4, 0x1c6c6162, 0x856530d8, 0xf262004e, 0x6c0695ed, 0x1b01a57b, 0x8208f4c1, 0xf50fc457,
|
||||
0x65b0d9c6, 0x12b7e950, 0x8bbeb8ea, 0xfcb9887c, 0x62dd1ddf, 0x15da2d49, 0x8cd37cf3, 0xfbd44c65,
|
||||
0x4db26158, 0x3ab551ce, 0xa3bc0074, 0xd4bb30e2, 0x4adfa541, 0x3dd895d7, 0xa4d1c46d, 0xd3d6f4fb,
|
||||
0x4369e96a, 0x346ed9fc, 0xad678846, 0xda60b8d0, 0x44042d73, 0x33031de5, 0xaa0a4c5f, 0xdd0d7cc9,
|
||||
0x5005713c, 0x270241aa, 0xbe0b1010, 0xc90c2086, 0x5768b525, 0x206f85b3, 0xb966d409, 0xce61e49f,
|
||||
0x5edef90e, 0x29d9c998, 0xb0d09822, 0xc7d7a8b4, 0x59b33d17, 0x2eb40d81, 0xb7bd5c3b, 0xc0ba6cad,
|
||||
0xedb88320, 0x9abfb3b6, 0x03b6e20c, 0x74b1d29a, 0xead54739, 0x9dd277af, 0x04db2615, 0x73dc1683,
|
||||
0xe3630b12, 0x94643b84, 0x0d6d6a3e, 0x7a6a5aa8, 0xe40ecf0b, 0x9309ff9d, 0x0a00ae27, 0x7d079eb1,
|
||||
0xf00f9344, 0x8708a3d2, 0x1e01f268, 0x6906c2fe, 0xf762575d, 0x806567cb, 0x196c3671, 0x6e6b06e7,
|
||||
0xfed41b76, 0x89d32be0, 0x10da7a5a, 0x67dd4acc, 0xf9b9df6f, 0x8ebeeff9, 0x17b7be43, 0x60b08ed5,
|
||||
0xd6d6a3e8, 0xa1d1937e, 0x38d8c2c4, 0x4fdff252, 0xd1bb67f1, 0xa6bc5767, 0x3fb506dd, 0x48b2364b,
|
||||
0xd80d2bda, 0xaf0a1b4c, 0x36034af6, 0x41047a60, 0xdf60efc3, 0xa867df55, 0x316e8eef, 0x4669be79,
|
||||
0xcb61b38c, 0xbc66831a, 0x256fd2a0, 0x5268e236, 0xcc0c7795, 0xbb0b4703, 0x220216b9, 0x5505262f,
|
||||
0xc5ba3bbe, 0xb2bd0b28, 0x2bb45a92, 0x5cb36a04, 0xc2d7ffa7, 0xb5d0cf31, 0x2cd99e8b, 0x5bdeae1d,
|
||||
0x9b64c2b0, 0xec63f226, 0x756aa39c, 0x026d930a, 0x9c0906a9, 0xeb0e363f, 0x72076785, 0x05005713,
|
||||
0x95bf4a82, 0xe2b87a14, 0x7bb12bae, 0x0cb61b38, 0x92d28e9b, 0xe5d5be0d, 0x7cdcefb7, 0x0bdbdf21,
|
||||
0x86d3d2d4, 0xf1d4e242, 0x68ddb3f8, 0x1fda836e, 0x81be16cd, 0xf6b9265b, 0x6fb077e1, 0x18b74777,
|
||||
0x88085ae6, 0xff0f6a70, 0x66063bca, 0x11010b5c, 0x8f659eff, 0xf862ae69, 0x616bffd3, 0x166ccf45,
|
||||
0xa00ae278, 0xd70dd2ee, 0x4e048354, 0x3903b3c2, 0xa7672661, 0xd06016f7, 0x4969474d, 0x3e6e77db,
|
||||
0xaed16a4a, 0xd9d65adc, 0x40df0b66, 0x37d83bf0, 0xa9bcae53, 0xdebb9ec5, 0x47b2cf7f, 0x30b5ffe9,
|
||||
0xbdbdf21c, 0xcabac28a, 0x53b39330, 0x24b4a3a6, 0xbad03605, 0xcdd70693, 0x54de5729, 0x23d967bf,
|
||||
0xb3667a2e, 0xc4614ab8, 0x5d681b02, 0x2a6f2b94, 0xb40bbe37, 0xc30c8ea1, 0x5a05df1b, 0x2d02ef8d};
|
||||
|
||||
bool dwgFileStream::setPos(duint64 p){
|
||||
if (p >= sz)
|
||||
return false;
|
||||
|
||||
stream->seekg(p);
|
||||
return stream->good();
|
||||
}
|
||||
|
||||
bool dwgFileStream::read(duint8* s, duint64 n){
|
||||
stream->read (reinterpret_cast<char*>(s),n);
|
||||
return stream->good();
|
||||
}
|
||||
|
||||
bool dwgCharStream::setPos(duint64 p){
|
||||
if (p > size()) {
|
||||
isOk = false;
|
||||
return false;
|
||||
}
|
||||
|
||||
pos = p;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool dwgCharStream::read(duint8* s, duint64 n){
|
||||
if ( n > (sz - pos) ) {
|
||||
isOk = false;
|
||||
return false;
|
||||
}
|
||||
for (duint64 i=0; i<n; i++){
|
||||
s[i]= stream[pos++];
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
dwgBuffer::dwgBuffer(duint8 *buf, int size, DRW_TextCodec *dc)
|
||||
: decoder(dc),
|
||||
filestr(new dwgCharStream(buf, size)),
|
||||
maxSize(size),
|
||||
currByte(),
|
||||
bitPos(0)
|
||||
{}
|
||||
|
||||
dwgBuffer::dwgBuffer(std::istream *stream, DRW_TextCodec *dc)
|
||||
: decoder(dc),
|
||||
filestr(new dwgFileStream(stream)),
|
||||
maxSize(static_cast<int>(filestr->size())),
|
||||
currByte(),
|
||||
bitPos(0)
|
||||
{}
|
||||
|
||||
dwgBuffer::dwgBuffer( const dwgBuffer& org )
|
||||
: decoder(org.decoder),
|
||||
filestr(org.filestr->clone()),
|
||||
maxSize(static_cast<int>(filestr->size())),
|
||||
currByte(org.currByte),
|
||||
bitPos(org.bitPos)
|
||||
{}
|
||||
|
||||
dwgBuffer& dwgBuffer::operator=( const dwgBuffer& org )
|
||||
{
|
||||
if (&org == this)
|
||||
{
|
||||
return *this;
|
||||
}
|
||||
|
||||
filestr = org.filestr->clone();
|
||||
decoder = org.decoder;
|
||||
maxSize = static_cast<int>(filestr->size());
|
||||
currByte = org.currByte;
|
||||
bitPos = org.bitPos;
|
||||
return *this;
|
||||
}
|
||||
|
||||
dwgBuffer::~dwgBuffer(){
|
||||
delete filestr;
|
||||
}
|
||||
|
||||
/**Gets the current byte position in buffer **/
|
||||
duint64 dwgBuffer::getPosition(){
|
||||
if (bitPos != 0)
|
||||
return filestr->getPos() -1;
|
||||
return filestr->getPos();
|
||||
}
|
||||
|
||||
/**Sets the buffer position in pos byte, reset the bit position **/
|
||||
bool dwgBuffer::setPosition(duint64 pos){
|
||||
bitPos = 0;
|
||||
/* if (pos>=maxSize)
|
||||
return false;*/
|
||||
return filestr->setPos(pos);
|
||||
// return true;
|
||||
}
|
||||
|
||||
//RLZ: Fails if ... ???
|
||||
void dwgBuffer::setBitPos(duint8 pos){
|
||||
if (pos>7)
|
||||
return;
|
||||
if (pos != 0 && bitPos == 0){
|
||||
duint8 buffer;
|
||||
filestr->read (&buffer,1);
|
||||
currByte = buffer;
|
||||
}
|
||||
if (pos == 0 && bitPos != 0){//reset current byte
|
||||
filestr->setPos(filestr->getPos()-1);
|
||||
}
|
||||
bitPos = pos;
|
||||
}
|
||||
|
||||
bool dwgBuffer::moveBitPos(dint32 size){
|
||||
if (size == 0) return true;
|
||||
|
||||
dint32 b= size + bitPos;
|
||||
filestr->setPos(getPosition() + (b >> 3) );
|
||||
bitPos = b & 7;
|
||||
|
||||
if (bitPos != 0){
|
||||
filestr->read (&currByte,1);
|
||||
}
|
||||
return filestr->good();
|
||||
}
|
||||
|
||||
/**Reads one Bit returns a char with value 0/1 (B) **/
|
||||
duint8 dwgBuffer::getBit(){
|
||||
duint8 buffer;
|
||||
duint8 ret = 0;
|
||||
if (bitPos == 0){
|
||||
filestr->read (&buffer,1);
|
||||
currByte = buffer;
|
||||
}
|
||||
|
||||
ret = (currByte >> (7 - bitPos) & 1);
|
||||
++bitPos;
|
||||
if (bitPos == 8)
|
||||
bitPos = 0;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**Reads one Bit returns a bool value 0==false 1==true (B) **/
|
||||
bool dwgBuffer::getBoolBit(){
|
||||
return (getBit() != 0);
|
||||
}
|
||||
|
||||
/**Reads two Bits returns a char (BB) **/
|
||||
duint8 dwgBuffer::get2Bits(){
|
||||
duint8 buffer;
|
||||
duint8 ret = 0;
|
||||
if (bitPos == 0){
|
||||
filestr->read (&buffer,1);
|
||||
currByte = buffer;
|
||||
}
|
||||
|
||||
bitPos = static_cast<duint8>(bitPos+2);
|
||||
if (bitPos < 9)
|
||||
ret = static_cast<duint8>(currByte >>(8 - bitPos));
|
||||
else {//read one bit per byte
|
||||
ret = static_cast<duint8>(currByte << 1);
|
||||
filestr->read (&buffer,1);
|
||||
currByte = buffer;
|
||||
bitPos = 1;
|
||||
ret = static_cast<duint8>(ret | currByte >> 7);
|
||||
}
|
||||
if (bitPos == 8)
|
||||
bitPos = 0;
|
||||
ret = ret & 3;
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**Reads thee Bits returns a char (3B) **/
|
||||
//RLZ: todo verify this
|
||||
duint8 dwgBuffer::get3Bits(){
|
||||
duint8 buffer;
|
||||
duint8 ret = 0;
|
||||
if (bitPos == 0){
|
||||
filestr->read (&buffer,1);
|
||||
currByte = buffer;
|
||||
}
|
||||
|
||||
bitPos = static_cast<duint8>(bitPos + 3);
|
||||
if (bitPos < 9)
|
||||
ret = static_cast<duint8>(currByte >>(8 - bitPos));
|
||||
else {//read one bit per byte
|
||||
ret = static_cast<duint8>(currByte << 1);
|
||||
filestr->read (&buffer,1);
|
||||
currByte = buffer;
|
||||
bitPos = 1;
|
||||
ret = static_cast<duint8>(ret | currByte >> 7);
|
||||
}
|
||||
if (bitPos == 8)
|
||||
bitPos = 0;
|
||||
ret = ret & 7;
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**Reads tree Bits returns a char (3B) for R24 **/
|
||||
//to be written
|
||||
|
||||
/**Reads compresed Short (max. 16 + 2 bits) little-endian order, returns a UNsigned 16 bits (BS) **/
|
||||
duint16 dwgBuffer::getBitShort(){
|
||||
duint8 b = get2Bits();
|
||||
if (b == 0)
|
||||
return getRawShort16();
|
||||
else if (b== 1)
|
||||
return getRawChar8();
|
||||
else if (b == 2)
|
||||
return 0;
|
||||
else
|
||||
return 256;
|
||||
}
|
||||
/**Reads compresed Short (max. 16 + 2 bits) little-endian order, returns a signed 16 bits (BS) **/
|
||||
dint16 dwgBuffer::getSBitShort(){
|
||||
duint8 b = get2Bits();
|
||||
if (b == 0)
|
||||
return static_cast<dint16>(getRawShort16());
|
||||
else if (b== 1)
|
||||
return static_cast<dint16>(getRawChar8());
|
||||
else if (b == 2)
|
||||
return 0;
|
||||
else
|
||||
return 256;
|
||||
}
|
||||
|
||||
/**Reads compresed 32 bits Int (max. 32 + 2 bits) little-endian order, returns a signed 32 bits (BL) **/
|
||||
//to be written
|
||||
dint32 dwgBuffer::getBitLong(){
|
||||
dint8 b = get2Bits();
|
||||
if (b == 0)
|
||||
return getRawLong32();
|
||||
else if (b== 1)
|
||||
return getRawChar8();
|
||||
else //if (b == 2)
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**Reads compresed 64 bits Int (max. 56 + 3 bits) little-endian order, returns a unsigned 64 bits (BLL) **/
|
||||
duint64 dwgBuffer::getBitLongLong(){
|
||||
dint8 b = get3Bits();
|
||||
duint64 ret=0;
|
||||
for (duint8 i=0; i<b; i++){
|
||||
ret = ret << 8;
|
||||
ret |= getRawChar8();
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**Reads compresed Double (max. 64 + 2 bits) returns a floating point double of 64 bits (BD) **/
|
||||
double dwgBuffer::getBitDouble(){
|
||||
dint8 b = get2Bits();
|
||||
if (b == 1)
|
||||
return 1.0;
|
||||
else if (b == 0){
|
||||
duint8 buffer[8];
|
||||
if (bitPos != 0) {
|
||||
for (int i = 0; i < 8; i++)
|
||||
buffer[i] = getRawChar8();
|
||||
} else {
|
||||
filestr->read (buffer,8);
|
||||
}
|
||||
// cppcheck-suppress invalidPointerCast
|
||||
double* ret = reinterpret_cast<double*>( buffer );
|
||||
return *ret;
|
||||
}
|
||||
// if (b == 2)
|
||||
return 0.0;
|
||||
}
|
||||
|
||||
/**Reads 3 compresed Double (max. 64 + 2 bits) returns a DRW_Coord of floating point double of 64 bits (3BD) **/
|
||||
DRW_Coord dwgBuffer::get3BitDouble(){
|
||||
DRW_Coord crd;
|
||||
crd.x = getBitDouble();
|
||||
crd.y = getBitDouble();
|
||||
crd.z = getBitDouble();
|
||||
return crd;
|
||||
}
|
||||
|
||||
/**Reads raw char 8 bits returns a unsigned char (RC) **/
|
||||
duint8 dwgBuffer::getRawChar8(){
|
||||
duint8 ret;
|
||||
duint8 buffer;
|
||||
filestr->read (&buffer,1);
|
||||
if (bitPos == 0)
|
||||
return buffer;
|
||||
else {
|
||||
ret = static_cast<duint8>(currByte << bitPos);
|
||||
currByte = buffer;
|
||||
ret = static_cast<duint8>(ret | (currByte >>(8 - bitPos)));
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**Reads raw short 16 bits little-endian order, returns a unsigned short (RS) **/
|
||||
duint16 dwgBuffer::getRawShort16(){
|
||||
duint8 buffer[2];
|
||||
duint16 ret;
|
||||
|
||||
filestr->read (buffer,2);
|
||||
if (bitPos == 0) {
|
||||
/* no offset directly swap bytes for little-endian */
|
||||
ret = static_cast<duint16>((buffer[1] << 8) | (buffer[0] & 0x00FF));
|
||||
} else {
|
||||
ret = static_cast<duint16>((buffer[0] << 8) | (buffer[1] & 0x00FF));
|
||||
/* apply offset */
|
||||
ret = static_cast<duint16>(ret >> (8 - bitPos));
|
||||
ret = static_cast<duint16>(ret | (currByte << (8 + bitPos)));
|
||||
currByte = buffer[1];
|
||||
/* swap bytes for little-endian */
|
||||
ret = static_cast<duint16>((ret << 8) | (ret >> 8));
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**Reads raw double IEEE standard 64 bits returns a double (RD) **/
|
||||
double dwgBuffer::getRawDouble(){
|
||||
duint8 buffer[8];
|
||||
if (bitPos == 0)
|
||||
filestr->read (buffer,8);
|
||||
else {
|
||||
for (int i = 0; i < 8; i++)
|
||||
buffer[i] = getRawChar8();
|
||||
}
|
||||
// cppcheck-suppress invalidPointerCast
|
||||
double* nOffset = reinterpret_cast<double*>( buffer );
|
||||
return *nOffset;
|
||||
}
|
||||
|
||||
/**Reads 2 raw double IEEE standard 64 bits returns a DRW_Coord of floating point double 64 bits (2RD) **/
|
||||
DRW_Coord dwgBuffer::get2RawDouble(){
|
||||
DRW_Coord crd;
|
||||
crd.x = getRawDouble();
|
||||
crd.y = getRawDouble();
|
||||
return crd;
|
||||
}
|
||||
|
||||
|
||||
/**Reads raw int 32 bits little-endian order, returns a unsigned int (RL) **/
|
||||
duint32 dwgBuffer::getRawLong32(){
|
||||
duint16 tmp1 = getRawShort16();
|
||||
duint16 tmp2 = getRawShort16();
|
||||
duint32 ret = (tmp2 << 16) | (tmp1 & 0x0000FFFF);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**Reads raw int 64 bits little-endian order, returns a unsigned long long (RLL) **/
|
||||
duint64 dwgBuffer::getRawLong64(){
|
||||
duint32 tmp1 = getRawLong32();
|
||||
duint64 tmp2 = getRawLong32();
|
||||
duint64 ret = (tmp2 << 32) | (tmp1 & 0x00000000FFFFFFFF);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**Reads modular unsigner int, char based, compresed form, little-endian order, returns a unsigned int (U-MC) **/
|
||||
duint32 dwgBuffer::getUModularChar(){
|
||||
std::vector<duint8> buffer;
|
||||
duint32 result =0;
|
||||
for (int i=0; i<4;i++){
|
||||
duint8 b= getRawChar8();
|
||||
buffer.push_back(b & 0x7F);
|
||||
if (! (b & 0x80))
|
||||
break;
|
||||
}
|
||||
int offset = 0;
|
||||
for (unsigned int i=0; i<buffer.size();i++){
|
||||
result += buffer[i] << offset;
|
||||
offset +=7;
|
||||
}
|
||||
//RLZ: WARNING!!! needed to verify on read handles
|
||||
//result = result & 0x7F;
|
||||
return result;
|
||||
}
|
||||
|
||||
/**Reads modular int, char based, compresed form, little-endian order, returns a signed int (MC) **/
|
||||
dint32 dwgBuffer::getModularChar(){
|
||||
bool negative = false;
|
||||
std::vector<dint8> buffer;
|
||||
dint32 result =0;
|
||||
for (int i=0; i<4;i++){
|
||||
duint8 b= getRawChar8();
|
||||
buffer.push_back(b & 0x7F);
|
||||
if (! (b & 0x80))
|
||||
break;
|
||||
}
|
||||
dint8 b= buffer.back();
|
||||
if (b & 0x40) {
|
||||
negative = true;
|
||||
buffer.pop_back();
|
||||
buffer.push_back(b & 0x3F);
|
||||
}
|
||||
|
||||
int offset = 0;
|
||||
for (unsigned int i=0; i<buffer.size();i++){
|
||||
result += buffer[i] << offset;
|
||||
offset +=7;
|
||||
}
|
||||
if (negative)
|
||||
result = -result;
|
||||
return result;
|
||||
}
|
||||
|
||||
/**Reads modular int, short based, compresed form, little-endian order, returns a unsigned int (MC) **/
|
||||
dint32 dwgBuffer::getModularShort(){
|
||||
// bool negative = false;
|
||||
std::vector<dint16> buffer;
|
||||
dint32 result =0;
|
||||
for (int i=0; i<2;i++){
|
||||
duint16 b= getRawShort16();
|
||||
buffer.push_back(b & 0x7FFF);
|
||||
if (! (b & 0x8000))
|
||||
break;
|
||||
}
|
||||
|
||||
//only positive ?
|
||||
/* dint8 b= buffer.back();
|
||||
if (! (b & 0x40)) {
|
||||
negative = true;
|
||||
buffer.pop_back();
|
||||
buffer.push_back(b & 0x3F);
|
||||
}*/
|
||||
|
||||
int offset = 0;
|
||||
for (unsigned int i=0; i<buffer.size();i++){
|
||||
result += buffer[i] << offset;
|
||||
offset +=15;
|
||||
}
|
||||
/* if (negative)
|
||||
result = -result;*/
|
||||
return result;
|
||||
}
|
||||
|
||||
dwgHandle dwgBuffer::getHandle(){ //H
|
||||
dwgHandle hl;
|
||||
duint8 data = getRawChar8();
|
||||
hl.code = (data >> 4) & 0x0F;
|
||||
hl.size = data & 0x0F;
|
||||
hl.ref=0;
|
||||
for (int i=0; i< hl.size;i++){
|
||||
hl.ref = (hl.ref << 8) | getRawChar8();
|
||||
}
|
||||
return hl;
|
||||
}
|
||||
|
||||
dwgHandle dwgBuffer::getOffsetHandle(duint32 href){ //H
|
||||
dwgHandle hl = getHandle();
|
||||
|
||||
if (hl.code > 5){
|
||||
if (hl.code == 0x0C)
|
||||
hl.ref = href - hl.ref;
|
||||
else if (hl.code == 0x0A)
|
||||
hl.ref = href + hl.ref;
|
||||
else if (hl.code == 0x08)
|
||||
hl.ref = href - 1;
|
||||
else if (hl.code == 0x06)
|
||||
hl.ref = href + 1;
|
||||
//all are soft pointer reference change to 7 (without offset)
|
||||
hl.code = 7;
|
||||
}
|
||||
return hl;
|
||||
}
|
||||
|
||||
//internal until 2004
|
||||
std::string dwgBuffer::get8bitStr(){
|
||||
duint16 textSize = getBitShort();
|
||||
if (textSize == 0)
|
||||
return std::string();
|
||||
duint8 *tmpBuffer = new duint8[textSize];
|
||||
bool good = getBytes(tmpBuffer, textSize);
|
||||
if (!good)
|
||||
return std::string();
|
||||
|
||||
/* filestr->read (buffer,textSize);
|
||||
if (!filestr->good())
|
||||
return std::string();
|
||||
|
||||
duint8 tmp;
|
||||
if (bitPos != 0){
|
||||
for (int i=0; i<textSize;i++){
|
||||
tmp = buffer[i];
|
||||
buffer[i] = (currByte << bitPos) | (tmp >> (8 - bitPos));
|
||||
currByte = tmp;
|
||||
}
|
||||
}*/
|
||||
std::string str(reinterpret_cast<char*>(tmpBuffer), textSize);
|
||||
delete[]tmpBuffer;
|
||||
|
||||
return str;
|
||||
}
|
||||
|
||||
//internal since 2007 //pending: are 2 bytes null terminated??
|
||||
//nullTerm = true if string are 2 bytes null terminated from the stream
|
||||
std::string dwgBuffer::get16bitStr(duint16 textSize, bool nullTerm){
|
||||
if (textSize == 0)
|
||||
return std::string();
|
||||
textSize = static_cast<duint16>(textSize*2);
|
||||
duint16 ts = textSize;
|
||||
if (nullTerm)
|
||||
ts = static_cast<duint16>(ts+2);
|
||||
duint8 *tmpBuffer = new duint8[textSize + 2];
|
||||
bool good = getBytes(tmpBuffer, ts);
|
||||
if (!good)
|
||||
return std::string();
|
||||
if (!nullTerm) {
|
||||
tmpBuffer[textSize] = '\0';
|
||||
tmpBuffer[textSize + 1] = '\0';
|
||||
}
|
||||
std::string str(reinterpret_cast<char*>(tmpBuffer), ts);
|
||||
delete[]tmpBuffer;
|
||||
|
||||
return str;
|
||||
}
|
||||
|
||||
//T 8 bit text converted from codepage to utf8
|
||||
std::string dwgBuffer::getCP8Text(){
|
||||
std::string strData;
|
||||
strData = get8bitStr();//RLZ correct these function
|
||||
if (decoder == NULL)
|
||||
return strData;
|
||||
|
||||
return decoder->toUtf8(strData);
|
||||
}
|
||||
|
||||
//TU unicode 16 bit (UCS) text converted to utf8
|
||||
/**Reads 2-bytes char (UCS2, NULL terminated) and convert to std::string (only for Latin-1)
|
||||
ts= total input size in bytes.
|
||||
**/
|
||||
std::string dwgBuffer::getUCSStr(duint16 ts){
|
||||
std::string strData;
|
||||
if (ts<4) //at least 1 char
|
||||
return std::string();
|
||||
strData = get16bitStr(ts/2, false);
|
||||
if (decoder == NULL)
|
||||
return strData;
|
||||
|
||||
return decoder->toUtf8(strData);
|
||||
}
|
||||
|
||||
//TU unicode 16 bit (UCS) text converted to utf8
|
||||
//nullTerm = true if string are 2 bytes null terminated from the stream
|
||||
std::string dwgBuffer::getUCSText(bool nullTerm){
|
||||
std::string strData;
|
||||
duint16 ts = getBitShort();
|
||||
if (ts == 0)
|
||||
return std::string();
|
||||
|
||||
strData = get16bitStr(ts, nullTerm);
|
||||
if (decoder == NULL)
|
||||
return strData;
|
||||
|
||||
return decoder->toUtf8(strData);
|
||||
}
|
||||
|
||||
//RLZ: read a T or TU if version is 2007+
|
||||
//nullTerm = true if string are 2 bytes null terminated from the stream
|
||||
std::string dwgBuffer::getVariableText(DRW::Version v, bool nullTerm){//TV
|
||||
if (v > DRW::AC1018)
|
||||
return getUCSText(nullTerm);
|
||||
return getCP8Text();
|
||||
}
|
||||
duint16 dwgBuffer::getObjType(DRW::Version v){//OT
|
||||
if (v > DRW::AC1021) {
|
||||
duint8 b = get2Bits();
|
||||
if (b == 0)
|
||||
return getRawChar8();
|
||||
else if (b== 1){
|
||||
return static_cast<duint16>((getRawChar8() + 0x01F0));
|
||||
} else //b == 2
|
||||
return getRawShort16();
|
||||
}
|
||||
return getBitShort();
|
||||
}
|
||||
|
||||
/* Bit Extrusion
|
||||
* For R2000+, this is a single bit, If the single bit is 1,
|
||||
* the extrusion value is assumed to be 0,0,1 and no explicit
|
||||
* extrusion is stored. If the single bit is 0, then it will
|
||||
* be followed by 3BD.
|
||||
* For R13-R14 this is 3BD.
|
||||
*/
|
||||
DRW_Coord dwgBuffer::getExtrusion(bool b_R2000_style) {
|
||||
DRW_Coord ext(0.0,0.0,1.0);
|
||||
if ( b_R2000_style )
|
||||
/* If the bit is one, the extrusion value is assumed to be 0,0,1*/
|
||||
if ( getBit() == 1 )
|
||||
return ext;
|
||||
/*R13-R14 or bit == 0*/
|
||||
ext.x = getBitDouble();
|
||||
ext.y = getBitDouble();
|
||||
ext.z = getBitDouble();
|
||||
return ext;
|
||||
}
|
||||
|
||||
/**Reads compresed Double with default (max. 64 + 2 bits) returns a floating point double of 64 bits (DD) **/
|
||||
double dwgBuffer::getDefaultDouble(double d){
|
||||
dint8 b = get2Bits();
|
||||
if (b == 0)
|
||||
return d;
|
||||
else if (b == 1){
|
||||
duint8 buffer[4];
|
||||
char *tmp;
|
||||
if (bitPos != 0) {
|
||||
for (int i = 0; i < 4; i++)
|
||||
buffer[i] = getRawChar8();
|
||||
} else {
|
||||
filestr->read (buffer,4);
|
||||
}
|
||||
// cppcheck-suppress invalidPointerCast
|
||||
tmp = reinterpret_cast<char*>(&d);
|
||||
for (int i = 0; i < 4; i++)
|
||||
tmp[i] = buffer[i];
|
||||
// cppcheck-suppress invalidPointerCast
|
||||
double ret = *reinterpret_cast<double*>( tmp );
|
||||
return ret;
|
||||
} else if (b == 2){
|
||||
duint8 buffer[6];
|
||||
char *tmp;
|
||||
if (bitPos != 0) {
|
||||
for (int i = 0; i < 6; i++)
|
||||
buffer[i] = getRawChar8();
|
||||
} else {
|
||||
filestr->read (buffer,6);
|
||||
}
|
||||
// cppcheck-suppress invalidPointerCast
|
||||
tmp = reinterpret_cast<char*>(&d);
|
||||
for (int i = 2; i < 6; i++)
|
||||
tmp[i-2] = buffer[i];
|
||||
tmp[4] = buffer[0];
|
||||
tmp[5] = buffer[1];
|
||||
// cppcheck-suppress invalidPointerCast
|
||||
double ret = *reinterpret_cast<double*>( tmp );
|
||||
return ret;
|
||||
}
|
||||
// if (b == 3) return a full raw double
|
||||
return getRawDouble();
|
||||
}
|
||||
|
||||
|
||||
/* BitThickness
|
||||
* For R13-R14, this is a BD.
|
||||
* For R2000+, this is a single bit, If the bit is one,
|
||||
* the thickness value is assumed to be 0.0, if not a BD follow
|
||||
*/
|
||||
double dwgBuffer::getThickness(bool b_R2000_style) {
|
||||
if ( b_R2000_style )
|
||||
/* If the bit is one, the thickness value is assumed to be 0.0.*/
|
||||
if ( getBit() == 1 )
|
||||
return 0.0;
|
||||
/*R13-R14 or bit == 0*/
|
||||
return getBitDouble();
|
||||
}
|
||||
|
||||
/* CmColor (CMC)
|
||||
* For R15 and earlier call directly BS as ACIS color.
|
||||
* For R2004+, can be CMC or ENC
|
||||
* RGB value, first 4bits 0xC0 => ByLayer, 0xC1 => ByBlock, 0xC2 => RGB, 0xC3 => last 4 are ACIS
|
||||
*/
|
||||
duint32 dwgBuffer::getCmColor(DRW::Version v) {
|
||||
if (v < DRW::AC1018) //2000-
|
||||
return getSBitShort();
|
||||
duint16 idx = getBitShort();
|
||||
duint32 rgb = getBitLong();
|
||||
duint8 cb = getRawChar8();
|
||||
duint8 type = static_cast<duint8>(rgb >> 24);
|
||||
DRW_DBG("\ntype COLOR: "); DRW_DBGH(type);
|
||||
DRW_DBG("\nindex COLOR: "); DRW_DBGH(idx);
|
||||
DRW_DBG("\nRGB COLOR: "); DRW_DBGH(rgb);
|
||||
DRW_DBG("\nbyte COLOR: "); DRW_DBGH(cb);
|
||||
if (cb&1){
|
||||
std::string colorName = getVariableText(v, false);
|
||||
DRW_DBG("\ncolorName: "); DRW_DBG(colorName);
|
||||
}
|
||||
if (cb&2){
|
||||
std::string bookName = getVariableText(v, false);
|
||||
DRW_DBG("\nbookName: "); DRW_DBG(bookName);
|
||||
}
|
||||
switch (type) {
|
||||
case 0xC0:
|
||||
return 256;//ByLayer
|
||||
break;
|
||||
case 0xC1:
|
||||
return 0;//ByBlock
|
||||
break;
|
||||
case 0xC2:
|
||||
return 256;//RGB RLZ TODO
|
||||
break;
|
||||
case 0xC3:
|
||||
return rgb&0xFF;//ACIS
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
//check cb if strings follows RLZ TODO
|
||||
return 256; //default return ByLayer
|
||||
}
|
||||
|
||||
/* EnColor (ENC)
|
||||
* For R15 and earlier call directly BS as ACIS color.
|
||||
* For R2004+, can be CMC or ENC
|
||||
* RGB value, first 4bits 0xC0 => ByLayer, 0xC1 => ByBlock, 0xC2 => RGB, 0xC3 => last 4 are ACIS
|
||||
*/
|
||||
duint32 dwgBuffer::getEnColor(DRW::Version v) {
|
||||
if (v < DRW::AC1018) //2000-
|
||||
return getSBitShort();
|
||||
duint32 rgb = 0;
|
||||
duint16 idx = getBitShort();
|
||||
DRW_DBG("idx reads COLOR: "); DRW_DBGH(idx);
|
||||
duint16 flags = static_cast<duint16>(idx>>8);
|
||||
idx = idx & 0x1FF; //RLZ: warning this is correct?
|
||||
DRW_DBG("\nflag COLOR: "); DRW_DBGH(flags);
|
||||
DRW_DBG(", index COLOR: "); DRW_DBGH(idx);
|
||||
// if (flags & 0x80) {
|
||||
// rgb = getBitLong();
|
||||
// DRW_DBG("\nRGB COLOR: "); DRW_DBGH(rgb);
|
||||
// }
|
||||
if (flags & 0x20) {
|
||||
duint32 cb = getBitLong();
|
||||
DRW_DBG("\nTransparency COLOR: "); DRW_DBGH(cb);
|
||||
}
|
||||
if (flags & 0x40)
|
||||
DRW_DBG("\nacdbColor COLOR are present");
|
||||
else {
|
||||
if (flags & 0x80) {
|
||||
rgb = getBitLong();
|
||||
DRW_DBG("\nRGB COLOR: "); DRW_DBGH(rgb);
|
||||
}
|
||||
}
|
||||
|
||||
/* if (flags & 0x80)
|
||||
return getBitLong();*/
|
||||
|
||||
return idx; //default return ByLayer
|
||||
}
|
||||
|
||||
|
||||
/**Reads raw short 16 bits big-endian order, returns a unsigned short crc & size **/
|
||||
duint16 dwgBuffer::getBERawShort16(){
|
||||
char buffer[2];
|
||||
buffer[0] = getRawChar8();
|
||||
buffer[1] = getRawChar8();
|
||||
duint16 size = static_cast<duint16>((buffer[0] << 8) | (buffer[1] & 0xFF));
|
||||
return size;
|
||||
}
|
||||
|
||||
/* reads "size" bytes and stores in "buf" return false if fail */
|
||||
bool dwgBuffer::getBytes(unsigned char *buf, int size){
|
||||
filestr->read (buf,size);
|
||||
if (!filestr->good())
|
||||
return false;
|
||||
|
||||
if (bitPos != 0){
|
||||
for (int i=0; i<size;i++){
|
||||
duint8 tmp = buf[i];
|
||||
buf[i] = static_cast<unsigned char>((currByte << bitPos) | (tmp >> (8 - bitPos)));
|
||||
currByte = tmp;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
duint16 dwgBuffer::crc8(duint16 dx, dint32 start, dint32 end){
|
||||
int pos = static_cast<int>(filestr->getPos());
|
||||
filestr->setPos(start);
|
||||
int n = end-start;
|
||||
duint8 *tmpBuf = new duint8[n];
|
||||
duint8 *p = tmpBuf;
|
||||
filestr->read (tmpBuf,n);
|
||||
filestr->setPos(pos);
|
||||
if (!filestr->good())
|
||||
return 0;
|
||||
|
||||
while (n-- > 0) {
|
||||
duint8 al = static_cast<duint8>((*p) ^ (static_cast<duint8>(dx & 0xFF)));
|
||||
dx = (dx>>8) & 0xFF;
|
||||
dx = static_cast<duint16>(dx ^ crctable[al & 0xFF]);
|
||||
p++;
|
||||
}
|
||||
delete[]tmpBuf;
|
||||
return(dx);
|
||||
}
|
||||
|
||||
duint32 dwgBuffer::crc32(duint32 seed,dint32 start,dint32 end){
|
||||
int pos = static_cast<int>(filestr->getPos());
|
||||
filestr->setPos(start);
|
||||
int n = end-start;
|
||||
duint8 *tmpBuf = new duint8[n];
|
||||
duint8 *p = tmpBuf;
|
||||
filestr->read (tmpBuf,n);
|
||||
filestr->setPos(pos);
|
||||
if (!filestr->good())
|
||||
return 0;
|
||||
|
||||
duint32 invertedCrc = ~seed;
|
||||
while (n-- > 0) {
|
||||
duint8 data = *p++;
|
||||
invertedCrc = (invertedCrc >> 8) ^ crc32Table[(invertedCrc ^ data) & 0xff];
|
||||
}
|
||||
delete[]tmpBuf;
|
||||
return ~invertedCrc;
|
||||
}
|
||||
|
||||
|
||||
/*std::string dwgBuffer::getBytes(int size){
|
||||
char buffer[size];
|
||||
char tmp;
|
||||
filestr->read (buffer,size);
|
||||
if (!filestr->good())
|
||||
return NULL;
|
||||
|
||||
if (bitPos != 0){
|
||||
for (int i=0; i<=size;i++){
|
||||
tmp = buffer[i];
|
||||
buffer[i] = (currByte << bitPos) | (tmp >> (8 - bitPos));
|
||||
currByte = tmp;
|
||||
}
|
||||
}
|
||||
std::string st;
|
||||
for (int i=0; i<size;i++) {
|
||||
st.push_back(buffer[i]);
|
||||
}
|
||||
return st;
|
||||
// return std::string(buffer);
|
||||
}*/
|
|
@ -1,162 +0,0 @@
|
|||
/******************************************************************************
|
||||
** libDXFrw - Library to read/write DXF files (ascii & binary) **
|
||||
** **
|
||||
** Copyright (C) 2011-2015 José F. Soriano, rallazz@gmail.com **
|
||||
** **
|
||||
** This library is free software, licensed under the terms of the GNU **
|
||||
** General Public License as published by the Free Software Foundation, **
|
||||
** either version 2 of the License, or (at your option) any later version. **
|
||||
** You should have received a copy of the GNU General Public License **
|
||||
** along with this program. If not, see <http://www.gnu.org/licenses/>. **
|
||||
******************************************************************************/
|
||||
|
||||
#ifndef DWGBUFFER_H
|
||||
#define DWGBUFFER_H
|
||||
|
||||
#include <fstream>
|
||||
#include <sstream>
|
||||
#include <QtGlobal>
|
||||
#include "../drw_base.h"
|
||||
|
||||
class DRW_Coord;
|
||||
class DRW_TextCodec;
|
||||
|
||||
class dwgBasicStream{
|
||||
protected:
|
||||
dwgBasicStream(){}
|
||||
public:
|
||||
virtual ~dwgBasicStream() = default;
|
||||
virtual bool read(duint8* s, duint64 n) = 0;
|
||||
virtual duint64 size() = 0;
|
||||
virtual duint64 getPos() = 0;
|
||||
virtual bool setPos(duint64 p) = 0;
|
||||
virtual bool good() = 0;
|
||||
virtual dwgBasicStream* clone() = 0;
|
||||
};
|
||||
|
||||
class dwgFileStream: public dwgBasicStream{
|
||||
public:
|
||||
explicit dwgFileStream(std::istream *s)
|
||||
: stream(nullptr),
|
||||
sz(0)
|
||||
{
|
||||
stream = s;
|
||||
stream->seekg (0, std::ios::end);
|
||||
sz = stream->tellg();
|
||||
stream->seekg(0, std::ios_base::beg);
|
||||
}
|
||||
virtual ~dwgFileStream() = default;
|
||||
virtual bool read(duint8* s, duint64 n);
|
||||
virtual duint64 size(){return sz;}
|
||||
virtual duint64 getPos(){return stream->tellg();}
|
||||
virtual bool setPos(duint64 p);
|
||||
virtual bool good(){return stream->good();}
|
||||
virtual dwgBasicStream* clone(){return new dwgFileStream(stream);}
|
||||
private:
|
||||
Q_DISABLE_COPY(dwgFileStream)
|
||||
std::istream *stream;
|
||||
duint64 sz;
|
||||
};
|
||||
|
||||
class dwgCharStream: public dwgBasicStream{
|
||||
public:
|
||||
dwgCharStream(duint8 *buf, duint64 s)
|
||||
: stream(buf),
|
||||
sz(s),
|
||||
pos(0),
|
||||
isOk(true)
|
||||
{}
|
||||
virtual ~dwgCharStream() = default;
|
||||
|
||||
virtual bool read(duint8* s, duint64 n);
|
||||
virtual duint64 size(){return sz;}
|
||||
virtual duint64 getPos(){return pos;}
|
||||
virtual bool setPos(duint64 p);
|
||||
virtual bool good(){return isOk;}
|
||||
virtual dwgBasicStream* clone(){return new dwgCharStream(stream, sz);}
|
||||
private:
|
||||
Q_DISABLE_COPY(dwgCharStream)
|
||||
duint8 *stream;
|
||||
duint64 sz;
|
||||
duint64 pos;
|
||||
bool isOk;
|
||||
};
|
||||
|
||||
class dwgBuffer {
|
||||
public:
|
||||
dwgBuffer(std::istream *stream, DRW_TextCodec *dc = nullptr);
|
||||
dwgBuffer(duint8 *buf, int size, DRW_TextCodec *dc = nullptr);
|
||||
dwgBuffer( const dwgBuffer& org );
|
||||
dwgBuffer& operator=( const dwgBuffer& org );
|
||||
~dwgBuffer();
|
||||
duint64 size(){return filestr->size();}
|
||||
bool setPosition(duint64 pos);
|
||||
duint64 getPosition();
|
||||
void resetPosition(){setPosition(0); setBitPos(0);}
|
||||
void setBitPos(duint8 pos);
|
||||
duint8 getBitPos() const {return bitPos;}
|
||||
bool moveBitPos(dint32 size);
|
||||
|
||||
duint8 getBit(); //B
|
||||
bool getBoolBit(); //B as bool
|
||||
duint8 get2Bits(); //BB
|
||||
duint8 get3Bits(); //3B
|
||||
duint16 getBitShort(); //BS
|
||||
dint16 getSBitShort(); //BS
|
||||
dint32 getBitLong(); //BL
|
||||
duint64 getBitLongLong(); //BLL (R24)
|
||||
double getBitDouble(); //BD
|
||||
//2BD => call BD 2 times
|
||||
DRW_Coord get3BitDouble(); //3BD
|
||||
duint8 getRawChar8(); //RC
|
||||
duint16 getRawShort16(); //RS
|
||||
double getRawDouble(); //RD
|
||||
duint32 getRawLong32(); //RL
|
||||
duint64 getRawLong64(); //RLL
|
||||
DRW_Coord get2RawDouble(); //2RD
|
||||
//3RD => call RD 3 times
|
||||
duint32 getUModularChar(); //UMC, unsigned for offsets in 1015
|
||||
dint32 getModularChar(); //MC
|
||||
dint32 getModularShort(); //MS
|
||||
dwgHandle getHandle(); //H
|
||||
dwgHandle getOffsetHandle(duint32 href); //H converted to hard
|
||||
UTF8STRING getVariableText(DRW::Version v, bool nullTerm = true); //TV => call TU for 2007+ or T for previous versions
|
||||
UTF8STRING getCP8Text(); //T 8 bit text converted from codepage to utf8
|
||||
UTF8STRING getUCSText(bool nullTerm = true); //TU unicode 16 bit (UCS) text converted to utf8
|
||||
UTF8STRING getUCSStr(duint16 ts);
|
||||
|
||||
duint16 getObjType(DRW::Version v); //OT
|
||||
|
||||
//X, U, SN,
|
||||
|
||||
DRW_Coord getExtrusion(bool b_R2000_style); //BE
|
||||
double getDefaultDouble(double d); //DD
|
||||
double getThickness(bool b_R2000_style);//BT
|
||||
//3DD
|
||||
duint32 getCmColor(DRW::Version v); //CMC
|
||||
duint32 getEnColor(DRW::Version v); //ENC
|
||||
//TC
|
||||
|
||||
duint16 getBERawShort16(); //RS big-endian order
|
||||
|
||||
bool isGood(){return filestr->good();}
|
||||
bool getBytes(duint8 *buf, int size);
|
||||
int numRemainingBytes(){return (maxSize- static_cast<int>(filestr->getPos()));}
|
||||
|
||||
duint16 crc8(duint16 dx,dint32 start,dint32 end);
|
||||
duint32 crc32(duint32 seed,dint32 start,dint32 end);
|
||||
|
||||
// duint8 getCurrByte(){return currByte;}
|
||||
DRW_TextCodec *decoder;
|
||||
|
||||
private:
|
||||
dwgBasicStream *filestr;
|
||||
int maxSize;
|
||||
duint8 currByte;
|
||||
duint8 bitPos;
|
||||
|
||||
UTF8STRING get8bitStr();
|
||||
UTF8STRING get16bitStr(duint16 textSize, bool nullTerm = true);
|
||||
};
|
||||
|
||||
#endif // DWGBUFFER_H
|
File diff suppressed because it is too large
Load Diff
|
@ -1,250 +0,0 @@
|
|||
/******************************************************************************
|
||||
** libDXFrw - Library to read/write DXF files (ascii & binary) **
|
||||
** **
|
||||
** Copyright (C) 2011-2015 José F. Soriano, rallazz@gmail.com **
|
||||
** **
|
||||
** This library is free software, licensed under the terms of the GNU **
|
||||
** General Public License as published by the Free Software Foundation, **
|
||||
** either version 2 of the License, or (at your option) any later version. **
|
||||
** You should have received a copy of the GNU General Public License **
|
||||
** along with this program. If not, see <http://www.gnu.org/licenses/>. **
|
||||
******************************************************************************/
|
||||
|
||||
#ifndef DWGREADER_H
|
||||
#define DWGREADER_H
|
||||
|
||||
#include <map>
|
||||
#include <list>
|
||||
#include "drw_textcodec.h"
|
||||
#include "dwgutil.h"
|
||||
#include "dwgbuffer.h"
|
||||
#include "../libdwgr.h"
|
||||
|
||||
class objHandle{
|
||||
public:
|
||||
objHandle()
|
||||
: type(0),
|
||||
handle(0),
|
||||
loc(0)
|
||||
{}
|
||||
|
||||
objHandle(duint32 t, duint32 h, duint32 l)
|
||||
: type(t),
|
||||
handle(h),
|
||||
loc(l)
|
||||
{}
|
||||
|
||||
duint32 type;
|
||||
duint32 handle;
|
||||
duint32 loc;
|
||||
};
|
||||
|
||||
//until 2000 = 2000-
|
||||
//since 2004 except 2007 = 2004+
|
||||
// 2007 = 2007
|
||||
// pages of section
|
||||
/* 2000-: No pages, only sections
|
||||
* 2004+: Id, page number (index)
|
||||
* size, size of page in file stream
|
||||
* address, address in file stream
|
||||
* dataSize, data size for this page
|
||||
* startOffset, start offset for this page
|
||||
* cSize, compresed size of data
|
||||
* uSize, uncompresed size of data
|
||||
* 2007: page Id, pageCount & pages
|
||||
* size, size in file
|
||||
* dataSize
|
||||
* startOffset, start position in decompresed data stream
|
||||
* cSize, compresed size of data
|
||||
* uSize, uncompresed size of data
|
||||
* address, address in file stream
|
||||
* */
|
||||
class dwgPageInfo {
|
||||
public:
|
||||
dwgPageInfo()
|
||||
: Id(),
|
||||
address(),
|
||||
size(),
|
||||
dataSize(),
|
||||
startOffset(),
|
||||
cSize(),
|
||||
uSize()
|
||||
{}
|
||||
|
||||
dwgPageInfo(duint64 i, duint64 ad, duint32 sz)
|
||||
: Id(i),
|
||||
address(ad),
|
||||
size(sz),
|
||||
dataSize(),
|
||||
startOffset(),
|
||||
cSize(),
|
||||
uSize()
|
||||
{}
|
||||
|
||||
~dwgPageInfo() = default;
|
||||
duint64 Id;
|
||||
duint64 address; //in file stream, for rd18, rd21
|
||||
duint64 size; //in file stream, for rd18, rd21
|
||||
duint64 dataSize; //for rd18, rd21
|
||||
duint32 startOffset; //for rd18, rd21
|
||||
duint64 cSize; //compresed page size, for rd21
|
||||
duint64 uSize; //uncompresed page size, for rd21
|
||||
};
|
||||
|
||||
// sections of file
|
||||
/* 2000-: No pages, only section Id, size & address in file
|
||||
* 2004+: Id, Section Id
|
||||
* size, total size of uncompresed data
|
||||
* pageCount & pages, number of pages in section
|
||||
* maxSize, max decompressed Size per page
|
||||
* compresed, (1 = no, 2 = yes, normally 2)
|
||||
* encrypted, (0 = no, 1 = yes, 2 = unknown)
|
||||
* name, read & stored but not used
|
||||
* 2007: same as 2004+ except encoding, saved in compresed field
|
||||
* */
|
||||
class dwgSectionInfo {
|
||||
public:
|
||||
dwgSectionInfo()
|
||||
: Id(-1),
|
||||
name(),
|
||||
compresed(1),//1=no, 2=yes
|
||||
encrypted(0),//???
|
||||
pages(),
|
||||
size(),
|
||||
pageCount(0),
|
||||
maxSize(),
|
||||
address()
|
||||
{}
|
||||
|
||||
~dwgSectionInfo() = default;
|
||||
dint32 Id; //section Id, 2000- rd15 rd18
|
||||
std::string name; //section name rd18
|
||||
duint32 compresed;//is compresed? 1=no, 2=yes rd18, rd21(encoding)
|
||||
duint32 encrypted;//encrypted (doc: 0=no, 1=yes, 2=unkn) on read: objects 0 and encrypted yes rd18
|
||||
std::map<duint32, dwgPageInfo >pages;//index, size, offset
|
||||
duint64 size;//size of section, 2000- rd15, rd18, rd21 (data size)
|
||||
duint64 pageCount; //number of pages (dwgPageInfo) in section rd18, rd21
|
||||
duint64 maxSize; //max decompressed size (needed??) rd18 rd21
|
||||
duint64 address; //address (seek) , 2000-
|
||||
};
|
||||
|
||||
|
||||
//! Class to handle dwg obj control entries
|
||||
/*!
|
||||
* Class to handle dwg obj control entries
|
||||
* @author Rallaz
|
||||
*/
|
||||
class DRW_ObjControl : public DRW_TableEntry {
|
||||
public:
|
||||
DRW_ObjControl()
|
||||
: hadlesList()
|
||||
{ reset();}
|
||||
|
||||
// cppcheck-suppress functionStatic
|
||||
void reset(){}
|
||||
bool parseDwg(DRW::Version version, dwgBuffer *buf, duint32 bs=0);
|
||||
std::list<duint32>hadlesList;
|
||||
};
|
||||
|
||||
|
||||
class dwgReader {
|
||||
friend class dwgR;
|
||||
public:
|
||||
dwgReader(std::istream *stream, dwgR *p)
|
||||
: ObjectMap(),
|
||||
objObjectMap(),
|
||||
remainingMap(),
|
||||
ltypemap(),
|
||||
layermap(),
|
||||
blockmap(),
|
||||
stylemap(),
|
||||
dimstylemap(),
|
||||
vportmap(),
|
||||
blockRecordmap(),
|
||||
appIdmap(),
|
||||
maintenanceVersion(0),
|
||||
fileBuf(new dwgBuffer(stream)),
|
||||
parent(p),
|
||||
version(),
|
||||
previewImagePos(),
|
||||
sections(),
|
||||
classesmap(),
|
||||
decoder(),
|
||||
nextEntLink(0),
|
||||
prevEntLink(0)
|
||||
{
|
||||
decoder.setVersion(DRW::AC1021, false);//default 2007 in utf8(no convert)
|
||||
decoder.setCodePage("UTF-16", false);
|
||||
}
|
||||
virtual ~dwgReader();
|
||||
|
||||
protected:
|
||||
virtual bool readMetaData() = 0;
|
||||
virtual bool readPreview(){return false;}
|
||||
virtual bool readFileHeader() = 0;
|
||||
virtual bool readDwgHeader(DRW_Header& hdr)=0;
|
||||
virtual bool readDwgClasses() = 0;
|
||||
virtual bool readDwgHandles() = 0;
|
||||
virtual bool readDwgTables(DRW_Header& hdr)=0;
|
||||
virtual bool readDwgBlocks(DRW_Interface& intfa) = 0;
|
||||
virtual bool readDwgEntities(DRW_Interface& intfa) = 0;
|
||||
virtual bool readDwgObjects(DRW_Interface& intfa) = 0;
|
||||
|
||||
virtual bool readDwgEntity(dwgBuffer *dbuf, objHandle& obj, DRW_Interface& intfa);
|
||||
bool readDwgObject(dwgBuffer *dbuf, objHandle& obj, DRW_Interface& intfa);
|
||||
void parseAttribs(DRW_Entity* e);
|
||||
std::string findTableName(DRW::TTYPE table, dint32 handle);
|
||||
|
||||
void setCodePage(std::string *c){decoder.setCodePage(c, false);}
|
||||
std::string getCodePage() const { return decoder.getCodePage();}
|
||||
bool readDwgHeader(DRW_Header& hdr, dwgBuffer *buf, dwgBuffer *hBuf);
|
||||
bool readDwgHandles(dwgBuffer *dbuf, duint32 offset, duint32 size);
|
||||
bool readDwgTables(DRW_Header& hdr, dwgBuffer *dbuf);
|
||||
static bool checkSentinel(dwgBuffer *buf, enum secEnum::DWGSection, bool start);
|
||||
|
||||
bool readDwgBlocks(DRW_Interface& intfa, dwgBuffer *dbuf);
|
||||
bool readDwgEntities(DRW_Interface& intfa, dwgBuffer *dbuf);
|
||||
bool readDwgObjects(DRW_Interface& intfa, dwgBuffer *dbuf);
|
||||
bool readPlineVertex(DRW_Polyline& pline, dwgBuffer *dbuf);
|
||||
|
||||
public:
|
||||
std::map<duint32, objHandle>ObjectMap;
|
||||
std::map<duint32, objHandle>objObjectMap; //stores the ojects & entities not read in readDwgEntities
|
||||
std::map<duint32, objHandle>remainingMap; //stores the ojects & entities not read in all proces, for debug only
|
||||
std::map<duint32, DRW_LType*> ltypemap;
|
||||
std::map<duint32, DRW_Layer*> layermap;
|
||||
std::map<duint32, DRW_Block*> blockmap;
|
||||
std::map<duint32, DRW_Textstyle*> stylemap;
|
||||
std::map<duint32, DRW_Dimstyle*> dimstylemap;
|
||||
std::map<duint32, DRW_Vport*> vportmap;
|
||||
std::map<duint32, DRW_Block_Record*> blockRecordmap;
|
||||
std::map<duint32, DRW_AppId*> appIdmap;
|
||||
// duint32 currBlock;
|
||||
duint8 maintenanceVersion;
|
||||
|
||||
protected:
|
||||
dwgBuffer *fileBuf;
|
||||
dwgR *parent;
|
||||
DRW::Version version;
|
||||
|
||||
//seeker (position) for the beginning sentinel of the image data (R13 to R15)
|
||||
duint32 previewImagePos;
|
||||
|
||||
//sections map
|
||||
std::map<enum secEnum::DWGSection, dwgSectionInfo >sections;
|
||||
std::map<duint32, DRW_Class*> classesmap;
|
||||
|
||||
protected:
|
||||
DRW_TextCodec decoder;
|
||||
|
||||
protected:
|
||||
// duint32 blockCtrl;
|
||||
duint32 nextEntLink;
|
||||
duint32 prevEntLink;
|
||||
private:
|
||||
Q_DISABLE_COPY(dwgReader)
|
||||
};
|
||||
|
||||
|
||||
|
||||
#endif // DWGREADER_H
|
|
@ -1,200 +0,0 @@
|
|||
/******************************************************************************
|
||||
** libDXFrw - Library to read/write DXF files (ascii & binary) **
|
||||
** **
|
||||
** Copyright (C) 2011-2015 José F. Soriano, rallazz@gmail.com **
|
||||
** **
|
||||
** This library is free software, licensed under the terms of the GNU **
|
||||
** General Public License as published by the Free Software Foundation, **
|
||||
** either version 2 of the License, or (at your option) any later version. **
|
||||
** You should have received a copy of the GNU General Public License **
|
||||
** along with this program. If not, see <http://www.gnu.org/licenses/>. **
|
||||
******************************************************************************/
|
||||
|
||||
#include <cstdlib>
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
#include <string>
|
||||
#include <sstream>
|
||||
#include "drw_dbg.h"
|
||||
#include "dwgreader15.h"
|
||||
#include "drw_textcodec.h"
|
||||
#include "../libdwgr.h"
|
||||
|
||||
bool dwgReader15::readMetaData() {
|
||||
version = parent->getVersion();
|
||||
decoder.setVersion(version, false);
|
||||
DRW_DBG("dwgReader15::readMetaData\n");
|
||||
if (! fileBuf->setPosition(13))
|
||||
return false;
|
||||
previewImagePos = fileBuf->getRawLong32();
|
||||
DRW_DBG("previewImagePos (seekerImageData) = "); DRW_DBG(previewImagePos);
|
||||
/* MEASUREMENT system variable 2 bytes*/
|
||||
duint16 meas = fileBuf->getRawShort16();
|
||||
DRW_DBG("\nMEASUREMENT (0 = English, 1 = Metric)= "); DRW_DBG(meas);
|
||||
duint16 cp = fileBuf->getRawShort16();
|
||||
DRW_DBG("\ncodepage= "); DRW_DBG(cp); DRW_DBG("\n");
|
||||
if (cp == 29) //TODO RLZ: locate wath code page and correct this
|
||||
decoder.setCodePage("ANSI_1252", false);
|
||||
if (cp == 30)
|
||||
decoder.setCodePage("ANSI_1252", false);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool dwgReader15::readFileHeader() {
|
||||
bool ret = true;
|
||||
DRW_DBG("dwgReader15::readFileHeader\n");
|
||||
if (! fileBuf->setPosition(21))
|
||||
return false;
|
||||
duint32 count = fileBuf->getRawLong32();
|
||||
DRW_DBG("count records= "); DRW_DBG(count); DRW_DBG("\n");
|
||||
|
||||
for (unsigned int i = 0; i < count; i++) {
|
||||
duint8 rec = fileBuf->getRawChar8();
|
||||
duint32 address = fileBuf->getRawLong32();
|
||||
duint32 size = fileBuf->getRawLong32();
|
||||
dwgSectionInfo si;
|
||||
si.Id = rec;
|
||||
si.size = size;
|
||||
si.address = address;
|
||||
if (rec == 0) {
|
||||
DRW_DBG("\nSection HEADERS address= ");
|
||||
DRW_DBG(address); DRW_DBG(" size= "); DRW_DBG(size);
|
||||
sections[secEnum::HEADER] = si;
|
||||
} else if (rec == 1) {
|
||||
DRW_DBG("\nSection CLASSES address= ");
|
||||
DRW_DBG(address); DRW_DBG(" size= "); DRW_DBG(size);
|
||||
sections[secEnum::CLASSES] = si;
|
||||
} else if (rec == 2) {
|
||||
DRW_DBG("\nSection OBJECTS (handles) address= ");
|
||||
DRW_DBG(address); DRW_DBG(" size= "); DRW_DBG(size);
|
||||
sections[secEnum::HANDLES] = si;
|
||||
} else if (rec == 3) {
|
||||
DRW_DBG("\nSection UNKNOWN address= ");
|
||||
DRW_DBG(address); DRW_DBG(" size= "); DRW_DBG(size);
|
||||
sections[secEnum::UNKNOWNS] = si;
|
||||
} else if (rec == 4) {
|
||||
DRW_DBG("\nSection R14DATA (AcDb:Template) address= ");
|
||||
DRW_DBG(address); DRW_DBG(" size= "); DRW_DBG(size);
|
||||
sections[secEnum::TEMPLATE] = si;
|
||||
} else if (rec == 5) {
|
||||
DRW_DBG("\nSection R14REC5 (AcDb:AuxHeader) address= ");
|
||||
DRW_DBG(address); DRW_DBG(" size= "); DRW_DBG(size);
|
||||
sections[secEnum::AUXHEADER] = si;
|
||||
} else {
|
||||
std::cerr << "\nUnsupported section number\n";
|
||||
}
|
||||
}
|
||||
if (! fileBuf->isGood())
|
||||
return false;
|
||||
DRW_DBG("\nposition after read section locator records= "); DRW_DBG(fileBuf->getPosition());
|
||||
DRW_DBG(", bit are= "); DRW_DBG(fileBuf->getBitPos());
|
||||
duint32 ckcrc = static_cast<duint32>(fileBuf->crc8(0, 0, static_cast<dint32>(fileBuf->getPosition())));
|
||||
DRW_DBG("\nfile header crc8 0 result= "); DRW_DBG(ckcrc);
|
||||
|
||||
QT_WARNING_PUSH
|
||||
QT_WARNING_DISABLE_GCC("-Wswitch-default")
|
||||
|
||||
switch (count){
|
||||
case 3:
|
||||
ckcrc = ckcrc ^ 0xA598;
|
||||
break;
|
||||
case 4:
|
||||
ckcrc = ckcrc ^ 0x8101;
|
||||
break;
|
||||
case 5:
|
||||
ckcrc = ckcrc ^ 0x3CC4;
|
||||
break;
|
||||
case 6:
|
||||
ckcrc = ckcrc ^ 0x8461;
|
||||
}
|
||||
|
||||
QT_WARNING_POP
|
||||
|
||||
DRW_DBG("\nfile header crc8 xor result= "); DRW_DBG(ckcrc);
|
||||
DRW_DBG("\nfile header CRC= "); DRW_DBG(fileBuf->getRawShort16());
|
||||
DRW_DBG("\nfile header sentinel= ");
|
||||
checkSentinel(fileBuf, secEnum::FILEHEADER, false);
|
||||
|
||||
DRW_DBG("\nposition after read file header sentinel= "); DRW_DBG(fileBuf->getPosition());
|
||||
DRW_DBG(", bit are= "); DRW_DBG(fileBuf->getBitPos());
|
||||
|
||||
DRW_DBG("\ndwgReader15::readFileHeader END\n");
|
||||
return ret;
|
||||
}
|
||||
|
||||
bool dwgReader15::readDwgHeader(DRW_Header& hdr){
|
||||
DRW_DBG("dwgReader15::readDwgHeader\n");
|
||||
dwgSectionInfo si = sections[secEnum::HEADER];
|
||||
if (si.Id<0)//not found, ends
|
||||
return false;
|
||||
if (!fileBuf->setPosition(si.address))
|
||||
return false;
|
||||
duint8 *tmpByteStr = new duint8[si.size];
|
||||
fileBuf->getBytes(tmpByteStr, static_cast<int>(si.size));
|
||||
dwgBuffer buff(tmpByteStr, static_cast<int>(si.size), &decoder);
|
||||
DRW_DBG("Header section sentinel= ");
|
||||
checkSentinel(&buff, secEnum::HEADER, true);
|
||||
bool ret = dwgReader::readDwgHeader(hdr, &buff, &buff);
|
||||
delete[]tmpByteStr;
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
bool dwgReader15::readDwgClasses(){
|
||||
DRW_DBG("\ndwgReader15::readDwgClasses\n");
|
||||
dwgSectionInfo si = sections[secEnum::CLASSES];
|
||||
if (si.Id<0)//not found, ends
|
||||
return false;
|
||||
if (!fileBuf->setPosition(si.address))
|
||||
return false;
|
||||
|
||||
DRW_DBG("classes section sentinel= ");
|
||||
checkSentinel(fileBuf, secEnum::CLASSES, true);
|
||||
|
||||
duint32 size = fileBuf->getRawLong32();
|
||||
if (size != (si.size - 38)) {
|
||||
DRW_DBG("\nWARNING dwgReader15::readDwgClasses size are "); DRW_DBG(size);
|
||||
DRW_DBG(" and secSize - 38 are "); DRW_DBG(si.size - 38); DRW_DBG("\n");
|
||||
}
|
||||
duint8 *tmpByteStr = new duint8[size];
|
||||
fileBuf->getBytes(tmpByteStr, size);
|
||||
dwgBuffer buff(tmpByteStr, size, &decoder);
|
||||
size--; //reduce 1 byte instead of check pos + bitPos
|
||||
while (size > buff.getPosition()) {
|
||||
DRW_Class *cl = new DRW_Class();
|
||||
cl->parseDwg(version, &buff, &buff);
|
||||
classesmap[cl->classNum] = cl;
|
||||
}
|
||||
DRW_DBG("\nCRC: "); DRW_DBGH(fileBuf->getRawShort16());
|
||||
DRW_DBG("\nclasses section end sentinel= ");
|
||||
checkSentinel(fileBuf, secEnum::CLASSES, false);
|
||||
bool ret = buff.isGood();
|
||||
delete[]tmpByteStr;
|
||||
return ret;
|
||||
}
|
||||
|
||||
bool dwgReader15::readDwgHandles() {
|
||||
DRW_DBG("\ndwgReader15::readDwgHandles\n");
|
||||
dwgSectionInfo si = sections[secEnum::HANDLES];
|
||||
if (si.Id<0)//not found, ends
|
||||
return false;
|
||||
|
||||
return dwgReader::readDwgHandles(fileBuf, static_cast<duint32>(si.address), static_cast<duint32>(si.size));
|
||||
}
|
||||
|
||||
/*********** objects ************************/
|
||||
/**
|
||||
* Reads all the object referenced in the object map section of the DWG file
|
||||
* (using their object file offsets)
|
||||
*/
|
||||
bool dwgReader15::readDwgTables(DRW_Header& hdr) {
|
||||
return dwgReader::readDwgTables(hdr, fileBuf);
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads all the object referenced in the object map section of the DWG file
|
||||
* (using their object file offsets)
|
||||
*/
|
||||
bool dwgReader15::readDwgBlocks(DRW_Interface& intfa) {
|
||||
return dwgReader::readDwgBlocks(intfa, fileBuf);
|
||||
}
|
|
@ -1,43 +0,0 @@
|
|||
/******************************************************************************
|
||||
** libDXFrw - Library to read/write DXF files (ascii & binary) **
|
||||
** **
|
||||
** Copyright (C) 2011-2015 José F. Soriano, rallazz@gmail.com **
|
||||
** **
|
||||
** This library is free software, licensed under the terms of the GNU **
|
||||
** General Public License as published by the Free Software Foundation, **
|
||||
** either version 2 of the License, or (at your option) any later version. **
|
||||
** You should have received a copy of the GNU General Public License **
|
||||
** along with this program. If not, see <http://www.gnu.org/licenses/>. **
|
||||
******************************************************************************/
|
||||
|
||||
#ifndef DWGREADER15_H
|
||||
#define DWGREADER15_H
|
||||
|
||||
#include <map>
|
||||
#include <list>
|
||||
#include "drw_textcodec.h"
|
||||
#include "dwgbuffer.h"
|
||||
#include "dwgreader.h"
|
||||
|
||||
class dwgReader15 : public dwgReader {
|
||||
public:
|
||||
dwgReader15(std::istream *stream, dwgR *p):dwgReader(stream, p){ }
|
||||
virtual ~dwgReader15() {}
|
||||
bool readMetaData();
|
||||
bool readFileHeader();
|
||||
bool readDwgHeader(DRW_Header& hdr);
|
||||
bool readDwgClasses();
|
||||
bool readDwgHandles();
|
||||
bool readDwgTables(DRW_Header& hdr);
|
||||
bool readDwgBlocks(DRW_Interface& intfa);
|
||||
bool readDwgEntities(DRW_Interface& intfa){
|
||||
return dwgReader::readDwgEntities(intfa, fileBuf);
|
||||
}
|
||||
bool readDwgObjects(DRW_Interface& intfa){
|
||||
return dwgReader::readDwgObjects(intfa, fileBuf);
|
||||
}
|
||||
// bool readDwgEntity(objHandle& obj, DRW_Interface& intfa);
|
||||
};
|
||||
|
||||
|
||||
#endif // DWGREADER15_H
|
|
@ -1,597 +0,0 @@
|
|||
/******************************************************************************
|
||||
** libDXFrw - Library to read/write DXF files (ascii & binary) **
|
||||
** **
|
||||
** Copyright (C) 2011-2015 José F. Soriano, rallazz@gmail.com **
|
||||
** **
|
||||
** This library is free software, licensed under the terms of the GNU **
|
||||
** General Public License as published by the Free Software Foundation, **
|
||||
** either version 2 of the License, or (at your option) any later version. **
|
||||
** You should have received a copy of the GNU General Public License **
|
||||
** along with this program. If not, see <http://www.gnu.org/licenses/>. **
|
||||
******************************************************************************/
|
||||
|
||||
#include <cstdlib>
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
#include <string>
|
||||
#include <sstream>
|
||||
#include "drw_dbg.h"
|
||||
#include "dwgreader18.h"
|
||||
#include "dwgutil.h"
|
||||
#include "drw_textcodec.h"
|
||||
#include "../libdwgr.h"
|
||||
|
||||
void dwgReader18::genMagicNumber(){
|
||||
int size =0x114;
|
||||
duint8 *tmpMagicStr = new duint8[size];
|
||||
duint8 *p = tmpMagicStr;
|
||||
int rSeed =1;
|
||||
while (size--) {
|
||||
rSeed *= 0x343fd;
|
||||
rSeed += 0x269ec3;
|
||||
*p++ = static_cast<duint8>(rSeed >> 0x10);
|
||||
}
|
||||
int j = 0;
|
||||
size =0x114;
|
||||
for (int i=0; i< size;i++) {
|
||||
DRW_DBGH(tmpMagicStr[i]);
|
||||
if (j == 15) {
|
||||
DRW_DBG("\n");
|
||||
j = 0;
|
||||
} else {
|
||||
DRW_DBG(", ");
|
||||
j++;
|
||||
}
|
||||
}
|
||||
delete[]tmpMagicStr;
|
||||
}
|
||||
|
||||
duint32 dwgReader18::checksum(duint32 seed, duint8* data, duint32 sz){
|
||||
duint32 size = sz;
|
||||
duint32 sum1 = seed & 0xffff;
|
||||
duint32 sum2 = seed >> 0x10;
|
||||
while (size != 0) {
|
||||
// duint32 chunkSize = min(0x15b0, size);
|
||||
duint32 chunkSize = 0x15b0 < size? 0x15b0:size;
|
||||
size -= chunkSize;
|
||||
for (duint32 i = 0; i < chunkSize; i++) {
|
||||
sum1 += *data++;
|
||||
sum2 += sum1;
|
||||
}
|
||||
sum1 %= 0xFFF1;
|
||||
sum2 %= 0xFFF1;
|
||||
}
|
||||
return (sum2 << 0x10) | (sum1 & 0xffff);
|
||||
}
|
||||
|
||||
//called: Section page map: 0x41630e3b
|
||||
void dwgReader18::parseSysPage(duint8 *decompSec, duint32 decompSize){
|
||||
DRW_DBG("\nparseSysPage:\n ");
|
||||
duint32 compSize = fileBuf->getRawLong32();
|
||||
DRW_DBG("Compressed size= "); DRW_DBG(compSize); DRW_DBG(", "); DRW_DBGH(compSize);
|
||||
DRW_DBG("\nCompression type= "); DRW_DBGH(fileBuf->getRawLong32());
|
||||
DRW_DBG("\nSection page checksum= "); DRW_DBGH(fileBuf->getRawLong32()); DRW_DBG("\n");
|
||||
|
||||
duint8 hdrData[20];
|
||||
fileBuf->moveBitPos(-160);
|
||||
fileBuf->getBytes(hdrData, 20);
|
||||
for (duint8 i= 16; i<20; ++i)
|
||||
hdrData[i]=0;
|
||||
duint32 calcsH = checksum(0, hdrData, 20);
|
||||
DRW_DBG("Calc hdr checksum= "); DRW_DBGH(calcsH);
|
||||
duint8 *tmpCompSec = new duint8[compSize];
|
||||
fileBuf->getBytes(tmpCompSec, compSize);
|
||||
duint32 calcsD = checksum(calcsH, tmpCompSec, compSize);
|
||||
DRW_DBG("\nCalc data checksum= "); DRW_DBGH(calcsD); DRW_DBG("\n");
|
||||
|
||||
#ifdef DRW_DBG_DUMP
|
||||
for (unsigned int i=0, j=0; i< compSize;i++) {
|
||||
DRW_DBGH( (unsigned char)compSec[i]);
|
||||
if (j == 7) { DRW_DBG("\n"); j = 0;
|
||||
} else { DRW_DBG(", "); j++; }
|
||||
} DRW_DBG("\n");
|
||||
#endif
|
||||
DRW_DBG("decompresing "); DRW_DBG(compSize); DRW_DBG(" bytes in "); DRW_DBG(decompSize); DRW_DBG(" bytes\n");
|
||||
dwgCompressor comp;
|
||||
comp.decompress18(tmpCompSec, decompSec, compSize, decompSize);
|
||||
#ifdef DRW_DBG_DUMP
|
||||
for (unsigned int i=0, j=0; i< decompSize;i++) {
|
||||
DRW_DBGH( decompSec[i]);
|
||||
if (j == 7) { DRW_DBG("\n"); j = 0;
|
||||
} else { DRW_DBG(", "); j++; }
|
||||
} DRW_DBG("\n");
|
||||
#endif
|
||||
delete[]tmpCompSec;
|
||||
}
|
||||
|
||||
//called ???: Section map: 0x4163003b
|
||||
bool dwgReader18::parseDataPage(dwgSectionInfo si/*, duint8 *dData*/){
|
||||
DRW_DBG("\nparseDataPage\n ");
|
||||
objData = new duint8 [si.pageCount * si.maxSize];
|
||||
|
||||
for (std::map<duint32, dwgPageInfo>::iterator it=si.pages.begin(); it!=si.pages.end(); ++it){
|
||||
dwgPageInfo pi = it->second;
|
||||
if (!fileBuf->setPosition(pi.address))
|
||||
return false;
|
||||
//decript section header
|
||||
duint8 hdrData[32];
|
||||
fileBuf->getBytes(hdrData, 32);
|
||||
dwgCompressor::decrypt18Hdr(hdrData, 32, static_cast<duint32>(pi.address));
|
||||
DRW_DBG("Section "); DRW_DBG(si.name); DRW_DBG(" page header=\n");
|
||||
for (unsigned int i=0, j=0; i< 32;i++) {
|
||||
DRW_DBGH( static_cast<unsigned char>(hdrData[i]));
|
||||
if (j == 7) {
|
||||
DRW_DBG("\n");
|
||||
j = 0;
|
||||
} else {
|
||||
DRW_DBG(", ");
|
||||
j++;
|
||||
}
|
||||
} DRW_DBG("\n");
|
||||
|
||||
DRW_DBG("\n Page number= "); DRW_DBGH(pi.Id);
|
||||
DRW_DBG("\n size in file= "); DRW_DBGH(pi.size);
|
||||
DRW_DBG("\n address in file= "); DRW_DBGH(pi.address);
|
||||
DRW_DBG("\n Data size= "); DRW_DBGH(pi.dataSize);
|
||||
DRW_DBG("\n Start offset= "); DRW_DBGH(pi.startOffset); DRW_DBG("\n");
|
||||
dwgBuffer bufHdr(hdrData, 32, &decoder);
|
||||
DRW_DBG(" section page type= "); DRW_DBGH(bufHdr.getRawLong32());
|
||||
DRW_DBG("\n section number= "); DRW_DBGH(bufHdr.getRawLong32());
|
||||
pi.cSize = bufHdr.getRawLong32();
|
||||
DRW_DBG("\n data size (compressed)= "); DRW_DBGH(pi.cSize); DRW_DBG(" dec "); DRW_DBG(pi.cSize);
|
||||
pi.uSize = bufHdr.getRawLong32();
|
||||
DRW_DBG("\n page size (decompressed)= "); DRW_DBGH(pi.uSize); DRW_DBG(" dec "); DRW_DBG(pi.uSize);
|
||||
DRW_DBG("\n start offset (in decompressed buffer)= "); DRW_DBGH(bufHdr.getRawLong32());
|
||||
DRW_DBG("\n unknown= "); DRW_DBGH(bufHdr.getRawLong32());
|
||||
DRW_DBG("\n header checksum= "); DRW_DBGH(bufHdr.getRawLong32());
|
||||
DRW_DBG("\n data checksum= "); DRW_DBGH(bufHdr.getRawLong32()); DRW_DBG("\n");
|
||||
|
||||
//get compresed data
|
||||
duint8 *cData = new duint8[pi.cSize];
|
||||
if (!fileBuf->setPosition(pi.address+32))
|
||||
{
|
||||
delete[]cData;
|
||||
return false;
|
||||
}
|
||||
fileBuf->getBytes(cData, static_cast<int>(pi.cSize));
|
||||
|
||||
//calculate checksum
|
||||
duint32 calcsD = checksum(0, cData, static_cast<duint32>(pi.cSize));
|
||||
for (duint8 i= 24; i<28; ++i)
|
||||
hdrData[i]=0;
|
||||
duint32 calcsH = checksum(calcsD, hdrData, 32);
|
||||
DRW_DBG("Calc header checksum= "); DRW_DBGH(calcsH);
|
||||
DRW_DBG("\nCalc data checksum= "); DRW_DBGH(calcsD); DRW_DBG("\n");
|
||||
|
||||
duint8* oData = objData + pi.startOffset;
|
||||
pi.uSize = si.maxSize;
|
||||
DRW_DBG("decompresing "); DRW_DBG(pi.cSize); DRW_DBG(" bytes in "); DRW_DBG(pi.uSize); DRW_DBG(" bytes\n");
|
||||
dwgCompressor comp;
|
||||
comp.decompress18(cData, oData, static_cast<duint32>(pi.cSize), static_cast<duint32>(pi.uSize));
|
||||
delete[]cData;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool dwgReader18::readMetaData() {
|
||||
version = parent->getVersion();
|
||||
decoder.setVersion(version, false);
|
||||
DRW_DBG("dwgReader18::readMetaData\n");
|
||||
if (! fileBuf->setPosition(11))
|
||||
return false;
|
||||
maintenanceVersion = fileBuf->getRawChar8();
|
||||
DRW_DBG("maintenance verion= "); DRW_DBGH(maintenanceVersion);
|
||||
DRW_DBG("\nbyte at 0x0C= "); DRW_DBGH(fileBuf->getRawChar8());
|
||||
previewImagePos = fileBuf->getRawLong32(); //+ page header size (0x20).
|
||||
DRW_DBG("\npreviewImagePos (seekerImageData) = "); DRW_DBG(previewImagePos);
|
||||
DRW_DBG("\napp Dwg version= "); DRW_DBGH(fileBuf->getRawChar8()); DRW_DBG(", ");
|
||||
DRW_DBG("\napp maintenance version= "); DRW_DBGH(fileBuf->getRawChar8());
|
||||
duint16 cp = fileBuf->getRawShort16();
|
||||
DRW_DBG("\ncodepage= "); DRW_DBG(cp);
|
||||
if (cp == 30)
|
||||
decoder.setCodePage("ANSI_1252", false);
|
||||
DRW_DBG("\n3 0x00 bytes(seems 0x00, appDwgV & appMaintV) = "); DRW_DBGH(fileBuf->getRawChar8()); DRW_DBG(", ");
|
||||
DRW_DBGH(fileBuf->getRawChar8()); DRW_DBG(", "); DRW_DBGH(fileBuf->getRawChar8());
|
||||
securityFlags = fileBuf->getRawLong32();
|
||||
DRW_DBG("\nsecurity flags= "); DRW_DBG(securityFlags);
|
||||
// UNKNOWN SECTION 4 bytes
|
||||
duint32 uk = fileBuf->getRawLong32();
|
||||
DRW_DBG("\nUNKNOWN SECTION ( 4 bytes) = "); DRW_DBG(uk);
|
||||
duint32 sumInfoAddr = fileBuf->getRawLong32();
|
||||
DRW_DBG("\nsummary Info Address= "); DRW_DBG(sumInfoAddr);
|
||||
duint32 vbaAdd = fileBuf->getRawLong32();
|
||||
DRW_DBG("\nVBA address= "); DRW_DBGH(vbaAdd);
|
||||
DRW_DBG("\npos 0x28 are 0x00000080= "); DRW_DBGH(fileBuf->getRawLong32());
|
||||
DRW_DBG("\n");
|
||||
return true;
|
||||
}
|
||||
|
||||
bool dwgReader18::readFileHeader() {
|
||||
|
||||
if (! fileBuf->setPosition(0x80))
|
||||
return false;
|
||||
|
||||
// genMagicNumber(); DBG("\n"); DBG("\n");
|
||||
DRW_DBG("Encripted Header Data=\n");
|
||||
duint8 byteStr[0x6C];
|
||||
int size =0x6C;
|
||||
for (int i=0, j=0; i< 0x6C;i++) {
|
||||
duint8 ch = fileBuf->getRawChar8();
|
||||
DRW_DBGH(ch);
|
||||
if (j == 15) {
|
||||
DRW_DBG("\n");
|
||||
j = 0;
|
||||
} else {
|
||||
DRW_DBG(", ");
|
||||
j++;
|
||||
}
|
||||
byteStr[i] = static_cast<duint8>(DRW_magicNum18[i] ^ ch);
|
||||
}
|
||||
DRW_DBG("\n");
|
||||
|
||||
// size =0x6C;
|
||||
DRW_DBG("Decripted Header Data=\n");
|
||||
for (int i=0, j = 0; i< size;i++) {
|
||||
DRW_DBGH( static_cast<unsigned char>(byteStr[i]));
|
||||
if (j == 15) {
|
||||
DRW_DBG("\n");
|
||||
j = 0;
|
||||
} else {
|
||||
DRW_DBG(", ");
|
||||
j++;
|
||||
}
|
||||
}
|
||||
dwgBuffer buff(byteStr, 0x6C, &decoder);
|
||||
std::string name = reinterpret_cast<char*>(byteStr);
|
||||
DRW_DBG("\nFile ID string (AcFssFcAJMB)= "); DRW_DBG(name.c_str());
|
||||
//ID string + NULL = 12
|
||||
buff.setPosition(12);
|
||||
DRW_DBG("\n0x00 long= "); DRW_DBGH(buff.getRawLong32());
|
||||
DRW_DBG("\n0x6c long= "); DRW_DBGH(buff.getRawLong32());
|
||||
DRW_DBG("\n0x04 long= "); DRW_DBGH(buff.getRawLong32());
|
||||
DRW_DBG("\nRoot tree node gap= "); DRW_DBGH(buff.getRawLong32());
|
||||
DRW_DBG("\nLowermost left tree node gap= "); DRW_DBGH(buff.getRawLong32());
|
||||
DRW_DBG("\nLowermost right tree node gap= "); DRW_DBGH(buff.getRawLong32());
|
||||
DRW_DBG("\nUnknown long (1)= "); DRW_DBGH(buff.getRawLong32());
|
||||
DRW_DBG("\nLast section page Id= "); DRW_DBGH(buff.getRawLong32());
|
||||
DRW_DBG("\nLast section page end address 64b= "); DRW_DBGH(buff.getRawLong64());
|
||||
DRW_DBG("\nStart of second header data address 64b= "); DRW_DBGH(buff.getRawLong64());
|
||||
DRW_DBG("\nGap amount= "); DRW_DBGH(buff.getRawLong32());
|
||||
DRW_DBG("\nSection page amount= "); DRW_DBGH(buff.getRawLong32());
|
||||
DRW_DBG("\n0x20 long= "); DRW_DBGH(buff.getRawLong32());
|
||||
DRW_DBG("\n0x80 long= "); DRW_DBGH(buff.getRawLong32());
|
||||
DRW_DBG("\n0x40 long= "); DRW_DBGH(buff.getRawLong32());
|
||||
dint32 secPageMapId = buff.getRawLong32();
|
||||
DRW_DBG("\nSection Page Map Id= "); DRW_DBGH(secPageMapId);
|
||||
duint64 secPageMapAddr = buff.getRawLong64()+0x100;
|
||||
DRW_DBG("\nSection Page Map address 64b= "); DRW_DBGH(secPageMapAddr);
|
||||
DRW_DBG("\nSection Page Map address 64b dec= "); DRW_DBG(secPageMapAddr);
|
||||
duint32 secMapId = buff.getRawLong32();
|
||||
DRW_DBG("\nSection Map Id= "); DRW_DBGH(secMapId);
|
||||
DRW_DBG("\nSection page array size= "); DRW_DBGH(buff.getRawLong32());
|
||||
DRW_DBG("\nGap array size= "); DRW_DBGH(buff.getRawLong32());
|
||||
//TODO: verify CRC
|
||||
DRW_DBG("\nCRC32= "); DRW_DBGH(buff.getRawLong32());
|
||||
// for (duint8 i = 0x68; i < 0x6c; ++i)
|
||||
// byteStr[i] = '\0';
|
||||
// byteStr[i] = '\0';
|
||||
duint32 crcCalc = buff.crc32(0x00,0,0x6C);
|
||||
DRW_DBG("\nCRC32 calculated= "); DRW_DBGH(crcCalc);
|
||||
|
||||
DRW_DBG("\nEnd Encrypted Data. Reads 0x14 bytes, equal to magic number:\n");
|
||||
for (int i=0, j=0; i< 0x14;i++) {
|
||||
DRW_DBG("magic num: "); DRW_DBGH( static_cast<unsigned char>(DRW_magicNumEnd18[i]));
|
||||
DRW_DBG(",read "); DRW_DBGH( static_cast<unsigned char>(fileBuf->getRawChar8()));
|
||||
if (j == 3) {
|
||||
DRW_DBG("\n");
|
||||
j = 0;
|
||||
} else {
|
||||
DRW_DBG(", ");
|
||||
j++;
|
||||
}
|
||||
}
|
||||
// At this point are parsed the first 256 bytes
|
||||
DRW_DBG("\nJump to Section Page Map address: "); DRW_DBGH(secPageMapAddr);
|
||||
|
||||
if (! fileBuf->setPosition(secPageMapAddr))
|
||||
return false;
|
||||
duint32 pageType = fileBuf->getRawLong32();
|
||||
DRW_DBG("\nSection page type= "); DRW_DBGH(pageType);
|
||||
duint32 decompSize = fileBuf->getRawLong32();
|
||||
DRW_DBG("\nDecompressed size= "); DRW_DBG(decompSize); DRW_DBG(", "); DRW_DBGH(decompSize);
|
||||
if (pageType != 0x41630e3b){
|
||||
//bad page type, ends
|
||||
DRW_DBG("Warning, bad page type, was expected 0x41630e3b instead of"); DRW_DBGH(pageType); DRW_DBG("\n");
|
||||
return false;
|
||||
}
|
||||
duint8 *tmpDecompSec = new duint8[decompSize];
|
||||
parseSysPage(tmpDecompSec, decompSize);
|
||||
|
||||
//parses "Section page map" decompresed data
|
||||
dwgBuffer buff2(tmpDecompSec, decompSize, &decoder);
|
||||
duint32 address = 0x100;
|
||||
//stores temporaly info of all pages:
|
||||
std::map<duint32, dwgPageInfo >sectionPageMapTmp;
|
||||
|
||||
for (unsigned int i = 0; i < decompSize;) {
|
||||
dint32 id = buff2.getRawLong32();//RLZ bad can be +/-
|
||||
duint32 size = buff2.getRawLong32();
|
||||
i += 8;
|
||||
DRW_DBG("Page num= "); DRW_DBG(id); DRW_DBG(" size= "); DRW_DBGH(size);
|
||||
DRW_DBG(" address= "); DRW_DBGH(address); DRW_DBG("\n");
|
||||
//TODO num can be negative indicating gap
|
||||
// duint64 ind = id > 0 ? id : -id;
|
||||
if (id < 0){
|
||||
DRW_DBG("Parent= "); DRW_DBG(buff2.getRawLong32());
|
||||
DRW_DBG("\nLeft= "); DRW_DBG(buff2.getRawLong32());
|
||||
DRW_DBG(", Right= "); DRW_DBG(buff2.getRawLong32());
|
||||
DRW_DBG(", 0x00= ");DRW_DBGH(buff2.getRawLong32()); DRW_DBG("\n");
|
||||
i += 16;
|
||||
}
|
||||
|
||||
sectionPageMapTmp[id] = dwgPageInfo(id, address, size);
|
||||
address += size;
|
||||
}
|
||||
delete[]tmpDecompSec;
|
||||
|
||||
DRW_DBG("\n*** dwgReader18: Processing Data Section Map ***\n");
|
||||
dwgPageInfo sectionMap = sectionPageMapTmp[secMapId];
|
||||
if (!fileBuf->setPosition(sectionMap.address))
|
||||
return false;
|
||||
pageType = fileBuf->getRawLong32();
|
||||
DRW_DBG("\nSection page type= "); DRW_DBGH(pageType);
|
||||
decompSize = fileBuf->getRawLong32();
|
||||
DRW_DBG("\nDecompressed size= "); DRW_DBG(decompSize); DRW_DBG(", "); DRW_DBGH(decompSize);
|
||||
if (pageType != 0x4163003b){
|
||||
//bad page type, ends
|
||||
DRW_DBG("Warning, bad page type, was expected 0x4163003b instead of"); DRW_DBGH(pageType); DRW_DBG("\n");
|
||||
return false;
|
||||
}
|
||||
tmpDecompSec = new duint8[decompSize];
|
||||
parseSysPage(tmpDecompSec, decompSize);
|
||||
|
||||
//reads sections:
|
||||
DRW_DBG("\n*** dwgReader18: reads sections:");
|
||||
dwgBuffer buff3(tmpDecompSec, decompSize, &decoder);
|
||||
duint32 numDescriptions = buff3.getRawLong32();
|
||||
DRW_DBG("\nnumDescriptions (sections)= "); DRW_DBG(numDescriptions);
|
||||
DRW_DBG("\n0x02 long= "); DRW_DBGH(buff3.getRawLong32());
|
||||
DRW_DBG("\n0x00007400 long= "); DRW_DBGH(buff3.getRawLong32());
|
||||
DRW_DBG("\n0x00 long= "); DRW_DBGH(buff3.getRawLong32());
|
||||
DRW_DBG("\nunknown long (numDescriptions?)= "); DRW_DBG(buff3.getRawLong32()); DRW_DBG("\n");
|
||||
|
||||
for (unsigned int i = 0; i < numDescriptions; i++) {
|
||||
dwgSectionInfo secInfo;
|
||||
secInfo.size = buff3.getRawLong64();
|
||||
DRW_DBG("\nSize of section= "); DRW_DBGH(secInfo.size);
|
||||
secInfo.pageCount = buff3.getRawLong32();
|
||||
DRW_DBG("\nPage count= "); DRW_DBGH(secInfo.pageCount);
|
||||
secInfo.maxSize = buff3.getRawLong32();
|
||||
DRW_DBG("\nMax Decompressed Size= "); DRW_DBGH(secInfo.maxSize);
|
||||
DRW_DBG("\nunknown long= "); DRW_DBGH(buff3.getRawLong32());
|
||||
secInfo.compresed = buff3.getRawLong32();
|
||||
DRW_DBG("\nis Compressed? 1:no, 2:yes= "); DRW_DBGH(secInfo.compresed);
|
||||
secInfo.Id = buff3.getRawLong32();
|
||||
DRW_DBG("\nSection Id= "); DRW_DBGH(secInfo.Id);
|
||||
secInfo.encrypted = buff3.getRawLong32();
|
||||
//encrypted (doc: 0 no, 1 yes, 2 unkn) on read: objects 0 and encrypted yes
|
||||
DRW_DBG("\nEncrypted= "); DRW_DBGH(secInfo.encrypted);
|
||||
duint8 nameCStr[64];
|
||||
buff3.getBytes(nameCStr, 64);
|
||||
secInfo.name = reinterpret_cast<char*>(nameCStr);
|
||||
DRW_DBG("\nSection std::Name= "); DRW_DBG( secInfo.name.c_str() ); DRW_DBG("\n");
|
||||
for (unsigned int i = 0; i < secInfo.pageCount; i++){
|
||||
duint32 pn = buff3.getRawLong32();
|
||||
dwgPageInfo pi = sectionPageMapTmp[pn]; //get a copy
|
||||
DRW_DBG(" reading pag num = "); DRW_DBGH(pn);
|
||||
pi.dataSize = buff3.getRawLong32();
|
||||
pi.startOffset = static_cast<duint32>(buff3.getRawLong64());
|
||||
secInfo.pages[pn]= pi;//complete copy in secInfo
|
||||
DRW_DBG("\n Page number= "); DRW_DBGH(secInfo.pages[pn].Id);
|
||||
DRW_DBG("\n size in file= "); DRW_DBGH(secInfo.pages[pn].size);
|
||||
DRW_DBG("\n address in file= "); DRW_DBGH(secInfo.pages[pn].address);
|
||||
DRW_DBG("\n Data size= "); DRW_DBGH(secInfo.pages[pn].dataSize);
|
||||
DRW_DBG("\n Start offset= "); DRW_DBGH(secInfo.pages[pn].startOffset); DRW_DBG("\n");
|
||||
}
|
||||
//do not save empty section
|
||||
if (!secInfo.name.empty()) {
|
||||
DRW_DBG("Saved section Name= "); DRW_DBG( secInfo.name.c_str() ); DRW_DBG("\n");
|
||||
sections[secEnum::getEnum(secInfo.name)] = secInfo;
|
||||
}
|
||||
}
|
||||
delete[]tmpDecompSec;
|
||||
|
||||
if (! fileBuf->isGood())
|
||||
return false;
|
||||
DRW_DBG("\ndwgReader18::readFileHeader END\n\n");
|
||||
return true;
|
||||
}
|
||||
|
||||
bool dwgReader18::readDwgHeader(DRW_Header& hdr){
|
||||
DRW_DBG("dwgReader18::readDwgHeader\n");
|
||||
dwgSectionInfo si = sections[secEnum::HEADER];
|
||||
if (si.Id<0)//not found, ends
|
||||
return false;
|
||||
bool ret = parseDataPage(si/*, objData*/);
|
||||
//global store for uncompressed data of all pages
|
||||
uncompSize=si.size;
|
||||
if (ret) {
|
||||
dwgBuffer dataBuf(objData, static_cast<int>(si.size), &decoder);
|
||||
DRW_DBG("Header section sentinel= ");
|
||||
checkSentinel(&dataBuf, secEnum::HEADER, true);
|
||||
if (version == DRW::AC1018){
|
||||
ret = dwgReader::readDwgHeader(hdr, &dataBuf, &dataBuf);
|
||||
} else {
|
||||
dwgBuffer handleBuf(objData, static_cast<int>(si.size), &decoder);
|
||||
ret = dwgReader::readDwgHeader(hdr, &dataBuf, &handleBuf);
|
||||
}
|
||||
}
|
||||
//Cleanup: global store for uncompressed data of all pages
|
||||
if (objData != nullptr){
|
||||
delete[] objData;
|
||||
objData = nullptr;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
bool dwgReader18::readDwgClasses(){
|
||||
DRW_DBG("\ndwgReader18::readDwgClasses\n");
|
||||
dwgSectionInfo si = sections[secEnum::CLASSES];
|
||||
if (si.Id<0)//not found, ends
|
||||
return false;
|
||||
bool ret = parseDataPage(si/*, objData*/);
|
||||
//global store for uncompressed data of all pages
|
||||
uncompSize=si.size;
|
||||
if (ret) {
|
||||
|
||||
dwgBuffer dataBuf(objData, static_cast<int>(uncompSize), &decoder);
|
||||
|
||||
DRW_DBG("classes section sentinel= ");
|
||||
checkSentinel(&dataBuf, secEnum::CLASSES, true);
|
||||
|
||||
duint32 size = dataBuf.getRawLong32();
|
||||
DRW_DBG("\ndata size in bytes "); DRW_DBG(size);
|
||||
if (version > DRW::AC1021 && maintenanceVersion > 3) { //2010+
|
||||
duint32 hSize = dataBuf.getRawLong32();
|
||||
DRW_DBG("\n2010+ & MV> 3, higth 32b: "); DRW_DBG(hSize);
|
||||
}
|
||||
duint32 bitSize = 0;
|
||||
if (version > DRW::AC1021) {//2007+
|
||||
bitSize = dataBuf.getRawLong32();
|
||||
DRW_DBG("\ntotal size in bits "); DRW_DBG(bitSize);
|
||||
}
|
||||
duint32 maxClassNum = dataBuf.getBitShort();
|
||||
DRW_DBG("\nMaximum class number "); DRW_DBG(maxClassNum);
|
||||
DRW_DBG("\nRc 1 "); DRW_DBG(dataBuf.getRawChar8());
|
||||
DRW_DBG("\nRc 2 "); DRW_DBG(dataBuf.getRawChar8());
|
||||
DRW_DBG("\nBit "); DRW_DBG(dataBuf.getBit());
|
||||
|
||||
/*******************************/
|
||||
dwgBuffer *strBuf = &dataBuf;
|
||||
dwgBuffer strBuff(objData, static_cast<int>(uncompSize), &decoder);
|
||||
//prepare string stream for 2007+
|
||||
if (version > DRW::AC1021) {//2007+
|
||||
strBuf = &strBuff;
|
||||
duint32 strStartPos = bitSize+191;//size in bits + 24 bytes (sn+size+hSize) - 1 bit (endbit)
|
||||
DRW_DBG("\nstrStartPos: "); DRW_DBG(strStartPos);
|
||||
strBuff.setPosition(strStartPos >> 3);
|
||||
strBuff.setBitPos(strStartPos & 7);
|
||||
DRW_DBG("\nclasses strings buff.getPosition: "); DRW_DBG(strBuff.getPosition());
|
||||
DRW_DBG("\nclasses strings buff.getBitPos: "); DRW_DBG(strBuff.getBitPos());
|
||||
DRW_DBG("\nendBit "); DRW_DBG(strBuff.getBit());
|
||||
strStartPos -= 16;//decrement 16 bits
|
||||
DRW_DBG("\nstrStartPos: "); DRW_DBG(strStartPos);
|
||||
strBuff.setPosition(strStartPos >> 3);
|
||||
strBuff.setBitPos(strStartPos & 7);
|
||||
DRW_DBG("\nclasses strings buff.getPosition: "); DRW_DBG(strBuff.getPosition());
|
||||
DRW_DBG("\nclasses strings buff.getBitPos: "); DRW_DBG(strBuff.getBitPos());
|
||||
duint32 strDataSize = strBuff.getRawShort16();
|
||||
DRW_DBG("\nstrDataSize: "); DRW_DBG(strDataSize);
|
||||
if (strDataSize & 0x8000) {
|
||||
strStartPos -= 16;//decrement 16 bits
|
||||
strDataSize &= 0x7FFF; //strip 0x8000;
|
||||
strBuff.setPosition(strStartPos >> 3);
|
||||
strBuff.setBitPos(strStartPos & 7);
|
||||
duint32 hiSize = strBuff.getRawShort16();
|
||||
strDataSize |= (hiSize << 15);
|
||||
}
|
||||
strStartPos -= strDataSize;
|
||||
DRW_DBG("\nstrStartPos: "); DRW_DBG(strStartPos);
|
||||
strBuff.setPosition(strStartPos >> 3);
|
||||
strBuff.setBitPos(strStartPos & 7);
|
||||
DRW_DBG("\nclasses strings buff.getPosition: "); DRW_DBG(strBuff.getPosition());
|
||||
DRW_DBG("\nclasses strings buff.getBitPos: "); DRW_DBG(strBuff.getBitPos());
|
||||
}
|
||||
|
||||
/*******************************/
|
||||
|
||||
duint32 endDataPos = maxClassNum-499;
|
||||
DRW_DBG("\nbuff.getPosition: "); DRW_DBG(dataBuf.getPosition());
|
||||
for (duint32 i= 0; i<endDataPos;i++) {
|
||||
DRW_Class *cl = new DRW_Class();
|
||||
cl->parseDwg(version, &dataBuf, strBuf);
|
||||
classesmap[cl->classNum] = cl;
|
||||
DRW_DBG("\nbuff.getPosition: "); DRW_DBG(dataBuf.getPosition());
|
||||
}
|
||||
DRW_DBG("\nend classes data buff.getPosition: "); DRW_DBG(dataBuf.getPosition());
|
||||
DRW_DBG("\nend classes data buff.getBitPos: "); DRW_DBG(dataBuf.getBitPos());
|
||||
DRW_DBG("\nend classes strings buff.getPosition: "); DRW_DBG(strBuf->getPosition());
|
||||
DRW_DBG("\nend classes strings buff.getBitPos: "); DRW_DBG(strBuf->getBitPos());
|
||||
|
||||
/***************/
|
||||
|
||||
strBuf->setPosition(strBuf->getPosition()+1);//skip remaining bits
|
||||
DRW_DBG("\nCRC: "); DRW_DBGH(strBuf->getRawShort16());
|
||||
if (version > DRW::AC1018){
|
||||
DRW_DBG("\nunknown CRC: "); DRW_DBGH(strBuf->getRawShort16());
|
||||
}
|
||||
DRW_DBG("\nclasses section end sentinel= ");
|
||||
checkSentinel(strBuf, secEnum::CLASSES, false);
|
||||
|
||||
ret = strBuf->isGood();
|
||||
}
|
||||
//Cleanup: global store for uncompressed data of all pages
|
||||
if (objData != nullptr){
|
||||
delete[] objData;
|
||||
objData = nullptr;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
/*********** objects map ************************/
|
||||
/** Note: object map are split in sections with max size 2035?
|
||||
* heach section are 2 bytes size + data bytes + 2 bytes crc
|
||||
* size value are data bytes + 2 and to calculate crc are used
|
||||
* 2 bytes size + data bytes
|
||||
* last section are 2 bytes size + 2 bytes crc (size value always 2)
|
||||
**/
|
||||
bool dwgReader18::readDwgHandles() {
|
||||
DRW_DBG("\ndwgReader18::readDwgHandles\n");
|
||||
dwgSectionInfo si = sections[secEnum::HANDLES];
|
||||
if (si.Id<0)//not found, ends
|
||||
return false;
|
||||
bool ret = parseDataPage(si);
|
||||
//global store for uncompressed data of all pages
|
||||
uncompSize=si.size;
|
||||
if (ret) {
|
||||
|
||||
dwgBuffer dataBuf(objData, static_cast<int>(uncompSize), &decoder);
|
||||
|
||||
ret = dwgReader::readDwgHandles(&dataBuf, 0, static_cast<duint32>(si.size));
|
||||
}
|
||||
//Cleanup: global store for uncompressed data of all pages
|
||||
if (objData != nullptr){
|
||||
delete[] objData;
|
||||
objData = nullptr;
|
||||
uncompSize = 0;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
/*********** objects ************************/
|
||||
/**
|
||||
* Reads all the object referenced in the object map section of the DWG file
|
||||
* (using their object file offsets)
|
||||
*/
|
||||
bool dwgReader18::readDwgTables(DRW_Header& hdr) {
|
||||
DRW_DBG("\ndwgReader18::readDwgTables\n");
|
||||
dwgSectionInfo si = sections[secEnum::OBJECTS];
|
||||
|
||||
if (si.Id<0)//not found, ends
|
||||
return false;
|
||||
bool ret = parseDataPage(si/*, objData*/);
|
||||
//global store for uncompressed data of all pages
|
||||
uncompSize=si.size;
|
||||
if (ret) {
|
||||
|
||||
dwgBuffer dataBuf(objData, static_cast<int>(uncompSize), &decoder);
|
||||
|
||||
ret = dwgReader::readDwgTables(hdr, &dataBuf);
|
||||
|
||||
}
|
||||
//Do not delete objData in this point, needed in the remaining code
|
||||
return ret;
|
||||
}
|
|
@ -1,99 +0,0 @@
|
|||
/******************************************************************************
|
||||
** libDXFrw - Library to read/write DXF files (ascii & binary) **
|
||||
** **
|
||||
** Copyright (C) 2011-2015 José F. Soriano, rallazz@gmail.com **
|
||||
** **
|
||||
** This library is free software, licensed under the terms of the GNU **
|
||||
** General Public License as published by the Free Software Foundation, **
|
||||
** either version 2 of the License, or (at your option) any later version. **
|
||||
** You should have received a copy of the GNU General Public License **
|
||||
** along with this program. If not, see <http://www.gnu.org/licenses/>. **
|
||||
******************************************************************************/
|
||||
|
||||
#ifndef DWGREADER18_H
|
||||
#define DWGREADER18_H
|
||||
|
||||
#include <map>
|
||||
#include <list>
|
||||
#include "dwgreader.h"
|
||||
//#include "../drw_textcodec.h"
|
||||
#include "dwgbuffer.h"
|
||||
|
||||
static const int DRW_magicNum18[] = {
|
||||
0x29, 0x23, 0xbe, 0x84, 0xe1, 0x6c, 0xd6, 0xae,
|
||||
0x52, 0x90, 0x49, 0xf1, 0xf1, 0xbb, 0xe9, 0xeb,
|
||||
0xb3, 0xa6, 0xdb, 0x3c, 0x87, 0x0c, 0x3e, 0x99,
|
||||
0x24, 0x5e, 0x0d, 0x1c, 0x06, 0xb7, 0x47, 0xde,
|
||||
0xb3, 0x12, 0x4d, 0xc8, 0x43, 0xbb, 0x8b, 0xa6,
|
||||
0x1f, 0x03, 0x5a, 0x7d, 0x09, 0x38, 0x25, 0x1f,
|
||||
0x5d, 0xd4, 0xcb, 0xfc, 0x96, 0xf5, 0x45, 0x3b,
|
||||
0x13, 0x0d, 0x89, 0x0a, 0x1c, 0xdb, 0xae, 0x32,
|
||||
0x20, 0x9a, 0x50, 0xee, 0x40, 0x78, 0x36, 0xfd,
|
||||
0x12, 0x49, 0x32, 0xf6, 0x9e, 0x7d, 0x49, 0xdc,
|
||||
0xad, 0x4f, 0x14, 0xf2, 0x44, 0x40, 0x66, 0xd0,
|
||||
0x6b, 0xc4, 0x30, 0xb7, 0x32, 0x3b, 0xa1, 0x22,
|
||||
0xf6, 0x22, 0x91, 0x9d, 0xe1, 0x8b, 0x1f, 0xda,
|
||||
0xb0, 0xca, 0x99, 0x02
|
||||
};
|
||||
|
||||
static const int DRW_magicNumEnd18[] = {
|
||||
0xf8, 0x46, 0x6a, 0x04, 0x96, 0x73, 0x0e, 0xd9,
|
||||
0x16, 0x2f, 0x67, 0x68, 0xd4, 0xf7, 0x4a, 0x4a,
|
||||
0xd0, 0x57, 0x68, 0x76};
|
||||
|
||||
class dwgReader18 : public dwgReader {
|
||||
public:
|
||||
dwgReader18(std::istream *stream, dwgR *p)
|
||||
: dwgReader(stream, p),
|
||||
objData(nullptr),
|
||||
uncompSize(),
|
||||
securityFlags()
|
||||
{}
|
||||
|
||||
virtual ~dwgReader18(){
|
||||
if (objData != nullptr)
|
||||
delete[] objData;
|
||||
}
|
||||
bool readMetaData();
|
||||
bool readFileHeader();
|
||||
bool readDwgHeader(DRW_Header& hdr);
|
||||
bool readDwgClasses();
|
||||
bool readDwgHandles();
|
||||
bool readDwgTables(DRW_Header& hdr);
|
||||
bool readDwgBlocks(DRW_Interface& intfa){
|
||||
dwgBuffer dataBuf(objData, static_cast<int>(uncompSize), &decoder);
|
||||
return dwgReader::readDwgBlocks(intfa, &dataBuf);
|
||||
}
|
||||
|
||||
virtual bool readDwgEntities(DRW_Interface& intfa){
|
||||
dwgBuffer dataBuf(objData, static_cast<int>(uncompSize), &decoder);
|
||||
return dwgReader::readDwgEntities(intfa, &dataBuf);
|
||||
}
|
||||
virtual bool readDwgObjects(DRW_Interface& intfa){
|
||||
dwgBuffer dataBuf(objData, static_cast<int>(uncompSize), &decoder);
|
||||
return dwgReader::readDwgObjects(intfa, &dataBuf);
|
||||
}
|
||||
|
||||
// bool readDwgEntity(objHandle& obj, DRW_Interface& intfa){
|
||||
// bool ret = true;
|
||||
// return ret;
|
||||
// }
|
||||
|
||||
protected:
|
||||
duint8 *objData;
|
||||
duint64 uncompSize;
|
||||
|
||||
private:
|
||||
Q_DISABLE_COPY(dwgReader18)
|
||||
// cppcheck-suppress unusedPrivateFunction
|
||||
static void genMagicNumber();
|
||||
// dwgBuffer* bufObj;
|
||||
void parseSysPage(duint8 *decompSec, duint32 decompSize); //called: Section page map: 0x41630e3b
|
||||
bool parseDataPage(dwgSectionInfo si/*, duint8 *dData*/); //called ???: Section map: 0x4163003b
|
||||
static duint32 checksum(duint32 seed, duint8* data, duint32 sz);
|
||||
|
||||
private:
|
||||
duint32 securityFlags;
|
||||
};
|
||||
|
||||
#endif // DWGREADER18_H
|
|
@ -1,486 +0,0 @@
|
|||
/******************************************************************************
|
||||
** libDXFrw - Library to read/write DXF files (ascii & binary) **
|
||||
** **
|
||||
** Copyright (C) 2011-2015 José F. Soriano, rallazz@gmail.com **
|
||||
** **
|
||||
** This library is free software, licensed under the terms of the GNU **
|
||||
** General Public License as published by the Free Software Foundation, **
|
||||
** either version 2 of the License, or (at your option) any later version. **
|
||||
** You should have received a copy of the GNU General Public License **
|
||||
** along with this program. If not, see <http://www.gnu.org/licenses/>. **
|
||||
******************************************************************************/
|
||||
|
||||
#include <cstdlib>
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
#include <string>
|
||||
#include <sstream>
|
||||
#include "drw_dbg.h"
|
||||
#include "dwgreader21.h"
|
||||
#include "drw_textcodec.h"
|
||||
#include "../libdwgr.h"
|
||||
|
||||
bool dwgReader21::readMetaData() {
|
||||
version = parent->getVersion();
|
||||
decoder.setVersion(version, false);
|
||||
DRW_DBG("dwgReader21::readFileHeader()\n");
|
||||
DRW_DBG("dwgReader21::parsing metadata\n");
|
||||
if (! fileBuf->setPosition(11))
|
||||
return false;
|
||||
maintenanceVersion = fileBuf->getRawChar8();
|
||||
DRW_DBG("maintenance verion= "); DRW_DBGH(maintenanceVersion);
|
||||
DRW_DBG("\nbyte at 0x0C= "); DRW_DBG(fileBuf->getRawChar8());
|
||||
previewImagePos = fileBuf->getRawLong32();
|
||||
DRW_DBG("previewImagePos (seekerImageData) = "); DRW_DBG(previewImagePos);
|
||||
DRW_DBG("\n\napp writer version= "); DRW_DBGH(fileBuf->getRawChar8());
|
||||
DRW_DBG("\napp writer maintenance version= "); DRW_DBGH(fileBuf->getRawChar8());
|
||||
duint16 cp = fileBuf->getRawShort16();
|
||||
DRW_DBG("\ncodepage= "); DRW_DBG(cp);
|
||||
if (cp == 30)
|
||||
decoder.setCodePage("ANSI_1252", false);
|
||||
/* UNKNOUWN SECTION 2 bytes*/
|
||||
DRW_DBG("\nUNKNOWN SECTION= "); DRW_DBG(fileBuf->getRawShort16());
|
||||
DRW_DBG("\nUNKNOUWN SECTION 3b= "); DRW_DBG(fileBuf->getRawChar8());
|
||||
duint32 secType = fileBuf->getRawLong32();
|
||||
DRW_DBG("\nsecurity type flag= "); DRW_DBGH(secType);
|
||||
/* UNKNOWN2 SECTION 4 bytes*/
|
||||
DRW_DBG("\nUNKNOWN SECTION 4bytes= "); DRW_DBG(fileBuf->getRawLong32());
|
||||
|
||||
DRW_DBG("\nSummary info address= "); DRW_DBGH(fileBuf->getRawLong32());
|
||||
DRW_DBG("\nVBA project address= "); DRW_DBGH(fileBuf->getRawLong32());
|
||||
DRW_DBG("\n0x00000080 32b= "); DRW_DBGH(fileBuf->getRawLong32());
|
||||
DRW_DBG("\nApp info address= "); DRW_DBGH(fileBuf->getRawLong32());
|
||||
//current position are 0x30 from here to 0x80 are undocumented
|
||||
DRW_DBG("\nAnother address? = "); DRW_DBGH(fileBuf->getRawLong32());
|
||||
return true;
|
||||
}
|
||||
|
||||
bool dwgReader21::parseSysPage(duint64 sizeCompressed, duint64 sizeUncompressed, duint64 correctionFactor, duint64 offset, duint8 *decompData){
|
||||
//round to 8
|
||||
duint64 alsize = (sizeCompressed + 7) &(-8);
|
||||
//minimum RS chunk:
|
||||
duint32 chunks = static_cast<duint32>(((alsize * correctionFactor)+238)/239);
|
||||
duint64 fpsize = chunks * 255;
|
||||
|
||||
if (! fileBuf->setPosition(offset))
|
||||
return false;
|
||||
duint8 *tmpDataRaw = new duint8[fpsize];
|
||||
fileBuf->getBytes(tmpDataRaw, static_cast<int>(fpsize));
|
||||
duint8 *tmpDataRS = new duint8[fpsize];
|
||||
dwgRSCodec::decode239I(tmpDataRaw, tmpDataRS, static_cast<duint32>(fpsize/255));
|
||||
dwgCompressor::decompress21(tmpDataRS, decompData, static_cast<duint32>(sizeCompressed),
|
||||
static_cast<duint32>(sizeUncompressed));
|
||||
delete[]tmpDataRaw;
|
||||
delete[]tmpDataRS;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool dwgReader21::parseDataPage(dwgSectionInfo si, duint8 *dData){
|
||||
DRW_DBG("parseDataPage, section size: "); DRW_DBG(si.size);
|
||||
for (std::map<duint32, dwgPageInfo>::iterator it=si.pages.begin(); it!=si.pages.end(); ++it){
|
||||
dwgPageInfo pi = it->second;
|
||||
if (!fileBuf->setPosition(pi.address))
|
||||
return false;
|
||||
|
||||
duint8 *tmpPageRaw = new duint8[pi.size];
|
||||
fileBuf->getBytes(tmpPageRaw, static_cast<int>(pi.size));
|
||||
#ifdef DRW_DBG_DUMP
|
||||
DRW_DBG("\nSection OBJECTS raw data=\n");
|
||||
for (unsigned int i=0, j=0; i< pi.size;i++) {
|
||||
DRW_DBGH( (unsigned char)tmpPageRaw[i]);
|
||||
if (j == 7) { DRW_DBG("\n"); j = 0;
|
||||
} else { DRW_DBG(", "); j++; }
|
||||
} DRW_DBG("\n");
|
||||
#endif
|
||||
|
||||
duint8 *tmpPageRS = new duint8[pi.size];
|
||||
duint8 chunks = static_cast<duint8>(pi.size / 255);
|
||||
dwgRSCodec::decode251I(tmpPageRaw, tmpPageRS, chunks);
|
||||
#ifdef DRW_DBG_DUMP
|
||||
DRW_DBG("\nSection OBJECTS RS data=\n");
|
||||
for (unsigned int i=0, j=0; i< pi.size;i++) {
|
||||
DRW_DBGH( (unsigned char)tmpPageRS[i]);
|
||||
if (j == 7) { DRW_DBG("\n"); j = 0;
|
||||
} else { DRW_DBG(", "); j++; }
|
||||
} DRW_DBG("\n");
|
||||
#endif
|
||||
|
||||
DRW_DBG("\npage uncomp size: "); DRW_DBG(pi.uSize); DRW_DBG(" comp size: "); DRW_DBG(pi.cSize);
|
||||
DRW_DBG("\noffset: "); DRW_DBG(pi.startOffset);
|
||||
duint8 *pageData = dData + pi.startOffset;
|
||||
dwgCompressor::decompress21(tmpPageRS, pageData, static_cast<duint32>(pi.cSize),
|
||||
static_cast<duint32>(pi.uSize));
|
||||
|
||||
#ifdef DRW_DBG_DUMP
|
||||
DRW_DBG("\n\nSection OBJECTS decompresed data=\n");
|
||||
for (unsigned int i=0, j=0; i< pi.uSize;i++) {
|
||||
DRW_DBGH( (unsigned char)pageData[i]);
|
||||
if (j == 7) { DRW_DBG("\n"); j = 0;
|
||||
} else { DRW_DBG(", "); j++; }
|
||||
} DRW_DBG("\n");
|
||||
#endif
|
||||
|
||||
delete[]tmpPageRaw;
|
||||
delete[]tmpPageRS;
|
||||
}
|
||||
DRW_DBG("\n");
|
||||
return true;
|
||||
}
|
||||
|
||||
bool dwgReader21::readFileHeader() {
|
||||
|
||||
DRW_DBG("\n\ndwgReader21::parsing file header\n");
|
||||
if (! fileBuf->setPosition(0x80))
|
||||
return false;
|
||||
duint8 fileHdrRaw[0x2FD];//0x3D8
|
||||
fileBuf->getBytes(fileHdrRaw, 0x2FD);
|
||||
duint8 fileHdrdRS[0x2CD];
|
||||
dwgRSCodec::decode239I(fileHdrRaw, fileHdrdRS, 3);
|
||||
|
||||
#ifdef DRW_DBG_DUMP
|
||||
DRW_DBG("\ndwgReader21::parsed Reed Solomon decode:\n");
|
||||
int j = 0;
|
||||
for (int i=0, j=0; i<0x2CD; i++){
|
||||
DRW_DBGH( (unsigned char)fileHdrdRS[i]);
|
||||
if (j== 15){ j=0; DRW_DBG("\n");
|
||||
} else{ j++; DRW_DBG(", "); }
|
||||
} DRW_DBG("\n");
|
||||
#endif
|
||||
|
||||
dwgBuffer fileHdrBuf(fileHdrdRS, 0x2CD, &decoder);
|
||||
DRW_DBG("\nCRC 64b= "); DRW_DBGH(fileHdrBuf.getRawLong64());
|
||||
DRW_DBG("\nunknown key 64b= "); DRW_DBGH(fileHdrBuf.getRawLong64());
|
||||
DRW_DBG("\ncomp data CRC 64b= "); DRW_DBGH(fileHdrBuf.getRawLong64());
|
||||
dint32 fileHdrCompLength = fileHdrBuf.getRawLong32();
|
||||
DRW_DBG("\ncompr len 4bytes= "); DRW_DBG(fileHdrCompLength);
|
||||
dint32 fileHdrCompLength2 = fileHdrBuf.getRawLong32();
|
||||
DRW_DBG("\nlength2 4bytes= "); DRW_DBG(fileHdrCompLength2);
|
||||
|
||||
int fileHdrDataLength = 0x110;
|
||||
duint8 *fileHdrData;
|
||||
if (fileHdrCompLength < 0) {
|
||||
fileHdrDataLength = fileHdrCompLength * -1;
|
||||
fileHdrData = new duint8[fileHdrDataLength];
|
||||
fileHdrBuf.getBytes(fileHdrData, fileHdrDataLength);
|
||||
}else {
|
||||
DRW_DBG("\ndwgReader21:: file header are compresed:\n");
|
||||
duint8 *compByteStr = new duint8[fileHdrCompLength];
|
||||
fileHdrBuf.getBytes(compByteStr, fileHdrCompLength);
|
||||
fileHdrData = new duint8[fileHdrDataLength];
|
||||
dwgCompressor::decompress21(compByteStr, fileHdrData, fileHdrCompLength, fileHdrDataLength);
|
||||
delete[] compByteStr;
|
||||
}
|
||||
|
||||
#ifdef DRW_DBG_DUMP
|
||||
DRW_DBG("\ndwgReader21::parsed file header:\n");
|
||||
for (int i=0, j=0; i<fileHdrDataLength; i++){
|
||||
DRW_DBGH( (unsigned char)fileHdrData[i]);
|
||||
if (j== 15){ j=0; DRW_DBG("\n");
|
||||
} else{ j++; DRW_DBG(", "); }
|
||||
} DRW_DBG("\n");
|
||||
#endif
|
||||
|
||||
dwgBuffer fileHdrDataBuf(fileHdrData, fileHdrDataLength, &decoder);
|
||||
DRW_DBG("\nHeader size = "); DRW_DBGH(fileHdrDataBuf.getRawLong64());
|
||||
DRW_DBG("\nFile size = "); DRW_DBGH(fileHdrDataBuf.getRawLong64());
|
||||
DRW_DBG("\nPagesMapCrcCompressed = "); DRW_DBGH(fileHdrDataBuf.getRawLong64());
|
||||
duint64 PagesMapCorrectionFactor = fileHdrDataBuf.getRawLong64();
|
||||
DRW_DBG("\nPagesMapCorrectionFactor = "); DRW_DBG(PagesMapCorrectionFactor);
|
||||
DRW_DBG("\nPagesMapCrcSeed = "); DRW_DBGH(fileHdrDataBuf.getRawLong64());
|
||||
DRW_DBG("\nPages map2offset = "); DRW_DBGH(fileHdrDataBuf.getRawLong64()); //relative to data page map 1, add 0x480 to get stream position
|
||||
DRW_DBG("\nPages map2Id = "); DRW_DBG(fileHdrDataBuf.getRawLong64());
|
||||
duint64 PagesMapOffset = fileHdrDataBuf.getRawLong64();
|
||||
DRW_DBG("\nPagesMapOffset = "); DRW_DBGH(PagesMapOffset); //relative to data page map 1, add 0x480 to get stream position
|
||||
DRW_DBG("\nPagesMapId = "); DRW_DBG(fileHdrDataBuf.getRawLong64());
|
||||
DRW_DBG("\nHeader2offset = "); DRW_DBGH(fileHdrDataBuf.getRawLong64()); //relative to data page map 1, add 0x480 to get stream position
|
||||
duint64 PagesMapSizeCompressed = fileHdrDataBuf.getRawLong64();
|
||||
DRW_DBG("\nPagesMapSizeCompressed = "); DRW_DBG(PagesMapSizeCompressed);
|
||||
duint64 PagesMapSizeUncompressed = fileHdrDataBuf.getRawLong64();
|
||||
DRW_DBG("\nPagesMapSizeUncompressed = "); DRW_DBG(PagesMapSizeUncompressed);
|
||||
DRW_DBG("\nPagesAmount = "); DRW_DBGH(fileHdrDataBuf.getRawLong64());
|
||||
duint64 PagesMaxId = fileHdrDataBuf.getRawLong64();
|
||||
DRW_DBG("\nPagesMaxId = "); DRW_DBG(PagesMaxId);
|
||||
DRW_DBG("\nUnknown (normally 0x20) = "); DRW_DBGH(fileHdrDataBuf.getRawLong64());
|
||||
DRW_DBG("\nUnknown (normally 0x40) = "); DRW_DBGH(fileHdrDataBuf.getRawLong64());
|
||||
DRW_DBG("\nPagesMapCrcUncompressed = "); DRW_DBGH(fileHdrDataBuf.getRawLong64());
|
||||
DRW_DBG("\nUnknown (normally 0xf800) = "); DRW_DBGH(fileHdrDataBuf.getRawLong64());
|
||||
DRW_DBG("\nUnknown (normally 4) = "); DRW_DBGH(fileHdrDataBuf.getRawLong64());
|
||||
DRW_DBG("\nUnknown (normally 1) = "); DRW_DBGH(fileHdrDataBuf.getRawLong64());
|
||||
DRW_DBG("\nSectionsAmount (number of sections + 1) = "); DRW_DBGH(fileHdrDataBuf.getRawLong64());
|
||||
DRW_DBG("\nSectionsMapCrcUncompressed = "); DRW_DBGH(fileHdrDataBuf.getRawLong64());
|
||||
duint64 SectionsMapSizeCompressed = fileHdrDataBuf.getRawLong64();
|
||||
DRW_DBG("\nSectionsMapSizeCompressed = "); DRW_DBGH(SectionsMapSizeCompressed);
|
||||
DRW_DBG("\nSectionsMap2Id = "); DRW_DBG(fileHdrDataBuf.getRawLong64());
|
||||
duint64 SectionsMapId = fileHdrDataBuf.getRawLong64();
|
||||
DRW_DBG("\nSectionsMapId = "); DRW_DBG(SectionsMapId);
|
||||
duint64 SectionsMapSizeUncompressed = fileHdrDataBuf.getRawLong64();
|
||||
DRW_DBG("\nSectionsMapSizeUncompressed = "); DRW_DBGH(SectionsMapSizeUncompressed);
|
||||
DRW_DBG("\nSectionsMapCrcCompressed = "); DRW_DBGH(fileHdrDataBuf.getRawLong64());
|
||||
duint64 SectionsMapCorrectionFactor = fileHdrDataBuf.getRawLong64();
|
||||
DRW_DBG("\nSectionsMapCorrectionFactor = "); DRW_DBG(SectionsMapCorrectionFactor);
|
||||
DRW_DBG("\nSectionsMapCrcSeed = "); DRW_DBGH(fileHdrDataBuf.getRawLong64());
|
||||
DRW_DBG("\nStreamVersion (normally 0x60100) = "); DRW_DBGH(fileHdrDataBuf.getRawLong64());
|
||||
DRW_DBG("\nCrcSeed = "); DRW_DBGH(fileHdrDataBuf.getRawLong64());
|
||||
DRW_DBG("\nCrcSeedEncoded = "); DRW_DBGH(fileHdrDataBuf.getRawLong64());
|
||||
DRW_DBG("\nRandomSeed = "); DRW_DBGH(fileHdrDataBuf.getRawLong64());
|
||||
DRW_DBG("\nHeader CRC64 = "); DRW_DBGH(fileHdrDataBuf.getRawLong64()); DRW_DBG("\n");
|
||||
|
||||
delete[] fileHdrData;
|
||||
|
||||
DRW_DBG("\ndwgReader21::parse page map:\n");
|
||||
duint8 *PagesMapData = new duint8[PagesMapSizeUncompressed];
|
||||
|
||||
bool ret = parseSysPage(PagesMapSizeCompressed, PagesMapSizeUncompressed, PagesMapCorrectionFactor, 0x480+PagesMapOffset, PagesMapData);
|
||||
if (!ret) {
|
||||
delete[]PagesMapData;
|
||||
return false;
|
||||
}
|
||||
|
||||
duint64 address = 0x480;
|
||||
duint64 i = 0;
|
||||
dwgBuffer PagesMapBuf(PagesMapData, static_cast<int>(PagesMapSizeUncompressed), &decoder);
|
||||
//stores temporaly info of all pages:
|
||||
std::map<duint32, dwgPageInfo >sectionPageMapTmp;
|
||||
|
||||
// dwgPageInfo *m_pages= new dwgPageInfo[PagesMaxId+1];
|
||||
while (PagesMapSizeUncompressed > i ) {
|
||||
duint64 size = PagesMapBuf.getRawLong64();
|
||||
dint64 id = PagesMapBuf.getRawLong64();
|
||||
duint64 ind = id > 0 ? id : -id;
|
||||
i += 16;
|
||||
|
||||
DRW_DBG("Page gap= "); DRW_DBG(id); DRW_DBG(" Page num= "); DRW_DBG(ind); DRW_DBG(" size= "); DRW_DBGH(size);
|
||||
DRW_DBG(" address= "); DRW_DBGH(address); DRW_DBG("\n");
|
||||
sectionPageMapTmp[static_cast<duint32>(ind)] = dwgPageInfo(ind, address, static_cast<duint32>(size));
|
||||
address += size;
|
||||
//TODO num can be negative indicating gap
|
||||
// seek += offset;
|
||||
}
|
||||
delete[]PagesMapData;
|
||||
|
||||
DRW_DBG("\n*** dwgReader21: Processing Section Map ***\n");
|
||||
duint8 *SectionsMapData = new duint8[SectionsMapSizeUncompressed];
|
||||
dwgPageInfo sectionMap = sectionPageMapTmp[static_cast<duint32>(SectionsMapId)];
|
||||
ret = parseSysPage(SectionsMapSizeCompressed, SectionsMapSizeUncompressed, SectionsMapCorrectionFactor,
|
||||
sectionMap.address, SectionsMapData);
|
||||
if (!ret)
|
||||
return false;
|
||||
|
||||
//reads sections:
|
||||
//Note: compressed value are not stored in file then, commpresed field are use to store
|
||||
// encoding value
|
||||
dwgBuffer SectionsMapBuf(SectionsMapData, static_cast<int>(SectionsMapSizeUncompressed), &decoder);
|
||||
duint8 nextId =1;
|
||||
while(SectionsMapBuf.getPosition() < SectionsMapBuf.size()){
|
||||
dwgSectionInfo secInfo;
|
||||
secInfo.size = SectionsMapBuf.getRawLong64();
|
||||
DRW_DBG("\nSize of section (data size)= "); DRW_DBGH(secInfo.size);
|
||||
secInfo.maxSize = SectionsMapBuf.getRawLong64();
|
||||
DRW_DBG("\nMax Decompressed Size= "); DRW_DBGH(secInfo.maxSize);
|
||||
secInfo.encrypted = static_cast<duint32>(SectionsMapBuf.getRawLong64());
|
||||
//encrypted (doc: 0 no, 1 yes, 2 unkn) on read: objects 0 and encrypted yes
|
||||
DRW_DBG("\nencription= "); DRW_DBGH(secInfo.encrypted);
|
||||
DRW_DBG("\nHashCode = "); DRW_DBGH(SectionsMapBuf.getRawLong64());
|
||||
duint64 SectionNameLength = SectionsMapBuf.getRawLong64();
|
||||
DRW_DBG("\nSectionNameLength = "); DRW_DBG(SectionNameLength);
|
||||
DRW_DBG("\nUnknown = "); DRW_DBGH(SectionsMapBuf.getRawLong64());
|
||||
secInfo.compresed = static_cast<duint32>(SectionsMapBuf.getRawLong64());
|
||||
DRW_DBG("\nEncoding (compresed) = "); DRW_DBGH(secInfo.compresed);
|
||||
secInfo.pageCount = SectionsMapBuf.getRawLong64();
|
||||
DRW_DBG("\nPage count= "); DRW_DBGH(secInfo.pageCount);
|
||||
secInfo.name = SectionsMapBuf.getUCSStr(static_cast<duint16>(SectionNameLength));
|
||||
DRW_DBG("\nSection name = "); DRW_DBG(secInfo.name); DRW_DBG("\n");
|
||||
|
||||
for (unsigned int i=0; i< secInfo.pageCount; i++){
|
||||
duint64 po = SectionsMapBuf.getRawLong64();
|
||||
duint32 ds = static_cast<duint32>(SectionsMapBuf.getRawLong64());
|
||||
duint32 pn = static_cast<duint32>(SectionsMapBuf.getRawLong64());
|
||||
DRW_DBG(" pag Id = "); DRW_DBGH(pn); DRW_DBG(" data size = "); DRW_DBGH(ds);
|
||||
dwgPageInfo pi = sectionPageMapTmp[pn]; //get a copy
|
||||
pi.dataSize = ds;
|
||||
pi.startOffset = static_cast<duint32>(po);
|
||||
pi.uSize = SectionsMapBuf.getRawLong64();
|
||||
pi.cSize = SectionsMapBuf.getRawLong64();
|
||||
secInfo.pages[pn]= pi;//complete copy in secInfo
|
||||
DRW_DBG("\n Page number= "); DRW_DBGH(secInfo.pages[pn].Id);
|
||||
DRW_DBG("\n address in file= "); DRW_DBGH(secInfo.pages[pn].address);
|
||||
DRW_DBG("\n size in file= "); DRW_DBGH(secInfo.pages[pn].size);
|
||||
DRW_DBG("\n Data size= "); DRW_DBGH(secInfo.pages[pn].dataSize);
|
||||
DRW_DBG("\n Start offset= "); DRW_DBGH(secInfo.pages[pn].startOffset);
|
||||
DRW_DBG("\n Page uncompressed size = "); DRW_DBGH(secInfo.pages[pn].uSize);
|
||||
DRW_DBG("\n Page compressed size = "); DRW_DBGH(secInfo.pages[pn].cSize);
|
||||
|
||||
DRW_DBG("\n Page checksum = "); DRW_DBGH(SectionsMapBuf.getRawLong64());
|
||||
DRW_DBG("\n Page CRC = "); DRW_DBGH(SectionsMapBuf.getRawLong64()); DRW_DBG("\n");
|
||||
}
|
||||
|
||||
if (!secInfo.name.empty()) {
|
||||
secInfo.Id = nextId++;
|
||||
DRW_DBG("Saved section Name= "); DRW_DBG( secInfo.name.c_str() ); DRW_DBG("\n");
|
||||
sections[secEnum::getEnum(secInfo.name)] = secInfo;
|
||||
}
|
||||
}
|
||||
delete[]SectionsMapData;
|
||||
|
||||
if (! fileBuf->isGood())
|
||||
return false;
|
||||
|
||||
DRW_DBG("\ndwgReader21::readFileHeader END\n");
|
||||
return true;
|
||||
}
|
||||
|
||||
bool dwgReader21::readDwgHeader(DRW_Header& hdr){
|
||||
DRW_DBG("\ndwgReader21::readDwgHeader\n");
|
||||
dwgSectionInfo si = sections[secEnum::HEADER];
|
||||
if (si.Id<0)//not found, ends
|
||||
return false;
|
||||
DRW_DBG("\nprepare section of size "); DRW_DBG(si.size);DRW_DBG("\n");
|
||||
duint8 *tmpHeaderData = new duint8[si.size];
|
||||
bool ret = dwgReader21::parseDataPage(si, tmpHeaderData);
|
||||
if (!ret) {
|
||||
delete[]tmpHeaderData;
|
||||
return ret;
|
||||
}
|
||||
|
||||
dwgBuffer dataBuf(tmpHeaderData, static_cast<int>(si.size), &decoder);
|
||||
dwgBuffer handleBuf(tmpHeaderData, static_cast<int>(si.size), &decoder);
|
||||
DRW_DBG("Header section sentinel= ");
|
||||
checkSentinel(&dataBuf, secEnum::HEADER, true);
|
||||
ret = dwgReader::readDwgHeader(hdr, &dataBuf, &handleBuf);
|
||||
delete[]tmpHeaderData;
|
||||
return ret;
|
||||
}
|
||||
|
||||
bool dwgReader21::readDwgClasses(){
|
||||
DRW_DBG("\ndwgReader21::readDwgClasses");
|
||||
dwgSectionInfo si = sections[secEnum::CLASSES];
|
||||
if (si.Id<0)//not found, ends
|
||||
return false;
|
||||
|
||||
DRW_DBG("\nprepare section of size "); DRW_DBG(si.size);DRW_DBG("\n");
|
||||
duint8 *tmpClassesData = new duint8[si.size];
|
||||
bool ret = dwgReader21::parseDataPage(si, tmpClassesData);
|
||||
if (!ret)
|
||||
return ret;
|
||||
|
||||
dwgBuffer buff(tmpClassesData, static_cast<int>(si.size), &decoder);
|
||||
DRW_DBG("classes section sentinel= ");
|
||||
checkSentinel(&buff, secEnum::CLASSES, true);
|
||||
|
||||
duint32 size = buff.getRawLong32();
|
||||
DRW_DBG("\ndata size in bytes "); DRW_DBG(size);
|
||||
|
||||
duint32 bitSize = buff.getRawLong32();
|
||||
DRW_DBG("\ntotal size in bits "); DRW_DBG(bitSize);
|
||||
|
||||
duint32 maxClassNum = buff.getBitShort();
|
||||
DRW_DBG("\nMaximum class number "); DRW_DBG(maxClassNum);
|
||||
DRW_DBG("\nRc 1 "); DRW_DBG(buff.getRawChar8());
|
||||
DRW_DBG("\nRc 2 "); DRW_DBG(buff.getRawChar8());
|
||||
DRW_DBG("\nBit "); DRW_DBG(buff.getBit());
|
||||
|
||||
/*******************************/
|
||||
//prepare string stream
|
||||
dwgBuffer strBuff(tmpClassesData, static_cast<int>(si.size), &decoder);
|
||||
duint32 strStartPos = bitSize + 159;//size in bits + 20 bytes (sn+size) - 1 bit (endbit)
|
||||
DRW_DBG("\nstrStartPos: "); DRW_DBG(strStartPos);
|
||||
strBuff.setPosition(strStartPos >> 3);
|
||||
strBuff.setBitPos(strStartPos & 7);
|
||||
DRW_DBG("\nclasses strings buff.getPosition: "); DRW_DBG(strBuff.getPosition());
|
||||
DRW_DBG("\nclasses strings buff.getBitPos: "); DRW_DBG(strBuff.getBitPos());
|
||||
DRW_DBG("\nendBit "); DRW_DBG(strBuff.getBit());
|
||||
strStartPos -= 16;//decrement 16 bits
|
||||
DRW_DBG("\nstrStartPos: "); DRW_DBG(strStartPos);
|
||||
strBuff.setPosition(strStartPos >> 3);
|
||||
strBuff.setBitPos(strStartPos & 7);
|
||||
DRW_DBG("\nclasses strings buff.getPosition: "); DRW_DBG(strBuff.getPosition());
|
||||
DRW_DBG("\nclasses strings buff.getBitPos: "); DRW_DBG(strBuff.getBitPos());
|
||||
duint32 strDataSize = strBuff.getRawShort16();
|
||||
DRW_DBG("\nstrDataSize: "); DRW_DBG(strDataSize);
|
||||
if (strDataSize & 0x8000) {
|
||||
strStartPos -= 16;//decrement 16 bits
|
||||
strDataSize &= 0x7FFF; //strip 0x8000;
|
||||
strBuff.setPosition(strStartPos >> 3);
|
||||
strBuff.setBitPos(strStartPos & 7);
|
||||
duint32 hiSize = strBuff.getRawShort16();
|
||||
strDataSize |= (hiSize << 15);
|
||||
}
|
||||
strStartPos -= strDataSize;
|
||||
DRW_DBG("\nstrStartPos: "); DRW_DBG(strStartPos);
|
||||
strBuff.setPosition(strStartPos >> 3);
|
||||
strBuff.setBitPos(strStartPos & 7);
|
||||
DRW_DBG("\nclasses strings buff.getPosition: "); DRW_DBG(strBuff.getPosition());
|
||||
DRW_DBG("\nclasses strings buff.getBitPos: "); DRW_DBG(strBuff.getBitPos());
|
||||
|
||||
|
||||
/*******************************/
|
||||
|
||||
duint32 endDataPos = maxClassNum-499;
|
||||
DRW_DBG("\nbuff.getPosition: "); DRW_DBG(buff.getPosition());
|
||||
for (duint32 i= 0; i<endDataPos;i++) {
|
||||
DRW_Class *cl = new DRW_Class();
|
||||
cl->parseDwg(version, &buff, &strBuff);
|
||||
classesmap[cl->classNum] = cl;
|
||||
DRW_DBG("\nbuff.getPosition: "); DRW_DBG(buff.getPosition());
|
||||
}
|
||||
DRW_DBG("\nend classes data buff.getPosition: "); DRW_DBG(buff.getPosition());
|
||||
DRW_DBG("\nend classes data buff.getBitPos: "); DRW_DBG(buff.getBitPos());
|
||||
|
||||
buff.setPosition(size+20);//sizeVal+sn+32bSize
|
||||
DRW_DBG("\nCRC: "); DRW_DBGH(buff.getRawShort16());
|
||||
DRW_DBG("\nclasses section end sentinel= ");
|
||||
checkSentinel(&buff, secEnum::CLASSES, true);
|
||||
delete[]tmpClassesData;
|
||||
return buff.isGood();
|
||||
}
|
||||
|
||||
|
||||
bool dwgReader21::readDwgHandles(){
|
||||
DRW_DBG("\ndwgReader21::readDwgHandles");
|
||||
dwgSectionInfo si = sections[secEnum::HANDLES];
|
||||
if (si.Id<0)//not found, ends
|
||||
return false;
|
||||
|
||||
DRW_DBG("\nprepare section of size "); DRW_DBG(si.size);DRW_DBG("\n");
|
||||
duint8 *tmpHandlesData = new duint8[si.size];
|
||||
bool ret = dwgReader21::parseDataPage(si, tmpHandlesData);
|
||||
if (!ret)
|
||||
return ret;
|
||||
|
||||
dwgBuffer dataBuf(tmpHandlesData, static_cast<int>(si.size), &decoder);
|
||||
|
||||
ret = dwgReader::readDwgHandles(&dataBuf, 0, static_cast<duint32>(si.size));
|
||||
delete[]tmpHandlesData;
|
||||
return ret;
|
||||
}
|
||||
|
||||
/*********** objects ************************/
|
||||
/**
|
||||
* Reads all the object referenced in the object map section of the DWG file
|
||||
* (using their object file offsets)
|
||||
*/
|
||||
bool dwgReader21::readDwgTables(DRW_Header& hdr) {
|
||||
DRW_DBG("\ndwgReader21::readDwgTables\n");
|
||||
dwgSectionInfo si = sections[secEnum::OBJECTS];
|
||||
if (si.Id<0)//not found, ends
|
||||
return false;
|
||||
|
||||
DRW_DBG("\nprepare section of size "); DRW_DBG(si.size);DRW_DBG("\n");
|
||||
dataSize = si.size;
|
||||
objData = new duint8 [dataSize];
|
||||
bool ret = dwgReader21::parseDataPage(si, objData);
|
||||
if (!ret)
|
||||
return ret;
|
||||
|
||||
DRW_DBG("readDwgTables total data size= "); DRW_DBG(dataSize); DRW_DBG("\n");
|
||||
dwgBuffer dataBuf(objData, static_cast<int>(dataSize), &decoder);
|
||||
ret = dwgReader::readDwgTables(hdr, &dataBuf);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
bool dwgReader21::readDwgBlocks(DRW_Interface& intfa){
|
||||
dwgBuffer dataBuf(objData, static_cast<int>(dataSize), &decoder);
|
||||
return dwgReader::readDwgBlocks(intfa, &dataBuf);
|
||||
}
|
|
@ -1,65 +0,0 @@
|
|||
/******************************************************************************
|
||||
** libDXFrw - Library to read/write DXF files (ascii & binary) **
|
||||
** **
|
||||
** Copyright (C) 2011-2015 José F. Soriano, rallazz@gmail.com **
|
||||
** **
|
||||
** This library is free software, licensed under the terms of the GNU **
|
||||
** General Public License as published by the Free Software Foundation, **
|
||||
** either version 2 of the License, or (at your option) any later version. **
|
||||
** You should have received a copy of the GNU General Public License **
|
||||
** along with this program. If not, see <http://www.gnu.org/licenses/>. **
|
||||
******************************************************************************/
|
||||
|
||||
#ifndef DWGREADER21_H
|
||||
#define DWGREADER21_H
|
||||
|
||||
#include <map>
|
||||
#include <list>
|
||||
#include "drw_textcodec.h"
|
||||
#include "dwgbuffer.h"
|
||||
#include "dwgreader.h"
|
||||
|
||||
//reader for AC1021 aka v2007, chapter 5
|
||||
class dwgReader21 : public dwgReader {
|
||||
public:
|
||||
dwgReader21(std::istream *stream, dwgR *p)
|
||||
: dwgReader(stream, p),
|
||||
objData(nullptr),
|
||||
dataSize(0)
|
||||
{}
|
||||
|
||||
virtual ~dwgReader21(){
|
||||
if (objData != nullptr)
|
||||
delete[] objData;
|
||||
}
|
||||
bool readMetaData();
|
||||
bool readFileHeader();
|
||||
bool readDwgHeader(DRW_Header& hdr);
|
||||
bool readDwgClasses();
|
||||
bool readDwgHandles();
|
||||
bool readDwgTables(DRW_Header& hdr);
|
||||
bool readDwgBlocks(DRW_Interface& intfa);
|
||||
virtual bool readDwgEntities(DRW_Interface& intfa){
|
||||
dwgBuffer dataBuf(objData, static_cast<int>(dataSize), &decoder);
|
||||
return dwgReader::readDwgEntities(intfa, &dataBuf);
|
||||
}
|
||||
virtual bool readDwgObjects(DRW_Interface& intfa){
|
||||
dwgBuffer dataBuf(objData, static_cast<int>(dataSize), &decoder);
|
||||
return dwgReader::readDwgObjects(intfa, &dataBuf);
|
||||
}
|
||||
//bool readDwgEntity(objHandle& obj, DRW_Interface& intfa){
|
||||
// return false;
|
||||
//}
|
||||
|
||||
private:
|
||||
Q_DISABLE_COPY(dwgReader21)
|
||||
bool parseSysPage(duint64 sizeCompressed, duint64 sizeUncompressed, duint64 correctionFactor, duint64 offset,
|
||||
duint8 *decompData);
|
||||
bool parseDataPage(dwgSectionInfo si, duint8 *dData);
|
||||
|
||||
duint8 *objData;
|
||||
duint64 dataSize;
|
||||
|
||||
};
|
||||
|
||||
#endif // DWGREADER21_H
|
|
@ -1,43 +0,0 @@
|
|||
/******************************************************************************
|
||||
** libDXFrw - Library to read/write DXF files (ascii & binary) **
|
||||
** **
|
||||
** Copyright (C) 2011-2015 José F. Soriano, rallazz@gmail.com **
|
||||
** **
|
||||
** This library is free software, licensed under the terms of the GNU **
|
||||
** General Public License as published by the Free Software Foundation, **
|
||||
** either version 2 of the License, or (at your option) any later version. **
|
||||
** You should have received a copy of the GNU General Public License **
|
||||
** along with this program. If not, see <http://www.gnu.org/licenses/>. **
|
||||
******************************************************************************/
|
||||
|
||||
#include <cstdlib>
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
#include <string>
|
||||
#include <sstream>
|
||||
#include "drw_dbg.h"
|
||||
#include "dwgreader24.h"
|
||||
#include "drw_textcodec.h"
|
||||
#include "../libdwgr.h"
|
||||
|
||||
|
||||
bool dwgReader24::readFileHeader() {
|
||||
DRW_DBG("dwgReader24::readFileHeader\n");
|
||||
bool ret = dwgReader18::readFileHeader();
|
||||
DRW_DBG("dwgReader24::readFileHeader END\n");
|
||||
return ret;
|
||||
}
|
||||
|
||||
bool dwgReader24::readDwgHeader(DRW_Header& hdr){
|
||||
DRW_DBG("dwgReader24::readDwgHeader\n");
|
||||
bool ret = dwgReader18::readDwgHeader(hdr);
|
||||
DRW_DBG("dwgReader24::readDwgHeader END\n");
|
||||
return ret;
|
||||
}
|
||||
|
||||
bool dwgReader24::readDwgClasses(){
|
||||
DRW_DBG("\ndwgReader24::readDwgClasses");
|
||||
bool ret = dwgReader18::readDwgClasses();
|
||||
DRW_DBG("\ndwgReader24::readDwgClasses END\n");
|
||||
return ret;
|
||||
}
|
|
@ -1,50 +0,0 @@
|
|||
/******************************************************************************
|
||||
** libDXFrw - Library to read/write DXF files (ascii & binary) **
|
||||
** **
|
||||
** Copyright (C) 2011-2015 José F. Soriano, rallazz@gmail.com **
|
||||
** **
|
||||
** This library is free software, licensed under the terms of the GNU **
|
||||
** General Public License as published by the Free Software Foundation, **
|
||||
** either version 2 of the License, or (at your option) any later version. **
|
||||
** You should have received a copy of the GNU General Public License **
|
||||
** along with this program. If not, see <http://www.gnu.org/licenses/>. **
|
||||
******************************************************************************/
|
||||
|
||||
#ifndef DWGREADER24_H
|
||||
#define DWGREADER24_H
|
||||
|
||||
#include <map>
|
||||
#include <list>
|
||||
#include "drw_textcodec.h"
|
||||
#include "dwgbuffer.h"
|
||||
#include "dwgreader18.h"
|
||||
|
||||
class dwgReader24 : public dwgReader18 {
|
||||
public:
|
||||
dwgReader24(std::istream *stream, dwgR *p):dwgReader18(stream, p){ }
|
||||
virtual ~dwgReader24(){}
|
||||
bool readFileHeader();
|
||||
bool readDwgHeader(DRW_Header& hdr);
|
||||
bool readDwgClasses();
|
||||
// bool readDwgHandles(){return false;}
|
||||
// bool readDwgTables(){return false;}
|
||||
bool readDwgBlocks(DRW_Interface& intfa){
|
||||
dwgBuffer dataBuf(objData, static_cast<int>(uncompSize), &decoder);
|
||||
return dwgReader::readDwgBlocks(intfa, &dataBuf);
|
||||
}
|
||||
virtual bool readDwgEntities(DRW_Interface& intfa){
|
||||
dwgBuffer dataBuf(objData, static_cast<int>(uncompSize), &decoder);
|
||||
return dwgReader::readDwgEntities(intfa, &dataBuf);
|
||||
}
|
||||
virtual bool readDwgObjects(DRW_Interface& intfa){
|
||||
dwgBuffer dataBuf(objData, static_cast<int>(uncompSize), &decoder);
|
||||
return dwgReader::readDwgObjects(intfa, &dataBuf);
|
||||
}
|
||||
|
||||
// bool readDwgEntity(objHandle& obj, DRW_Interface& intfa){
|
||||
// DRW_UNUSED(obj);
|
||||
// DRW_UNUSED(intfa);
|
||||
// return false;}
|
||||
};
|
||||
|
||||
#endif // DWGREADER24_H
|
|
@ -1,43 +0,0 @@
|
|||
/******************************************************************************
|
||||
** libDXFrw - Library to read/write DXF files (ascii & binary) **
|
||||
** **
|
||||
** Copyright (C) 2011-2015 José F. Soriano, rallazz@gmail.com **
|
||||
** **
|
||||
** This library is free software, licensed under the terms of the GNU **
|
||||
** General Public License as published by the Free Software Foundation, **
|
||||
** either version 2 of the License, or (at your option) any later version. **
|
||||
** You should have received a copy of the GNU General Public License **
|
||||
** along with this program. If not, see <http://www.gnu.org/licenses/>. **
|
||||
******************************************************************************/
|
||||
|
||||
#include <cstdlib>
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
#include <string>
|
||||
#include <sstream>
|
||||
#include "drw_dbg.h"
|
||||
#include "dwgreader27.h"
|
||||
#include "drw_textcodec.h"
|
||||
#include "../libdwgr.h"
|
||||
|
||||
|
||||
bool dwgReader27::readFileHeader() {
|
||||
DRW_DBG("dwgReader27::readFileHeader\n");
|
||||
bool ret = dwgReader18::readFileHeader();
|
||||
DRW_DBG("dwgReader27::readFileHeader END\n");
|
||||
return ret;
|
||||
}
|
||||
|
||||
bool dwgReader27::readDwgHeader(DRW_Header& hdr){
|
||||
DRW_DBG("dwgReader27::readDwgHeader\n");
|
||||
bool ret = dwgReader18::readDwgHeader(hdr);
|
||||
DRW_DBG("dwgReader27::readDwgHeader END\n");
|
||||
return ret;
|
||||
}
|
||||
|
||||
bool dwgReader27::readDwgClasses(){
|
||||
DRW_DBG("dwgReader27::readDwgClasses");
|
||||
bool ret = dwgReader18::readDwgClasses();
|
||||
DRW_DBG("\ndwgReader27::readDwgClasses END\n");
|
||||
return ret;
|
||||
}
|
|
@ -1,49 +0,0 @@
|
|||
/******************************************************************************
|
||||
** libDXFrw - Library to read/write DXF files (ascii & binary) **
|
||||
** **
|
||||
** Copyright (C) 2011-2015 José F. Soriano, rallazz@gmail.com **
|
||||
** **
|
||||
** This library is free software, licensed under the terms of the GNU **
|
||||
** General Public License as published by the Free Software Foundation, **
|
||||
** either version 2 of the License, or (at your option) any later version. **
|
||||
** You should have received a copy of the GNU General Public License **
|
||||
** along with this program. If not, see <http://www.gnu.org/licenses/>. **
|
||||
******************************************************************************/
|
||||
|
||||
#ifndef DWGREADER27_H
|
||||
#define DWGREADER27_H
|
||||
|
||||
#include <map>
|
||||
#include <list>
|
||||
#include "drw_textcodec.h"
|
||||
#include "dwgbuffer.h"
|
||||
#include "dwgreader18.h"
|
||||
|
||||
class dwgReader27 : public dwgReader18 {
|
||||
public:
|
||||
dwgReader27(std::istream *stream, dwgR *p):dwgReader18(stream, p){ }
|
||||
virtual ~dwgReader27(){}
|
||||
bool readFileHeader();
|
||||
bool readDwgHeader(DRW_Header& hdr);
|
||||
bool readDwgClasses();
|
||||
// bool readDwgHandles(){return false;}
|
||||
// bool readDwgTables(){return false;}
|
||||
bool readDwgBlocks(DRW_Interface& intfa){
|
||||
dwgBuffer dataBuf(objData, static_cast<int>(uncompSize), &decoder);
|
||||
return dwgReader::readDwgBlocks(intfa, &dataBuf);
|
||||
}
|
||||
virtual bool readDwgEntities(DRW_Interface& intfa){
|
||||
dwgBuffer dataBuf(objData, static_cast<int>(uncompSize), &decoder);
|
||||
return dwgReader::readDwgEntities(intfa, &dataBuf);
|
||||
}
|
||||
virtual bool readDwgObjects(DRW_Interface& intfa){
|
||||
dwgBuffer dataBuf(objData, static_cast<int>(uncompSize), &decoder);
|
||||
return dwgReader::readDwgObjects(intfa, &dataBuf);
|
||||
}
|
||||
// bool readDwgEntity(objHandle& obj, DRW_Interface& intfa){
|
||||
// DRW_UNUSED(obj);
|
||||
// DRW_UNUSED(intfa);
|
||||
// return false;}
|
||||
};
|
||||
|
||||
#endif // DWGREADER21_H
|
|
@ -1,692 +0,0 @@
|
|||
/******************************************************************************
|
||||
** libDXFrw - Library to read/write DXF files (ascii & binary) **
|
||||
** **
|
||||
** Copyright (C) 2011-2015 José F. Soriano, rallazz@gmail.com **
|
||||
** **
|
||||
** This library is free software, licensed under the terms of the GNU **
|
||||
** General Public License as published by the Free Software Foundation, **
|
||||
** either version 2 of the License, or (at your option) any later version. **
|
||||
** You should have received a copy of the GNU General Public License **
|
||||
** along with this program. If not, see <http://www.gnu.org/licenses/>. **
|
||||
******************************************************************************/
|
||||
|
||||
#include <sstream>
|
||||
#include "drw_dbg.h"
|
||||
#include "dwgutil.h"
|
||||
#include "rscodec.h"
|
||||
#include "../libdwgr.h"
|
||||
|
||||
/** utility function
|
||||
* convert a int to string in hex
|
||||
**/
|
||||
namespace DRW {
|
||||
std::string toHexStr(int n){
|
||||
#if defined(__APPLE__)
|
||||
char buffer[9]= {'\0'};
|
||||
snprintf(buffer,9, "%X", n);
|
||||
return std::string(buffer);
|
||||
#else
|
||||
std::ostringstream Convert;
|
||||
Convert << std::uppercase << std::hex << n;
|
||||
return Convert.str();
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief dwgRSCodec::decode239I
|
||||
* @param in : input data (at least 255*blk bytes)
|
||||
* @param out : output data (at least 239*blk bytes)
|
||||
* @param blk number of codewords ( 1 cw == 255 bytes)
|
||||
*/
|
||||
void dwgRSCodec::decode239I(unsigned char *in, unsigned char *out, duint32 blk){
|
||||
unsigned char data[255];
|
||||
RScodec rsc(0x96, 8, 8); //(255, 239)
|
||||
for (duint32 i=0; i<blk; i++){
|
||||
int k = i;
|
||||
for (int j=0; j<255; j++) {
|
||||
data[j] = in[k];
|
||||
k +=blk;
|
||||
}
|
||||
int r = rsc.decode(data);
|
||||
if (r<0)
|
||||
DRW_DBG("\nWARNING: dwgRSCodec::decode239I, can't correct all errors");
|
||||
k = i*239;
|
||||
for (int j=0; j<239; j++) {
|
||||
out[k++] = data[j];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief dwgRSCodec::decode251I
|
||||
* @param in : input data (at least 255*blk bytes)
|
||||
* @param out : output data (at least 251*blk bytes)
|
||||
* @param blk number of codewords ( 1 cw == 255 bytes)
|
||||
*/
|
||||
void dwgRSCodec::decode251I(unsigned char *in, unsigned char *out, duint32 blk){
|
||||
unsigned char data[255];
|
||||
RScodec rsc(0xB8, 8, 2); //(255, 251)
|
||||
for (duint32 i=0; i<blk; i++){
|
||||
int k = i;
|
||||
for (int j=0; j<255; j++) {
|
||||
data[j] = in[k];
|
||||
k +=blk;
|
||||
}
|
||||
int r = rsc.decode(data);
|
||||
if (r<0)
|
||||
DRW_DBG("\nWARNING: dwgRSCodec::decode251I, can't correct all errors");
|
||||
k = i*251;
|
||||
for (int j=0; j<251; j++) {
|
||||
out[k++] = data[j];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
duint32 dwgCompressor::twoByteOffset(duint32 *ll){
|
||||
duint32 cont = 0;
|
||||
duint8 fb = bufC[pos++];
|
||||
cont = (fb >> 2) | (bufC[pos++] << 6);
|
||||
*ll = (fb & 0x03);
|
||||
return cont;
|
||||
}
|
||||
|
||||
duint32 dwgCompressor::longCompressionOffset(){
|
||||
duint32 cont = 0;
|
||||
duint8 ll = bufC[pos++];
|
||||
while (ll == 0x00){
|
||||
cont += 0xFF;
|
||||
ll = bufC[pos++];
|
||||
}
|
||||
cont += ll;
|
||||
return cont;
|
||||
}
|
||||
|
||||
duint32 dwgCompressor::long20CompressionOffset(){
|
||||
// duint32 cont = 0;
|
||||
duint32 cont = 0x0F;
|
||||
duint8 ll = bufC[pos++];
|
||||
while (ll == 0x00){
|
||||
// cont += 0xFF;
|
||||
ll = bufC[pos++];
|
||||
}
|
||||
cont += ll;
|
||||
return cont;
|
||||
}
|
||||
|
||||
duint32 dwgCompressor::litLength18(){
|
||||
duint32 cont=0;
|
||||
duint8 ll = bufC[pos++];
|
||||
//no literal length, this byte is next opCode
|
||||
if (ll > 0x0F) {
|
||||
pos--;
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (ll == 0x00) {
|
||||
cont = 0x0F;
|
||||
ll = bufC[pos++];
|
||||
while (ll == 0x00){//repeat until ll != 0x00
|
||||
cont +=0xFF;
|
||||
ll = bufC[pos++];
|
||||
}
|
||||
}
|
||||
cont +=ll;
|
||||
cont +=3; //already sum 3
|
||||
return cont;
|
||||
}
|
||||
|
||||
void dwgCompressor::decompress18(duint8 *cbuf, duint8 *dbuf, duint32 csize, duint32 dsize){
|
||||
bufC = cbuf;
|
||||
bufD = dbuf;
|
||||
sizeC = csize -2;
|
||||
sizeD = dsize;
|
||||
DRW_DBG("dwgCompressor::decompress, last 2 bytes: ");
|
||||
DRW_DBGH(bufC[sizeC]);DRW_DBGH(bufC[sizeC+1]);DRW_DBG("\n");
|
||||
sizeC = csize;
|
||||
|
||||
duint32 compBytes;
|
||||
duint32 compOffset;
|
||||
duint32 litCount;
|
||||
|
||||
pos=0; //current position in compresed buffer
|
||||
rpos=0; //current position in resulting decompresed buffer
|
||||
litCount = litLength18();
|
||||
//copy first lileral lenght
|
||||
for (duint32 i=0; i < litCount; ++i) {
|
||||
bufD[rpos++] = bufC[pos++];
|
||||
}
|
||||
|
||||
while (pos < csize && (rpos < dsize+1)){//rpos < dsize to prevent crash more robust are needed
|
||||
duint8 oc = bufC[pos++]; //next opcode
|
||||
if (oc == 0x10){
|
||||
compBytes = longCompressionOffset()+ 9;
|
||||
compOffset = twoByteOffset(&litCount) + 0x3FFF;
|
||||
if (litCount == 0)
|
||||
litCount= litLength18();
|
||||
} else if (oc > 0x11 && oc< 0x20){
|
||||
compBytes = (oc & 0x0F) + 2;
|
||||
compOffset = twoByteOffset(&litCount) + 0x3FFF;
|
||||
if (litCount == 0)
|
||||
litCount= litLength18();
|
||||
} else if (oc == 0x20){
|
||||
compBytes = longCompressionOffset() + 0x21;
|
||||
compOffset = twoByteOffset(&litCount);
|
||||
if (litCount == 0)
|
||||
litCount= litLength18();
|
||||
else
|
||||
oc = 0x00;
|
||||
} else if (oc > 0x20 && oc< 0x40){
|
||||
compBytes = oc - 0x1E;
|
||||
compOffset = twoByteOffset(&litCount);
|
||||
if (litCount == 0)
|
||||
litCount= litLength18();
|
||||
} else if ( oc > 0x3F){
|
||||
compBytes = ((oc & 0xF0) >> 4) - 1;
|
||||
duint8 ll2 = bufC[pos++];
|
||||
compOffset = (ll2 << 2) | ((oc & 0x0C) >> 2);
|
||||
litCount = oc & 0x03;
|
||||
if (litCount < 1){
|
||||
litCount= litLength18();}
|
||||
} else if (oc == 0x11){
|
||||
DRW_DBG("dwgCompressor::decompress, end of input stream, Cpos: ");
|
||||
DRW_DBG(pos);DRW_DBG(", Dpos: ");DRW_DBG(rpos);DRW_DBG("\n");
|
||||
return; //end of input stream
|
||||
} else { //ll < 0x10
|
||||
DRW_DBG("WARNING dwgCompressor::decompress, failed, illegal char, Cpos: ");
|
||||
DRW_DBG(pos);DRW_DBG(", Dpos: ");DRW_DBG(rpos);DRW_DBG("\n");
|
||||
return; //fails, not valid
|
||||
}
|
||||
//copy "compresed data", TODO Needed verify out of bounds
|
||||
duint32 remaining = sizeD - (litCount+rpos);
|
||||
if (remaining < compBytes){
|
||||
compBytes = remaining;
|
||||
DRW_DBG("WARNING dwgCompressor::decompress, bad compBytes size, Cpos: ");
|
||||
DRW_DBG(pos);DRW_DBG(", Dpos: ");DRW_DBG(rpos);DRW_DBG("\n");
|
||||
}
|
||||
for (duint32 i=0, j= rpos - compOffset -1; i < compBytes; i++) {
|
||||
bufD[rpos++] = bufD[j++];
|
||||
}
|
||||
//copy "uncompresed data", TODO Needed verify out of bounds
|
||||
for (duint32 i=0; i < litCount; i++) {
|
||||
bufD[rpos++] = bufC[pos++];
|
||||
}
|
||||
}
|
||||
DRW_DBG("WARNING dwgCompressor::decompress, bad out, Cpos: ");DRW_DBG(pos);DRW_DBG(", Dpos: ");DRW_DBG(rpos);DRW_DBG("\n");
|
||||
}
|
||||
|
||||
|
||||
void dwgCompressor::decrypt18Hdr(duint8 *buf, duint32 size, duint32 offset){
|
||||
duint8 max = static_cast<duint8>(size / 4);
|
||||
duint32 secMask = 0x4164536b ^ offset;
|
||||
duint32* pHdr = reinterpret_cast<duint32*>(buf);
|
||||
for (duint8 j = 0; j < max; j++)
|
||||
*pHdr++ ^= secMask;
|
||||
}
|
||||
|
||||
/*void dwgCompressor::decrypt18Data(duint8 *buf, duint32 size, duint32 offset){
|
||||
duint8 max = size / 4;
|
||||
duint32 secMask = 0x4164536b ^ offset;
|
||||
duint32* pHdr = (duint32*)buf;
|
||||
for (duint8 j = 0; j < max; j++)
|
||||
*pHdr++ ^= secMask;
|
||||
}*/
|
||||
|
||||
duint32 dwgCompressor::litLength21(duint8 *cbuf, duint8 oc, duint32 *si){
|
||||
|
||||
duint32 srcIndex=*si;
|
||||
|
||||
duint32 length = oc + 8;
|
||||
if (length == 0x17) {
|
||||
duint32 n = cbuf[srcIndex++];
|
||||
length += n;
|
||||
if (n == 0xff) {
|
||||
do {
|
||||
n = cbuf[srcIndex++];
|
||||
n |= static_cast<duint32>(cbuf[srcIndex++] << 8);
|
||||
length += n;
|
||||
} while (n == 0xffff);
|
||||
}
|
||||
}
|
||||
|
||||
*si = srcIndex;
|
||||
return length;
|
||||
}
|
||||
|
||||
void dwgCompressor::decompress21(duint8 *cbuf, duint8 *dbuf, duint32 csize, duint32 dsize){
|
||||
duint32 srcIndex=0;
|
||||
duint32 dstIndex=0;
|
||||
duint32 length=0;
|
||||
duint32 sourceOffset;
|
||||
duint8 opCode;
|
||||
|
||||
opCode = cbuf[srcIndex++];
|
||||
if ((opCode >> 4) == 2){
|
||||
srcIndex = srcIndex +2;
|
||||
length = cbuf[srcIndex++] & 0x07;
|
||||
}
|
||||
|
||||
while (srcIndex < csize && (dstIndex < dsize+1)){//dstIndex < dsize to prevent crash more robust are needed
|
||||
if (length == 0)
|
||||
length = litLength21(cbuf, opCode, &srcIndex);
|
||||
copyCompBytes21(cbuf, dbuf, length, srcIndex, dstIndex);
|
||||
srcIndex += length;
|
||||
dstIndex += length;
|
||||
if (dstIndex >=dsize) break; //check if last chunk are compresed & terminate
|
||||
|
||||
length = 0;
|
||||
opCode = cbuf[srcIndex++];
|
||||
readInstructions21(cbuf, &srcIndex, &opCode, &sourceOffset, &length);
|
||||
while (true) {
|
||||
//prevent crash with corrupted data
|
||||
if (sourceOffset > dstIndex){
|
||||
DRW_DBG("\nWARNING dwgCompressor::decompress21 => sourceOffset> dstIndex.\n");
|
||||
DRW_DBG("csize = "); DRW_DBG(csize); DRW_DBG(" srcIndex = "); DRW_DBG(srcIndex);
|
||||
DRW_DBG("\ndsize = "); DRW_DBG(dsize); DRW_DBG(" dstIndex = "); DRW_DBG(dstIndex);
|
||||
sourceOffset = dstIndex;
|
||||
}
|
||||
//prevent crash with corrupted data
|
||||
if (length > dsize - dstIndex){
|
||||
DRW_DBG("\nWARNING dwgCompressor::decompress21 => length > dsize - dstIndex.\n");
|
||||
DRW_DBG("csize = "); DRW_DBG(csize); DRW_DBG(" srcIndex = "); DRW_DBG(srcIndex);
|
||||
DRW_DBG("\ndsize = "); DRW_DBG(dsize); DRW_DBG(" dstIndex = "); DRW_DBG(dstIndex);
|
||||
length = dsize - dstIndex;
|
||||
srcIndex = csize;//force exit
|
||||
}
|
||||
sourceOffset = dstIndex-sourceOffset;
|
||||
for (duint32 i=0; i< length; i++)
|
||||
dbuf[dstIndex++] = dbuf[sourceOffset+i];
|
||||
|
||||
length = opCode & 7;
|
||||
if ((length != 0) || (srcIndex >= csize)) {
|
||||
break;
|
||||
}
|
||||
opCode = cbuf[srcIndex++];
|
||||
if ((opCode >> 4) == 0) {
|
||||
break;
|
||||
}
|
||||
if ((opCode >> 4) == 15) {
|
||||
opCode &= 15;
|
||||
}
|
||||
readInstructions21(cbuf, &srcIndex, &opCode, &sourceOffset, &length);
|
||||
}
|
||||
}
|
||||
DRW_DBG("\ncsize = "); DRW_DBG(csize); DRW_DBG(" srcIndex = "); DRW_DBG(srcIndex);
|
||||
DRW_DBG("\ndsize = "); DRW_DBG(dsize); DRW_DBG(" dstIndex = "); DRW_DBG(dstIndex);DRW_DBG("\n");
|
||||
}
|
||||
|
||||
void dwgCompressor::readInstructions21(duint8 *cbuf, duint32 *si, duint8 *oc, duint32 *so, duint32 *l){
|
||||
duint32 length;
|
||||
duint32 srcIndex = *si;
|
||||
duint32 sourceOffset;
|
||||
unsigned char opCode = *oc;
|
||||
switch ((opCode >> 4)) {
|
||||
case 0:
|
||||
length = (opCode & 0xf) + 0x13;
|
||||
sourceOffset = cbuf[srcIndex++];
|
||||
opCode = cbuf[srcIndex++];
|
||||
length = ((opCode >> 3) & 0x10) + length;
|
||||
sourceOffset = ((opCode & 0x78) << 5) + 1 + sourceOffset;
|
||||
break;
|
||||
case 1:
|
||||
length = (opCode & 0xf) + 3;
|
||||
sourceOffset = cbuf[srcIndex++];
|
||||
opCode = cbuf[srcIndex++];
|
||||
sourceOffset = ((opCode & 0xf8) << 5) + 1 + sourceOffset;
|
||||
break;
|
||||
case 2:
|
||||
sourceOffset = cbuf[srcIndex++];
|
||||
sourceOffset = ((cbuf[srcIndex++] << 8) & 0xff00) | sourceOffset;
|
||||
length = opCode & 7;
|
||||
if ((opCode & 8) == 0) {
|
||||
opCode = cbuf[srcIndex++];
|
||||
length = (opCode & 0xf8) + length;
|
||||
} else {
|
||||
sourceOffset++;
|
||||
length = (cbuf[srcIndex++] << 3) + length;
|
||||
opCode = cbuf[srcIndex++];
|
||||
length = (((opCode & 0xf8) << 8) + length) + 0x100;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
length = opCode >> 4;
|
||||
sourceOffset = opCode & 15;
|
||||
opCode = cbuf[srcIndex++];
|
||||
sourceOffset = (((opCode & 0xf8) << 1) + sourceOffset) + 1;
|
||||
break;
|
||||
}
|
||||
*oc = opCode;
|
||||
*si = srcIndex;
|
||||
*so = sourceOffset;
|
||||
*l = length;
|
||||
}
|
||||
|
||||
|
||||
void dwgCompressor::copyCompBytes21(duint8 *cbuf, duint8 *dbuf, duint32 l, duint32 si, duint32 di){
|
||||
duint32 length =l;
|
||||
duint32 dix = di;
|
||||
duint32 six = si;
|
||||
|
||||
while (length > 31){
|
||||
//in doc: 16-31, 0-15
|
||||
for (duint32 i = six+24; i<six+32; i++)
|
||||
dbuf[dix++] = cbuf[i];
|
||||
for (duint32 i = six+16; i<six+24; i++)
|
||||
dbuf[dix++] = cbuf[i];
|
||||
for (duint32 i = six+8; i<six+16; i++)
|
||||
dbuf[dix++] = cbuf[i];
|
||||
for (duint32 i = six; i<six+8; i++)
|
||||
dbuf[dix++] = cbuf[i];
|
||||
six = six + 32;
|
||||
length = length -32;
|
||||
}
|
||||
|
||||
switch (length) {
|
||||
case 0:
|
||||
break;
|
||||
case 1: //Ok
|
||||
dbuf[dix] = cbuf[six];
|
||||
break;
|
||||
case 2: //Ok
|
||||
dbuf[dix++] = cbuf[six+1];
|
||||
dbuf[dix] = cbuf[six];
|
||||
break;
|
||||
case 3: //Ok
|
||||
dbuf[dix++] = cbuf[six+2];
|
||||
dbuf[dix++] = cbuf[six+1];
|
||||
dbuf[dix] = cbuf[six];
|
||||
break;
|
||||
case 4: //Ok
|
||||
for (int i = 0; i<4;i++) //RLZ is OK, or are inverse?, OK
|
||||
dbuf[dix++] = cbuf[six++];
|
||||
break;
|
||||
case 5: //Ok
|
||||
dbuf[dix++] = cbuf[six+4];
|
||||
for (int i = 0; i<4;i++)
|
||||
dbuf[dix++] = cbuf[six++];
|
||||
break;
|
||||
case 6: //Ok
|
||||
dbuf[dix++] = cbuf[six+5];
|
||||
for (int i = 1; i<5;i++)
|
||||
dbuf[dix++] = cbuf[six+i];
|
||||
dbuf[dix] = cbuf[six];
|
||||
break;
|
||||
case 7:
|
||||
//in doc: six+5, six+6, 1-5, six+0
|
||||
dbuf[dix++] = cbuf[six+6];
|
||||
dbuf[dix++] = cbuf[six+5];
|
||||
for (int i = 1; i<5;i++)
|
||||
dbuf[dix++] = cbuf[six+i];
|
||||
dbuf[dix] = cbuf[six];
|
||||
case 8: //Ok
|
||||
for (int i = 0; i<8;i++) //RLZ 4[0],4[4] or 4[4],4[0]
|
||||
dbuf[dix++] = cbuf[six++];
|
||||
break;
|
||||
case 9: //Ok
|
||||
dbuf[dix++] = cbuf[six+8];
|
||||
for (int i = 0; i<8;i++)
|
||||
dbuf[dix++] = cbuf[six++];
|
||||
break;
|
||||
case 10: //Ok
|
||||
dbuf[dix++] = cbuf[six+9];
|
||||
for (int i = 1; i<9;i++)
|
||||
dbuf[dix++] = cbuf[six+i];
|
||||
dbuf[dix] = cbuf[six];
|
||||
break;
|
||||
case 11:
|
||||
//in doc: six+9, six+10, 1-9, six+0
|
||||
dbuf[dix++] = cbuf[six+10];
|
||||
dbuf[dix++] = cbuf[six+9];
|
||||
for (int i = 1; i<9;i++)
|
||||
dbuf[dix++] = cbuf[six+i];
|
||||
dbuf[dix] = cbuf[six];
|
||||
break;
|
||||
case 12: //Ok
|
||||
for (int i = 8; i<12;i++)
|
||||
dbuf[dix++] = cbuf[six+i];
|
||||
for (int i = 0; i<8;i++)
|
||||
dbuf[dix++] = cbuf[six++];
|
||||
break;
|
||||
case 13: //Ok
|
||||
dbuf[dix++] = cbuf[six+12];
|
||||
for (int i = 8; i<12;i++)
|
||||
dbuf[dix++] = cbuf[six+i];
|
||||
for (int i = 0; i<8;i++)
|
||||
dbuf[dix++] = cbuf[six++];
|
||||
break;
|
||||
case 14: //Ok
|
||||
dbuf[dix++] = cbuf[six+13];
|
||||
for (int i = 9; i<13; i++)
|
||||
dbuf[dix++] = cbuf[six+i];
|
||||
for (int i = 1; i<9; i++)
|
||||
dbuf[dix++] = cbuf[six+i];
|
||||
dbuf[dix] = cbuf[six];
|
||||
break;
|
||||
case 15:
|
||||
//in doc: six+13, six+14, 9-12, 1-8, six+0
|
||||
dbuf[dix++] = cbuf[six+14];
|
||||
dbuf[dix++] = cbuf[six+13];
|
||||
for (int i = 9; i<13; i++)
|
||||
dbuf[dix++] = cbuf[six+i];
|
||||
for (int i = 1; i<9; i++)
|
||||
dbuf[dix++] = cbuf[six+i];
|
||||
dbuf[dix] = cbuf[six];
|
||||
break;
|
||||
case 16: //Ok
|
||||
for (int i = 8; i<16;i++)
|
||||
dbuf[dix++] = cbuf[six+i];
|
||||
for (int i = 0; i<8;i++)
|
||||
dbuf[dix++] = cbuf[six++];
|
||||
break;
|
||||
case 17: //Seems Ok
|
||||
for (int i = 9; i<17;i++)
|
||||
dbuf[dix++] = cbuf[six+i];
|
||||
dbuf[dix++] = cbuf[six+8];
|
||||
for (int i = 0; i<8;i++)
|
||||
dbuf[dix++] = cbuf[six++];
|
||||
break;
|
||||
case 18:
|
||||
//in doc: six+17, 1-16, six+0
|
||||
dbuf[dix++] = cbuf[six+17];
|
||||
for (int i = 9; i<17;i++)
|
||||
dbuf[dix++] = cbuf[six+i];
|
||||
for (int i = 1; i<9;i++)
|
||||
dbuf[dix++] = cbuf[six+i];
|
||||
dbuf[dix] = cbuf[six];
|
||||
break;
|
||||
case 19:
|
||||
//in doc: 16-18, 0-15
|
||||
dbuf[dix++] = cbuf[six+18];
|
||||
dbuf[dix++] = cbuf[six+17];
|
||||
dbuf[dix++] = cbuf[six+16];
|
||||
for (int i = 8; i<16;i++)
|
||||
dbuf[dix++] = cbuf[six+i];
|
||||
for (int i = 0; i<8;i++)
|
||||
dbuf[dix++] = cbuf[six++];
|
||||
break;
|
||||
case 20:
|
||||
//in doc: 16-19, 0-15
|
||||
for (int i = 16; i<20;i++)
|
||||
dbuf[dix++] = cbuf[six+i];
|
||||
for (int i = 8; i<16;i++)
|
||||
dbuf[dix++] = cbuf[six+i];
|
||||
for (int i = 0; i<8;i++)
|
||||
dbuf[dix++] = cbuf[six++];
|
||||
break;
|
||||
case 21:
|
||||
//in doc: six+20, 16-19, 0-15
|
||||
dbuf[dix++] = cbuf[six+20];
|
||||
for (int i = 16; i<20;i++)
|
||||
dbuf[dix++] = cbuf[six+i];
|
||||
for (int i = 8; i<16;i++)
|
||||
dbuf[dix++] = cbuf[six+i];
|
||||
for (int i = 0; i<8;i++)
|
||||
dbuf[dix++] = cbuf[six+i];
|
||||
break;
|
||||
case 22:
|
||||
//in doc: six+20, six+21, 16-19, 0-15
|
||||
dbuf[dix++] = cbuf[six+21];
|
||||
dbuf[dix++] = cbuf[six+20];
|
||||
for (int i = 16; i<20;i++)
|
||||
dbuf[dix++] = cbuf[six+i];
|
||||
for (int i = 8; i<16;i++)
|
||||
dbuf[dix++] = cbuf[six+i];
|
||||
for (int i = 0; i<8;i++)
|
||||
dbuf[dix++] = cbuf[six++];
|
||||
break;
|
||||
case 23:
|
||||
//in doc: six+20, six+21, six+22, 16-19, 0-15
|
||||
dbuf[dix++] = cbuf[six+22];
|
||||
dbuf[dix++] = cbuf[six+21];
|
||||
dbuf[dix++] = cbuf[six+20];
|
||||
for (int i = 16; i<20;i++)
|
||||
dbuf[dix++] = cbuf[six+i];
|
||||
for (int i = 8; i<16;i++)
|
||||
dbuf[dix++] = cbuf[six+i];
|
||||
for (int i = 0; i<8;i++)
|
||||
dbuf[dix++] = cbuf[six+i];
|
||||
break;
|
||||
case 24:
|
||||
//in doc: 16-23, 0-15
|
||||
for (int i = 16; i<24;i++)
|
||||
dbuf[dix++] = cbuf[six+i];
|
||||
for (int i = 8; i<16;i++)
|
||||
dbuf[dix++] = cbuf[six+i];
|
||||
for (int i = 0; i<8; i++)
|
||||
dbuf[dix++] = cbuf[six++];
|
||||
break;
|
||||
case 25:
|
||||
//in doc: 17-24, six+16, 0-15
|
||||
for (int i = 17; i<25;i++)
|
||||
dbuf[dix++] = cbuf[six+i];
|
||||
dbuf[dix++] = cbuf[six+16];
|
||||
for (int i = 8; i<16; i++)
|
||||
dbuf[dix++] = cbuf[six+i];
|
||||
for (int i = 0; i<8; i++)
|
||||
dbuf[dix++] = cbuf[six++];
|
||||
break;
|
||||
case 26:
|
||||
//in doc: six+25, 17-24, six+16, 0-15
|
||||
dbuf[dix++] = cbuf[six+25];
|
||||
for (int i = 17; i<25;i++)
|
||||
dbuf[dix++] = cbuf[six+i];
|
||||
dbuf[dix++] = cbuf[six+16];
|
||||
for (int i = 8; i<16;i++)
|
||||
dbuf[dix++] = cbuf[six+i];
|
||||
for (int i = 0; i<8; i++)
|
||||
dbuf[dix++] = cbuf[six++];
|
||||
break;
|
||||
case 27:
|
||||
//in doc: six+25, six+26, 17-24, six+16, 0-15
|
||||
dbuf[dix++] = cbuf[six+26];
|
||||
dbuf[dix++] = cbuf[six+25];
|
||||
for (int i = 17; i<25;i++)
|
||||
dbuf[dix++] = cbuf[six+i];
|
||||
dbuf[dix++] = cbuf[six+16];
|
||||
for (int i = 8; i<16;i++)
|
||||
dbuf[dix++] = cbuf[six+i];
|
||||
for (int i = 0; i<8; i++)
|
||||
dbuf[dix++] = cbuf[six++];
|
||||
break;
|
||||
case 28:
|
||||
//in doc: 24-27, 16-23, 0-15
|
||||
for (int i = 24; i<28; i++)
|
||||
dbuf[dix++] = cbuf[six+i];
|
||||
for (int i = 16; i<24;i++)
|
||||
dbuf[dix++] = cbuf[six+i];
|
||||
for (int i = 8; i<16; i++)
|
||||
dbuf[dix++] = cbuf[six+i];
|
||||
for (int i = 0; i<8; i++)
|
||||
dbuf[dix++] = cbuf[six++];
|
||||
break;
|
||||
case 29:
|
||||
//in doc: six+28, 24-27, 16-23, 0-15
|
||||
dbuf[dix++] = cbuf[six+28];
|
||||
for (int i = 24; i<28; i++)
|
||||
dbuf[dix++] = cbuf[six+i];
|
||||
for (int i = 16; i<24;i++)
|
||||
dbuf[dix++] = cbuf[six+i];
|
||||
for (int i = 8; i<16;i++)
|
||||
dbuf[dix++] = cbuf[six+i];
|
||||
for (int i = 0; i<8; i++)
|
||||
dbuf[dix++] = cbuf[six++];
|
||||
break;
|
||||
case 30:
|
||||
//in doc: six+28, six+29, 24-27, 16-23, 0-15
|
||||
dbuf[dix++] = cbuf[six+29];
|
||||
dbuf[dix++] = cbuf[six+28];
|
||||
for (int i = 24; i<28; i++)
|
||||
dbuf[dix++] = cbuf[six+i];
|
||||
for (int i = 16; i<24;i++)
|
||||
dbuf[dix++] = cbuf[six+i];
|
||||
for (int i = 8; i<16;i++)
|
||||
dbuf[dix++] = cbuf[six+i];
|
||||
for (int i = 0; i<8; i++)
|
||||
dbuf[dix++] = cbuf[six++];
|
||||
break;
|
||||
case 31:
|
||||
//in doc: six+30, 26-29, 18-25, 2-17, 0-1
|
||||
dbuf[dix++] = cbuf[six+30];
|
||||
for (int i = 26; i<30;i++)
|
||||
dbuf[dix++] = cbuf[six+i];
|
||||
for (int i = 18; i<26;i++)
|
||||
dbuf[dix++] = cbuf[six+i];
|
||||
/* for (int i = 2; i<18; i++)
|
||||
dbuf[dix++] = cbuf[six+i];*/
|
||||
for (int i = 10; i<18; i++)
|
||||
dbuf[dix++] = cbuf[six+i];
|
||||
for (int i = 2; i<10; i++)
|
||||
dbuf[dix++] = cbuf[six+i];
|
||||
dbuf[dix++] = cbuf[six+1];
|
||||
dbuf[dix] = cbuf[six];
|
||||
break;
|
||||
default:
|
||||
DRW_DBG("WARNING dwgCompressor::copyCompBytes21, bad output.\n");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
secEnum::DWGSection secEnum::getEnum(const std::string &nameSec){
|
||||
//TODO: complete it
|
||||
if (nameSec=="AcDb:Header"){
|
||||
return HEADER;
|
||||
} else if (nameSec=="AcDb:Classes"){
|
||||
return CLASSES;
|
||||
} else if (nameSec=="AcDb:SummaryInfo"){
|
||||
return SUMARYINFO;
|
||||
} else if (nameSec=="AcDb:Preview"){
|
||||
return PREVIEW;
|
||||
} else if (nameSec=="AcDb:VBAProject"){
|
||||
return VBAPROY;
|
||||
} else if (nameSec=="AcDb:AppInfo"){
|
||||
return APPINFO;
|
||||
} else if (nameSec=="AcDb:FileDepList"){
|
||||
return FILEDEP;
|
||||
} else if (nameSec=="AcDb:RevHistory"){
|
||||
return REVHISTORY;
|
||||
} else if (nameSec=="AcDb:Security"){
|
||||
return SECURITY;
|
||||
} else if (nameSec=="AcDb:AcDbObjects"){
|
||||
return OBJECTS;
|
||||
} else if (nameSec=="AcDb:ObjFreeSpace"){
|
||||
return OBJFREESPACE;
|
||||
} else if (nameSec=="AcDb:Template"){
|
||||
return TEMPLATE;
|
||||
} else if (nameSec=="AcDb:Handles"){
|
||||
return HANDLES;
|
||||
} else if (nameSec=="AcDb:AcDsPrototype_1b"){
|
||||
return PROTOTYPE;
|
||||
} else if (nameSec=="AcDb:AuxHeader"){
|
||||
return AUXHEADER;
|
||||
} else if (nameSec=="AcDb:Signature"){
|
||||
return SIGNATURE;
|
||||
} else if (nameSec=="AcDb:AppInfoHistory"){ //in ac1021
|
||||
return APPINFOHISTORY;
|
||||
// } else if (nameSec=="AcDb:Extended Entity Data"){
|
||||
// return EXTEDATA;
|
||||
// } else if (nameSec=="AcDb:PROXY ENTITY GRAPHICS"){
|
||||
// return PROXYGRAPHICS;
|
||||
}
|
||||
return UNKNOWNS;
|
||||
}
|
|
@ -1,99 +0,0 @@
|
|||
/******************************************************************************
|
||||
** libDXFrw - Library to read/write DXF files (ascii & binary) **
|
||||
** **
|
||||
** Copyright (C) 2011-2015 José F. Soriano, rallazz@gmail.com **
|
||||
** **
|
||||
** This library is free software, licensed under the terms of the GNU **
|
||||
** General Public License as published by the Free Software Foundation, **
|
||||
** either version 2 of the License, or (at your option) any later version. **
|
||||
** You should have received a copy of the GNU General Public License **
|
||||
** along with this program. If not, see <http://www.gnu.org/licenses/>. **
|
||||
******************************************************************************/
|
||||
|
||||
#ifndef DWGUTIL_H
|
||||
#define DWGUTIL_H
|
||||
|
||||
#include "../drw_base.h"
|
||||
|
||||
namespace DRW {
|
||||
std::string toHexStr(int n);
|
||||
}
|
||||
|
||||
class dwgRSCodec {
|
||||
public:
|
||||
dwgRSCodec(){}
|
||||
~dwgRSCodec(){}
|
||||
static void decode239I(duint8 *in, duint8 *out, duint32 blk);
|
||||
static void decode251I(duint8 *in, duint8 *out, duint32 blk);
|
||||
};
|
||||
|
||||
class dwgCompressor {
|
||||
public:
|
||||
dwgCompressor()
|
||||
: bufC(),
|
||||
bufD(),
|
||||
sizeC(),
|
||||
sizeD(),
|
||||
pos(),
|
||||
rpos()
|
||||
{}
|
||||
|
||||
~dwgCompressor() = default;
|
||||
|
||||
void decompress18(duint8 *cbuf, duint8 *dbuf, duint32 csize, duint32 dsize);
|
||||
static void decrypt18Hdr(duint8 *buf, duint32 size, duint32 offset);
|
||||
// static void decrypt18Data(duint8 *buf, duint32 size, duint32 offset);
|
||||
static void decompress21(duint8 *cbuf, duint8 *dbuf, duint32 csize, duint32 dsize);
|
||||
|
||||
private:
|
||||
duint32 litLength18();
|
||||
static duint32 litLength21(duint8 *cbuf, duint8 oc, duint32 *si);
|
||||
static void copyCompBytes21(duint8 *cbuf, duint8 *dbuf, duint32 l, duint32 si, duint32 di);
|
||||
static void readInstructions21(duint8 *cbuf, duint32 *si, duint8 *oc, duint32 *so, duint32 *l);
|
||||
|
||||
duint32 longCompressionOffset();
|
||||
duint32 long20CompressionOffset();
|
||||
duint32 twoByteOffset(duint32 *ll);
|
||||
|
||||
duint8 *bufC;
|
||||
duint8 *bufD;
|
||||
duint32 sizeC;
|
||||
duint32 sizeD;
|
||||
duint32 pos;
|
||||
duint32 rpos;
|
||||
|
||||
};
|
||||
|
||||
class secEnum {
|
||||
public:
|
||||
enum DWGSection {
|
||||
UNKNOWNS, /*!< UNKNOWN section. */
|
||||
FILEHEADER, /*!< File Header (in R3-R15*/
|
||||
HEADER, /*!< AcDb:Header */
|
||||
CLASSES, /*!< AcDb:Classes */
|
||||
SUMARYINFO, /*!< AcDb:SummaryInfo */
|
||||
PREVIEW, /*!< AcDb:Preview */
|
||||
VBAPROY, /*!< AcDb:VBAProject */
|
||||
APPINFO, /*!< AcDb:AppInfo */
|
||||
FILEDEP, /*!< AcDb:FileDepList */
|
||||
REVHISTORY, /*!< AcDb:RevHistory */
|
||||
SECURITY, /*!< AcDb:Security */
|
||||
OBJECTS, /*!< AcDb:AcDbObjects */
|
||||
OBJFREESPACE, /*!< AcDb:ObjFreeSpace */
|
||||
TEMPLATE, /*!< AcDb:Template */
|
||||
HANDLES, /*!< AcDb:Handles */
|
||||
PROTOTYPE, /*!< AcDb:AcDsPrototype_1b */
|
||||
AUXHEADER, /*!< AcDb:AuxHeader, in (R13-R15) second file header */
|
||||
SIGNATURE, /*!< AcDb:Signature */
|
||||
APPINFOHISTORY, /*!< AcDb:AppInfoHistory (in ac1021 may be a renamed section?*/
|
||||
EXTEDATA, /*!< Extended Entity Data */
|
||||
PROXYGRAPHICS /*!< PROXY ENTITY GRAPHICS */
|
||||
};
|
||||
|
||||
secEnum(){}
|
||||
~secEnum(){}
|
||||
|
||||
static DWGSection getEnum(const std::__cxx11::string &nameSec);
|
||||
};
|
||||
|
||||
#endif // DWGUTIL_H
|
|
@ -1,399 +0,0 @@
|
|||
/******************************************************************************
|
||||
** libDXFrw - Library to read/write DXF files (ascii & binary) **
|
||||
** **
|
||||
** Copyright (C) 2011-2014 J.F. Soriano (Rallaz), rallazz@gmail.com **
|
||||
** **
|
||||
** This library is free software, licensed under the terms of the GNU **
|
||||
** General Public License as published by the Free Software Foundation, **
|
||||
** either version 2 of the License, or (at your option) any later version. **
|
||||
** You should have received a copy of the GNU General Public License **
|
||||
** along with this program. If not, see <http://www.gnu.org/licenses/>. **
|
||||
******************************************************************************/
|
||||
|
||||
/**
|
||||
* Reed-Solomon codec
|
||||
* Reed Solomon code lifted from encoder/decoder for Reed-Solomon written by Simon Rockliff
|
||||
*
|
||||
* Original code:
|
||||
* This program may be freely modified and/or given to whoever wants it.
|
||||
* A condition of such distribution is that the author's contribution be
|
||||
* acknowledged by his name being left in the comments heading the program,
|
||||
* however no responsibility is accepted for any financial or other loss which
|
||||
* may result from some unforseen errors or malfunctioning of the program
|
||||
* during use.
|
||||
* Simon Rockliff, 26th June 1991
|
||||
*/
|
||||
|
||||
|
||||
#include "rscodec.h"
|
||||
#include <new> // std::nothrow
|
||||
#include <fstream>
|
||||
|
||||
RScodec::RScodec(unsigned int pp, int mm, int tt)
|
||||
: mm(mm),
|
||||
tt(tt),
|
||||
nn((1<<mm) -1), //mm==8 nn=255
|
||||
kk(nn -(tt*2)),
|
||||
gg(new (std::nothrow) int[nn-kk+1]),
|
||||
isOk(true),
|
||||
index_of(new (std::nothrow) unsigned int[nn+1]),
|
||||
alpha_to(new (std::nothrow) int[nn+1])
|
||||
{
|
||||
RSgenerate_gf(pp);
|
||||
/* compute the generator polynomial for this RS code */
|
||||
RSgen_poly();
|
||||
}
|
||||
|
||||
RScodec::~RScodec() {
|
||||
delete[] alpha_to;
|
||||
delete[] index_of;
|
||||
delete[] gg;
|
||||
}
|
||||
|
||||
|
||||
/* generate GF(2^mm) from the irreducible polynomial p(X) in pp[0]..pp[mm]
|
||||
lookup tables: index->polynomial form alpha_to[] contains j=alpha**i;
|
||||
polynomial form -> index form index_of[j=alpha**i] = i
|
||||
alpha=2 is the primitive element of GF(2^mm)
|
||||
*/
|
||||
void RScodec::RSgenerate_gf(unsigned int pp) {
|
||||
int i, mask ;
|
||||
|
||||
mask = 1 ;
|
||||
alpha_to[mm] = 0 ;
|
||||
for (i=0; i<mm; i++) {
|
||||
alpha_to[i] = mask ;
|
||||
index_of[alpha_to[i]] = i ;
|
||||
int pb = (pp >>(mm-1-i)) & 1;
|
||||
if (pb!=0) {
|
||||
alpha_to[mm] ^= mask;
|
||||
}
|
||||
mask <<= 1 ;
|
||||
}
|
||||
index_of[alpha_to[mm]] = mm ;
|
||||
mask >>= 1 ;
|
||||
for (i=mm+1; i<nn; i++) {
|
||||
if (alpha_to[i-1] >= mask) {
|
||||
alpha_to[i] = alpha_to[mm] ^ ((alpha_to[i-1]^mask)<<1) ;
|
||||
} else alpha_to[i] = alpha_to[i-1]<<1 ;
|
||||
index_of[alpha_to[i]] = i ;
|
||||
}
|
||||
index_of[0] = -1 ;
|
||||
}
|
||||
|
||||
|
||||
/* Obtain the generator polynomial of the tt-error correcting, length
|
||||
nn=(2^mm -1) Reed Solomon code from the product of (X+alpha**i), i=1..2*tt
|
||||
*/
|
||||
void RScodec::RSgen_poly() {
|
||||
int i,j ;
|
||||
int tmp;
|
||||
int bb = nn-kk;; //nn-kk length of parity data
|
||||
|
||||
gg[0] = 2 ; /* primitive element alpha = 2 for GF(2**mm) */
|
||||
gg[1] = 1 ; /* g(x) = (X+alpha) initially */
|
||||
for (i=2; i<=bb; i++) {
|
||||
gg[i] = 1 ;
|
||||
for (j=i-1; j>0; j--)
|
||||
if (gg[j] != 0) {
|
||||
if (gg[j]<0) { isOk=false; return; }
|
||||
tmp = (index_of[gg[j]]+i)%nn;
|
||||
if (tmp<0) { isOk=false; return; }
|
||||
gg[j] = gg[j-1]^ alpha_to[tmp] ;
|
||||
} else {
|
||||
gg[j] = gg[j-1] ;
|
||||
}
|
||||
gg[0] = alpha_to[(index_of[gg[0]]+i)%nn] ; /* gg[0] can never be zero */
|
||||
}
|
||||
/* convert gg[] to index form for quicker encoding */
|
||||
for (i=0; i<=bb; i++) gg[i] = index_of[gg[i]] ;
|
||||
}
|
||||
|
||||
int RScodec::calcDecode(unsigned char* data, int* recd, int** elp, int* d, int* l, int* u_lu, int* s, int* root,
|
||||
int* loc, int* z, int* err, int* reg, int bb) const
|
||||
{
|
||||
if (!isOk) return -1;
|
||||
int count = 0;
|
||||
int syn_error = 0;
|
||||
int i, j, u, q;
|
||||
|
||||
// for (int i=0; i<nn; i++)
|
||||
// recd[i] = index_of[recd[i]] ; /* put recd[i] into index form */
|
||||
for (int i = 0, j = bb; i<kk; i++, j++)
|
||||
recd[j] = index_of[data[j]]; /* put data in recd[i] into index form */
|
||||
for (int i = kk, j = 0; i<nn; i++, j++)
|
||||
recd[j] = index_of[data[j]]; /* put data in recd[i] into index form */
|
||||
|
||||
/* first form the syndromes */
|
||||
for (i = 1; i <= bb; i++) {
|
||||
s[i] = 0;
|
||||
for (j = 0; j<nn; j++) {
|
||||
if (recd[j] != -1) {
|
||||
s[i] ^= alpha_to[(recd[j] + i*j) % nn]; /* recd[j] in index form */
|
||||
}
|
||||
}
|
||||
/* convert syndrome from polynomial form to index form */
|
||||
if (s[i] != 0) syn_error = 1; /* set flag if non-zero syndrome => error */
|
||||
s[i] = index_of[s[i]];
|
||||
}
|
||||
|
||||
if (!syn_error) { /* if no errors, ends */
|
||||
/* no non-zero syndromes => no errors: output is received codeword */
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* errors are present, try and correct */
|
||||
/* compute the error location polynomial via the Berlekamp iterative algorithm,
|
||||
following the terminology of Lin and Costello : d[u] is the 'mu'th
|
||||
discrepancy, where u='mu'+1 and 'mu' (the Greek letter!) is the step number
|
||||
ranging from -1 to 2*tt (see L&C), l[u] is the
|
||||
degree of the elp at that step, and u_l[u] is the difference between the
|
||||
step number and the degree of the elp.
|
||||
*/
|
||||
/* initialise table entries */
|
||||
d[0] = 0; /* index form */
|
||||
d[1] = s[1]; /* index form */
|
||||
elp[0][0] = 0; /* index form */
|
||||
elp[1][0] = 1; /* polynomial form */
|
||||
for (i = 1; i<bb; i++) {
|
||||
elp[0][i] = -1; /* index form */
|
||||
elp[1][i] = 0; /* polynomial form */
|
||||
}
|
||||
l[0] = 0;
|
||||
l[1] = 0;
|
||||
u_lu[0] = -1;
|
||||
u_lu[1] = 0;
|
||||
u = 0;
|
||||
|
||||
do {
|
||||
u++;
|
||||
if (d[u] == -1) {
|
||||
l[u + 1] = l[u];
|
||||
for (i = 0; i <= l[u]; i++) {
|
||||
elp[u + 1][i] = elp[u][i];
|
||||
elp[u][i] = index_of[elp[u][i]];
|
||||
}
|
||||
}
|
||||
else {
|
||||
/* search for words with greatest u_lu[q] for which d[q]!=0 */
|
||||
q = u - 1;
|
||||
while ((d[q] == -1) && (q>0)) q--;
|
||||
/* have found first non-zero d[q] */
|
||||
if (q>0) {
|
||||
j = q;
|
||||
do {
|
||||
j--;
|
||||
if ((d[j] != -1) && (u_lu[q]<u_lu[j]))
|
||||
q = j;
|
||||
} while (j>0);
|
||||
}
|
||||
|
||||
/* have now found q such that d[u]!=0 and u_lu[q] is maximum */
|
||||
/* store degree of new elp polynomial */
|
||||
if (l[u]>l[q] + u - q) {
|
||||
l[u + 1] = l[u];
|
||||
}
|
||||
else {
|
||||
l[u + 1] = l[q] + u - q;
|
||||
}
|
||||
|
||||
/* form new elp(x) */
|
||||
for (i = 0; i<bb; i++) elp[u + 1][i] = 0;
|
||||
for (i = 0; i <= l[q]; i++){
|
||||
if (elp[q][i] != -1) {
|
||||
elp[u + 1][i + u - q] = alpha_to[(d[u] + nn - d[q] + elp[q][i]) % nn];
|
||||
}
|
||||
}
|
||||
for (i = 0; i <= l[u]; i++) {
|
||||
elp[u + 1][i] ^= elp[u][i];
|
||||
elp[u][i] = index_of[elp[u][i]]; /*convert old elp value to index*/
|
||||
}
|
||||
}
|
||||
u_lu[u + 1] = u - l[u + 1];
|
||||
|
||||
/* form (u+1)th discrepancy */
|
||||
if (u<bb){ /* no discrepancy computed on last iteration */
|
||||
if (s[u + 1] != -1) {
|
||||
d[u + 1] = alpha_to[s[u + 1]];
|
||||
}
|
||||
else {
|
||||
d[u + 1] = 0;
|
||||
}
|
||||
for (i = 1; i <= l[u + 1]; i++){
|
||||
if ((s[u + 1 - i] != -1) && (elp[u + 1][i] != 0)) {
|
||||
d[u + 1] ^= alpha_to[(s[u + 1 - i] + index_of[elp[u + 1][i]]) % nn];
|
||||
}
|
||||
}
|
||||
d[u + 1] = index_of[d[u + 1]]; /* put d[u+1] into index form */
|
||||
}
|
||||
} while ((u<bb) && (l[u + 1] <= tt));
|
||||
|
||||
u++;
|
||||
if (l[u]>tt) { /* elp has degree has degree >tt hence cannot solve */
|
||||
return -1; /* just output is received codeword as is */
|
||||
}
|
||||
|
||||
/* can correct error */
|
||||
/* put elp into index form */
|
||||
for (i = 0; i <= l[u]; i++) elp[u][i] = index_of[elp[u][i]];
|
||||
|
||||
/* find roots of the error location polynomial */
|
||||
for (i = 1; i <= l[u]; i++) {
|
||||
reg[i] = elp[u][i];
|
||||
}
|
||||
count = 0;
|
||||
for (i = 1; i <= nn; i++) {
|
||||
q = 1;
|
||||
for (j = 1; j <= l[u]; j++) {
|
||||
if (reg[j] != -1) {
|
||||
reg[j] = (reg[j] + j) % nn;
|
||||
q ^= alpha_to[reg[j]];
|
||||
}
|
||||
}
|
||||
if (!q) { /* store root and error location number indices */
|
||||
root[count] = i;
|
||||
loc[count] = nn - i;
|
||||
count++;
|
||||
}
|
||||
}
|
||||
|
||||
if (count != l[u]) { /* no. roots != degree of elp => >tt errors and cannot solve */
|
||||
return -1; /* just output is received codeword as is */
|
||||
}
|
||||
|
||||
/* no. roots = degree of elp hence <= tt errors */
|
||||
/* form polynomial z(x) */
|
||||
for (i = 1; i <= l[u]; i++) { /* Z[0] = 1 always - do not need */
|
||||
if ((s[i] != -1) && (elp[u][i] != -1)) {
|
||||
z[i] = alpha_to[s[i]] ^ alpha_to[elp[u][i]];
|
||||
}
|
||||
else if ((s[i] != -1) && (elp[u][i] == -1)) {
|
||||
z[i] = alpha_to[s[i]];
|
||||
}
|
||||
else if ((s[i] == -1) && (elp[u][i] != -1)) {
|
||||
z[i] = alpha_to[elp[u][i]];
|
||||
}
|
||||
else {
|
||||
z[i] = 0;
|
||||
}
|
||||
for (j = 1; j<i; j++) {
|
||||
if ((s[j] != -1) && (elp[u][i - j] != -1)) {
|
||||
z[i] ^= alpha_to[(elp[u][i - j] + s[j]) % nn];
|
||||
}
|
||||
}
|
||||
z[i] = index_of[z[i]]; /* put into index form */
|
||||
}
|
||||
|
||||
/* evaluate errors at locations given by error location numbers loc[i] */
|
||||
for (i = 0; i<nn; i++) err[i] = 0;
|
||||
for (i = 0; i<l[u]; i++) { /* compute numerator of error term first */
|
||||
err[loc[i]] = 1; /* accounts for z[0] */
|
||||
for (j = 1; j <= l[u]; j++) {
|
||||
if (z[j] != -1) {
|
||||
err[loc[i]] ^= alpha_to[(z[j] + j*root[i]) % nn];
|
||||
}
|
||||
}
|
||||
if (err[loc[i]] != 0) {
|
||||
err[loc[i]] = index_of[err[loc[i]]];
|
||||
q = 0; /* form denominator of error term */
|
||||
for (j = 0; j<l[u]; j++) {
|
||||
if (j != i) {
|
||||
q += index_of[1 ^ alpha_to[(loc[j] + root[i]) % nn]];
|
||||
}
|
||||
}
|
||||
q = q % nn;
|
||||
err[loc[i]] = alpha_to[(err[loc[i]] - q + nn) % nn];
|
||||
data[loc[i]] ^= static_cast<unsigned char>(err[loc[i]]);/*change errors by correct data, in polynomial form */
|
||||
}
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
||||
/** take the string of symbols in data[i], i=0..(k-1) and encode systematically
|
||||
to produce 2*tt parity symbols in bd[0]..bd[2*tt-1]
|
||||
data[] is input and bd[] is output in polynomial form.
|
||||
Encoding is done by using a feedback shift register with appropriate
|
||||
connections specified by the elements of gg[], which was generated above.
|
||||
Codeword is c(X) = data(X)*X**(nn-kk)+ b(X) */
|
||||
bool RScodec::encode(unsigned char *data, unsigned char *parity) const {
|
||||
if (!isOk) return false;
|
||||
int i,j ;
|
||||
unsigned char *idata = data;
|
||||
unsigned char *bd = parity;
|
||||
int bb = nn-kk;; //nn-kk length of parity data
|
||||
|
||||
for (i=0; i<bb; i++) bd[i] = 0 ;
|
||||
for (i=kk-1; i>=0; i--) {
|
||||
int feedback = index_of[idata[i]^bd[bb-1]] ;
|
||||
if (feedback != -1) {
|
||||
for (j=bb-1; j>0; j--)
|
||||
if (gg[j] != -1)
|
||||
bd[j] = static_cast<unsigned char>(bd[j-1]^alpha_to[(gg[j]+feedback)%nn]);
|
||||
else
|
||||
bd[j] = bd[j-1] ;
|
||||
bd[0] = static_cast<unsigned char>(alpha_to[(gg[0]+feedback)%nn]);
|
||||
} else {
|
||||
for (j=bb-1; j>0; j--)
|
||||
bd[j] = bd[j-1] ;
|
||||
bd[0] = 0 ;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/* assume we have received bits grouped into mm-bit symbols in recd[i],
|
||||
i=0..(nn-1), and recd[i] is index form (ie as powers of alpha).
|
||||
We first compute the 2*tt syndromes by substituting alpha**i into rec(X) and
|
||||
evaluating, storing the syndromes in s[i], i=1..2tt (leave s[0] zero) .
|
||||
Then we use the Berlekamp iteration to find the error location polynomial
|
||||
elp[i]. If the degree of the elp is >tt, we cannot correct all the errors
|
||||
and hence just put out the information symbols uncorrected. If the degree of
|
||||
elp is <=tt, we substitute alpha**i , i=1..n into the elp to get the roots,
|
||||
hence the inverse roots, the error location numbers. If the number of errors
|
||||
located does not equal the degree of the elp, we have more than tt errors
|
||||
and cannot correct them. Otherwise, we then solve for the error value at
|
||||
the error location and correct the error. The procedure is that found in
|
||||
Lin and Costello. For the cases where the number of errors is known to be too
|
||||
large to correct, the information symbols as received are output (the
|
||||
advantage of systematic encoding is that hopefully some of the information
|
||||
symbols will be okay and that if we are in luck, the errors are in the
|
||||
parity part of the transmitted codeword). Of course, these insoluble cases
|
||||
can be returned as error flags to the calling routine if desired. */
|
||||
/** return value: number of corrected errors or -1 if can't correct it */
|
||||
int RScodec::decode(unsigned char *data) const {
|
||||
if (!isOk) return -1;
|
||||
int bb = nn-kk;; //nn-kk length of parity data
|
||||
|
||||
int *recd = new (std::nothrow) int[nn];
|
||||
int **elp = new int*[bb + 2];
|
||||
for (int i = 0; i < bb + 2; ++i)
|
||||
elp[i] = new int[bb];
|
||||
int *d = new int[bb + 2];
|
||||
int *l = new int[bb + 2];
|
||||
int *u_lu = new int[bb + 2];
|
||||
int *s = new int[bb + 1];
|
||||
int *root = new int[tt];
|
||||
int *loc = new int[tt];
|
||||
int *z = new int[tt+1];
|
||||
int *err = new int[nn];
|
||||
int *reg = new int[tt + 1];
|
||||
|
||||
int res = calcDecode(data, recd, elp ,d ,l, u_lu, s, root, loc ,z, err, reg, bb);
|
||||
|
||||
delete[] recd;
|
||||
for (int i = 0; i < bb + 2; ++i)
|
||||
delete[] elp[i];
|
||||
delete[] elp;
|
||||
delete[] d;
|
||||
delete[] l;
|
||||
delete[] u_lu;
|
||||
delete[] s;
|
||||
delete[] root;
|
||||
delete[] loc;
|
||||
delete[] z;
|
||||
delete[] err;
|
||||
delete[] reg;
|
||||
|
||||
return res;
|
||||
}
|
|
@ -1,74 +0,0 @@
|
|||
/******************************************************************************
|
||||
** libDXFrw - Library to read/write DXF files (ascii & binary) **
|
||||
** **
|
||||
** Copyright (C) 2011-2014 J.F. Soriano (Rallaz), rallazz@gmail.com **
|
||||
** **
|
||||
** This library is free software, licensed under the terms of the GNU **
|
||||
** General Public License as published by the Free Software Foundation, **
|
||||
** either version 2 of the License, or (at your option) any later version. **
|
||||
** You should have received a copy of the GNU General Public License **
|
||||
** along with this program. If not, see <http://www.gnu.org/licenses/>. **
|
||||
******************************************************************************/
|
||||
|
||||
/**
|
||||
* Reed-Solomon codec
|
||||
* Reed Solomon code lifted from encoder/decoder for Reed-Solomon written by Simon Rockliff
|
||||
*
|
||||
* Original code:
|
||||
* This program may be freely modified and/or given to whoever wants it.
|
||||
* A condition of such distribution is that the author's contribution be
|
||||
* acknowledged by his name being left in the comments heading the program,
|
||||
* however no responsibility is accepted for any financial or other loss which
|
||||
* may result from some unforseen errors or malfunctioning of the program
|
||||
* during use.
|
||||
* Simon Rockliff, 26th June 1991
|
||||
*/
|
||||
|
||||
|
||||
|
||||
#ifndef RSCODEC_H
|
||||
#define RSCODEC_H
|
||||
|
||||
#include <QtGlobal>
|
||||
|
||||
/**
|
||||
mm: RS code over GF(2^4)
|
||||
nn: nn= (2^mm) - 1 length of codeword
|
||||
tt: number of errors that can be corrected
|
||||
kk: kk = nn-2*tt
|
||||
pp: irreducible polynomial coeffts, pp [mm] send as int
|
||||
*/
|
||||
class RScodec {
|
||||
public:
|
||||
RScodec(unsigned int pp, int mm, int tt);
|
||||
|
||||
~RScodec();
|
||||
// bool encode(int *data, int *parity);
|
||||
// int decode(int *recd);
|
||||
bool encode(unsigned char *data, unsigned char *parity) const;
|
||||
int decode(unsigned char *data) const;
|
||||
bool isOkey() const {return isOk;}
|
||||
const unsigned int* indexOf() const {return index_of;}
|
||||
const int* alphaTo() const {return alpha_to;}
|
||||
|
||||
private:
|
||||
void RSgenerate_gf(unsigned int pp);
|
||||
void RSgen_poly();
|
||||
int calcDecode(unsigned char* data, int* recd, int** elp, int* d, int* l, int* u_lu, int* s, int* root, int* loc,
|
||||
int* z, int* err, int* reg, int bb) const;
|
||||
|
||||
|
||||
private:
|
||||
Q_DISABLE_COPY(RScodec)
|
||||
int mm; //RS code over GF(2^4)
|
||||
int tt; //number of errors that can be corrected
|
||||
int nn; //(2^mm) - 1 length of codeword
|
||||
int kk; //nn-2*tt length of original data
|
||||
|
||||
int *gg;
|
||||
bool isOk;
|
||||
unsigned int *index_of;
|
||||
int *alpha_to;
|
||||
};
|
||||
|
||||
#endif // RSCODEC_H
|
|
@ -1,236 +0,0 @@
|
|||
/******************************************************************************
|
||||
** libDXFrw - Library to read/write DXF files (ascii & binary) **
|
||||
** **
|
||||
** Copyright (C) 2011-2015 José F. Soriano, rallazz@gmail.com **
|
||||
** **
|
||||
** This library is free software, licensed under the terms of the GNU **
|
||||
** General Public License as published by the Free Software Foundation, **
|
||||
** either version 2 of the License, or (at your option) any later version. **
|
||||
** You should have received a copy of the GNU General Public License **
|
||||
** along with this program. If not, see <http://www.gnu.org/licenses/>. **
|
||||
******************************************************************************/
|
||||
|
||||
|
||||
#include "libdwgr.h"
|
||||
#include <fstream>
|
||||
#include <algorithm>
|
||||
#include <sstream>
|
||||
#include "intern/drw_dbg.h"
|
||||
#include "intern/drw_textcodec.h"
|
||||
#include "intern/dwgreader.h"
|
||||
#include "intern/dwgreader15.h"
|
||||
#include "intern/dwgreader18.h"
|
||||
#include "intern/dwgreader21.h"
|
||||
#include "intern/dwgreader24.h"
|
||||
#include "intern/dwgreader27.h"
|
||||
|
||||
#define FIRSTHANDLE 48
|
||||
|
||||
/*enum sections {
|
||||
secUnknown,
|
||||
secHeader,
|
||||
secTables,
|
||||
secBlocks,
|
||||
secEntities,
|
||||
secObjects
|
||||
};*/
|
||||
|
||||
dwgR::dwgR()
|
||||
: version(DRW::UNKNOWNV),
|
||||
error(DRW::BAD_NONE),
|
||||
fileName(),
|
||||
applyExt(false),
|
||||
codePage(),
|
||||
iface(),
|
||||
reader(nullptr)
|
||||
{
|
||||
DRW_DBGSL(DRW_dbg::NONE);
|
||||
}
|
||||
|
||||
dwgR::~dwgR(){
|
||||
if (reader != nullptr)
|
||||
delete reader;
|
||||
|
||||
}
|
||||
|
||||
void dwgR::setDebug(DRW::DBG_LEVEL lvl){
|
||||
switch (lvl){
|
||||
case DRW::DEBUG:
|
||||
DRW_DBGSL(DRW_dbg::DEBUG);
|
||||
break;
|
||||
default:
|
||||
DRW_DBGSL(DRW_dbg::NONE);
|
||||
}
|
||||
}
|
||||
|
||||
/*reads metadata and loads image preview*/
|
||||
bool dwgR::getPreview(std::istream &stream){
|
||||
bool isOk = open(&stream);
|
||||
if (!isOk)
|
||||
return false;
|
||||
|
||||
isOk = reader->readMetaData();
|
||||
if (isOk) {
|
||||
isOk = reader->readPreview();
|
||||
} else
|
||||
error = DRW::BAD_READ_METADATA;
|
||||
|
||||
if (reader != nullptr) {
|
||||
delete reader;
|
||||
reader = nullptr;
|
||||
}
|
||||
return isOk;
|
||||
}
|
||||
|
||||
bool dwgR::read(std::istream &stream, DRW_Interface *interface_, bool ext){
|
||||
applyExt = ext;
|
||||
iface = interface_;
|
||||
|
||||
bool isOk = open(&stream);
|
||||
if (!isOk)
|
||||
return false;
|
||||
|
||||
isOk = reader->readMetaData();
|
||||
if (isOk) {
|
||||
isOk = reader->readFileHeader();
|
||||
if (isOk) {
|
||||
isOk = processDwg();
|
||||
} else
|
||||
error = DRW::BAD_READ_FILE_HEADER;
|
||||
} else
|
||||
error = DRW::BAD_READ_METADATA;
|
||||
|
||||
if (reader != nullptr) {
|
||||
delete reader;
|
||||
reader = nullptr;
|
||||
}
|
||||
|
||||
return isOk;
|
||||
}
|
||||
|
||||
bool dwgR::open(std::istream *stream){
|
||||
char line[7];
|
||||
stream->read (line, 6);
|
||||
line[6]='\0';
|
||||
DRW_DBG("dwgR::read 2\n");
|
||||
DRW_DBG("dwgR::read line version: ");
|
||||
DRW_DBG(line);
|
||||
DRW_DBG("\n");
|
||||
|
||||
if (strcmp(line, "AC1006") == 0)
|
||||
version = DRW::AC1006;
|
||||
else if (strcmp(line, "AC1009") == 0) {
|
||||
version = DRW::AC1009;
|
||||
// reader = new dwgReader09(&filestr, this);
|
||||
}else if (strcmp(line, "AC1012") == 0){
|
||||
version = DRW::AC1012;
|
||||
reader = new dwgReader15(stream, this);
|
||||
} else if (strcmp(line, "AC1014") == 0) {
|
||||
version = DRW::AC1014;
|
||||
reader = new dwgReader15(stream, this);
|
||||
} else if (strcmp(line, "AC1015") == 0) {
|
||||
version = DRW::AC1015;
|
||||
reader = new dwgReader15(stream, this);
|
||||
} else if (strcmp(line, "AC1018") == 0){
|
||||
version = DRW::AC1018;
|
||||
reader = new dwgReader18(stream, this);
|
||||
} else if (strcmp(line, "AC1021") == 0) {
|
||||
version = DRW::AC1021;
|
||||
reader = new dwgReader21(stream, this);
|
||||
} else if (strcmp(line, "AC1024") == 0) {
|
||||
version = DRW::AC1024;
|
||||
reader = new dwgReader24(stream, this);
|
||||
} else if (strcmp(line, "AC1027") == 0) {
|
||||
version = DRW::AC1027;
|
||||
reader = new dwgReader27(stream, this);
|
||||
} else
|
||||
version = DRW::UNKNOWNV;
|
||||
|
||||
if (reader == NULL) {
|
||||
error = DRW::BAD_VERSION;
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/********* Reader Process *********/
|
||||
|
||||
bool dwgR::processDwg() {
|
||||
DRW_DBG("dwgR::processDwg() start processing dwg\n");
|
||||
bool ret;
|
||||
bool ret2;
|
||||
DRW_Header hdr;
|
||||
ret = reader->readDwgHeader(hdr);
|
||||
if (!ret) {
|
||||
error = DRW::BAD_READ_HEADER;
|
||||
}
|
||||
|
||||
ret2 = reader->readDwgClasses();
|
||||
if (ret && !ret2) {
|
||||
error = DRW::BAD_READ_CLASSES;
|
||||
ret = ret2;
|
||||
}
|
||||
|
||||
ret2 = reader->readDwgHandles();
|
||||
if (ret && !ret2) {
|
||||
error = DRW::BAD_READ_HANDLES;
|
||||
ret = ret2;
|
||||
}
|
||||
|
||||
ret2 = reader->readDwgTables(hdr);
|
||||
if (ret && !ret2) {
|
||||
error = DRW::BAD_READ_TABLES;
|
||||
ret = ret2;
|
||||
}
|
||||
|
||||
iface->addHeader(&hdr);
|
||||
|
||||
for (std::map<duint32, DRW_LType*>::iterator it=reader->ltypemap.begin(); it!=reader->ltypemap.end(); ++it) {
|
||||
DRW_LType *lt = it->second;
|
||||
iface->addLType(const_cast<DRW_LType&>(*lt) );
|
||||
}
|
||||
for (std::map<duint32, DRW_Layer*>::iterator it=reader->layermap.begin(); it!=reader->layermap.end(); ++it) {
|
||||
DRW_Layer *ly = it->second;
|
||||
iface->addLayer(const_cast<DRW_Layer&>(*ly));
|
||||
}
|
||||
|
||||
for (std::map<duint32, DRW_Textstyle*>::iterator it=reader->stylemap.begin(); it!=reader->stylemap.end(); ++it) {
|
||||
DRW_Textstyle *ly = it->second;
|
||||
iface->addTextStyle(const_cast<DRW_Textstyle&>(*ly));
|
||||
}
|
||||
|
||||
for (std::map<duint32, DRW_Dimstyle*>::iterator it=reader->dimstylemap.begin(); it!=reader->dimstylemap.end(); ++it) {
|
||||
DRW_Dimstyle *ly = it->second;
|
||||
iface->addDimStyle(const_cast<DRW_Dimstyle&>(*ly));
|
||||
}
|
||||
|
||||
for (std::map<duint32, DRW_Vport*>::iterator it=reader->vportmap.begin(); it!=reader->vportmap.end(); ++it) {
|
||||
DRW_Vport *ly = it->second;
|
||||
iface->addVport(const_cast<DRW_Vport&>(*ly));
|
||||
}
|
||||
|
||||
for (std::map<duint32, DRW_AppId*>::iterator it=reader->appIdmap.begin(); it!=reader->appIdmap.end(); ++it) {
|
||||
DRW_AppId *ly = it->second;
|
||||
iface->addAppId(const_cast<DRW_AppId&>(*ly));
|
||||
}
|
||||
|
||||
ret2 = reader->readDwgBlocks(*iface);
|
||||
if (ret && !ret2) {
|
||||
error = DRW::BAD_READ_BLOCKS;
|
||||
ret = ret2;
|
||||
}
|
||||
|
||||
ret2 = reader->readDwgEntities(*iface);
|
||||
if (ret && !ret2) {
|
||||
error = DRW::BAD_READ_ENTITIES;
|
||||
ret = ret2;
|
||||
}
|
||||
|
||||
ret2 = reader->readDwgObjects(*iface);
|
||||
if (ret && !ret2) {
|
||||
error = DRW::BAD_READ_OBJECTS;
|
||||
ret = ret2;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
|
@ -1,51 +0,0 @@
|
|||
/******************************************************************************
|
||||
** libDXFrw - Library to read/write DXF files (ascii & binary) **
|
||||
** **
|
||||
** Copyright (C) 2011-2015 José F. Soriano, rallazz@gmail.com **
|
||||
** **
|
||||
** This library is free software, licensed under the terms of the GNU **
|
||||
** General Public License as published by the Free Software Foundation, **
|
||||
** either version 2 of the License, or (at your option) any later version. **
|
||||
** You should have received a copy of the GNU General Public License **
|
||||
** along with this program. If not, see <http://www.gnu.org/licenses/>. **
|
||||
******************************************************************************/
|
||||
|
||||
#ifndef LIBDWGR_H
|
||||
#define LIBDWGR_H
|
||||
|
||||
#include <string>
|
||||
#include <QtGlobal>
|
||||
#include "drw_entities.h"
|
||||
#include "drw_objects.h"
|
||||
#include "drw_classes.h"
|
||||
#include "drw_interface.h"
|
||||
|
||||
class dwgReader;
|
||||
|
||||
class dwgR {
|
||||
public:
|
||||
dwgR();
|
||||
~dwgR();
|
||||
//read: return true if all ok
|
||||
bool read(std::istream &stream, DRW_Interface *interface_, bool ext);
|
||||
bool getPreview(std::istream &stream);
|
||||
DRW::Version getVersion() const {return version;}
|
||||
DRW::error getError() const {return error;}
|
||||
static void setDebug(DRW::DBG_LEVEL lvl);
|
||||
|
||||
private:
|
||||
bool open(std::istream *stream);
|
||||
bool processDwg();
|
||||
private:
|
||||
Q_DISABLE_COPY(dwgR)
|
||||
DRW::Version version;
|
||||
DRW::error error;
|
||||
std::string fileName;
|
||||
bool applyExt; /*apply extrusion in entities to conv in 2D?*/
|
||||
std::string codePage;
|
||||
DRW_Interface *iface;
|
||||
dwgReader *reader;
|
||||
|
||||
};
|
||||
|
||||
#endif // LIBDWGR_H
|
|
@ -119,7 +119,6 @@ private:
|
|||
bool writeBlocks();
|
||||
bool writeObjects();
|
||||
bool writeExtData(const std::vector<DRW_Variant*> &ed);
|
||||
/*use version from dwgutil.h*/
|
||||
static std::string toHexStr(int n);//RLZ removeme
|
||||
|
||||
private:
|
||||
|
|
|
@ -6,9 +6,8 @@
|
|||
*
|
||||
* With libdxfrw you can read and write several parts of a dxf files.<p>
|
||||
* Dxf files can be written in assci and binary form, both are supported.<p>
|
||||
* Dwg support (only read) are work in progress.<p>
|
||||
*
|
||||
* the complete documentation and examples are pending to free time,
|
||||
* but to start see DRW_Interface, dxfRW & dwgR, clases
|
||||
* but to start see DRW_Interface, dxfRW clases
|
||||
*/
|
||||
|
||||
|
|
|
@ -6,22 +6,12 @@ SOURCES += \
|
|||
$$PWD/vdxfpaintdevice.cpp \
|
||||
$$PWD/libdxfrw/intern/drw_dbg.cpp \
|
||||
$$PWD/libdxfrw/intern/drw_textcodec.cpp \
|
||||
$$PWD/libdxfrw/intern/dwgbuffer.cpp \
|
||||
$$PWD/libdxfrw/intern/dwgreader.cpp \
|
||||
$$PWD/libdxfrw/intern/dwgreader15.cpp \
|
||||
$$PWD/libdxfrw/intern/dwgreader18.cpp \
|
||||
$$PWD/libdxfrw/intern/dwgreader21.cpp \
|
||||
$$PWD/libdxfrw/intern/dwgreader24.cpp \
|
||||
$$PWD/libdxfrw/intern/dwgreader27.cpp \
|
||||
$$PWD/libdxfrw/intern/dwgutil.cpp \
|
||||
$$PWD/libdxfrw/intern/dxfreader.cpp \
|
||||
$$PWD/libdxfrw/intern/dxfwriter.cpp \
|
||||
$$PWD/libdxfrw/intern/rscodec.cpp \
|
||||
$$PWD/libdxfrw/drw_classes.cpp \
|
||||
$$PWD/libdxfrw/drw_entities.cpp \
|
||||
$$PWD/libdxfrw/drw_header.cpp \
|
||||
$$PWD/libdxfrw/drw_objects.cpp \
|
||||
$$PWD/libdxfrw/libdwgr.cpp \
|
||||
$$PWD/libdxfrw/libdxfrw.cpp \
|
||||
$$PWD/dxiface.cpp \
|
||||
$$PWD/dxfdef.cpp
|
||||
|
@ -35,24 +25,14 @@ HEADERS += \
|
|||
$$PWD/dxfdef.h \
|
||||
$$PWD/libdxfrw/intern/drw_dbg.h \
|
||||
$$PWD/libdxfrw/intern/drw_textcodec.h \
|
||||
$$PWD/libdxfrw/intern/dwgbuffer.h \
|
||||
$$PWD/libdxfrw/intern/dwgreader.h \
|
||||
$$PWD/libdxfrw/intern/dwgreader15.h \
|
||||
$$PWD/libdxfrw/intern/dwgreader18.h \
|
||||
$$PWD/libdxfrw/intern/dwgreader21.h \
|
||||
$$PWD/libdxfrw/intern/dwgreader24.h \
|
||||
$$PWD/libdxfrw/intern/dwgreader27.h \
|
||||
$$PWD/libdxfrw/intern/dwgutil.h \
|
||||
$$PWD/libdxfrw/intern/dxfreader.h \
|
||||
$$PWD/libdxfrw/intern/dxfwriter.h \
|
||||
$$PWD/libdxfrw/intern/rscodec.h \
|
||||
$$PWD/libdxfrw/drw_base.h \
|
||||
$$PWD/libdxfrw/drw_classes.h \
|
||||
$$PWD/libdxfrw/drw_entities.h \
|
||||
$$PWD/libdxfrw/drw_header.h \
|
||||
$$PWD/libdxfrw/drw_interface.h \
|
||||
$$PWD/libdxfrw/drw_objects.h \
|
||||
$$PWD/libdxfrw/libdwgr.h \
|
||||
$$PWD/libdxfrw/libdxfrw.h \
|
||||
$$PWD/libdxfrw/main_doc.h \
|
||||
$$PWD/dxiface.h
|
||||
|
|
Loading…
Reference in New Issue
Block a user