Skip to content

Commit

Permalink
Solve the bugs when reading hatch entities.
Browse files Browse the repository at this point in the history
Solve the bugs when dwg files contain hatch entities.
The code of parsing hatch entities is different from
the book `Open Design Specification for .dwg files` at
https://www.opendesign.com/files/guestdownloads/OpenDesign_Specification_for_.dwg_files.pdf
  • Loading branch information
exogeny committed Dec 17, 2019
1 parent a5bf2b4 commit a34bc00
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions src/drw_entities.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1897,15 +1897,22 @@ bool DRW_Hatch::parseDwg(DRW::Version version, dwgBuffer *buf, duint32 bs){
bool isRational = buf->getBit();
spline->flags |= (isRational << 2); //rational
spline->flags |= (buf->getBit() << 1); //periodic
// refer the information at
// https://www.opendesign.com/files/guestdownloads/OpenDesign_Specification_for_.dwg_files.pdf
// first get the number of knots and control points
// and then repeat to read the points.
// > numknots BL 95 number of knots
// > numctlpts BL 96 number of control points
spline->nknots = buf->getBitLong();
spline->ncontrol = buf->getBitLong();
spline->knotslist.reserve(spline->nknots);
spline->controllist.reserve(spline->ncontrol);
for (dint32 j = 0; j < spline->nknots;++j){
spline->knotslist.push_back (buf->getBitDouble());
}
spline->ncontrol = buf->getBitLong();
spline->controllist.reserve(spline->ncontrol);
for (dint32 j = 0; j < spline->ncontrol;++j){
DRW_Coord* crd = new DRW_Coord(buf->get3BitDouble());
// pt0 2RD 10 control point
DRW_Coord* crd = new DRW_Coord(buf->get2RawDouble());
spline->controllist.push_back(crd);
if(isRational)
crd->z = buf->getBitDouble(); //RLZ: investigate how store weight
Expand All @@ -1915,7 +1922,8 @@ bool DRW_Hatch::parseDwg(DRW::Version version, dwgBuffer *buf, duint32 bs){
spline->nfit = buf->getBitLong();
spline->fitlist.reserve(spline->nfit);
for (dint32 j = 0; j < spline->nfit;++j){
DRW_Coord* crd = new DRW_Coord(buf->get3BitDouble());
// Fitpoint 2RD 11
DRW_Coord* crd = new DRW_Coord(buf->get2RawDouble());
spline->fitlist.push_back (crd);
}
spline->tgStart = buf->get2RawDouble();
Expand Down

0 comments on commit a34bc00

Please sign in to comment.