Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Port extrusion handling fix from QGIS #48

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 11 additions & 11 deletions src/drw_entities.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -501,7 +501,7 @@ bool DRW_Point::parseDwg(DRW::Version version, dwgBuffer *buf, duint32 bs){
DRW_DBG("point: "); DRW_DBGPT(basePoint.x, basePoint.y, basePoint.z);
thickness = buf->getThickness(version > DRW::AC1014);//BD
DRW_DBG("\nthickness: "); DRW_DBG(thickness);
extPoint = buf->getExtrusion(version > DRW::AC1014);
extPoint = buf->getExtrusion( version > DRW::AC1014, haveExtrusion );
DRW_DBG(", Extrusion: "); DRW_DBGPT(extPoint.x, extPoint.y, extPoint.z);

double x_axis = buf->getBitDouble();//BD
Expand Down Expand Up @@ -560,7 +560,7 @@ bool DRW_Line::parseDwg(DRW::Version version, dwgBuffer *buf, duint32 bs){
DRW_DBG("\nend point: "); DRW_DBGPT(secPoint.x, secPoint.y, secPoint.z);
thickness = buf->getThickness(version > DRW::AC1014);//BD
DRW_DBG("\nthickness: "); DRW_DBG(thickness);
extPoint = buf->getExtrusion(version > DRW::AC1014);
extPoint = buf->getExtrusion( version > DRW::AC1014, haveExtrusion );
DRW_DBG(", Extrusion: "); DRW_DBGPT(extPoint.x, extPoint.y, extPoint.z);DRW_DBG("\n");
ret = DRW_Entity::parseDwgEntHandle(version, buf);
if (!ret)
Expand Down Expand Up @@ -624,7 +624,7 @@ bool DRW_Circle::parseDwg(DRW::Version version, dwgBuffer *buf, duint32 bs){

thickness = buf->getThickness(version > DRW::AC1014);
DRW_DBG(" thickness: "); DRW_DBG(thickness);
extPoint = buf->getExtrusion(version > DRW::AC1014);
extPoint = buf->getExtrusion( version > DRW::AC1014, haveExtrusion );
DRW_DBG("\nextrusion: "); DRW_DBGPT(extPoint.x, extPoint.y, extPoint.z); DRW_DBG("\n");

ret = DRW_Entity::parseDwgEntHandle(version, buf);
Expand Down Expand Up @@ -683,7 +683,7 @@ bool DRW_Arc::parseDwg(DRW::Version version, dwgBuffer *buf, duint32 bs){
DRW_DBG("\nradius: "); DRW_DBG(radious);
thickness = buf->getThickness(version > DRW::AC1014);
DRW_DBG(" thickness: "); DRW_DBG(thickness);
extPoint = buf->getExtrusion(version > DRW::AC1014);
extPoint = buf->getExtrusion( version > DRW::AC1014, haveExtrusion );
DRW_DBG("\nextrusion: "); DRW_DBGPT(extPoint.x, extPoint.y, extPoint.z);
staangle = buf->getBitDouble();
DRW_DBG("\nstart angle: "); DRW_DBG(staangle);
Expand Down Expand Up @@ -866,7 +866,7 @@ bool DRW_Trace::parseDwg(DRW::Version version, dwgBuffer *buf, duint32 bs){
fourPoint.x = buf->getRawDouble();
fourPoint.y = buf->getRawDouble();
fourPoint.z = basePoint.z;
extPoint = buf->getExtrusion(version>DRW::AC1014);
extPoint = buf->getExtrusion(version>DRW::AC1014, haveExtrusion);

DRW_DBG(" - base "); DRW_DBGPT(basePoint.x, basePoint.y, basePoint.z);
DRW_DBG("\n - sec "); DRW_DBGPT(secPoint.x, secPoint.y, secPoint.z);
Expand Down Expand Up @@ -1068,7 +1068,7 @@ bool DRW_Insert::parseDwg(DRW::Version version, dwgBuffer *buf, duint32 bs){
}
angle = buf->getBitDouble();
DRW_DBG("scale : "); DRW_DBGPT(xscale, yscale, zscale); DRW_DBG(", angle: "); DRW_DBG(angle);
extPoint = buf->getExtrusion(false); //3BD R14 style
extPoint = buf->getExtrusion(false, haveExtrusion); //3BD R14 style
DRW_DBG("\nextrusion: "); DRW_DBGPT(extPoint.x, extPoint.y, extPoint.z);

bool hasAttrib = buf->getBit();
Expand Down Expand Up @@ -1198,7 +1198,7 @@ bool DRW_LWPolyline::parseDwg(DRW::Version version, dwgBuffer *buf, duint32 bs){
if (flags & 2)
thickness = buf->getBitDouble();
if (flags & 1)
extPoint = buf->getExtrusion(false);
extPoint = buf->getExtrusion(false, haveExtrusion);
vertexnum = buf->getBitLong();
vertlist.reserve(vertexnum);
unsigned int bulgesnum = 0;
Expand Down Expand Up @@ -1358,7 +1358,7 @@ bool DRW_Text::parseDwg(DRW::Version version, dwgBuffer *buf, duint32 bs){
}
secPoint.z = basePoint.z;
DRW_DBG("Alignment: "); DRW_DBGPT(secPoint.x, secPoint.y, basePoint.z); DRW_DBG("\n");
extPoint = buf->getExtrusion(version > DRW::AC1014);
extPoint = buf->getExtrusion(version > DRW::AC1014, haveExtrusion);
DRW_DBG("Extrusion: "); DRW_DBGPT(extPoint.x, extPoint.y, extPoint.z); DRW_DBG("\n");
thickness = buf->getThickness(version > DRW::AC1014); /* Thickness BD 39 */

Expand Down Expand Up @@ -1569,7 +1569,7 @@ bool DRW_Polyline::parseDwg(DRW::Version version, dwgBuffer *buf, duint32 bs){
defendwidth = buf->getBitDouble();
thickness = buf->getThickness(version > DRW::AC1014);
basePoint = DRW_Coord(0,0,buf->getBitDouble());
extPoint = buf->getExtrusion(version > DRW::AC1014);
extPoint = buf->getExtrusion( version > DRW::AC1014, haveExtrusion );
} else if (oType == 0x10) { //pline 3D
duint8 tmpFlag = buf->getRawChar8();
DRW_DBG("flags 1 value: "); DRW_DBG(tmpFlag);
Expand Down Expand Up @@ -2388,7 +2388,7 @@ bool DRW_Dimension::parseDwg(DRW::Version version, dwgBuffer *buf, dwgBuffer *sB
duint8 dimVersion = buf->getRawChar8();
DRW_DBG("\ndimVersion: "); DRW_DBG(dimVersion);
}
extPoint = buf->getExtrusion(version > DRW::AC1014);
extPoint = buf->getExtrusion(version > DRW::AC1014, haveExtrusion);
DRW_DBG("\nextPoint: "); DRW_DBGPT(extPoint.x, extPoint.y, extPoint.z);
if (version > DRW::AC1014) { //2000+
DRW_DBG("\nFive unknown bits: "); DRW_DBG(buf->getBit()); DRW_DBG(buf->getBit());
Expand Down Expand Up @@ -2801,7 +2801,7 @@ bool DRW_Leader::parseDwg(DRW::Version version, dwgBuffer *buf, duint32 bs){
}
DRW_Coord Endptproj = buf->get3BitDouble();
DRW_DBG("\nEndptproj "); DRW_DBGPT(Endptproj.x, Endptproj.y, Endptproj.z);
extrusionPoint = buf->getExtrusion(version > DRW::AC1014);
extrusionPoint = buf->getExtrusion(version > DRW::AC1014, haveExtrusion);
DRW_DBG("\nextrusionPoint "); DRW_DBGPT(extrusionPoint.x, extrusionPoint.y, extrusionPoint.z);
if (version > DRW::AC1014) { //2000+
DRW_DBG("\nFive unknown bits: "); DRW_DBG(buf->getBit()); DRW_DBG(buf->getBit());
Expand Down
4 changes: 3 additions & 1 deletion src/intern/dwgbuffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -674,8 +674,9 @@ duint16 dwgBuffer::getObjType(DRW::Version v){//OT
* be followed by 3BD.
* For R13-R14 this is 3BD.
*/
DRW_Coord dwgBuffer::getExtrusion(bool b_R2000_style) {
DRW_Coord dwgBuffer::getExtrusion( bool b_R2000_style, bool &haveExtrusion ) {
DRW_Coord ext(0.0,0.0,1.0);
haveExtrusion = false;
if ( b_R2000_style )
/* If the bit is one, the extrusion value is assumed to be 0,0,1*/
if ( getBit() == 1 )
Expand All @@ -684,6 +685,7 @@ DRW_Coord dwgBuffer::getExtrusion(bool b_R2000_style) {
ext.x = getBitDouble();
ext.y = getBitDouble();
ext.z = getBitDouble();
haveExtrusion = ext.x != 0.0 || ext.y != 0.0 || ext.z != 1.0;
return ext;
}

Expand Down
2 changes: 1 addition & 1 deletion src/intern/dwgbuffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ class dwgBuffer {

//X, U, SN,

DRW_Coord getExtrusion(bool b_R2000_style); //BE
DRW_Coord getExtrusion( bool b_R2000_style, bool &haveExtrusion ); //BE
double getDefaultDouble(double d); //DD
double getThickness(bool b_R2000_style);//BT
//3DD
Expand Down
1 change: 1 addition & 0 deletions src/intern/dwgreader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -957,6 +957,7 @@ bool dwgReader::readDwgEntity(dwgBuffer *dbuf, objHandle& obj, DRW_Interface& in
#define ENTRY_PARSE(e) \
ret = e.parseDwg(version, &buff, bs); \
parseAttribs(&e); \
e.applyExtrusion(); \
nextEntLink = e.nextEntLink; \
prevEntLink = e.prevEntLink;

Expand Down