40 # define DL_STRGRP_END STRGRP_END
42 #ifndef DL_ATTFLAGS_CODE
43 # define DL_ATTFLAGS_CODE ATTFLAGS_CODE
46 # define DL_TXTHI_CODE TXTHI_CODE
48 #ifndef DL_TXT_STYLE_CODE
49 # define DL_TXT_STYLE_CODE TXT_STYLE_CODE
51 #ifndef DL_FIRST_XCOORD_CODE
52 # define DL_FIRST_XCOORD_CODE FIRST_XCOORD_CODE
54 #ifndef DL_FIRST_YCOORD_CODE
55 # define DL_FIRST_YCOORD_CODE FIRST_YCOORD_CODE
57 #ifndef DL_CLOSED_PLINE
58 # define DL_CLOSED_PLINE CLOSED_PLINE
82 DL_Codes::version exportVersion = DL_Codes::AC1015;
83 DL_Dxf* dxf =
new DL_Dxf();
85 gerbv_aperture_t *apert;
88 double x[4], y[4], r, dx, dy, nom;
91 dw = dxf->out(file_name, exportVersion);
94 GERB_MESSAGE(_(
"Can't open file for writing: %s"), file_name);
99 setlocale(LC_NUMERIC,
"C");
104 dxf->writeHeader(*dw);
106 dw->dxfString(DL_STRGRP_END,
"$INSUNITS");
107 dw->dxfInt(DL_ATTFLAGS_CODE, INSUNITS_INCH);
109 dw->dxfString(DL_STRGRP_END,
"$DIMEXE");
110 dw->dxfReal(DL_TXTHI_CODE, 1.25);
112 dw->dxfString(DL_STRGRP_END,
"$TEXTSTYLE");
113 dw->dxfString(DL_TXT_STYLE_CODE,
"Standard");
116 dw->dxfString(DL_STRGRP_END,
"$LIMMIN");
117 dw->dxfReal(DL_FIRST_XCOORD_CODE, 0.0);
118 dw->dxfReal(DL_FIRST_YCOORD_CODE, 0.0);
123 dxf->writeVPort(*dw);
126 #if (DL_VERSION_MAJOR == 3)
127 dw->tableLinetypes(1);
128 dxf->writeLinetype(*dw, DL_LinetypeData(
"ByLayer",
"ByLayer", 0, 0, 0));
130 dw->tableLineTypes(1);
131 dxf->writeLineType(*dw, DL_LineTypeData(
"ByLayer", 0));
139 #if (DL_VERSION_MAJOR == 3)
140 dxf->writeLayer(*dw, DL_LayerData(
"0", 0),
146 dxf->writeLayer(*dw, DL_LayerData(
"0", 0),
155 #if (DL_VERSION_MAJOR == 3)
156 dxf->writeStyle(*dw, DL_StyleData(
"Standard",
157 0, 2.5, 1.0, 0.0, 0, 2.5,
"txt",
""));
159 dxf->writeStyle(*dw);
165 dw->tableAppidEntry(0x12);
166 dw->dxfString(2,
"ACAD");
167 dw->dxfInt(DL_ATTFLAGS_CODE, 0);
172 dw->sectionEntities();
174 #if (DL_VERSION_MAJOR == 3)
175 DL_Attributes *attr =
new DL_Attributes(
"0", 0, -1,
"ByLayer", 1.0);
177 DL_Attributes *attr =
new DL_Attributes(
"0", 0, -1,
"ByLayer");
180 for (net = img->
netlist; net != NULL; net = net->
next) {
186 dxf->writePolyline(*dw,
187 DL_PolylineData(1, 0, 0, DL_CLOSED_PLINE),
199 double a1 = DEG2RAD(net->
cirseg->angle1);
200 double a2 = DEG2RAD(net->
cirseg->angle2);
201 double ar = net->
cirseg->width / 2.0;
202 double cx = net->
cirseg->cp_x;
203 double cy = net->
cirseg->cp_y;
204 int steps = (int)(fabs(net->
cirseg->angle2 -
205 net->
cirseg->angle1) / 2.0) + 1;
206 for (
int s = 1; s <= steps; s++) {
207 double a = a1 + (a2 - a1) * s / steps;
208 dxf->writeVertex(*dw,
215 dxf->writeVertex(*dw,
225 dxf->writePolylineEnd(*dw);
232 switch (apert->type) {
236 r = apert->parameter[0]/2;
237 dxf->writeCircle(*dw,
238 DL_CircleData(x[0], y[0], 0.0, r),
242 x[0] = net->
stop_x + apert->parameter[0]/2;
243 y[0] = net->
stop_y + apert->parameter[1]/2;
245 y[1] = y[0] - apert->parameter[1];
246 x[2] = x[1] - apert->parameter[0];
250 dxf->writePolyline(*dw,
251 DL_PolylineData(4, 0, 0, DL_CLOSED_PLINE),
253 for (i = 0; i < 4; i++)
254 dxf->writeVertex(*dw,
255 DL_VertexData(x[i], y[i], 0, 0));
256 dxf->writePolylineEnd(*dw);
259 if (apert->parameter[0] > apert->parameter[1]) {
261 r = apert->parameter[1]/2;
262 dx = apert->parameter[0]/2 - r;
274 r = apert->parameter[0]/2;
275 dy = apert->parameter[1]/2 - r;
287 dxf->writePolyline(*dw,
288 DL_PolylineData(4, 0, 0, DL_CLOSED_PLINE),
290 dxf->writeVertex(*dw,
291 DL_VertexData(x[3], y[3], 0, -1));
292 dxf->writeVertex(*dw,
293 DL_VertexData(x[0], y[0], 0, 0));
294 dxf->writeVertex(*dw,
295 DL_VertexData(x[1], y[1], 0, -1));
296 dxf->writeVertex(*dw,
297 DL_VertexData(x[2], y[2], 0, 0));
299 dxf->writePolylineEnd(*dw);
304 GERB_COMPILE_WARNING(
305 "%s:%d: aperture type %d is "
316 double a1 = net->
cirseg->angle1;
317 double a2 = net->
cirseg->angle2;
324 DL_ArcData(net->
cirseg->cp_x,
332 switch (apert->type) {
337 nom = apert->parameter[0] /
338 (2*sqrt(dx*dx + dy*dy));
354 dxf->writePolyline(*dw,
355 DL_PolylineData(4, 0, 0, DL_CLOSED_PLINE),
357 dxf->writeVertex(*dw,
358 DL_VertexData(x[3], y[3], 0, -1));
359 dxf->writeVertex(*dw,
360 DL_VertexData(x[0], y[0], 0, 0));
361 dxf->writeVertex(*dw,
362 DL_VertexData(x[1], y[1], 0, -1));
363 dxf->writeVertex(*dw,
364 DL_VertexData(x[2], y[2], 0, 0));
366 dxf->writePolylineEnd(*dw);
369 GERB_COMPILE_WARNING(
370 "%s:%d: aperture type %d is "
387 dxf->writeObjects(*dw);
388 dxf->writeObjectsEnd(*dw);
396 setlocale(LC_NUMERIC,
"");
gboolean gerbv_export_dxf_file_from_image(const gchar *file_name, gerbv_image_t *input_img, gerbv_user_transformation_t *trans)
Export an image to a new file in DXF format.
void gerbv_destroy_image(gerbv_image_t *image)
Free an image structure.
gerbv_image_t * gerbv_image_duplicate_image(gerbv_image_t *sourceImage, gerbv_user_transformation_t *transform)
Duplicate an existing image and return the new copy.
The main header file for the libgerbv library.
@ GERBV_APERTURE_STATE_ON
@ GERBV_APERTURE_STATE_FLASH
@ GERBV_INTERPOLATION_PAREA_START
@ GERBV_INTERPOLATION_CW_CIRCULAR
@ GERBV_INTERPOLATION_PAREA_END
@ GERBV_INTERPOLATION_CCW_CIRCULAR
gerbv_aperture_t * aperture[APERTURE_MAX]
gerbv_aperture_state_t aperture_state
gerbv_interpolation_t interpolation