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

Import: C++ DXF importer wrongly scaled polyline bulges #13678

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/Mod/Import/App/dxf/dxf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#include "PreCompiled.h"

// required by windows for M_PI definition
#define _USE_MATH_DEFINES

Check warning on line 9 in src/Mod/Import/App/dxf/dxf.cpp

View workflow job for this annotation

GitHub Actions / Lint / Lint

declaration uses identifier '_USE_MATH_DEFINES', which is a reserved identifier [bugprone-reserved-identifier]
#include <cmath>
#include <fstream>
#include <iomanip>
Expand All @@ -25,14 +25,14 @@


using namespace std;
static Base::Vector3d MakeVector3d(const double coordinates[3])

Check warning on line 28 in src/Mod/Import/App/dxf/dxf.cpp

View workflow job for this annotation

GitHub Actions / Lint / Lint

do not declare C-style arrays, use std::array<> instead [cppcoreguidelines-avoid-c-arrays,modernize-avoid-c-arrays]
{
// NOLINTNEXTLINE(readability/nolint)
// NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-pointer-arithmetic)
return Base::Vector3d(coordinates[0], coordinates[1], coordinates[2]);
}

CDxfWrite::CDxfWrite(const char* filepath)

Check warning on line 35 in src/Mod/Import/App/dxf/dxf.cpp

View workflow job for this annotation

GitHub Actions / Lint / Lint

constructor does not initialize these fields: m_entityHandle, m_layerHandle, m_blockHandle, m_blkRecordHandle [cppcoreguidelines-pro-type-member-init]
: // TODO: these should probably be parameters in config file
// handles:
// boilerplate 0 - A00
Expand All @@ -44,8 +44,8 @@
, m_ssBlkRecord(new std::ostringstream())
, m_ssEntity(new std::ostringstream())
, m_ssLayer(new std::ostringstream())
, m_version(12)

Check warning on line 47 in src/Mod/Import/App/dxf/dxf.cpp

View workflow job for this annotation

GitHub Actions / Lint / Lint

12 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers]
, m_handle(0xA00)

Check warning on line 48 in src/Mod/Import/App/dxf/dxf.cpp

View workflow job for this annotation

GitHub Actions / Lint / Lint

0xA00 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers]
, // room for 2560 handles in boilerplate files
// m_entityHandle(0x300), //don't need special ranges for handles
// m_layerHandle(0x30),
Expand All @@ -66,7 +66,7 @@

// use lots of digits to avoid rounding errors
m_ssEntity->setf(std::ios::fixed);
m_ssEntity->precision(9);

Check warning on line 69 in src/Mod/Import/App/dxf/dxf.cpp

View workflow job for this annotation

GitHub Actions / Lint / Lint

9 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers]
}

CDxfWrite::~CDxfWrite()
Expand Down Expand Up @@ -128,7 +128,7 @@
// added by Wandererfan 2018 (wandererfan@gmail.com) for FreeCAD project
void CDxfWrite::writeClassesSection()
{
if (m_version < 14) {

Check warning on line 131 in src/Mod/Import/App/dxf/dxf.cpp

View workflow job for this annotation

GitHub Actions / Lint / Lint

14 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers]
return;
}

Expand Down Expand Up @@ -159,7 +159,7 @@
fileSpec = m_dataDir + ss.str();
(*m_ofs) << getPlateFile(fileSpec);

if (m_version > 12) {

Check warning on line 162 in src/Mod/Import/App/dxf/dxf.cpp

View workflow job for this annotation

GitHub Actions / Lint / Lint

12 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers]
(*m_ofs) << (*m_ssBlkRecord).str();
(*m_ofs) << " 0" << endl;
(*m_ofs) << "ENDTAB" << endl;
Expand All @@ -180,7 +180,7 @@
(*m_ssLayer) << "LAYER" << endl;
(*m_ssLayer) << " 5" << endl;
(*m_ssLayer) << tablehash << endl;
if (m_version > 12) {

Check warning on line 183 in src/Mod/Import/App/dxf/dxf.cpp

View workflow job for this annotation

GitHub Actions / Lint / Lint

12 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers]
(*m_ssLayer) << "330" << endl;
(*m_ssLayer) << 0 << endl;
(*m_ssLayer) << "100" << endl;
Expand All @@ -193,7 +193,7 @@
(*m_ssLayer) << "LAYER" << endl;
(*m_ssLayer) << " 5" << endl;
(*m_ssLayer) << getLayerHandle() << endl;
if (m_version > 12) {

Check warning on line 196 in src/Mod/Import/App/dxf/dxf.cpp

View workflow job for this annotation

GitHub Actions / Lint / Lint

12 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers]
(*m_ssLayer) << "330" << endl;
(*m_ssLayer) << tablehash << endl;
(*m_ssLayer) << "100" << endl;
Expand Down Expand Up @@ -2162,7 +2162,7 @@
// In the latter case the stroke attributes apply to the closure stroke (if any) which ends at
// the first vertex.
Setup3DVectorAttribute(ePrimaryPoint, currentVertex.location);
SetupScaledDoubleAttribute(eFloat3, currentVertex.bulge);
SetupValueAttribute(eFloat3, currentVertex.bulge);
SetupValueAttribute(eInteger1, flags);
while (get_next_record() && m_record_type != eObjectType) {
if ((m_record_type == ePrimaryPoint + eXOffset && have_x)
Expand Down Expand Up @@ -2208,7 +2208,7 @@
// To avoid eating and discarding the rest of the entieies if ENDSEQ is missing,
// we quit on any unknown type-0 record.
Setup3DVectorAttribute(ePrimaryPoint, currentVertex.location);
SetupScaledDoubleAttribute(eFloat3, currentVertex.bulge);
SetupValueAttribute(eFloat3, currentVertex.bulge);
while (get_next_record() && m_record_type == eObjectType && IsObjectName("VERTEX")) {
// Set vertex defaults
currentVertex.location = Base::Vector3d();
Expand Down