/
ImpExpDxf.h
121 lines (103 loc) · 5.54 KB
/
ImpExpDxf.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
/***************************************************************************
* Copyright (c) 2015 Yorik van Havre (yorik@uncreated.net) *
* *
* This file is part of the FreeCAD CAx development system. *
* *
* This library is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Library General Public *
* License as published by the Free Software Foundation; either *
* version 2 of the License, or (at your option) any later version. *
* *
* This library is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU Library General Public License for more details. *
* *
* You should have received a copy of the GNU Library General Public *
* License along with this library; see the file COPYING.LIB. If not, *
* write to the Free Software Foundation, Inc., 59 Temple Place, *
* Suite 330, Boston, MA 02111-1307, USA *
* *
***************************************************************************/
#ifndef IMPEXPDXF_H
#define IMPEXPDXF_H
#include "dxf.h"
#include <Mod/Part/App/TopoShape.h>
#include <App/Document.h>
#include <gp_Pnt.hxx>
class BRepAdaptor_Curve;
namespace Import
{
class ImportExport ImpExpDxfRead : public CDxfRead
{
public:
ImpExpDxfRead(std::string filepath, App::Document *pcDoc);
// CDxfRead's virtual functions
void OnReadLine(const double* s, const double* e, bool hidden);
void OnReadPoint(const double* s);
void OnReadText(const double* point, const double height, const char* text);
void OnReadArc(const double* s, const double* e, const double* c, bool dir, bool hidden);
void OnReadCircle(const double* s, const double* c, bool dir, bool hidden);
void OnReadEllipse(const double* c, double major_radius, double minor_radius, double rotation, double start_angle, double end_angle, bool dir);
void OnReadSpline(struct SplineData& sd);
void OnReadInsert(const double* point, const double* scale, const char* name, double rotation);
void OnReadDimension(const double* s, const double* e, const double* point, double rotation);
void AddGraphics() const;
// FreeCAD-specific functions
void AddObject(Part::TopoShape *shape); //Called by OnRead functions to add Part objects
std::string Deformat(const char* text); // Removes DXF formatting from texts
std::string getOptionSource() { return m_optionSource; }
void setOptionSource(std::string s) { m_optionSource = s; }
void setOptions(void);
private:
gp_Pnt makePoint(const double* p);
protected:
App::Document *document;
bool optionGroupLayers;
bool optionImportAnnotations;
double optionScaling;
std::map <std::string, std::vector <Part::TopoShape*> > layers;
std::string m_optionSource;
};
class ImportExport ImpExpDxfWrite : public CDxfWrite
{
public:
ImpExpDxfWrite(std::string filepath);
~ImpExpDxfWrite();
void exportShape(const TopoDS_Shape input);
std::string getOptionSource() { return m_optionSource; }
void setOptionSource(std::string s) { m_optionSource = s; }
void setOptions(void);
void exportText(const char* text, Base::Vector3d position1, Base::Vector3d position2, double size, int just);
void exportLinearDim(Base::Vector3d textLocn, Base::Vector3d lineLocn,
Base::Vector3d extLine1Start, Base::Vector3d extLine2Start,
char* dimText, int type);
void exportAngularDim(Base::Vector3d textLocn, Base::Vector3d lineLocn,
Base::Vector3d extLine1Start, Base::Vector3d extLine2Start,
Base::Vector3d apexPoint,
char* dimText);
void exportRadialDim(Base::Vector3d centerPoint, Base::Vector3d textLocn,
Base::Vector3d arcPoint,
char* dimText);
void exportDiametricDim(Base::Vector3d textLocn,
Base::Vector3d arcPoint1, Base::Vector3d arcPoint2,
char* dimText);
static bool gp_PntEqual(gp_Pnt p1, gp_Pnt p2);
static bool gp_PntCompare(gp_Pnt p1, gp_Pnt p2);
protected:
void exportCircle(BRepAdaptor_Curve& c);
void exportEllipse(BRepAdaptor_Curve& c);
void exportArc(BRepAdaptor_Curve& c);
void exportEllipseArc(BRepAdaptor_Curve& c);
void exportBSpline(BRepAdaptor_Curve& c);
void exportBCurve(BRepAdaptor_Curve& c);
void exportLine(BRepAdaptor_Curve& c);
void exportLWPoly(BRepAdaptor_Curve& c); //LWPolyline not supported in R12?
void exportPolyline(BRepAdaptor_Curve& c);
// std::string m_optionSource;
double optionMaxLength;
bool optionPolyLine;
bool optionExpPoints;
};
}
#endif // IMPEXPDXF_H