Skip to content

Commit

Permalink
Merge branch 'feature/#251' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
HuguesDelorme committed Jan 18, 2024
2 parents f23aff6 + 2c28702 commit 8b61e1d
Show file tree
Hide file tree
Showing 3 changed files with 240 additions and 42 deletions.
92 changes: 89 additions & 3 deletions src/io_dxf/dxf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2791,8 +2791,13 @@ bool CDxfRead::ReadVertex(Dxf_VERTEX* vertex)
y_found = y_found || n == 20;
HandleCoordCode(n, &vertex->point);
break;
case 40:
vertex->startingWidth = stringToDouble(m_str);
break;
case 41:
vertex->endingWidth = stringToDouble(m_str);
break;
case 42: {
// bulge
const int bulge = stringToInt(m_str);
if (bulge == 0)
vertex->bulge = Dxf_VERTEX::Bulge::StraightSegment;
Expand All @@ -2801,9 +2806,63 @@ bool CDxfRead::ReadVertex(Dxf_VERTEX* vertex)
}
break;
case 70:
// flags
vertex->flags = stringToUnsigned(m_str);
break;
case 71:
vertex->polyfaceMeshVertex1 = stringToInt(m_str);
break;
case 72:
vertex->polyfaceMeshVertex2 = stringToInt(m_str);
break;
case 73:
vertex->polyfaceMeshVertex3 = stringToInt(m_str);
break;
case 74:
vertex->polyfaceMeshVertex4 = stringToInt(m_str);
break;
default:
HandleCommonGroupCode(n);
break;
}
}

return false;
}

