libDXF 0.0.1
A library with DXF related functions written in C.
|
00001 00045 #include "imagedef.h" 00046 00047 00053 DxfImagedef * 00054 dxf_imagedef_new () 00055 { 00056 #if DEBUG 00057 DXF_DEBUG_BEGIN 00058 #endif 00059 DxfImagedef *imagedef = NULL; 00060 size_t size; 00061 00062 size = sizeof (DxfImagedef); 00063 /* avoid malloc of 0 bytes */ 00064 if (size == 0) size = 1; 00065 if ((imagedef = malloc (size)) == NULL) 00066 { 00067 fprintf (stderr, 00068 (_("Error in %s () could not allocate memory for a DxfImagedef struct.\n")), 00069 __FUNCTION__); 00070 imagedef = NULL; 00071 } 00072 else 00073 { 00074 memset (imagedef, 0, size); 00075 } 00076 #if DEBUG 00077 DXF_DEBUG_END 00078 #endif 00079 return (imagedef); 00080 } 00081 00082 00090 DxfImagedef * 00091 dxf_imagedef_init 00092 ( 00093 DxfImagedef *imagedef 00095 ) 00096 { 00097 #if DEBUG 00098 DXF_DEBUG_BEGIN 00099 #endif 00100 /* Do some basic checks. */ 00101 if (imagedef == NULL) 00102 { 00103 fprintf (stderr, 00104 (_("Warning in %s () a NULL pointer was passed.\n")), 00105 __FUNCTION__); 00106 imagedef = dxf_imagedef_new (); 00107 } 00108 if (imagedef == NULL) 00109 { 00110 fprintf (stderr, 00111 (_("Error in %s () could not allocate memory for a DxfImagedef struct.\n")), 00112 __FUNCTION__); 00113 return (NULL); 00114 } 00115 dxf_imagedef_set_id_code (imagedef, 0); 00116 dxf_imagedef_set_dictionary_owner_soft (imagedef, strdup ("")); 00117 dxf_imagedef_set_dictionary_owner_hard (imagedef, strdup ("")); 00118 dxf_imagedef_set_file_name (imagedef, strdup ("")); 00119 dxf_imagedef_set_x0 (imagedef, 0.0); 00120 dxf_imagedef_set_y0 (imagedef, 0.0); 00121 dxf_imagedef_set_x0 (imagedef, 0.0); 00122 dxf_imagedef_set_y0 (imagedef, 0.0); 00123 dxf_imagedef_set_class_version (imagedef, 0); 00124 dxf_imagedef_set_image_is_loaded_flag (imagedef, 0); 00125 dxf_imagedef_set_resolution_units (imagedef, 0); 00126 dxf_imagedef_set_acad_image_dict_soft (imagedef, strdup ("")); 00127 dxf_imagedef_set_imagedef_reactor (imagedef, dxf_imagedef_reactor_new ()); 00128 dxf_imagedef_reactor_init ((DxfImagedefReactor *) dxf_imagedef_get_imagedef_reactor (imagedef)); 00129 dxf_imagedef_set_next (imagedef, NULL); 00130 #if DEBUG 00131 DXF_DEBUG_END 00132 #endif 00133 return (imagedef); 00134 } 00135 00136 00148 DxfImagedef * 00149 dxf_imagedef_read 00150 ( 00151 DxfFile *fp, 00153 DxfImagedef *imagedef 00155 ) 00156 { 00157 #if DEBUG 00158 DXF_DEBUG_BEGIN 00159 #endif 00160 char *temp_string = NULL; 00161 int i; 00162 00163 /* Do some basic checks. */ 00164 if (fp == NULL) 00165 { 00166 fprintf (stderr, 00167 (_("Error in %s () a NULL file pointer was passed.\n")), 00168 __FUNCTION__); 00169 /* Clean up. */ 00170 free (temp_string); 00171 return (NULL); 00172 } 00173 if (fp->acad_version_number < AutoCAD_14) 00174 { 00175 fprintf (stderr, 00176 (_("Warning in %s () illegal DXF version for this entity.\n")), 00177 __FUNCTION__); 00178 } 00179 if (imagedef == NULL) 00180 { 00181 fprintf (stderr, 00182 (_("Warning in %s () a NULL pointer was passed.\n")), 00183 __FUNCTION__); 00184 imagedef = dxf_imagedef_new (); 00185 imagedef = dxf_imagedef_init (imagedef); 00186 } 00187 i = 0; 00188 (fp->line_number)++; 00189 fscanf (fp->fp, "%[^\n]", temp_string); 00190 while (strcmp (temp_string, "0") != 0) 00191 { 00192 if (ferror (fp->fp)) 00193 { 00194 fprintf (stderr, 00195 (_("Error in %s () while reading from: %s in line: %d.\n")), 00196 __FUNCTION__, fp->filename, fp->line_number); 00197 /* Clean up. */ 00198 free (temp_string); 00199 fclose (fp->fp); 00200 return (NULL); 00201 } 00202 else if (strcmp (temp_string, "1") == 0) 00203 { 00204 /* Now follows a string containing a file name. */ 00205 (fp->line_number)++; 00206 fscanf (fp->fp, "%s\n", imagedef->file_name); 00207 } 00208 if (strcmp (temp_string, "5") == 0) 00209 { 00210 /* Now follows a string containing a sequential 00211 * id number. */ 00212 (fp->line_number)++; 00213 fscanf (fp->fp, "%x\n", &imagedef->id_code); 00214 } 00215 else if (strcmp (temp_string, "10") == 0) 00216 { 00217 /* Now follows a string containing the 00218 * U-value of the image size in pixels. */ 00219 (fp->line_number)++; 00220 fscanf (fp->fp, "%lf\n", &imagedef->x0); 00221 } 00222 else if (strcmp (temp_string, "20") == 0) 00223 { 00224 /* Now follows a string containing the 00225 * V-value of the image size in pixels. */ 00226 (fp->line_number)++; 00227 fscanf (fp->fp, "%lf\n", &imagedef->y0); 00228 } 00229 else if (strcmp (temp_string, "11") == 0) 00230 { 00231 /* Now follows a string containing the 00232 * U-value of the default size of one pixel in 00233 * AutoCAD units. */ 00234 (fp->line_number)++; 00235 fscanf (fp->fp, "%lf\n", &imagedef->x1); 00236 } 00237 else if (strcmp (temp_string, "12") == 0) 00238 { 00239 /* Now follows a string containing the 00240 * V-value of the default size of one pixel in 00241 * AutoCAD units. */ 00242 (fp->line_number)++; 00243 fscanf (fp->fp, "%lf\n", &imagedef->y1); 00244 } 00245 else if (strcmp (temp_string, "90") == 0) 00246 { 00247 /* Now follows a string containing the 00248 * value of class version. */ 00249 (fp->line_number)++; 00250 fscanf (fp->fp, "%d\n", &imagedef->class_version); 00251 } 00252 else if ((fp->acad_version_number >= AutoCAD_13) 00253 && (strcmp (temp_string, "100") == 0)) 00254 { 00255 /* Now follows a string containing the 00256 * subclass marker value. */ 00257 (fp->line_number)++; 00258 fscanf (fp->fp, "%s\n", temp_string); 00259 if (strcmp (temp_string, "AcDbRasterImageDef") != 0) 00260 { 00261 fprintf (stderr, 00262 (_("Warning in %s () found a bad subclass marker in: %s in line: %d.\n")), 00263 __FUNCTION__, fp->filename, fp->line_number); 00264 } 00265 } 00266 else if (strcmp (temp_string, "280") == 0) 00267 { 00268 /* Now follows a string containing the 00269 * value of the image is loaded flag. */ 00270 (fp->line_number)++; 00271 fscanf (fp->fp, "%d\n", &imagedef->image_is_loaded_flag); 00272 } 00273 else if (strcmp (temp_string, "281") == 0) 00274 { 00275 /* Now follows a string containing the 00276 * value of the resolution units. */ 00277 (fp->line_number)++; 00278 fscanf (fp->fp, "%d\n", &imagedef->resolution_units); 00279 } 00280 else if ((strcmp (temp_string, "330") == 0) 00281 && (i == 0)) 00282 { 00283 /* Now follows a string containing Soft-pointer 00284 * ID/handle to owner dictionary. */ 00285 (fp->line_number)++; 00286 fscanf (fp->fp, "%s\n", imagedef->dictionary_owner_soft); 00287 i++; 00288 } 00289 else if ((strcmp (temp_string, "330") == 0) 00290 && (i == 1)) 00291 { 00292 /* Now follows a string containing Soft-pointer 00293 * ID/handle to owner dictionary. */ 00294 (fp->line_number)++; 00295 fscanf (fp->fp, "%s\n", imagedef->acad_image_dict_soft); 00296 i++; 00298 } 00299 else if ((strcmp (temp_string, "330") == 0) 00300 && (i > 1)) 00301 { 00302 /* Now follows a string containing a Soft 00303 * pointer reference to entity. */ 00304 (fp->line_number)++; 00305 fscanf (fp->fp, "%s\n", imagedef->imagedef_reactor_soft[i]); 00306 i++; 00307 } 00308 else if (strcmp (temp_string, "360") == 0) 00309 { 00310 /* Now follows a string containing Hard owner 00311 * ID/handle to owner dictionary. */ 00312 (fp->line_number)++; 00313 fscanf (fp->fp, "%s\n", imagedef->dictionary_owner_hard); 00314 } 00315 else if (strcmp (temp_string, "999") == 0) 00316 { 00317 /* Now follows a string containing a comment. */ 00318 (fp->line_number)++; 00319 fscanf (fp->fp, "%s\n", temp_string); 00320 fprintf (stdout, (_("DXF comment: %s\n")), temp_string); 00321 } 00322 else 00323 { 00324 fprintf (stderr, 00325 (_("Warning in %s () unknown string tag found while reading from: %s in line: %d.\n")), 00326 __FUNCTION__, fp->filename, fp->line_number); 00327 } 00328 } 00329 /* Clean up. */ 00330 free (temp_string); 00331 #if DEBUG 00332 DXF_DEBUG_END 00333 #endif 00334 return (imagedef); 00335 } 00336 00337 00344 int 00345 dxf_imagedef_write 00346 ( 00347 DxfFile *fp, 00349 DxfImagedef *imagedef 00351 ) 00352 { 00353 #if DEBUG 00354 DXF_DEBUG_BEGIN 00355 #endif 00356 char *dxf_entity_name = strdup ("IMAGEDEF"); 00357 00358 /* Do some basic checks. */ 00359 if (fp == NULL) 00360 { 00361 fprintf (stderr, 00362 (_("Error in %s () a NULL file pointer was passed.\n")), 00363 __FUNCTION__); 00364 /* Clean up. */ 00365 free (dxf_entity_name); 00366 return (EXIT_FAILURE); 00367 } 00368 if (imagedef == NULL) 00369 { 00370 fprintf (stderr, 00371 (_("Error in %s () a NULL pointer was passed.\n")), 00372 __FUNCTION__); 00373 /* Clean up. */ 00374 free (dxf_entity_name); 00375 return (EXIT_FAILURE); 00376 } 00377 if (fp->acad_version_number < AutoCAD_14) 00378 { 00379 fprintf (stderr, 00380 (_("Warning in %s () illegal DXF version for this %s entity with id-code: %x.\n")), 00381 __FUNCTION__, dxf_entity_name, imagedef->id_code); 00382 } 00383 /* Start writing output. */ 00384 fprintf (fp->fp, " 0\n%s\n", dxf_entity_name); 00385 if (dxf_imagedef_get_id_code (imagedef) != -1) 00386 { 00387 fprintf (fp->fp, " 5\n%x\n", dxf_imagedef_get_id_code (imagedef)); 00388 } 00399 if ((strcmp (imagedef->dictionary_owner_soft, "") != 0) 00400 && (fp->acad_version_number >= AutoCAD_14)) 00401 { 00402 fprintf (fp->fp, "102\n{ACAD_REACTORS\n"); 00403 fprintf (fp->fp, "330\n%s\n", dxf_imagedef_get_dictionary_owner_soft (imagedef)); 00404 fprintf (fp->fp, "330\n%s\n", dxf_imagedef_get_acad_image_dict_soft (imagedef)); 00405 if (dxf_imagedef_get_imagedef_reactor (imagedef) != NULL) 00406 { 00407 DxfImagedefReactor *iter; 00408 iter = dxf_imagedef_get_imagedef_reactor (imagedef); 00409 while (iter != NULL) 00410 { 00411 fprintf (fp->fp, "330\n%s\n", dxf_imagedef_reactor_get_associated_image_object (iter)); 00412 iter = (DxfImagedefReactor *) dxf_imagedef_reactor_get_next (iter); 00413 } 00414 } 00415 fprintf (fp->fp, "102\n}\n"); 00416 } 00417 if ((strcmp (imagedef->dictionary_owner_hard, "") != 0) 00418 && (fp->acad_version_number >= AutoCAD_14)) 00419 { 00420 fprintf (fp->fp, "102\n{ACAD_XDICTIONARY\n"); 00421 fprintf (fp->fp, "360\n%s\n", dxf_imagedef_get_dictionary_owner_hard (imagedef)); 00422 fprintf (fp->fp, "102\n}\n"); 00423 } 00424 if (fp->acad_version_number >= AutoCAD_13) 00425 { 00426 fprintf (fp->fp, "100\nAcDbRasterImageDef\n"); 00427 } 00428 fprintf (fp->fp, " 90\n%d\n", dxf_imagedef_get_class_version (imagedef)); 00429 fprintf (fp->fp, " 1\n%s\n", dxf_imagedef_get_file_name (imagedef)); 00430 fprintf (fp->fp, " 10\n%f\n", dxf_imagedef_get_x0 (imagedef)); 00431 fprintf (fp->fp, " 20\n%f\n", dxf_imagedef_get_y0 (imagedef)); 00432 fprintf (fp->fp, " 11\n%f\n", dxf_imagedef_get_x1 (imagedef)); 00433 fprintf (fp->fp, " 12\n%f\n", dxf_imagedef_get_y1 (imagedef)); 00434 fprintf (fp->fp, "280\n%d\n", dxf_imagedef_get_image_is_loaded_flag (imagedef)); 00435 fprintf (fp->fp, "281\n%d\n", dxf_imagedef_get_resolution_units (imagedef)); 00436 /* Clean up. */ 00437 free (dxf_entity_name); 00438 #if DEBUG 00439 DXF_DEBUG_END 00440 #endif 00441 return (EXIT_SUCCESS); 00442 } 00443 00444 00452 int 00453 dxf_imagedef_free 00454 ( 00455 DxfImagedef *imagedef 00458 ) 00459 { 00460 #if DEBUG 00461 DXF_DEBUG_BEGIN 00462 #endif 00463 int i; 00464 00465 /* Do some basic checks. */ 00466 if (imagedef == NULL) 00467 { 00468 fprintf (stderr, 00469 (_("Error in %s () a NULL pointer was passed.\n")), 00470 __FUNCTION__); 00471 return (EXIT_FAILURE); 00472 } 00473 if (imagedef->next != NULL) 00474 { 00475 fprintf (stderr, 00476 (_("Error in %s () pointer to next was not NULL.\n")), 00477 __FUNCTION__); 00478 return (EXIT_FAILURE); 00479 } 00480 free (imagedef->dictionary_owner_soft); 00481 free (imagedef->dictionary_owner_hard); 00482 free (imagedef->file_name); 00483 free (imagedef->acad_image_dict_soft); 00484 for (i = 0; i < DXF_MAX_PARAM; i++) 00485 { 00486 free (imagedef->imagedef_reactor_soft[i]); 00487 } 00488 free (imagedef); 00489 imagedef = NULL; 00490 #if DEBUG 00491 DXF_DEBUG_END 00492 #endif 00493 return (EXIT_SUCCESS); 00494 } 00495 00496 00501 void 00502 dxf_imagedef_free_chain 00503 ( 00504 DxfImagedef *imagedefs 00506 ) 00507 { 00508 #ifdef DEBUG 00509 DXF_DEBUG_BEGIN 00510 #endif 00511 if (imagedefs == NULL) 00512 { 00513 fprintf (stderr, 00514 (_("Warning in %s () a NULL pointer was passed.\n")), 00515 __FUNCTION__); 00516 } 00517 while (imagedefs != NULL) 00518 { 00519 struct DxfImagedef *iter = imagedefs->next; 00520 dxf_imagedef_free (imagedefs); 00521 imagedefs = (DxfImagedef *) iter; 00522 } 00523 #if DEBUG 00524 DXF_DEBUG_END 00525 #endif 00526 } 00527 00528 00535 int 00536 dxf_imagedef_get_id_code 00537 ( 00538 DxfImagedef *imagedef 00540 ) 00541 { 00542 #if DEBUG 00543 DXF_DEBUG_BEGIN 00544 #endif 00545 /* Do some basic checks. */ 00546 if (imagedef == NULL) 00547 { 00548 fprintf (stderr, 00549 (_("Error in %s () a NULL pointer was passed.\n")), 00550 __FUNCTION__); 00551 return (EXIT_FAILURE); 00552 } 00553 if (imagedef->id_code < 0) 00554 { 00555 fprintf (stderr, 00556 (_("Error in %s () a negative value was found in the id_code member.\n")), 00557 __FUNCTION__); 00558 return (EXIT_FAILURE); 00559 } 00560 #if DEBUG 00561 DXF_DEBUG_END 00562 #endif 00563 return (imagedef->id_code); 00564 } 00565 00566 00573 DxfImagedef * 00574 dxf_imagedef_set_id_code 00575 ( 00576 DxfImagedef *imagedef, 00578 int id_code 00582 ) 00583 { 00584 #if DEBUG 00585 DXF_DEBUG_BEGIN 00586 #endif 00587 /* Do some basic checks. */ 00588 if (imagedef == NULL) 00589 { 00590 fprintf (stderr, 00591 (_("Error in %s () a NULL pointer was passed.\n")), 00592 __FUNCTION__); 00593 return (NULL); 00594 } 00595 if (id_code < 0) 00596 { 00597 fprintf (stderr, 00598 (_("Error in %s () a negative id-code value was passed.\n")), 00599 __FUNCTION__); 00600 return (NULL); 00601 } 00602 imagedef->id_code = id_code; 00603 #if DEBUG 00604 DXF_DEBUG_END 00605 #endif 00606 return (imagedef); 00607 } 00608 00609 00619 char * 00620 dxf_imagedef_get_dictionary_owner_soft 00621 ( 00622 DxfImagedef *imagedef 00624 ) 00625 { 00626 #if DEBUG 00627 DXF_DEBUG_BEGIN 00628 #endif 00629 /* Do some basic checks. */ 00630 if (imagedef == NULL) 00631 { 00632 fprintf (stderr, 00633 (_("Error in %s () a NULL pointer was passed.\n")), 00634 __FUNCTION__); 00635 return (NULL); 00636 } 00637 if (imagedef->dictionary_owner_soft == NULL) 00638 { 00639 fprintf (stderr, 00640 (_("Error in %s () a NULL pointer was found in the dictionary_owner_soft member.\n")), 00641 __FUNCTION__); 00642 return (NULL); 00643 } 00644 #if DEBUG 00645 DXF_DEBUG_END 00646 #endif 00647 return (strdup (imagedef->dictionary_owner_soft)); 00648 } 00649 00650 00658 DxfImagedef * 00659 dxf_imagedef_set_dictionary_owner_soft 00660 ( 00661 DxfImagedef *imagedef, 00663 char *dictionary_owner_soft 00666 ) 00667 { 00668 #if DEBUG 00669 DXF_DEBUG_BEGIN 00670 #endif 00671 /* Do some basic checks. */ 00672 if (imagedef == NULL) 00673 { 00674 fprintf (stderr, 00675 (_("Error in %s () a NULL pointer was passed.\n")), 00676 __FUNCTION__); 00677 return (NULL); 00678 } 00679 if (dictionary_owner_soft == NULL) 00680 { 00681 fprintf (stderr, 00682 (_("Error in %s () a NULL pointer was passed.\n")), 00683 __FUNCTION__); 00684 return (NULL); 00685 } 00686 imagedef->dictionary_owner_soft = strdup (dictionary_owner_soft); 00687 #if DEBUG 00688 DXF_DEBUG_END 00689 #endif 00690 return (imagedef); 00691 } 00692 00693 00703 char * 00704 dxf_imagedef_get_dictionary_owner_hard 00705 ( 00706 DxfImagedef *imagedef 00708 ) 00709 { 00710 #if DEBUG 00711 DXF_DEBUG_BEGIN 00712 #endif 00713 /* Do some basic checks. */ 00714 if (imagedef == NULL) 00715 { 00716 fprintf (stderr, 00717 (_("Error in %s () a NULL pointer was passed.\n")), 00718 __FUNCTION__); 00719 return (NULL); 00720 } 00721 if (imagedef->dictionary_owner_hard == NULL) 00722 { 00723 fprintf (stderr, 00724 (_("Error in %s () a NULL pointer was found in the dictionary_owner_hard member.\n")), 00725 __FUNCTION__); 00726 return (NULL); 00727 } 00728 #if DEBUG 00729 DXF_DEBUG_END 00730 #endif 00731 return (strdup (imagedef->dictionary_owner_hard)); 00732 } 00733 00734 00742 DxfImagedef * 00743 dxf_imagedef_set_dictionary_owner_hard 00744 ( 00745 DxfImagedef *imagedef, 00747 char *dictionary_owner_hard 00750 ) 00751 { 00752 #if DEBUG 00753 DXF_DEBUG_BEGIN 00754 #endif 00755 /* Do some basic checks. */ 00756 if (imagedef == NULL) 00757 { 00758 fprintf (stderr, 00759 (_("Error in %s () a NULL pointer was passed.\n")), 00760 __FUNCTION__); 00761 return (NULL); 00762 } 00763 if (dictionary_owner_hard == NULL) 00764 { 00765 fprintf (stderr, 00766 (_("Error in %s () a NULL pointer was passed.\n")), 00767 __FUNCTION__); 00768 return (NULL); 00769 } 00770 imagedef->dictionary_owner_hard = strdup (dictionary_owner_hard); 00771 #if DEBUG 00772 DXF_DEBUG_END 00773 #endif 00774 return (imagedef); 00775 } 00776 00777 00783 char * 00784 dxf_imagedef_get_file_name 00785 ( 00786 DxfImagedef *imagedef 00788 ) 00789 { 00790 #if DEBUG 00791 DXF_DEBUG_BEGIN 00792 #endif 00793 /* Do some basic checks. */ 00794 if (imagedef == NULL) 00795 { 00796 fprintf (stderr, 00797 (_("Error in %s () a NULL pointer was passed.\n")), 00798 __FUNCTION__); 00799 return (NULL); 00800 } 00801 if (imagedef->file_name == NULL) 00802 { 00803 fprintf (stderr, 00804 (_("Error in %s () a NULL pointer was found in the file_name member.\n")), 00805 __FUNCTION__); 00806 return (NULL); 00807 } 00808 #if DEBUG 00809 DXF_DEBUG_END 00810 #endif 00811 return (strdup (imagedef->file_name)); 00812 } 00813 00814 00821 DxfImagedef * 00822 dxf_imagedef_set_file_name 00823 ( 00824 DxfImagedef *imagedef, 00826 char *file_name 00829 ) 00830 { 00831 #if DEBUG 00832 DXF_DEBUG_BEGIN 00833 #endif 00834 /* Do some basic checks. */ 00835 if (imagedef == NULL) 00836 { 00837 fprintf (stderr, 00838 (_("Error in %s () a NULL pointer was passed.\n")), 00839 __FUNCTION__); 00840 return (NULL); 00841 } 00842 if (file_name == NULL) 00843 { 00844 fprintf (stderr, 00845 (_("Error in %s () a NULL pointer was passed.\n")), 00846 __FUNCTION__); 00847 return (NULL); 00848 } 00849 imagedef->file_name = strdup (file_name); 00850 #if DEBUG 00851 DXF_DEBUG_END 00852 #endif 00853 return (imagedef); 00854 } 00855 00856 00862 DxfPoint * 00863 dxf_imagedef_get_p0 00864 ( 00865 DxfImagedef *imagedef 00867 ) 00868 { 00869 #ifdef DEBUG 00870 DXF_DEBUG_BEGIN 00871 #endif 00872 /* Do some basic checks. */ 00873 if (imagedef == NULL) 00874 { 00875 fprintf (stderr, 00876 (_("Error in %s () a NULL pointer was passed.\n")), 00877 __FUNCTION__); 00878 return (NULL); 00879 } 00880 if (imagedef->p0 == NULL) 00881 { 00882 fprintf (stderr, 00883 (_("Error in %s () a NULL pointer was found.\n")), 00884 __FUNCTION__); 00885 return (NULL); 00886 } 00887 #if DEBUG 00888 DXF_DEBUG_END 00889 #endif 00890 return (imagedef->p0); 00891 } 00892 00893 00899 DxfImagedef * 00900 dxf_imagedef_set_p0 00901 ( 00902 DxfImagedef *imagedef, 00904 DxfPoint *p0 00906 ) 00907 { 00908 #ifdef DEBUG 00909 DXF_DEBUG_BEGIN 00910 #endif 00911 /* Do some basic checks. */ 00912 if (imagedef == NULL) 00913 { 00914 fprintf (stderr, 00915 (_("Error in %s () a NULL pointer was passed.\n")), 00916 __FUNCTION__); 00917 return (NULL); 00918 } 00919 if (p0 == NULL) 00920 { 00921 fprintf (stderr, 00922 (_("Error in %s () a NULL pointer was passed.\n")), 00923 __FUNCTION__); 00924 return (NULL); 00925 } 00926 imagedef->p0 = p0; 00927 #if DEBUG 00928 DXF_DEBUG_END 00929 #endif 00930 return (imagedef); 00931 } 00932 00933 00940 double 00941 dxf_imagedef_get_x0 00942 ( 00943 DxfImagedef *imagedef 00945 ) 00946 { 00947 #ifdef DEBUG 00948 DXF_DEBUG_BEGIN 00949 #endif 00950 00951 /* Do some basic checks. */ 00952 if (imagedef == NULL) 00953 { 00954 fprintf (stderr, 00955 (_("Error in %s () a NULL pointer was passed.\n")), 00956 __FUNCTION__); 00957 return (EXIT_FAILURE); 00958 } 00959 if (imagedef->p0 == NULL) 00960 { 00961 fprintf (stderr, 00962 (_("Error in %s () a NULL pointer was found.\n")), 00963 __FUNCTION__); 00964 return (EXIT_FAILURE); 00965 } 00966 #if DEBUG 00967 DXF_DEBUG_END 00968 #endif 00969 return (imagedef->p0->x0); 00970 } 00971 00972 00980 DxfImagedef * 00981 dxf_imagedef_set_x0 00982 ( 00983 DxfImagedef *imagedef, 00985 double x0 00988 ) 00989 { 00990 #ifdef DEBUG 00991 DXF_DEBUG_BEGIN 00992 #endif 00993 /* Do some basic checks. */ 00994 if (imagedef == NULL) 00995 { 00996 fprintf (stderr, 00997 (_("Error in %s () a NULL pointer was passed.\n")), 00998 __FUNCTION__); 00999 return (NULL); 01000 } 01001 if (imagedef->p0 == NULL) 01002 { 01003 fprintf (stderr, 01004 (_("Error in %s () a NULL pointer was found.\n")), 01005 __FUNCTION__); 01006 return (NULL); 01007 } 01008 imagedef->p0->x0 = x0; 01009 #if DEBUG 01010 DXF_DEBUG_END 01011 #endif 01012 return (imagedef); 01013 } 01014 01015 01022 double 01023 dxf_imagedef_get_y0 01024 ( 01025 DxfImagedef *imagedef 01027 ) 01028 { 01029 #ifdef DEBUG 01030 DXF_DEBUG_BEGIN 01031 #endif 01032 01033 /* Do some basic checks. */ 01034 if (imagedef == NULL) 01035 { 01036 fprintf (stderr, 01037 (_("Error in %s () a NULL pointer was passed.\n")), 01038 __FUNCTION__); 01039 return (EXIT_FAILURE); 01040 } 01041 if (imagedef->p0 == NULL) 01042 { 01043 fprintf (stderr, 01044 (_("Error in %s () a NULL pointer was found.\n")), 01045 __FUNCTION__); 01046 return (EXIT_FAILURE); 01047 } 01048 #if DEBUG 01049 DXF_DEBUG_END 01050 #endif 01051 return (imagedef->p0->y0); 01052 } 01053 01054 01062 DxfImagedef * 01063 dxf_imagedef_set_y0 01064 ( 01065 DxfImagedef *imagedef, 01067 double y0 01070 ) 01071 { 01072 #ifdef DEBUG 01073 DXF_DEBUG_BEGIN 01074 #endif 01075 /* Do some basic checks. */ 01076 if (imagedef == NULL) 01077 { 01078 fprintf (stderr, 01079 (_("Error in %s () a NULL pointer was passed.\n")), 01080 __FUNCTION__); 01081 return (NULL); 01082 } 01083 if (imagedef->p0 == NULL) 01084 { 01085 fprintf (stderr, 01086 (_("Error in %s () a NULL pointer was found.\n")), 01087 __FUNCTION__); 01088 return (NULL); 01089 } 01090 imagedef->p0->y0 = y0; 01091 #if DEBUG 01092 DXF_DEBUG_END 01093 #endif 01094 return (imagedef); 01095 } 01096 01097 01104 DxfPoint * 01105 dxf_imagedef_get_p1 01106 ( 01107 DxfImagedef *imagedef 01109 ) 01110 { 01111 #ifdef DEBUG 01112 DXF_DEBUG_BEGIN 01113 #endif 01114 /* Do some basic checks. */ 01115 if (imagedef == NULL) 01116 { 01117 fprintf (stderr, 01118 (_("Error in %s () a NULL pointer was passed.\n")), 01119 __FUNCTION__); 01120 return (NULL); 01121 } 01122 if (imagedef->p1 == NULL) 01123 { 01124 fprintf (stderr, 01125 (_("Error in %s () a NULL pointer was found.\n")), 01126 __FUNCTION__); 01127 return (NULL); 01128 } 01129 #if DEBUG 01130 DXF_DEBUG_END 01131 #endif 01132 return (imagedef->p1); 01133 } 01134 01135 01142 DxfImagedef * 01143 dxf_imagedef_set_p1 01144 ( 01145 DxfImagedef *imagedef, 01147 DxfPoint *p1 01149 ) 01150 { 01151 #ifdef DEBUG 01152 DXF_DEBUG_BEGIN 01153 #endif 01154 /* Do some basic checks. */ 01155 if (imagedef == NULL) 01156 { 01157 fprintf (stderr, 01158 (_("Error in %s () a NULL pointer was passed.\n")), 01159 __FUNCTION__); 01160 return (NULL); 01161 } 01162 if (p1 == NULL) 01163 { 01164 fprintf (stderr, 01165 (_("Error in %s () a NULL pointer was passed.\n")), 01166 __FUNCTION__); 01167 return (NULL); 01168 } 01169 imagedef->p1 = p1; 01170 #if DEBUG 01171 DXF_DEBUG_END 01172 #endif 01173 return (imagedef); 01174 } 01175 01176 01183 double 01184 dxf_imagedef_get_x1 01185 ( 01186 DxfImagedef *imagedef 01188 ) 01189 { 01190 #ifdef DEBUG 01191 DXF_DEBUG_BEGIN 01192 #endif 01193 01194 /* Do some basic checks. */ 01195 if (imagedef == NULL) 01196 { 01197 fprintf (stderr, 01198 (_("Error in %s () a NULL pointer was passed.\n")), 01199 __FUNCTION__); 01200 return (EXIT_FAILURE); 01201 } 01202 if (imagedef->p1 == NULL) 01203 { 01204 fprintf (stderr, 01205 (_("Error in %s () a NULL pointer was found.\n")), 01206 __FUNCTION__); 01207 return (EXIT_FAILURE); 01208 } 01209 #if DEBUG 01210 DXF_DEBUG_END 01211 #endif 01212 return (imagedef->p1->x0); 01213 } 01214 01215 01223 DxfImagedef * 01224 dxf_imagedef_set_x1 01225 ( 01226 DxfImagedef *imagedef, 01228 double x1 01231 ) 01232 { 01233 #ifdef DEBUG 01234 DXF_DEBUG_BEGIN 01235 #endif 01236 /* Do some basic checks. */ 01237 if (imagedef == NULL) 01238 { 01239 fprintf (stderr, 01240 (_("Error in %s () a NULL pointer was passed.\n")), 01241 __FUNCTION__); 01242 return (NULL); 01243 } 01244 if (imagedef->p1 == NULL) 01245 { 01246 fprintf (stderr, 01247 (_("Error in %s () a NULL pointer was found.\n")), 01248 __FUNCTION__); 01249 return (NULL); 01250 } 01251 imagedef->p1->x0 = x1; 01252 #if DEBUG 01253 DXF_DEBUG_END 01254 #endif 01255 return (imagedef); 01256 } 01257 01258 01265 double 01266 dxf_imagedef_get_y1 01267 ( 01268 DxfImagedef *imagedef 01270 ) 01271 { 01272 #ifdef DEBUG 01273 DXF_DEBUG_BEGIN 01274 #endif 01275 01276 /* Do some basic checks. */ 01277 if (imagedef == NULL) 01278 { 01279 fprintf (stderr, 01280 (_("Error in %s () a NULL pointer was passed.\n")), 01281 __FUNCTION__); 01282 return (EXIT_FAILURE); 01283 } 01284 if (imagedef->p1 == NULL) 01285 { 01286 fprintf (stderr, 01287 (_("Error in %s () a NULL pointer was found.\n")), 01288 __FUNCTION__); 01289 return (EXIT_FAILURE); 01290 } 01291 #if DEBUG 01292 DXF_DEBUG_END 01293 #endif 01294 return (imagedef->p1->y0); 01295 } 01296 01297 01305 DxfImagedef * 01306 dxf_imagedef_set_y1 01307 ( 01308 DxfImagedef *imagedef, 01310 double y1 01313 ) 01314 { 01315 #ifdef DEBUG 01316 DXF_DEBUG_BEGIN 01317 #endif 01318 /* Do some basic checks. */ 01319 if (imagedef == NULL) 01320 { 01321 fprintf (stderr, 01322 (_("Error in %s () a NULL pointer was passed.\n")), 01323 __FUNCTION__); 01324 return (NULL); 01325 } 01326 if (imagedef->p1 == NULL) 01327 { 01328 fprintf (stderr, 01329 (_("Error in %s () a NULL pointer was found.\n")), 01330 __FUNCTION__); 01331 return (NULL); 01332 } 01333 imagedef->p1->y0 = y1; 01334 #if DEBUG 01335 DXF_DEBUG_END 01336 #endif 01337 return (imagedef); 01338 } 01339 01340 01347 int32_t 01348 dxf_imagedef_get_class_version 01349 ( 01350 DxfImagedef *imagedef 01352 ) 01353 { 01354 #if DEBUG 01355 DXF_DEBUG_BEGIN 01356 #endif 01357 /* Do some basic checks. */ 01358 if (imagedef == NULL) 01359 { 01360 fprintf (stderr, 01361 (_("Error in %s () a NULL pointer was passed.\n")), 01362 __FUNCTION__); 01363 return (EXIT_FAILURE); 01364 } 01365 if (imagedef->class_version < 0) 01366 { 01367 fprintf (stderr, 01368 (_("Error in %s () a negative value was found in the class_version member.\n")), 01369 __FUNCTION__); 01370 return (EXIT_FAILURE); 01371 } 01372 if (imagedef->class_version > 0) 01373 { 01374 fprintf (stderr, 01375 (_("Error in %s () an out of range value was found in the class_version member.\n")), 01376 __FUNCTION__); 01377 return (EXIT_FAILURE); 01378 } 01379 #if DEBUG 01380 DXF_DEBUG_END 01381 #endif 01382 return (imagedef->class_version); 01383 } 01384 01385 01392 DxfImagedef * 01393 dxf_imagedef_set_class_version 01394 ( 01395 DxfImagedef *imagedef, 01397 int32_t class_version 01399 ) 01400 { 01401 #if DEBUG 01402 DXF_DEBUG_BEGIN 01403 #endif 01404 /* Do some basic checks. */ 01405 if (imagedef == NULL) 01406 { 01407 fprintf (stderr, 01408 (_("Error in %s () a NULL pointer was passed.\n")), 01409 __FUNCTION__); 01410 return (NULL); 01411 } 01412 if (class_version < 0) 01413 { 01414 fprintf (stderr, 01415 (_("Error in %s () a negative class_version value was passed.\n")), 01416 __FUNCTION__); 01417 return (NULL); 01418 } 01419 if (class_version > 0) 01420 { 01421 fprintf (stderr, 01422 (_("Error in %s () an out of range class_version value was passed.\n")), 01423 __FUNCTION__); 01424 return (NULL); 01425 } 01426 imagedef->class_version = class_version; 01427 #if DEBUG 01428 DXF_DEBUG_END 01429 #endif 01430 return (imagedef); 01431 } 01432 01433 01440 int 01441 dxf_imagedef_get_image_is_loaded_flag 01442 ( 01443 DxfImagedef *imagedef 01445 ) 01446 { 01447 #if DEBUG 01448 DXF_DEBUG_BEGIN 01449 #endif 01450 /* Do some basic checks. */ 01451 if (imagedef == NULL) 01452 { 01453 fprintf (stderr, 01454 (_("Error in %s () a NULL pointer was passed.\n")), 01455 __FUNCTION__); 01456 return (EXIT_FAILURE); 01457 } 01458 if (imagedef->image_is_loaded_flag < 0) 01459 { 01460 fprintf (stderr, 01461 (_("Error in %s () a negative value was found in the image_is_loaded_flag member.\n")), 01462 __FUNCTION__); 01463 return (EXIT_FAILURE); 01464 } 01465 if (imagedef->image_is_loaded_flag > 1) 01466 { 01467 fprintf (stderr, 01468 (_("Error in %s () an out of range value was found in the image_is_loaded_flag member.\n")), 01469 __FUNCTION__); 01470 return (EXIT_FAILURE); 01471 } 01472 #if DEBUG 01473 DXF_DEBUG_END 01474 #endif 01475 return (imagedef->image_is_loaded_flag); 01476 } 01477 01478 01485 DxfImagedef * 01486 dxf_imagedef_set_image_is_loaded_flag 01487 ( 01488 DxfImagedef *imagedef, 01490 int image_is_loaded_flag 01492 ) 01493 { 01494 #if DEBUG 01495 DXF_DEBUG_BEGIN 01496 #endif 01497 /* Do some basic checks. */ 01498 if (imagedef == NULL) 01499 { 01500 fprintf (stderr, 01501 (_("Error in %s () a NULL pointer was passed.\n")), 01502 __FUNCTION__); 01503 return (NULL); 01504 } 01505 if (image_is_loaded_flag < 0) 01506 { 01507 fprintf (stderr, 01508 (_("Error in %s () a negative image_is_loaded_flag value was passed.\n")), 01509 __FUNCTION__); 01510 return (NULL); 01511 } 01512 if (image_is_loaded_flag > 1) 01513 { 01514 fprintf (stderr, 01515 (_("Error in %s () an out of range image_is_loaded_flag value was passed.\n")), 01516 __FUNCTION__); 01517 return (NULL); 01518 } 01519 imagedef->image_is_loaded_flag = image_is_loaded_flag; 01520 #if DEBUG 01521 DXF_DEBUG_END 01522 #endif 01523 return (imagedef); 01524 } 01525 01526 01533 int 01534 dxf_imagedef_get_resolution_units 01535 ( 01536 DxfImagedef *imagedef 01538 ) 01539 { 01540 #if DEBUG 01541 DXF_DEBUG_BEGIN 01542 #endif 01543 /* Do some basic checks. */ 01544 if (imagedef == NULL) 01545 { 01546 fprintf (stderr, 01547 (_("Error in %s () a NULL pointer was passed.\n")), 01548 __FUNCTION__); 01549 return (EXIT_FAILURE); 01550 } 01551 if (imagedef->resolution_units < 0) 01552 { 01553 fprintf (stderr, 01554 (_("Error in %s () a negative value was found in the resolution_units member.\n")), 01555 __FUNCTION__); 01556 return (EXIT_FAILURE); 01557 } 01558 if (imagedef->resolution_units > 5) 01559 { 01560 fprintf (stderr, 01561 (_("Error in %s () an out of range value was found in the resolution_units member.\n")), 01562 __FUNCTION__); 01563 return (EXIT_FAILURE); 01564 } 01565 #if DEBUG 01566 DXF_DEBUG_END 01567 #endif 01568 return (imagedef->resolution_units); 01569 } 01570 01571 01578 DxfImagedef * 01579 dxf_imagedef_set_resolution_units 01580 ( 01581 DxfImagedef *imagedef, 01583 int resolution_units 01585 ) 01586 { 01587 #if DEBUG 01588 DXF_DEBUG_BEGIN 01589 #endif 01590 /* Do some basic checks. */ 01591 if (imagedef == NULL) 01592 { 01593 fprintf (stderr, 01594 (_("Error in %s () a NULL pointer was passed.\n")), 01595 __FUNCTION__); 01596 return (NULL); 01597 } 01598 if (resolution_units < 0) 01599 { 01600 fprintf (stderr, 01601 (_("Error in %s () a negative resolution_units value was passed.\n")), 01602 __FUNCTION__); 01603 return (NULL); 01604 } 01605 if (resolution_units > 5) 01606 { 01607 fprintf (stderr, 01608 (_("Error in %s () an out of range resolution_units value was passed.\n")), 01609 __FUNCTION__); 01610 return (NULL); 01611 } 01612 imagedef->resolution_units = resolution_units; 01613 #if DEBUG 01614 DXF_DEBUG_END 01615 #endif 01616 return (imagedef); 01617 } 01618 01619 01629 char * 01630 dxf_imagedef_get_acad_image_dict_soft 01631 ( 01632 DxfImagedef *imagedef 01634 ) 01635 { 01636 #if DEBUG 01637 DXF_DEBUG_BEGIN 01638 #endif 01639 /* Do some basic checks. */ 01640 if (imagedef == NULL) 01641 { 01642 fprintf (stderr, 01643 (_("Error in %s () a NULL pointer was passed.\n")), 01644 __FUNCTION__); 01645 return (NULL); 01646 } 01647 if (imagedef->acad_image_dict_soft == NULL) 01648 { 01649 fprintf (stderr, 01650 (_("Error in %s () a NULL pointer was found in the acad_image_dict_soft member.\n")), 01651 __FUNCTION__); 01652 return (NULL); 01653 } 01654 #if DEBUG 01655 DXF_DEBUG_END 01656 #endif 01657 return (strdup (imagedef->acad_image_dict_soft)); 01658 } 01659 01660 01668 DxfImagedef * 01669 dxf_imagedef_set_acad_image_dict_soft 01670 ( 01671 DxfImagedef *imagedef, 01673 char *acad_image_dict_soft 01676 ) 01677 { 01678 #if DEBUG 01679 DXF_DEBUG_BEGIN 01680 #endif 01681 /* Do some basic checks. */ 01682 if (imagedef == NULL) 01683 { 01684 fprintf (stderr, 01685 (_("Error in %s () a NULL pointer was passed.\n")), 01686 __FUNCTION__); 01687 return (NULL); 01688 } 01689 if (acad_image_dict_soft == NULL) 01690 { 01691 fprintf (stderr, 01692 (_("Error in %s () a NULL pointer was passed.\n")), 01693 __FUNCTION__); 01694 return (NULL); 01695 } 01696 imagedef->acad_image_dict_soft = strdup (acad_image_dict_soft); 01697 #if DEBUG 01698 DXF_DEBUG_END 01699 #endif 01700 return (imagedef); 01701 } 01702 01703 01712 DxfImagedefReactor * 01713 dxf_imagedef_get_imagedef_reactor 01714 ( 01715 DxfImagedef *imagedef 01717 ) 01718 { 01719 #if DEBUG 01720 DXF_DEBUG_BEGIN 01721 #endif 01722 /* Do some basic checks. */ 01723 if (imagedef == NULL) 01724 { 01725 fprintf (stderr, 01726 (_("Error in %s () a NULL pointer was passed.\n")), 01727 __FUNCTION__); 01728 return (NULL); 01729 } 01730 if (imagedef->imagedef_reactor == NULL) 01731 { 01732 fprintf (stderr, 01733 (_("Error in %s () a NULL pointer was found in the imagedef_reactor member.\n")), 01734 __FUNCTION__); 01735 return (NULL); 01736 } 01737 #if DEBUG 01738 DXF_DEBUG_END 01739 #endif 01740 return ((DxfImagedefReactor *) imagedef->imagedef_reactor); 01741 } 01742 01743 01748 DxfImagedef * 01749 dxf_imagedef_set_imagedef_reactor 01750 ( 01751 DxfImagedef *imagedef, 01753 DxfImagedefReactor *imagedef_reactor 01756 ) 01757 { 01758 #if DEBUG 01759 DXF_DEBUG_BEGIN 01760 #endif 01761 /* Do some basic checks. */ 01762 if (imagedef == NULL) 01763 { 01764 fprintf (stderr, 01765 (_("Error in %s () a NULL pointer was passed.\n")), 01766 __FUNCTION__); 01767 return (NULL); 01768 } 01769 if (imagedef_reactor == NULL) 01770 { 01771 fprintf (stderr, 01772 (_("Error in %s () a NULL pointer was passed.\n")), 01773 __FUNCTION__); 01774 return (NULL); 01775 } 01776 imagedef->imagedef_reactor = (DxfImagedefReactor *) imagedef_reactor; 01777 #if DEBUG 01778 DXF_DEBUG_END 01779 #endif 01780 return (imagedef); 01781 } 01782 01783 01792 DxfImagedef * 01793 dxf_imagedef_get_next 01794 ( 01795 DxfImagedef *imagedef 01797 ) 01798 { 01799 #if DEBUG 01800 DXF_DEBUG_BEGIN 01801 #endif 01802 /* Do some basic checks. */ 01803 if (imagedef == NULL) 01804 { 01805 fprintf (stderr, 01806 (_("Error in %s () a NULL pointer was passed.\n")), 01807 __FUNCTION__); 01808 return (NULL); 01809 } 01810 if (imagedef->next == NULL) 01811 { 01812 fprintf (stderr, 01813 (_("Error in %s () a NULL pointer was found in the next member.\n")), 01814 __FUNCTION__); 01815 return (NULL); 01816 } 01817 #if DEBUG 01818 DXF_DEBUG_END 01819 #endif 01820 return ((DxfImagedef *) imagedef->next); 01821 } 01822 01823 01828 DxfImagedef * 01829 dxf_imagedef_set_next 01830 ( 01831 DxfImagedef *imagedef, 01833 DxfImagedef *next 01835 ) 01836 { 01837 #if DEBUG 01838 DXF_DEBUG_BEGIN 01839 #endif 01840 /* Do some basic checks. */ 01841 if (imagedef == NULL) 01842 { 01843 fprintf (stderr, 01844 (_("Error in %s () a NULL pointer was passed.\n")), 01845 __FUNCTION__); 01846 return (NULL); 01847 } 01848 if (next == NULL) 01849 { 01850 fprintf (stderr, 01851 (_("Error in %s () a NULL pointer was passed.\n")), 01852 __FUNCTION__); 01853 return (NULL); 01854 } 01855 imagedef->next = (struct DxfImagedef *) next; 01856 #if DEBUG 01857 DXF_DEBUG_END 01858 #endif 01859 return (imagedef); 01860 } 01861 01862 01871 DxfImagedef * 01872 dxf_imagedef_get_last 01873 ( 01874 DxfImagedef *imagedef 01876 ) 01877 { 01878 #if DEBUG 01879 DXF_DEBUG_BEGIN 01880 #endif 01881 /* Do some basic checks. */ 01882 if (imagedef == NULL) 01883 { 01884 fprintf (stderr, 01885 (_("Error in %s () a NULL pointer was passed.\n")), 01886 __FUNCTION__); 01887 return (NULL); 01888 } 01889 if (imagedef->next == NULL) 01890 { 01891 fprintf (stderr, 01892 (_("Warning in %s () a NULL pointer was found in the next member.\n")), 01893 __FUNCTION__); 01894 return ((DxfImagedef *) imagedef); 01895 } 01896 DxfImagedef *iter = (DxfImagedef *) imagedef->next; 01897 while (iter->next != NULL) 01898 { 01899 iter = (DxfImagedef *) iter->next; 01900 } 01901 #if DEBUG 01902 DXF_DEBUG_END 01903 #endif 01904 return ((DxfImagedef *) iter); 01905 } 01906 01907 01908 /* EOF*/