libDXF 0.0.1
A library with DXF related functions written in C.
|
00001 00044 #include "3dline.h" 00045 00046 00055 Dxf3dline * 00056 dxf_3dline_new () 00057 { 00058 #if DEBUG 00059 DXF_DEBUG_BEGIN 00060 #endif 00061 Dxf3dline *line = NULL; 00062 size_t size; 00063 00064 size = sizeof (Dxf3dline); 00065 /* avoid malloc of 0 bytes */ 00066 if (size == 0) size = 1; 00067 if ((line = malloc (size)) == NULL) 00068 { 00069 fprintf (stderr, 00070 (_("Error in %s () could not allocate memory.\n")), 00071 __FUNCTION__); 00072 line = NULL; 00073 } 00074 else 00075 { 00076 memset (line, 0, size); 00077 } 00078 #if DEBUG 00079 DXF_DEBUG_END 00080 #endif 00081 return (line); 00082 } 00083 00084 00092 Dxf3dline * 00093 dxf_3dline_init 00094 ( 00095 Dxf3dline *line 00097 ) 00098 { 00099 #if DEBUG 00100 DXF_DEBUG_BEGIN 00101 #endif 00102 /* Do some basic checks. */ 00103 if (line == NULL) 00104 { 00105 fprintf (stderr, 00106 (_("Warning in %s () a NULL pointer was passed.\n")), 00107 __FUNCTION__); 00108 line = dxf_3dline_new (); 00109 } 00110 if (line == NULL) 00111 { 00112 fprintf (stderr, 00113 (_("Error in %s () could not allocate memory.\n")), 00114 __FUNCTION__); 00115 return (NULL); 00116 } 00117 dxf_3dline_set_id_code (line, 0); 00118 dxf_3dline_set_linetype (line, strdup (DXF_DEFAULT_LINETYPE)); 00119 dxf_3dline_set_layer (line, strdup (DXF_DEFAULT_LAYER)); 00120 dxf_3dline_set_p0 (line, dxf_point_new ()); 00121 dxf_point_init ((DxfPoint *) dxf_3dline_get_p0 (line)); 00122 dxf_3dline_set_x0 (line, 0.0); 00123 dxf_3dline_set_y0 (line, 0.0); 00124 dxf_3dline_set_z0 (line, 0.0); 00125 dxf_3dline_set_p1 (line, dxf_point_new ()); 00126 dxf_point_init ((DxfPoint *) dxf_3dline_get_p1 (line)); 00127 dxf_3dline_set_x1 (line, 0.0); 00128 dxf_3dline_set_y1 (line, 0.0); 00129 dxf_3dline_set_z1 (line, 0.0); 00130 dxf_3dline_set_extr_x0 (line, 0.0); 00131 dxf_3dline_set_extr_y0 (line, 0.0); 00132 dxf_3dline_set_extr_z0 (line, 1.0); 00133 dxf_3dline_set_elevation (line, 0.0); 00134 dxf_3dline_set_thickness (line, 0.0); 00135 dxf_3dline_set_linetype_scale (line, DXF_DEFAULT_LINETYPE_SCALE); 00136 dxf_3dline_set_visibility (line, DXF_DEFAULT_VISIBILITY); 00137 dxf_3dline_set_color (line, DXF_COLOR_BYLAYER); 00138 dxf_3dline_set_paperspace (line, DXF_MODELSPACE); 00139 dxf_3dline_set_graphics_data_size (line, 0); 00140 dxf_3dline_set_shadow_mode (line, 0); 00141 dxf_3dline_set_binary_graphics_data (line, (DxfBinaryGraphicsData *) dxf_binary_graphics_data_new ()); 00142 dxf_binary_graphics_data_init ((DxfBinaryGraphicsData *) dxf_3dline_get_binary_graphics_data (line)); 00143 dxf_3dline_set_dictionary_owner_soft (line, strdup ("")); 00144 dxf_3dline_set_material (line, strdup ("")); 00145 dxf_3dline_set_dictionary_owner_hard (line, strdup ("")); 00146 dxf_3dline_set_lineweight (line, 0); 00147 dxf_3dline_set_plot_style_name (line, strdup ("")); 00148 dxf_3dline_set_color_value (line, 0); 00149 dxf_3dline_set_color_name (line, strdup ("")); 00150 dxf_3dline_set_transparency (line, 0); 00151 dxf_3dline_set_next (line, NULL); 00152 #if DEBUG 00153 DXF_DEBUG_END 00154 #endif 00155 return (line); 00156 } 00157 00158 00170 Dxf3dline * 00171 dxf_3dline_read 00172 ( 00173 DxfFile *fp, 00175 Dxf3dline *line 00177 ) 00178 { 00179 #if DEBUG 00180 DXF_DEBUG_BEGIN 00181 #endif 00182 char *temp_string = NULL; 00183 00184 /* Do some basic checks. */ 00185 if (fp == NULL) 00186 { 00187 fprintf (stderr, 00188 (_("Error in %s () a NULL file pointer was passed.\n")), 00189 __FUNCTION__); 00190 /* Clean up. */ 00191 free (temp_string); 00192 return (NULL); 00193 } 00194 if (line == NULL) 00195 { 00196 fprintf (stderr, 00197 (_("Warning in %s () a NULL pointer was passed.\n")), 00198 __FUNCTION__); 00199 line = dxf_3dline_new (); 00200 line = dxf_3dline_init (line); 00201 } 00202 (fp->line_number)++; 00203 fscanf (fp->fp, "%[^\n]", temp_string); 00204 while (strcmp (temp_string, "0") != 0) 00205 { 00206 if (ferror (fp->fp)) 00207 { 00208 fprintf (stderr, 00209 (_("Error in %s () while reading from: %s in line: %d.\n")), 00210 __FUNCTION__, fp->filename, fp->line_number); 00211 fclose (fp->fp); 00212 /* Clean up. */ 00213 free (temp_string); 00214 return (NULL); 00215 } 00216 if (strcmp (temp_string, "5") == 0) 00217 { 00218 /* Now follows a string containing a sequential 00219 * id number. */ 00220 (fp->line_number)++; 00221 fscanf (fp->fp, "%x\n", &line->id_code); 00222 } 00223 else if (strcmp (temp_string, "6") == 0) 00224 { 00225 /* Now follows a string containing a linetype 00226 * name. */ 00227 (fp->line_number)++; 00228 fscanf (fp->fp, "%s\n", line->linetype); 00229 } 00230 else if (strcmp (temp_string, "8") == 0) 00231 { 00232 /* Now follows a string containing a layer name. */ 00233 (fp->line_number)++; 00234 fscanf (fp->fp, "%s\n", line->layer); 00235 } 00236 else if (strcmp (temp_string, "10") == 0) 00237 { 00238 /* Now follows a string containing the 00239 * X-coordinate of the center point. */ 00240 (fp->line_number)++; 00241 fscanf (fp->fp, "%lf\n", &line->p0->x0); 00242 } 00243 else if (strcmp (temp_string, "20") == 0) 00244 { 00245 /* Now follows a string containing the 00246 * Y-coordinate of the center point. */ 00247 (fp->line_number)++; 00248 fscanf (fp->fp, "%lf\n", &line->p0->y0); 00249 } 00250 else if (strcmp (temp_string, "30") == 0) 00251 { 00252 /* Now follows a string containing the 00253 * Z-coordinate of the center point. */ 00254 (fp->line_number)++; 00255 fscanf (fp->fp, "%lf\n", &line->p0->z0); 00256 } 00257 else if (strcmp (temp_string, "11") == 0) 00258 { 00259 /* Now follows a string containing the 00260 * X-coordinate of the center point. */ 00261 (fp->line_number)++; 00262 fscanf (fp->fp, "%lf\n", &line->p1->x0); 00263 } 00264 else if (strcmp (temp_string, "21") == 0) 00265 { 00266 /* Now follows a string containing the 00267 * Y-coordinate of the center point. */ 00268 (fp->line_number)++; 00269 fscanf (fp->fp, "%lf\n", &line->p1->y0); 00270 } 00271 else if (strcmp (temp_string, "31") == 0) 00272 { 00273 /* Now follows a string containing the 00274 * Z-coordinate of the center point. */ 00275 (fp->line_number)++; 00276 fscanf (fp->fp, "%lf\n", &line->p1->z0); 00277 } 00278 else if (strcmp (temp_string, "38") == 0) 00279 { 00280 /* Now follows a string containing the 00281 * elevation. */ 00282 (fp->line_number)++; 00283 fscanf (fp->fp, "%lf\n", &line->elevation); 00284 } 00285 else if (strcmp (temp_string, "39") == 0) 00286 { 00287 /* Now follows a string containing the 00288 * thickness. */ 00289 (fp->line_number)++; 00290 fscanf (fp->fp, "%lf\n", &line->thickness); 00291 } 00292 else if (strcmp (temp_string, "48") == 0) 00293 { 00294 /* Now follows a string containing the linetype 00295 * scale. */ 00296 (fp->line_number)++; 00297 fscanf (fp->fp, "%lf\n", &line->linetype_scale); 00298 } 00299 else if (strcmp (temp_string, "60") == 0) 00300 { 00301 /* Now follows a string containing the 00302 * visibility value. */ 00303 (fp->line_number)++; 00304 fscanf (fp->fp, "%hd\n", &line->visibility); 00305 } 00306 else if (strcmp (temp_string, "62") == 0) 00307 { 00308 /* Now follows a string containing the 00309 * color value. */ 00310 (fp->line_number)++; 00311 fscanf (fp->fp, "%d\n", &line->color); 00312 } 00313 else if (strcmp (temp_string, "67") == 0) 00314 { 00315 /* Now follows a string containing the 00316 * paperspace value. */ 00317 (fp->line_number)++; 00318 fscanf (fp->fp, "%d\n", &line->paperspace); 00319 } 00320 else if (strcmp (temp_string, "92") == 0) 00321 { 00322 /* Now follows a string containing the 00323 * graphics data size value. */ 00324 (fp->line_number)++; 00325 fscanf (fp->fp, "%d\n", &line->graphics_data_size); 00326 } 00327 else if (strcmp (temp_string, "100") == 0) 00328 { 00329 /* Now follows a string containing the 00330 * subclass marker value. */ 00331 (fp->line_number)++; 00332 fscanf (fp->fp, "%s\n", temp_string); 00333 if ((strcmp (temp_string, "AcDbEntity") != 0) 00334 && ((strcmp (temp_string, "AcDbLine") != 0))) 00335 { 00336 fprintf (stderr, 00337 (_("Warning in %s () found a bad subclass marker in: %s in line: %d.\n")), 00338 __FUNCTION__, fp->filename, fp->line_number); 00339 } 00340 } 00341 else if (strcmp (temp_string, "160") == 0) 00342 { 00343 /* Now follows a string containing the 00344 * graphics data size value. */ 00345 (fp->line_number)++; 00346 fscanf (fp->fp, "%d\n", &line->graphics_data_size); 00347 } 00348 else if (strcmp (temp_string, "210") == 0) 00349 { 00350 /* Now follows a string containing the 00351 * X-value of the extrusion vector. */ 00352 (fp->line_number)++; 00353 fscanf (fp->fp, "%lf\n", &line->extr_x0); 00354 } 00355 else if (strcmp (temp_string, "220") == 0) 00356 { 00357 /* Now follows a string containing the 00358 * Y-value of the extrusion vector. */ 00359 (fp->line_number)++; 00360 fscanf (fp->fp, "%lf\n", &line->extr_y0); 00361 } 00362 else if (strcmp (temp_string, "230") == 0) 00363 { 00364 /* Now follows a string containing the 00365 * Z-value of the extrusion vector. */ 00366 (fp->line_number)++; 00367 fscanf (fp->fp, "%lf\n", &line->extr_z0); 00368 } 00369 else if (strcmp (temp_string, "284") == 0) 00370 { 00371 /* Now follows a string containing the shadow 00372 * mode value. */ 00373 (fp->line_number)++; 00374 fscanf (fp->fp, "%hd\n", &line->shadow_mode); 00375 } 00376 else if (strcmp (temp_string, "310") == 0) 00377 { 00378 /* Now follows a string containing binary 00379 * graphics data. */ 00380 (fp->line_number)++; 00381 fscanf (fp->fp, "%s\n", line->binary_graphics_data->data_line); 00382 dxf_binary_graphics_data_init ((DxfBinaryGraphicsData *) line->binary_graphics_data->next); 00383 line->binary_graphics_data = (DxfBinaryGraphicsData *) line->binary_graphics_data->next; 00384 } 00385 else if (strcmp (temp_string, "330") == 0) 00386 { 00387 /* Now follows a string containing Soft-pointer 00388 * ID/handle to owner dictionary. */ 00389 (fp->line_number)++; 00390 fscanf (fp->fp, "%s\n", line->dictionary_owner_soft); 00391 } 00392 else if (strcmp (temp_string, "347") == 0) 00393 { 00394 /* Now follows a string containing a 00395 * hard-pointer ID/handle to material object. */ 00396 (fp->line_number)++; 00397 fscanf (fp->fp, "%s\n", line->material); 00398 } 00399 else if (strcmp (temp_string, "360") == 0) 00400 { 00401 /* Now follows a string containing Hard owner 00402 * ID/handle to owner dictionary. */ 00403 (fp->line_number)++; 00404 fscanf (fp->fp, "%s\n", line->dictionary_owner_hard); 00405 } 00406 else if (strcmp (temp_string, "370") == 0) 00407 { 00408 /* Now follows a string containing the lineweight 00409 * value. */ 00410 (fp->line_number)++; 00411 fscanf (fp->fp, "%hd\n", &line->lineweight); 00412 } 00413 else if (strcmp (temp_string, "390") == 0) 00414 { 00415 /* Now follows a string containing a plot style 00416 * name value. */ 00417 (fp->line_number)++; 00418 fscanf (fp->fp, "%s\n", line->plot_style_name); 00419 } 00420 else if (strcmp (temp_string, "420") == 0) 00421 { 00422 /* Now follows a string containing a color value. */ 00423 (fp->line_number)++; 00424 fscanf (fp->fp, "%ld\n", &line->color_value); 00425 } 00426 else if (strcmp (temp_string, "430") == 0) 00427 { 00428 /* Now follows a string containing a color 00429 * name value. */ 00430 (fp->line_number)++; 00431 fscanf (fp->fp, "%s\n", line->color_name); 00432 } 00433 else if (strcmp (temp_string, "440") == 0) 00434 { 00435 /* Now follows a string containing a transparency 00436 * value. */ 00437 (fp->line_number)++; 00438 fscanf (fp->fp, "%ld\n", &line->transparency); 00439 } 00440 else if (strcmp (temp_string, "999") == 0) 00441 { 00442 /* Now follows a string containing a comment. */ 00443 (fp->line_number)++; 00444 fscanf (fp->fp, "%s\n", temp_string); 00445 fprintf (stdout, "DXF comment: %s\n", temp_string); 00446 } 00447 else 00448 { 00449 fprintf (stderr, 00450 (_("Warning in %s () unknown string tag found while reading from: %s in line: %d.\n")), 00451 __FUNCTION__, fp->filename, fp->line_number); 00452 } 00453 } 00454 /* Handle omitted members and/or illegal values. */ 00455 if (strcmp (line->linetype, "") == 0) 00456 { 00457 line->linetype = strdup (DXF_DEFAULT_LINETYPE); 00458 } 00459 if (strcmp (line->layer, "") == 0) 00460 { 00461 line->layer = strdup (DXF_DEFAULT_LAYER); 00462 } 00463 /* Clean up. */ 00464 free (temp_string); 00465 #if DEBUG 00466 DXF_DEBUG_END 00467 #endif 00468 return (line); 00469 } 00470 00471 00482 int 00483 dxf_3dline_write 00484 ( 00485 DxfFile *fp, 00487 Dxf3dline *line 00489 ) 00490 { 00491 #if DEBUG 00492 DXF_DEBUG_BEGIN 00493 #endif 00494 char *dxf_entity_name = strdup ("3DLINE"); 00495 00496 /* Do some basic checks. */ 00497 if (fp == NULL) 00498 { 00499 fprintf (stderr, 00500 (_("Error in %s () a NULL file pointer was passed.\n")), 00501 __FUNCTION__); 00502 /* Clean up. */ 00503 free (dxf_entity_name); 00504 return (EXIT_FAILURE); 00505 } 00506 if (line == NULL) 00507 { 00508 fprintf (stderr, 00509 (_("Error in %s () a NULL pointer was passed.\n")), 00510 __FUNCTION__); 00511 /* Clean up. */ 00512 free (dxf_entity_name); 00513 return (EXIT_FAILURE); 00514 } 00515 if ((dxf_3dline_get_x0 (line) == dxf_3dline_get_x1 (line)) 00516 && (dxf_3dline_get_y0 (line) == dxf_3dline_get_y1 (line)) 00517 && (dxf_3dline_get_z0 (line) == dxf_3dline_get_z1 (line))) 00518 { 00519 fprintf (stderr, 00520 (_("Error in %s () start point and end point are identical for the %s entity with id-code: %x\n")), 00521 __FUNCTION__, dxf_entity_name, dxf_3dline_get_id_code (line)); 00522 dxf_entity_skip (dxf_entity_name); 00523 /* Clean up. */ 00524 free (dxf_entity_name); 00525 return (EXIT_FAILURE); 00526 } 00527 if ((strcmp (dxf_3dline_get_layer (line), "") == 0) 00528 || (dxf_3dline_get_layer (line) == NULL)) 00529 { 00530 fprintf (stderr, 00531 (_("Warning in %s () invalid layer string for the %s entity with id-code: %x\n")), 00532 __FUNCTION__, dxf_entity_name, dxf_3dline_get_id_code (line)); 00533 fprintf (stderr, 00534 (_(" %s entity is relocated to layer 0\n")), 00535 dxf_entity_name); 00536 dxf_3dline_set_layer (line, DXF_DEFAULT_LAYER); 00537 } 00538 if (dxf_3dline_get_linetype (line) == NULL) 00539 { 00540 fprintf (stderr, 00541 (_("Warning in %s () invalid linetype string for the %s entity with id-code: %x\n")), 00542 __FUNCTION__, dxf_entity_name, dxf_3dline_get_id_code (line)); 00543 fprintf (stderr, 00544 (_("\t%s linetype is set to %s\n")), 00545 dxf_entity_name, DXF_DEFAULT_LINETYPE); 00546 dxf_3dline_set_linetype (line, DXF_DEFAULT_LINETYPE); 00547 } 00548 if (fp->acad_version_number > AutoCAD_11) 00549 { 00550 dxf_entity_name = strdup ("LINE"); 00551 } 00552 /* Start writing output. */ 00553 fprintf (fp->fp, " 0\n%s\n", dxf_entity_name); 00554 if (dxf_3dline_get_id_code (line) != -1) 00555 { 00556 fprintf (fp->fp, " 5\n%x\n", dxf_3dline_get_id_code (line)); 00557 } 00568 if ((strcmp (dxf_3dline_get_dictionary_owner_soft (line), "") != 0) 00569 && (fp->acad_version_number >= AutoCAD_14)) 00570 { 00571 fprintf (fp->fp, "102\n{ACAD_REACTORS\n"); 00572 fprintf (fp->fp, "330\n%s\n", dxf_3dline_get_dictionary_owner_soft (line)); 00573 fprintf (fp->fp, "102\n}\n"); 00574 } 00575 if ((strcmp (dxf_3dline_get_dictionary_owner_hard (line), "") != 0) 00576 && (fp->acad_version_number >= AutoCAD_14)) 00577 { 00578 fprintf (fp->fp, "102\n{ACAD_XDICTIONARY\n"); 00579 fprintf (fp->fp, "360\n%s\n", dxf_3dline_get_dictionary_owner_hard (line)); 00580 fprintf (fp->fp, "102\n}\n"); 00581 } 00582 if (fp->acad_version_number >= AutoCAD_13) 00583 { 00584 fprintf (fp->fp, "100\nAcDbEntity\n"); 00585 } 00586 if ((dxf_3dline_get_paperspace (line) == DXF_PAPERSPACE) 00587 && (fp->acad_version_number >= AutoCAD_13)) 00588 { 00589 fprintf (fp->fp, " 67\n%d\n", DXF_PAPERSPACE); 00590 } 00591 fprintf (fp->fp, " 8\n%s\n", dxf_3dline_get_layer (line)); 00592 if (strcmp (dxf_3dline_get_linetype (line), DXF_DEFAULT_LINETYPE) != 0) 00593 { 00594 fprintf (fp->fp, " 6\n%s\n", dxf_3dline_get_linetype (line)); 00595 } 00596 if ((fp->acad_version_number <= AutoCAD_11) 00597 && DXF_FLATLAND 00598 && (dxf_3dline_get_elevation (line) != 0.0)) 00599 { 00600 fprintf (fp->fp, " 38\n%f\n", dxf_3dline_get_elevation (line)); 00601 } 00602 if ((fp->acad_version_number >= AutoCAD_2008) 00603 && (strcmp (dxf_3dline_get_material (line), "") != 0)) 00604 { 00605 fprintf (fp->fp, "347\n%s\n", dxf_3dline_get_material (line)); 00606 } 00607 if (dxf_3dline_get_color (line) != DXF_COLOR_BYLAYER) 00608 { 00609 fprintf (fp->fp, " 62\n%d\n", dxf_3dline_get_color (line)); 00610 } 00611 if (fp->acad_version_number >= AutoCAD_2002) 00612 { 00613 fprintf (fp->fp, "370\n%d\n", dxf_3dline_get_lineweight (line)); 00614 } 00615 if ((dxf_3dline_get_linetype_scale (line) != 1.0) 00616 && (fp->acad_version_number >= AutoCAD_13)) 00617 { 00618 fprintf (fp->fp, " 48\n%f\n", dxf_3dline_get_linetype_scale (line)); 00619 } 00620 if ((dxf_3dline_get_visibility (line) != 0) 00621 && (fp->acad_version_number >= AutoCAD_13)) 00622 { 00623 fprintf (fp->fp, " 60\n%d\n", dxf_3dline_get_visibility (line)); 00624 } 00625 if (fp->acad_version_number >= AutoCAD_2000) 00626 { 00627 #ifdef BUILD_64 00628 fprintf (fp->fp, "160\n%d\n", dxf_3dline_get_graphics_data_size (line)); 00629 #else 00630 fprintf (fp->fp, " 92\n%d\n", dxf_3dline_get_graphics_data_size (line)); 00631 #endif 00632 if (dxf_3dline_get_binary_graphics_data (line) != NULL) 00633 { 00634 DxfBinaryGraphicsData *iter; 00635 iter = dxf_3dline_get_binary_graphics_data (line); 00636 while (iter != NULL) 00637 { 00638 fprintf (fp->fp, "310\n%s\n", dxf_binary_graphics_data_get_data_line (iter)); 00639 iter = (DxfBinaryGraphicsData *) dxf_binary_graphics_data_get_next (iter); 00640 } 00641 } 00642 } 00643 if (fp->acad_version_number >= AutoCAD_2004) 00644 { 00645 fprintf (fp->fp, "420\n%ld\n", dxf_3dline_get_color_value (line)); 00646 fprintf (fp->fp, "430\n%s\n", dxf_3dline_get_color_name (line)); 00647 fprintf (fp->fp, "440\n%ld\n", dxf_3dline_get_transparency (line)); 00648 } 00649 if (fp->acad_version_number >= AutoCAD_2009) 00650 { 00651 fprintf (fp->fp, "390\n%s\n", dxf_3dline_get_plot_style_name (line)); 00652 fprintf (fp->fp, "284\n%d\n", dxf_3dline_get_shadow_mode (line)); 00653 } 00654 if (fp->acad_version_number >= AutoCAD_13) 00655 { 00656 fprintf (fp->fp, "100\nAcDbLine\n"); 00657 } 00658 if (dxf_3dline_get_thickness (line) != 0.0) 00659 { 00660 fprintf (fp->fp, " 39\n%f\n", dxf_3dline_get_thickness (line)); 00661 } 00662 fprintf (fp->fp, " 10\n%f\n", dxf_3dline_get_x0 (line)); 00663 fprintf (fp->fp, " 20\n%f\n", dxf_3dline_get_y0 (line)); 00664 fprintf (fp->fp, " 30\n%f\n", dxf_3dline_get_z0 (line)); 00665 fprintf (fp->fp, " 11\n%f\n", dxf_3dline_get_x1 (line)); 00666 fprintf (fp->fp, " 21\n%f\n", dxf_3dline_get_y1 (line)); 00667 fprintf (fp->fp, " 31\n%f\n", dxf_3dline_get_z1 (line)); 00668 if ((fp->acad_version_number >= AutoCAD_12) 00669 && (dxf_3dline_get_extr_x0 (line) != 0.0) 00670 && (dxf_3dline_get_extr_y0 (line) != 0.0) 00671 && (dxf_3dline_get_extr_z0 (line) != 1.0)) 00672 { 00673 fprintf (fp->fp, "210\n%f\n", dxf_3dline_get_extr_x0 (line)); 00674 fprintf (fp->fp, "220\n%f\n", dxf_3dline_get_extr_y0 (line)); 00675 fprintf (fp->fp, "230\n%f\n", dxf_3dline_get_extr_z0 (line)); 00676 } 00677 /* Clean up. */ 00678 free (dxf_entity_name); 00679 #if DEBUG 00680 DXF_DEBUG_END 00681 #endif 00682 return (EXIT_SUCCESS); 00683 } 00684 00685 00693 int 00694 dxf_3dline_free 00695 ( 00696 Dxf3dline *line 00699 ) 00700 { 00701 #if DEBUG 00702 DXF_DEBUG_BEGIN 00703 #endif 00704 if (line == NULL) 00705 { 00706 fprintf (stderr, 00707 (_("Error in %s () a NULL pointer was passed.\n")), 00708 __FUNCTION__); 00709 return (EXIT_FAILURE); 00710 } 00711 if (line->next != NULL) 00712 { 00713 fprintf (stderr, 00714 (_("Error in %s () pointer to next was not NULL.\n")), 00715 __FUNCTION__); 00716 return (EXIT_FAILURE); 00717 } 00718 free (dxf_3dline_get_linetype (line)); 00719 free (dxf_3dline_get_layer (line)); 00720 dxf_binary_graphics_data_free_chain (dxf_3dline_get_binary_graphics_data (line)); 00721 free (dxf_3dline_get_dictionary_owner_soft (line)); 00722 free (dxf_3dline_get_material (line)); 00723 free (dxf_3dline_get_dictionary_owner_hard (line)); 00724 free (dxf_3dline_get_plot_style_name (line)); 00725 free (dxf_3dline_get_color_name (line)); 00726 dxf_point_free (dxf_3dline_get_p0 (line)); 00727 dxf_point_free (dxf_3dline_get_p1 (line)); 00728 free (line); 00729 line = NULL; 00730 #if DEBUG 00731 DXF_DEBUG_END 00732 #endif 00733 return (EXIT_SUCCESS); 00734 } 00735 00736 00741 void 00742 dxf_3dline_free_chain 00743 ( 00744 Dxf3dline *lines 00746 ) 00747 { 00748 #ifdef DEBUG 00749 DXF_DEBUG_BEGIN 00750 #endif 00751 if (lines == NULL) 00752 { 00753 fprintf (stderr, 00754 (_("Warning in %s () a NULL pointer was passed.\n")), 00755 __FUNCTION__); 00756 } 00757 while (lines != NULL) 00758 { 00759 struct Dxf3dline *iter = (struct Dxf3dline *) lines->next; 00760 dxf_3dline_free (lines); 00761 lines = (Dxf3dline *) iter; 00762 } 00763 #if DEBUG 00764 DXF_DEBUG_END 00765 #endif 00766 } 00767 00768 00774 int 00775 dxf_3dline_get_id_code 00776 ( 00777 Dxf3dline *line 00779 ) 00780 { 00781 #if DEBUG 00782 DXF_DEBUG_BEGIN 00783 #endif 00784 /* Do some basic checks. */ 00785 if (line == NULL) 00786 { 00787 fprintf (stderr, 00788 (_("Error in %s () a NULL pointer was passed.\n")), 00789 __FUNCTION__); 00790 return (EXIT_FAILURE); 00791 } 00792 if (line->id_code < 0) 00793 { 00794 fprintf (stderr, 00795 (_("Error in %s () a negative value was found.\n")), 00796 __FUNCTION__); 00797 return (EXIT_FAILURE); 00798 } 00799 #if DEBUG 00800 DXF_DEBUG_END 00801 #endif 00802 return (line->id_code); 00803 } 00804 00805 00809 Dxf3dline * 00810 dxf_3dline_set_id_code 00811 ( 00812 Dxf3dline *line, 00814 int id_code 00818 ) 00819 { 00820 #if DEBUG 00821 DXF_DEBUG_BEGIN 00822 #endif 00823 /* Do some basic checks. */ 00824 if (line == NULL) 00825 { 00826 fprintf (stderr, 00827 (_("Error in %s () a NULL pointer was passed.\n")), 00828 __FUNCTION__); 00829 return (NULL); 00830 } 00831 if (id_code < 0) 00832 { 00833 fprintf (stderr, 00834 (_("Error in %s () a negative value was passed.\n")), 00835 __FUNCTION__); 00836 return (NULL); 00837 } 00838 line->id_code = id_code; 00839 #if DEBUG 00840 DXF_DEBUG_END 00841 #endif 00842 return (line); 00843 } 00844 00845 00851 char * 00852 dxf_3dline_get_linetype 00853 ( 00854 Dxf3dline *line 00856 ) 00857 { 00858 #if DEBUG 00859 DXF_DEBUG_BEGIN 00860 #endif 00861 /* Do some basic checks. */ 00862 if (line == NULL) 00863 { 00864 fprintf (stderr, 00865 (_("Error in %s () a NULL pointer was passed.\n")), 00866 __FUNCTION__); 00867 return (NULL); 00868 } 00869 if (line->linetype == NULL) 00870 { 00871 fprintf (stderr, 00872 (_("Error in %s () a NULL pointer was found.\n")), 00873 __FUNCTION__); 00874 return (NULL); 00875 } 00876 #if DEBUG 00877 DXF_DEBUG_END 00878 #endif 00879 return (strdup (line->linetype)); 00880 } 00881 00882 00886 Dxf3dline * 00887 dxf_3dline_set_linetype 00888 ( 00889 Dxf3dline *line, 00891 char *linetype 00893 ) 00894 { 00895 #if DEBUG 00896 DXF_DEBUG_BEGIN 00897 #endif 00898 /* Do some basic checks. */ 00899 if (line == NULL) 00900 { 00901 fprintf (stderr, 00902 (_("Error in %s () a NULL pointer was passed.\n")), 00903 __FUNCTION__); 00904 return (NULL); 00905 } 00906 if (linetype == NULL) 00907 { 00908 fprintf (stderr, 00909 (_("Error in %s () a NULL pointer was passed.\n")), 00910 __FUNCTION__); 00911 return (NULL); 00912 } 00913 line->linetype = strdup (linetype); 00914 #if DEBUG 00915 DXF_DEBUG_END 00916 #endif 00917 return (line); 00918 } 00919 00920 00926 char * 00927 dxf_3dline_get_layer 00928 ( 00929 Dxf3dline *line 00931 ) 00932 { 00933 #if DEBUG 00934 DXF_DEBUG_BEGIN 00935 #endif 00936 /* Do some basic checks. */ 00937 if (line == NULL) 00938 { 00939 fprintf (stderr, 00940 (_("Error in %s () a NULL pointer was passed.\n")), 00941 __FUNCTION__); 00942 return (NULL); 00943 } 00944 if (line->layer == NULL) 00945 { 00946 fprintf (stderr, 00947 (_("Error in %s () a NULL pointer was found.\n")), 00948 __FUNCTION__); 00949 return (NULL); 00950 } 00951 #if DEBUG 00952 DXF_DEBUG_END 00953 #endif 00954 return (strdup (line->layer)); 00955 } 00956 00957 00961 Dxf3dline * 00962 dxf_3dline_set_layer 00963 ( 00964 Dxf3dline *line, 00966 char *layer 00968 ) 00969 { 00970 #if DEBUG 00971 DXF_DEBUG_BEGIN 00972 #endif 00973 /* Do some basic checks. */ 00974 if (line == NULL) 00975 { 00976 fprintf (stderr, 00977 (_("Error in %s () a NULL pointer was passed.\n")), 00978 __FUNCTION__); 00979 return (NULL); 00980 } 00981 if (layer == NULL) 00982 { 00983 fprintf (stderr, 00984 (_("Error in %s () a NULL pointer was passed.\n")), 00985 __FUNCTION__); 00986 return (NULL); 00987 } 00988 line->layer = strdup (layer); 00989 #if DEBUG 00990 DXF_DEBUG_END 00991 #endif 00992 return (line); 00993 } 00994 00995 01001 double 01002 dxf_3dline_get_elevation 01003 ( 01004 Dxf3dline *line 01006 ) 01007 { 01008 #if DEBUG 01009 DXF_DEBUG_BEGIN 01010 #endif 01011 /* Do some basic checks. */ 01012 if (line == NULL) 01013 { 01014 fprintf (stderr, 01015 (_("Error in %s () a NULL pointer was passed.\n")), 01016 __FUNCTION__); 01017 return (EXIT_FAILURE); 01018 } 01019 #if DEBUG 01020 DXF_DEBUG_END 01021 #endif 01022 return (line->elevation); 01023 } 01024 01025 01029 Dxf3dline * 01030 dxf_3dline_set_elevation 01031 ( 01032 Dxf3dline *line, 01034 double elevation 01036 ) 01037 { 01038 #if DEBUG 01039 DXF_DEBUG_BEGIN 01040 #endif 01041 /* Do some basic checks. */ 01042 if (line == NULL) 01043 { 01044 fprintf (stderr, 01045 (_("Error in %s () a NULL pointer was passed.\n")), 01046 __FUNCTION__); 01047 return (NULL); 01048 } 01049 line->elevation = elevation; 01050 #if DEBUG 01051 DXF_DEBUG_END 01052 #endif 01053 return (line); 01054 } 01055 01056 01062 double 01063 dxf_3dline_get_thickness 01064 ( 01065 Dxf3dline *line 01067 ) 01068 { 01069 #if DEBUG 01070 DXF_DEBUG_BEGIN 01071 #endif 01072 /* Do some basic checks. */ 01073 if (line == NULL) 01074 { 01075 fprintf (stderr, 01076 (_("Error in %s () a NULL pointer was passed.\n")), 01077 __FUNCTION__); 01078 return (EXIT_FAILURE); 01079 } 01080 if (line->thickness < 0.0) 01081 { 01082 fprintf (stderr, 01083 (_("Error in %s () a negative value was found.\n")), 01084 __FUNCTION__); 01085 return (EXIT_FAILURE); 01086 } 01087 #if DEBUG 01088 DXF_DEBUG_END 01089 #endif 01090 return (line->thickness); 01091 } 01092 01093 01097 Dxf3dline * 01098 dxf_3dline_set_thickness 01099 ( 01100 Dxf3dline *line, 01102 double thickness 01104 ) 01105 { 01106 #if DEBUG 01107 DXF_DEBUG_BEGIN 01108 #endif 01109 /* Do some basic checks. */ 01110 if (line == NULL) 01111 { 01112 fprintf (stderr, 01113 (_("Error in %s () a NULL pointer was passed.\n")), 01114 __FUNCTION__); 01115 return (NULL); 01116 } 01117 if (thickness < 0.0) 01118 { 01119 fprintf (stderr, 01120 (_("Error in %s () a negative value was passed.\n")), 01121 __FUNCTION__); 01122 return (NULL); 01123 } 01124 line->thickness = thickness; 01125 #if DEBUG 01126 DXF_DEBUG_END 01127 #endif 01128 return (line); 01129 } 01130 01131 01140 double 01141 dxf_3dline_get_linetype_scale 01142 ( 01143 Dxf3dline *line 01145 ) 01146 { 01147 #if DEBUG 01148 DXF_DEBUG_BEGIN 01149 #endif 01150 /* Do some basic checks. */ 01151 if (line == NULL) 01152 { 01153 fprintf (stderr, 01154 (_("Error in %s () a NULL pointer was passed.\n")), 01155 __FUNCTION__); 01156 return (EXIT_FAILURE); 01157 } 01158 if (line->linetype_scale < 0.0) 01159 { 01160 fprintf (stderr, 01161 (_("Error in %s () a negative value was found.\n")), 01162 __FUNCTION__); 01163 return (EXIT_FAILURE); 01164 } 01165 #if DEBUG 01166 DXF_DEBUG_END 01167 #endif 01168 return (line->linetype_scale); 01169 } 01170 01171 01178 Dxf3dline * 01179 dxf_3dline_set_linetype_scale 01180 ( 01181 Dxf3dline *line, 01183 double linetype_scale 01185 ) 01186 { 01187 #if DEBUG 01188 DXF_DEBUG_BEGIN 01189 #endif 01190 /* Do some basic checks. */ 01191 if (line == NULL) 01192 { 01193 fprintf (stderr, 01194 (_("Error in %s () a NULL pointer was passed.\n")), 01195 __FUNCTION__); 01196 return (NULL); 01197 } 01198 if (linetype_scale < 0.0) 01199 { 01200 fprintf (stderr, 01201 (_("Error in %s () a negative value was passed.\n")), 01202 __FUNCTION__); 01203 return (NULL); 01204 } 01205 line->linetype_scale = linetype_scale; 01206 #if DEBUG 01207 DXF_DEBUG_END 01208 #endif 01209 return (line); 01210 } 01211 01212 01221 int16_t 01222 dxf_3dline_get_visibility 01223 ( 01224 Dxf3dline *line 01226 ) 01227 { 01228 #if DEBUG 01229 DXF_DEBUG_BEGIN 01230 #endif 01231 /* Do some basic checks. */ 01232 if (line == NULL) 01233 { 01234 fprintf (stderr, 01235 (_("Error in %s () a NULL pointer was passed.\n")), 01236 __FUNCTION__); 01237 return (EXIT_FAILURE); 01238 } 01239 if (line->visibility < 0) 01240 { 01241 fprintf (stderr, 01242 (_("Error in %s () a negative value was found.\n")), 01243 __FUNCTION__); 01244 return (EXIT_FAILURE); 01245 } 01246 if (line->visibility > 1) 01247 { 01248 fprintf (stderr, 01249 (_("Error in %s () an out of range value was found.\n")), 01250 __FUNCTION__); 01251 return (EXIT_FAILURE); 01252 } 01253 #if DEBUG 01254 DXF_DEBUG_END 01255 #endif 01256 return (line->visibility); 01257 } 01258 01259 01266 Dxf3dline * 01267 dxf_3dline_set_visibility 01268 ( 01269 Dxf3dline *line, 01271 int16_t visibility 01273 ) 01274 { 01275 #if DEBUG 01276 DXF_DEBUG_BEGIN 01277 #endif 01278 /* Do some basic checks. */ 01279 if (line == NULL) 01280 { 01281 fprintf (stderr, 01282 (_("Error in %s () a NULL pointer was passed.\n")), 01283 __FUNCTION__); 01284 return (NULL); 01285 } 01286 if (visibility < 0) 01287 { 01288 fprintf (stderr, 01289 (_("Error in %s () a negative value was passed.\n")), 01290 __FUNCTION__); 01291 return (NULL); 01292 } 01293 if (visibility > 1) 01294 { 01295 fprintf (stderr, 01296 (_("Error in %s () an out of range value was passed.\n")), 01297 __FUNCTION__); 01298 return (NULL); 01299 } 01300 line->visibility = visibility; 01301 #if DEBUG 01302 DXF_DEBUG_END 01303 #endif 01304 return (line); 01305 } 01306 01307 01313 int 01314 dxf_3dline_get_color 01315 ( 01316 Dxf3dline *line 01318 ) 01319 { 01320 #if DEBUG 01321 DXF_DEBUG_BEGIN 01322 #endif 01323 /* Do some basic checks. */ 01324 if (line == NULL) 01325 { 01326 fprintf (stderr, 01327 (_("Error in %s () a NULL pointer was passed.\n")), 01328 __FUNCTION__); 01329 return (EXIT_FAILURE); 01330 } 01331 if (line->color < 0) 01332 { 01333 fprintf (stderr, 01334 (_("Warning in %s () a negative value was found.\n")), 01335 __FUNCTION__); 01336 } 01337 #if DEBUG 01338 DXF_DEBUG_END 01339 #endif 01340 return (line->color); 01341 } 01342 01343 01347 Dxf3dline * 01348 dxf_3dline_set_color 01349 ( 01350 Dxf3dline *line, 01352 int color 01354 ) 01355 { 01356 #if DEBUG 01357 DXF_DEBUG_BEGIN 01358 #endif 01359 /* Do some basic checks. */ 01360 if (line == NULL) 01361 { 01362 fprintf (stderr, 01363 (_("Error in %s () a NULL pointer was passed.\n")), 01364 __FUNCTION__); 01365 return (NULL); 01366 } 01367 if (color < 0) 01368 { 01369 fprintf (stderr, 01370 (_("Warning in %s () a negative value was passed.\n")), 01371 __FUNCTION__); 01372 } 01373 line->color = color; 01374 #if DEBUG 01375 DXF_DEBUG_END 01376 #endif 01377 return (line); 01378 } 01379 01380 01386 int 01387 dxf_3dline_get_paperspace 01388 ( 01389 Dxf3dline *line 01391 ) 01392 { 01393 #if DEBUG 01394 DXF_DEBUG_BEGIN 01395 #endif 01396 /* Do some basic checks. */ 01397 if (line == NULL) 01398 { 01399 fprintf (stderr, 01400 (_("Error in %s () a NULL pointer was passed.\n")), 01401 __FUNCTION__); 01402 return (EXIT_FAILURE); 01403 } 01404 if (line->paperspace < 0) 01405 { 01406 fprintf (stderr, 01407 (_("Warning in %s () a negative value was found.\n")), 01408 __FUNCTION__); 01409 } 01410 if (line->paperspace > 1) 01411 { 01412 fprintf (stderr, 01413 (_("Warning in %s () an out of range value was found.\n")), 01414 __FUNCTION__); 01415 } 01416 #if DEBUG 01417 DXF_DEBUG_END 01418 #endif 01419 return (line->paperspace); 01420 } 01421 01422 01429 Dxf3dline * 01430 dxf_3dline_set_paperspace 01431 ( 01432 Dxf3dline *line, 01434 int paperspace 01436 ) 01437 { 01438 #if DEBUG 01439 DXF_DEBUG_BEGIN 01440 #endif 01441 /* Do some basic checks. */ 01442 if (line == NULL) 01443 { 01444 fprintf (stderr, 01445 (_("Error in %s () a NULL pointer was passed.\n")), 01446 __FUNCTION__); 01447 return (NULL); 01448 } 01449 if (paperspace < 0) 01450 { 01451 fprintf (stderr, 01452 (_("Error in %s () a negative value was passed.\n")), 01453 __FUNCTION__); 01454 return (NULL); 01455 } 01456 if (paperspace > 1) 01457 { 01458 fprintf (stderr, 01459 (_("Error in %s () an out of range value was passed.\n")), 01460 __FUNCTION__); 01461 return (NULL); 01462 } 01463 line->paperspace = paperspace; 01464 #if DEBUG 01465 DXF_DEBUG_END 01466 #endif 01467 return (line); 01468 } 01469 01470 01478 int 01479 dxf_3dline_get_graphics_data_size 01480 ( 01481 Dxf3dline *line 01483 ) 01484 { 01485 #if DEBUG 01486 DXF_DEBUG_BEGIN 01487 #endif 01488 /* Do some basic checks. */ 01489 if (line == NULL) 01490 { 01491 fprintf (stderr, 01492 (_("Error in %s () a NULL pointer was passed.\n")), 01493 __FUNCTION__); 01494 return (EXIT_FAILURE); 01495 } 01496 if (line->graphics_data_size < 0) 01497 { 01498 fprintf (stderr, 01499 (_("Warning in %s () a negative value was found.\n")), 01500 __FUNCTION__); 01501 } 01502 if (line->graphics_data_size == 0) 01503 { 01504 fprintf (stderr, 01505 (_("Warning in %s () a zero value was found.\n")), 01506 __FUNCTION__); 01507 } 01508 #if DEBUG 01509 DXF_DEBUG_END 01510 #endif 01511 return (line->graphics_data_size); 01512 } 01513 01514 01522 Dxf3dline * 01523 dxf_3dline_set_graphics_data_size 01524 ( 01525 Dxf3dline *line, 01527 int graphics_data_size 01530 ) 01531 { 01532 #if DEBUG 01533 DXF_DEBUG_BEGIN 01534 #endif 01535 /* Do some basic checks. */ 01536 if (line == NULL) 01537 { 01538 fprintf (stderr, 01539 (_("Error in %s () a NULL pointer was passed.\n")), 01540 __FUNCTION__); 01541 return (NULL); 01542 } 01543 if (graphics_data_size < 0) 01544 { 01545 fprintf (stderr, 01546 (_("Error in %s () a negative value was passed.\n")), 01547 __FUNCTION__); 01548 return (NULL); 01549 } 01550 if (graphics_data_size == 0) 01551 { 01552 fprintf (stderr, 01553 (_("Error in %s () a zero value was passed.\n")), 01554 __FUNCTION__); 01555 return (NULL); 01556 } 01557 line->graphics_data_size = graphics_data_size; 01558 #if DEBUG 01559 DXF_DEBUG_END 01560 #endif 01561 return (line); 01562 } 01563 01564 01571 int16_t 01572 dxf_3dline_get_shadow_mode 01573 ( 01574 Dxf3dline *line 01576 ) 01577 { 01578 #if DEBUG 01579 DXF_DEBUG_BEGIN 01580 #endif 01581 /* Do some basic checks. */ 01582 if (line == NULL) 01583 { 01584 fprintf (stderr, 01585 (_("Error in %s () a NULL pointer was passed.\n")), 01586 __FUNCTION__); 01587 return (EXIT_FAILURE); 01588 } 01589 if (line->shadow_mode < 0) 01590 { 01591 fprintf (stderr, 01592 (_("Error in %s () a negative value was found.\n")), 01593 __FUNCTION__); 01594 return (EXIT_FAILURE); 01595 } 01596 if (line->shadow_mode > 3) 01597 { 01598 fprintf (stderr, 01599 (_("Error in %s () an out of range value was found.\n")), 01600 __FUNCTION__); 01601 return (EXIT_FAILURE); 01602 } 01603 #if DEBUG 01604 DXF_DEBUG_END 01605 #endif 01606 return (line->shadow_mode); 01607 } 01608 01609 01616 Dxf3dline * 01617 dxf_3dline_set_shadow_mode 01618 ( 01619 Dxf3dline *line, 01621 int16_t shadow_mode 01623 ) 01624 { 01625 #if DEBUG 01626 DXF_DEBUG_BEGIN 01627 #endif 01628 /* Do some basic checks. */ 01629 if (line == NULL) 01630 { 01631 fprintf (stderr, 01632 (_("Error in %s () a NULL pointer was passed.\n")), 01633 __FUNCTION__); 01634 return (NULL); 01635 } 01636 if (shadow_mode < 0) 01637 { 01638 fprintf (stderr, 01639 (_("Error in %s () a negative value was passed.\n")), 01640 __FUNCTION__); 01641 return (NULL); 01642 } 01643 if (shadow_mode > 3) 01644 { 01645 fprintf (stderr, 01646 (_("Error in %s () an out of range value was passed.\n")), 01647 __FUNCTION__); 01648 return (NULL); 01649 } 01650 line->shadow_mode = shadow_mode; 01651 #if DEBUG 01652 DXF_DEBUG_END 01653 #endif 01654 return (line); 01655 } 01656 01657 01666 DxfBinaryGraphicsData * 01667 dxf_3dline_get_binary_graphics_data 01668 ( 01669 Dxf3dline *line 01671 ) 01672 { 01673 #if DEBUG 01674 DXF_DEBUG_BEGIN 01675 #endif 01676 /* Do some basic checks. */ 01677 if (line == NULL) 01678 { 01679 fprintf (stderr, 01680 (_("Error in %s () a NULL pointer was passed.\n")), 01681 __FUNCTION__); 01682 return (NULL); 01683 } 01684 if (line->binary_graphics_data == NULL) 01685 { 01686 fprintf (stderr, 01687 (_("Error in %s () a NULL pointer was found.\n")), 01688 __FUNCTION__); 01689 return (NULL); 01690 } 01691 #if DEBUG 01692 DXF_DEBUG_END 01693 #endif 01694 return ((DxfBinaryGraphicsData *) line->binary_graphics_data); 01695 } 01696 01697 01705 Dxf3dline * 01706 dxf_3dline_set_binary_graphics_data 01707 ( 01708 Dxf3dline *line, 01710 DxfBinaryGraphicsData *data 01713 ) 01714 { 01715 #if DEBUG 01716 DXF_DEBUG_BEGIN 01717 #endif 01718 /* Do some basic checks. */ 01719 if (line == NULL) 01720 { 01721 fprintf (stderr, 01722 (_("Error in %s () a NULL pointer was passed.\n")), 01723 __FUNCTION__); 01724 return (NULL); 01725 } 01726 if (data == NULL) 01727 { 01728 fprintf (stderr, 01729 (_("Error in %s () a NULL pointer was passed.\n")), 01730 __FUNCTION__); 01731 return (NULL); 01732 } 01733 line->binary_graphics_data = (DxfBinaryGraphicsData *) data; 01734 #if DEBUG 01735 DXF_DEBUG_END 01736 #endif 01737 return (line); 01738 } 01739 01740 01749 char * 01750 dxf_3dline_get_dictionary_owner_soft 01751 ( 01752 Dxf3dline *line 01754 ) 01755 { 01756 #if DEBUG 01757 DXF_DEBUG_BEGIN 01758 #endif 01759 /* Do some basic checks. */ 01760 if (line == NULL) 01761 { 01762 fprintf (stderr, 01763 (_("Error in %s () a NULL pointer was passed.\n")), 01764 __FUNCTION__); 01765 return (NULL); 01766 } 01767 if (line->dictionary_owner_soft == NULL) 01768 { 01769 fprintf (stderr, 01770 (_("Error in %s () a NULL pointer was found.\n")), 01771 __FUNCTION__); 01772 return (NULL); 01773 } 01774 #if DEBUG 01775 DXF_DEBUG_END 01776 #endif 01777 return (strdup (line->dictionary_owner_soft)); 01778 } 01779 01780 01785 Dxf3dline * 01786 dxf_3dline_set_dictionary_owner_soft 01787 ( 01788 Dxf3dline *line, 01790 char *dictionary_owner_soft 01793 ) 01794 { 01795 #if DEBUG 01796 DXF_DEBUG_BEGIN 01797 #endif 01798 /* Do some basic checks. */ 01799 if (line == NULL) 01800 { 01801 fprintf (stderr, 01802 (_("Error in %s () a NULL pointer was passed.\n")), 01803 __FUNCTION__); 01804 return (NULL); 01805 } 01806 if (dictionary_owner_soft == NULL) 01807 { 01808 fprintf (stderr, 01809 (_("Error in %s () a NULL pointer was passed.\n")), 01810 __FUNCTION__); 01811 return (NULL); 01812 } 01813 line->dictionary_owner_soft = strdup (dictionary_owner_soft); 01814 #if DEBUG 01815 DXF_DEBUG_END 01816 #endif 01817 return (line); 01818 } 01819 01820 01829 char * 01830 dxf_3dline_get_material 01831 ( 01832 Dxf3dline *line 01834 ) 01835 { 01836 #if DEBUG 01837 DXF_DEBUG_BEGIN 01838 #endif 01839 /* Do some basic checks. */ 01840 if (line == NULL) 01841 { 01842 fprintf (stderr, 01843 (_("Error in %s () a NULL pointer was passed.\n")), 01844 __FUNCTION__); 01845 return (NULL); 01846 } 01847 if (line->material == NULL) 01848 { 01849 fprintf (stderr, 01850 (_("Error in %s () a NULL pointer was found.\n")), 01851 __FUNCTION__); 01852 return (NULL); 01853 } 01854 #if DEBUG 01855 DXF_DEBUG_END 01856 #endif 01857 return (strdup (line->material)); 01858 } 01859 01860 01867 Dxf3dline * 01868 dxf_3dline_set_material 01869 ( 01870 Dxf3dline *line, 01872 char *material 01875 ) 01876 { 01877 #if DEBUG 01878 DXF_DEBUG_BEGIN 01879 #endif 01880 /* Do some basic checks. */ 01881 if (line == NULL) 01882 { 01883 fprintf (stderr, 01884 (_("Error in %s () a NULL pointer was passed.\n")), 01885 __FUNCTION__); 01886 return (NULL); 01887 } 01888 if (material == NULL) 01889 { 01890 fprintf (stderr, 01891 (_("Error in %s () a NULL pointer was passed.\n")), 01892 __FUNCTION__); 01893 return (NULL); 01894 } 01895 line->material = strdup (material); 01896 #if DEBUG 01897 DXF_DEBUG_END 01898 #endif 01899 return (line); 01900 } 01901 01902 01911 char * 01912 dxf_3dline_get_dictionary_owner_hard 01913 ( 01914 Dxf3dline *line 01916 ) 01917 { 01918 #if DEBUG 01919 DXF_DEBUG_BEGIN 01920 #endif 01921 /* Do some basic checks. */ 01922 if (line == NULL) 01923 { 01924 fprintf (stderr, 01925 (_("Error in %s () a NULL pointer was passed.\n")), 01926 __FUNCTION__); 01927 return (NULL); 01928 } 01929 if (line->dictionary_owner_hard == NULL) 01930 { 01931 fprintf (stderr, 01932 (_("Error in %s () a NULL pointer was found.\n")), 01933 __FUNCTION__); 01934 return (NULL); 01935 } 01936 #if DEBUG 01937 DXF_DEBUG_END 01938 #endif 01939 return (strdup (line->dictionary_owner_hard)); 01940 } 01941 01942 01947 Dxf3dline * 01948 dxf_3dline_set_dictionary_owner_hard 01949 ( 01950 Dxf3dline *line, 01952 char *dictionary_owner_hard 01955 ) 01956 { 01957 #if DEBUG 01958 DXF_DEBUG_BEGIN 01959 #endif 01960 /* Do some basic checks. */ 01961 if (line == NULL) 01962 { 01963 fprintf (stderr, 01964 (_("Error in %s () a NULL pointer was passed.\n")), 01965 __FUNCTION__); 01966 return (NULL); 01967 } 01968 if (dictionary_owner_hard == NULL) 01969 { 01970 fprintf (stderr, 01971 (_("Error in %s () a NULL pointer was passed.\n")), 01972 __FUNCTION__); 01973 return (NULL); 01974 } 01975 line->dictionary_owner_hard = strdup (dictionary_owner_hard); 01976 #if DEBUG 01977 DXF_DEBUG_END 01978 #endif 01979 return (line); 01980 } 01981 01982 01989 int16_t 01990 dxf_3dline_get_lineweight 01991 ( 01992 Dxf3dline *line 01994 ) 01995 { 01996 #if DEBUG 01997 DXF_DEBUG_BEGIN 01998 #endif 01999 /* Do some basic checks. */ 02000 if (line == NULL) 02001 { 02002 fprintf (stderr, 02003 (_("Error in %s () a NULL pointer was passed.\n")), 02004 __FUNCTION__); 02005 return (EXIT_FAILURE); 02006 } 02007 #if DEBUG 02008 DXF_DEBUG_END 02009 #endif 02010 return (line->lineweight); 02011 } 02012 02013 02020 Dxf3dline * 02021 dxf_3dline_set_lineweight 02022 ( 02023 Dxf3dline *line, 02025 int16_t lineweight 02027 ) 02028 { 02029 #if DEBUG 02030 DXF_DEBUG_BEGIN 02031 #endif 02032 /* Do some basic checks. */ 02033 if (line == NULL) 02034 { 02035 fprintf (stderr, 02036 (_("Error in %s () a NULL pointer was passed.\n")), 02037 __FUNCTION__); 02038 return (NULL); 02039 } 02040 line->lineweight = lineweight; 02041 #if DEBUG 02042 DXF_DEBUG_END 02043 #endif 02044 return (line); 02045 } 02046 02047 02054 char * 02055 dxf_3dline_get_plot_style_name 02056 ( 02057 Dxf3dline *line 02059 ) 02060 { 02061 #if DEBUG 02062 DXF_DEBUG_BEGIN 02063 #endif 02064 /* Do some basic checks. */ 02065 if (line == NULL) 02066 { 02067 fprintf (stderr, 02068 (_("Error in %s () a NULL pointer was passed.\n")), 02069 __FUNCTION__); 02070 return (NULL); 02071 } 02072 if (line->plot_style_name == NULL) 02073 { 02074 fprintf (stderr, 02075 (_("Error in %s () a NULL pointer was found.\n")), 02076 __FUNCTION__); 02077 return (NULL); 02078 } 02079 #if DEBUG 02080 DXF_DEBUG_END 02081 #endif 02082 return (strdup (line->plot_style_name)); 02083 } 02084 02085 02092 Dxf3dline * 02093 dxf_3dline_set_plot_style_name 02094 ( 02095 Dxf3dline *line, 02097 char *plot_style_name 02100 ) 02101 { 02102 #if DEBUG 02103 DXF_DEBUG_BEGIN 02104 #endif 02105 /* Do some basic checks. */ 02106 if (line == NULL) 02107 { 02108 fprintf (stderr, 02109 (_("Error in %s () a NULL pointer was passed.\n")), 02110 __FUNCTION__); 02111 return (NULL); 02112 } 02113 if (plot_style_name == NULL) 02114 { 02115 fprintf (stderr, 02116 (_("Error in %s () a NULL pointer was passed.\n")), 02117 __FUNCTION__); 02118 return (NULL); 02119 } 02120 line->plot_style_name = strdup (plot_style_name); 02121 #if DEBUG 02122 DXF_DEBUG_END 02123 #endif 02124 return (line); 02125 } 02126 02127 02134 long 02135 dxf_3dline_get_color_value 02136 ( 02137 Dxf3dline *line 02139 ) 02140 { 02141 #if DEBUG 02142 DXF_DEBUG_BEGIN 02143 #endif 02144 /* Do some basic checks. */ 02145 if (line == NULL) 02146 { 02147 fprintf (stderr, 02148 (_("Error in %s () a NULL pointer was passed.\n")), 02149 __FUNCTION__); 02150 return (EXIT_FAILURE); 02151 } 02152 #if DEBUG 02153 DXF_DEBUG_END 02154 #endif 02155 return (line->color_value); 02156 } 02157 02158 02165 Dxf3dline * 02166 dxf_3dline_set_color_value 02167 ( 02168 Dxf3dline *line, 02170 long color_value 02172 ) 02173 { 02174 #if DEBUG 02175 DXF_DEBUG_BEGIN 02176 #endif 02177 /* Do some basic checks. */ 02178 if (line == NULL) 02179 { 02180 fprintf (stderr, 02181 (_("Error in %s () a NULL pointer was passed.\n")), 02182 __FUNCTION__); 02183 return (NULL); 02184 } 02185 line->color_value = color_value; 02186 #if DEBUG 02187 DXF_DEBUG_END 02188 #endif 02189 return (line); 02190 } 02191 02192 02199 char * 02200 dxf_3dline_get_color_name 02201 ( 02202 Dxf3dline *line 02204 ) 02205 { 02206 #if DEBUG 02207 DXF_DEBUG_BEGIN 02208 #endif 02209 /* Do some basic checks. */ 02210 if (line == NULL) 02211 { 02212 fprintf (stderr, 02213 (_("Error in %s () a NULL pointer was passed.\n")), 02214 __FUNCTION__); 02215 return (NULL); 02216 } 02217 if (line->color_name == NULL) 02218 { 02219 fprintf (stderr, 02220 (_("Error in %s () a NULL pointer was found.\n")), 02221 __FUNCTION__); 02222 return (NULL); 02223 } 02224 #if DEBUG 02225 DXF_DEBUG_END 02226 #endif 02227 return (strdup (line->color_name)); 02228 } 02229 02230 02237 Dxf3dline * 02238 dxf_3dline_set_color_name 02239 ( 02240 Dxf3dline *line, 02242 char *color_name 02245 ) 02246 { 02247 #if DEBUG 02248 DXF_DEBUG_BEGIN 02249 #endif 02250 /* Do some basic checks. */ 02251 if (line == NULL) 02252 { 02253 fprintf (stderr, 02254 (_("Error in %s () a NULL pointer was passed.\n")), 02255 __FUNCTION__); 02256 return (NULL); 02257 } 02258 if (color_name == NULL) 02259 { 02260 fprintf (stderr, 02261 (_("Error in %s () a NULL pointer was passed.\n")), 02262 __FUNCTION__); 02263 return (NULL); 02264 } 02265 line->color_name = strdup (color_name); 02266 #if DEBUG 02267 DXF_DEBUG_END 02268 #endif 02269 return (line); 02270 } 02271 02272 02279 long 02280 dxf_3dline_get_transparency 02281 ( 02282 Dxf3dline *line 02284 ) 02285 { 02286 #if DEBUG 02287 DXF_DEBUG_BEGIN 02288 #endif 02289 /* Do some basic checks. */ 02290 if (line == NULL) 02291 { 02292 fprintf (stderr, 02293 (_("Error in %s () a NULL pointer was passed.\n")), 02294 __FUNCTION__); 02295 return (EXIT_FAILURE); 02296 } 02297 #if DEBUG 02298 DXF_DEBUG_END 02299 #endif 02300 return (line->transparency); 02301 } 02302 02303 02310 Dxf3dline * 02311 dxf_3dline_set_transparency 02312 ( 02313 Dxf3dline *line, 02315 long transparency 02317 ) 02318 { 02319 #if DEBUG 02320 DXF_DEBUG_BEGIN 02321 #endif 02322 /* Do some basic checks. */ 02323 if (line == NULL) 02324 { 02325 fprintf (stderr, 02326 (_("Error in %s () a NULL pointer was passed.\n")), 02327 __FUNCTION__); 02328 return (NULL); 02329 } 02330 line->transparency = transparency; 02331 #if DEBUG 02332 DXF_DEBUG_END 02333 #endif 02334 return (line); 02335 } 02336 02337 02343 DxfPoint * 02344 dxf_3dline_get_p0 02345 ( 02346 Dxf3dline *line 02348 ) 02349 { 02350 #ifdef DEBUG 02351 DXF_DEBUG_BEGIN 02352 #endif 02353 /* Do some basic checks. */ 02354 if (line == NULL) 02355 { 02356 fprintf (stderr, 02357 (_("Error in %s () a NULL pointer was passed.\n")), 02358 __FUNCTION__); 02359 return (NULL); 02360 } 02361 if (line->p0 == NULL) 02362 { 02363 fprintf (stderr, 02364 (_("Error in %s () a NULL pointer was found.\n")), 02365 __FUNCTION__); 02366 return (NULL); 02367 } 02368 #if DEBUG 02369 DXF_DEBUG_END 02370 #endif 02371 return (line->p0); 02372 } 02373 02374 02380 Dxf3dline * 02381 dxf_3dline_set_p0 02382 ( 02383 Dxf3dline *line, 02385 DxfPoint *p0 02387 ) 02388 { 02389 #ifdef DEBUG 02390 DXF_DEBUG_BEGIN 02391 #endif 02392 /* Do some basic checks. */ 02393 if (line == NULL) 02394 { 02395 fprintf (stderr, 02396 (_("Error in %s () a NULL pointer was passed.\n")), 02397 __FUNCTION__); 02398 return (NULL); 02399 } 02400 if (p0 == NULL) 02401 { 02402 fprintf (stderr, 02403 (_("Error in %s () a NULL pointer was passed.\n")), 02404 __FUNCTION__); 02405 return (NULL); 02406 } 02407 line->p0 = (DxfPoint *) p0; 02408 #if DEBUG 02409 DXF_DEBUG_END 02410 #endif 02411 return (line); 02412 } 02413 02414 02420 double 02421 dxf_3dline_get_x0 02422 ( 02423 Dxf3dline *line 02425 ) 02426 { 02427 #ifdef DEBUG 02428 DXF_DEBUG_BEGIN 02429 #endif 02430 02431 /* Do some basic checks. */ 02432 if (line == NULL) 02433 { 02434 fprintf (stderr, 02435 (_("Error in %s () a NULL pointer was passed.\n")), 02436 __FUNCTION__); 02437 return (EXIT_FAILURE); 02438 } 02439 if (line->p0 == NULL) 02440 { 02441 fprintf (stderr, 02442 (_("Error in %s () a NULL pointer was found.\n")), 02443 __FUNCTION__); 02444 return (EXIT_FAILURE); 02445 } 02446 #if DEBUG 02447 DXF_DEBUG_END 02448 #endif 02449 return (line->p0->x0); 02450 } 02451 02452 02458 Dxf3dline * 02459 dxf_3dline_set_x0 02460 ( 02461 Dxf3dline *line, 02463 double x0 02466 ) 02467 { 02468 #ifdef DEBUG 02469 DXF_DEBUG_BEGIN 02470 #endif 02471 /* Do some basic checks. */ 02472 if (line == NULL) 02473 { 02474 fprintf (stderr, 02475 (_("Error in %s () a NULL pointer was passed.\n")), 02476 __FUNCTION__); 02477 return (NULL); 02478 } 02479 if (line->p0 == NULL) 02480 { 02481 fprintf (stderr, 02482 (_("Error in %s () a NULL pointer was found.\n")), 02483 __FUNCTION__); 02484 return (NULL); 02485 } 02486 line->p0->x0 = x0; 02487 #if DEBUG 02488 DXF_DEBUG_END 02489 #endif 02490 return (line); 02491 } 02492 02493 02499 double 02500 dxf_3dline_get_y0 02501 ( 02502 Dxf3dline *line 02504 ) 02505 { 02506 #ifdef DEBUG 02507 DXF_DEBUG_BEGIN 02508 #endif 02509 02510 /* Do some basic checks. */ 02511 if (line == NULL) 02512 { 02513 fprintf (stderr, 02514 (_("Error in %s () a NULL pointer was passed.\n")), 02515 __FUNCTION__); 02516 return (EXIT_FAILURE); 02517 } 02518 if (line->p0 == NULL) 02519 { 02520 fprintf (stderr, 02521 (_("Error in %s () a NULL pointer was found.\n")), 02522 __FUNCTION__); 02523 return (EXIT_FAILURE); 02524 } 02525 #if DEBUG 02526 DXF_DEBUG_END 02527 #endif 02528 return (line->p0->y0); 02529 } 02530 02531 02537 Dxf3dline * 02538 dxf_3dline_set_y0 02539 ( 02540 Dxf3dline *line, 02542 double y0 02545 ) 02546 { 02547 #ifdef DEBUG 02548 DXF_DEBUG_BEGIN 02549 #endif 02550 /* Do some basic checks. */ 02551 if (line == NULL) 02552 { 02553 fprintf (stderr, 02554 (_("Error in %s () a NULL pointer was passed.\n")), 02555 __FUNCTION__); 02556 return (NULL); 02557 } 02558 if (line->p0 == NULL) 02559 { 02560 fprintf (stderr, 02561 (_("Error in %s () a NULL pointer was found.\n")), 02562 __FUNCTION__); 02563 return (NULL); 02564 } 02565 line->p0->y0 = y0; 02566 #if DEBUG 02567 DXF_DEBUG_END 02568 #endif 02569 return (line); 02570 } 02571 02572 02578 double 02579 dxf_3dline_get_z0 02580 ( 02581 Dxf3dline *line 02583 ) 02584 { 02585 #ifdef DEBUG 02586 DXF_DEBUG_BEGIN 02587 #endif 02588 02589 /* Do some basic checks. */ 02590 if (line == NULL) 02591 { 02592 fprintf (stderr, 02593 (_("Error in %s () a NULL pointer was passed.\n")), 02594 __FUNCTION__); 02595 return (EXIT_FAILURE); 02596 } 02597 if (line->p0 == NULL) 02598 { 02599 fprintf (stderr, 02600 (_("Error in %s () a NULL pointer was found.\n")), 02601 __FUNCTION__); 02602 return (EXIT_FAILURE); 02603 } 02604 #if DEBUG 02605 DXF_DEBUG_END 02606 #endif 02607 return (line->p0->z0); 02608 } 02609 02610 02616 Dxf3dline * 02617 dxf_3dline_set_z0 02618 ( 02619 Dxf3dline *line, 02621 double z0 02624 ) 02625 { 02626 #ifdef DEBUG 02627 DXF_DEBUG_BEGIN 02628 #endif 02629 /* Do some basic checks. */ 02630 if (line == NULL) 02631 { 02632 fprintf (stderr, 02633 (_("Error in %s () a NULL pointer was passed.\n")), 02634 __FUNCTION__); 02635 return (NULL); 02636 } 02637 if (line->p0 == NULL) 02638 { 02639 fprintf (stderr, 02640 (_("Error in %s () a NULL pointer was found.\n")), 02641 __FUNCTION__); 02642 return (NULL); 02643 } 02644 line->p0->z0 = z0; 02645 #if DEBUG 02646 DXF_DEBUG_END 02647 #endif 02648 return (line); 02649 } 02650 02651 02657 DxfPoint * 02658 dxf_3dline_get_p1 02659 ( 02660 Dxf3dline *line 02662 ) 02663 { 02664 #ifdef DEBUG 02665 DXF_DEBUG_BEGIN 02666 #endif 02667 /* Do some basic checks. */ 02668 if (line == NULL) 02669 { 02670 fprintf (stderr, 02671 (_("Error in %s () a NULL pointer was passed.\n")), 02672 __FUNCTION__); 02673 return (NULL); 02674 } 02675 if (line->p1 == NULL) 02676 { 02677 fprintf (stderr, 02678 (_("Error in %s () a NULL pointer was found.\n")), 02679 __FUNCTION__); 02680 return (NULL); 02681 } 02682 if ((line->p0->x0 == line->p1->x0) 02683 && (line->p0->y0 == line->p1->y0) 02684 && (line->p0->z0 == line->p1->z0)) 02685 { 02686 fprintf (stderr, 02687 (_("Warning in %s () a 3DLINE with points with identical coordinates were passed.\n")), 02688 __FUNCTION__); 02689 } 02690 #if DEBUG 02691 DXF_DEBUG_END 02692 #endif 02693 return (line->p1); 02694 } 02695 02696 02702 Dxf3dline * 02703 dxf_3dline_set_p1 02704 ( 02705 Dxf3dline *line, 02707 DxfPoint *p1 02709 ) 02710 { 02711 #ifdef DEBUG 02712 DXF_DEBUG_BEGIN 02713 #endif 02714 /* Do some basic checks. */ 02715 if (line == NULL) 02716 { 02717 fprintf (stderr, 02718 (_("Error in %s () a NULL pointer was passed.\n")), 02719 __FUNCTION__); 02720 return (NULL); 02721 } 02722 if (p1 == NULL) 02723 { 02724 fprintf (stderr, 02725 (_("Error in %s () a NULL pointer was passed.\n")), 02726 __FUNCTION__); 02727 return (NULL); 02728 } 02729 line->p1 = (DxfPoint *) p1; 02730 #if DEBUG 02731 DXF_DEBUG_END 02732 #endif 02733 return (line); 02734 } 02735 02736 02742 double 02743 dxf_3dline_get_x1 02744 ( 02745 Dxf3dline *line 02747 ) 02748 { 02749 #ifdef DEBUG 02750 DXF_DEBUG_BEGIN 02751 #endif 02752 02753 /* Do some basic checks. */ 02754 if (line == NULL) 02755 { 02756 fprintf (stderr, 02757 (_("Error in %s () a NULL pointer was passed.\n")), 02758 __FUNCTION__); 02759 return (EXIT_FAILURE); 02760 } 02761 if (line->p1 == NULL) 02762 { 02763 fprintf (stderr, 02764 (_("Error in %s () a NULL pointer was found.\n")), 02765 __FUNCTION__); 02766 return (EXIT_FAILURE); 02767 } 02768 #if DEBUG 02769 DXF_DEBUG_END 02770 #endif 02771 return (line->p1->x0); 02772 } 02773 02774 02780 Dxf3dline * 02781 dxf_3dline_set_x1 02782 ( 02783 Dxf3dline *line, 02785 double x1 02788 ) 02789 { 02790 #ifdef DEBUG 02791 DXF_DEBUG_BEGIN 02792 #endif 02793 /* Do some basic checks. */ 02794 if (line == NULL) 02795 { 02796 fprintf (stderr, 02797 (_("Error in %s () a NULL pointer was passed.\n")), 02798 __FUNCTION__); 02799 return (NULL); 02800 } 02801 if (line->p1 == NULL) 02802 { 02803 fprintf (stderr, 02804 (_("Error in %s () a NULL pointer was found.\n")), 02805 __FUNCTION__); 02806 return (NULL); 02807 } 02808 line->p1->x0 = x1; 02809 #if DEBUG 02810 DXF_DEBUG_END 02811 #endif 02812 return (line); 02813 } 02814 02815 02821 double 02822 dxf_3dline_get_y1 02823 ( 02824 Dxf3dline *line 02826 ) 02827 { 02828 #ifdef DEBUG 02829 DXF_DEBUG_BEGIN 02830 #endif 02831 02832 /* Do some basic checks. */ 02833 if (line == NULL) 02834 { 02835 fprintf (stderr, 02836 (_("Error in %s () a NULL pointer was passed.\n")), 02837 __FUNCTION__); 02838 return (EXIT_FAILURE); 02839 } 02840 if (line->p1 == NULL) 02841 { 02842 fprintf (stderr, 02843 (_("Error in %s () a NULL pointer was found.\n")), 02844 __FUNCTION__); 02845 return (EXIT_FAILURE); 02846 } 02847 #if DEBUG 02848 DXF_DEBUG_END 02849 #endif 02850 return (line->p1->y0); 02851 } 02852 02853 02859 Dxf3dline * 02860 dxf_3dline_set_y1 02861 ( 02862 Dxf3dline *line, 02864 double y1 02867 ) 02868 { 02869 #ifdef DEBUG 02870 DXF_DEBUG_BEGIN 02871 #endif 02872 /* Do some basic checks. */ 02873 if (line == NULL) 02874 { 02875 fprintf (stderr, 02876 (_("Error in %s () a NULL pointer was passed.\n")), 02877 __FUNCTION__); 02878 return (NULL); 02879 } 02880 if (line->p1 == NULL) 02881 { 02882 fprintf (stderr, 02883 (_("Error in %s () a NULL pointer was found.\n")), 02884 __FUNCTION__); 02885 return (NULL); 02886 } 02887 line->p1->y0 = y1; 02888 #if DEBUG 02889 DXF_DEBUG_END 02890 #endif 02891 return (line); 02892 } 02893 02894 02900 double 02901 dxf_3dline_get_z1 02902 ( 02903 Dxf3dline *line 02905 ) 02906 { 02907 #ifdef DEBUG 02908 DXF_DEBUG_BEGIN 02909 #endif 02910 02911 /* Do some basic checks. */ 02912 if (line == NULL) 02913 { 02914 fprintf (stderr, 02915 (_("Error in %s () a NULL pointer was passed.\n")), 02916 __FUNCTION__); 02917 return (EXIT_FAILURE); 02918 } 02919 if (line->p1 == NULL) 02920 { 02921 fprintf (stderr, 02922 (_("Error in %s () a NULL pointer was found.\n")), 02923 __FUNCTION__); 02924 return (EXIT_FAILURE); 02925 } 02926 #if DEBUG 02927 DXF_DEBUG_END 02928 #endif 02929 return (line->p1->z0); 02930 } 02931 02932 02938 Dxf3dline * 02939 dxf_3dline_set_z1 02940 ( 02941 Dxf3dline *line, 02943 double z1 02946 ) 02947 { 02948 #ifdef DEBUG 02949 DXF_DEBUG_BEGIN 02950 #endif 02951 /* Do some basic checks. */ 02952 if (line == NULL) 02953 { 02954 fprintf (stderr, 02955 (_("Error in %s () a NULL pointer was passed.\n")), 02956 __FUNCTION__); 02957 return (NULL); 02958 } 02959 if (line->p1 == NULL) 02960 { 02961 fprintf (stderr, 02962 (_("Error in %s () a NULL pointer was found.\n")), 02963 __FUNCTION__); 02964 return (NULL); 02965 } 02966 line->p1->z0 = z1; 02967 #if DEBUG 02968 DXF_DEBUG_END 02969 #endif 02970 return (line); 02971 } 02972 02973 02980 double 02981 dxf_3dline_get_extr_x0 02982 ( 02983 Dxf3dline *line 02985 ) 02986 { 02987 #ifdef DEBUG 02988 DXF_DEBUG_BEGIN 02989 #endif 02990 02991 /* Do some basic checks. */ 02992 if (line == NULL) 02993 { 02994 fprintf (stderr, 02995 (_("Error in %s () a NULL pointer was passed.\n")), 02996 __FUNCTION__); 02997 return (EXIT_FAILURE); 02998 } 02999 #if DEBUG 03000 DXF_DEBUG_END 03001 #endif 03002 return (line->extr_x0); 03003 } 03004 03005 03013 Dxf3dline * 03014 dxf_3dline_set_extr_x0 03015 ( 03016 Dxf3dline *line, 03018 double extr_x0 03021 ) 03022 { 03023 #ifdef DEBUG 03024 DXF_DEBUG_BEGIN 03025 #endif 03026 /* Do some basic checks. */ 03027 if (line == NULL) 03028 { 03029 fprintf (stderr, 03030 (_("Error in %s () a NULL pointer was passed.\n")), 03031 __FUNCTION__); 03032 return (NULL); 03033 } 03034 line->extr_x0 = extr_x0; 03035 #if DEBUG 03036 DXF_DEBUG_END 03037 #endif 03038 return (line); 03039 } 03040 03041 03048 double 03049 dxf_3dline_get_extr_y0 03050 ( 03051 Dxf3dline *line 03053 ) 03054 { 03055 #ifdef DEBUG 03056 DXF_DEBUG_BEGIN 03057 #endif 03058 03059 /* Do some basic checks. */ 03060 if (line == NULL) 03061 { 03062 fprintf (stderr, 03063 (_("Error in %s () a NULL pointer was passed.\n")), 03064 __FUNCTION__); 03065 return (EXIT_FAILURE); 03066 } 03067 #if DEBUG 03068 DXF_DEBUG_END 03069 #endif 03070 return (line->extr_y0); 03071 } 03072 03073 03081 Dxf3dline * 03082 dxf_3dline_set_extr_y0 03083 ( 03084 Dxf3dline *line, 03086 double extr_y0 03089 ) 03090 { 03091 #ifdef DEBUG 03092 DXF_DEBUG_BEGIN 03093 #endif 03094 /* Do some basic checks. */ 03095 if (line == NULL) 03096 { 03097 fprintf (stderr, 03098 (_("Error in %s () a NULL pointer was passed.\n")), 03099 __FUNCTION__); 03100 return (NULL); 03101 } 03102 line->extr_y0 = extr_y0; 03103 #if DEBUG 03104 DXF_DEBUG_END 03105 #endif 03106 return (line); 03107 } 03108 03109 03116 double 03117 dxf_3dline_get_extr_z0 03118 ( 03119 Dxf3dline *line 03121 ) 03122 { 03123 #ifdef DEBUG 03124 DXF_DEBUG_BEGIN 03125 #endif 03126 03127 /* Do some basic checks. */ 03128 if (line == NULL) 03129 { 03130 fprintf (stderr, 03131 (_("Error in %s () a NULL pointer was passed.\n")), 03132 __FUNCTION__); 03133 return (EXIT_FAILURE); 03134 } 03135 #if DEBUG 03136 DXF_DEBUG_END 03137 #endif 03138 return (line->extr_z0); 03139 } 03140 03141 03149 Dxf3dline * 03150 dxf_3dline_set_extr_z0 03151 ( 03152 Dxf3dline *line, 03154 double extr_z0 03157 ) 03158 { 03159 #ifdef DEBUG 03160 DXF_DEBUG_BEGIN 03161 #endif 03162 /* Do some basic checks. */ 03163 if (line == NULL) 03164 { 03165 fprintf (stderr, 03166 (_("Error in %s () a NULL pointer was passed.\n")), 03167 __FUNCTION__); 03168 return (NULL); 03169 } 03170 line->extr_z0 = extr_z0; 03171 #if DEBUG 03172 DXF_DEBUG_END 03173 #endif 03174 return (line); 03175 } 03176 03177 03186 DxfPoint * 03187 dxf_3dline_get_extrusion_vector_as_point 03188 ( 03189 Dxf3dline *line 03191 ) 03192 { 03193 #ifdef DEBUG 03194 DXF_DEBUG_BEGIN 03195 #endif 03196 DxfPoint *point = NULL; 03197 03198 /* Do some basic checks. */ 03199 if (line == NULL) 03200 { 03201 fprintf (stderr, 03202 (_("Error in %s () a NULL pointer was passed.\n")), 03203 __FUNCTION__); 03204 return (NULL); 03205 } 03206 if ((line->p0->x0 == line->p1->x0) 03207 && (line->p0->y0 == line->p1->y0) 03208 && (line->p0->z0 == line->p1->z0)) 03209 { 03210 fprintf (stderr, 03211 (_("Error in %s () a 3DLINE with points with identical coordinates were passed.\n")), 03212 __FUNCTION__); 03213 return (NULL); 03214 } 03215 point = dxf_point_init (point); 03216 if (point == NULL) 03217 { 03218 fprintf (stderr, 03219 (_("Error in %s () could not allocate memory.\n")), 03220 __FUNCTION__); 03221 return (NULL); 03222 } 03223 point->x0 = line->extr_x0; 03224 point->y0 = line->extr_y0; 03225 point->z0 = line->extr_z0; 03226 #if DEBUG 03227 DXF_DEBUG_END 03228 #endif 03229 return (point); 03230 } 03231 03232 03237 Dxf3dline * 03238 dxf_3dline_set_extrusion_vector_from_point 03239 ( 03240 Dxf3dline *line, 03242 DxfPoint *point 03244 ) 03245 { 03246 #if DEBUG 03247 DXF_DEBUG_BEGIN 03248 #endif 03249 /* Do some basic checks. */ 03250 if (line == NULL) 03251 { 03252 fprintf (stderr, 03253 (_("Error in %s () a NULL pointer was passed.\n")), 03254 __FUNCTION__); 03255 return (NULL); 03256 } 03257 if (point == NULL) 03258 { 03259 fprintf (stderr, 03260 (_("Error in %s () a NULL pointer was passed.\n")), 03261 __FUNCTION__); 03262 return (NULL); 03263 } 03264 line->extr_x0 = (double) point->x0; 03265 line->extr_y0 = (double) point->y0; 03266 line->extr_z0 = (double) point->z0; 03267 #if DEBUG 03268 DXF_DEBUG_END 03269 #endif 03270 return (line); 03271 } 03272 03273 03277 Dxf3dline * 03278 dxf_3dline_set_extrusion_vector 03279 ( 03280 Dxf3dline *line, 03282 double extr_x0, 03284 double extr_y0, 03286 double extr_z0 03288 ) 03289 { 03290 #if DEBUG 03291 DXF_DEBUG_BEGIN 03292 #endif 03293 /* Do some basic checks. */ 03294 if (line == NULL) 03295 { 03296 fprintf (stderr, 03297 (_("Error in %s () a NULL pointer was passed.\n")), 03298 __FUNCTION__); 03299 return (NULL); 03300 } 03301 line->extr_x0 = extr_x0; 03302 line->extr_y0 = extr_y0; 03303 line->extr_z0 = extr_z0; 03304 #if DEBUG 03305 DXF_DEBUG_END 03306 #endif 03307 return (line); 03308 } 03309 03310 03316 DxfPoint * 03317 dxf_3dline_get_mid_point 03318 ( 03319 Dxf3dline *line, 03321 int id_code, 03325 int inheritance 03333 ) 03334 { 03335 #ifdef DEBUG 03336 DXF_DEBUG_BEGIN 03337 #endif 03338 DxfPoint *point = NULL; 03339 03340 /* Do some basic checks. */ 03341 if (line == NULL) 03342 { 03343 fprintf (stderr, 03344 (_("Error in %s () a NULL pointer was passed.\n")), 03345 __FUNCTION__); 03346 return (NULL); 03347 } 03348 if ((line->p0->x0 == line->p1->x0) 03349 && (line->p0->y0 == line->p1->y0) 03350 && (line->p0->z0 == line->p1->z0)) 03351 { 03352 fprintf (stderr, 03353 (_("Error in %s () a 3DLINE with points with identical coordinates were passed.\n")), 03354 __FUNCTION__); 03355 return (NULL); 03356 } 03357 point = dxf_point_init (point); 03358 if (point == NULL) 03359 { 03360 fprintf (stderr, 03361 (_("Error in %s () could not allocate memory.\n")), 03362 __FUNCTION__); 03363 return (NULL); 03364 } 03365 if (id_code < 0) 03366 { 03367 fprintf (stderr, 03368 (_("Warning in %s () a negative value was passed.\n")), 03369 __FUNCTION__); 03370 } 03371 point->id_code = id_code; 03372 point->x0 = (line->p0->x0 + line->p1->x0) / 2; 03373 point->y0 = (line->p0->y0 + line->p1->y0) / 2; 03374 point->z0 = (line->p0->z0 + line->p1->z0) / 2; 03375 switch (inheritance) 03376 { 03377 case 0: 03378 /* Do nothing. */ 03379 break; 03380 case 1: 03381 if (line->linetype != NULL) 03382 { 03383 point->linetype = strdup (line->linetype); 03384 } 03385 if (line->layer != NULL) 03386 { 03387 point->layer = strdup (line->layer); 03388 } 03389 point->thickness = line->thickness; 03390 point->linetype_scale = line->linetype_scale; 03391 point->visibility = line->visibility; 03392 point->color = line->color; 03393 point->paperspace = line->paperspace; 03394 if (line->dictionary_owner_soft != NULL) 03395 { 03396 point->dictionary_owner_soft = strdup (line->dictionary_owner_soft); 03397 } 03398 if (line->dictionary_owner_hard != NULL) 03399 { 03400 point->dictionary_owner_hard = strdup (line->dictionary_owner_hard); 03401 } 03402 break; 03403 default: 03404 fprintf (stderr, 03405 (_("Warning in %s (): unknown inheritance option passed.\n")), 03406 __FUNCTION__); 03407 fprintf (stderr, 03408 (_("\tResolving to default.\n"))); 03409 break; 03410 } 03411 #if DEBUG 03412 DXF_DEBUG_END 03413 #endif 03414 return (point); 03415 } 03416 03417 03424 double 03425 dxf_3dline_get_length 03426 ( 03427 Dxf3dline *line 03429 ) 03430 { 03431 #ifdef DEBUG 03432 DXF_DEBUG_BEGIN 03433 #endif 03434 /* Do some basic checks. */ 03435 if (line == NULL) 03436 { 03437 fprintf (stderr, 03438 (_("Error in %s () a NULL pointer was passed.\n")), 03439 __FUNCTION__); 03440 return (0.0); 03441 } 03442 if ((line->p0->x0 == line->p1->x0) 03443 && (line->p0->y0 == line->p1->y0) 03444 && (line->p0->z0 == line->p1->z0)) 03445 { 03446 fprintf (stderr, 03447 (_("Error in %s () endpoints with identical coordinates were passed.\n")), 03448 __FUNCTION__); 03449 return (0.0); 03450 } 03451 #if DEBUG 03452 DXF_DEBUG_END 03453 #endif 03454 return (sqrt ( 03455 ((line->p1->x0 - line->p0->x0) * (line->p1->x0 - line->p0->x0)) 03456 + ((line->p1->y0 - line->p0->y0) * (line->p1->y0 - line->p0->y0)) 03457 + ((line->p1->z0 - line->p0->z0) * (line->p1->z0 - line->p0->z0)) 03458 ) 03459 ); 03460 } 03461 03462 03471 Dxf3dline * 03472 dxf_3dline_create_from_points 03473 ( 03474 DxfPoint *p0, 03476 DxfPoint *p1, 03478 int id_code, 03482 int inheritance 03491 ) 03492 { 03493 #if DEBUG 03494 DXF_DEBUG_BEGIN 03495 #endif 03496 Dxf3dline *line = NULL; 03497 03498 /* Do some basic checks. */ 03499 if ((p0 == NULL) || (p1 == NULL)) 03500 { 03501 fprintf (stderr, 03502 (_("Error in %s () a NULL pointer was passed.\n")), 03503 __FUNCTION__); 03504 return (NULL); 03505 } 03506 if ((p0->x0 == p1->x0) && (p0->y0 == p1->y0) && (p0->z0 == p1->z0)) 03507 { 03508 fprintf (stderr, 03509 (_("Error in %s () points with identical coordinates were passed.\n")), 03510 __FUNCTION__); 03511 return (NULL); 03512 } 03513 if ((inheritance < 0) || (inheritance > 2)) 03514 { 03515 fprintf (stderr, 03516 (_("Error in %s () an illegal inherit value was passed.\n")), 03517 __FUNCTION__); 03518 return (NULL); 03519 } 03520 line = dxf_3dline_init (line); 03521 if (line == NULL) 03522 { 03523 fprintf (stderr, 03524 (_("Error in %s () could not allocate memory.\n")), 03525 __FUNCTION__); 03526 return (NULL); 03527 } 03528 if (id_code < 0) 03529 { 03530 fprintf (stderr, 03531 (_("Warning in %s () a negative value was passed.\n")), 03532 __FUNCTION__); 03533 } 03534 line->id_code = id_code; 03535 line->p0->x0 = p0->x0; 03536 line->p0->y0 = p0->y0; 03537 line->p0->z0 = p0->z0; 03538 line->p1->x0 = p1->x0; 03539 line->p1->y0 = p1->y0; 03540 line->p1->z0 = p1->z0; 03541 switch (inheritance) 03542 { 03543 case 0: 03544 /* Do nothing. */ 03545 break; 03546 case 1: 03547 if (p0->linetype != NULL) 03548 { 03549 line->linetype = p0->linetype; 03550 } 03551 if (p0->layer != NULL) 03552 { 03553 line->layer = p0->layer; 03554 } 03555 line->thickness = p0->thickness; 03556 line->linetype_scale = p0->linetype_scale; 03557 line->visibility = p0->visibility; 03558 line->color = p0->color; 03559 line->paperspace = p0->paperspace; 03560 if (p0->dictionary_owner_soft != NULL) 03561 { 03562 line->dictionary_owner_soft = strdup (p0->dictionary_owner_soft); 03563 } 03564 if (p0->dictionary_owner_hard != NULL) 03565 { 03566 line->dictionary_owner_hard = strdup (p0->dictionary_owner_hard); 03567 } 03568 break; 03569 case 2: 03570 if (p1->linetype != NULL) 03571 { 03572 line->linetype = p1->linetype; 03573 } 03574 if (p1->layer != NULL) 03575 { 03576 line->layer = p1->layer; 03577 } 03578 line->thickness = p1->thickness; 03579 line->linetype_scale = p1->linetype_scale; 03580 line->visibility = p1->visibility; 03581 line->color = p1->color; 03582 line->paperspace = p1->paperspace; 03583 if (p1->dictionary_owner_soft != NULL) 03584 { 03585 line->dictionary_owner_soft = strdup (p1->dictionary_owner_soft); 03586 } 03587 if (p1->dictionary_owner_hard != NULL) 03588 { 03589 line->dictionary_owner_hard = strdup (p1->dictionary_owner_hard); 03590 } 03591 break; 03592 default: 03593 fprintf (stderr, 03594 (_("Warning in %s (): unknown inheritance option passed.\n")), 03595 __FUNCTION__); 03596 fprintf (stderr, 03597 (_("\tResolving to default.\n"))); 03598 break; 03599 } 03600 #if DEBUG 03601 DXF_DEBUG_END 03602 #endif 03603 return (line); 03604 } 03605 03606 03615 Dxf3dline * 03616 dxf_3dline_get_next 03617 ( 03618 Dxf3dline *line 03620 ) 03621 { 03622 #if DEBUG 03623 DXF_DEBUG_BEGIN 03624 #endif 03625 /* Do some basic checks. */ 03626 if (line == NULL) 03627 { 03628 fprintf (stderr, 03629 (_("Error in %s () a NULL pointer was passed.\n")), 03630 __FUNCTION__); 03631 return (NULL); 03632 } 03633 if (line->next == NULL) 03634 { 03635 fprintf (stderr, 03636 (_("Error in %s () a NULL pointer was found.\n")), 03637 __FUNCTION__); 03638 return (NULL); 03639 } 03640 #if DEBUG 03641 DXF_DEBUG_END 03642 #endif 03643 return ((Dxf3dline *) line->next); 03644 } 03645 03646 03651 Dxf3dline * 03652 dxf_3dline_set_next 03653 ( 03654 Dxf3dline *line, 03656 Dxf3dline *next 03658 ) 03659 { 03660 #if DEBUG 03661 DXF_DEBUG_BEGIN 03662 #endif 03663 /* Do some basic checks. */ 03664 if (line == NULL) 03665 { 03666 fprintf (stderr, 03667 (_("Error in %s () a NULL pointer was passed.\n")), 03668 __FUNCTION__); 03669 return (NULL); 03670 } 03671 if (next == NULL) 03672 { 03673 fprintf (stderr, 03674 (_("Error in %s () a NULL pointer was passed.\n")), 03675 __FUNCTION__); 03676 return (NULL); 03677 } 03678 line->next = (struct Dxf3dline *) next; 03679 #if DEBUG 03680 DXF_DEBUG_END 03681 #endif 03682 return (line); 03683 } 03684 03685 03694 Dxf3dline * 03695 dxf_3dline_get_last 03696 ( 03697 Dxf3dline *line 03699 ) 03700 { 03701 #if DEBUG 03702 DXF_DEBUG_BEGIN 03703 #endif 03704 /* Do some basic checks. */ 03705 if (line == NULL) 03706 { 03707 fprintf (stderr, 03708 (_("Error in %s () a NULL pointer was passed.\n")), 03709 __FUNCTION__); 03710 return (NULL); 03711 } 03712 if (line->next == NULL) 03713 { 03714 fprintf (stderr, 03715 (_("Warning in %s () a NULL pointer was found.\n")), 03716 __FUNCTION__); 03717 return ((Dxf3dline *) line); 03718 } 03719 Dxf3dline *iter = (Dxf3dline *) line->next; 03720 while (iter->next != NULL) 03721 { 03722 iter = (Dxf3dline *) iter->next; 03723 } 03724 #if DEBUG 03725 DXF_DEBUG_END 03726 #endif 03727 return ((Dxf3dline *) iter); 03728 } 03729 03730 03731 /* EOF */