bool CDxfRead::Read3dFace()
{
Dxf_3DFACE face;
while (!m_ifs.eof()) {
get_line();
const int n = stringToInt(m_str, StringToErrorMode::ReturnErrorValue);
if (n == 0) {
ResolveColorIndex();
OnRead3dFace(face);
return true;
}
else if (isStringToErrorValue(n)) {
this->ReportError_readInteger("DXF::Read3dFace()");
return false;
}

get_line();
switch (n) {
case 10: case 20: case 30:
HandleCoordCode<10, 20, 30>(n, &face.corner1);
break;
case 11: case 21: case 31:
HandleCoordCode<11, 21, 31>(n, &face.corner2);
break;
case 12: case 22: case 32:
HandleCoordCode<12, 22, 32>(n, &face.corner3);
break;
case 13: case 23: case 33:
HandleCoordCode<13, 23, 33>(n, &face.corner4);
face.hasCorner4 = true;
break;
case 70:
face.flags = stringToUnsigned(m_str);
break;
default:
HandleCommonGroupCode(n);
break;
Expand Down Expand Up @@ -2913,11 +2972,37 @@ bool CDxfRead::ReadPolyLine()
return true;
}

break;
case 39:
polyline.thickness = stringToDouble(m_str);
break;
case 70:
// flags
polyline.flags = stringToUnsigned(m_str);
break;
case 40:
polyline.defaultStartWidth = stringToDouble(m_str);
break;
case 41:
polyline.defaultEndWidth = stringToDouble(m_str);
break;
case 71:
polyline.polygonMeshMVertexCount = stringToInt(m_str);
break;
case 72:
polyline.polygonMeshNVertexCount = stringToInt(m_str);
break;
case 73:
polyline.smoothSurfaceMDensity = stringToDouble(m_str);
break;
case 74:
polyline.smoothSurfaceNDensity = stringToDouble(m_str);
break;
case 75:
polyline.type = static_cast<Dxf_POLYLINE::Type>(stringToUnsigned(m_str));
break;
case 210: case 220: case 230:
HandleCoordCode<210, 220, 230>(n, &polyline.extrusionDirection);
break;
default:
HandleCommonGroupCode(n);
break;
Expand Down Expand Up @@ -3402,6 +3487,7 @@ void CDxfRead::DoRead(bool ignore_errors)
mapEntityHandler.insert({ "POLYLINE", [=]{ return ReadPolyLine(); } });
mapEntityHandler.insert({ "SECTION", [=]{ return ReadSection(); } });
mapEntityHandler.insert({ "SOLID", [=]{ return ReadSolid(); } });
mapEntityHandler.insert({ "3DFACE", [=]{ return Read3dFace(); } });
mapEntityHandler.insert({ "SPLINE", [=]{ return ReadSpline(); } });
mapEntityHandler.insert({ "STYLE", [=]{ return ReadStyle(); } });
mapEntityHandler.insert({ "TEXT", [=]{ return ReadText(); } });
Expand Down
56 changes: 53 additions & 3 deletions src/io_dxf/dxf.h
Original file line number Diff line number Diff line change
Expand Up @@ -192,13 +192,32 @@ struct Dxf_VERTEX {
SplineFrameControlPoint = 16,
Polyline3dVertex = 32,
Polygon3dVertex = 64,
PolyfaceMesgVertex = 128
PolyfaceMeshVertex = 128
};
using Flags = unsigned;

// Code: 10, 20, 30
DxfCoords point = {};
// Code: 40
double startingWidth = 0.;
// Code: 41
double endingWidth = 0.;
// Code: 42
Bulge bulge = Bulge::StraightSegment;
// Code: 70
Flags flags = Flag::None;
// Code: 50
double curveFitTangentDirection = 0.;
// Code: 71
int polyfaceMeshVertex1 = 0;
// Code: 72
int polyfaceMeshVertex2 = 0;
// Code: 73
int polyfaceMeshVertex3 = 0;
// Code: 74
int polyfaceMeshVertex4 = 0;
// Code: 91
// int identifier = 0;
};

struct Dxf_POLYLINE {
Expand All @@ -222,16 +241,27 @@ struct Dxf_POLYLINE {
BezierSurface = 8
};

double elevation = 0.;
// Code: 39
double thickness = 0.;
// Code: 70
Flags flags = Flag::None;
// Code: 40
double defaultStartWidth = 0.;
// Code: 41
double defaultEndWidth = 0.;
// Code: 71(number of vertices in the mesh)
int polygonMeshMVertexCount = 0;
// Code: 72(number of faces in the mesh)
int polygonMeshNVertexCount = 0;
// Code: 73
double smoothSurfaceMDensity = 0.;
// Code: 74
double smoothSurfaceNDensity = 0.;
// Code: 75
Type type = Type::NoSmoothSurfaceFitted;
// Code: 210, 220, 230
DxfCoords extrusionDirection = { 0., 0., 1. };

std::vector<Dxf_VERTEX> vertices;
};

Expand All @@ -256,7 +286,7 @@ struct Dxf_INSERT {
DxfCoords extrusionDirection = { 0., 0., 1. };
};

struct Dxf_SOLID {
struct Dxf_QuadBase {
// Code: 10, 20, 30
DxfCoords corner1;
// Code: 11, 21, 31
Expand All @@ -266,6 +296,23 @@ struct Dxf_SOLID {
// Code: 13, 23, 33
DxfCoords corner4;
bool hasCorner4 = false;
};

struct Dxf_3DFACE : public Dxf_QuadBase {
enum Flag {
None = 0,
InvisibleEdge1 = 1,
InvisibleEdge2 = 2,
InvisibleEdge3 = 4,
InvisibleEdge4 = 8
};
using Flags = unsigned;

// Code: 70
Flags flags = Flag::None;
};

struct Dxf_SOLID : public Dxf_QuadBase {
// Code: 39
double thickness = 0.;
// Code: 210, 220, 230
Expand Down Expand Up @@ -603,6 +650,7 @@ class CDxfRead
bool ReadLwPolyLine();
bool ReadPolyLine();
bool ReadVertex(Dxf_VERTEX* vertex);
bool Read3dFace();
bool ReadSolid();
bool ReadSection();
bool ReadTable();
Expand Down Expand Up @@ -693,6 +741,8 @@ class CDxfRead

virtual void OnReadPolyline(const Dxf_POLYLINE&) = 0;

virtual void OnRead3dFace(const Dxf_3DFACE&) = 0;

virtual void OnReadPoint(const DxfCoords& s) = 0;

virtual void OnReadText(const Dxf_TEXT&) = 0;
Expand Down
Loading

0 comments on commit 8b61e1d

Please sign in to comment.