libDXF 0.0.1
A library with DXF related functions written in C.
|
00001 00042 #include "hatch.h" 00043 00044 00045 /* dxf_hatch functions. */ 00046 00052 DxfHatch * 00053 dxf_hatch_new () 00054 { 00055 #if DEBUG 00056 DXF_DEBUG_BEGIN 00057 #endif 00058 DxfHatch *hatch = NULL; 00059 size_t size; 00060 00061 size = sizeof (DxfHatch); 00062 /* avoid malloc of 0 bytes */ 00063 if (size == 0) size = 1; 00064 if ((hatch = malloc (size)) == NULL) 00065 { 00066 fprintf (stderr, 00067 (_("Error in %s () could not allocate memory for a DxfHatch struct.\n")), 00068 __FUNCTION__); 00069 hatch = NULL; 00070 } 00071 else 00072 { 00073 memset (hatch, 0, size); 00074 } 00075 #if DEBUG 00076 DXF_DEBUG_END 00077 #endif 00078 return (hatch); 00079 } 00080 00081 00089 DxfHatch * 00090 dxf_hatch_init 00091 ( 00092 DxfHatch *hatch 00094 ) 00095 { 00096 #if DEBUG 00097 DXF_DEBUG_BEGIN 00098 #endif 00099 /* Do some basic checks. */ 00100 if (hatch == NULL) 00101 { 00102 fprintf (stderr, 00103 (_("Warning in %s () a NULL pointer was passed.\n")), 00104 __FUNCTION__); 00105 hatch = dxf_hatch_new (); 00106 } 00107 if (hatch == NULL) 00108 { 00109 fprintf (stderr, 00110 (_("Error in %s () could not allocate memory for a DxfHatch struct.\n")), 00111 __FUNCTION__); 00112 return (NULL); 00113 } 00114 hatch->id_code = 0; 00115 hatch->linetype = strdup (DXF_DEFAULT_LINETYPE); 00116 hatch->layer = strdup (DXF_DEFAULT_LAYER); 00117 hatch->x0 = 0.0; 00118 hatch->y0 = 0.0; 00119 hatch->z0 = 0.0; 00120 hatch->extr_x0 = 0.0; 00121 hatch->extr_y0 = 0.0; 00122 hatch->extr_z0 = 0.0; 00123 hatch->thickness = 0.0; 00124 hatch->pattern_scale = 1.0; 00125 hatch->pixel_size = 1.0; 00126 hatch->pattern_angle = 0.0; 00127 hatch->linetype_scale = DXF_DEFAULT_LINETYPE_SCALE; 00128 hatch->visibility = DXF_DEFAULT_VISIBILITY; 00129 hatch->color = DXF_COLOR_BYLAYER; 00130 hatch->paperspace = DXF_MODELSPACE; 00131 hatch->solid_fill = 0; 00132 hatch->associative = 1; 00133 hatch->hatch_style = 0; 00134 hatch->hatch_pattern_type = 0; 00135 hatch->pattern_double = 0; 00136 hatch->number_of_pattern_def_lines = 0; 00137 dxf_hatch_pattern_def_line_init ((DxfHatchPatternDefLine *) hatch->def_lines); 00138 hatch->number_of_boundary_paths = 0; 00139 dxf_hatch_boundary_path_init ((DxfHatchBoundaryPath *) hatch->paths); 00140 hatch->number_of_seed_points = 0; 00141 dxf_hatch_pattern_seedpoint_init ((DxfHatchPatternSeedPoint *) hatch->seed_points); 00142 hatch->graphics_data_size = 0; 00143 dxf_binary_graphics_data_init ((DxfBinaryGraphicsData *) hatch->binary_graphics_data); 00144 dxf_hatch_pattern_init ((DxfHatchPattern *) hatch->patterns); 00145 hatch->dictionary_owner_soft = strdup (""); 00146 hatch->dictionary_owner_hard = strdup (""); 00147 hatch->next = NULL; 00148 #if DEBUG 00149 DXF_DEBUG_END 00150 #endif 00151 return (hatch); 00152 } 00153 00154 00158 int 00159 dxf_hatch_write 00160 ( 00161 DxfFile *fp, 00163 DxfHatch *hatch 00165 ) 00166 { 00167 #if DEBUG 00168 DXF_DEBUG_BEGIN 00169 #endif 00170 char *dxf_entity_name = strdup ("HATCH"); 00171 DxfBinaryGraphicsData *data = NULL; 00172 DxfHatchPatternDefLine *line = NULL; 00173 DxfHatchPatternSeedPoint *point = NULL; 00174 00175 /* Do some basic checks. */ 00176 if (fp == NULL) 00177 { 00178 fprintf (stderr, 00179 (_("Error in %s () a NULL file pointer was passed.\n")), 00180 __FUNCTION__); 00181 /* Clean up. */ 00182 free (dxf_entity_name); 00183 return (EXIT_FAILURE); 00184 } 00185 if (fp->acad_version_number < AutoCAD_14) 00186 { 00187 fprintf (stderr, 00188 (_("Error in %s () illegal DXF version for this entity.\n")), 00189 __FUNCTION__); 00190 /* Clean up. */ 00191 free (dxf_entity_name); 00192 return (EXIT_FAILURE); 00193 } 00194 if (hatch == NULL) 00195 { 00196 fprintf (stderr, 00197 (_("Error in %s () a NULL pointer was passed.\n")), 00198 __FUNCTION__); 00199 /* Clean up. */ 00200 free (dxf_entity_name); 00201 return (EXIT_FAILURE); 00202 } 00203 if (strcmp (hatch->layer, "") == 0) 00204 { 00205 fprintf (stderr, 00206 (_("Warning: empty layer string for the %s entity with id-code: %x\n")), 00207 dxf_entity_name, hatch->id_code); 00208 fprintf (stderr, 00209 (_(" %s entity is relocated to layer 0")), 00210 dxf_entity_name); 00211 hatch->layer = strdup (DXF_DEFAULT_LAYER); 00212 } 00213 if (strcmp (hatch->linetype, "") == 0) 00214 { 00215 fprintf (stderr, 00216 (_("Warning: empty linetype string for the %s entity with id-code: %x\n")), 00217 dxf_entity_name, hatch->id_code); 00218 fprintf (stderr, 00219 (_(" %s entity is reset to default linetype")), 00220 dxf_entity_name); 00221 hatch->linetype = strdup (DXF_DEFAULT_LINETYPE); 00222 } 00223 /* Start writing output. */ 00224 fprintf (fp->fp, " 0\n%s\n", dxf_entity_name); 00225 if (hatch->id_code != -1) 00226 { 00227 fprintf (fp->fp, " 5\n%x\n", hatch->id_code); 00228 } 00239 if ((strcmp (hatch->dictionary_owner_soft, "") != 0) 00240 && (fp->acad_version_number >= AutoCAD_14)) 00241 { 00242 fprintf (fp->fp, "102\n{ACAD_REACTORS\n"); 00243 fprintf (fp->fp, "330\n%s\n", hatch->dictionary_owner_soft); 00244 fprintf (fp->fp, "102\n}\n"); 00245 } 00246 if ((strcmp (hatch->dictionary_owner_hard, "") != 0) 00247 && (fp->acad_version_number >= AutoCAD_14)) 00248 { 00249 fprintf (fp->fp, "102\n{ACAD_XDICTIONARY\n"); 00250 fprintf (fp->fp, "360\n%s\n", hatch->dictionary_owner_hard); 00251 fprintf (fp->fp, "102\n}\n"); 00252 } 00253 if (fp->acad_version_number >= AutoCAD_13) 00254 { 00255 fprintf (fp->fp, "100\nAcDbEntity\n"); 00256 } 00257 if (hatch->paperspace == DXF_PAPERSPACE) 00258 { 00259 fprintf (fp->fp, " 67\n%d\n", DXF_PAPERSPACE); 00260 } 00261 fprintf (fp->fp, " 8\n%s\n", hatch->layer); 00262 if (strcmp (hatch->linetype, DXF_DEFAULT_LINETYPE) != 0) 00263 { 00264 fprintf (fp->fp, " 6\n%s\n", hatch->linetype); 00265 } 00266 if ((fp->acad_version_number <= AutoCAD_11) 00267 && DXF_FLATLAND 00268 && (hatch->elevation != 0.0)) 00269 { 00270 fprintf (fp->fp, " 38\n%f\n", hatch->elevation); 00271 } 00272 if (hatch->thickness != 0.0) 00273 { 00274 fprintf (fp->fp, " 39\n%f\n", hatch->thickness); 00275 } 00276 if (hatch->color != DXF_COLOR_BYLAYER) 00277 { 00278 fprintf (fp->fp, " 62\n%d\n", hatch->color); 00279 } 00280 if (hatch->linetype_scale != 1.0) 00281 { 00282 fprintf (fp->fp, " 48\n%f\n", hatch->linetype_scale); 00283 } 00284 if (hatch->visibility != 0) 00285 { 00286 fprintf (fp->fp, " 60\n%d\n", hatch->visibility); 00287 } 00288 if (hatch->graphics_data_size > 0) 00289 { 00290 fprintf (fp->fp, " 92\n%d\n", hatch->graphics_data_size); 00291 } 00292 data = (DxfBinaryGraphicsData *) hatch->binary_graphics_data; 00293 while (data != NULL) 00294 { 00295 fprintf (fp->fp, "310\n%s\n", data->data_line); 00296 data = (DxfBinaryGraphicsData *) dxf_binary_graphics_data_get_next (data); 00297 } 00298 fprintf (fp->fp, "100\nAcDbHatch\n"); 00299 fprintf (fp->fp, " 10\n%f\n", hatch->x0); 00300 fprintf (fp->fp, " 20\n%f\n", hatch->y0); 00301 fprintf (fp->fp, " 30\n%f\n", hatch->z0); 00302 fprintf (fp->fp, "210\n%f\n", hatch->extr_x0); 00303 fprintf (fp->fp, "220\n%f\n", hatch->extr_y0); 00304 fprintf (fp->fp, "230\n%f\n", hatch->extr_z0); 00305 fprintf (fp->fp, " 2\n%s\n", hatch->pattern_name); 00306 fprintf (fp->fp, " 70\n%d\n", hatch->solid_fill); 00307 fprintf (fp->fp, " 71\n%d\n", hatch->associative); 00308 fprintf (fp->fp, " 91\n%d\n", hatch->number_of_boundary_paths); 00309 dxf_hatch_boundary_path_write (fp, (DxfHatchBoundaryPath *) hatch->paths); 00310 fprintf (fp->fp, " 75\n%d\n", hatch->hatch_style); 00311 fprintf (fp->fp, " 76\n%d\n", hatch->hatch_pattern_type); 00312 if (!hatch->solid_fill) 00313 { 00314 fprintf (fp->fp, " 52\n%f\n", hatch->pattern_angle); 00315 fprintf (fp->fp, " 41\n%f\n", hatch->pattern_scale); 00316 fprintf (fp->fp, " 77\n%d\n", hatch->pattern_double); 00317 } 00318 fprintf (fp->fp, " 78\n%d\n", hatch->number_of_pattern_def_lines); 00319 line = (DxfHatchPatternDefLine *) hatch->def_lines; 00320 while (line != NULL) 00321 { 00322 dxf_hatch_pattern_def_line_write (fp, (DxfHatchPatternDefLine *) line); 00323 line = (DxfHatchPatternDefLine *) line->next; 00324 } 00325 fprintf (fp->fp, " 47\n%f\n", hatch->pixel_size); 00326 fprintf (fp->fp, " 98\n%d\n", hatch->number_of_seed_points); 00327 point = (DxfHatchPatternSeedPoint *) hatch->seed_points; 00328 while (point != NULL) 00329 { 00330 dxf_hatch_pattern_seedpoint_write (fp, (DxfHatchPatternSeedPoint *) point); 00331 point = (DxfHatchPatternSeedPoint *) point->next; 00332 } 00333 /* Clean up. */ 00334 dxf_hatch_pattern_def_line_free (line); 00335 dxf_hatch_pattern_seedpoint_free (point); 00336 free (dxf_entity_name); 00337 #if DEBUG 00338 DXF_DEBUG_END 00339 #endif 00340 return (EXIT_SUCCESS); 00341 } 00342 00343 00351 int 00352 dxf_hatch_free 00353 ( 00354 DxfHatch *hatch 00357 ) 00358 { 00359 #if DEBUG 00360 DXF_DEBUG_BEGIN 00361 #endif 00362 /* Do some basic checks. */ 00363 if (hatch == NULL) 00364 { 00365 fprintf (stderr, 00366 (_("Error in %s () a NULL pointer was passed.\n")), 00367 __FUNCTION__); 00368 return (EXIT_FAILURE); 00369 } 00370 if (hatch->next != NULL) 00371 { 00372 fprintf (stderr, 00373 (_("Error in %s () pointer to next was not NULL.\n")), 00374 __FUNCTION__); 00375 return (EXIT_FAILURE); 00376 } 00377 free (hatch->pattern_name); 00378 free (hatch->linetype); 00379 free (hatch->layer); 00380 free (hatch->def_lines); 00381 free (hatch->paths); 00382 free (hatch->seed_points); 00383 dxf_binary_graphics_data_free_chain ((DxfBinaryGraphicsData *) hatch->binary_graphics_data); 00384 dxf_hatch_pattern_free_chain ((DxfHatchPattern *) hatch->patterns); 00385 free (hatch->dictionary_owner_soft); 00386 free (hatch->dictionary_owner_hard); 00387 free (hatch); 00388 hatch = NULL; 00389 #if DEBUG 00390 DXF_DEBUG_END 00391 #endif 00392 return (EXIT_SUCCESS); 00393 } 00394 00395 00400 void 00401 dxf_hatch_free_chain 00402 ( 00403 DxfHatch *hatches 00405 ) 00406 { 00407 #ifdef DEBUG 00408 DXF_DEBUG_BEGIN 00409 #endif 00410 /* Do some basic checks. */ 00411 if (hatches == NULL) 00412 { 00413 fprintf (stderr, 00414 (_("Warning in %s () a NULL pointer was passed.\n")), 00415 __FUNCTION__); 00416 } 00417 while (hatches != NULL) 00418 { 00419 struct DxfHatch *iter = hatches->next; 00420 dxf_hatch_free (hatches); 00421 hatches = (DxfHatch *) iter; 00422 } 00423 #if DEBUG 00424 DXF_DEBUG_END 00425 #endif 00426 } 00427 00428 00434 int 00435 dxf_hatch_get_id_code 00436 ( 00437 DxfHatch *hatch 00439 ) 00440 { 00441 #if DEBUG 00442 DXF_DEBUG_BEGIN 00443 #endif 00444 int result; 00445 00446 /* Do some basic checks. */ 00447 if (hatch == NULL) 00448 { 00449 fprintf (stderr, 00450 (_("Error in %s () a NULL pointer was passed.\n")), 00451 __FUNCTION__); 00452 return (EXIT_FAILURE); 00453 } 00454 if (hatch->id_code < 0) 00455 { 00456 fprintf (stderr, 00457 (_("Error in %s () a negative value was found in the id_code member.\n")), 00458 __FUNCTION__); 00459 return (EXIT_FAILURE); 00460 } 00461 result = hatch->id_code; 00462 #if DEBUG 00463 DXF_DEBUG_END 00464 #endif 00465 return (result); 00466 } 00467 00468 00472 DxfHatch * 00473 dxf_hatch_set_id_code 00474 ( 00475 DxfHatch *hatch, 00477 int id_code 00481 ) 00482 { 00483 #if DEBUG 00484 DXF_DEBUG_BEGIN 00485 #endif 00486 /* Do some basic checks. */ 00487 if (hatch == NULL) 00488 { 00489 fprintf (stderr, 00490 (_("Error in %s () a NULL pointer was passed.\n")), 00491 __FUNCTION__); 00492 return (NULL); 00493 } 00494 if (id_code < 0) 00495 { 00496 fprintf (stderr, 00497 (_("Error in %s () a negative id-code value was passed.\n")), 00498 __FUNCTION__); 00499 return (NULL); 00500 } 00501 hatch->id_code = id_code; 00502 #if DEBUG 00503 DXF_DEBUG_END 00504 #endif 00505 return (hatch); 00506 } 00507 00508 00514 char * 00515 dxf_hatch_get_linetype 00516 ( 00517 DxfHatch *hatch 00519 ) 00520 { 00521 #if DEBUG 00522 DXF_DEBUG_BEGIN 00523 #endif 00524 char *result = NULL; 00525 00526 /* Do some basic checks. */ 00527 if (hatch == NULL) 00528 { 00529 fprintf (stderr, 00530 (_("Error in %s () a NULL pointer was passed.\n")), 00531 __FUNCTION__); 00532 return (NULL); 00533 } 00534 if (hatch->linetype == NULL) 00535 { 00536 fprintf (stderr, 00537 (_("Error in %s () a NULL pointer was found in the linetype member.\n")), 00538 __FUNCTION__); 00539 return (NULL); 00540 } 00541 result = strdup (hatch->linetype); 00542 #if DEBUG 00543 DXF_DEBUG_END 00544 #endif 00545 return (result); 00546 } 00547 00548 00552 DxfHatch * 00553 dxf_hatch_set_linetype 00554 ( 00555 DxfHatch *hatch, 00557 char *linetype 00559 ) 00560 { 00561 #if DEBUG 00562 DXF_DEBUG_BEGIN 00563 #endif 00564 /* Do some basic checks. */ 00565 if (hatch == NULL) 00566 { 00567 fprintf (stderr, 00568 (_("Error in %s () a NULL pointer was passed.\n")), 00569 __FUNCTION__); 00570 return (NULL); 00571 } 00572 if (linetype == NULL) 00573 { 00574 fprintf (stderr, 00575 (_("Error in %s () a NULL pointer was passed.\n")), 00576 __FUNCTION__); 00577 return (NULL); 00578 } 00579 hatch->linetype = strdup (linetype); 00580 #if DEBUG 00581 DXF_DEBUG_END 00582 #endif 00583 return (hatch); 00584 } 00585 00586 00592 char * 00593 dxf_hatch_get_layer 00594 ( 00595 DxfHatch *hatch 00597 ) 00598 { 00599 #if DEBUG 00600 DXF_DEBUG_BEGIN 00601 #endif 00602 char *result = NULL; 00603 00604 /* Do some basic checks. */ 00605 if (hatch == NULL) 00606 { 00607 fprintf (stderr, 00608 (_("Error in %s () a NULL pointer was passed.\n")), 00609 __FUNCTION__); 00610 return (NULL); 00611 } 00612 if (hatch->layer == NULL) 00613 { 00614 fprintf (stderr, 00615 (_("Error in %s () a NULL pointer was found in the layer member.\n")), 00616 __FUNCTION__); 00617 return (NULL); 00618 } 00619 result = strdup (hatch->layer); 00620 #if DEBUG 00621 DXF_DEBUG_END 00622 #endif 00623 return (result); 00624 } 00625 00626 00630 DxfHatch * 00631 dxf_hatch_set_layer 00632 ( 00633 DxfHatch *hatch, 00635 char *layer 00637 ) 00638 { 00639 #if DEBUG 00640 DXF_DEBUG_BEGIN 00641 #endif 00642 /* Do some basic checks. */ 00643 if (hatch == NULL) 00644 { 00645 fprintf (stderr, 00646 (_("Error in %s () a NULL pointer was passed.\n")), 00647 __FUNCTION__); 00648 return (NULL); 00649 } 00650 if (layer == NULL) 00651 { 00652 fprintf (stderr, 00653 (_("Error in %s () a NULL pointer was passed.\n")), 00654 __FUNCTION__); 00655 return (NULL); 00656 } 00657 hatch->layer = strdup (layer); 00658 #if DEBUG 00659 DXF_DEBUG_END 00660 #endif 00661 return (hatch); 00662 } 00663 00664 00670 double 00671 dxf_hatch_get_elevation 00672 ( 00673 DxfHatch *hatch 00675 ) 00676 { 00677 #if DEBUG 00678 DXF_DEBUG_BEGIN 00679 #endif 00680 double result; 00681 00682 /* Do some basic checks. */ 00683 if (hatch == NULL) 00684 { 00685 fprintf (stderr, 00686 (_("Error in %s () a NULL pointer was passed.\n")), 00687 __FUNCTION__); 00688 return (EXIT_FAILURE); 00689 } 00690 result = hatch->elevation; 00691 #if DEBUG 00692 DXF_DEBUG_END 00693 #endif 00694 return (result); 00695 } 00696 00697 00701 DxfHatch * 00702 dxf_hatch_set_elevation 00703 ( 00704 DxfHatch *hatch, 00706 double elevation 00708 ) 00709 { 00710 #if DEBUG 00711 DXF_DEBUG_BEGIN 00712 #endif 00713 /* Do some basic checks. */ 00714 if (hatch == NULL) 00715 { 00716 fprintf (stderr, 00717 (_("Error in %s () a NULL pointer was passed.\n")), 00718 __FUNCTION__); 00719 return (NULL); 00720 } 00721 hatch->elevation = elevation; 00722 #if DEBUG 00723 DXF_DEBUG_END 00724 #endif 00725 return (hatch); 00726 } 00727 00728 00734 double 00735 dxf_hatch_get_thickness 00736 ( 00737 DxfHatch *hatch 00739 ) 00740 { 00741 #if DEBUG 00742 DXF_DEBUG_BEGIN 00743 #endif 00744 double result; 00745 00746 /* Do some basic checks. */ 00747 if (hatch == NULL) 00748 { 00749 fprintf (stderr, 00750 (_("Error in %s () a NULL pointer was passed.\n")), 00751 __FUNCTION__); 00752 return (EXIT_FAILURE); 00753 } 00754 if (hatch->thickness < 0.0) 00755 { 00756 fprintf (stderr, 00757 (_("Warning in %s () a negative value was found in the thickness member.\n")), 00758 __FUNCTION__); 00759 } 00760 result = hatch->thickness; 00761 #if DEBUG 00762 DXF_DEBUG_END 00763 #endif 00764 return (result); 00765 } 00766 00767 00771 DxfHatch * 00772 dxf_hatch_set_thickness 00773 ( 00774 DxfHatch *hatch, 00776 double thickness 00778 ) 00779 { 00780 #if DEBUG 00781 DXF_DEBUG_BEGIN 00782 #endif 00783 /* Do some basic checks. */ 00784 if (hatch == NULL) 00785 { 00786 fprintf (stderr, 00787 (_("Error in %s () a NULL pointer was passed.\n")), 00788 __FUNCTION__); 00789 return (NULL); 00790 } 00791 if (thickness < 0.0) 00792 { 00793 fprintf (stderr, 00794 (_("Warning in %s () a negative thickness value was passed.\n")), 00795 __FUNCTION__); 00796 } 00797 hatch->thickness = thickness; 00798 #if DEBUG 00799 DXF_DEBUG_END 00800 #endif 00801 return (hatch); 00802 } 00803 00804 00810 double 00811 dxf_hatch_get_linetype_scale 00812 ( 00813 DxfHatch *hatch 00815 ) 00816 { 00817 #if DEBUG 00818 DXF_DEBUG_BEGIN 00819 #endif 00820 double result; 00821 00822 /* Do some basic checks. */ 00823 if (hatch == NULL) 00824 { 00825 fprintf (stderr, 00826 (_("Error in %s () a NULL pointer was passed.\n")), 00827 __FUNCTION__); 00828 return (EXIT_FAILURE); 00829 } 00830 if (hatch->linetype_scale < 0.0) 00831 { 00832 fprintf (stderr, 00833 (_("Error in %s () a negative value was found in the linetype scale member.\n")), 00834 __FUNCTION__); 00835 return (EXIT_FAILURE); 00836 } 00837 result = hatch->linetype_scale; 00838 #if DEBUG 00839 DXF_DEBUG_END 00840 #endif 00841 return (result); 00842 } 00843 00844 00848 DxfHatch * 00849 dxf_hatch_set_linetype_scale 00850 ( 00851 DxfHatch *hatch, 00853 double linetype_scale 00855 ) 00856 { 00857 #if DEBUG 00858 DXF_DEBUG_BEGIN 00859 #endif 00860 /* Do some basic checks. */ 00861 if (hatch == NULL) 00862 { 00863 fprintf (stderr, 00864 (_("Error in %s () a NULL pointer was passed.\n")), 00865 __FUNCTION__); 00866 return (NULL); 00867 } 00868 if (linetype_scale < 0.0) 00869 { 00870 fprintf (stderr, 00871 (_("Error in %s () a negative linetype scale value was passed.\n")), 00872 __FUNCTION__); 00873 return (NULL); 00874 } 00875 hatch->linetype_scale = linetype_scale; 00876 #if DEBUG 00877 DXF_DEBUG_END 00878 #endif 00879 return (hatch); 00880 } 00881 00882 00888 int16_t 00889 dxf_hatch_get_visibility 00890 ( 00891 DxfHatch *hatch 00893 ) 00894 { 00895 #if DEBUG 00896 DXF_DEBUG_BEGIN 00897 #endif 00898 int16_t result; 00899 00900 /* Do some basic checks. */ 00901 if (hatch == NULL) 00902 { 00903 fprintf (stderr, 00904 (_("Error in %s () a NULL pointer was passed.\n")), 00905 __FUNCTION__); 00906 return (EXIT_FAILURE); 00907 } 00908 if (hatch->visibility < 0) 00909 { 00910 fprintf (stderr, 00911 (_("Error in %s () a negative value was found in the visibility member.\n")), 00912 __FUNCTION__); 00913 return (EXIT_FAILURE); 00914 } 00915 if (hatch->visibility > 1) 00916 { 00917 fprintf (stderr, 00918 (_("Error in %s () an out of range value was found in the visibility member.\n")), 00919 __FUNCTION__); 00920 return (EXIT_FAILURE); 00921 } 00922 result = hatch->visibility; 00923 #if DEBUG 00924 DXF_DEBUG_END 00925 #endif 00926 return (result); 00927 } 00928 00929 00933 DxfHatch * 00934 dxf_hatch_set_visibility 00935 ( 00936 DxfHatch *hatch, 00938 int16_t visibility 00940 ) 00941 { 00942 #if DEBUG 00943 DXF_DEBUG_BEGIN 00944 #endif 00945 /* Do some basic checks. */ 00946 if (hatch == NULL) 00947 { 00948 fprintf (stderr, 00949 (_("Error in %s () a NULL pointer was passed.\n")), 00950 __FUNCTION__); 00951 return (NULL); 00952 } 00953 if (visibility < 0) 00954 { 00955 fprintf (stderr, 00956 (_("Error in %s () a negative visibility value was passed.\n")), 00957 __FUNCTION__); 00958 return (NULL); 00959 } 00960 if (visibility > 1) 00961 { 00962 fprintf (stderr, 00963 (_("Error in %s () an out of range visibility value was passed.\n")), 00964 __FUNCTION__); 00965 return (NULL); 00966 } 00967 hatch->visibility = visibility; 00968 #if DEBUG 00969 DXF_DEBUG_END 00970 #endif 00971 return (hatch); 00972 } 00973 00974 00980 int 00981 dxf_hatch_get_color 00982 ( 00983 DxfHatch *hatch 00985 ) 00986 { 00987 #if DEBUG 00988 DXF_DEBUG_BEGIN 00989 #endif 00990 int result; 00991 00992 /* Do some basic checks. */ 00993 if (hatch == NULL) 00994 { 00995 fprintf (stderr, 00996 (_("Error in %s () a NULL pointer was passed.\n")), 00997 __FUNCTION__); 00998 return (EXIT_FAILURE); 00999 } 01000 if (hatch->color < 0) 01001 { 01002 fprintf (stderr, 01003 (_("Warning in %s () a negative value was found in the color member.\n")), 01004 __FUNCTION__); 01005 } 01006 result = hatch->color; 01007 #if DEBUG 01008 DXF_DEBUG_END 01009 #endif 01010 return (result); 01011 } 01012 01013 01017 DxfHatch * 01018 dxf_hatch_set_color 01019 ( 01020 DxfHatch *hatch, 01022 int color 01024 ) 01025 { 01026 #if DEBUG 01027 DXF_DEBUG_BEGIN 01028 #endif 01029 /* Do some basic checks. */ 01030 if (hatch == NULL) 01031 { 01032 fprintf (stderr, 01033 (_("Error in %s () a NULL pointer was passed.\n")), 01034 __FUNCTION__); 01035 return (NULL); 01036 } 01037 if (color < 0) 01038 { 01039 fprintf (stderr, 01040 (_("Warning in %s () a negative color value was passed.\n")), 01041 __FUNCTION__); 01042 fprintf (stderr, 01043 (_("\teffectively turning this entity it's visibility off.\n"))); 01044 } 01045 hatch->color = color; 01046 #if DEBUG 01047 DXF_DEBUG_END 01048 #endif 01049 return (hatch); 01050 } 01051 01052 01058 int 01059 dxf_hatch_get_paperspace 01060 ( 01061 DxfHatch *hatch 01063 ) 01064 { 01065 #if DEBUG 01066 DXF_DEBUG_BEGIN 01067 #endif 01068 int result; 01069 01070 /* Do some basic checks. */ 01071 if (hatch == NULL) 01072 { 01073 fprintf (stderr, 01074 (_("Error in %s () a NULL pointer was passed.\n")), 01075 __FUNCTION__); 01076 return (EXIT_FAILURE); 01077 } 01078 if (hatch->paperspace < 0) 01079 { 01080 fprintf (stderr, 01081 (_("Warning in %s () a negative value was found in the paperspace member.\n")), 01082 __FUNCTION__); 01083 } 01084 if (hatch->paperspace > 1) 01085 { 01086 fprintf (stderr, 01087 (_("Warning in %s () an out of range value was found in the paperspace member.\n")), 01088 __FUNCTION__); 01089 } 01090 result = hatch->paperspace; 01091 #if DEBUG 01092 DXF_DEBUG_END 01093 #endif 01094 return (result); 01095 } 01096 01097 01101 DxfHatch * 01102 dxf_hatch_set_paperspace 01103 ( 01104 DxfHatch *hatch, 01106 int paperspace 01108 ) 01109 { 01110 #if DEBUG 01111 DXF_DEBUG_BEGIN 01112 #endif 01113 /* Do some basic checks. */ 01114 if (hatch == NULL) 01115 { 01116 fprintf (stderr, 01117 (_("Error in %s () a NULL pointer was passed.\n")), 01118 __FUNCTION__); 01119 return (NULL); 01120 } 01121 if (paperspace < 0) 01122 { 01123 fprintf (stderr, 01124 (_("Error in %s () a negative paperspace value was passed.\n")), 01125 __FUNCTION__); 01126 return (NULL); 01127 } 01128 if (paperspace > 1) 01129 { 01130 fprintf (stderr, 01131 (_("Error in %s () an out of range paperspace value was passed.\n")), 01132 __FUNCTION__); 01133 return (NULL); 01134 } 01135 hatch->paperspace = paperspace; 01136 #if DEBUG 01137 DXF_DEBUG_END 01138 #endif 01139 return (hatch); 01140 } 01141 01142 01148 int 01149 dxf_hatch_get_graphics_data_size 01150 ( 01151 DxfHatch *hatch 01153 ) 01154 { 01155 #if DEBUG 01156 DXF_DEBUG_BEGIN 01157 #endif 01158 int result; 01159 01160 /* Do some basic checks. */ 01161 if (hatch == NULL) 01162 { 01163 fprintf (stderr, 01164 (_("Error in %s () a NULL pointer was passed.\n")), 01165 __FUNCTION__); 01166 return (EXIT_FAILURE); 01167 } 01168 if (hatch->graphics_data_size < 0) 01169 { 01170 fprintf (stderr, 01171 (_("Warning in %s () a negative value was found in the graphics_data_size member.\n")), 01172 __FUNCTION__); 01173 } 01174 if (hatch->graphics_data_size == 0) 01175 { 01176 fprintf (stderr, 01177 (_("Warning in %s () a zero value was found in the graphics_data_size member.\n")), 01178 __FUNCTION__); 01179 } 01180 result = hatch->graphics_data_size; 01181 #if DEBUG 01182 DXF_DEBUG_END 01183 #endif 01184 return (result); 01185 } 01186 01187 01191 DxfHatch * 01192 dxf_hatch_set_graphics_data_size 01193 ( 01194 DxfHatch *hatch, 01196 int graphics_data_size 01199 ) 01200 { 01201 #if DEBUG 01202 DXF_DEBUG_BEGIN 01203 #endif 01204 /* Do some basic checks. */ 01205 if (hatch == NULL) 01206 { 01207 fprintf (stderr, 01208 (_("Error in %s () a NULL pointer was passed.\n")), 01209 __FUNCTION__); 01210 return (NULL); 01211 } 01212 if (graphics_data_size < 0) 01213 { 01214 fprintf (stderr, 01215 (_("Error in %s () a negative graphics_data_size value was passed.\n")), 01216 __FUNCTION__); 01217 return (NULL); 01218 } 01219 if (graphics_data_size == 0) 01220 { 01221 fprintf (stderr, 01222 (_("Error in %s () a zero graphics_data_size value was passed.\n")), 01223 __FUNCTION__); 01224 return (NULL); 01225 } 01226 hatch->graphics_data_size = graphics_data_size; 01227 #if DEBUG 01228 DXF_DEBUG_END 01229 #endif 01230 return (hatch); 01231 } 01232 01233 01242 DxfBinaryGraphicsData * 01243 dxf_hatch_get_binary_graphics_data 01244 ( 01245 DxfHatch *hatch 01247 ) 01248 { 01249 #if DEBUG 01250 DXF_DEBUG_BEGIN 01251 #endif 01252 DxfBinaryGraphicsData *result; 01253 01254 /* Do some basic checks. */ 01255 if (hatch == NULL) 01256 { 01257 fprintf (stderr, 01258 (_("Error in %s () a NULL pointer was passed.\n")), 01259 __FUNCTION__); 01260 return (NULL); 01261 } 01262 if (hatch->binary_graphics_data == NULL) 01263 { 01264 fprintf (stderr, 01265 (_("Error in %s () a NULL pointer was found in the binary_graphics_data member.\n")), 01266 __FUNCTION__); 01267 return (NULL); 01268 } 01269 result = (DxfBinaryGraphicsData *) hatch->binary_graphics_data; 01270 #if DEBUG 01271 DXF_DEBUG_END 01272 #endif 01273 return (result); 01274 } 01275 01276 01281 DxfHatch * 01282 dxf_hatch_set_binary_graphics_data 01283 ( 01284 DxfHatch *hatch, 01286 DxfBinaryGraphicsData *data 01289 ) 01290 { 01291 #if DEBUG 01292 DXF_DEBUG_BEGIN 01293 #endif 01294 /* Do some basic checks. */ 01295 if (hatch == NULL) 01296 { 01297 fprintf (stderr, 01298 (_("Error in %s () a NULL pointer was passed.\n")), 01299 __FUNCTION__); 01300 return (NULL); 01301 } 01302 if (data == NULL) 01303 { 01304 fprintf (stderr, 01305 (_("Error in %s () a NULL pointer was passed.\n")), 01306 __FUNCTION__); 01307 return (NULL); 01308 } 01309 hatch->binary_graphics_data = (struct DxfBinaryGraphicsData *) data; 01310 #if DEBUG 01311 DXF_DEBUG_END 01312 #endif 01313 return (hatch); 01314 } 01315 01316 01325 char * 01326 dxf_hatch_get_dictionary_owner_soft 01327 ( 01328 DxfHatch *hatch 01330 ) 01331 { 01332 #if DEBUG 01333 DXF_DEBUG_BEGIN 01334 #endif 01335 char *result; 01336 01337 /* Do some basic checks. */ 01338 if (hatch == NULL) 01339 { 01340 fprintf (stderr, 01341 (_("Error in %s () a NULL pointer was passed.\n")), 01342 __FUNCTION__); 01343 return (NULL); 01344 } 01345 if (hatch->dictionary_owner_soft == NULL) 01346 { 01347 fprintf (stderr, 01348 (_("Error in %s () a NULL pointer was found in the dictionary_owner_soft member.\n")), 01349 __FUNCTION__); 01350 return (NULL); 01351 } 01352 result = strdup (hatch->dictionary_owner_soft); 01353 #if DEBUG 01354 DXF_DEBUG_END 01355 #endif 01356 return (result); 01357 } 01358 01359 01364 DxfHatch * 01365 dxf_hatch_set_dictionary_owner_soft 01366 ( 01367 DxfHatch *hatch, 01369 char *dictionary_owner_soft 01372 ) 01373 { 01374 #if DEBUG 01375 DXF_DEBUG_BEGIN 01376 #endif 01377 /* Do some basic checks. */ 01378 if (hatch == NULL) 01379 { 01380 fprintf (stderr, 01381 (_("Error in %s () a NULL pointer was passed.\n")), 01382 __FUNCTION__); 01383 return (NULL); 01384 } 01385 if (dictionary_owner_soft == NULL) 01386 { 01387 fprintf (stderr, 01388 (_("Error in %s () a NULL pointer was passed.\n")), 01389 __FUNCTION__); 01390 return (NULL); 01391 } 01392 hatch->dictionary_owner_soft = strdup (dictionary_owner_soft); 01393 #if DEBUG 01394 DXF_DEBUG_END 01395 #endif 01396 return (hatch); 01397 } 01398 01399 01408 char * 01409 dxf_hatch_get_dictionary_owner_hard 01410 ( 01411 DxfHatch *hatch 01413 ) 01414 { 01415 #if DEBUG 01416 DXF_DEBUG_BEGIN 01417 #endif 01418 char *result; 01419 01420 /* Do some basic checks. */ 01421 if (hatch == NULL) 01422 { 01423 fprintf (stderr, 01424 (_("Error in %s () a NULL pointer was passed.\n")), 01425 __FUNCTION__); 01426 return (NULL); 01427 } 01428 if (hatch->dictionary_owner_hard == NULL) 01429 { 01430 fprintf (stderr, 01431 (_("Error in %s () a NULL pointer was found in the dictionary_owner_hard member.\n")), 01432 __FUNCTION__); 01433 return (NULL); 01434 } 01435 result = strdup (hatch->dictionary_owner_hard); 01436 #if DEBUG 01437 DXF_DEBUG_END 01438 #endif 01439 return (result); 01440 } 01441 01442 01447 DxfHatch * 01448 dxf_hatch_set_dictionary_owner_hard 01449 ( 01450 DxfHatch *hatch, 01452 char *dictionary_owner_hard 01455 ) 01456 { 01457 #if DEBUG 01458 DXF_DEBUG_BEGIN 01459 #endif 01460 /* Do some basic checks. */ 01461 if (hatch == NULL) 01462 { 01463 fprintf (stderr, 01464 (_("Error in %s () a NULL pointer was passed.\n")), 01465 __FUNCTION__); 01466 return (NULL); 01467 } 01468 if (dictionary_owner_hard == NULL) 01469 { 01470 fprintf (stderr, 01471 (_("Error in %s () a NULL pointer was passed.\n")), 01472 __FUNCTION__); 01473 return (NULL); 01474 } 01475 hatch->dictionary_owner_hard = strdup (dictionary_owner_hard); 01476 #if DEBUG 01477 DXF_DEBUG_END 01478 #endif 01479 return (hatch); 01480 } 01481 01482 01488 char * 01489 dxf_hatch_get_pattern_name 01490 ( 01491 DxfHatch *hatch 01493 ) 01494 { 01495 #if DEBUG 01496 DXF_DEBUG_BEGIN 01497 #endif 01498 char *result = NULL; 01499 01500 /* Do some basic checks. */ 01501 if (hatch == NULL) 01502 { 01503 fprintf (stderr, 01504 (_("Error in %s () a NULL pointer was passed.\n")), 01505 __FUNCTION__); 01506 return (NULL); 01507 } 01508 if (hatch->pattern_name == NULL) 01509 { 01510 fprintf (stderr, 01511 (_("Error in %s () a NULL pointer was found in the pattern_name member.\n")), 01512 __FUNCTION__); 01513 return (NULL); 01514 } 01515 result = strdup (hatch->pattern_name); 01516 #if DEBUG 01517 DXF_DEBUG_END 01518 #endif 01519 return (result); 01520 } 01521 01522 01526 DxfHatch * 01527 dxf_hatch_set_pattern_name 01528 ( 01529 DxfHatch *hatch, 01531 char *pattern_name 01533 ) 01534 { 01535 #if DEBUG 01536 DXF_DEBUG_BEGIN 01537 #endif 01538 /* Do some basic checks. */ 01539 if (hatch == NULL) 01540 { 01541 fprintf (stderr, 01542 (_("Error in %s () a NULL pointer was passed.\n")), 01543 __FUNCTION__); 01544 return (NULL); 01545 } 01546 if (pattern_name == NULL) 01547 { 01548 fprintf (stderr, 01549 (_("Error in %s () a NULL pointer was passed.\n")), 01550 __FUNCTION__); 01551 return (NULL); 01552 } 01553 hatch->pattern_name = strdup (pattern_name); 01554 #if DEBUG 01555 DXF_DEBUG_END 01556 #endif 01557 return (hatch); 01558 } 01559 01560 01566 double 01567 dxf_hatch_get_x0 01568 ( 01569 DxfHatch *hatch 01571 ) 01572 { 01573 #if DEBUG 01574 DXF_DEBUG_BEGIN 01575 #endif 01576 double result; 01577 01578 /* Do some basic checks. */ 01579 if (hatch == NULL) 01580 { 01581 fprintf (stderr, 01582 (_("Error in %s () a NULL pointer was passed.\n")), 01583 __FUNCTION__); 01584 return (EXIT_FAILURE); 01585 } 01586 result = hatch->x0; 01587 #if DEBUG 01588 DXF_DEBUG_END 01589 #endif 01590 return (result); 01591 } 01592 01593 01597 DxfHatch * 01598 dxf_hatch_set_x0 01599 ( 01600 DxfHatch *hatch, 01602 double x0 01604 ) 01605 { 01606 #if DEBUG 01607 DXF_DEBUG_BEGIN 01608 #endif 01609 /* Do some basic checks. */ 01610 if (hatch == NULL) 01611 { 01612 fprintf (stderr, 01613 (_("Error in %s () a NULL pointer was passed.\n")), 01614 __FUNCTION__); 01615 return (NULL); 01616 } 01617 hatch->x0 = x0; 01618 #if DEBUG 01619 DXF_DEBUG_END 01620 #endif 01621 return (hatch); 01622 } 01623 01624 01630 double 01631 dxf_hatch_get_y0 01632 ( 01633 DxfHatch *hatch 01635 ) 01636 { 01637 #if DEBUG 01638 DXF_DEBUG_BEGIN 01639 #endif 01640 double result; 01641 01642 /* Do some basic checks. */ 01643 if (hatch == NULL) 01644 { 01645 fprintf (stderr, 01646 (_("Error in %s () a NULL pointer was passed.\n")), 01647 __FUNCTION__); 01648 return (EXIT_FAILURE); 01649 } 01650 result = hatch->y0; 01651 #if DEBUG 01652 DXF_DEBUG_END 01653 #endif 01654 return (result); 01655 } 01656 01657 01661 DxfHatch * 01662 dxf_hatch_set_y0 01663 ( 01664 DxfHatch *hatch, 01666 double y0 01668 ) 01669 { 01670 #if DEBUG 01671 DXF_DEBUG_BEGIN 01672 #endif 01673 /* Do some basic checks. */ 01674 if (hatch == NULL) 01675 { 01676 fprintf (stderr, 01677 (_("Error in %s () a NULL pointer was passed.\n")), 01678 __FUNCTION__); 01679 return (NULL); 01680 } 01681 hatch->y0 = y0; 01682 #if DEBUG 01683 DXF_DEBUG_END 01684 #endif 01685 return (hatch); 01686 } 01687 01688 01694 double 01695 dxf_hatch_get_z0 01696 ( 01697 DxfHatch *hatch 01699 ) 01700 { 01701 #if DEBUG 01702 DXF_DEBUG_BEGIN 01703 #endif 01704 double result; 01705 01706 /* Do some basic checks. */ 01707 if (hatch == NULL) 01708 { 01709 fprintf (stderr, 01710 (_("Error in %s () a NULL pointer was passed.\n")), 01711 __FUNCTION__); 01712 return (EXIT_FAILURE); 01713 } 01714 result = hatch->z0; 01715 #if DEBUG 01716 DXF_DEBUG_END 01717 #endif 01718 return (result); 01719 } 01720 01721 01725 DxfHatch * 01726 dxf_hatch_set_z0 01727 ( 01728 DxfHatch *hatch, 01730 double z0 01732 ) 01733 { 01734 #if DEBUG 01735 DXF_DEBUG_BEGIN 01736 #endif 01737 /* Do some basic checks. */ 01738 if (hatch == NULL) 01739 { 01740 fprintf (stderr, 01741 (_("Error in %s () a NULL pointer was passed.\n")), 01742 __FUNCTION__); 01743 return (NULL); 01744 } 01745 hatch->z0 = z0; 01746 #if DEBUG 01747 DXF_DEBUG_END 01748 #endif 01749 return (hatch); 01750 } 01751 01752 01758 double 01759 dxf_hatch_get_pattern_scale 01760 ( 01761 DxfHatch *hatch 01763 ) 01764 { 01765 #if DEBUG 01766 DXF_DEBUG_BEGIN 01767 #endif 01768 double result; 01769 01770 /* Do some basic checks. */ 01771 if (hatch == NULL) 01772 { 01773 fprintf (stderr, 01774 (_("Error in %s () a NULL pointer was passed.\n")), 01775 __FUNCTION__); 01776 return (EXIT_FAILURE); 01777 } 01778 result = hatch->pattern_scale; 01779 #if DEBUG 01780 DXF_DEBUG_END 01781 #endif 01782 return (result); 01783 } 01784 01785 01789 DxfHatch * 01790 dxf_hatch_set_pattern_scale 01791 ( 01792 DxfHatch *hatch, 01794 double pattern_scale 01796 ) 01797 { 01798 #if DEBUG 01799 DXF_DEBUG_BEGIN 01800 #endif 01801 /* Do some basic checks. */ 01802 if (hatch == NULL) 01803 { 01804 fprintf (stderr, 01805 (_("Error in %s () a NULL pointer was passed.\n")), 01806 __FUNCTION__); 01807 return (NULL); 01808 } 01809 hatch->pattern_scale = pattern_scale; 01810 #if DEBUG 01811 DXF_DEBUG_END 01812 #endif 01813 return (hatch); 01814 } 01815 01816 01822 double 01823 dxf_hatch_get_pixel_size 01824 ( 01825 DxfHatch *hatch 01827 ) 01828 { 01829 #if DEBUG 01830 DXF_DEBUG_BEGIN 01831 #endif 01832 double result; 01833 01834 /* Do some basic checks. */ 01835 if (hatch == NULL) 01836 { 01837 fprintf (stderr, 01838 (_("Error in %s () a NULL pointer was passed.\n")), 01839 __FUNCTION__); 01840 return (EXIT_FAILURE); 01841 } 01842 result = hatch->pixel_size; 01843 #if DEBUG 01844 DXF_DEBUG_END 01845 #endif 01846 return (result); 01847 } 01848 01849 01853 DxfHatch * 01854 dxf_hatch_set_pixel_size 01855 ( 01856 DxfHatch *hatch, 01858 double pixel_size 01860 ) 01861 { 01862 #if DEBUG 01863 DXF_DEBUG_BEGIN 01864 #endif 01865 /* Do some basic checks. */ 01866 if (hatch == NULL) 01867 { 01868 fprintf (stderr, 01869 (_("Error in %s () a NULL pointer was passed.\n")), 01870 __FUNCTION__); 01871 return (NULL); 01872 } 01873 hatch->pixel_size = pixel_size; 01874 #if DEBUG 01875 DXF_DEBUG_END 01876 #endif 01877 return (hatch); 01878 } 01879 01880 01886 double 01887 dxf_hatch_get_pattern_angle 01888 ( 01889 DxfHatch *hatch 01891 ) 01892 { 01893 #if DEBUG 01894 DXF_DEBUG_BEGIN 01895 #endif 01896 double result; 01897 01898 /* Do some basic checks. */ 01899 if (hatch == NULL) 01900 { 01901 fprintf (stderr, 01902 (_("Error in %s () a NULL pointer was passed.\n")), 01903 __FUNCTION__); 01904 return (EXIT_FAILURE); 01905 } 01906 result = hatch->pattern_angle; 01907 #if DEBUG 01908 DXF_DEBUG_END 01909 #endif 01910 return (result); 01911 } 01912 01913 01917 DxfHatch * 01918 dxf_hatch_set_pattern_angle 01919 ( 01920 DxfHatch *hatch, 01922 double pattern_angle 01924 ) 01925 { 01926 #if DEBUG 01927 DXF_DEBUG_BEGIN 01928 #endif 01929 /* Do some basic checks. */ 01930 if (hatch == NULL) 01931 { 01932 fprintf (stderr, 01933 (_("Error in %s () a NULL pointer was passed.\n")), 01934 __FUNCTION__); 01935 return (NULL); 01936 } 01937 hatch->pattern_angle = pattern_angle; 01938 #if DEBUG 01939 DXF_DEBUG_END 01940 #endif 01941 return (hatch); 01942 } 01943 01944 01950 int 01951 dxf_hatch_get_solid_fill 01952 ( 01953 DxfHatch *hatch 01955 ) 01956 { 01957 #if DEBUG 01958 DXF_DEBUG_BEGIN 01959 #endif 01960 int result; 01961 01962 /* Do some basic checks. */ 01963 if (hatch == NULL) 01964 { 01965 fprintf (stderr, 01966 (_("Error in %s () a NULL pointer was passed.\n")), 01967 __FUNCTION__); 01968 return (EXIT_FAILURE); 01969 } 01970 if (hatch->solid_fill < 0) 01971 { 01972 fprintf (stderr, 01973 (_("Error in %s () a negative value was found in the solid_fill member.\n")), 01974 __FUNCTION__); 01975 return (EXIT_FAILURE); 01976 } 01977 if (hatch->solid_fill > 1) 01978 { 01979 fprintf (stderr, 01980 (_("Error in %s () an out of range value was found in the solid_fill member.\n")), 01981 __FUNCTION__); 01982 return (EXIT_FAILURE); 01983 } 01984 result = hatch->solid_fill; 01985 #if DEBUG 01986 DXF_DEBUG_END 01987 #endif 01988 return (result); 01989 } 01990 01991 01995 DxfHatch * 01996 dxf_hatch_set_solid_fill 01997 ( 01998 DxfHatch *hatch, 02000 int solid_fill 02002 ) 02003 { 02004 #if DEBUG 02005 DXF_DEBUG_BEGIN 02006 #endif 02007 /* Do some basic checks. */ 02008 if (hatch == NULL) 02009 { 02010 fprintf (stderr, 02011 (_("Error in %s () a NULL pointer was passed.\n")), 02012 __FUNCTION__); 02013 return (NULL); 02014 } 02015 if (solid_fill < 0) 02016 { 02017 fprintf (stderr, 02018 (_("Error in %s () a negative solid_fill value was passed.\n")), 02019 __FUNCTION__); 02020 return (NULL); 02021 } 02022 if (solid_fill > 1) 02023 { 02024 fprintf (stderr, 02025 (_("Error in %s () an out of range solid_fill value was passed.\n")), 02026 __FUNCTION__); 02027 return (NULL); 02028 } 02029 hatch->solid_fill = solid_fill; 02030 #if DEBUG 02031 DXF_DEBUG_END 02032 #endif 02033 return (hatch); 02034 } 02035 02036 02042 int 02043 dxf_hatch_get_associative 02044 ( 02045 DxfHatch *hatch 02047 ) 02048 { 02049 #if DEBUG 02050 DXF_DEBUG_BEGIN 02051 #endif 02052 int result; 02053 02054 /* Do some basic checks. */ 02055 if (hatch == NULL) 02056 { 02057 fprintf (stderr, 02058 (_("Error in %s () a NULL pointer was passed.\n")), 02059 __FUNCTION__); 02060 return (EXIT_FAILURE); 02061 } 02062 if (hatch->associative < 0) 02063 { 02064 fprintf (stderr, 02065 (_("Error in %s () a negative value was found in the associative member.\n")), 02066 __FUNCTION__); 02067 return (EXIT_FAILURE); 02068 } 02069 if (hatch->associative > 1) 02070 { 02071 fprintf (stderr, 02072 (_("Error in %s () an out of range value was found in the associative member.\n")), 02073 __FUNCTION__); 02074 return (EXIT_FAILURE); 02075 } 02076 result = hatch->associative; 02077 #if DEBUG 02078 DXF_DEBUG_END 02079 #endif 02080 return (result); 02081 } 02082 02083 02087 DxfHatch * 02088 dxf_hatch_set_associative 02089 ( 02090 DxfHatch *hatch, 02092 int associative 02094 ) 02095 { 02096 #if DEBUG 02097 DXF_DEBUG_BEGIN 02098 #endif 02099 /* Do some basic checks. */ 02100 if (hatch == NULL) 02101 { 02102 fprintf (stderr, 02103 (_("Error in %s () a NULL pointer was passed.\n")), 02104 __FUNCTION__); 02105 return (NULL); 02106 } 02107 if (associative < 0) 02108 { 02109 fprintf (stderr, 02110 (_("Error in %s () a negative associative value was passed.\n")), 02111 __FUNCTION__); 02112 return (NULL); 02113 } 02114 if (associative > 1) 02115 { 02116 fprintf (stderr, 02117 (_("Error in %s () an out of range associative value was passed.\n")), 02118 __FUNCTION__); 02119 return (NULL); 02120 } 02121 hatch->associative = associative; 02122 #if DEBUG 02123 DXF_DEBUG_END 02124 #endif 02125 return (hatch); 02126 } 02127 02128 02134 int 02135 dxf_hatch_get_hatch_style 02136 ( 02137 DxfHatch *hatch 02139 ) 02140 { 02141 #if DEBUG 02142 DXF_DEBUG_BEGIN 02143 #endif 02144 int result; 02145 02146 /* Do some basic checks. */ 02147 if (hatch == NULL) 02148 { 02149 fprintf (stderr, 02150 (_("Error in %s () a NULL pointer was passed.\n")), 02151 __FUNCTION__); 02152 return (EXIT_FAILURE); 02153 } 02154 if (hatch->hatch_style < 0) 02155 { 02156 fprintf (stderr, 02157 (_("Error in %s () a negative value was found in the hatch_style member.\n")), 02158 __FUNCTION__); 02159 return (EXIT_FAILURE); 02160 } 02161 if (hatch->hatch_style > 2) 02162 { 02163 fprintf (stderr, 02164 (_("Error in %s () an out of range value was found in the hatch_style member.\n")), 02165 __FUNCTION__); 02166 return (EXIT_FAILURE); 02167 } 02168 result = hatch->hatch_style; 02169 #if DEBUG 02170 DXF_DEBUG_END 02171 #endif 02172 return (result); 02173 } 02174 02175 02179 DxfHatch * 02180 dxf_hatch_set_hatch_style 02181 ( 02182 DxfHatch *hatch, 02184 int hatch_style 02186 ) 02187 { 02188 #if DEBUG 02189 DXF_DEBUG_BEGIN 02190 #endif 02191 /* Do some basic checks. */ 02192 if (hatch == NULL) 02193 { 02194 fprintf (stderr, 02195 (_("Error in %s () a NULL pointer was passed.\n")), 02196 __FUNCTION__); 02197 return (NULL); 02198 } 02199 if (hatch_style < 0) 02200 { 02201 fprintf (stderr, 02202 (_("Error in %s () a negative hatch_style value was passed.\n")), 02203 __FUNCTION__); 02204 return (NULL); 02205 } 02206 if (hatch_style > 2) 02207 { 02208 fprintf (stderr, 02209 (_("Error in %s () an out of range hatch_style value was passed.\n")), 02210 __FUNCTION__); 02211 return (NULL); 02212 } 02213 hatch->hatch_style = hatch_style; 02214 #if DEBUG 02215 DXF_DEBUG_END 02216 #endif 02217 return (hatch); 02218 } 02219 02220 02226 int 02227 dxf_hatch_get_hatch_pattern_type 02228 ( 02229 DxfHatch *hatch 02231 ) 02232 { 02233 #if DEBUG 02234 DXF_DEBUG_BEGIN 02235 #endif 02236 int result; 02237 02238 /* Do some basic checks. */ 02239 if (hatch == NULL) 02240 { 02241 fprintf (stderr, 02242 (_("Error in %s () a NULL pointer was passed.\n")), 02243 __FUNCTION__); 02244 return (EXIT_FAILURE); 02245 } 02246 if (hatch->hatch_pattern_type < 0) 02247 { 02248 fprintf (stderr, 02249 (_("Error in %s () a negative value was found in the hatch_pattern_type member.\n")), 02250 __FUNCTION__); 02251 return (EXIT_FAILURE); 02252 } 02253 if (hatch->hatch_pattern_type > 2) 02254 { 02255 fprintf (stderr, 02256 (_("Error in %s () an out of range value was found in the hatch_pattern_type member.\n")), 02257 __FUNCTION__); 02258 return (EXIT_FAILURE); 02259 } 02260 result = hatch->hatch_pattern_type; 02261 #if DEBUG 02262 DXF_DEBUG_END 02263 #endif 02264 return (result); 02265 } 02266 02267 02271 DxfHatch * 02272 dxf_hatch_set_hatch_pattern_type 02273 ( 02274 DxfHatch *hatch, 02276 int hatch_pattern_type 02278 ) 02279 { 02280 #if DEBUG 02281 DXF_DEBUG_BEGIN 02282 #endif 02283 /* Do some basic checks. */ 02284 if (hatch == NULL) 02285 { 02286 fprintf (stderr, 02287 (_("Error in %s () a NULL pointer was passed.\n")), 02288 __FUNCTION__); 02289 return (NULL); 02290 } 02291 if (hatch_pattern_type < 0) 02292 { 02293 fprintf (stderr, 02294 (_("Error in %s () a negative hatch_pattern_type value was passed.\n")), 02295 __FUNCTION__); 02296 return (NULL); 02297 } 02298 if (hatch_pattern_type > 2) 02299 { 02300 fprintf (stderr, 02301 (_("Error in %s () an out of range hatch_pattern_type value was passed.\n")), 02302 __FUNCTION__); 02303 return (NULL); 02304 } 02305 hatch->hatch_pattern_type = hatch_pattern_type; 02306 #if DEBUG 02307 DXF_DEBUG_END 02308 #endif 02309 return (hatch); 02310 } 02311 02312 02318 int 02319 dxf_hatch_get_pattern_double 02320 ( 02321 DxfHatch *hatch 02323 ) 02324 { 02325 #if DEBUG 02326 DXF_DEBUG_BEGIN 02327 #endif 02328 int result; 02329 02330 /* Do some basic checks. */ 02331 if (hatch == NULL) 02332 { 02333 fprintf (stderr, 02334 (_("Error in %s () a NULL pointer was passed.\n")), 02335 __FUNCTION__); 02336 return (EXIT_FAILURE); 02337 } 02338 if (hatch->pattern_double < 0) 02339 { 02340 fprintf (stderr, 02341 (_("Error in %s () a negative value was found in the pattern_double member.\n")), 02342 __FUNCTION__); 02343 return (EXIT_FAILURE); 02344 } 02345 if (hatch->pattern_double > 1) 02346 { 02347 fprintf (stderr, 02348 (_("Error in %s () an out of range value was found in the pattern_double member.\n")), 02349 __FUNCTION__); 02350 return (EXIT_FAILURE); 02351 } 02352 result = hatch->pattern_double; 02353 #if DEBUG 02354 DXF_DEBUG_END 02355 #endif 02356 return (result); 02357 } 02358 02359 02363 DxfHatch * 02364 dxf_hatch_set_pattern_double 02365 ( 02366 DxfHatch *hatch, 02368 int pattern_double 02370 ) 02371 { 02372 #if DEBUG 02373 DXF_DEBUG_BEGIN 02374 #endif 02375 /* Do some basic checks. */ 02376 if (hatch == NULL) 02377 { 02378 fprintf (stderr, 02379 (_("Error in %s () a NULL pointer was passed.\n")), 02380 __FUNCTION__); 02381 return (NULL); 02382 } 02383 if (pattern_double < 0) 02384 { 02385 fprintf (stderr, 02386 (_("Error in %s () a negative pattern_double value was passed.\n")), 02387 __FUNCTION__); 02388 return (NULL); 02389 } 02390 if (pattern_double > 1) 02391 { 02392 fprintf (stderr, 02393 (_("Error in %s () an out of range pattern_double value was passed.\n")), 02394 __FUNCTION__); 02395 return (NULL); 02396 } 02397 hatch->pattern_double = pattern_double; 02398 #if DEBUG 02399 DXF_DEBUG_END 02400 #endif 02401 return (hatch); 02402 } 02403 02404 02410 double 02411 dxf_hatch_get_extr_x0 02412 ( 02413 DxfHatch *hatch 02415 ) 02416 { 02417 #if DEBUG 02418 DXF_DEBUG_BEGIN 02419 #endif 02420 double result; 02421 02422 /* Do some basic checks. */ 02423 if (hatch == NULL) 02424 { 02425 fprintf (stderr, 02426 (_("Error in %s () a NULL pointer was passed.\n")), 02427 __FUNCTION__); 02428 return (EXIT_FAILURE); 02429 } 02430 result = hatch->extr_x0; 02431 #if DEBUG 02432 DXF_DEBUG_END 02433 #endif 02434 return (result); 02435 } 02436 02437 02441 DxfHatch * 02442 dxf_hatch_set_extr_x0 02443 ( 02444 DxfHatch *hatch, 02446 double extr_x0 02448 ) 02449 { 02450 #if DEBUG 02451 DXF_DEBUG_BEGIN 02452 #endif 02453 /* Do some basic checks. */ 02454 if (hatch == NULL) 02455 { 02456 fprintf (stderr, 02457 (_("Error in %s () a NULL pointer was passed.\n")), 02458 __FUNCTION__); 02459 return (NULL); 02460 } 02461 hatch->extr_x0 = extr_x0; 02462 #if DEBUG 02463 DXF_DEBUG_END 02464 #endif 02465 return (hatch); 02466 } 02467 02468 02474 double 02475 dxf_hatch_get_extr_y0 02476 ( 02477 DxfHatch *hatch 02479 ) 02480 { 02481 #if DEBUG 02482 DXF_DEBUG_BEGIN 02483 #endif 02484 double result; 02485 02486 /* Do some basic checks. */ 02487 if (hatch == NULL) 02488 { 02489 fprintf (stderr, 02490 (_("Error in %s () a NULL pointer was passed.\n")), 02491 __FUNCTION__); 02492 return (EXIT_FAILURE); 02493 } 02494 result = hatch->extr_y0; 02495 #if DEBUG 02496 DXF_DEBUG_END 02497 #endif 02498 return (result); 02499 } 02500 02501 02505 DxfHatch * 02506 dxf_hatch_set_extr_y0 02507 ( 02508 DxfHatch *hatch, 02510 double extr_y0 02512 ) 02513 { 02514 #if DEBUG 02515 DXF_DEBUG_BEGIN 02516 #endif 02517 /* Do some basic checks. */ 02518 if (hatch == NULL) 02519 { 02520 fprintf (stderr, 02521 (_("Error in %s () a NULL pointer was passed.\n")), 02522 __FUNCTION__); 02523 return (NULL); 02524 } 02525 hatch->extr_y0 = extr_y0; 02526 #if DEBUG 02527 DXF_DEBUG_END 02528 #endif 02529 return (hatch); 02530 } 02531 02532 02538 double 02539 dxf_hatch_get_extr_z0 02540 ( 02541 DxfHatch *hatch 02543 ) 02544 { 02545 #if DEBUG 02546 DXF_DEBUG_BEGIN 02547 #endif 02548 double result; 02549 02550 /* Do some basic checks. */ 02551 if (hatch == NULL) 02552 { 02553 fprintf (stderr, 02554 (_("Error in %s () a NULL pointer was passed.\n")), 02555 __FUNCTION__); 02556 return (EXIT_FAILURE); 02557 } 02558 result = hatch->extr_z0; 02559 #if DEBUG 02560 DXF_DEBUG_END 02561 #endif 02562 return (result); 02563 } 02564 02565 02569 DxfHatch * 02570 dxf_hatch_set_extr_z0 02571 ( 02572 DxfHatch *hatch, 02574 double extr_z0 02576 ) 02577 { 02578 #if DEBUG 02579 DXF_DEBUG_BEGIN 02580 #endif 02581 /* Do some basic checks. */ 02582 if (hatch == NULL) 02583 { 02584 fprintf (stderr, 02585 (_("Error in %s () a NULL pointer was passed.\n")), 02586 __FUNCTION__); 02587 return (NULL); 02588 } 02589 hatch->extr_z0 = extr_z0; 02590 #if DEBUG 02591 DXF_DEBUG_END 02592 #endif 02593 return (hatch); 02594 } 02595 02596 02604 DxfHatchBoundaryPath * 02605 dxf_hatch_get_boundary_paths 02606 ( 02607 DxfHatch *hatch 02609 ) 02610 { 02611 #if DEBUG 02612 DXF_DEBUG_BEGIN 02613 #endif 02614 DxfHatchBoundaryPath *result; 02615 02616 /* Do some basic checks. */ 02617 if (hatch == NULL) 02618 { 02619 fprintf (stderr, 02620 (_("Error in %s () a NULL pointer was passed.\n")), 02621 __FUNCTION__); 02622 return (NULL); 02623 } 02624 if (hatch->paths == NULL) 02625 { 02626 fprintf (stderr, 02627 (_("Error in %s () a NULL pointer was found in the paths member.\n")), 02628 __FUNCTION__); 02629 return (NULL); 02630 } 02631 result = (DxfHatchBoundaryPath *) hatch->paths; 02632 #if DEBUG 02633 DXF_DEBUG_END 02634 #endif 02635 return (result); 02636 } 02637 02638 02642 DxfHatch * 02643 dxf_hatch_set_boundary_paths 02644 ( 02645 DxfHatch *hatch, 02647 DxfHatchBoundaryPath *paths 02649 ) 02650 { 02651 #if DEBUG 02652 DXF_DEBUG_BEGIN 02653 #endif 02654 /* Do some basic checks. */ 02655 if (hatch == NULL) 02656 { 02657 fprintf (stderr, 02658 (_("Error in %s () a NULL pointer was passed.\n")), 02659 __FUNCTION__); 02660 return (NULL); 02661 } 02662 if (paths == NULL) 02663 { 02664 fprintf (stderr, 02665 (_("Error in %s () a NULL pointer was passed.\n")), 02666 __FUNCTION__); 02667 return (NULL); 02668 } 02669 hatch->paths = (struct DxfHatchBoundaryPath *) paths; 02670 #if DEBUG 02671 DXF_DEBUG_END 02672 #endif 02673 return (hatch); 02674 } 02675 02676 02684 DxfHatchPattern * 02685 dxf_hatch_get_patterns 02686 ( 02687 DxfHatch *hatch 02689 ) 02690 { 02691 #if DEBUG 02692 DXF_DEBUG_BEGIN 02693 #endif 02694 DxfHatchPattern *result; 02695 02696 /* Do some basic checks. */ 02697 if (hatch == NULL) 02698 { 02699 fprintf (stderr, 02700 (_("Error in %s () a NULL pointer was passed.\n")), 02701 __FUNCTION__); 02702 return (NULL); 02703 } 02704 if (hatch->patterns == NULL) 02705 { 02706 fprintf (stderr, 02707 (_("Error in %s () a NULL pointer was found in the patterns member.\n")), 02708 __FUNCTION__); 02709 return (NULL); 02710 } 02711 result = (DxfHatchPattern *) hatch->patterns; 02712 #if DEBUG 02713 DXF_DEBUG_END 02714 #endif 02715 return (result); 02716 } 02717 02718 02722 DxfHatch * 02723 dxf_hatch_set_patterns 02724 ( 02725 DxfHatch *hatch, 02727 DxfHatchPattern *patterns 02729 ) 02730 { 02731 #if DEBUG 02732 DXF_DEBUG_BEGIN 02733 #endif 02734 /* Do some basic checks. */ 02735 if (hatch == NULL) 02736 { 02737 fprintf (stderr, 02738 (_("Error in %s () a NULL pointer was passed.\n")), 02739 __FUNCTION__); 02740 return (NULL); 02741 } 02742 if (patterns == NULL) 02743 { 02744 fprintf (stderr, 02745 (_("Error in %s () a NULL pointer was passed.\n")), 02746 __FUNCTION__); 02747 return (NULL); 02748 } 02749 hatch->patterns = (struct DxfHatchPattern *) patterns; 02750 #if DEBUG 02751 DXF_DEBUG_END 02752 #endif 02753 return (hatch); 02754 } 02755 02756 02765 DxfHatch * 02766 dxf_hatch_get_next 02767 ( 02768 DxfHatch *hatch 02770 ) 02771 { 02772 #if DEBUG 02773 DXF_DEBUG_BEGIN 02774 #endif 02775 DxfHatch *result; 02776 02777 /* Do some basic checks. */ 02778 if (hatch == NULL) 02779 { 02780 fprintf (stderr, 02781 (_("Error in %s () a NULL pointer was passed.\n")), 02782 __FUNCTION__); 02783 return (NULL); 02784 } 02785 if (hatch->next == NULL) 02786 { 02787 fprintf (stderr, 02788 (_("Error in %s () a NULL pointer was found in the next member.\n")), 02789 __FUNCTION__); 02790 return (NULL); 02791 } 02792 result = (DxfHatch *) hatch->next; 02793 #if DEBUG 02794 DXF_DEBUG_END 02795 #endif 02796 return (result); 02797 } 02798 02799 02804 DxfHatch * 02805 dxf_hatch_set_next 02806 ( 02807 DxfHatch *hatch, 02809 DxfHatch *next 02811 ) 02812 { 02813 #if DEBUG 02814 DXF_DEBUG_BEGIN 02815 #endif 02816 /* Do some basic checks. */ 02817 if (hatch == NULL) 02818 { 02819 fprintf (stderr, 02820 (_("Error in %s () a NULL pointer was passed.\n")), 02821 __FUNCTION__); 02822 return (NULL); 02823 } 02824 if (next == NULL) 02825 { 02826 fprintf (stderr, 02827 (_("Error in %s () a NULL pointer was passed.\n")), 02828 __FUNCTION__); 02829 return (NULL); 02830 } 02831 hatch->next = (struct DxfHatch *) next; 02832 #if DEBUG 02833 DXF_DEBUG_END 02834 #endif 02835 return (hatch); 02836 } 02837 02838 02847 DxfHatch * 02848 dxf_hatch_get_last 02849 ( 02850 DxfHatch *hatch 02852 ) 02853 { 02854 #if DEBUG 02855 DXF_DEBUG_BEGIN 02856 #endif 02857 /* Do some basic checks. */ 02858 if (hatch == NULL) 02859 { 02860 fprintf (stderr, 02861 (_("Error in %s () a NULL pointer was passed.\n")), 02862 __FUNCTION__); 02863 return (NULL); 02864 } 02865 if (hatch->next == NULL) 02866 { 02867 fprintf (stderr, 02868 (_("Warning in %s () a NULL pointer was found in the next member.\n")), 02869 __FUNCTION__); 02870 return ((DxfHatch *) hatch); 02871 } 02872 DxfHatch *iter = (DxfHatch *) hatch->next; 02873 while (iter->next != NULL) 02874 { 02875 iter = (DxfHatch *) iter->next; 02876 } 02877 #if DEBUG 02878 DXF_DEBUG_END 02879 #endif 02880 return ((DxfHatch *) iter); 02881 } 02882 02883 02884 /* dxf_hatch_pattern functions. */ 02885 02886 02892 DxfHatchPattern * 02893 dxf_hatch_pattern_new () 02894 { 02895 #if DEBUG 02896 DXF_DEBUG_BEGIN 02897 #endif 02898 DxfHatchPattern *pattern = NULL; 02899 size_t size; 02900 02901 size = sizeof (DxfHatchPattern); 02902 /* avoid malloc of 0 bytes */ 02903 if (size == 0) size = 1; 02904 if ((pattern = malloc (size)) == NULL) 02905 { 02906 fprintf (stderr, 02907 (_("Error in %s () could not allocate memory for a DxfHatchPatternSeedpoint struct.\n")), 02908 __FUNCTION__); 02909 pattern = NULL; 02910 } 02911 else 02912 { 02913 memset (pattern, 0, size); 02914 } 02915 #if DEBUG 02916 DXF_DEBUG_END 02917 #endif 02918 return (pattern); 02919 } 02920 02921 02929 DxfHatchPattern * 02930 dxf_hatch_pattern_init 02931 ( 02932 DxfHatchPattern *pattern 02934 ) 02935 { 02936 #if DEBUG 02937 DXF_DEBUG_BEGIN 02938 #endif 02939 /* Do some basic checks. */ 02940 if (pattern == NULL) 02941 { 02942 fprintf (stderr, 02943 (_("Warning in %s () a NULL pointer was passed.\n")), 02944 __FUNCTION__); 02945 pattern = dxf_hatch_pattern_new (); 02946 } 02947 if (pattern == NULL) 02948 { 02949 fprintf (stderr, 02950 (_("Error in %s () could not allocate memory for a DxfHatchPattern struct.\n")), 02951 __FUNCTION__); 02952 return (NULL); 02953 } 02954 pattern->id_code = 0; 02955 pattern->number_of_def_lines = 0; 02956 dxf_hatch_pattern_def_line_init ((DxfHatchPatternDefLine *) pattern->def_lines); 02957 pattern->number_of_seed_points = 0; 02958 dxf_hatch_pattern_seedpoint_init ((DxfHatchPatternSeedPoint *) pattern->seed_points); 02959 pattern->next = NULL; 02960 #if DEBUG 02961 DXF_DEBUG_END 02962 #endif 02963 return (pattern); 02964 } 02965 02966 02974 int 02975 dxf_hatch_pattern_free 02976 ( 02977 DxfHatchPattern *pattern 02980 ) 02981 { 02982 #if DEBUG 02983 DXF_DEBUG_BEGIN 02984 #endif 02985 /* Do some basic checks. */ 02986 if (pattern == NULL) 02987 { 02988 fprintf (stderr, 02989 (_("Error in %s () a NULL pointer was passed.\n")), 02990 __FUNCTION__); 02991 return (EXIT_FAILURE); 02992 } 02993 if (pattern->next != NULL) 02994 { 02995 fprintf (stderr, 02996 (_("Error in %s () pointer to next was not NULL.\n")), 02997 __FUNCTION__); 02998 return (EXIT_FAILURE); 02999 } 03000 free (pattern->def_lines); 03001 free (pattern->seed_points); 03002 free (pattern); 03003 pattern = NULL; 03004 #if DEBUG 03005 DXF_DEBUG_END 03006 #endif 03007 return (EXIT_SUCCESS); 03008 } 03009 03010 03015 void 03016 dxf_hatch_pattern_free_chain 03017 ( 03018 DxfHatchPattern *patterns 03020 ) 03021 { 03022 #ifdef DEBUG 03023 DXF_DEBUG_BEGIN 03024 #endif 03025 /* Do some basic checks. */ 03026 if (patterns == NULL) 03027 { 03028 fprintf (stderr, 03029 (_("Warning in %s () a NULL pointer was passed.\n")), 03030 __FUNCTION__); 03031 } 03032 while (patterns != NULL) 03033 { 03034 struct DxfHatchPattern *iter = patterns->next; 03035 dxf_hatch_pattern_free (patterns); 03036 patterns = (DxfHatchPattern *) iter; 03037 } 03038 #if DEBUG 03039 DXF_DEBUG_END 03040 #endif 03041 } 03042 03043 03049 int 03050 dxf_hatch_pattern_get_id_code 03051 ( 03052 DxfHatchPattern *pattern 03054 ) 03055 { 03056 #if DEBUG 03057 DXF_DEBUG_BEGIN 03058 #endif 03059 int result; 03060 03061 /* Do some basic checks. */ 03062 if (pattern == NULL) 03063 { 03064 fprintf (stderr, 03065 (_("Error in %s () a NULL pointer was passed.\n")), 03066 __FUNCTION__); 03067 return (EXIT_FAILURE); 03068 } 03069 if (pattern->id_code < 0) 03070 { 03071 fprintf (stderr, 03072 (_("Error in %s () a negative value was found in the id_code member.\n")), 03073 __FUNCTION__); 03074 return (EXIT_FAILURE); 03075 } 03076 result = pattern->id_code; 03077 #if DEBUG 03078 DXF_DEBUG_END 03079 #endif 03080 return (result); 03081 } 03082 03083 03087 DxfHatchPattern * 03088 dxf_hatch_pattern_set_id_code 03089 ( 03090 DxfHatchPattern *pattern, 03092 int id_code 03096 ) 03097 { 03098 #if DEBUG 03099 DXF_DEBUG_BEGIN 03100 #endif 03101 /* Do some basic checks. */ 03102 if (pattern == NULL) 03103 { 03104 fprintf (stderr, 03105 (_("Error in %s () a NULL pointer was passed.\n")), 03106 __FUNCTION__); 03107 return (NULL); 03108 } 03109 if (id_code < 0) 03110 { 03111 fprintf (stderr, 03112 (_("Error in %s () a negative id-code value was passed.\n")), 03113 __FUNCTION__); 03114 return (NULL); 03115 } 03116 pattern->id_code = id_code; 03117 #if DEBUG 03118 DXF_DEBUG_END 03119 #endif 03120 return (pattern); 03121 } 03122 03123 03130 int 03131 dxf_hatch_pattern_get_number_of_def_lines 03132 ( 03133 DxfHatchPattern *pattern 03135 ) 03136 { 03137 #if DEBUG 03138 DXF_DEBUG_BEGIN 03139 #endif 03140 int result; 03141 03142 /* Do some basic checks. */ 03143 if (pattern == NULL) 03144 { 03145 fprintf (stderr, 03146 (_("Error in %s () a NULL pointer was passed.\n")), 03147 __FUNCTION__); 03148 return (EXIT_FAILURE); 03149 } 03150 if (pattern->number_of_def_lines < 0) 03151 { 03152 fprintf (stderr, 03153 (_("Error in %s () a negative value was found in the number_of_def_lines member.\n")), 03154 __FUNCTION__); 03155 return (EXIT_FAILURE); 03156 } 03157 result = pattern->number_of_def_lines; 03158 #if DEBUG 03159 DXF_DEBUG_END 03160 #endif 03161 return (result); 03162 } 03163 03164 03169 DxfHatchPattern * 03170 dxf_hatch_pattern_set_number_of_def_lines 03171 ( 03172 DxfHatchPattern *pattern, 03174 int number_of_def_lines 03176 ) 03177 { 03178 #if DEBUG 03179 DXF_DEBUG_BEGIN 03180 #endif 03181 /* Do some basic checks. */ 03182 if (pattern == NULL) 03183 { 03184 fprintf (stderr, 03185 (_("Error in %s () a NULL pointer was passed.\n")), 03186 __FUNCTION__); 03187 return (NULL); 03188 } 03189 if (number_of_def_lines < 0) 03190 { 03191 fprintf (stderr, 03192 (_("Error in %s () a negative number_of_def_lines value was passed.\n")), 03193 __FUNCTION__); 03194 return (NULL); 03195 } 03196 pattern->number_of_def_lines = number_of_def_lines; 03197 #if DEBUG 03198 DXF_DEBUG_END 03199 #endif 03200 return (pattern); 03201 } 03202 03203 03212 DxfHatchPatternDefLine * 03213 dxf_hatch_pattern_get_def_lines 03214 ( 03215 DxfHatchPattern *pattern 03217 ) 03218 { 03219 #if DEBUG 03220 DXF_DEBUG_BEGIN 03221 #endif 03222 DxfHatchPatternDefLine *result; 03223 03224 /* Do some basic checks. */ 03225 if (pattern == NULL) 03226 { 03227 fprintf (stderr, 03228 (_("Error in %s () a NULL pointer was passed.\n")), 03229 __FUNCTION__); 03230 return (NULL); 03231 } 03232 result = (DxfHatchPatternDefLine *) pattern->def_lines; 03233 #if DEBUG 03234 DXF_DEBUG_END 03235 #endif 03236 return (result); 03237 } 03238 03239 03244 DxfHatchPattern * 03245 dxf_hatch_pattern_set_def_lines 03246 ( 03247 DxfHatchPattern *pattern, 03249 DxfHatchPatternDefLine *def_lines 03251 ) 03252 { 03253 #if DEBUG 03254 DXF_DEBUG_BEGIN 03255 #endif 03256 /* Do some basic checks. */ 03257 if (pattern == NULL) 03258 { 03259 fprintf (stderr, 03260 (_("Error in %s () a NULL pointer was passed.\n")), 03261 __FUNCTION__); 03262 return (NULL); 03263 } 03264 if (def_lines == NULL) 03265 { 03266 fprintf (stderr, 03267 (_("Error in %s () a NULL pointer was passed.\n")), 03268 __FUNCTION__); 03269 return (NULL); 03270 } 03271 pattern->def_lines = (struct DxfHatchPatternDefLine *) def_lines; 03272 #if DEBUG 03273 DXF_DEBUG_END 03274 #endif 03275 return (pattern); 03276 } 03277 03278 03285 int 03286 dxf_hatch_pattern_get_number_of_seed_points 03287 ( 03288 DxfHatchPattern *pattern 03290 ) 03291 { 03292 #if DEBUG 03293 DXF_DEBUG_BEGIN 03294 #endif 03295 int result; 03296 03297 /* Do some basic checks. */ 03298 if (pattern == NULL) 03299 { 03300 fprintf (stderr, 03301 (_("Error in %s () a NULL pointer was passed.\n")), 03302 __FUNCTION__); 03303 return (EXIT_FAILURE); 03304 } 03305 if (pattern->number_of_seed_points < 0) 03306 { 03307 fprintf (stderr, 03308 (_("Error in %s () a negative value was found in the number_of_seed_points member.\n")), 03309 __FUNCTION__); 03310 return (EXIT_FAILURE); 03311 } 03312 result = pattern->number_of_seed_points; 03313 #if DEBUG 03314 DXF_DEBUG_END 03315 #endif 03316 return (result); 03317 } 03318 03319 03324 DxfHatchPattern * 03325 dxf_hatch_pattern_set_number_of_seed_points 03326 ( 03327 DxfHatchPattern *pattern, 03329 int number_of_seed_points 03331 ) 03332 { 03333 #if DEBUG 03334 DXF_DEBUG_BEGIN 03335 #endif 03336 /* Do some basic checks. */ 03337 if (pattern == NULL) 03338 { 03339 fprintf (stderr, 03340 (_("Error in %s () a NULL pointer was passed.\n")), 03341 __FUNCTION__); 03342 return (NULL); 03343 } 03344 if (number_of_seed_points < 0) 03345 { 03346 fprintf (stderr, 03347 (_("Error in %s () a negative number_of_seed_points value was passed.\n")), 03348 __FUNCTION__); 03349 return (NULL); 03350 } 03351 pattern->number_of_seed_points = number_of_seed_points; 03352 #if DEBUG 03353 DXF_DEBUG_END 03354 #endif 03355 return (pattern); 03356 } 03357 03358 03367 DxfHatchPatternSeedPoint * 03368 dxf_hatch_pattern_get_seed_points 03369 ( 03370 DxfHatchPattern *pattern 03372 ) 03373 { 03374 #if DEBUG 03375 DXF_DEBUG_BEGIN 03376 #endif 03377 DxfHatchPatternSeedPoint *result; 03378 03379 /* Do some basic checks. */ 03380 if (pattern == NULL) 03381 { 03382 fprintf (stderr, 03383 (_("Error in %s () a NULL pointer was passed.\n")), 03384 __FUNCTION__); 03385 return (NULL); 03386 } 03387 result = (DxfHatchPatternSeedPoint *) pattern->seed_points; 03388 #if DEBUG 03389 DXF_DEBUG_END 03390 #endif 03391 return (result); 03392 } 03393 03394 03399 DxfHatchPattern * 03400 dxf_hatch_pattern_set_seed_points 03401 ( 03402 DxfHatchPattern *pattern, 03404 DxfHatchPatternSeedPoint *seed_points 03406 ) 03407 { 03408 #if DEBUG 03409 DXF_DEBUG_BEGIN 03410 #endif 03411 /* Do some basic checks. */ 03412 if (pattern == NULL) 03413 { 03414 fprintf (stderr, 03415 (_("Error in %s () a NULL pointer was passed.\n")), 03416 __FUNCTION__); 03417 return (NULL); 03418 } 03419 if (seed_points == NULL) 03420 { 03421 fprintf (stderr, 03422 (_("Error in %s () a NULL pointer was passed.\n")), 03423 __FUNCTION__); 03424 return (NULL); 03425 } 03426 pattern->seed_points = (struct DxfHatchPatternSeedPoint *) seed_points; 03427 #if DEBUG 03428 DXF_DEBUG_END 03429 #endif 03430 return (pattern); 03431 } 03432 03433 03442 DxfHatchPattern * 03443 dxf_hatch_pattern_get_next 03444 ( 03445 DxfHatchPattern *pattern 03447 ) 03448 { 03449 #if DEBUG 03450 DXF_DEBUG_BEGIN 03451 #endif 03452 DxfHatchPattern *result; 03453 03454 /* Do some basic checks. */ 03455 if (pattern == NULL) 03456 { 03457 fprintf (stderr, 03458 (_("Error in %s () a NULL pointer was passed.\n")), 03459 __FUNCTION__); 03460 return (NULL); 03461 } 03462 if (pattern->next == NULL) 03463 { 03464 fprintf (stderr, 03465 (_("Error in %s () a NULL pointer was found in the next member.\n")), 03466 __FUNCTION__); 03467 return (NULL); 03468 } 03469 result = (DxfHatchPattern *) pattern->next; 03470 #if DEBUG 03471 DXF_DEBUG_END 03472 #endif 03473 return (result); 03474 } 03475 03476 03481 DxfHatchPattern * 03482 dxf_hatch_pattern_set_next 03483 ( 03484 DxfHatchPattern *pattern, 03486 DxfHatchPatternDefLine *next 03489 ) 03490 { 03491 #if DEBUG 03492 DXF_DEBUG_BEGIN 03493 #endif 03494 /* Do some basic checks. */ 03495 if (pattern == NULL) 03496 { 03497 fprintf (stderr, 03498 (_("Error in %s () a NULL pointer was passed.\n")), 03499 __FUNCTION__); 03500 return (NULL); 03501 } 03502 if (next == NULL) 03503 { 03504 fprintf (stderr, 03505 (_("Error in %s () a NULL pointer was passed.\n")), 03506 __FUNCTION__); 03507 return (NULL); 03508 } 03509 pattern->next = (struct DxfHatchPattern *) next; 03510 #if DEBUG 03511 DXF_DEBUG_END 03512 #endif 03513 return (pattern); 03514 } 03515 03516 03525 DxfHatchPattern * 03526 dxf_hatch_pattern_get_last 03527 ( 03528 DxfHatchPattern *pattern 03530 ) 03531 { 03532 #if DEBUG 03533 DXF_DEBUG_BEGIN 03534 #endif 03535 /* Do some basic checks. */ 03536 if (pattern == NULL) 03537 { 03538 fprintf (stderr, 03539 (_("Error in %s () a NULL pointer was passed.\n")), 03540 __FUNCTION__); 03541 return (NULL); 03542 } 03543 if (pattern->next == NULL) 03544 { 03545 fprintf (stderr, 03546 (_("Warning in %s () a NULL pointer was found in the next member.\n")), 03547 __FUNCTION__); 03548 return ((DxfHatchPattern *) pattern); 03549 } 03550 DxfHatchPattern *iter = (DxfHatchPattern *) pattern->next; 03551 while (iter->next != NULL) 03552 { 03553 iter = (DxfHatchPattern *) iter->next; 03554 } 03555 #if DEBUG 03556 DXF_DEBUG_END 03557 #endif 03558 return ((DxfHatchPattern *) iter); 03559 } 03560 03561 03562 /* dxf_hatch_pattern_def_line_dash functions. */ 03563 03570 DxfHatchPatternDefLineDash * 03571 dxf_hatch_pattern_def_line_dash_new () 03572 { 03573 #if DEBUG 03574 DXF_DEBUG_BEGIN 03575 #endif 03576 DxfHatchPatternDefLineDash *dash = NULL; 03577 size_t size; 03578 03579 size = sizeof (DxfHatchPatternDefLineDash); 03580 /* avoid malloc of 0 bytes */ 03581 if (size == 0) size = 1; 03582 if ((dash = malloc (size)) == NULL) 03583 { 03584 fprintf (stderr, 03585 (_("Error in %s () could not allocate memory for a DxfHatchPatternDefLineDash struct.\n")), 03586 __FUNCTION__); 03587 dash = NULL; 03588 } 03589 else 03590 { 03591 memset (dash, 0, size); 03592 } 03593 #if DEBUG 03594 DXF_DEBUG_END 03595 #endif 03596 return (dash); 03597 } 03598 03599 03607 DxfHatchPatternDefLineDash * 03608 dxf_hatch_pattern_def_line_dash_init 03609 ( 03610 DxfHatchPatternDefLineDash *dash 03612 ) 03613 { 03614 #if DEBUG 03615 DXF_DEBUG_BEGIN 03616 #endif 03617 03618 /* Do some basic checks. */ 03619 if (dash == NULL) 03620 { 03621 fprintf (stderr, 03622 (_("Warning in %s () a NULL pointer was passed.\n")), 03623 __FUNCTION__); 03624 dash = dxf_hatch_pattern_def_line_dash_new (); 03625 } 03626 dash->length = 0.0; 03627 dash->next = NULL; 03628 #if DEBUG 03629 DXF_DEBUG_END 03630 #endif 03631 return (dash); 03632 } 03633 03634 03642 int 03643 dxf_hatch_pattern_def_line_dash_free 03644 ( 03645 DxfHatchPatternDefLineDash *dash 03648 ) 03649 { 03650 #if DEBUG 03651 DXF_DEBUG_BEGIN 03652 #endif 03653 /* Do some basic checks. */ 03654 if (dash == NULL) 03655 { 03656 fprintf (stderr, 03657 (_("Error in %s () a NULL pointer was passed.\n")), 03658 __FUNCTION__); 03659 return (EXIT_FAILURE); 03660 } 03661 if (dash->next != NULL) 03662 { 03663 fprintf (stderr, 03664 (_("Error in %s () pointer to next was not NULL.\n")), 03665 __FUNCTION__); 03666 return (EXIT_FAILURE); 03667 } 03668 free (dash); 03669 dash = NULL; 03670 #if DEBUG 03671 DXF_DEBUG_END 03672 #endif 03673 return (EXIT_SUCCESS); 03674 } 03675 03676 03681 void 03682 dxf_hatch_pattern_def_line_dash_free_chain 03683 ( 03684 DxfHatchPatternDefLineDash *dashes 03687 ) 03688 { 03689 #ifdef DEBUG 03690 DXF_DEBUG_BEGIN 03691 #endif 03692 /* Do some basic checks. */ 03693 if (dashes == NULL) 03694 { 03695 fprintf (stderr, 03696 (_("Warning in %s () a NULL pointer was passed.\n")), 03697 __FUNCTION__); 03698 } 03699 while (dashes != NULL) 03700 { 03701 struct DxfHatchPatternDefLineDash *iter = dashes->next; 03702 dxf_hatch_pattern_def_line_dash_free (dashes); 03703 dashes = (DxfHatchPatternDefLineDash *) iter; 03704 } 03705 #if DEBUG 03706 DXF_DEBUG_END 03707 #endif 03708 } 03709 03710 03717 double 03718 dxf_hatch_pattern_def_line_dash_get_length 03719 ( 03720 DxfHatchPatternDefLineDash *dash 03722 ) 03723 { 03724 #if DEBUG 03725 DXF_DEBUG_BEGIN 03726 #endif 03727 double result; 03728 03729 /* Do some basic checks. */ 03730 if (dash == NULL) 03731 { 03732 fprintf (stderr, 03733 (_("Error in %s () a NULL pointer was passed.\n")), 03734 __FUNCTION__); 03735 return (EXIT_FAILURE); 03736 } 03737 result = dash->length; 03738 #if DEBUG 03739 DXF_DEBUG_END 03740 #endif 03741 return (result); 03742 } 03743 03744 03748 DxfHatchPatternDefLineDash * 03749 dxf_hatch_pattern_def_line_dash_set_length 03750 ( 03751 DxfHatchPatternDefLineDash *dash, 03753 double length 03755 ) 03756 { 03757 #if DEBUG 03758 DXF_DEBUG_BEGIN 03759 #endif 03760 /* Do some basic checks. */ 03761 if (dash == NULL) 03762 { 03763 fprintf (stderr, 03764 (_("Error in %s () a NULL pointer was passed.\n")), 03765 __FUNCTION__); 03766 return (NULL); 03767 } 03768 dash->length = length; 03769 #if DEBUG 03770 DXF_DEBUG_END 03771 #endif 03772 return (dash); 03773 } 03774 03775 03784 DxfHatchPatternDefLineDash * 03785 dxf_hatch_pattern_def_line_dash_get_next 03786 ( 03787 DxfHatchPatternDefLineDash *dash 03789 ) 03790 { 03791 #if DEBUG 03792 DXF_DEBUG_BEGIN 03793 #endif 03794 DxfHatchPatternDefLineDash *result; 03795 03796 /* Do some basic checks. */ 03797 if (dash == NULL) 03798 { 03799 fprintf (stderr, 03800 (_("Error in %s () a NULL pointer was passed.\n")), 03801 __FUNCTION__); 03802 return (NULL); 03803 } 03804 if (dash->next == NULL) 03805 { 03806 fprintf (stderr, 03807 (_("Error in %s () a NULL pointer was found in the next member.\n")), 03808 __FUNCTION__); 03809 return (NULL); 03810 } 03811 result = (DxfHatchPatternDefLineDash *) dash->next; 03812 #if DEBUG 03813 DXF_DEBUG_END 03814 #endif 03815 return (result); 03816 } 03817 03818 03823 DxfHatchPatternDefLineDash * 03824 dxf_hatch_pattern_def_line_dash_set_next 03825 ( 03826 DxfHatchPatternDefLineDash *dash, 03828 DxfHatchPatternDefLineDash *next 03831 ) 03832 { 03833 #if DEBUG 03834 DXF_DEBUG_BEGIN 03835 #endif 03836 /* Do some basic checks. */ 03837 if (dash == NULL) 03838 { 03839 fprintf (stderr, 03840 (_("Error in %s () a NULL pointer was passed.\n")), 03841 __FUNCTION__); 03842 return (NULL); 03843 } 03844 if (next == NULL) 03845 { 03846 fprintf (stderr, 03847 (_("Error in %s () a NULL pointer was passed.\n")), 03848 __FUNCTION__); 03849 return (NULL); 03850 } 03851 dash->next = (struct DxfHatchPatternDefLineDash *) next; 03852 #if DEBUG 03853 DXF_DEBUG_END 03854 #endif 03855 return (dash); 03856 } 03857 03858 03867 DxfHatchPatternDefLineDash * 03868 dxf_hatch_pattern_def_line_dash_get_last 03869 ( 03870 DxfHatchPatternDefLineDash *dash 03872 ) 03873 { 03874 #if DEBUG 03875 DXF_DEBUG_BEGIN 03876 #endif 03877 /* Do some basic checks. */ 03878 if (dash == NULL) 03879 { 03880 fprintf (stderr, 03881 (_("Error in %s () a NULL pointer was passed.\n")), 03882 __FUNCTION__); 03883 return (NULL); 03884 } 03885 if (dash->next == NULL) 03886 { 03887 fprintf (stderr, 03888 (_("Warning in %s () a NULL pointer was found in the next member.\n")), 03889 __FUNCTION__); 03890 return ((DxfHatchPatternDefLineDash *) dash); 03891 } 03892 DxfHatchPatternDefLineDash *iter = (DxfHatchPatternDefLineDash *) dash->next; 03893 while (iter->next != NULL) 03894 { 03895 iter = (DxfHatchPatternDefLineDash *) iter->next; 03896 } 03897 #if DEBUG 03898 DXF_DEBUG_END 03899 #endif 03900 return ((DxfHatchPatternDefLineDash *) iter); 03901 } 03902 03903 03904 /* dxf_hatch_pattern_def_line functions. */ 03905 03911 DxfHatchPatternDefLine * 03912 dxf_hatch_pattern_def_line_new () 03913 { 03914 #if DEBUG 03915 DXF_DEBUG_BEGIN 03916 #endif 03917 DxfHatchPatternDefLine *line = NULL; 03918 size_t size; 03919 03920 size = sizeof (DxfHatchPatternDefLine); 03921 /* avoid malloc of 0 bytes */ 03922 if (size == 0) size = 1; 03923 if ((line = malloc (size)) == NULL) 03924 { 03925 fprintf (stderr, 03926 (_("Error in %s () could not allocate memory for a DxfHatchPatternDefLine struct.\n")), 03927 __FUNCTION__); 03928 line = NULL; 03929 } 03930 else 03931 { 03932 memset (line, 0, size); 03933 } 03934 #if DEBUG 03935 DXF_DEBUG_END 03936 #endif 03937 return (line); 03938 } 03939 03940 03948 DxfHatchPatternDefLine * 03949 dxf_hatch_pattern_def_line_init 03950 ( 03951 DxfHatchPatternDefLine *line 03953 ) 03954 { 03955 #if DEBUG 03956 DXF_DEBUG_BEGIN 03957 #endif 03958 /* Do some basic checks. */ 03959 if (line == NULL) 03960 { 03961 fprintf (stderr, 03962 (_("Warning in %s () a NULL pointer was passed.\n")), 03963 __FUNCTION__); 03964 line = dxf_hatch_pattern_def_line_new (); 03965 } 03966 if (line == NULL) 03967 { 03968 fprintf (stderr, 03969 (_("Error in %s () could not allocate memory for a DxfHatchPatternDefLine struct.\n")), 03970 __FUNCTION__); 03971 return (NULL); 03972 } 03973 line->id_code = 0; 03974 line->angle = 0.0; 03975 line->x0 = 0.0; 03976 line->y0 = 0.0; 03977 line->x1 = 0.0; 03978 line->y1 = 0.0; 03979 line->number_of_dash_items = 0; 03980 line->dashes = NULL; 03981 line->next = NULL; 03982 #if DEBUG 03983 DXF_DEBUG_END 03984 #endif 03985 return (line); 03986 } 03987 03988 03996 int 03997 dxf_hatch_pattern_def_line_write 03998 ( 03999 DxfFile *fp, 04001 DxfHatchPatternDefLine *line 04003 ) 04004 { 04005 #if DEBUG 04006 DXF_DEBUG_BEGIN 04007 #endif 04008 int i; 04009 04010 /* Do some basic checks. */ 04011 if (fp == NULL) 04012 { 04013 fprintf (stderr, 04014 (_("Error in %s () a NULL pointer was passed.\n")), 04015 __FUNCTION__); 04016 return (EXIT_FAILURE); 04017 } 04018 if (line == NULL) 04019 { 04020 fprintf (stderr, 04021 (_("Error in %s () a NULL pointer was passed.\n")), 04022 __FUNCTION__); 04023 return (EXIT_FAILURE); 04024 } 04025 /* Start writing output. */ 04026 fprintf (fp->fp, " 53\n%f\n", line->angle); 04027 fprintf (fp->fp, " 43\n%f\n", line->x0); 04028 fprintf (fp->fp, " 44\n%f\n", line->y0); 04029 fprintf (fp->fp, " 45\n%f\n", line->x1); 04030 fprintf (fp->fp, " 46\n%f\n", line->y1); 04031 fprintf (fp->fp, " 79\n%d\n", line->number_of_dash_items); 04032 if (line->number_of_dash_items > 0) 04033 { 04034 /* Draw hatch pattern definition line dash items. */ 04035 DxfHatchPatternDefLineDash *dash; 04036 i = 0; 04037 dash = dxf_hatch_pattern_def_line_get_dashes (line); 04038 if (dash == NULL) 04039 { 04040 fprintf (stderr, 04041 (_("Warning in %s () no pointer to the first dash found.\n")), 04042 __FUNCTION__); 04043 04044 } 04045 while (dash != NULL) 04046 { 04047 fprintf (fp->fp, " 49\n%f\n", dash->length); 04048 i++; 04049 dash = dxf_hatch_pattern_def_line_dash_get_next (dash); 04050 } 04051 if (i >= line->number_of_dash_items) 04052 { 04053 fprintf (stderr, 04054 (_("Warning in %s () more dashes found than expected.\n")), 04055 __FUNCTION__); 04056 04057 } 04058 } 04059 else 04060 { 04061 fprintf (stderr, 04062 (_("Warning in %s () no dash length found.\n")), 04063 __FUNCTION__); 04064 } 04065 #if DEBUG 04066 DXF_DEBUG_END 04067 #endif 04068 return (EXIT_SUCCESS); 04069 } 04070 04071 04079 int 04080 dxf_hatch_pattern_def_line_free 04081 ( 04082 DxfHatchPatternDefLine *line 04085 ) 04086 { 04087 #if DEBUG 04088 DXF_DEBUG_BEGIN 04089 #endif 04090 /* Do some basic checks. */ 04091 if (line == NULL) 04092 { 04093 fprintf (stderr, 04094 (_("Error in %s () a NULL pointer was passed.\n")), 04095 __FUNCTION__); 04096 return (EXIT_FAILURE); 04097 } 04098 if (line->next != NULL) 04099 { 04100 fprintf (stderr, 04101 (_("Error in %s () pointer to next was not NULL.\n")), 04102 __FUNCTION__); 04103 return (EXIT_FAILURE); 04104 } 04105 free (line); 04106 line = NULL; 04107 #if DEBUG 04108 DXF_DEBUG_END 04109 #endif 04110 return (EXIT_SUCCESS); 04111 } 04112 04113 04118 void 04119 dxf_hatch_pattern_def_line_free_chain 04120 ( 04121 DxfHatchPatternDefLine *lines 04124 ) 04125 { 04126 #ifdef DEBUG 04127 DXF_DEBUG_BEGIN 04128 #endif 04129 /* Do some basic checks. */ 04130 if (lines == NULL) 04131 { 04132 fprintf (stderr, 04133 (_("Warning in %s () a NULL pointer was passed.\n")), 04134 __FUNCTION__); 04135 } 04136 while (lines != NULL) 04137 { 04138 struct DxfHatchPatternDefLine *iter = lines->next; 04139 dxf_hatch_pattern_def_line_free (lines); 04140 lines = (DxfHatchPatternDefLine *) iter; 04141 } 04142 #if DEBUG 04143 DXF_DEBUG_END 04144 #endif 04145 } 04146 04147 04153 int 04154 dxf_hatch_pattern_def_line_get_id_code 04155 ( 04156 DxfHatchPatternDefLine *line 04158 ) 04159 { 04160 #if DEBUG 04161 DXF_DEBUG_BEGIN 04162 #endif 04163 int result; 04164 04165 /* Do some basic checks. */ 04166 if (line == NULL) 04167 { 04168 fprintf (stderr, 04169 (_("Error in %s () a NULL pointer was passed.\n")), 04170 __FUNCTION__); 04171 return (EXIT_FAILURE); 04172 } 04173 if (line->id_code < 0) 04174 { 04175 fprintf (stderr, 04176 (_("Error in %s () a negative value was found in the id_code member.\n")), 04177 __FUNCTION__); 04178 return (EXIT_FAILURE); 04179 } 04180 result = line->id_code; 04181 #if DEBUG 04182 DXF_DEBUG_END 04183 #endif 04184 return (result); 04185 } 04186 04187 04191 DxfHatchPatternDefLine * 04192 dxf_hatch_pattern_def_line_set_id_code 04193 ( 04194 DxfHatchPatternDefLine *line, 04196 int id_code 04200 ) 04201 { 04202 #if DEBUG 04203 DXF_DEBUG_BEGIN 04204 #endif 04205 /* Do some basic checks. */ 04206 if (line == NULL) 04207 { 04208 fprintf (stderr, 04209 (_("Error in %s () a NULL pointer was passed.\n")), 04210 __FUNCTION__); 04211 return (NULL); 04212 } 04213 if (id_code < 0) 04214 { 04215 fprintf (stderr, 04216 (_("Error in %s () a negative id-code value was passed.\n")), 04217 __FUNCTION__); 04218 return (NULL); 04219 } 04220 line->id_code = id_code; 04221 #if DEBUG 04222 DXF_DEBUG_END 04223 #endif 04224 return (line); 04225 } 04226 04227 04233 double 04234 dxf_hatch_pattern_def_line_get_angle 04235 ( 04236 DxfHatchPatternDefLine *line 04238 ) 04239 { 04240 #if DEBUG 04241 DXF_DEBUG_BEGIN 04242 #endif 04243 double result; 04244 04245 /* Do some basic checks. */ 04246 if (line == NULL) 04247 { 04248 fprintf (stderr, 04249 (_("Error in %s () a NULL pointer was passed.\n")), 04250 __FUNCTION__); 04251 return (EXIT_FAILURE); 04252 } 04253 result = line->angle; 04254 #if DEBUG 04255 DXF_DEBUG_END 04256 #endif 04257 return (result); 04258 } 04259 04260 04264 DxfHatchPatternDefLine * 04265 dxf_hatch_pattern_def_line_set_angle 04266 ( 04267 DxfHatchPatternDefLine *line, 04269 double angle 04271 ) 04272 { 04273 #if DEBUG 04274 DXF_DEBUG_BEGIN 04275 #endif 04276 /* Do some basic checks. */ 04277 if (line == NULL) 04278 { 04279 fprintf (stderr, 04280 (_("Error in %s () a NULL pointer was passed.\n")), 04281 __FUNCTION__); 04282 return (NULL); 04283 } 04284 line->angle = angle; 04285 #if DEBUG 04286 DXF_DEBUG_END 04287 #endif 04288 return (line); 04289 } 04290 04291 04298 double 04299 dxf_hatch_pattern_def_line_get_x0 04300 ( 04301 DxfHatchPatternDefLine *line 04303 ) 04304 { 04305 #if DEBUG 04306 DXF_DEBUG_BEGIN 04307 #endif 04308 double result; 04309 04310 /* Do some basic checks. */ 04311 if (line == NULL) 04312 { 04313 fprintf (stderr, 04314 (_("Error in %s () a NULL pointer was passed.\n")), 04315 __FUNCTION__); 04316 return (EXIT_FAILURE); 04317 } 04318 result = line->x0; 04319 #if DEBUG 04320 DXF_DEBUG_END 04321 #endif 04322 return (result); 04323 } 04324 04325 04329 DxfHatchPatternDefLine * 04330 dxf_hatch_pattern_def_line_set_x0 04331 ( 04332 DxfHatchPatternDefLine *line, 04334 double x0 04336 ) 04337 { 04338 #if DEBUG 04339 DXF_DEBUG_BEGIN 04340 #endif 04341 /* Do some basic checks. */ 04342 if (line == NULL) 04343 { 04344 fprintf (stderr, 04345 (_("Error in %s () a NULL pointer was passed.\n")), 04346 __FUNCTION__); 04347 return (NULL); 04348 } 04349 line->x0 = x0; 04350 #if DEBUG 04351 DXF_DEBUG_END 04352 #endif 04353 return (line); 04354 } 04355 04356 04363 double 04364 dxf_hatch_pattern_def_line_get_y0 04365 ( 04366 DxfHatchPatternDefLine *line 04368 ) 04369 { 04370 #if DEBUG 04371 DXF_DEBUG_BEGIN 04372 #endif 04373 double result; 04374 04375 /* Do some basic checks. */ 04376 if (line == NULL) 04377 { 04378 fprintf (stderr, 04379 (_("Error in %s () a NULL pointer was passed.\n")), 04380 __FUNCTION__); 04381 return (EXIT_FAILURE); 04382 } 04383 result = line->y0; 04384 #if DEBUG 04385 DXF_DEBUG_END 04386 #endif 04387 return (result); 04388 } 04389 04390 04394 DxfHatchPatternDefLine * 04395 dxf_hatch_pattern_def_line_set_y0 04396 ( 04397 DxfHatchPatternDefLine *line, 04399 double y0 04401 ) 04402 { 04403 #if DEBUG 04404 DXF_DEBUG_BEGIN 04405 #endif 04406 /* Do some basic checks. */ 04407 if (line == NULL) 04408 { 04409 fprintf (stderr, 04410 (_("Error in %s () a NULL pointer was passed.\n")), 04411 __FUNCTION__); 04412 return (NULL); 04413 } 04414 line->y0 = y0; 04415 #if DEBUG 04416 DXF_DEBUG_END 04417 #endif 04418 return (line); 04419 } 04420 04421 04428 double 04429 dxf_hatch_pattern_def_line_get_x1 04430 ( 04431 DxfHatchPatternDefLine *line 04433 ) 04434 { 04435 #if DEBUG 04436 DXF_DEBUG_BEGIN 04437 #endif 04438 double result; 04439 04440 /* Do some basic checks. */ 04441 if (line == NULL) 04442 { 04443 fprintf (stderr, 04444 (_("Error in %s () a NULL pointer was passed.\n")), 04445 __FUNCTION__); 04446 return (EXIT_FAILURE); 04447 } 04448 result = line->x1; 04449 #if DEBUG 04450 DXF_DEBUG_END 04451 #endif 04452 return (result); 04453 } 04454 04455 04460 DxfHatchPatternDefLine * 04461 dxf_hatch_pattern_def_line_set_x1 04462 ( 04463 DxfHatchPatternDefLine *line, 04465 double x1 04467 ) 04468 { 04469 #if DEBUG 04470 DXF_DEBUG_BEGIN 04471 #endif 04472 /* Do some basic checks. */ 04473 if (line == NULL) 04474 { 04475 fprintf (stderr, 04476 (_("Error in %s () a NULL pointer was passed.\n")), 04477 __FUNCTION__); 04478 return (NULL); 04479 } 04480 line->x1 = x1; 04481 #if DEBUG 04482 DXF_DEBUG_END 04483 #endif 04484 return (line); 04485 } 04486 04487 04494 double 04495 dxf_hatch_pattern_def_line_get_y1 04496 ( 04497 DxfHatchPatternDefLine *line 04499 ) 04500 { 04501 #if DEBUG 04502 DXF_DEBUG_BEGIN 04503 #endif 04504 double result; 04505 04506 /* Do some basic checks. */ 04507 if (line == NULL) 04508 { 04509 fprintf (stderr, 04510 (_("Error in %s () a NULL pointer was passed.\n")), 04511 __FUNCTION__); 04512 return (EXIT_FAILURE); 04513 } 04514 result = line->y1; 04515 #if DEBUG 04516 DXF_DEBUG_END 04517 #endif 04518 return (result); 04519 } 04520 04521 04526 DxfHatchPatternDefLine * 04527 dxf_hatch_pattern_def_line_set_y1 04528 ( 04529 DxfHatchPatternDefLine *line, 04531 double y1 04533 ) 04534 { 04535 #if DEBUG 04536 DXF_DEBUG_BEGIN 04537 #endif 04538 /* Do some basic checks. */ 04539 if (line == NULL) 04540 { 04541 fprintf (stderr, 04542 (_("Error in %s () a NULL pointer was passed.\n")), 04543 __FUNCTION__); 04544 return (NULL); 04545 } 04546 line->y1 = y1; 04547 #if DEBUG 04548 DXF_DEBUG_END 04549 #endif 04550 return (line); 04551 } 04552 04553 04560 int 04561 dxf_hatch_pattern_def_line_get_number_of_dash_items 04562 ( 04563 DxfHatchPatternDefLine *line 04565 ) 04566 { 04567 #if DEBUG 04568 DXF_DEBUG_BEGIN 04569 #endif 04570 int result; 04571 04572 /* Do some basic checks. */ 04573 if (line == NULL) 04574 { 04575 fprintf (stderr, 04576 (_("Error in %s () a NULL pointer was passed.\n")), 04577 __FUNCTION__); 04578 return (EXIT_FAILURE); 04579 } 04580 if (line->number_of_dash_items < 0) 04581 { 04582 fprintf (stderr, 04583 (_("Error in %s () a negative value was found in the dash_items member.\n")), 04584 __FUNCTION__); 04585 return (EXIT_FAILURE); 04586 } 04587 result = line->number_of_dash_items; 04588 #if DEBUG 04589 DXF_DEBUG_END 04590 #endif 04591 return (result); 04592 } 04593 04594 04599 DxfHatchPatternDefLine * 04600 dxf_hatch_pattern_def_line_set_number_of_dash_items 04601 ( 04602 DxfHatchPatternDefLine *line, 04604 int number_of_dash_items 04606 ) 04607 { 04608 #if DEBUG 04609 DXF_DEBUG_BEGIN 04610 #endif 04611 /* Do some basic checks. */ 04612 if (line == NULL) 04613 { 04614 fprintf (stderr, 04615 (_("Error in %s () a NULL pointer was passed.\n")), 04616 __FUNCTION__); 04617 return (NULL); 04618 } 04619 if (number_of_dash_items < 0) 04620 { 04621 fprintf (stderr, 04622 (_("Error in %s () a negative dash_items value was passed.\n")), 04623 __FUNCTION__); 04624 return (NULL); 04625 } 04626 line->number_of_dash_items = number_of_dash_items; 04627 #if DEBUG 04628 DXF_DEBUG_END 04629 #endif 04630 return (line); 04631 } 04632 04633 04642 DxfHatchPatternDefLineDash * 04643 dxf_hatch_pattern_def_line_get_dashes 04644 ( 04645 DxfHatchPatternDefLine *line 04647 ) 04648 { 04649 #if DEBUG 04650 DXF_DEBUG_BEGIN 04651 #endif 04652 DxfHatchPatternDefLineDash *result; 04653 04654 /* Do some basic checks. */ 04655 if (line == NULL) 04656 { 04657 fprintf (stderr, 04658 (_("Error in %s () a NULL pointer was passed.\n")), 04659 __FUNCTION__); 04660 return (NULL); 04661 } 04662 result = (DxfHatchPatternDefLineDash *) line->dashes; 04663 #if DEBUG 04664 DXF_DEBUG_END 04665 #endif 04666 return (result); 04667 } 04668 04669 04674 DxfHatchPatternDefLine * 04675 dxf_hatch_pattern_def_line_set_dashes 04676 ( 04677 DxfHatchPatternDefLine *line, 04679 DxfHatchPatternDefLineDash *dashes 04681 ) 04682 { 04683 #if DEBUG 04684 DXF_DEBUG_BEGIN 04685 #endif 04686 /* Do some basic checks. */ 04687 if (line == NULL) 04688 { 04689 fprintf (stderr, 04690 (_("Error in %s () a NULL pointer was passed.\n")), 04691 __FUNCTION__); 04692 return (NULL); 04693 } 04694 if (dashes == NULL) 04695 { 04696 fprintf (stderr, 04697 (_("Error in %s () a NULL pointer was passed.\n")), 04698 __FUNCTION__); 04699 return (NULL); 04700 } 04701 line->dashes = (struct DxfHatchPatternDefLineDash *) dashes; 04702 #if DEBUG 04703 DXF_DEBUG_END 04704 #endif 04705 return (line); 04706 } 04707 04708 04717 DxfHatchPatternDefLine * 04718 dxf_hatch_pattern_def_line_get_next 04719 ( 04720 DxfHatchPatternDefLine *line 04722 ) 04723 { 04724 #if DEBUG 04725 DXF_DEBUG_BEGIN 04726 #endif 04727 DxfHatchPatternDefLine *result; 04728 04729 /* Do some basic checks. */ 04730 if (line == NULL) 04731 { 04732 fprintf (stderr, 04733 (_("Error in %s () a NULL pointer was passed.\n")), 04734 __FUNCTION__); 04735 return (NULL); 04736 } 04737 if (line->next == NULL) 04738 { 04739 fprintf (stderr, 04740 (_("Error in %s () a NULL pointer was found in the next member.\n")), 04741 __FUNCTION__); 04742 return (NULL); 04743 } 04744 result = (DxfHatchPatternDefLine *) line->next; 04745 #if DEBUG 04746 DXF_DEBUG_END 04747 #endif 04748 return (result); 04749 } 04750 04751 04756 DxfHatchPatternDefLine * 04757 dxf_hatch_pattern_def_line_set_next 04758 ( 04759 DxfHatchPatternDefLine *line, 04761 DxfHatchPatternDefLine *next 04764 ) 04765 { 04766 #if DEBUG 04767 DXF_DEBUG_BEGIN 04768 #endif 04769 /* Do some basic checks. */ 04770 if (line == NULL) 04771 { 04772 fprintf (stderr, 04773 (_("Error in %s () a NULL pointer was passed.\n")), 04774 __FUNCTION__); 04775 return (NULL); 04776 } 04777 if (next == NULL) 04778 { 04779 fprintf (stderr, 04780 (_("Error in %s () a NULL pointer was passed.\n")), 04781 __FUNCTION__); 04782 return (NULL); 04783 } 04784 line->next = (struct DxfHatchPatternDefLine *) next; 04785 #if DEBUG 04786 DXF_DEBUG_END 04787 #endif 04788 return (line); 04789 } 04790 04791 04800 DxfHatchPatternDefLine * 04801 dxf_hatch_pattern_def_line_get_last 04802 ( 04803 DxfHatchPatternDefLine *line 04805 ) 04806 { 04807 #if DEBUG 04808 DXF_DEBUG_BEGIN 04809 #endif 04810 /* Do some basic checks. */ 04811 if (line == NULL) 04812 { 04813 fprintf (stderr, 04814 (_("Error in %s () a NULL pointer was passed.\n")), 04815 __FUNCTION__); 04816 return (NULL); 04817 } 04818 if (line->next == NULL) 04819 { 04820 fprintf (stderr, 04821 (_("Warning in %s () a NULL pointer was found in the next member.\n")), 04822 __FUNCTION__); 04823 return ((DxfHatchPatternDefLine *) line); 04824 } 04825 DxfHatchPatternDefLine *iter = (DxfHatchPatternDefLine *) line->next; 04826 while (iter->next != NULL) 04827 { 04828 iter = (DxfHatchPatternDefLine *) iter->next; 04829 } 04830 #if DEBUG 04831 DXF_DEBUG_END 04832 #endif 04833 return ((DxfHatchPatternDefLine *) iter); 04834 } 04835 04836 04837 /* dxf_hatch_pattern_seedpoint functions. */ 04838 04844 DxfHatchPatternSeedPoint * 04845 dxf_hatch_pattern_seedpoint_new () 04846 { 04847 #if DEBUG 04848 DXF_DEBUG_BEGIN 04849 #endif 04850 DxfHatchPatternSeedPoint *seedpoint = NULL; 04851 size_t size; 04852 04853 size = sizeof (DxfHatchPatternSeedPoint); 04854 /* avoid malloc of 0 bytes */ 04855 if (size == 0) size = 1; 04856 if ((seedpoint = malloc (size)) == NULL) 04857 { 04858 fprintf (stderr, 04859 (_("Error in %s () could not allocate memory for a DxfHatchPatternSeedpoint struct.\n")), 04860 __FUNCTION__); 04861 seedpoint = NULL; 04862 } 04863 else 04864 { 04865 memset (seedpoint, 0, size); 04866 } 04867 #if DEBUG 04868 DXF_DEBUG_END 04869 #endif 04870 return (seedpoint); 04871 } 04872 04873 04881 DxfHatchPatternSeedPoint * 04882 dxf_hatch_pattern_seedpoint_init 04883 ( 04884 DxfHatchPatternSeedPoint *seedpoint 04886 ) 04887 { 04888 #if DEBUG 04889 DXF_DEBUG_BEGIN 04890 #endif 04891 /* Do some basic checks. */ 04892 if (seedpoint == NULL) 04893 { 04894 fprintf (stderr, 04895 (_("Warning in %s () a NULL pointer was passed.\n")), 04896 __FUNCTION__); 04897 seedpoint = dxf_hatch_pattern_seedpoint_new (); 04898 } 04899 if (seedpoint == NULL) 04900 { 04901 fprintf (stderr, 04902 (_("Error in %s () could not allocate memory for a DxfHatchPatternSeedPoint struct.\n")), 04903 __FUNCTION__); 04904 return (NULL); 04905 } 04906 seedpoint->id_code = 0; 04907 seedpoint->x0 = 0.0; 04908 seedpoint->y0 = 0.0; 04909 seedpoint->next = NULL; 04910 #if DEBUG 04911 DXF_DEBUG_END 04912 #endif 04913 return (seedpoint); 04914 } 04915 04916 04924 int 04925 dxf_hatch_pattern_seedpoint_write 04926 ( 04927 DxfFile *fp, 04929 DxfHatchPatternSeedPoint *seedpoint 04931 ) 04932 { 04933 #if DEBUG 04934 DXF_DEBUG_BEGIN 04935 #endif 04936 /* Do some basic checks. */ 04937 if (fp == NULL) 04938 { 04939 fprintf (stderr, 04940 (_("Error in %s () a NULL pointer was passed.\n")), 04941 __FUNCTION__); 04942 return (EXIT_FAILURE); 04943 } 04944 if (seedpoint == NULL) 04945 { 04946 fprintf (stderr, 04947 (_("Error in %s () a NULL pointer was passed.\n")), 04948 __FUNCTION__); 04949 return (EXIT_FAILURE); 04950 } 04951 /* Start writing output. */ 04952 fprintf (fp->fp, " 10\n%f\n", seedpoint->x0); 04953 fprintf (fp->fp, " 20\n%f\n", seedpoint->y0); 04954 #if DEBUG 04955 DXF_DEBUG_END 04956 #endif 04957 return (EXIT_SUCCESS); 04958 } 04959 04960 04968 int 04969 dxf_hatch_pattern_seedpoint_free 04970 ( 04971 DxfHatchPatternSeedPoint *seedpoint 04974 ) 04975 { 04976 #if DEBUG 04977 DXF_DEBUG_BEGIN 04978 #endif 04979 /* Do some basic checks. */ 04980 if (seedpoint == NULL) 04981 { 04982 fprintf (stderr, 04983 (_("Error in %s () a NULL pointer was passed.\n")), 04984 __FUNCTION__); 04985 return (EXIT_FAILURE); 04986 } 04987 if (seedpoint->next != NULL) 04988 { 04989 fprintf (stderr, 04990 (_("Error in %s () pointer to next was not NULL.\n")), 04991 __FUNCTION__); 04992 return (EXIT_FAILURE); 04993 } 04994 free (seedpoint); 04995 seedpoint = NULL; 04996 #if DEBUG 04997 DXF_DEBUG_END 04998 #endif 04999 return (EXIT_SUCCESS); 05000 } 05001 05002 05007 void 05008 dxf_hatch_pattern_seedpoint_free_chain 05009 ( 05010 DxfHatchPatternSeedPoint *hatch_pattern_seed_points 05013 ) 05014 { 05015 #ifdef DEBUG 05016 DXF_DEBUG_BEGIN 05017 #endif 05018 /* Do some basic checks. */ 05019 if (hatch_pattern_seed_points == NULL) 05020 { 05021 fprintf (stderr, 05022 (_("Warning in %s () a NULL pointer was passed.\n")), 05023 __FUNCTION__); 05024 } 05025 while (hatch_pattern_seed_points != NULL) 05026 { 05027 struct DxfHatchPatternSeedPoint *iter = hatch_pattern_seed_points->next; 05028 dxf_hatch_pattern_seedpoint_free (hatch_pattern_seed_points); 05029 hatch_pattern_seed_points = (DxfHatchPatternSeedPoint *) iter; 05030 } 05031 #if DEBUG 05032 DXF_DEBUG_END 05033 #endif 05034 } 05035 05036 05042 int 05043 dxf_hatch_pattern_seedpoint_get_id_code 05044 ( 05045 DxfHatchPatternSeedPoint *point 05047 ) 05048 { 05049 #if DEBUG 05050 DXF_DEBUG_BEGIN 05051 #endif 05052 int result; 05053 05054 /* Do some basic checks. */ 05055 if (point == NULL) 05056 { 05057 fprintf (stderr, 05058 (_("Error in %s () a NULL pointer was passed.\n")), 05059 __FUNCTION__); 05060 return (EXIT_FAILURE); 05061 } 05062 if (point->id_code < 0) 05063 { 05064 fprintf (stderr, 05065 (_("Error in %s () a negative value was found in the id_code member.\n")), 05066 __FUNCTION__); 05067 return (EXIT_FAILURE); 05068 } 05069 result = point->id_code; 05070 #if DEBUG 05071 DXF_DEBUG_END 05072 #endif 05073 return (result); 05074 } 05075 05076 05080 DxfHatchPatternSeedPoint * 05081 dxf_hatch_pattern_seedpoint_set_id_code 05082 ( 05083 DxfHatchPatternSeedPoint *point, 05085 int id_code 05089 ) 05090 { 05091 #if DEBUG 05092 DXF_DEBUG_BEGIN 05093 #endif 05094 /* Do some basic checks. */ 05095 if (point == NULL) 05096 { 05097 fprintf (stderr, 05098 (_("Error in %s () a NULL pointer was passed.\n")), 05099 __FUNCTION__); 05100 return (NULL); 05101 } 05102 if (id_code < 0) 05103 { 05104 fprintf (stderr, 05105 (_("Error in %s () a negative id-code value was passed.\n")), 05106 __FUNCTION__); 05107 return (NULL); 05108 } 05109 point->id_code = id_code; 05110 #if DEBUG 05111 DXF_DEBUG_END 05112 #endif 05113 return (point); 05114 } 05115 05116 05122 double 05123 dxf_hatch_pattern_seedpoint_get_x0 05124 ( 05125 DxfHatchPatternSeedPoint *point 05127 ) 05128 { 05129 #if DEBUG 05130 DXF_DEBUG_BEGIN 05131 #endif 05132 double result; 05133 05134 /* Do some basic checks. */ 05135 if (point == NULL) 05136 { 05137 fprintf (stderr, 05138 (_("Error in %s () a NULL pointer was passed.\n")), 05139 __FUNCTION__); 05140 return (EXIT_FAILURE); 05141 } 05142 result = point->x0; 05143 #if DEBUG 05144 DXF_DEBUG_END 05145 #endif 05146 return (result); 05147 } 05148 05149 05153 DxfHatchPatternSeedPoint * 05154 dxf_hatch_pattern_seedpoint_set_x0 05155 ( 05156 DxfHatchPatternSeedPoint *point, 05158 double x0 05160 ) 05161 { 05162 #if DEBUG 05163 DXF_DEBUG_BEGIN 05164 #endif 05165 /* Do some basic checks. */ 05166 if (point == NULL) 05167 { 05168 fprintf (stderr, 05169 (_("Error in %s () a NULL pointer was passed.\n")), 05170 __FUNCTION__); 05171 return (NULL); 05172 } 05173 point->x0 = x0; 05174 #if DEBUG 05175 DXF_DEBUG_END 05176 #endif 05177 return (point); 05178 } 05179 05180 05186 double 05187 dxf_hatch_pattern_seedpoint_get_y0 05188 ( 05189 DxfHatchPatternSeedPoint *point 05191 ) 05192 { 05193 #if DEBUG 05194 DXF_DEBUG_BEGIN 05195 #endif 05196 double result; 05197 05198 /* Do some basic checks. */ 05199 if (point == NULL) 05200 { 05201 fprintf (stderr, 05202 (_("Error in %s () a NULL pointer was passed.\n")), 05203 __FUNCTION__); 05204 return (EXIT_FAILURE); 05205 } 05206 result = point->y0; 05207 #if DEBUG 05208 DXF_DEBUG_END 05209 #endif 05210 return (result); 05211 } 05212 05213 05217 DxfHatchPatternSeedPoint * 05218 dxf_hatch_pattern_seedpoint_set_y0 05219 ( 05220 DxfHatchPatternSeedPoint *point, 05222 double y0 05224 ) 05225 { 05226 #if DEBUG 05227 DXF_DEBUG_BEGIN 05228 #endif 05229 /* Do some basic checks. */ 05230 if (point == NULL) 05231 { 05232 fprintf (stderr, 05233 (_("Error in %s () a NULL pointer was passed.\n")), 05234 __FUNCTION__); 05235 return (NULL); 05236 } 05237 point->y0 = y0; 05238 #if DEBUG 05239 DXF_DEBUG_END 05240 #endif 05241 return (point); 05242 } 05243 05244 05253 DxfHatchPatternSeedPoint * 05254 dxf_hatch_pattern_seedpoint_get_next 05255 ( 05256 DxfHatchPatternSeedPoint *point 05258 ) 05259 { 05260 #if DEBUG 05261 DXF_DEBUG_BEGIN 05262 #endif 05263 DxfHatchPatternSeedPoint *result; 05264 05265 /* Do some basic checks. */ 05266 if (point == NULL) 05267 { 05268 fprintf (stderr, 05269 (_("Error in %s () a NULL pointer was passed.\n")), 05270 __FUNCTION__); 05271 return (NULL); 05272 } 05273 if (point->next == NULL) 05274 { 05275 fprintf (stderr, 05276 (_("Error in %s () a NULL pointer was found in the next member.\n")), 05277 __FUNCTION__); 05278 return (NULL); 05279 } 05280 result = (DxfHatchPatternSeedPoint *) point->next; 05281 #if DEBUG 05282 DXF_DEBUG_END 05283 #endif 05284 return (result); 05285 } 05286 05287 05292 DxfHatchPatternSeedPoint * 05293 dxf_hatch_pattern_seedpoint_set_next 05294 ( 05295 DxfHatchPatternSeedPoint *point, 05297 DxfHatchPatternSeedPoint *next 05300 ) 05301 { 05302 #if DEBUG 05303 DXF_DEBUG_BEGIN 05304 #endif 05305 /* Do some basic checks. */ 05306 if (point == NULL) 05307 { 05308 fprintf (stderr, 05309 (_("Error in %s () a NULL pointer was passed.\n")), 05310 __FUNCTION__); 05311 return (NULL); 05312 } 05313 if (next == NULL) 05314 { 05315 fprintf (stderr, 05316 (_("Error in %s () a NULL pointer was passed.\n")), 05317 __FUNCTION__); 05318 return (NULL); 05319 } 05320 point->next = (struct DxfHatchPatternSeedPoint *) next; 05321 #if DEBUG 05322 DXF_DEBUG_END 05323 #endif 05324 return (point); 05325 } 05326 05327 05336 DxfHatchPatternSeedPoint * 05337 dxf_hatch_pattern_seedpoint_get_last 05338 ( 05339 DxfHatchPatternSeedPoint *point 05341 ) 05342 { 05343 #if DEBUG 05344 DXF_DEBUG_BEGIN 05345 #endif 05346 /* Do some basic checks. */ 05347 if (point == NULL) 05348 { 05349 fprintf (stderr, 05350 (_("Error in %s () a NULL pointer was passed.\n")), 05351 __FUNCTION__); 05352 return (NULL); 05353 } 05354 if (point->next == NULL) 05355 { 05356 fprintf (stderr, 05357 (_("Warning in %s () a NULL pointer was found in the next member.\n")), 05358 __FUNCTION__); 05359 return ((DxfHatchPatternSeedPoint *) point); 05360 } 05361 DxfHatchPatternSeedPoint *iter = (DxfHatchPatternSeedPoint *) point->next; 05362 while (iter->next != NULL) 05363 { 05364 iter = (DxfHatchPatternSeedPoint *) iter->next; 05365 } 05366 #if DEBUG 05367 DXF_DEBUG_END 05368 #endif 05369 return ((DxfHatchPatternSeedPoint *) iter); 05370 } 05371 05372 05373 /* dxf_hatch_boundary_path functions. */ 05374 05380 DxfHatchBoundaryPath * 05381 dxf_hatch_boundary_path_new () 05382 { 05383 #if DEBUG 05384 DXF_DEBUG_BEGIN 05385 #endif 05386 DxfHatchBoundaryPath *path = NULL; 05387 size_t size; 05388 05389 size = sizeof (DxfHatchBoundaryPath); 05390 /* avoid malloc of 0 bytes */ 05391 if (size == 0) size = 1; 05392 if ((path = malloc (size)) == NULL) 05393 { 05394 fprintf (stderr, 05395 (_("Error in %s () could not allocate memory for a DxfHatchBoundaryPath struct.\n")), 05396 __FUNCTION__); 05397 path = NULL; 05398 } 05399 else 05400 { 05401 memset (path, 0, size); 05402 } 05403 #if DEBUG 05404 DXF_DEBUG_END 05405 #endif 05406 return (path); 05407 } 05408 05409 05417 DxfHatchBoundaryPath * 05418 dxf_hatch_boundary_path_init 05419 ( 05420 DxfHatchBoundaryPath *path 05422 ) 05423 { 05424 #if DEBUG 05425 DXF_DEBUG_BEGIN 05426 #endif 05427 /* Do some basic checks. */ 05428 if (path == NULL) 05429 { 05430 fprintf (stderr, 05431 (_("Warning in %s () a NULL pointer was passed.\n")), 05432 __FUNCTION__); 05433 path = dxf_hatch_boundary_path_new (); 05434 } 05435 if (path == NULL) 05436 { 05437 fprintf (stderr, 05438 (_("Error in %s () could not allocate memory for a DxfHatchBoundaryPath struct.\n")), 05439 __FUNCTION__); 05440 return (NULL); 05441 } 05442 path->id_code = 0; 05443 dxf_hatch_boundary_path_edge_init ((DxfHatchBoundaryPathEdge *) path->edges); 05444 dxf_hatch_boundary_path_polyline_init ((DxfHatchBoundaryPathPolyline *) path->polylines); 05445 path->next = NULL; 05446 #if DEBUG 05447 DXF_DEBUG_END 05448 #endif 05449 return (path); 05450 } 05451 05452 05458 int 05459 dxf_hatch_boundary_path_write 05460 ( 05461 DxfFile *fp, 05463 DxfHatchBoundaryPath *path 05465 ) 05466 { 05467 #if DEBUG 05468 DXF_DEBUG_BEGIN 05469 #endif 05470 DxfHatchBoundaryPathPolyline *iter; 05471 05472 /* Do some basic checks. */ 05473 if (fp == NULL) 05474 { 05475 fprintf (stderr, 05476 (_("Error in %s () a NULL pointer was passed.\n")), 05477 __FUNCTION__); 05478 return (EXIT_FAILURE); 05479 } 05480 if (path == NULL) 05481 { 05482 fprintf (stderr, 05483 (_("Error in %s () a NULL pointer was passed.\n")), 05484 __FUNCTION__); 05485 return (EXIT_FAILURE); 05486 } 05487 /* Start writing output. */ 05488 for (;;) 05489 { 05490 if (path->next == NULL) 05491 { 05492 fprintf (stderr, 05493 (_("Information from %s () last boundary path encountered.\n")), 05494 __FUNCTION__); 05495 break; 05496 } 05497 else 05498 { 05499 /* Test for edge type or polylines type. */ 05500 if (path->edges != NULL) 05501 { 05503 } 05504 else if (path->polylines != NULL) 05505 { 05506 iter = dxf_hatch_boundary_path_polyline_new (); 05507 iter = (DxfHatchBoundaryPathPolyline *) path->polylines; 05508 for (;;) 05509 { 05510 dxf_hatch_boundary_path_polyline_write 05511 ( 05512 fp, 05513 iter 05514 ); 05515 iter = (DxfHatchBoundaryPathPolyline *) iter->next; 05516 if (iter == NULL) 05517 { 05518 break; 05519 } 05520 } 05521 } 05522 else 05523 { 05524 fprintf (stderr, 05525 (_("Error in %s () unknown boundary path type encountered.\n")), 05526 __FUNCTION__); 05527 return (EXIT_FAILURE); 05528 } 05529 } 05530 } 05531 #if DEBUG 05532 DXF_DEBUG_END 05533 #endif 05534 return (EXIT_SUCCESS); 05535 } 05536 05537 05545 int 05546 dxf_hatch_boundary_path_free 05547 ( 05548 DxfHatchBoundaryPath *path 05551 ) 05552 { 05553 #if DEBUG 05554 DXF_DEBUG_BEGIN 05555 #endif 05556 /* Do some basic checks. */ 05557 if (path == NULL) 05558 { 05559 fprintf (stderr, 05560 (_("Error in %s () a NULL pointer was passed.\n")), 05561 __FUNCTION__); 05562 return (EXIT_FAILURE); 05563 } 05564 if (path->next != NULL) 05565 { 05566 fprintf (stderr, 05567 (_("Error in %s () pointer to next was not NULL.\n")), 05568 __FUNCTION__); 05569 return (EXIT_FAILURE); 05570 } 05571 free (path->edges); 05572 free (path->polylines); 05573 free (path); 05574 path = NULL; 05575 #if DEBUG 05576 DXF_DEBUG_END 05577 #endif 05578 return (EXIT_SUCCESS); 05579 } 05580 05581 05586 void 05587 dxf_hatch_boundary_path_free_chain 05588 ( 05589 DxfHatchBoundaryPath *hatch_boundary_paths 05591 ) 05592 { 05593 #ifdef DEBUG 05594 DXF_DEBUG_BEGIN 05595 #endif 05596 /* Do some basic checks. */ 05597 if (hatch_boundary_paths == NULL) 05598 { 05599 fprintf (stderr, 05600 (_("Warning in %s () a NULL pointer was passed.\n")), 05601 __FUNCTION__); 05602 } 05603 while (hatch_boundary_paths != NULL) 05604 { 05605 struct DxfHatchBoundaryPath *iter = hatch_boundary_paths->next; 05606 dxf_hatch_boundary_path_free (hatch_boundary_paths); 05607 hatch_boundary_paths = (DxfHatchBoundaryPath *) iter; 05608 } 05609 #if DEBUG 05610 DXF_DEBUG_END 05611 #endif 05612 } 05613 05614 05620 int 05621 dxf_hatch_boundary_path_get_id_code 05622 ( 05623 DxfHatchBoundaryPath *path 05625 ) 05626 { 05627 #if DEBUG 05628 DXF_DEBUG_BEGIN 05629 #endif 05630 int result; 05631 05632 /* Do some basic checks. */ 05633 if (path == NULL) 05634 { 05635 fprintf (stderr, 05636 (_("Error in %s () a NULL pointer was passed.\n")), 05637 __FUNCTION__); 05638 return (EXIT_FAILURE); 05639 } 05640 if (path->id_code < 0) 05641 { 05642 fprintf (stderr, 05643 (_("Error in %s () a negative value was found in the id_code member.\n")), 05644 __FUNCTION__); 05645 return (EXIT_FAILURE); 05646 } 05647 result = path->id_code; 05648 #if DEBUG 05649 DXF_DEBUG_END 05650 #endif 05651 return (result); 05652 } 05653 05654 05658 DxfHatchBoundaryPath * 05659 dxf_hatch_boundary_path_set_id_code 05660 ( 05661 DxfHatchBoundaryPath *path, 05663 int id_code 05667 ) 05668 { 05669 #if DEBUG 05670 DXF_DEBUG_BEGIN 05671 #endif 05672 /* Do some basic checks. */ 05673 if (path == NULL) 05674 { 05675 fprintf (stderr, 05676 (_("Error in %s () a NULL pointer was passed.\n")), 05677 __FUNCTION__); 05678 return (NULL); 05679 } 05680 if (id_code < 0) 05681 { 05682 fprintf (stderr, 05683 (_("Error in %s () a negative id-code value was passed.\n")), 05684 __FUNCTION__); 05685 return (NULL); 05686 } 05687 path->id_code = id_code; 05688 #if DEBUG 05689 DXF_DEBUG_END 05690 #endif 05691 return (path); 05692 } 05693 05694 05702 DxfHatchBoundaryPathEdge * 05703 dxf_hatch_boundary_path_get_edges 05704 ( 05705 DxfHatchBoundaryPath *path 05707 ) 05708 { 05709 #if DEBUG 05710 DXF_DEBUG_BEGIN 05711 #endif 05712 DxfHatchBoundaryPathEdge *result; 05713 05714 /* Do some basic checks. */ 05715 if (path == NULL) 05716 { 05717 fprintf (stderr, 05718 (_("Error in %s () a NULL pointer was passed.\n")), 05719 __FUNCTION__); 05720 return (NULL); 05721 } 05722 result = (DxfHatchBoundaryPathEdge *) path->edges; 05723 #if DEBUG 05724 DXF_DEBUG_END 05725 #endif 05726 return (result); 05727 } 05728 05729 05733 DxfHatchBoundaryPath * 05734 dxf_hatch_boundary_path_set_edges 05735 ( 05736 DxfHatchBoundaryPath *path, 05738 DxfHatchBoundaryPathEdge *edges 05740 ) 05741 { 05742 #if DEBUG 05743 DXF_DEBUG_BEGIN 05744 #endif 05745 /* Do some basic checks. */ 05746 if (path == NULL) 05747 { 05748 fprintf (stderr, 05749 (_("Error in %s () a NULL pointer was passed.\n")), 05750 __FUNCTION__); 05751 return (NULL); 05752 } 05753 if (edges == NULL) 05754 { 05755 fprintf (stderr, 05756 (_("Error in %s () a NULL pointer was passed.\n")), 05757 __FUNCTION__); 05758 return (NULL); 05759 } 05760 path->edges = (struct DxfHatchBoundaryPathEdge *) edges; 05761 #if DEBUG 05762 DXF_DEBUG_END 05763 #endif 05764 return (path); 05765 } 05766 05767 05775 DxfHatchBoundaryPathPolyline * 05776 dxf_hatch_boundary_path_get_polylines 05777 ( 05778 DxfHatchBoundaryPath *path 05780 ) 05781 { 05782 #if DEBUG 05783 DXF_DEBUG_BEGIN 05784 #endif 05785 DxfHatchBoundaryPathPolyline *result; 05786 05787 /* Do some basic checks. */ 05788 if (path == NULL) 05789 { 05790 fprintf (stderr, 05791 (_("Error in %s () a NULL pointer was passed.\n")), 05792 __FUNCTION__); 05793 return (NULL); 05794 } 05795 result = (DxfHatchBoundaryPathPolyline *) path->polylines; 05796 #if DEBUG 05797 DXF_DEBUG_END 05798 #endif 05799 return (result); 05800 } 05801 05802 05806 DxfHatchBoundaryPath * 05807 dxf_hatch_boundary_path_set_polylines 05808 ( 05809 DxfHatchBoundaryPath *path, 05811 DxfHatchBoundaryPathPolyline *polylines 05813 ) 05814 { 05815 #if DEBUG 05816 DXF_DEBUG_BEGIN 05817 #endif 05818 /* Do some basic checks. */ 05819 if (path == NULL) 05820 { 05821 fprintf (stderr, 05822 (_("Error in %s () a NULL pointer was passed.\n")), 05823 __FUNCTION__); 05824 return (NULL); 05825 } 05826 if (polylines == NULL) 05827 { 05828 fprintf (stderr, 05829 (_("Error in %s () a NULL pointer was passed.\n")), 05830 __FUNCTION__); 05831 return (NULL); 05832 } 05833 path->polylines = (struct DxfHatchBoundaryPathPolyline *) polylines; 05834 #if DEBUG 05835 DXF_DEBUG_END 05836 #endif 05837 return (path); 05838 } 05839 05840 05849 DxfHatchBoundaryPath * 05850 dxf_hatch_boundary_path_get_next 05851 ( 05852 DxfHatchBoundaryPath *path 05854 ) 05855 { 05856 #if DEBUG 05857 DXF_DEBUG_BEGIN 05858 #endif 05859 DxfHatchBoundaryPath *result; 05860 05861 /* Do some basic checks. */ 05862 if (path == NULL) 05863 { 05864 fprintf (stderr, 05865 (_("Error in %s () a NULL pointer was passed.\n")), 05866 __FUNCTION__); 05867 return (NULL); 05868 } 05869 if (path->next == NULL) 05870 { 05871 fprintf (stderr, 05872 (_("Error in %s () a NULL pointer was found in the next member.\n")), 05873 __FUNCTION__); 05874 return (NULL); 05875 } 05876 result = (DxfHatchBoundaryPath *) path->next; 05877 #if DEBUG 05878 DXF_DEBUG_END 05879 #endif 05880 return (result); 05881 } 05882 05883 05888 DxfHatchBoundaryPath * 05889 dxf_hatch_boundary_path_set_next 05890 ( 05891 DxfHatchBoundaryPath *path, 05893 DxfHatchBoundaryPath *next 05896 ) 05897 { 05898 #if DEBUG 05899 DXF_DEBUG_BEGIN 05900 #endif 05901 /* Do some basic checks. */ 05902 if (path == NULL) 05903 { 05904 fprintf (stderr, 05905 (_("Error in %s () a NULL pointer was passed.\n")), 05906 __FUNCTION__); 05907 return (NULL); 05908 } 05909 if (next == NULL) 05910 { 05911 fprintf (stderr, 05912 (_("Error in %s () a NULL pointer was passed.\n")), 05913 __FUNCTION__); 05914 return (NULL); 05915 } 05916 path->next = (struct DxfHatchBoundaryPath *) next; 05917 #if DEBUG 05918 DXF_DEBUG_END 05919 #endif 05920 return (path); 05921 } 05922 05923 05932 DxfHatchBoundaryPath * 05933 dxf_hatch_boundary_path_get_last 05934 ( 05935 DxfHatchBoundaryPath *path 05937 ) 05938 { 05939 #if DEBUG 05940 DXF_DEBUG_BEGIN 05941 #endif 05942 /* Do some basic checks. */ 05943 if (path == NULL) 05944 { 05945 fprintf (stderr, 05946 (_("Error in %s () a NULL pointer was passed.\n")), 05947 __FUNCTION__); 05948 return (NULL); 05949 } 05950 if (path->next == NULL) 05951 { 05952 fprintf (stderr, 05953 (_("Warning in %s () a NULL pointer was found in the next member.\n")), 05954 __FUNCTION__); 05955 return ((DxfHatchBoundaryPath *) path); 05956 } 05957 DxfHatchBoundaryPath *iter = (DxfHatchBoundaryPath *) path->next; 05958 while (iter->next != NULL) 05959 { 05960 iter = (DxfHatchBoundaryPath *) iter->next; 05961 } 05962 #if DEBUG 05963 DXF_DEBUG_END 05964 #endif 05965 return ((DxfHatchBoundaryPath *) iter); 05966 } 05967 05968 05969 /* dxf_hatch_boundary_path_polyline functions. */ 05970 05976 DxfHatchBoundaryPathPolyline * 05977 dxf_hatch_boundary_path_polyline_new () 05978 { 05979 #if DEBUG 05980 DXF_DEBUG_BEGIN 05981 #endif 05982 DxfHatchBoundaryPathPolyline *polyline = NULL; 05983 size_t size; 05984 05985 size = sizeof (DxfHatchBoundaryPathPolyline); 05986 /* avoid malloc of 0 bytes */ 05987 if (size == 0) size = 1; 05988 if ((polyline = malloc (size)) == NULL) 05989 { 05990 fprintf (stderr, 05991 (_("Error in %s () could not allocate memory for a DxfHatchBoundaryPathPolyline struct.\n")), 05992 __FUNCTION__); 05993 polyline = NULL; 05994 } 05995 else 05996 { 05997 memset (polyline, 0, size); 05998 } 05999 #if DEBUG 06000 DXF_DEBUG_END 06001 #endif 06002 return (polyline); 06003 } 06004 06005 06013 DxfHatchBoundaryPathPolyline * 06014 dxf_hatch_boundary_path_polyline_init 06015 ( 06016 DxfHatchBoundaryPathPolyline *polyline 06018 ) 06019 { 06020 #if DEBUG 06021 DXF_DEBUG_BEGIN 06022 #endif 06023 /* Do some basic checks. */ 06024 if (polyline == NULL) 06025 { 06026 fprintf (stderr, 06027 (_("Warning in %s () a NULL pointer was passed.\n")), 06028 __FUNCTION__); 06029 polyline = dxf_hatch_boundary_path_polyline_new (); 06030 } 06031 if (polyline == NULL) 06032 { 06033 fprintf (stderr, 06034 (_("Error in %s () could not allocate memory for a DxfHatchBoundaryPathPolyline struct.\n")), 06035 __FUNCTION__); 06036 return (NULL); 06037 } 06038 polyline->id_code = 0; 06039 polyline->is_closed = 0; 06040 polyline->number_of_vertices = 0; 06041 polyline->vertices = NULL; 06042 polyline->next = NULL; 06043 #if DEBUG 06044 DXF_DEBUG_END 06045 #endif 06046 return (polyline); 06047 } 06048 06049 06056 int 06057 dxf_hatch_boundary_path_polyline_write 06058 ( 06059 DxfFile *fp, 06061 DxfHatchBoundaryPathPolyline *polyline 06063 ) 06064 { 06065 #if DEBUG 06066 DXF_DEBUG_BEGIN 06067 #endif 06068 DxfHatchBoundaryPathPolylineVertex *iter; 06069 06070 /* Do some basic checks. */ 06071 if (fp == NULL) 06072 { 06073 fprintf (stderr, 06074 (_("Error in %s () a NULL pointer was passed.\n")), 06075 __FUNCTION__); 06076 return (EXIT_FAILURE); 06077 } 06078 if (polyline == NULL) 06079 { 06080 fprintf (stderr, 06081 (_("Error in %s () a NULL pointer was passed.\n")), 06082 __FUNCTION__); 06083 return (EXIT_FAILURE); 06084 } 06085 fprintf (fp->fp, " 73\n%d\n", polyline->is_closed); 06086 fprintf (fp->fp, " 93\n%d\n", polyline->number_of_vertices); 06087 /* draw hatch boundary vertices. */ 06088 iter = dxf_hatch_boundary_path_polyline_vertex_new (); 06089 iter = (DxfHatchBoundaryPathPolylineVertex *) polyline->vertices; 06090 for (;;) 06091 { 06092 dxf_hatch_boundary_path_polyline_vertex_write 06093 ( 06094 fp, 06095 iter 06096 ); 06097 iter = (DxfHatchBoundaryPathPolylineVertex *) iter->next; 06098 if (iter == NULL) 06099 { 06100 break; 06101 } 06102 } 06103 /* test for closed polyline: close with first vertex. */ 06104 if (polyline->is_closed) 06105 { 06106 dxf_hatch_boundary_path_polyline_vertex_write 06107 ( 06108 fp, 06109 (DxfHatchBoundaryPathPolylineVertex *) polyline->vertices 06110 ); 06111 } 06112 #if DEBUG 06113 DXF_DEBUG_END 06114 #endif 06115 return (EXIT_SUCCESS); 06116 } 06117 06118 06126 int 06127 dxf_hatch_boundary_path_polyline_free 06128 ( 06129 DxfHatchBoundaryPathPolyline *polyline 06132 ) 06133 { 06134 #if DEBUG 06135 DXF_DEBUG_BEGIN 06136 #endif 06137 /* Do some basic checks. */ 06138 if (polyline == NULL) 06139 { 06140 fprintf (stderr, 06141 (_("Error in %s () a NULL pointer was passed.\n")), 06142 __FUNCTION__); 06143 return (EXIT_FAILURE); 06144 } 06145 if (polyline->next != NULL) 06146 { 06147 fprintf (stderr, 06148 (_("Error in %s () pointer to next was not NULL.\n")), 06149 __FUNCTION__); 06150 return (EXIT_FAILURE); 06151 } 06152 free (polyline->vertices); 06153 free (polyline); 06154 polyline = NULL; 06155 #if DEBUG 06156 DXF_DEBUG_END 06157 #endif 06158 return (EXIT_SUCCESS); 06159 } 06160 06161 06166 void 06167 dxf_hatch_boundary_path_polyline_free_chain 06168 ( 06169 DxfHatchBoundaryPathPolyline *polylines 06172 ) 06173 { 06174 #ifdef DEBUG 06175 DXF_DEBUG_BEGIN 06176 #endif 06177 /* Do some basic checks. */ 06178 if (polylines == NULL) 06179 { 06180 fprintf (stderr, 06181 (_("Warning in %s () a NULL pointer was passed.\n")), 06182 __FUNCTION__); 06183 } 06184 while (polylines != NULL) 06185 { 06186 struct DxfHatchBoundaryPathPolyline *iter = polylines->next; 06187 dxf_hatch_boundary_path_polyline_free (polylines); 06188 polylines = (DxfHatchBoundaryPathPolyline *) iter; 06189 } 06190 #if DEBUG 06191 DXF_DEBUG_END 06192 #endif 06193 } 06194 06195 06201 int 06202 dxf_hatch_boundary_path_polyline_get_id_code 06203 ( 06204 DxfHatchBoundaryPathPolyline *polyline 06206 ) 06207 { 06208 #if DEBUG 06209 DXF_DEBUG_BEGIN 06210 #endif 06211 int result; 06212 06213 /* Do some basic checks. */ 06214 if (polyline == NULL) 06215 { 06216 fprintf (stderr, 06217 (_("Error in %s () a NULL pointer was passed.\n")), 06218 __FUNCTION__); 06219 return (EXIT_FAILURE); 06220 } 06221 if (polyline->id_code < 0) 06222 { 06223 fprintf (stderr, 06224 (_("Error in %s () a negative value was found in the id_code member.\n")), 06225 __FUNCTION__); 06226 return (EXIT_FAILURE); 06227 } 06228 result = polyline->id_code; 06229 #if DEBUG 06230 DXF_DEBUG_END 06231 #endif 06232 return (result); 06233 } 06234 06235 06239 DxfHatchBoundaryPathPolyline * 06240 dxf_hatch_boundary_path_polyline_set_id_code 06241 ( 06242 DxfHatchBoundaryPathPolyline *polyline, 06244 int id_code 06248 ) 06249 { 06250 #if DEBUG 06251 DXF_DEBUG_BEGIN 06252 #endif 06253 /* Do some basic checks. */ 06254 if (polyline == NULL) 06255 { 06256 fprintf (stderr, 06257 (_("Error in %s () a NULL pointer was passed.\n")), 06258 __FUNCTION__); 06259 return (NULL); 06260 } 06261 if (id_code < 0) 06262 { 06263 fprintf (stderr, 06264 (_("Error in %s () a negative id-code value was passed.\n")), 06265 __FUNCTION__); 06266 return (NULL); 06267 } 06268 polyline->id_code = id_code; 06269 #if DEBUG 06270 DXF_DEBUG_END 06271 #endif 06272 return (polyline); 06273 } 06274 06275 06282 int 06283 dxf_hatch_boundary_path_polyline_get_is_closed 06284 ( 06285 DxfHatchBoundaryPathPolyline *polyline 06287 ) 06288 { 06289 #if DEBUG 06290 DXF_DEBUG_BEGIN 06291 #endif 06292 int result; 06293 06294 /* Do some basic checks. */ 06295 if (polyline == NULL) 06296 { 06297 fprintf (stderr, 06298 (_("Error in %s () a NULL pointer was passed.\n")), 06299 __FUNCTION__); 06300 return (EXIT_FAILURE); 06301 } 06302 if (polyline->is_closed < 0) 06303 { 06304 fprintf (stderr, 06305 (_("Error in %s () a negative value was found in the is_closed member.\n")), 06306 __FUNCTION__); 06307 return (EXIT_FAILURE); 06308 } 06309 if (polyline->is_closed > 1) 06310 { 06311 fprintf (stderr, 06312 (_("Error in %s () an out of range value was found in the is_closed member.\n")), 06313 __FUNCTION__); 06314 return (EXIT_FAILURE); 06315 } 06316 result = polyline->is_closed; 06317 #if DEBUG 06318 DXF_DEBUG_END 06319 #endif 06320 return (result); 06321 } 06322 06323 06328 DxfHatchBoundaryPathPolyline * 06329 dxf_hatch_boundary_path_polyline_set_is_closed 06330 ( 06331 DxfHatchBoundaryPathPolyline *polyline, 06333 int is_closed 06335 ) 06336 { 06337 #if DEBUG 06338 DXF_DEBUG_BEGIN 06339 #endif 06340 /* Do some basic checks. */ 06341 if (polyline == NULL) 06342 { 06343 fprintf (stderr, 06344 (_("Error in %s () a NULL pointer was passed.\n")), 06345 __FUNCTION__); 06346 return (NULL); 06347 } 06348 if (is_closed < 0) 06349 { 06350 fprintf (stderr, 06351 (_("Error in %s () a negative value was passed.\n")), 06352 __FUNCTION__); 06353 return (NULL); 06354 } 06355 if (is_closed > 1) 06356 { 06357 fprintf (stderr, 06358 (_("Error in %s () an out of range value was passed.\n")), 06359 __FUNCTION__); 06360 return (NULL); 06361 } 06362 polyline->is_closed = is_closed; 06363 #if DEBUG 06364 DXF_DEBUG_END 06365 #endif 06366 return (polyline); 06367 } 06368 06369 06376 int 06377 dxf_hatch_boundary_path_polyline_get_number_of_vertices 06378 ( 06379 DxfHatchBoundaryPathPolyline *polyline 06381 ) 06382 { 06383 #if DEBUG 06384 DXF_DEBUG_BEGIN 06385 #endif 06386 int result; 06387 06388 /* Do some basic checks. */ 06389 if (polyline == NULL) 06390 { 06391 fprintf (stderr, 06392 (_("Error in %s () a NULL pointer was passed.\n")), 06393 __FUNCTION__); 06394 return (EXIT_FAILURE); 06395 } 06396 if (polyline->number_of_vertices < 0) 06397 { 06398 fprintf (stderr, 06399 (_("Error in %s () a negative value was found in the is_closed member.\n")), 06400 __FUNCTION__); 06401 return (EXIT_FAILURE); 06402 } 06403 result = polyline->number_of_vertices; 06404 #if DEBUG 06405 DXF_DEBUG_END 06406 #endif 06407 return (result); 06408 } 06409 06410 06415 DxfHatchBoundaryPathPolyline * 06416 dxf_hatch_boundary_path_polyline_set_number_of_vertices 06417 ( 06418 DxfHatchBoundaryPathPolyline *polyline, 06420 int number_of_vertices 06422 ) 06423 { 06424 #if DEBUG 06425 DXF_DEBUG_BEGIN 06426 #endif 06427 /* Do some basic checks. */ 06428 if (polyline == NULL) 06429 { 06430 fprintf (stderr, 06431 (_("Error in %s () a NULL pointer was passed.\n")), 06432 __FUNCTION__); 06433 return (NULL); 06434 } 06435 if (number_of_vertices < 0) 06436 { 06437 fprintf (stderr, 06438 (_("Error in %s () a negative value was passed.\n")), 06439 __FUNCTION__); 06440 return (NULL); 06441 } 06442 polyline->number_of_vertices = number_of_vertices; 06443 #if DEBUG 06444 DXF_DEBUG_END 06445 #endif 06446 return (polyline); 06447 } 06448 06449 06457 DxfHatchBoundaryPathPolylineVertex * 06458 dxf_hatch_boundary_path_polyline_get_vertices 06459 ( 06460 DxfHatchBoundaryPathPolyline *polyline 06463 ) 06464 { 06465 #if DEBUG 06466 DXF_DEBUG_BEGIN 06467 #endif 06468 DxfHatchBoundaryPathPolylineVertex *result; 06469 06470 /* Do some basic checks. */ 06471 if (polyline == NULL) 06472 { 06473 fprintf (stderr, 06474 (_("Error in %s () a NULL pointer was passed.\n")), 06475 __FUNCTION__); 06476 return (NULL); 06477 } 06478 result = (DxfHatchBoundaryPathPolylineVertex *) polyline->vertices; 06479 #if DEBUG 06480 DXF_DEBUG_END 06481 #endif 06482 return (result); 06483 } 06484 06485 06489 DxfHatchBoundaryPathPolyline * 06490 dxf_hatch_boundary_path_polyline_set_vertices 06491 ( 06492 DxfHatchBoundaryPathPolyline *polyline, 06494 DxfHatchBoundaryPathPolylineVertex *vertices 06496 ) 06497 { 06498 #if DEBUG 06499 DXF_DEBUG_BEGIN 06500 #endif 06501 /* Do some basic checks. */ 06502 if (polyline == NULL) 06503 { 06504 fprintf (stderr, 06505 (_("Error in %s () a NULL pointer was passed.\n")), 06506 __FUNCTION__); 06507 return (NULL); 06508 } 06509 if (vertices == NULL) 06510 { 06511 fprintf (stderr, 06512 (_("Error in %s () a NULL pointer was passed.\n")), 06513 __FUNCTION__); 06514 return (NULL); 06515 } 06516 polyline->vertices = (struct DxfHatchBoundaryPathPolylineVertex *) vertices; 06517 #if DEBUG 06518 DXF_DEBUG_END 06519 #endif 06520 return (polyline); 06521 } 06522 06523 06531 int 06532 dxf_hatch_boundary_path_polyline_close_polyline 06533 ( 06534 DxfHatchBoundaryPathPolyline *polyline 06536 ) 06537 { 06538 #if DEBUG 06539 DXF_DEBUG_BEGIN 06540 #endif 06541 /* Do some basic checks. */ 06542 if (polyline == NULL) 06543 { 06544 fprintf (stderr, 06545 (_("Error in %s () invalid pointer to polyline (NULL).\n")), 06546 __FUNCTION__); 06547 return (EXIT_FAILURE); 06548 } 06549 if (polyline->is_closed == 0) 06550 { 06551 /* iterate over all vertices until the last vertex, 06552 * append a new vertex with values of the first vertex, 06553 * and set the "is_closed" member to 1. */ 06554 DxfHatchBoundaryPathPolylineVertex *first; 06555 DxfHatchBoundaryPathPolylineVertex *iter; 06556 DxfHatchBoundaryPathPolylineVertex *next; 06557 first = dxf_hatch_boundary_path_polyline_vertex_new (); 06558 iter = dxf_hatch_boundary_path_polyline_vertex_new (); 06559 next = dxf_hatch_boundary_path_polyline_vertex_new (); 06560 first = (DxfHatchBoundaryPathPolylineVertex *) polyline->vertices; 06561 iter = first; 06562 for (;;) 06563 { 06564 if (iter->next == NULL) 06565 { 06566 next = (DxfHatchBoundaryPathPolylineVertex *) iter->next; 06567 break; 06568 } 06569 iter = (DxfHatchBoundaryPathPolylineVertex *) iter->next; 06570 } 06571 first = (DxfHatchBoundaryPathPolylineVertex *) polyline->vertices; 06574 next->id_code = iter->id_code + 1; 06575 next->x0 = first->x0; 06576 next->y0 = first->y0; 06577 next->next = NULL; 06578 iter->next = (struct DxfHatchBoundaryPathPolylineVertex *) next; 06579 polyline->is_closed = 1; 06580 } 06581 else 06582 { 06583 /* iterate over all vertices until the last vertex, 06584 * test if the values of the last are identical with the 06585 * first vertex, if not: append a vertex with values of 06586 * the first vertex. */ 06587 DxfHatchBoundaryPathPolylineVertex *first; 06588 DxfHatchBoundaryPathPolylineVertex *iter; 06589 DxfHatchBoundaryPathPolylineVertex *next; 06590 first = dxf_hatch_boundary_path_polyline_vertex_new (); 06591 iter = dxf_hatch_boundary_path_polyline_vertex_new (); 06592 next = dxf_hatch_boundary_path_polyline_vertex_new (); 06593 first = (DxfHatchBoundaryPathPolylineVertex *) polyline->vertices; 06594 iter = first; 06595 for (;;) 06596 { 06597 if (iter->next == NULL) 06598 { 06599 next = (DxfHatchBoundaryPathPolylineVertex *) iter->next; 06600 break; 06601 } 06602 iter = (DxfHatchBoundaryPathPolylineVertex *) iter->next; 06603 } 06604 first = (DxfHatchBoundaryPathPolylineVertex *) polyline->vertices; 06605 if (iter->x0 != first->x0 && iter->y0 != first->y0) 06606 { 06607 /* the first vertex coordinates are identical to 06608 * the last vertex coordinates: do nothing and 06609 * leave. */ 06610 } 06611 else 06612 { 06615 next->id_code = iter->id_code + 1; 06616 next->x0 = (double) first->x0; 06617 next->y0 = first->y0; 06618 next->next = NULL; 06619 iter->next = (struct DxfHatchBoundaryPathPolylineVertex *) next; 06620 } 06622 } 06623 #if DEBUG 06624 DXF_DEBUG_END 06625 #endif 06626 return (EXIT_SUCCESS); 06627 } 06628 06629 06659 int 06660 dxf_hatch_boundary_path_polyline_point_inside_polyline 06661 ( 06662 DxfHatchBoundaryPathPolyline *polyline, 06664 DxfPoint *point 06666 ) 06667 { 06668 #if DEBUG 06669 DXF_DEBUG_BEGIN 06670 #endif 06671 /* Do some basic checks. */ 06672 if (polyline == NULL) 06673 { 06674 fprintf (stderr, 06675 (_("Error in %s () invalid pointer to polyline (NULL).\n")), 06676 __FUNCTION__); 06677 return (EXIT_FAILURE); 06678 } 06679 if (point == NULL) 06680 { 06681 fprintf (stderr, 06682 (_("Error in %s () invalid pointer to point (NULL).\n")), 06683 __FUNCTION__); 06684 return (EXIT_FAILURE); 06685 } 06686 if (polyline->is_closed != 1) 06687 { 06688 fprintf (stderr, 06689 (_("Error in %s () polyline is not a closed polygon.\n")), 06690 __FUNCTION__); 06691 return (EXIT_FAILURE); 06692 } 06693 DxfHatchBoundaryPathPolylineVertex *p0; 06694 DxfHatchBoundaryPathPolylineVertex *p1; 06695 DxfHatchBoundaryPathPolylineVertex *iter; 06696 DxfHatchBoundaryPathPolylineVertex *next; 06697 double angle; 06698 p0 = dxf_hatch_boundary_path_polyline_vertex_new (); 06699 p1 = dxf_hatch_boundary_path_polyline_vertex_new (); 06700 iter = dxf_hatch_boundary_path_polyline_vertex_new (); 06701 next = dxf_hatch_boundary_path_polyline_vertex_new (); 06702 iter = (DxfHatchBoundaryPathPolylineVertex *) polyline->vertices; 06703 next = (DxfHatchBoundaryPathPolylineVertex *) iter->next; 06704 angle = 0; 06705 for (;;) 06706 { 06707 if (next == NULL) 06708 { 06709 /* iter is the last vertex, no use to continue. */ 06710 break; 06711 } 06712 next = (DxfHatchBoundaryPathPolylineVertex *) iter->next; 06713 p0->x0 = iter->x0 - point->x0; 06714 p0->y0 = iter->y0 - point->y0; 06715 p1->x0 = next->x0 - point->x0; 06716 p1->y0 = next->y0 - point->y0; 06717 angle += dxf_hatch_boundary_path_polyline_vertex_angle (iter, next); 06718 iter = next; 06719 } 06720 /* clean up. */ 06721 dxf_hatch_boundary_path_polyline_vertex_free (p0); 06722 dxf_hatch_boundary_path_polyline_vertex_free (p1); 06723 if (abs (angle) < M_PI) 06724 return (OUTSIDE); 06725 else 06726 return (INSIDE); 06727 #if DEBUG 06728 DXF_DEBUG_END 06729 #endif 06730 06731 return (EXIT_FAILURE); 06732 } 06733 06734 06743 DxfHatchBoundaryPathPolyline * 06744 dxf_hatch_boundary_path_polyline_get_next 06745 ( 06746 DxfHatchBoundaryPathPolyline *polyline 06748 ) 06749 { 06750 #if DEBUG 06751 DXF_DEBUG_BEGIN 06752 #endif 06753 DxfHatchBoundaryPathPolyline *result; 06754 06755 /* Do some basic checks. */ 06756 if (polyline == NULL) 06757 { 06758 fprintf (stderr, 06759 (_("Error in %s () a NULL pointer was passed.\n")), 06760 __FUNCTION__); 06761 return (NULL); 06762 } 06763 if (polyline->next == NULL) 06764 { 06765 fprintf (stderr, 06766 (_("Error in %s () a NULL pointer was found in the next member.\n")), 06767 __FUNCTION__); 06768 return (NULL); 06769 } 06770 result = (DxfHatchBoundaryPathPolyline *) polyline->next; 06771 #if DEBUG 06772 DXF_DEBUG_END 06773 #endif 06774 return (result); 06775 } 06776 06777 06782 DxfHatchBoundaryPathPolyline * 06783 dxf_hatch_boundary_path_polyline_set_next 06784 ( 06785 DxfHatchBoundaryPathPolyline *polyline, 06787 DxfHatchBoundaryPathPolyline *next 06790 ) 06791 { 06792 #if DEBUG 06793 DXF_DEBUG_BEGIN 06794 #endif 06795 /* Do some basic checks. */ 06796 if (polyline == NULL) 06797 { 06798 fprintf (stderr, 06799 (_("Error in %s () a NULL pointer was passed.\n")), 06800 __FUNCTION__); 06801 return (NULL); 06802 } 06803 if (next == NULL) 06804 { 06805 fprintf (stderr, 06806 (_("Error in %s () a NULL pointer was passed.\n")), 06807 __FUNCTION__); 06808 return (NULL); 06809 } 06810 polyline->next = (struct DxfHatchBoundaryPathPolyline *) next; 06811 #if DEBUG 06812 DXF_DEBUG_END 06813 #endif 06814 return (polyline); 06815 } 06816 06817 06826 DxfHatchBoundaryPathPolyline * 06827 dxf_hatch_boundary_path_polyline_get_last 06828 ( 06829 DxfHatchBoundaryPathPolyline *polyline 06831 ) 06832 { 06833 #if DEBUG 06834 DXF_DEBUG_BEGIN 06835 #endif 06836 /* Do some basic checks. */ 06837 if (polyline == NULL) 06838 { 06839 fprintf (stderr, 06840 (_("Error in %s () a NULL pointer was passed.\n")), 06841 __FUNCTION__); 06842 return (NULL); 06843 } 06844 if (polyline->next == NULL) 06845 { 06846 fprintf (stderr, 06847 (_("Warning in %s () a NULL pointer was found in the next member.\n")), 06848 __FUNCTION__); 06849 return ((DxfHatchBoundaryPathPolyline *) polyline); 06850 } 06851 DxfHatchBoundaryPathPolyline *iter = (DxfHatchBoundaryPathPolyline *) polyline->next; 06852 while (iter->next != NULL) 06853 { 06854 iter = (DxfHatchBoundaryPathPolyline *) iter->next; 06855 } 06856 #if DEBUG 06857 DXF_DEBUG_END 06858 #endif 06859 return ((DxfHatchBoundaryPathPolyline *) iter); 06860 } 06861 06862 06863 /* dxf_hatch_boundary_path_polyline_vertex functions. */ 06864 06871 DxfHatchBoundaryPathPolylineVertex * 06872 dxf_hatch_boundary_path_polyline_vertex_new () 06873 { 06874 #if DEBUG 06875 DXF_DEBUG_BEGIN 06876 #endif 06877 DxfHatchBoundaryPathPolylineVertex *vertex = NULL; 06878 size_t size; 06879 06880 size = sizeof (DxfHatchBoundaryPathPolylineVertex); 06881 /* avoid malloc of 0 bytes */ 06882 if (size == 0) size = 1; 06883 if ((vertex = malloc (size)) == NULL) 06884 { 06885 fprintf (stderr, 06886 (_("Error in %s () could not allocate memory for a DxfHatchBoundaryPathPolylineVertex struct.\n")), 06887 __FUNCTION__); 06888 vertex = NULL; 06889 } 06890 else 06891 { 06892 memset (vertex, 0, size); 06893 } 06894 #if DEBUG 06895 DXF_DEBUG_END 06896 #endif 06897 return (vertex); 06898 } 06899 06900 06908 DxfHatchBoundaryPathPolylineVertex * 06909 dxf_hatch_boundary_path_polyline_vertex_init 06910 ( 06911 DxfHatchBoundaryPathPolylineVertex *vertex 06913 ) 06914 { 06915 #if DEBUG 06916 DXF_DEBUG_BEGIN 06917 #endif 06918 /* Do some basic checks. */ 06919 if (vertex == NULL) 06920 { 06921 fprintf (stderr, 06922 (_("Warning in %s () a NULL pointer was passed.\n")), 06923 __FUNCTION__); 06924 vertex = dxf_hatch_boundary_path_polyline_vertex_new (); 06925 } 06926 if (vertex == NULL) 06927 { 06928 fprintf (stderr, 06929 (_("Error in %s () could not allocate memory for a DxfHatchBoundaryPathPolylineVertex struct.\n")), 06930 __FUNCTION__); 06931 return (NULL); 06932 } 06933 vertex->id_code = 0; 06934 vertex->x0 = 0.0; 06935 vertex->y0 = 0.0; 06936 vertex->bulge = 0.0; 06937 vertex->has_bulge = 0; 06938 vertex->next = NULL; 06939 #if DEBUG 06940 DXF_DEBUG_END 06941 #endif 06942 return (vertex); 06943 } 06944 06945 06950 int 06951 dxf_hatch_boundary_path_polyline_vertex_write 06952 ( 06953 DxfFile *fp, 06955 DxfHatchBoundaryPathPolylineVertex *vertex 06957 ) 06958 { 06959 #if DEBUG 06960 DXF_DEBUG_BEGIN 06961 #endif 06962 /* Do some basic checks. */ 06963 if (fp == NULL) 06964 { 06965 fprintf (stderr, 06966 (_("Error in %s () a NULL pointer was passed.\n")), 06967 __FUNCTION__); 06968 return (EXIT_FAILURE); 06969 } 06970 if (vertex == NULL) 06971 { 06972 fprintf (stderr, 06973 (_("Error in %s () a NULL pointer was passed.\n")), 06974 __FUNCTION__); 06975 return (EXIT_FAILURE); 06976 } 06977 fprintf (fp->fp, " 10\n%f\n", vertex->x0); 06978 fprintf (fp->fp, " 20\n%f\n", vertex->y0); 06979 fprintf (fp->fp, " 72\n%d\n", vertex->has_bulge); 06980 if (vertex->has_bulge) 06981 { 06982 fprintf (fp->fp, " 42\n%f\n", vertex->bulge); 06983 } 06984 #if DEBUG 06985 DXF_DEBUG_END 06986 #endif 06987 return (EXIT_SUCCESS); 06988 } 06989 06990 06998 int 06999 dxf_hatch_boundary_path_polyline_vertex_free 07000 ( 07001 DxfHatchBoundaryPathPolylineVertex *vertex 07004 ) 07005 { 07006 #if DEBUG 07007 DXF_DEBUG_BEGIN 07008 #endif 07009 /* Do some basic checks. */ 07010 if (vertex == NULL) 07011 { 07012 fprintf (stderr, 07013 (_("Error in %s () a NULL pointer was passed.\n")), 07014 __FUNCTION__); 07015 return (EXIT_FAILURE); 07016 } 07017 if (vertex->next != NULL) 07018 { 07019 fprintf (stderr, 07020 (_("Error in %s () pointer to next was not NULL.\n")), 07021 __FUNCTION__); 07022 return (EXIT_FAILURE); 07023 } 07024 free (vertex); 07025 vertex = NULL; 07026 #if DEBUG 07027 DXF_DEBUG_END 07028 #endif 07029 return (EXIT_SUCCESS); 07030 } 07031 07032 07037 void 07038 dxf_hatch_boundary_path_polyline_vertex_free_chain 07039 ( 07040 DxfHatchBoundaryPathPolylineVertex *hatch_boundary_path_polyline_vertices 07043 ) 07044 { 07045 #ifdef DEBUG 07046 DXF_DEBUG_BEGIN 07047 #endif 07048 /* Do some basic checks. */ 07049 if (hatch_boundary_path_polyline_vertices == NULL) 07050 { 07051 fprintf (stderr, 07052 (_("Warning in %s () a NULL pointer was passed.\n")), 07053 __FUNCTION__); 07054 } 07055 while (hatch_boundary_path_polyline_vertices != NULL) 07056 { 07057 struct DxfHatchBoundaryPathPolylineVertex *iter = hatch_boundary_path_polyline_vertices->next; 07058 dxf_hatch_boundary_path_polyline_vertex_free (hatch_boundary_path_polyline_vertices); 07059 hatch_boundary_path_polyline_vertices = (DxfHatchBoundaryPathPolylineVertex *) iter; 07060 } 07061 #if DEBUG 07062 DXF_DEBUG_END 07063 #endif 07064 } 07065 07066 07073 int 07074 dxf_hatch_boundary_path_polyline_vertex_get_id_code 07075 ( 07076 DxfHatchBoundaryPathPolylineVertex *vertex 07079 ) 07080 { 07081 #if DEBUG 07082 DXF_DEBUG_BEGIN 07083 #endif 07084 int result; 07085 07086 /* Do some basic checks. */ 07087 if (vertex == NULL) 07088 { 07089 fprintf (stderr, 07090 (_("Error in %s () a NULL pointer was passed.\n")), 07091 __FUNCTION__); 07092 return (EXIT_FAILURE); 07093 } 07094 if (vertex->id_code < 0) 07095 { 07096 fprintf (stderr, 07097 (_("Error in %s () a negative value was found in the id_code member.\n")), 07098 __FUNCTION__); 07099 return (EXIT_FAILURE); 07100 } 07101 result = vertex->id_code; 07102 #if DEBUG 07103 DXF_DEBUG_END 07104 #endif 07105 return (result); 07106 } 07107 07108 07113 DxfHatchBoundaryPathPolylineVertex * 07114 dxf_hatch_boundary_path_polyline_vertex_set_id_code 07115 ( 07116 DxfHatchBoundaryPathPolylineVertex *vertex, 07119 int id_code 07123 ) 07124 { 07125 #if DEBUG 07126 DXF_DEBUG_BEGIN 07127 #endif 07128 /* Do some basic checks. */ 07129 if (vertex == NULL) 07130 { 07131 fprintf (stderr, 07132 (_("Error in %s () a NULL pointer was passed.\n")), 07133 __FUNCTION__); 07134 return (NULL); 07135 } 07136 if (id_code < 0) 07137 { 07138 fprintf (stderr, 07139 (_("Error in %s () a negative id-code value was passed.\n")), 07140 __FUNCTION__); 07141 return (NULL); 07142 } 07143 vertex->id_code = id_code; 07144 #if DEBUG 07145 DXF_DEBUG_END 07146 #endif 07147 return (vertex); 07148 } 07149 07150 07157 double 07158 dxf_hatch_boundary_path_polyline_vertex_get_x0 07159 ( 07160 DxfHatchBoundaryPathPolylineVertex *vertex 07163 ) 07164 { 07165 #if DEBUG 07166 DXF_DEBUG_BEGIN 07167 #endif 07168 double result; 07169 07170 /* Do some basic checks. */ 07171 if (vertex == NULL) 07172 { 07173 fprintf (stderr, 07174 (_("Error in %s () a NULL pointer was passed.\n")), 07175 __FUNCTION__); 07176 return (EXIT_FAILURE); 07177 } 07178 result = vertex->x0; 07179 #if DEBUG 07180 DXF_DEBUG_END 07181 #endif 07182 return (result); 07183 } 07184 07185 07190 DxfHatchBoundaryPathPolylineVertex * 07191 dxf_hatch_boundary_path_polyline_vertex_set_x0 07192 ( 07193 DxfHatchBoundaryPathPolylineVertex *vertex, 07196 double x0 07199 ) 07200 { 07201 #if DEBUG 07202 DXF_DEBUG_BEGIN 07203 #endif 07204 /* Do some basic checks. */ 07205 if (vertex == NULL) 07206 { 07207 fprintf (stderr, 07208 (_("Error in %s () a NULL pointer was passed.\n")), 07209 __FUNCTION__); 07210 return (NULL); 07211 } 07212 vertex->x0 = x0; 07213 #if DEBUG 07214 DXF_DEBUG_END 07215 #endif 07216 return (vertex); 07217 } 07218 07219 07226 double 07227 dxf_hatch_boundary_path_polyline_vertex_get_y0 07228 ( 07229 DxfHatchBoundaryPathPolylineVertex *vertex 07232 ) 07233 { 07234 #if DEBUG 07235 DXF_DEBUG_BEGIN 07236 #endif 07237 double result; 07238 07239 /* Do some basic checks. */ 07240 if (vertex == NULL) 07241 { 07242 fprintf (stderr, 07243 (_("Error in %s () a NULL pointer was passed.\n")), 07244 __FUNCTION__); 07245 return (EXIT_FAILURE); 07246 } 07247 result = vertex->y0; 07248 #if DEBUG 07249 DXF_DEBUG_END 07250 #endif 07251 return (result); 07252 } 07253 07254 07259 DxfHatchBoundaryPathPolylineVertex * 07260 dxf_hatch_boundary_path_polyline_vertex_set_y0 07261 ( 07262 DxfHatchBoundaryPathPolylineVertex *vertex, 07265 double y0 07268 ) 07269 { 07270 #if DEBUG 07271 DXF_DEBUG_BEGIN 07272 #endif 07273 /* Do some basic checks. */ 07274 if (vertex == NULL) 07275 { 07276 fprintf (stderr, 07277 (_("Error in %s () a NULL pointer was passed.\n")), 07278 __FUNCTION__); 07279 return (NULL); 07280 } 07281 vertex->y0 = y0; 07282 #if DEBUG 07283 DXF_DEBUG_END 07284 #endif 07285 return (vertex); 07286 } 07287 07288 07295 double 07296 dxf_hatch_boundary_path_polyline_vertex_get_bulge 07297 ( 07298 DxfHatchBoundaryPathPolylineVertex *vertex 07301 ) 07302 { 07303 #if DEBUG 07304 DXF_DEBUG_BEGIN 07305 #endif 07306 double result; 07307 07308 /* Do some basic checks. */ 07309 if (vertex == NULL) 07310 { 07311 fprintf (stderr, 07312 (_("Error in %s () a NULL pointer was passed.\n")), 07313 __FUNCTION__); 07314 return (EXIT_FAILURE); 07315 } 07316 result = vertex->bulge; 07317 #if DEBUG 07318 DXF_DEBUG_END 07319 #endif 07320 return (result); 07321 } 07322 07323 07328 DxfHatchBoundaryPathPolylineVertex * 07329 dxf_hatch_boundary_path_polyline_vertex_set_bulge 07330 ( 07331 DxfHatchBoundaryPathPolylineVertex *vertex, 07334 double bulge 07336 ) 07337 { 07338 #if DEBUG 07339 DXF_DEBUG_BEGIN 07340 #endif 07341 /* Do some basic checks. */ 07342 if (vertex == NULL) 07343 { 07344 fprintf (stderr, 07345 (_("Error in %s () a NULL pointer was passed.\n")), 07346 __FUNCTION__); 07347 return (NULL); 07348 } 07349 vertex->bulge = bulge; 07350 #if DEBUG 07351 DXF_DEBUG_END 07352 #endif 07353 return (vertex); 07354 } 07355 07356 07363 int 07364 dxf_hatch_boundary_path_polyline_vertex_get_has_bulge 07365 ( 07366 DxfHatchBoundaryPathPolylineVertex *vertex 07369 ) 07370 { 07371 #if DEBUG 07372 DXF_DEBUG_BEGIN 07373 #endif 07374 int result; 07375 07376 /* Do some basic checks. */ 07377 if (vertex == NULL) 07378 { 07379 fprintf (stderr, 07380 (_("Error in %s () a NULL pointer was passed.\n")), 07381 __FUNCTION__); 07382 return (EXIT_FAILURE); 07383 } 07384 if (vertex->has_bulge < 0) 07385 { 07386 fprintf (stderr, 07387 (_("Error in %s () a negative value was found in the has_bulge member.\n")), 07388 __FUNCTION__); 07389 return (EXIT_FAILURE); 07390 } 07391 if (vertex->has_bulge > 1) 07392 { 07393 fprintf (stderr, 07394 (_("Error in %s () an out of range value was found in the has_bulge member.\n")), 07395 __FUNCTION__); 07396 return (EXIT_FAILURE); 07397 } 07398 result = vertex->has_bulge; 07399 #if DEBUG 07400 DXF_DEBUG_END 07401 #endif 07402 return (result); 07403 } 07404 07405 07410 DxfHatchBoundaryPathPolylineVertex * 07411 dxf_hatch_boundary_path_polyline_vertex_set_has_bulge 07412 ( 07413 DxfHatchBoundaryPathPolylineVertex *vertex, 07416 int has_bulge 07418 ) 07419 { 07420 #if DEBUG 07421 DXF_DEBUG_BEGIN 07422 #endif 07423 /* Do some basic checks. */ 07424 if (vertex == NULL) 07425 { 07426 fprintf (stderr, 07427 (_("Error in %s () a NULL pointer was passed.\n")), 07428 __FUNCTION__); 07429 return (NULL); 07430 } 07431 if (has_bulge < 0) 07432 { 07433 fprintf (stderr, 07434 (_("Error in %s () a negative has_bulge flag value was passed.\n")), 07435 __FUNCTION__); 07436 return (NULL); 07437 } 07438 if (has_bulge > 1) 07439 { 07440 fprintf (stderr, 07441 (_("Error in %s () an out of range has_bulge flag value was passed.\n")), 07442 __FUNCTION__); 07443 return (NULL); 07444 } 07445 vertex->has_bulge = has_bulge; 07446 #if DEBUG 07447 DXF_DEBUG_END 07448 #endif 07449 return (vertex); 07450 } 07451 07452 07462 double 07463 dxf_hatch_boundary_path_polyline_vertex_angle 07464 ( 07465 DxfHatchBoundaryPathPolylineVertex *vertex_0, 07467 DxfHatchBoundaryPathPolylineVertex *vertex_1 07469 ) 07470 { 07471 #if DEBUG 07472 DXF_DEBUG_BEGIN 07473 #endif 07474 double x0; 07475 double y0; 07476 double x1; 07477 double y1; 07478 double dtheta; 07479 double theta0; 07480 double theta1; 07481 07482 /* Do some basic checks. */ 07483 if (vertex_0 == NULL) 07484 { 07485 fprintf (stderr, 07486 (_("Error in %s () a NULL pointer was passed.\n")), 07487 __FUNCTION__); 07488 return (EXIT_FAILURE); 07489 } 07490 if (vertex_1 == NULL) 07491 { 07492 fprintf (stderr, 07493 (_("Error in %s () a NULL pointer was passed.\n")), 07494 __FUNCTION__); 07495 return (EXIT_FAILURE); 07496 } 07497 if ((vertex_0->x0 == vertex_1->x0) 07498 && (vertex_0->y0 == vertex_1->y0)) 07499 { 07500 fprintf (stderr, 07501 (_("Error in %s () identical coordinates were passed.\n")), 07502 __FUNCTION__); 07503 return (EXIT_FAILURE); 07504 } 07505 x0 = vertex_0->x0; 07506 y0 = vertex_0->y0; 07507 x1 = vertex_1->x0; 07508 y1 = vertex_1->y0; 07509 theta0 = atan2 (y0, x0); 07510 theta1 = atan2 (y1, x1); 07511 dtheta = theta1 - theta0; 07512 while (dtheta > M_PI) 07513 dtheta -= 2 * M_PI; 07514 while (dtheta < -M_PI) 07515 dtheta += 2 * M_PI; 07516 #if DEBUG 07517 DXF_DEBUG_END 07518 #endif 07519 return (dtheta); 07520 } 07521 07522 07531 DxfHatchBoundaryPathPolylineVertex * 07532 dxf_hatch_boundary_path_polyline_vertex_get_next 07533 ( 07534 DxfHatchBoundaryPathPolylineVertex *vertex 07537 ) 07538 { 07539 #if DEBUG 07540 DXF_DEBUG_BEGIN 07541 #endif 07542 DxfHatchBoundaryPathPolylineVertex *result; 07543 07544 /* Do some basic checks. */ 07545 if (vertex == NULL) 07546 { 07547 fprintf (stderr, 07548 (_("Error in %s () a NULL pointer was passed.\n")), 07549 __FUNCTION__); 07550 return (NULL); 07551 } 07552 if (vertex->next == NULL) 07553 { 07554 fprintf (stderr, 07555 (_("Error in %s () a NULL pointer was found in the next member.\n")), 07556 __FUNCTION__); 07557 return (NULL); 07558 } 07559 result = (DxfHatchBoundaryPathPolylineVertex *) vertex->next; 07560 #if DEBUG 07561 DXF_DEBUG_END 07562 #endif 07563 return (result); 07564 } 07565 07566 07571 DxfHatchBoundaryPathPolylineVertex * 07572 dxf_hatch_boundary_path_polyline_vertex_set_next 07573 ( 07574 DxfHatchBoundaryPathPolylineVertex *vertex, 07577 DxfHatchBoundaryPathPolylineVertex *next 07580 ) 07581 { 07582 #if DEBUG 07583 DXF_DEBUG_BEGIN 07584 #endif 07585 /* Do some basic checks. */ 07586 if (vertex == NULL) 07587 { 07588 fprintf (stderr, 07589 (_("Error in %s () a NULL pointer was passed.\n")), 07590 __FUNCTION__); 07591 return (NULL); 07592 } 07593 if (next == NULL) 07594 { 07595 fprintf (stderr, 07596 (_("Error in %s () a NULL pointer was passed.\n")), 07597 __FUNCTION__); 07598 return (NULL); 07599 } 07600 vertex->next = (struct DxfHatchBoundaryPathPolylineVertex *) next; 07601 #if DEBUG 07602 DXF_DEBUG_END 07603 #endif 07604 return (vertex); 07605 } 07606 07607 07617 DxfHatchBoundaryPathPolylineVertex * 07618 dxf_hatch_boundary_path_polyline_vertex_get_last 07619 ( 07620 DxfHatchBoundaryPathPolylineVertex *vertex 07623 ) 07624 { 07625 #if DEBUG 07626 DXF_DEBUG_BEGIN 07627 #endif 07628 /* Do some basic checks. */ 07629 if (vertex == NULL) 07630 { 07631 fprintf (stderr, 07632 (_("Error in %s () a NULL pointer was passed.\n")), 07633 __FUNCTION__); 07634 return (NULL); 07635 } 07636 if (vertex->next == NULL) 07637 { 07638 fprintf (stderr, 07639 (_("Warning in %s () a NULL pointer was found in the next member.\n")), 07640 __FUNCTION__); 07641 return ((DxfHatchBoundaryPathPolylineVertex *) vertex); 07642 } 07643 DxfHatchBoundaryPathPolylineVertex *iter = (DxfHatchBoundaryPathPolylineVertex *) vertex->next; 07644 while (iter->next != NULL) 07645 { 07646 iter = (DxfHatchBoundaryPathPolylineVertex *) iter->next; 07647 } 07648 #if DEBUG 07649 DXF_DEBUG_END 07650 #endif 07651 return ((DxfHatchBoundaryPathPolylineVertex *) iter); 07652 } 07653 07654 07655 /* dxf_hatch_boundary_path_edge functions. */ 07656 07662 DxfHatchBoundaryPathEdge * 07663 dxf_hatch_boundary_path_edge_new () 07664 { 07665 #if DEBUG 07666 DXF_DEBUG_BEGIN 07667 #endif 07668 DxfHatchBoundaryPathEdge *edge = NULL; 07669 size_t size; 07670 07671 size = sizeof (DxfHatchBoundaryPathEdge); 07672 /* avoid malloc of 0 bytes */ 07673 if (size == 0) size = 1; 07674 if ((edge = malloc (size)) == NULL) 07675 { 07676 fprintf (stderr, 07677 (_("Error in %s () could not allocate memory for a DxfHatchBoundaryPathEdge struct.\n")), 07678 __FUNCTION__); 07679 edge = NULL; 07680 } 07681 else 07682 { 07683 memset (edge, 0, size); 07684 } 07685 #if DEBUG 07686 DXF_DEBUG_END 07687 #endif 07688 return (edge); 07689 } 07690 07691 07699 DxfHatchBoundaryPathEdge * 07700 dxf_hatch_boundary_path_edge_init 07701 ( 07702 DxfHatchBoundaryPathEdge *edge 07704 ) 07705 { 07706 #if DEBUG 07707 DXF_DEBUG_BEGIN 07708 #endif 07709 /* Do some basic checks. */ 07710 if (edge == NULL) 07711 { 07712 fprintf (stderr, 07713 (_("Warning in %s () a NULL pointer was passed.\n")), 07714 __FUNCTION__); 07715 edge = dxf_hatch_boundary_path_edge_new (); 07716 } 07717 if (edge == NULL) 07718 { 07719 fprintf (stderr, 07720 (_("Error in %s () could not allocate memory for a DxfHatchBoundaryPathEdge struct.\n")), 07721 __FUNCTION__); 07722 return (NULL); 07723 } 07724 edge->id_code = 0; 07725 edge->arcs = NULL; 07726 edge->ellipses = NULL; 07727 edge->lines = NULL; 07728 edge->splines = NULL; 07729 edge->next = NULL; 07730 #if DEBUG 07731 DXF_DEBUG_END 07732 #endif 07733 return (edge); 07734 } 07735 07736 07744 int 07745 dxf_hatch_boundary_path_edge_free 07746 ( 07747 DxfHatchBoundaryPathEdge *edge 07750 ) 07751 { 07752 #if DEBUG 07753 DXF_DEBUG_BEGIN 07754 #endif 07755 /* Do some basic checks. */ 07756 if (edge == NULL) 07757 { 07758 fprintf (stderr, 07759 (_("Error in %s () a NULL pointer was passed.\n")), 07760 __FUNCTION__); 07761 return (EXIT_FAILURE); 07762 } 07763 if (edge->next != NULL) 07764 { 07765 fprintf (stderr, 07766 (_("Error in %s () pointer to next was not NULL.\n")), 07767 __FUNCTION__); 07768 return (EXIT_FAILURE); 07769 } 07770 free (edge->arcs); 07771 free (edge->ellipses); 07772 free (edge->lines); 07773 free (edge->splines); 07774 free (edge); 07775 edge = NULL; 07776 #if DEBUG 07777 DXF_DEBUG_END 07778 #endif 07779 return (EXIT_SUCCESS); 07780 } 07781 07782 07787 void 07788 dxf_hatch_boundary_path_edge_free_chain 07789 ( 07790 DxfHatchBoundaryPathEdge *edges 07793 ) 07794 { 07795 #ifdef DEBUG 07796 DXF_DEBUG_BEGIN 07797 #endif 07798 /* Do some basic checks. */ 07799 if (edges == NULL) 07800 { 07801 fprintf (stderr, 07802 (_("Warning in %s () a NULL pointer was passed.\n")), 07803 __FUNCTION__); 07804 } 07805 while (edges != NULL) 07806 { 07807 struct DxfHatchBoundaryPathEdge *iter = edges->next; 07808 dxf_hatch_boundary_path_edge_free (edges); 07809 edges = (DxfHatchBoundaryPathEdge *) iter; 07810 } 07811 #if DEBUG 07812 DXF_DEBUG_END 07813 #endif 07814 } 07815 07816 07822 int 07823 dxf_hatch_boundary_path_edge_get_id_code 07824 ( 07825 DxfHatchBoundaryPathEdge *edge 07827 ) 07828 { 07829 #if DEBUG 07830 DXF_DEBUG_BEGIN 07831 #endif 07832 int result; 07833 07834 /* Do some basic checks. */ 07835 if (edge == NULL) 07836 { 07837 fprintf (stderr, 07838 (_("Error in %s () a NULL pointer was passed.\n")), 07839 __FUNCTION__); 07840 return (EXIT_FAILURE); 07841 } 07842 if (edge->id_code < 0) 07843 { 07844 fprintf (stderr, 07845 (_("Error in %s () a negative value was found in the id_code member.\n")), 07846 __FUNCTION__); 07847 return (EXIT_FAILURE); 07848 } 07849 result = edge->id_code; 07850 #if DEBUG 07851 DXF_DEBUG_END 07852 #endif 07853 return (result); 07854 } 07855 07856 07860 DxfHatchBoundaryPathEdge * 07861 dxf_hatch_boundary_path_edge_set_id_code 07862 ( 07863 DxfHatchBoundaryPathEdge *edge, 07865 int id_code 07869 ) 07870 { 07871 #if DEBUG 07872 DXF_DEBUG_BEGIN 07873 #endif 07874 /* Do some basic checks. */ 07875 if (edge == NULL) 07876 { 07877 fprintf (stderr, 07878 (_("Error in %s () a NULL pointer was passed.\n")), 07879 __FUNCTION__); 07880 return (NULL); 07881 } 07882 if (id_code < 0) 07883 { 07884 fprintf (stderr, 07885 (_("Error in %s () a negative id-code value was passed.\n")), 07886 __FUNCTION__); 07887 return (NULL); 07888 } 07889 edge->id_code = id_code; 07890 #if DEBUG 07891 DXF_DEBUG_END 07892 #endif 07893 return (edge); 07894 } 07895 07896 07903 DxfHatchBoundaryPathEdgeArc * 07904 dxf_hatch_boundary_path_edge_get_arcs 07905 ( 07906 DxfHatchBoundaryPathEdge *edge 07908 ) 07909 { 07910 #if DEBUG 07911 DXF_DEBUG_BEGIN 07912 #endif 07913 DxfHatchBoundaryPathEdgeArc *result = NULL; 07914 07915 /* Do some basic checks. */ 07916 if (edge == NULL) 07917 { 07918 fprintf (stderr, 07919 (_("Error in %s () a NULL pointer was passed.\n")), 07920 __FUNCTION__); 07921 return (NULL); 07922 } 07923 if (edge->arcs == NULL) 07924 { 07925 fprintf (stderr, 07926 (_("Error in %s () a NULL pointer was passed.\n")), 07927 __FUNCTION__); 07928 return (NULL); 07929 } 07930 dxf_hatch_boundary_path_edge_arc_new (result); 07931 if (result == NULL) 07932 { 07933 fprintf (stderr, 07934 (_("Error in %s () can not allocate memory for a DxfHatchBoundaryPathEdgeArc struct.\n")), 07935 __FUNCTION__); 07936 return (NULL); 07937 } 07938 result = (DxfHatchBoundaryPathEdgeArc *) edge->arcs; 07939 #if DEBUG 07940 DXF_DEBUG_END 07941 #endif 07942 return (result); 07943 } 07944 07945 07950 DxfHatchBoundaryPathEdge * 07951 dxf_hatch_boundary_path_edge_set_arcs 07952 ( 07953 DxfHatchBoundaryPathEdge *edge, 07955 DxfHatchBoundaryPathEdgeArc *arcs 07958 ) 07959 { 07960 #if DEBUG 07961 DXF_DEBUG_BEGIN 07962 #endif 07963 /* Do some basic checks. */ 07964 if (edge == NULL) 07965 { 07966 fprintf (stderr, 07967 (_("Error in %s () a NULL pointer was passed.\n")), 07968 __FUNCTION__); 07969 return (NULL); 07970 } 07971 if (arcs == NULL) 07972 { 07973 fprintf (stderr, 07974 (_("Error in %s () a NULL pointer was passed.\n")), 07975 __FUNCTION__); 07976 return (NULL); 07977 } 07978 edge->arcs = (struct DxfHatchBoundaryPathEdgeArc *) arcs; 07979 #if DEBUG 07980 DXF_DEBUG_END 07981 #endif 07982 return (edge); 07983 } 07984 07985 07992 DxfHatchBoundaryPathEdgeEllipse * 07993 dxf_hatch_boundary_path_edge_get_ellipses 07994 ( 07995 DxfHatchBoundaryPathEdge *edge 07997 ) 07998 { 07999 #if DEBUG 08000 DXF_DEBUG_BEGIN 08001 #endif 08002 DxfHatchBoundaryPathEdgeEllipse *result = NULL; 08003 08004 /* Do some basic checks. */ 08005 if (edge == NULL) 08006 { 08007 fprintf (stderr, 08008 (_("Error in %s () a NULL pointer was passed.\n")), 08009 __FUNCTION__); 08010 return (NULL); 08011 } 08012 if (edge->ellipses == NULL) 08013 { 08014 fprintf (stderr, 08015 (_("Error in %s () a NULL pointer was passed.\n")), 08016 __FUNCTION__); 08017 return (NULL); 08018 } 08019 dxf_hatch_boundary_path_edge_ellipse_new (result); 08020 if (result == NULL) 08021 { 08022 fprintf (stderr, 08023 (_("Error in %s () can not allocate memory for a DxfHatchBoundaryPathEdgeEllipse struct.\n")), 08024 __FUNCTION__); 08025 return (NULL); 08026 } 08027 result = (DxfHatchBoundaryPathEdgeEllipse *) edge->ellipses; 08028 #if DEBUG 08029 DXF_DEBUG_END 08030 #endif 08031 return (result); 08032 } 08033 08034 08039 DxfHatchBoundaryPathEdge * 08040 dxf_hatch_boundary_path_edge_set_ellipses 08041 ( 08042 DxfHatchBoundaryPathEdge *edge, 08044 DxfHatchBoundaryPathEdgeEllipse *ellipses 08047 ) 08048 { 08049 #if DEBUG 08050 DXF_DEBUG_BEGIN 08051 #endif 08052 /* Do some basic checks. */ 08053 if (edge == NULL) 08054 { 08055 fprintf (stderr, 08056 (_("Error in %s () a NULL pointer was passed.\n")), 08057 __FUNCTION__); 08058 return (NULL); 08059 } 08060 if (ellipses == NULL) 08061 { 08062 fprintf (stderr, 08063 (_("Error in %s () a NULL pointer was passed.\n")), 08064 __FUNCTION__); 08065 return (NULL); 08066 } 08067 edge->ellipses = (struct DxfHatchBoundaryPathEdgeEllipse *) ellipses; 08068 #if DEBUG 08069 DXF_DEBUG_END 08070 #endif 08071 return (edge); 08072 } 08073 08074 08081 DxfHatchBoundaryPathEdgeLine * 08082 dxf_hatch_boundary_path_edge_get_lines 08083 ( 08084 DxfHatchBoundaryPathEdge *edge 08086 ) 08087 { 08088 #if DEBUG 08089 DXF_DEBUG_BEGIN 08090 #endif 08091 DxfHatchBoundaryPathEdgeLine *result = NULL; 08092 08093 /* Do some basic checks. */ 08094 if (edge == NULL) 08095 { 08096 fprintf (stderr, 08097 (_("Error in %s () a NULL pointer was passed.\n")), 08098 __FUNCTION__); 08099 return (NULL); 08100 } 08101 if (edge->lines == NULL) 08102 { 08103 fprintf (stderr, 08104 (_("Error in %s () a NULL pointer was passed.\n")), 08105 __FUNCTION__); 08106 return (NULL); 08107 } 08108 dxf_hatch_boundary_path_edge_line_new (result); 08109 if (result == NULL) 08110 { 08111 fprintf (stderr, 08112 (_("Error in %s () can not allocate memory for a DxfHatchBoundaryPathEdgeLine struct.\n")), 08113 __FUNCTION__); 08114 return (NULL); 08115 } 08116 result = (DxfHatchBoundaryPathEdgeLine *) edge->lines; 08117 #if DEBUG 08118 DXF_DEBUG_END 08119 #endif 08120 return (result); 08121 } 08122 08123 08128 DxfHatchBoundaryPathEdge * 08129 dxf_hatch_boundary_path_edge_set_lines 08130 ( 08131 DxfHatchBoundaryPathEdge *edge, 08133 DxfHatchBoundaryPathEdgeLine *lines 08136 ) 08137 { 08138 #if DEBUG 08139 DXF_DEBUG_BEGIN 08140 #endif 08141 /* Do some basic checks. */ 08142 if (edge == NULL) 08143 { 08144 fprintf (stderr, 08145 (_("Error in %s () a NULL pointer was passed.\n")), 08146 __FUNCTION__); 08147 return (NULL); 08148 } 08149 if (lines == NULL) 08150 { 08151 fprintf (stderr, 08152 (_("Error in %s () a NULL pointer was passed.\n")), 08153 __FUNCTION__); 08154 return (NULL); 08155 } 08156 edge->lines = (struct DxfHatchBoundaryPathEdgeLine *) lines; 08157 #if DEBUG 08158 DXF_DEBUG_END 08159 #endif 08160 return (edge); 08161 } 08162 08163 08170 DxfHatchBoundaryPathEdgeSpline * 08171 dxf_hatch_boundary_path_edge_get_splines 08172 ( 08173 DxfHatchBoundaryPathEdge *edge 08175 ) 08176 { 08177 #if DEBUG 08178 DXF_DEBUG_BEGIN 08179 #endif 08180 DxfHatchBoundaryPathEdgeSpline *result = NULL; 08181 08182 /* Do some basic checks. */ 08183 if (edge == NULL) 08184 { 08185 fprintf (stderr, 08186 (_("Error in %s () a NULL pointer was passed.\n")), 08187 __FUNCTION__); 08188 return (NULL); 08189 } 08190 if (edge->splines == NULL) 08191 { 08192 fprintf (stderr, 08193 (_("Error in %s () a NULL pointer was passed.\n")), 08194 __FUNCTION__); 08195 return (NULL); 08196 } 08197 dxf_hatch_boundary_path_edge_spline_new (result); 08198 if (result == NULL) 08199 { 08200 fprintf (stderr, 08201 (_("Error in %s () can not allocate memory for a DxfHatchBoundaryPathEdgeSpline struct.\n")), 08202 __FUNCTION__); 08203 return (NULL); 08204 } 08205 result = (DxfHatchBoundaryPathEdgeSpline *) edge->splines; 08206 #if DEBUG 08207 DXF_DEBUG_END 08208 #endif 08209 return (result); 08210 } 08211 08212 08217 DxfHatchBoundaryPathEdge * 08218 dxf_hatch_boundary_path_edge_set_splines 08219 ( 08220 DxfHatchBoundaryPathEdge *edge, 08222 DxfHatchBoundaryPathEdgeSpline *splines 08225 ) 08226 { 08227 #if DEBUG 08228 DXF_DEBUG_BEGIN 08229 #endif 08230 /* Do some basic checks. */ 08231 if (edge == NULL) 08232 { 08233 fprintf (stderr, 08234 (_("Error in %s () a NULL pointer was passed.\n")), 08235 __FUNCTION__); 08236 return (NULL); 08237 } 08238 if (splines == NULL) 08239 { 08240 fprintf (stderr, 08241 (_("Error in %s () a NULL pointer was passed.\n")), 08242 __FUNCTION__); 08243 return (NULL); 08244 } 08245 edge->splines = (struct DxfHatchBoundaryPathEdgeSpline *) splines; 08246 #if DEBUG 08247 DXF_DEBUG_END 08248 #endif 08249 return (edge); 08250 } 08251 08252 08261 DxfHatchBoundaryPathEdge * 08262 dxf_hatch_boundary_path_edge_get_next 08263 ( 08264 DxfHatchBoundaryPathEdge *edge 08266 ) 08267 { 08268 #if DEBUG 08269 DXF_DEBUG_BEGIN 08270 #endif 08271 DxfHatchBoundaryPathEdge *result; 08272 08273 /* Do some basic checks. */ 08274 if (edge == NULL) 08275 { 08276 fprintf (stderr, 08277 (_("Error in %s () a NULL pointer was passed.\n")), 08278 __FUNCTION__); 08279 return (NULL); 08280 } 08281 if (edge->next == NULL) 08282 { 08283 fprintf (stderr, 08284 (_("Error in %s () a NULL pointer was found in the next member.\n")), 08285 __FUNCTION__); 08286 return (NULL); 08287 } 08288 result = (DxfHatchBoundaryPathEdge *) edge->next; 08289 #if DEBUG 08290 DXF_DEBUG_END 08291 #endif 08292 return (result); 08293 } 08294 08295 08300 DxfHatchBoundaryPathEdge * 08301 dxf_hatch_boundary_path_edge_set_next 08302 ( 08303 DxfHatchBoundaryPathEdge *edge, 08305 DxfHatchBoundaryPathEdge *next 08308 ) 08309 { 08310 #if DEBUG 08311 DXF_DEBUG_BEGIN 08312 #endif 08313 /* Do some basic checks. */ 08314 if (edge == NULL) 08315 { 08316 fprintf (stderr, 08317 (_("Error in %s () a NULL pointer was passed.\n")), 08318 __FUNCTION__); 08319 return (NULL); 08320 } 08321 if (next == NULL) 08322 { 08323 fprintf (stderr, 08324 (_("Error in %s () a NULL pointer was passed.\n")), 08325 __FUNCTION__); 08326 return (NULL); 08327 } 08328 edge->next = (struct DxfHatchBoundaryPathEdge *) next; 08329 #if DEBUG 08330 DXF_DEBUG_END 08331 #endif 08332 return (edge); 08333 } 08334 08335 08344 DxfHatchBoundaryPathEdge * 08345 dxf_hatch_boundary_path_edge_get_last 08346 ( 08347 DxfHatchBoundaryPathEdge *edge 08349 ) 08350 { 08351 #if DEBUG 08352 DXF_DEBUG_BEGIN 08353 #endif 08354 /* Do some basic checks. */ 08355 if (edge == NULL) 08356 { 08357 fprintf (stderr, 08358 (_("Error in %s () a NULL pointer was passed.\n")), 08359 __FUNCTION__); 08360 return (NULL); 08361 } 08362 if (edge->next == NULL) 08363 { 08364 fprintf (stderr, 08365 (_("Warning in %s () a NULL pointer was found in the next member.\n")), 08366 __FUNCTION__); 08367 return ((DxfHatchBoundaryPathEdge *) edge); 08368 } 08369 DxfHatchBoundaryPathEdge *iter = (DxfHatchBoundaryPathEdge *) edge->next; 08370 while (iter->next != NULL) 08371 { 08372 iter = (DxfHatchBoundaryPathEdge *) iter->next; 08373 } 08374 #if DEBUG 08375 DXF_DEBUG_END 08376 #endif 08377 return ((DxfHatchBoundaryPathEdge *) iter); 08378 } 08379 08380 08381 /* dxf_hatch_boundary_path_edge_arc functions. */ 08382 08388 DxfHatchBoundaryPathEdgeArc * 08389 dxf_hatch_boundary_path_edge_arc_new () 08390 { 08391 #if DEBUG 08392 DXF_DEBUG_BEGIN 08393 #endif 08394 DxfHatchBoundaryPathEdgeArc *arc = NULL; 08395 size_t size; 08396 08397 size = sizeof (DxfHatchBoundaryPathEdgeArc); 08398 /* avoid malloc of 0 bytes */ 08399 if (size == 0) size = 1; 08400 if ((arc = malloc (size)) == NULL) 08401 { 08402 fprintf (stderr, 08403 (_("Error in %s () could not allocate memory for a DxfHatchBoundaryPathEdgeArc struct.\n")), 08404 __FUNCTION__); 08405 arc = NULL; 08406 } 08407 else 08408 { 08409 memset (arc, 0, size); 08410 } 08411 #if DEBUG 08412 DXF_DEBUG_END 08413 #endif 08414 return (arc); 08415 } 08416 08417 08425 DxfHatchBoundaryPathEdgeArc * 08426 dxf_hatch_boundary_path_edge_arc_init 08427 ( 08428 DxfHatchBoundaryPathEdgeArc *arc 08430 ) 08431 { 08432 #if DEBUG 08433 DXF_DEBUG_BEGIN 08434 #endif 08435 /* Do some basic checks. */ 08436 if (arc == NULL) 08437 { 08438 fprintf (stderr, 08439 (_("Warning in %s () a NULL pointer was passed.\n")), 08440 __FUNCTION__); 08441 arc = dxf_hatch_boundary_path_edge_arc_new (); 08442 } 08443 if (arc == NULL) 08444 { 08445 fprintf (stderr, 08446 (_("Error in %s () could not allocate memory for a DxfHatchBoundaryPathEdgeArc struct.\n")), 08447 __FUNCTION__); 08448 return (NULL); 08449 } 08450 arc->id_code = 0; 08451 arc->x0 = 0.0; 08452 arc->y0 = 0.0; 08453 arc->radius = 0.0; 08454 arc->start_angle = 0.0; 08455 arc->end_angle = 0.0; 08456 arc->is_ccw = 0; 08457 arc->next = NULL; 08458 #if DEBUG 08459 DXF_DEBUG_END 08460 #endif 08461 return (arc); 08462 } 08463 08464 08472 int 08473 dxf_hatch_boundary_path_edge_arc_free 08474 ( 08475 DxfHatchBoundaryPathEdgeArc *arc 08478 ) 08479 { 08480 #if DEBUG 08481 DXF_DEBUG_BEGIN 08482 #endif 08483 /* Do some basic checks. */ 08484 if (arc == NULL) 08485 { 08486 fprintf (stderr, 08487 (_("Error in %s () a NULL pointer was passed.\n")), 08488 __FUNCTION__); 08489 return (EXIT_FAILURE); 08490 } 08491 if (arc->next != NULL) 08492 { 08493 fprintf (stderr, 08494 (_("Error in %s () pointer to next was not NULL.\n")), 08495 __FUNCTION__); 08496 return (EXIT_FAILURE); 08497 } 08498 free (arc); 08499 arc = NULL; 08500 #if DEBUG 08501 DXF_DEBUG_END 08502 #endif 08503 return (EXIT_SUCCESS); 08504 } 08505 08506 08511 void 08512 dxf_hatch_boundary_path_edge_arc_free_chain 08513 ( 08514 DxfHatchBoundaryPathEdgeArc *hatch_boundary_path_edge_arcs 08517 ) 08518 { 08519 #ifdef DEBUG 08520 DXF_DEBUG_BEGIN 08521 #endif 08522 /* Do some basic checks. */ 08523 if (hatch_boundary_path_edge_arcs == NULL) 08524 { 08525 fprintf (stderr, 08526 (_("Warning in %s () a NULL pointer was passed.\n")), 08527 __FUNCTION__); 08528 } 08529 while (hatch_boundary_path_edge_arcs != NULL) 08530 { 08531 struct DxfHatchBoundaryPathEdgeArc *iter = hatch_boundary_path_edge_arcs->next; 08532 dxf_hatch_boundary_path_edge_arc_free (hatch_boundary_path_edge_arcs); 08533 hatch_boundary_path_edge_arcs = (DxfHatchBoundaryPathEdgeArc *) iter; 08534 } 08535 #if DEBUG 08536 DXF_DEBUG_END 08537 #endif 08538 } 08539 08540 08546 int 08547 dxf_hatch_boundary_path_edge_arc_get_id_code 08548 ( 08549 DxfHatchBoundaryPathEdgeArc *arc 08551 ) 08552 { 08553 #if DEBUG 08554 DXF_DEBUG_BEGIN 08555 #endif 08556 int result; 08557 08558 /* Do some basic checks. */ 08559 if (arc == NULL) 08560 { 08561 fprintf (stderr, 08562 (_("Error in %s () a NULL pointer was passed.\n")), 08563 __FUNCTION__); 08564 return (EXIT_FAILURE); 08565 } 08566 if (arc->id_code < 0) 08567 { 08568 fprintf (stderr, 08569 (_("Error in %s () a negative value was found in the id_code member.\n")), 08570 __FUNCTION__); 08571 return (EXIT_FAILURE); 08572 } 08573 result = arc->id_code; 08574 #if DEBUG 08575 DXF_DEBUG_END 08576 #endif 08577 return (result); 08578 } 08579 08580 08584 DxfHatchBoundaryPathEdgeArc * 08585 dxf_hatch_boundary_path_edge_arc_set_id_code 08586 ( 08587 DxfHatchBoundaryPathEdgeArc *arc, 08589 int id_code 08593 ) 08594 { 08595 #if DEBUG 08596 DXF_DEBUG_BEGIN 08597 #endif 08598 /* Do some basic checks. */ 08599 if (arc == NULL) 08600 { 08601 fprintf (stderr, 08602 (_("Error in %s () a NULL pointer was passed.\n")), 08603 __FUNCTION__); 08604 return (NULL); 08605 } 08606 if (id_code < 0) 08607 { 08608 fprintf (stderr, 08609 (_("Error in %s () a negative id-code value was passed.\n")), 08610 __FUNCTION__); 08611 return (NULL); 08612 } 08613 arc->id_code = id_code; 08614 #if DEBUG 08615 DXF_DEBUG_END 08616 #endif 08617 return (arc); 08618 } 08619 08620 08627 double 08628 dxf_hatch_boundary_path_edge_arc_get_x0 08629 ( 08630 DxfHatchBoundaryPathEdgeArc *arc 08632 ) 08633 { 08634 #if DEBUG 08635 DXF_DEBUG_BEGIN 08636 #endif 08637 double result; 08638 08639 /* Do some basic checks. */ 08640 if (arc == NULL) 08641 { 08642 fprintf (stderr, 08643 (_("Error in %s () a NULL pointer was passed.\n")), 08644 __FUNCTION__); 08645 return (EXIT_FAILURE); 08646 } 08647 result = arc->x0; 08648 #if DEBUG 08649 DXF_DEBUG_END 08650 #endif 08651 return (result); 08652 } 08653 08654 08659 DxfHatchBoundaryPathEdgeArc * 08660 dxf_hatch_boundary_path_edge_arc_set_x0 08661 ( 08662 DxfHatchBoundaryPathEdgeArc *arc, 08664 double x0 08666 ) 08667 { 08668 #if DEBUG 08669 DXF_DEBUG_BEGIN 08670 #endif 08671 /* Do some basic checks. */ 08672 if (arc == NULL) 08673 { 08674 fprintf (stderr, 08675 (_("Error in %s () a NULL pointer was passed.\n")), 08676 __FUNCTION__); 08677 return (NULL); 08678 } 08679 arc->x0 = x0; 08680 #if DEBUG 08681 DXF_DEBUG_END 08682 #endif 08683 return (arc); 08684 } 08685 08686 08693 double 08694 dxf_hatch_boundary_path_edge_arc_get_y0 08695 ( 08696 DxfHatchBoundaryPathEdgeArc *arc 08698 ) 08699 { 08700 #if DEBUG 08701 DXF_DEBUG_BEGIN 08702 #endif 08703 double result; 08704 08705 /* Do some basic checks. */ 08706 if (arc == NULL) 08707 { 08708 fprintf (stderr, 08709 (_("Error in %s () a NULL pointer was passed.\n")), 08710 __FUNCTION__); 08711 return (EXIT_FAILURE); 08712 } 08713 result = arc->y0; 08714 #if DEBUG 08715 DXF_DEBUG_END 08716 #endif 08717 return (result); 08718 } 08719 08720 08725 DxfHatchBoundaryPathEdgeArc * 08726 dxf_hatch_boundary_path_edge_arc_set_y0 08727 ( 08728 DxfHatchBoundaryPathEdgeArc *arc, 08730 double y0 08732 ) 08733 { 08734 #if DEBUG 08735 DXF_DEBUG_BEGIN 08736 #endif 08737 /* Do some basic checks. */ 08738 if (arc == NULL) 08739 { 08740 fprintf (stderr, 08741 (_("Error in %s () a NULL pointer was passed.\n")), 08742 __FUNCTION__); 08743 return (NULL); 08744 } 08745 arc->y0 = y0; 08746 #if DEBUG 08747 DXF_DEBUG_END 08748 #endif 08749 return (arc); 08750 } 08751 08752 08758 DxfPoint * 08759 dxf_hatch_boundary_path_edge_arc_get_center_point 08760 ( 08761 DxfHatchBoundaryPathEdgeArc *arc, 08763 int id_code 08767 ) 08768 { 08769 #ifdef DEBUG 08770 DXF_DEBUG_BEGIN 08771 #endif 08772 DxfPoint *p1 = NULL; 08773 08774 /* Do some basic checks. */ 08775 if (arc == NULL) 08776 { 08777 fprintf (stderr, 08778 (_("Error in %s () a NULL pointer was passed.\n")), 08779 __FUNCTION__); 08780 return (NULL); 08781 } 08782 p1 = dxf_point_init (p1); 08783 if (p1 == NULL) 08784 { 08785 fprintf (stderr, 08786 (_("Error in %s () could not allocate memory for a DxfPoint struct.\n")), 08787 __FUNCTION__); 08788 return (NULL); 08789 } 08790 if (id_code < 0) 08791 { 08792 fprintf (stderr, 08793 (_("Warning in %s () passed id_code is smaller than 0.\n")), 08794 __FUNCTION__); 08795 } 08796 p1->id_code = id_code; 08797 p1->x0 = arc->x0; 08798 p1->y0 = arc->y0; 08799 #if DEBUG 08800 DXF_DEBUG_END 08801 #endif 08802 return (p1); 08803 } 08804 08805 08811 DxfHatchBoundaryPathEdgeArc * 08812 dxf_hatch_boundary_path_edge_arc_set_center_point 08813 ( 08814 DxfHatchBoundaryPathEdgeArc *arc, 08816 DxfPoint *point 08818 ) 08819 { 08820 #ifdef DEBUG 08821 DXF_DEBUG_BEGIN 08822 #endif 08823 /* Do some basic checks. */ 08824 if (arc == NULL) 08825 { 08826 fprintf (stderr, 08827 (_("Error in %s () a NULL pointer was passed.\n")), 08828 __FUNCTION__); 08829 return (NULL); 08830 } 08831 if (point == NULL) 08832 { 08833 fprintf (stderr, 08834 (_("Error in %s () a NULL pointer was passed.\n")), 08835 __FUNCTION__); 08836 return (NULL); 08837 } 08838 arc->x0 = point->x0; 08839 arc->y0 = point->y0; 08840 #if DEBUG 08841 DXF_DEBUG_END 08842 #endif 08843 return (arc); 08844 } 08845 08846 08852 double 08853 dxf_hatch_boundary_path_edge_arc_get_radius 08854 ( 08855 DxfHatchBoundaryPathEdgeArc *arc 08857 ) 08858 { 08859 #if DEBUG 08860 DXF_DEBUG_BEGIN 08861 #endif 08862 double result; 08863 08864 /* Do some basic checks. */ 08865 if (arc == NULL) 08866 { 08867 fprintf (stderr, 08868 (_("Error in %s () a NULL pointer was passed.\n")), 08869 __FUNCTION__); 08870 return (EXIT_FAILURE); 08871 } 08872 if (arc->radius < 0.0) 08873 { 08874 fprintf (stderr, 08875 (_("Error in %s () a negative value was found in the radius member.\n")), 08876 __FUNCTION__); 08877 return (EXIT_FAILURE); 08878 } 08879 if (arc->radius == 0.0) 08880 { 08881 fprintf (stderr, 08882 (_("Error in %s () a value of zero was found in the radius member.\n")), 08883 __FUNCTION__); 08884 return (EXIT_FAILURE); 08885 } 08886 result = arc->radius; 08887 #if DEBUG 08888 DXF_DEBUG_END 08889 #endif 08890 return (result); 08891 } 08892 08893 08897 DxfHatchBoundaryPathEdgeArc * 08898 dxf_hatch_boundary_path_edge_arc_set_radius 08899 ( 08900 DxfHatchBoundaryPathEdgeArc *arc, 08902 double radius 08904 ) 08905 { 08906 #if DEBUG 08907 DXF_DEBUG_BEGIN 08908 #endif 08909 /* Do some basic checks. */ 08910 if (arc == NULL) 08911 { 08912 fprintf (stderr, 08913 (_("Error in %s () a NULL pointer was passed.\n")), 08914 __FUNCTION__); 08915 return (NULL); 08916 } 08917 if (radius < 0.0) 08918 { 08919 fprintf (stderr, 08920 (_("Error in %s () a negative radius value was passed.\n")), 08921 __FUNCTION__); 08922 return (NULL); 08923 } 08924 if (radius == 0.0) 08925 { 08926 fprintf (stderr, 08927 (_("Error in %s () a value of zero was passed.\n")), 08928 __FUNCTION__); 08929 return (NULL); 08930 } 08931 arc->radius = radius; 08932 #if DEBUG 08933 DXF_DEBUG_END 08934 #endif 08935 return (arc); 08936 } 08937 08938 08944 double 08945 dxf_hatch_boundary_path_edge_arc_get_start_angle 08946 ( 08947 DxfHatchBoundaryPathEdgeArc *arc 08949 ) 08950 { 08951 #if DEBUG 08952 DXF_DEBUG_BEGIN 08953 #endif 08954 double result; 08955 08956 /* Do some basic checks. */ 08957 if (arc == NULL) 08958 { 08959 fprintf (stderr, 08960 (_("Error in %s () a NULL pointer was passed.\n")), 08961 __FUNCTION__); 08962 return (EXIT_FAILURE); 08963 } 08964 result = arc->start_angle; 08965 #if DEBUG 08966 DXF_DEBUG_END 08967 #endif 08968 return (result); 08969 } 08970 08971 08975 DxfHatchBoundaryPathEdgeArc * 08976 dxf_hatch_boundary_path_edge_arc_set_start_angle 08977 ( 08978 DxfHatchBoundaryPathEdgeArc *arc, 08980 double start_angle 08982 ) 08983 { 08984 #if DEBUG 08985 DXF_DEBUG_BEGIN 08986 #endif 08987 /* Do some basic checks. */ 08988 if (arc == NULL) 08989 { 08990 fprintf (stderr, 08991 (_("Error in %s () a NULL pointer was passed.\n")), 08992 __FUNCTION__); 08993 return (NULL); 08994 } 08995 arc->start_angle = start_angle; 08996 #if DEBUG 08997 DXF_DEBUG_END 08998 #endif 08999 return (arc); 09000 } 09001 09002 09008 double 09009 dxf_hatch_boundary_path_edge_arc_get_end_angle 09010 ( 09011 DxfHatchBoundaryPathEdgeArc *arc 09013 ) 09014 { 09015 #if DEBUG 09016 DXF_DEBUG_BEGIN 09017 #endif 09018 double result; 09019 09020 /* Do some basic checks. */ 09021 if (arc == NULL) 09022 { 09023 fprintf (stderr, 09024 (_("Error in %s () a NULL pointer was passed.\n")), 09025 __FUNCTION__); 09026 return (EXIT_FAILURE); 09027 } 09028 result = arc->end_angle; 09029 #if DEBUG 09030 DXF_DEBUG_END 09031 #endif 09032 return (result); 09033 } 09034 09035 09039 DxfHatchBoundaryPathEdgeArc * 09040 dxf_hatch_boundary_path_edge_arc_set_end_angle 09041 ( 09042 DxfHatchBoundaryPathEdgeArc *arc, 09044 double end_angle 09046 ) 09047 { 09048 #if DEBUG 09049 DXF_DEBUG_BEGIN 09050 #endif 09051 /* Do some basic checks. */ 09052 if (arc == NULL) 09053 { 09054 fprintf (stderr, 09055 (_("Error in %s () a NULL pointer was passed.\n")), 09056 __FUNCTION__); 09057 return (NULL); 09058 } 09059 arc->end_angle = end_angle; 09060 #if DEBUG 09061 DXF_DEBUG_END 09062 #endif 09063 return (arc); 09064 } 09065 09066 09073 int 09074 dxf_hatch_boundary_path_edge_arc_get_is_ccw 09075 ( 09076 DxfHatchBoundaryPathEdgeArc *arc 09078 ) 09079 { 09080 #if DEBUG 09081 DXF_DEBUG_BEGIN 09082 #endif 09083 int result; 09084 09085 /* Do some basic checks. */ 09086 if (arc == NULL) 09087 { 09088 fprintf (stderr, 09089 (_("Error in %s () a NULL pointer was passed.\n")), 09090 __FUNCTION__); 09091 return (EXIT_FAILURE); 09092 } 09093 if (arc->is_ccw < 0) 09094 { 09095 fprintf (stderr, 09096 (_("Warning in %s () a negative value was found in the is_ccw member.\n")), 09097 __FUNCTION__); 09098 } 09099 result = arc->is_ccw; 09100 #if DEBUG 09101 DXF_DEBUG_END 09102 #endif 09103 return (result); 09104 } 09105 09106 09110 DxfHatchBoundaryPathEdgeArc * 09111 dxf_hatch_boundary_path_edge_arc_set_is_ccw 09112 ( 09113 DxfHatchBoundaryPathEdgeArc *arc, 09115 int is_ccw 09117 ) 09118 { 09119 #if DEBUG 09120 DXF_DEBUG_BEGIN 09121 #endif 09122 /* Do some basic checks. */ 09123 if (arc == NULL) 09124 { 09125 fprintf (stderr, 09126 (_("Error in %s () a NULL pointer was passed.\n")), 09127 __FUNCTION__); 09128 return (NULL); 09129 } 09130 if (is_ccw < 0) 09131 { 09132 fprintf (stderr, 09133 (_("Warning in %s () a negative is_ccw value was passed.\n")), 09134 __FUNCTION__); 09135 } 09136 arc->is_ccw = is_ccw; 09137 #if DEBUG 09138 DXF_DEBUG_END 09139 #endif 09140 return (arc); 09141 } 09142 09143 09152 DxfHatchBoundaryPathEdgeArc * 09153 dxf_hatch_boundary_path_edge_arc_get_next 09154 ( 09155 DxfHatchBoundaryPathEdgeArc *arc 09157 ) 09158 { 09159 #if DEBUG 09160 DXF_DEBUG_BEGIN 09161 #endif 09162 DxfHatchBoundaryPathEdgeArc *result; 09163 09164 /* Do some basic checks. */ 09165 if (arc == NULL) 09166 { 09167 fprintf (stderr, 09168 (_("Error in %s () a NULL pointer was passed.\n")), 09169 __FUNCTION__); 09170 return (NULL); 09171 } 09172 if (arc->next == NULL) 09173 { 09174 fprintf (stderr, 09175 (_("Error in %s () a NULL pointer was found in the next member.\n")), 09176 __FUNCTION__); 09177 return (NULL); 09178 } 09179 result = (DxfHatchBoundaryPathEdgeArc *) arc->next; 09180 #if DEBUG 09181 DXF_DEBUG_END 09182 #endif 09183 return (result); 09184 } 09185 09186 09191 DxfHatchBoundaryPathEdgeArc * 09192 dxf_hatch_boundary_path_edge_arc_set_next 09193 ( 09194 DxfHatchBoundaryPathEdgeArc *arc, 09196 DxfHatchBoundaryPathEdgeArc *next 09199 ) 09200 { 09201 #if DEBUG 09202 DXF_DEBUG_BEGIN 09203 #endif 09204 /* Do some basic checks. */ 09205 if (arc == NULL) 09206 { 09207 fprintf (stderr, 09208 (_("Error in %s () a NULL pointer was passed.\n")), 09209 __FUNCTION__); 09210 return (NULL); 09211 } 09212 if (next == NULL) 09213 { 09214 fprintf (stderr, 09215 (_("Error in %s () a NULL pointer was passed.\n")), 09216 __FUNCTION__); 09217 return (NULL); 09218 } 09219 arc->next = (struct DxfHatchBoundaryPathEdgeArc *) next; 09220 #if DEBUG 09221 DXF_DEBUG_END 09222 #endif 09223 return (arc); 09224 } 09225 09226 09235 DxfHatchBoundaryPathEdgeArc * 09236 dxf_hatch_boundary_path_edge_arc_get_last 09237 ( 09238 DxfHatchBoundaryPathEdgeArc *arc 09240 ) 09241 { 09242 #if DEBUG 09243 DXF_DEBUG_BEGIN 09244 #endif 09245 /* Do some basic checks. */ 09246 if (arc == NULL) 09247 { 09248 fprintf (stderr, 09249 (_("Error in %s () a NULL pointer was passed.\n")), 09250 __FUNCTION__); 09251 return (NULL); 09252 } 09253 if (arc->next == NULL) 09254 { 09255 fprintf (stderr, 09256 (_("Warning in %s () a NULL pointer was found in the next member.\n")), 09257 __FUNCTION__); 09258 return ((DxfHatchBoundaryPathEdgeArc *) arc); 09259 } 09260 DxfHatchBoundaryPathEdgeArc *iter = (DxfHatchBoundaryPathEdgeArc *) arc->next; 09261 while (iter->next != NULL) 09262 { 09263 iter = (DxfHatchBoundaryPathEdgeArc *) iter->next; 09264 } 09265 #if DEBUG 09266 DXF_DEBUG_END 09267 #endif 09268 return ((DxfHatchBoundaryPathEdgeArc *) iter); 09269 } 09270 09271 09272 /* dxf_hatch_boundary_path_edge_ellipse functions. */ 09273 09279 DxfHatchBoundaryPathEdgeEllipse * 09280 dxf_hatch_boundary_path_edge_ellipse_new () 09281 { 09282 #if DEBUG 09283 DXF_DEBUG_BEGIN 09284 #endif 09285 DxfHatchBoundaryPathEdgeEllipse *ellipse = NULL; 09286 size_t size; 09287 09288 size = sizeof (DxfHatchBoundaryPathEdgeEllipse); 09289 /* avoid malloc of 0 bytes */ 09290 if (size == 0) size = 1; 09291 if ((ellipse = malloc (size)) == NULL) 09292 { 09293 fprintf (stderr, 09294 (_("Error in %s () could not allocate memory for a DxfHatchBoundaryPathEdgeEllipse struct.\n")), 09295 __FUNCTION__); 09296 ellipse = NULL; 09297 } 09298 else 09299 { 09300 memset (ellipse, 0, size); 09301 } 09302 #if DEBUG 09303 DXF_DEBUG_END 09304 #endif 09305 return (ellipse); 09306 } 09307 09308 09316 DxfHatchBoundaryPathEdgeEllipse * 09317 dxf_hatch_boundary_path_edge_ellipse_init 09318 ( 09319 DxfHatchBoundaryPathEdgeEllipse *ellipse 09321 ) 09322 { 09323 #if DEBUG 09324 DXF_DEBUG_BEGIN 09325 #endif 09326 /* Do some basic checks. */ 09327 if (ellipse == NULL) 09328 { 09329 fprintf (stderr, 09330 (_("Warning in %s () a NULL pointer was passed.\n")), 09331 __FUNCTION__); 09332 ellipse = dxf_hatch_boundary_path_edge_ellipse_new (); 09333 } 09334 if (ellipse == NULL) 09335 { 09336 fprintf (stderr, 09337 (_("Error in %s () could not allocate memory for a DxfHatchBoundaryPathEdgeEllipse struct.\n")), 09338 __FUNCTION__); 09339 return (NULL); 09340 } 09341 ellipse->id_code = 0; 09342 ellipse->x0 = 0.0; 09343 ellipse->y0 = 0.0; 09344 ellipse->x1 = 0.0; 09345 ellipse->y1 = 0.0; 09346 ellipse->ratio = 0.0; 09347 ellipse->start_angle = 0.0; 09348 ellipse->end_angle = 0.0; 09349 ellipse->is_ccw = 0; 09350 ellipse->next = NULL; 09351 #if DEBUG 09352 DXF_DEBUG_END 09353 #endif 09354 return (ellipse); 09355 } 09356 09357 09365 int 09366 dxf_hatch_boundary_path_edge_ellipse_free 09367 ( 09368 DxfHatchBoundaryPathEdgeEllipse *ellipse 09371 ) 09372 { 09373 #if DEBUG 09374 DXF_DEBUG_BEGIN 09375 #endif 09376 /* Do some basic checks. */ 09377 if (ellipse == NULL) 09378 { 09379 fprintf (stderr, 09380 (_("Error in %s () a NULL pointer was passed.\n")), 09381 __FUNCTION__); 09382 return (EXIT_FAILURE); 09383 } 09384 if (ellipse->next != NULL) 09385 { 09386 fprintf (stderr, 09387 (_("Error in %s () pointer to next was not NULL.\n")), 09388 __FUNCTION__); 09389 return (EXIT_FAILURE); 09390 } 09391 free (ellipse); 09392 ellipse = NULL; 09393 #if DEBUG 09394 DXF_DEBUG_END 09395 #endif 09396 return (EXIT_SUCCESS); 09397 } 09398 09399 09404 void 09405 dxf_hatch_boundary_path_edge_ellipse_free_chain 09406 ( 09407 DxfHatchBoundaryPathEdgeEllipse *hatch_boundary_path_edge_ellipses 09410 ) 09411 { 09412 #ifdef DEBUG 09413 DXF_DEBUG_BEGIN 09414 #endif 09415 /* Do some basic checks. */ 09416 if (hatch_boundary_path_edge_ellipses == NULL) 09417 { 09418 fprintf (stderr, 09419 (_("Warning in %s () a NULL pointer was passed.\n")), 09420 __FUNCTION__); 09421 } 09422 while (hatch_boundary_path_edge_ellipses != NULL) 09423 { 09424 struct DxfHatchBoundaryPathEdgeEllipse *iter = hatch_boundary_path_edge_ellipses->next; 09425 dxf_hatch_boundary_path_edge_ellipse_free (hatch_boundary_path_edge_ellipses); 09426 hatch_boundary_path_edge_ellipses = (DxfHatchBoundaryPathEdgeEllipse *) iter; 09427 } 09428 #if DEBUG 09429 DXF_DEBUG_END 09430 #endif 09431 } 09432 09433 09440 int 09441 dxf_hatch_boundary_path_edge_ellipse_get_id_code 09442 ( 09443 DxfHatchBoundaryPathEdgeEllipse *ellipse 09446 ) 09447 { 09448 #if DEBUG 09449 DXF_DEBUG_BEGIN 09450 #endif 09451 int result; 09452 09453 /* Do some basic checks. */ 09454 if (ellipse == NULL) 09455 { 09456 fprintf (stderr, 09457 (_("Error in %s () a NULL pointer was passed.\n")), 09458 __FUNCTION__); 09459 return (EXIT_FAILURE); 09460 } 09461 if (ellipse->id_code < 0) 09462 { 09463 fprintf (stderr, 09464 (_("Error in %s () a negative value was found in the id-code member.\n")), 09465 __FUNCTION__); 09466 return (EXIT_FAILURE); 09467 } 09468 result = ellipse->id_code; 09469 #if DEBUG 09470 DXF_DEBUG_END 09471 #endif 09472 return (result); 09473 } 09474 09475 09479 DxfHatchBoundaryPathEdgeEllipse * 09480 dxf_hatch_boundary_path_edge_ellipse_set_id_code 09481 ( 09482 DxfHatchBoundaryPathEdgeEllipse *ellipse, 09485 int id_code 09489 ) 09490 { 09491 #if DEBUG 09492 DXF_DEBUG_BEGIN 09493 #endif 09494 /* Do some basic checks. */ 09495 if (ellipse == NULL) 09496 { 09497 fprintf (stderr, 09498 (_("Error in %s () a NULL pointer was passed.\n")), 09499 __FUNCTION__); 09500 return (NULL); 09501 } 09502 if (id_code < 0) 09503 { 09504 fprintf (stderr, 09505 (_("Error in %s () a negative id-code value was passed.\n")), 09506 __FUNCTION__); 09507 return (NULL); 09508 } 09509 ellipse->id_code = id_code; 09510 #if DEBUG 09511 DXF_DEBUG_END 09512 #endif 09513 return (ellipse); 09514 } 09515 09516 09523 double 09524 dxf_hatch_boundary_path_edge_ellipse_get_x0 09525 ( 09526 DxfHatchBoundaryPathEdgeEllipse *ellipse 09529 ) 09530 { 09531 #if DEBUG 09532 DXF_DEBUG_BEGIN 09533 #endif 09534 double result; 09535 09536 /* Do some basic checks. */ 09537 if (ellipse == NULL) 09538 { 09539 fprintf (stderr, 09540 (_("Error in %s () a NULL pointer was passed.\n")), 09541 __FUNCTION__); 09542 return (EXIT_FAILURE); 09543 } 09544 result = ellipse->x0; 09545 #if DEBUG 09546 DXF_DEBUG_END 09547 #endif 09548 return (result); 09549 } 09550 09551 09556 DxfHatchBoundaryPathEdgeEllipse * 09557 dxf_hatch_boundary_path_edge_ellipse_set_x0 09558 ( 09559 DxfHatchBoundaryPathEdgeEllipse *ellipse, 09562 double x0 09565 ) 09566 { 09567 #if DEBUG 09568 DXF_DEBUG_BEGIN 09569 #endif 09570 /* Do some basic checks. */ 09571 if (ellipse == NULL) 09572 { 09573 fprintf (stderr, 09574 (_("Error in %s () a NULL pointer was passed.\n")), 09575 __FUNCTION__); 09576 return (NULL); 09577 } 09578 ellipse->x0 = x0; 09579 #if DEBUG 09580 DXF_DEBUG_END 09581 #endif 09582 return (ellipse); 09583 } 09584 09585 09592 double 09593 dxf_hatch_boundary_path_edge_ellipse_get_y0 09594 ( 09595 DxfHatchBoundaryPathEdgeEllipse *ellipse 09598 ) 09599 { 09600 #if DEBUG 09601 DXF_DEBUG_BEGIN 09602 #endif 09603 double result; 09604 09605 /* Do some basic checks. */ 09606 if (ellipse == NULL) 09607 { 09608 fprintf (stderr, 09609 (_("Error in %s () a NULL pointer was passed.\n")), 09610 __FUNCTION__); 09611 return (EXIT_FAILURE); 09612 } 09613 result = ellipse->y0; 09614 #if DEBUG 09615 DXF_DEBUG_END 09616 #endif 09617 return (result); 09618 } 09619 09620 09625 DxfHatchBoundaryPathEdgeEllipse * 09626 dxf_hatch_boundary_path_edge_ellipse_set_y0 09627 ( 09628 DxfHatchBoundaryPathEdgeEllipse *ellipse, 09631 double y0 09634 ) 09635 { 09636 #if DEBUG 09637 DXF_DEBUG_BEGIN 09638 #endif 09639 /* Do some basic checks. */ 09640 if (ellipse == NULL) 09641 { 09642 fprintf (stderr, 09643 (_("Error in %s () a NULL pointer was passed.\n")), 09644 __FUNCTION__); 09645 return (NULL); 09646 } 09647 ellipse->y0 = y0; 09648 #if DEBUG 09649 DXF_DEBUG_END 09650 #endif 09651 return (ellipse); 09652 } 09653 09654 09661 DxfPoint * 09662 dxf_hatch_boundary_path_edge_ellipse_get_center_point 09663 ( 09664 DxfHatchBoundaryPathEdgeEllipse *ellipse, 09667 int id_code 09671 ) 09672 { 09673 #ifdef DEBUG 09674 DXF_DEBUG_BEGIN 09675 #endif 09676 DxfPoint *p1 = NULL; 09677 09678 /* Do some basic checks. */ 09679 if (ellipse == NULL) 09680 { 09681 fprintf (stderr, 09682 (_("Error in %s () a NULL pointer was passed.\n")), 09683 __FUNCTION__); 09684 return (NULL); 09685 } 09686 p1 = dxf_point_init (p1); 09687 if (p1 == NULL) 09688 { 09689 fprintf (stderr, 09690 (_("Error in %s () could not allocate memory for a DxfPoint struct.\n")), 09691 __FUNCTION__); 09692 return (NULL); 09693 } 09694 if (id_code < 0) 09695 { 09696 fprintf (stderr, 09697 (_("Warning in %s () passed id_code is smaller than 0.\n")), 09698 __FUNCTION__); 09699 } 09700 p1->id_code = id_code; 09701 p1->x0 = ellipse->x0; 09702 p1->y0 = ellipse->y0; 09703 #if DEBUG 09704 DXF_DEBUG_END 09705 #endif 09706 return (p1); 09707 } 09708 09709 09716 DxfHatchBoundaryPathEdgeEllipse * 09717 dxf_hatch_boundary_path_edge_ellipse_set_center_point 09718 ( 09719 DxfHatchBoundaryPathEdgeEllipse *ellipse, 09722 DxfPoint *point 09724 ) 09725 { 09726 #ifdef DEBUG 09727 DXF_DEBUG_BEGIN 09728 #endif 09729 /* Do some basic checks. */ 09730 if (ellipse == NULL) 09731 { 09732 fprintf (stderr, 09733 (_("Error in %s () a NULL pointer was passed.\n")), 09734 __FUNCTION__); 09735 return (NULL); 09736 } 09737 if (point == NULL) 09738 { 09739 fprintf (stderr, 09740 (_("Error in %s () a NULL pointer was passed.\n")), 09741 __FUNCTION__); 09742 return (NULL); 09743 } 09744 ellipse->x0 = point->x0; 09745 ellipse->y0 = point->y0; 09746 #if DEBUG 09747 DXF_DEBUG_END 09748 #endif 09749 return (ellipse); 09750 } 09751 09752 09759 double 09760 dxf_hatch_boundary_path_edge_ellipse_get_x1 09761 ( 09762 DxfHatchBoundaryPathEdgeEllipse *ellipse 09765 ) 09766 { 09767 #if DEBUG 09768 DXF_DEBUG_BEGIN 09769 #endif 09770 double result; 09771 09772 /* Do some basic checks. */ 09773 if (ellipse == NULL) 09774 { 09775 fprintf (stderr, 09776 (_("Error in %s () a NULL pointer was passed.\n")), 09777 __FUNCTION__); 09778 return (EXIT_FAILURE); 09779 } 09780 result = ellipse->x1; 09781 #if DEBUG 09782 DXF_DEBUG_END 09783 #endif 09784 return (result); 09785 } 09786 09787 09792 DxfHatchBoundaryPathEdgeEllipse * 09793 dxf_hatch_boundary_path_edge_ellipse_set_x1 09794 ( 09795 DxfHatchBoundaryPathEdgeEllipse *ellipse, 09798 double x1 09801 ) 09802 { 09803 #if DEBUG 09804 DXF_DEBUG_BEGIN 09805 #endif 09806 /* Do some basic checks. */ 09807 if (ellipse == NULL) 09808 { 09809 fprintf (stderr, 09810 (_("Error in %s () a NULL pointer was passed.\n")), 09811 __FUNCTION__); 09812 return (NULL); 09813 } 09814 ellipse->x1 = x1; 09815 #if DEBUG 09816 DXF_DEBUG_END 09817 #endif 09818 return (ellipse); 09819 } 09820 09821 09828 double 09829 dxf_hatch_boundary_path_edge_ellipse_get_y1 09830 ( 09831 DxfHatchBoundaryPathEdgeEllipse *ellipse 09834 ) 09835 { 09836 #if DEBUG 09837 DXF_DEBUG_BEGIN 09838 #endif 09839 double result; 09840 09841 /* Do some basic checks. */ 09842 if (ellipse == NULL) 09843 { 09844 fprintf (stderr, 09845 (_("Error in %s () a NULL pointer was passed.\n")), 09846 __FUNCTION__); 09847 return (EXIT_FAILURE); 09848 } 09849 result = ellipse->y1; 09850 #if DEBUG 09851 DXF_DEBUG_END 09852 #endif 09853 return (result); 09854 } 09855 09856 09861 DxfHatchBoundaryPathEdgeEllipse * 09862 dxf_hatch_boundary_path_edge_ellipse_set_y1 09863 ( 09864 DxfHatchBoundaryPathEdgeEllipse *ellipse, 09867 double y1 09870 ) 09871 { 09872 #if DEBUG 09873 DXF_DEBUG_BEGIN 09874 #endif 09875 /* Do some basic checks. */ 09876 if (ellipse == NULL) 09877 { 09878 fprintf (stderr, 09879 (_("Error in %s () a NULL pointer was passed.\n")), 09880 __FUNCTION__); 09881 return (NULL); 09882 } 09883 ellipse->y1 = y1; 09884 #if DEBUG 09885 DXF_DEBUG_END 09886 #endif 09887 return (ellipse); 09888 } 09889 09890 09897 DxfPoint * 09898 dxf_hatch_boundary_path_edge_ellipse_get_end_point 09899 ( 09900 DxfHatchBoundaryPathEdgeEllipse *ellipse, 09903 int id_code 09907 ) 09908 { 09909 #ifdef DEBUG 09910 DXF_DEBUG_BEGIN 09911 #endif 09912 DxfPoint *p1 = NULL; 09913 09914 /* Do some basic checks. */ 09915 if (ellipse == NULL) 09916 { 09917 fprintf (stderr, 09918 (_("Error in %s () a NULL pointer was passed.\n")), 09919 __FUNCTION__); 09920 return (NULL); 09921 } 09922 p1 = dxf_point_init (p1); 09923 if (p1 == NULL) 09924 { 09925 fprintf (stderr, 09926 (_("Error in %s () could not allocate memory for a DxfPoint struct.\n")), 09927 __FUNCTION__); 09928 return (NULL); 09929 } 09930 if (id_code < 0) 09931 { 09932 fprintf (stderr, 09933 (_("Warning in %s () passed id_code is smaller than 0.\n")), 09934 __FUNCTION__); 09935 } 09936 p1->id_code = id_code; 09937 p1->x0 = ellipse->x1; 09938 p1->y0 = ellipse->y1; 09939 #if DEBUG 09940 DXF_DEBUG_END 09941 #endif 09942 return (p1); 09943 } 09944 09945 09952 DxfHatchBoundaryPathEdgeEllipse * 09953 dxf_hatch_boundary_path_edge_ellipse_set_end_point 09954 ( 09955 DxfHatchBoundaryPathEdgeEllipse *ellipse, 09958 DxfPoint *point 09960 ) 09961 { 09962 #ifdef DEBUG 09963 DXF_DEBUG_BEGIN 09964 #endif 09965 /* Do some basic checks. */ 09966 if (ellipse == NULL) 09967 { 09968 fprintf (stderr, 09969 (_("Error in %s () a NULL pointer was passed.\n")), 09970 __FUNCTION__); 09971 return (NULL); 09972 } 09973 if (point == NULL) 09974 { 09975 fprintf (stderr, 09976 (_("Error in %s () a NULL pointer was passed.\n")), 09977 __FUNCTION__); 09978 return (NULL); 09979 } 09980 ellipse->x1 = point->x0; 09981 ellipse->y1 = point->y0; 09982 #if DEBUG 09983 DXF_DEBUG_END 09984 #endif 09985 return (ellipse); 09986 } 09987 09988 09995 double 09996 dxf_hatch_boundary_path_edge_ellipse_get_ratio 09997 ( 09998 DxfHatchBoundaryPathEdgeEllipse *ellipse 10001 ) 10002 { 10003 #if DEBUG 10004 DXF_DEBUG_BEGIN 10005 #endif 10006 double result; 10007 10008 /* Do some basic checks. */ 10009 if (ellipse == NULL) 10010 { 10011 fprintf (stderr, 10012 (_("Error in %s () a NULL pointer was passed.\n")), 10013 __FUNCTION__); 10014 return (EXIT_FAILURE); 10015 } 10016 if (ellipse->ratio < 0.0) 10017 { 10018 fprintf (stderr, 10019 (_("Error in %s () a negative value was found in the ratio member.\n")), 10020 __FUNCTION__); 10021 return (EXIT_FAILURE); 10022 } 10023 if (ellipse->ratio == 0.0) 10024 { 10025 fprintf (stderr, 10026 (_("Error in %s () a value of zero was found in the ratio member.\n")), 10027 __FUNCTION__); 10028 return (EXIT_FAILURE); 10029 } 10030 result = ellipse->ratio; 10031 #if DEBUG 10032 DXF_DEBUG_END 10033 #endif 10034 return (result); 10035 } 10036 10037 10042 DxfHatchBoundaryPathEdgeEllipse * 10043 dxf_hatch_boundary_path_edge_ellipse_set_ratio 10044 ( 10045 DxfHatchBoundaryPathEdgeEllipse *ellipse, 10048 double ratio 10050 ) 10051 { 10052 #if DEBUG 10053 DXF_DEBUG_BEGIN 10054 #endif 10055 /* Do some basic checks. */ 10056 if (ellipse == NULL) 10057 { 10058 fprintf (stderr, 10059 (_("Error in %s () a NULL pointer was passed.\n")), 10060 __FUNCTION__); 10061 return (NULL); 10062 } 10063 if (ratio < 0.0) 10064 { 10065 fprintf (stderr, 10066 (_("Error in %s () a negative ratio value was passed.\n")), 10067 __FUNCTION__); 10068 return (NULL); 10069 } 10070 if (ratio == 0.0) 10071 { 10072 fprintf (stderr, 10073 (_("Error in %s () a value of zero was passed.\n")), 10074 __FUNCTION__); 10075 return (NULL); 10076 } 10077 ellipse->ratio = ratio; 10078 #if DEBUG 10079 DXF_DEBUG_END 10080 #endif 10081 return (ellipse); 10082 } 10083 10084 10091 double 10092 dxf_hatch_boundary_path_edge_ellipse_get_start_angle 10093 ( 10094 DxfHatchBoundaryPathEdgeEllipse *ellipse 10097 ) 10098 { 10099 #if DEBUG 10100 DXF_DEBUG_BEGIN 10101 #endif 10102 double result; 10103 10104 /* Do some basic checks. */ 10105 if (ellipse == NULL) 10106 { 10107 fprintf (stderr, 10108 (_("Error in %s () a NULL pointer was passed.\n")), 10109 __FUNCTION__); 10110 return (EXIT_FAILURE); 10111 } 10112 result = ellipse->start_angle; 10113 #if DEBUG 10114 DXF_DEBUG_END 10115 #endif 10116 return (result); 10117 } 10118 10119 10124 DxfHatchBoundaryPathEdgeEllipse * 10125 dxf_hatch_boundary_path_edge_ellipse_set_start_angle 10126 ( 10127 DxfHatchBoundaryPathEdgeEllipse *ellipse, 10130 double start_angle 10132 ) 10133 { 10134 #if DEBUG 10135 DXF_DEBUG_BEGIN 10136 #endif 10137 /* Do some basic checks. */ 10138 if (ellipse == NULL) 10139 { 10140 fprintf (stderr, 10141 (_("Error in %s () a NULL pointer was passed.\n")), 10142 __FUNCTION__); 10143 return (NULL); 10144 } 10145 ellipse->start_angle = start_angle; 10146 #if DEBUG 10147 DXF_DEBUG_END 10148 #endif 10149 return (ellipse); 10150 } 10151 10152 10159 double 10160 dxf_hatch_boundary_path_edge_ellipse_get_end_angle 10161 ( 10162 DxfHatchBoundaryPathEdgeEllipse *ellipse 10165 ) 10166 { 10167 #if DEBUG 10168 DXF_DEBUG_BEGIN 10169 #endif 10170 double result; 10171 10172 /* Do some basic checks. */ 10173 if (ellipse == NULL) 10174 { 10175 fprintf (stderr, 10176 (_("Error in %s () a NULL pointer was passed.\n")), 10177 __FUNCTION__); 10178 return (EXIT_FAILURE); 10179 } 10180 result = ellipse->end_angle; 10181 #if DEBUG 10182 DXF_DEBUG_END 10183 #endif 10184 return (result); 10185 } 10186 10187 10192 DxfHatchBoundaryPathEdgeEllipse * 10193 dxf_hatch_boundary_path_edge_ellipse_set_end_angle 10194 ( 10195 DxfHatchBoundaryPathEdgeEllipse *ellipse, 10198 double end_angle 10200 ) 10201 { 10202 #if DEBUG 10203 DXF_DEBUG_BEGIN 10204 #endif 10205 /* Do some basic checks. */ 10206 if (ellipse == NULL) 10207 { 10208 fprintf (stderr, 10209 (_("Error in %s () a NULL pointer was passed.\n")), 10210 __FUNCTION__); 10211 return (NULL); 10212 } 10213 ellipse->end_angle = end_angle; 10214 #if DEBUG 10215 DXF_DEBUG_END 10216 #endif 10217 return (ellipse); 10218 } 10219 10220 10227 int 10228 dxf_hatch_boundary_path_edge_ellipse_get_is_ccw 10229 ( 10230 DxfHatchBoundaryPathEdgeEllipse *ellipse 10233 ) 10234 { 10235 #if DEBUG 10236 DXF_DEBUG_BEGIN 10237 #endif 10238 int result; 10239 10240 /* Do some basic checks. */ 10241 if (ellipse == NULL) 10242 { 10243 fprintf (stderr, 10244 (_("Error in %s () a NULL pointer was passed.\n")), 10245 __FUNCTION__); 10246 return (EXIT_FAILURE); 10247 } 10248 if (ellipse->is_ccw < 0) 10249 { 10250 fprintf (stderr, 10251 (_("Warning in %s () a negative value was found in the is_ccw member.\n")), 10252 __FUNCTION__); 10253 } 10254 result = ellipse->is_ccw; 10255 #if DEBUG 10256 DXF_DEBUG_END 10257 #endif 10258 return (result); 10259 } 10260 10261 10266 DxfHatchBoundaryPathEdgeEllipse * 10267 dxf_hatch_boundary_path_edge_ellipse_set_is_ccw 10268 ( 10269 DxfHatchBoundaryPathEdgeEllipse *ellipse, 10272 int is_ccw 10274 ) 10275 { 10276 #if DEBUG 10277 DXF_DEBUG_BEGIN 10278 #endif 10279 /* Do some basic checks. */ 10280 if (ellipse == NULL) 10281 { 10282 fprintf (stderr, 10283 (_("Error in %s () a NULL pointer was passed.\n")), 10284 __FUNCTION__); 10285 return (NULL); 10286 } 10287 if (is_ccw < 0) 10288 { 10289 fprintf (stderr, 10290 (_("Warning in %s () a negative is_ccw value was passed.\n")), 10291 __FUNCTION__); 10292 } 10293 ellipse->is_ccw = is_ccw; 10294 #if DEBUG 10295 DXF_DEBUG_END 10296 #endif 10297 return (ellipse); 10298 } 10299 10300 10309 DxfHatchBoundaryPathEdgeEllipse * 10310 dxf_hatch_boundary_path_edge_ellipse_get_next 10311 ( 10312 DxfHatchBoundaryPathEdgeEllipse *ellipse 10315 ) 10316 { 10317 #if DEBUG 10318 DXF_DEBUG_BEGIN 10319 #endif 10320 DxfHatchBoundaryPathEdgeEllipse *result; 10321 10322 /* Do some basic checks. */ 10323 if (ellipse == NULL) 10324 { 10325 fprintf (stderr, 10326 (_("Error in %s () a NULL pointer was passed.\n")), 10327 __FUNCTION__); 10328 return (NULL); 10329 } 10330 if (ellipse->next == NULL) 10331 { 10332 fprintf (stderr, 10333 (_("Error in %s () a NULL pointer was found in the next member.\n")), 10334 __FUNCTION__); 10335 return (NULL); 10336 } 10337 result = (DxfHatchBoundaryPathEdgeEllipse *) ellipse->next; 10338 #if DEBUG 10339 DXF_DEBUG_END 10340 #endif 10341 return (result); 10342 } 10343 10344 10349 DxfHatchBoundaryPathEdgeEllipse * 10350 dxf_hatch_boundary_path_edge_ellipse_set_next 10351 ( 10352 DxfHatchBoundaryPathEdgeEllipse *ellipse, 10355 DxfHatchBoundaryPathEdgeEllipse *next 10358 ) 10359 { 10360 #if DEBUG 10361 DXF_DEBUG_BEGIN 10362 #endif 10363 /* Do some basic checks. */ 10364 if (ellipse == NULL) 10365 { 10366 fprintf (stderr, 10367 (_("Error in %s () a NULL pointer was passed.\n")), 10368 __FUNCTION__); 10369 return (NULL); 10370 } 10371 if (next == NULL) 10372 { 10373 fprintf (stderr, 10374 (_("Error in %s () a NULL pointer was passed.\n")), 10375 __FUNCTION__); 10376 return (NULL); 10377 } 10378 ellipse->next = (struct DxfHatchBoundaryPathEdgeEllipse *) next; 10379 #if DEBUG 10380 DXF_DEBUG_END 10381 #endif 10382 return (ellipse); 10383 } 10384 10385 10395 DxfHatchBoundaryPathEdgeEllipse * 10396 dxf_hatch_boundary_path_edge_ellipse_get_last 10397 ( 10398 DxfHatchBoundaryPathEdgeEllipse *ellipse 10401 ) 10402 { 10403 #if DEBUG 10404 DXF_DEBUG_BEGIN 10405 #endif 10406 /* Do some basic checks. */ 10407 if (ellipse == NULL) 10408 { 10409 fprintf (stderr, 10410 (_("Error in %s () a NULL pointer was passed.\n")), 10411 __FUNCTION__); 10412 return (NULL); 10413 } 10414 if (ellipse->next == NULL) 10415 { 10416 fprintf (stderr, 10417 (_("Warning in %s () a NULL pointer was found in the next member.\n")), 10418 __FUNCTION__); 10419 return ((DxfHatchBoundaryPathEdgeEllipse *) ellipse); 10420 } 10421 DxfHatchBoundaryPathEdgeEllipse *iter = (DxfHatchBoundaryPathEdgeEllipse *) ellipse->next; 10422 while (iter->next != NULL) 10423 { 10424 iter = (DxfHatchBoundaryPathEdgeEllipse *) iter->next; 10425 } 10426 #if DEBUG 10427 DXF_DEBUG_END 10428 #endif 10429 return ((DxfHatchBoundaryPathEdgeEllipse *) iter); 10430 } 10431 10432 10433 /* dxf_hatch_boundary_path_edge_line functions. */ 10434 10440 DxfHatchBoundaryPathEdgeLine * 10441 dxf_hatch_boundary_path_edge_line_new () 10442 { 10443 #if DEBUG 10444 DXF_DEBUG_BEGIN 10445 #endif 10446 DxfHatchBoundaryPathEdgeLine *line = NULL; 10447 size_t size; 10448 10449 size = sizeof (DxfHatchBoundaryPathEdgeLine); 10450 /* avoid malloc of 0 bytes */ 10451 if (size == 0) size = 1; 10452 if ((line = malloc (size)) == NULL) 10453 { 10454 fprintf (stderr, 10455 (_("Error in %s () could not allocate memory for a DxfHatchBoundaryPathEdgeLine struct.\n")), 10456 __FUNCTION__); 10457 line = NULL; 10458 } 10459 else 10460 { 10461 memset (line, 0, size); 10462 } 10463 #if DEBUG 10464 DXF_DEBUG_END 10465 #endif 10466 return (line); 10467 } 10468 10469 10477 DxfHatchBoundaryPathEdgeLine * 10478 dxf_hatch_boundary_path_edge_line_init 10479 ( 10480 DxfHatchBoundaryPathEdgeLine *line 10482 ) 10483 { 10484 #if DEBUG 10485 DXF_DEBUG_BEGIN 10486 #endif 10487 /* Do some basic checks. */ 10488 if (line == NULL) 10489 { 10490 fprintf (stderr, 10491 (_("Warning in %s () a NULL pointer was passed.\n")), 10492 __FUNCTION__); 10493 line = dxf_hatch_boundary_path_edge_line_new (); 10494 } 10495 if (line == NULL) 10496 { 10497 fprintf (stderr, 10498 (_("Error in %s () could not allocate memory for a DxfHatchBoundaryPathEdgeLine struct.\n")), 10499 __FUNCTION__); 10500 return (NULL); 10501 } 10502 line->id_code = 0; 10503 line->x0 = 0.0; 10504 line->y0 = 0.0; 10505 line->x1 = 0.0; 10506 line->y1 = 0.0; 10507 line->next = NULL; 10508 #if DEBUG 10509 DXF_DEBUG_END 10510 #endif 10511 return (line); 10512 } 10513 10514 10522 int 10523 dxf_hatch_boundary_path_edge_line_free 10524 ( 10525 DxfHatchBoundaryPathEdgeLine *line 10528 ) 10529 { 10530 #if DEBUG 10531 DXF_DEBUG_BEGIN 10532 #endif 10533 /* Do some basic checks. */ 10534 if (line == NULL) 10535 { 10536 fprintf (stderr, 10537 (_("Error in %s () a NULL pointer was passed.\n")), 10538 __FUNCTION__); 10539 return (EXIT_FAILURE); 10540 } 10541 if (line->next != NULL) 10542 { 10543 fprintf (stderr, 10544 (_("Error in %s () pointer to next was not NULL.\n")), 10545 __FUNCTION__); 10546 return (EXIT_FAILURE); 10547 } 10548 free (line); 10549 line = NULL; 10550 #if DEBUG 10551 DXF_DEBUG_END 10552 #endif 10553 return (EXIT_SUCCESS); 10554 } 10555 10556 10561 void 10562 dxf_hatch_boundary_path_edge_line_free_chain 10563 ( 10564 DxfHatchBoundaryPathEdgeLine *hatch_boundary_path_edge_lines 10567 ) 10568 { 10569 #ifdef DEBUG 10570 DXF_DEBUG_BEGIN 10571 #endif 10572 /* Do some basic checks. */ 10573 if (hatch_boundary_path_edge_lines == NULL) 10574 { 10575 fprintf (stderr, 10576 (_("Warning in %s () a NULL pointer was passed.\n")), 10577 __FUNCTION__); 10578 } 10579 while (hatch_boundary_path_edge_lines != NULL) 10580 { 10581 struct DxfHatchBoundaryPathEdgeLine *iter = hatch_boundary_path_edge_lines->next; 10582 dxf_hatch_boundary_path_edge_line_free (hatch_boundary_path_edge_lines); 10583 hatch_boundary_path_edge_lines = (DxfHatchBoundaryPathEdgeLine *) iter; 10584 } 10585 #if DEBUG 10586 DXF_DEBUG_END 10587 #endif 10588 } 10589 10590 10596 int 10597 dxf_hatch_boundary_path_edge_line_get_id_code 10598 ( 10599 DxfHatchBoundaryPathEdgeLine *line 10602 ) 10603 { 10604 #if DEBUG 10605 DXF_DEBUG_BEGIN 10606 #endif 10607 int result; 10608 10609 /* Do some basic checks. */ 10610 if (line == NULL) 10611 { 10612 fprintf (stderr, 10613 (_("Error in %s () a NULL pointer was passed.\n")), 10614 __FUNCTION__); 10615 return (EXIT_FAILURE); 10616 } 10617 if (line->id_code < 0) 10618 { 10619 fprintf (stderr, 10620 (_("Error in %s () a negative value was found in the id-code member.\n")), 10621 __FUNCTION__); 10622 return (EXIT_FAILURE); 10623 } 10624 result = line->id_code; 10625 #if DEBUG 10626 DXF_DEBUG_END 10627 #endif 10628 return (result); 10629 } 10630 10631 10635 DxfHatchBoundaryPathEdgeLine * 10636 dxf_hatch_boundary_path_edge_line_set_id_code 10637 ( 10638 DxfHatchBoundaryPathEdgeLine *line, 10641 int id_code 10645 ) 10646 { 10647 #if DEBUG 10648 DXF_DEBUG_BEGIN 10649 #endif 10650 /* Do some basic checks. */ 10651 if (line == NULL) 10652 { 10653 fprintf (stderr, 10654 (_("Error in %s () a NULL pointer was passed.\n")), 10655 __FUNCTION__); 10656 return (NULL); 10657 } 10658 if (id_code < 0) 10659 { 10660 fprintf (stderr, 10661 (_("Error in %s () a negative id-code value was passed.\n")), 10662 __FUNCTION__); 10663 return (NULL); 10664 } 10665 line->id_code = id_code; 10666 #if DEBUG 10667 DXF_DEBUG_END 10668 #endif 10669 return (line); 10670 } 10671 10672 10679 double 10680 dxf_hatch_boundary_path_edge_line_get_x0 10681 ( 10682 DxfHatchBoundaryPathEdgeLine *line 10684 ) 10685 { 10686 #if DEBUG 10687 DXF_DEBUG_BEGIN 10688 #endif 10689 double result; 10690 10691 /* Do some basic checks. */ 10692 if (line == NULL) 10693 { 10694 fprintf (stderr, 10695 (_("Error in %s () a NULL pointer was passed.\n")), 10696 __FUNCTION__); 10697 return (EXIT_FAILURE); 10698 } 10699 result = line->x0; 10700 #if DEBUG 10701 DXF_DEBUG_END 10702 #endif 10703 return (result); 10704 } 10705 10706 10711 DxfHatchBoundaryPathEdgeLine * 10712 dxf_hatch_boundary_path_edge_line_set_x0 10713 ( 10714 DxfHatchBoundaryPathEdgeLine *line, 10716 double x0 10719 ) 10720 { 10721 #if DEBUG 10722 DXF_DEBUG_BEGIN 10723 #endif 10724 /* Do some basic checks. */ 10725 if (line == NULL) 10726 { 10727 fprintf (stderr, 10728 (_("Error in %s () a NULL pointer was passed.\n")), 10729 __FUNCTION__); 10730 return (NULL); 10731 } 10732 line->x0 = x0; 10733 #if DEBUG 10734 DXF_DEBUG_END 10735 #endif 10736 return (line); 10737 } 10738 10739 10746 double 10747 dxf_hatch_boundary_path_edge_line_get_y0 10748 ( 10749 DxfHatchBoundaryPathEdgeLine *line 10751 ) 10752 { 10753 #if DEBUG 10754 DXF_DEBUG_BEGIN 10755 #endif 10756 double result; 10757 10758 /* Do some basic checks. */ 10759 if (line == NULL) 10760 { 10761 fprintf (stderr, 10762 (_("Error in %s () a NULL pointer was passed.\n")), 10763 __FUNCTION__); 10764 return (EXIT_FAILURE); 10765 } 10766 result = line->y0; 10767 #if DEBUG 10768 DXF_DEBUG_END 10769 #endif 10770 return (result); 10771 } 10772 10773 10778 DxfHatchBoundaryPathEdgeLine * 10779 dxf_hatch_boundary_path_edge_line_set_y0 10780 ( 10781 DxfHatchBoundaryPathEdgeLine *line, 10783 double y0 10786 ) 10787 { 10788 #if DEBUG 10789 DXF_DEBUG_BEGIN 10790 #endif 10791 /* Do some basic checks. */ 10792 if (line == NULL) 10793 { 10794 fprintf (stderr, 10795 (_("Error in %s () a NULL pointer was passed.\n")), 10796 __FUNCTION__); 10797 return (NULL); 10798 } 10799 line->y0 = y0; 10800 #if DEBUG 10801 DXF_DEBUG_END 10802 #endif 10803 return (line); 10804 } 10805 10806 10812 DxfPoint * 10813 dxf_hatch_boundary_path_edge_line_get_start_point 10814 ( 10815 DxfHatchBoundaryPathEdgeLine *line, 10817 int id_code 10821 ) 10822 { 10823 #ifdef DEBUG 10824 DXF_DEBUG_BEGIN 10825 #endif 10826 DxfPoint *p1 = NULL; 10827 10828 /* Do some basic checks. */ 10829 if (line == NULL) 10830 { 10831 fprintf (stderr, 10832 (_("Error in %s () a NULL pointer was passed.\n")), 10833 __FUNCTION__); 10834 return (NULL); 10835 } 10836 if ((line->x0 == line->x1) 10837 && (line->y0 == line->y1)) 10838 { 10839 fprintf (stderr, 10840 (_("Error in %s () a LINE with points with identical coordinates were passed.\n")), 10841 __FUNCTION__); 10842 return (NULL); 10843 } 10844 p1 = dxf_point_init (p1); 10845 if (p1 == NULL) 10846 { 10847 fprintf (stderr, 10848 (_("Error in %s () could not allocate memory for a DxfPoint struct.\n")), 10849 __FUNCTION__); 10850 return (NULL); 10851 } 10852 if (id_code < 0) 10853 { 10854 fprintf (stderr, 10855 (_("Warning in %s () passed id_code is smaller than 0.\n")), 10856 __FUNCTION__); 10857 } 10858 p1->id_code = id_code; 10859 p1->x0 = line->x0; 10860 p1->y0 = line->y0; 10861 #if DEBUG 10862 DXF_DEBUG_END 10863 #endif 10864 return (p1); 10865 } 10866 10867 10873 DxfHatchBoundaryPathEdgeLine * 10874 dxf_hatch_boundary_path_edge_line_set_start_point 10875 ( 10876 DxfHatchBoundaryPathEdgeLine *line, 10878 DxfPoint *point 10880 ) 10881 { 10882 #ifdef DEBUG 10883 DXF_DEBUG_BEGIN 10884 #endif 10885 /* Do some basic checks. */ 10886 if (line == NULL) 10887 { 10888 fprintf (stderr, 10889 (_("Error in %s () a NULL pointer was passed.\n")), 10890 __FUNCTION__); 10891 return (NULL); 10892 } 10893 if (point == NULL) 10894 { 10895 fprintf (stderr, 10896 (_("Error in %s () a NULL pointer was passed.\n")), 10897 __FUNCTION__); 10898 return (NULL); 10899 } 10900 line->x0 = point->x0; 10901 line->y0 = point->y0; 10902 #if DEBUG 10903 DXF_DEBUG_END 10904 #endif 10905 return (line); 10906 } 10907 10908 10915 double 10916 dxf_hatch_boundary_path_edge_line_get_x1 10917 ( 10918 DxfHatchBoundaryPathEdgeLine *line 10920 ) 10921 { 10922 #if DEBUG 10923 DXF_DEBUG_BEGIN 10924 #endif 10925 double result; 10926 10927 /* Do some basic checks. */ 10928 if (line == NULL) 10929 { 10930 fprintf (stderr, 10931 (_("Error in %s () a NULL pointer was passed.\n")), 10932 __FUNCTION__); 10933 return (EXIT_FAILURE); 10934 } 10935 result = line->x1; 10936 #if DEBUG 10937 DXF_DEBUG_END 10938 #endif 10939 return (result); 10940 } 10941 10942 10947 DxfHatchBoundaryPathEdgeLine * 10948 dxf_hatch_boundary_path_edge_line_set_x1 10949 ( 10950 DxfHatchBoundaryPathEdgeLine *line, 10952 double x1 10955 ) 10956 { 10957 #if DEBUG 10958 DXF_DEBUG_BEGIN 10959 #endif 10960 /* Do some basic checks. */ 10961 if (line == NULL) 10962 { 10963 fprintf (stderr, 10964 (_("Error in %s () a NULL pointer was passed.\n")), 10965 __FUNCTION__); 10966 return (NULL); 10967 } 10968 line->x1 = x1; 10969 #if DEBUG 10970 DXF_DEBUG_END 10971 #endif 10972 return (line); 10973 } 10974 10975 10982 double 10983 dxf_hatch_boundary_path_edge_line_get_y1 10984 ( 10985 DxfHatchBoundaryPathEdgeLine *line 10987 ) 10988 { 10989 #if DEBUG 10990 DXF_DEBUG_BEGIN 10991 #endif 10992 double result; 10993 10994 /* Do some basic checks. */ 10995 if (line == NULL) 10996 { 10997 fprintf (stderr, 10998 (_("Error in %s () a NULL pointer was passed.\n")), 10999 __FUNCTION__); 11000 return (EXIT_FAILURE); 11001 } 11002 result = line->y1; 11003 #if DEBUG 11004 DXF_DEBUG_END 11005 #endif 11006 return (result); 11007 } 11008 11009 11014 DxfHatchBoundaryPathEdgeLine * 11015 dxf_hatch_boundary_path_edge_line_set_y1 11016 ( 11017 DxfHatchBoundaryPathEdgeLine *line, 11019 double y1 11022 ) 11023 { 11024 #if DEBUG 11025 DXF_DEBUG_BEGIN 11026 #endif 11027 /* Do some basic checks. */ 11028 if (line == NULL) 11029 { 11030 fprintf (stderr, 11031 (_("Error in %s () a NULL pointer was passed.\n")), 11032 __FUNCTION__); 11033 return (NULL); 11034 } 11035 line->y1 = y1; 11036 #if DEBUG 11037 DXF_DEBUG_END 11038 #endif 11039 return (line); 11040 } 11041 11042 11048 DxfPoint * 11049 dxf_hatch_boundary_path_edge_line_get_end_point 11050 ( 11051 DxfHatchBoundaryPathEdgeLine *line, 11053 int id_code 11057 ) 11058 { 11059 #ifdef DEBUG 11060 DXF_DEBUG_BEGIN 11061 #endif 11062 DxfPoint *p2 = NULL; 11063 11064 /* Do some basic checks. */ 11065 if (line == NULL) 11066 { 11067 fprintf (stderr, 11068 (_("Error in %s () a NULL pointer was passed.\n")), 11069 __FUNCTION__); 11070 return (NULL); 11071 } 11072 if ((line->x0 == line->x1) 11073 && (line->y0 == line->y1)) 11074 { 11075 fprintf (stderr, 11076 (_("Error in %s () a line with endpoints with identical coordinates was passed.\n")), 11077 __FUNCTION__); 11078 return (NULL); 11079 } 11080 p2 = dxf_point_init (p2); 11081 if (p2 == NULL) 11082 { 11083 fprintf (stderr, 11084 (_("Error in %s () could not allocate memory for a DxfPoint struct.\n")), 11085 __FUNCTION__); 11086 return (NULL); 11087 } 11088 if (id_code < 0) 11089 { 11090 fprintf (stderr, 11091 (_("Warning in %s () passed id_code is smaller than 0.\n")), 11092 __FUNCTION__); 11093 } 11094 p2->id_code = id_code; 11095 p2->x0 = line->x1; 11096 p2->y0 = line->y1; 11097 #if DEBUG 11098 DXF_DEBUG_END 11099 #endif 11100 return (p2); 11101 } 11102 11103 11109 DxfHatchBoundaryPathEdgeLine * 11110 dxf_hatch_boundary_path_edge_line_set_end_point 11111 ( 11112 DxfHatchBoundaryPathEdgeLine *line, 11114 DxfPoint *point 11116 ) 11117 { 11118 #ifdef DEBUG 11119 DXF_DEBUG_BEGIN 11120 #endif 11121 /* Do some basic checks. */ 11122 if (line == NULL) 11123 { 11124 fprintf (stderr, 11125 (_("Error in %s () a NULL pointer was passed.\n")), 11126 __FUNCTION__); 11127 return (NULL); 11128 } 11129 if (point == NULL) 11130 { 11131 fprintf (stderr, 11132 (_("Error in %s () a NULL pointer was passed.\n")), 11133 __FUNCTION__); 11134 return (NULL); 11135 } 11136 line->x1 = point->x0; 11137 line->y1 = point->y0; 11138 #if DEBUG 11139 DXF_DEBUG_END 11140 #endif 11141 return (line); 11142 } 11143 11144 11153 DxfHatchBoundaryPathEdgeLine * 11154 dxf_hatch_boundary_path_edge_line_get_next 11155 ( 11156 DxfHatchBoundaryPathEdgeLine *line 11158 ) 11159 { 11160 #if DEBUG 11161 DXF_DEBUG_BEGIN 11162 #endif 11163 DxfHatchBoundaryPathEdgeLine *result; 11164 11165 /* Do some basic checks. */ 11166 if (line == NULL) 11167 { 11168 fprintf (stderr, 11169 (_("Error in %s () a NULL pointer was passed.\n")), 11170 __FUNCTION__); 11171 return (NULL); 11172 } 11173 if (line->next == NULL) 11174 { 11175 fprintf (stderr, 11176 (_("Error in %s () a NULL pointer was found in the next member.\n")), 11177 __FUNCTION__); 11178 return (NULL); 11179 } 11180 result = (DxfHatchBoundaryPathEdgeLine *) line->next; 11181 #if DEBUG 11182 DXF_DEBUG_END 11183 #endif 11184 return (result); 11185 } 11186 11187 11192 DxfHatchBoundaryPathEdgeLine * 11193 dxf_hatch_boundary_path_edge_line_set_next 11194 ( 11195 DxfHatchBoundaryPathEdgeLine *line, 11197 DxfHatchBoundaryPathEdgeLine *next 11200 ) 11201 { 11202 #if DEBUG 11203 DXF_DEBUG_BEGIN 11204 #endif 11205 /* Do some basic checks. */ 11206 if (line == NULL) 11207 { 11208 fprintf (stderr, 11209 (_("Error in %s () a NULL pointer was passed.\n")), 11210 __FUNCTION__); 11211 return (NULL); 11212 } 11213 if (next == NULL) 11214 { 11215 fprintf (stderr, 11216 (_("Error in %s () a NULL pointer was passed.\n")), 11217 __FUNCTION__); 11218 return (NULL); 11219 } 11220 line->next = (struct DxfHatchBoundaryPathEdgeLine *) next; 11221 #if DEBUG 11222 DXF_DEBUG_END 11223 #endif 11224 return (line); 11225 } 11226 11227 11236 DxfHatchBoundaryPathEdgeLine * 11237 dxf_hatch_boundary_path_edge_line_get_last 11238 ( 11239 DxfHatchBoundaryPathEdgeLine *line 11241 ) 11242 { 11243 #if DEBUG 11244 DXF_DEBUG_BEGIN 11245 #endif 11246 /* Do some basic checks. */ 11247 if (line == NULL) 11248 { 11249 fprintf (stderr, 11250 (_("Error in %s () a NULL pointer was passed.\n")), 11251 __FUNCTION__); 11252 return (NULL); 11253 } 11254 if (line->next == NULL) 11255 { 11256 fprintf (stderr, 11257 (_("Warning in %s () a NULL pointer was found in the next member.\n")), 11258 __FUNCTION__); 11259 return ((DxfHatchBoundaryPathEdgeLine *) line); 11260 } 11261 DxfHatchBoundaryPathEdgeLine *iter = (DxfHatchBoundaryPathEdgeLine *) line->next; 11262 while (iter->next != NULL) 11263 { 11264 iter = (DxfHatchBoundaryPathEdgeLine *) iter->next; 11265 } 11266 #if DEBUG 11267 DXF_DEBUG_END 11268 #endif 11269 return ((DxfHatchBoundaryPathEdgeLine *) iter); 11270 } 11271 11272 11273 /* dxf_hatch_boundary_path_edge_spline functions. */ 11274 11280 DxfHatchBoundaryPathEdgeSpline * 11281 dxf_hatch_boundary_path_edge_spline_new () 11282 { 11283 #if DEBUG 11284 DXF_DEBUG_BEGIN 11285 #endif 11286 DxfHatchBoundaryPathEdgeSpline *spline = NULL; 11287 size_t size; 11288 11289 size = sizeof (DxfHatchBoundaryPathEdgeSpline); 11290 /* avoid malloc of 0 bytes */ 11291 if (size == 0) size = 1; 11292 if ((spline = malloc (size)) == NULL) 11293 { 11294 fprintf (stderr, 11295 (_("Error in %s () could not allocate memory for a DxfHatchBoundaryPathEdgeSpline struct.\n")), 11296 __FUNCTION__); 11297 spline = NULL; 11298 } 11299 else 11300 { 11301 memset (spline, 0, size); 11302 } 11303 #if DEBUG 11304 DXF_DEBUG_END 11305 #endif 11306 return (spline); 11307 } 11308 11309 11317 DxfHatchBoundaryPathEdgeSpline * 11318 dxf_hatch_boundary_path_edge_spline_init 11319 ( 11320 DxfHatchBoundaryPathEdgeSpline *spline 11322 ) 11323 { 11324 #if DEBUG 11325 DXF_DEBUG_BEGIN 11326 #endif 11327 int i; 11328 11329 /* Do some basic checks. */ 11330 if (spline == NULL) 11331 { 11332 fprintf (stderr, 11333 (_("Warning in %s () a NULL pointer was passed.\n")), 11334 __FUNCTION__); 11335 spline = dxf_hatch_boundary_path_edge_spline_new (); 11336 } 11337 if (spline == NULL) 11338 { 11339 fprintf (stderr, 11340 (_("Error in %s () could not allocate memory for a DxfHatchBoundaryPathEdgeSpline struct.\n")), 11341 __FUNCTION__); 11342 return (NULL); 11343 } 11344 spline->id_code = 0; 11345 spline->degree = 0; 11346 spline->rational = 0; 11347 spline->periodic = 0; 11348 spline->number_of_knots = 0; 11349 for (i = 0; i >= DXF_MAX_HATCH_BOUNDARY_PATH_EDGE_SPLINE_KNOTS; i++) 11350 { 11351 spline->knots[i] = 0.0; 11352 } 11353 spline->number_of_control_points = 0; 11354 spline->control_points = NULL; 11355 spline->next = NULL; 11356 #if DEBUG 11357 DXF_DEBUG_END 11358 #endif 11359 return (spline); 11360 } 11361 11362 11370 int 11371 dxf_hatch_boundary_path_edge_spline_free 11372 ( 11373 DxfHatchBoundaryPathEdgeSpline *spline 11376 ) 11377 { 11378 #if DEBUG 11379 DXF_DEBUG_BEGIN 11380 #endif 11381 /* Do some basic checks. */ 11382 if (spline == NULL) 11383 { 11384 fprintf (stderr, 11385 (_("Error in %s () a NULL pointer was passed.\n")), 11386 __FUNCTION__); 11387 return (EXIT_FAILURE); 11388 } 11389 if (spline->next != NULL) 11390 { 11391 fprintf (stderr, 11392 (_("Error in %s () pointer to next was not NULL.\n")), 11393 __FUNCTION__); 11394 return (EXIT_FAILURE); 11395 } 11396 free (spline->control_points); 11397 free (spline); 11398 spline = NULL; 11399 #if DEBUG 11400 DXF_DEBUG_END 11401 #endif 11402 return (EXIT_SUCCESS); 11403 } 11404 11405 11410 void 11411 dxf_hatch_boundary_path_edge_spline_free_chain 11412 ( 11413 DxfHatchBoundaryPathEdgeSpline *hatch_boundary_path_edge_splines 11416 ) 11417 { 11418 #ifdef DEBUG 11419 DXF_DEBUG_BEGIN 11420 #endif 11421 /* Do some basic checks. */ 11422 if (hatch_boundary_path_edge_splines == NULL) 11423 { 11424 fprintf (stderr, 11425 (_("Warning in %s () a NULL pointer was passed.\n")), 11426 __FUNCTION__); 11427 } 11428 while (hatch_boundary_path_edge_splines != NULL) 11429 { 11430 struct DxfHatchBoundaryPathEdgeSpline *iter = hatch_boundary_path_edge_splines->next; 11431 dxf_hatch_boundary_path_edge_spline_free (hatch_boundary_path_edge_splines); 11432 hatch_boundary_path_edge_splines = (DxfHatchBoundaryPathEdgeSpline *) iter; 11433 } 11434 #if DEBUG 11435 DXF_DEBUG_END 11436 #endif 11437 } 11438 11439 11445 int 11446 dxf_hatch_boundary_path_edge_spline_get_id_code 11447 ( 11448 DxfHatchBoundaryPathEdgeSpline *spline 11451 ) 11452 { 11453 #if DEBUG 11454 DXF_DEBUG_BEGIN 11455 #endif 11456 int result; 11457 11458 /* Do some basic checks. */ 11459 if (spline == NULL) 11460 { 11461 fprintf (stderr, 11462 (_("Error in %s () a NULL pointer was passed.\n")), 11463 __FUNCTION__); 11464 return (EXIT_FAILURE); 11465 } 11466 if (spline->id_code < 0) 11467 { 11468 fprintf (stderr, 11469 (_("Error in %s () a negative value was found in the id_code member.\n")), 11470 __FUNCTION__); 11471 return (EXIT_FAILURE); 11472 } 11473 result = spline->id_code; 11474 #if DEBUG 11475 DXF_DEBUG_END 11476 #endif 11477 return (result); 11478 } 11479 11480 11484 DxfHatchBoundaryPathEdgeSpline * 11485 dxf_hatch_boundary_path_edge_spline_set_id_code 11486 ( 11487 DxfHatchBoundaryPathEdgeSpline *spline, 11490 int id_code 11494 ) 11495 { 11496 #if DEBUG 11497 DXF_DEBUG_BEGIN 11498 #endif 11499 /* Do some basic checks. */ 11500 if (spline == NULL) 11501 { 11502 fprintf (stderr, 11503 (_("Error in %s () a NULL pointer was passed.\n")), 11504 __FUNCTION__); 11505 return (NULL); 11506 } 11507 if (id_code < 0) 11508 { 11509 fprintf (stderr, 11510 (_("Error in %s () a negative id-code value was passed.\n")), 11511 __FUNCTION__); 11512 return (NULL); 11513 } 11514 spline->id_code = id_code; 11515 #if DEBUG 11516 DXF_DEBUG_END 11517 #endif 11518 return (spline); 11519 } 11520 11521 11527 int 11528 dxf_hatch_boundary_path_edge_spline_get_degree 11529 ( 11530 DxfHatchBoundaryPathEdgeSpline *spline 11533 ) 11534 { 11535 #if DEBUG 11536 DXF_DEBUG_BEGIN 11537 #endif 11538 int result; 11539 11540 /* Do some basic checks. */ 11541 if (spline == NULL) 11542 { 11543 fprintf (stderr, 11544 (_("Error in %s () a NULL pointer was passed.\n")), 11545 __FUNCTION__); 11546 return (EXIT_FAILURE); 11547 } 11548 if (spline->degree < 0) 11549 { 11550 fprintf (stderr, 11551 (_("Error in %s () a negative value was found in the degree member.\n")), 11552 __FUNCTION__); 11553 return (EXIT_FAILURE); 11554 } 11555 result = spline->degree; 11556 #if DEBUG 11557 DXF_DEBUG_END 11558 #endif 11559 return (result); 11560 } 11561 11562 11566 DxfHatchBoundaryPathEdgeSpline * 11567 dxf_hatch_boundary_path_edge_spline_set_degree 11568 ( 11569 DxfHatchBoundaryPathEdgeSpline *spline, 11572 int degree 11574 ) 11575 { 11576 #if DEBUG 11577 DXF_DEBUG_BEGIN 11578 #endif 11579 /* Do some basic checks. */ 11580 if (spline == NULL) 11581 { 11582 fprintf (stderr, 11583 (_("Error in %s () a NULL pointer was passed.\n")), 11584 __FUNCTION__); 11585 return (NULL); 11586 } 11587 if (degree < 0) 11588 { 11589 fprintf (stderr, 11590 (_("Error in %s () a negative degree value was passed.\n")), 11591 __FUNCTION__); 11592 return (NULL); 11593 } 11594 spline->degree = degree; 11595 #if DEBUG 11596 DXF_DEBUG_END 11597 #endif 11598 return (spline); 11599 } 11600 11601 11607 int 11608 dxf_hatch_boundary_path_edge_spline_get_rational 11609 ( 11610 DxfHatchBoundaryPathEdgeSpline *spline 11613 ) 11614 { 11615 #if DEBUG 11616 DXF_DEBUG_BEGIN 11617 #endif 11618 int result; 11619 11620 /* Do some basic checks. */ 11621 if (spline == NULL) 11622 { 11623 fprintf (stderr, 11624 (_("Error in %s () a NULL pointer was passed.\n")), 11625 __FUNCTION__); 11626 return (EXIT_FAILURE); 11627 } 11628 result = spline->rational; 11629 #if DEBUG 11630 DXF_DEBUG_END 11631 #endif 11632 return (result); 11633 } 11634 11635 11639 DxfHatchBoundaryPathEdgeSpline * 11640 dxf_hatch_boundary_path_edge_spline_set_rational 11641 ( 11642 DxfHatchBoundaryPathEdgeSpline *spline, 11645 int rational 11647 ) 11648 { 11649 #if DEBUG 11650 DXF_DEBUG_BEGIN 11651 #endif 11652 /* Do some basic checks. */ 11653 if (spline == NULL) 11654 { 11655 fprintf (stderr, 11656 (_("Error in %s () a NULL pointer was passed.\n")), 11657 __FUNCTION__); 11658 return (NULL); 11659 } 11660 spline->rational = rational; 11661 #if DEBUG 11662 DXF_DEBUG_END 11663 #endif 11664 return (spline); 11665 } 11666 11667 11673 int 11674 dxf_hatch_boundary_path_edge_spline_get_periodic 11675 ( 11676 DxfHatchBoundaryPathEdgeSpline *spline 11679 ) 11680 { 11681 #if DEBUG 11682 DXF_DEBUG_BEGIN 11683 #endif 11684 int result; 11685 11686 /* Do some basic checks. */ 11687 if (spline == NULL) 11688 { 11689 fprintf (stderr, 11690 (_("Error in %s () a NULL pointer was passed.\n")), 11691 __FUNCTION__); 11692 return (EXIT_FAILURE); 11693 } 11694 result = spline->periodic; 11695 #if DEBUG 11696 DXF_DEBUG_END 11697 #endif 11698 return (result); 11699 } 11700 11701 11705 DxfHatchBoundaryPathEdgeSpline * 11706 dxf_hatch_boundary_path_edge_spline_set_periodic 11707 ( 11708 DxfHatchBoundaryPathEdgeSpline *spline, 11711 int periodic 11713 ) 11714 { 11715 #if DEBUG 11716 DXF_DEBUG_BEGIN 11717 #endif 11718 /* Do some basic checks. */ 11719 if (spline == NULL) 11720 { 11721 fprintf (stderr, 11722 (_("Error in %s () a NULL pointer was passed.\n")), 11723 __FUNCTION__); 11724 return (NULL); 11725 } 11726 spline->periodic = periodic; 11727 #if DEBUG 11728 DXF_DEBUG_END 11729 #endif 11730 return (spline); 11731 } 11732 11733 11739 int 11740 dxf_hatch_boundary_path_edge_spline_get_number_of_knots 11741 ( 11742 DxfHatchBoundaryPathEdgeSpline *spline 11745 ) 11746 { 11747 #if DEBUG 11748 DXF_DEBUG_BEGIN 11749 #endif 11750 int result; 11751 11752 /* Do some basic checks. */ 11753 if (spline == NULL) 11754 { 11755 fprintf (stderr, 11756 (_("Error in %s () a NULL pointer was passed.\n")), 11757 __FUNCTION__); 11758 return (EXIT_FAILURE); 11759 } 11760 if (spline->number_of_knots < 0) 11761 { 11762 fprintf (stderr, 11763 (_("Error in %s () a negative number_of_knots value was found.\n")), 11764 __FUNCTION__); 11765 return (EXIT_FAILURE); 11766 } 11767 result = spline->number_of_knots; 11768 #if DEBUG 11769 DXF_DEBUG_END 11770 #endif 11771 return (result); 11772 } 11773 11774 11778 DxfHatchBoundaryPathEdgeSpline * 11779 dxf_hatch_boundary_path_edge_spline_set_number_of_knots 11780 ( 11781 DxfHatchBoundaryPathEdgeSpline *spline, 11784 int number_of_knots 11786 ) 11787 { 11788 #if DEBUG 11789 DXF_DEBUG_BEGIN 11790 #endif 11791 /* Do some basic checks. */ 11792 if (spline == NULL) 11793 { 11794 fprintf (stderr, 11795 (_("Error in %s () a NULL pointer was passed.\n")), 11796 __FUNCTION__); 11797 return (NULL); 11798 } 11799 if (number_of_knots < 0) 11800 { 11801 fprintf (stderr, 11802 (_("Error in %s () a negative number_of_knots value was passed.\n")), 11803 __FUNCTION__); 11804 return (NULL); 11805 } 11806 spline->number_of_knots = number_of_knots; 11807 #if DEBUG 11808 DXF_DEBUG_END 11809 #endif 11810 return (spline); 11811 } 11812 11813 11821 int 11822 dxf_hatch_boundary_path_edge_spline_get_knots 11823 ( 11824 DxfHatchBoundaryPathEdgeSpline *spline, 11827 double knots[DXF_MAX_HATCH_BOUNDARY_PATH_EDGE_SPLINE_KNOTS] 11829 ) 11830 { 11831 #if DEBUG 11832 DXF_DEBUG_BEGIN 11833 #endif 11834 int i; 11835 11836 /* Do some basic checks. */ 11837 if (spline == NULL) 11838 { 11839 fprintf (stderr, 11840 (_("Error in %s () a NULL pointer was passed.\n")), 11841 __FUNCTION__); 11842 return (EXIT_FAILURE); 11843 } 11844 for (i = 1; i < DXF_MAX_HATCH_BOUNDARY_PATH_EDGE_SPLINE_KNOTS; i++) 11845 { 11846 knots[i] = spline->knots[i]; 11847 } 11848 #if DEBUG 11849 DXF_DEBUG_END 11850 #endif 11851 return (EXIT_SUCCESS); 11852 } 11853 11854 11858 DxfHatchBoundaryPathEdgeSpline * 11859 dxf_hatch_boundary_path_edge_spline_set_knots 11860 ( 11861 DxfHatchBoundaryPathEdgeSpline *spline, 11864 double knots[DXF_MAX_HATCH_BOUNDARY_PATH_EDGE_SPLINE_KNOTS] 11867 ) 11868 { 11869 #if DEBUG 11870 DXF_DEBUG_BEGIN 11871 #endif 11872 int i; 11873 11874 /* Do some basic checks. */ 11875 if (spline == NULL) 11876 { 11877 fprintf (stderr, 11878 (_("Error in %s () a NULL pointer was passed.\n")), 11879 __FUNCTION__); 11880 return (NULL); 11881 } 11882 for (i = 1; i < DXF_MAX_HATCH_BOUNDARY_PATH_EDGE_SPLINE_KNOTS; i++) 11883 { 11884 if (&knots[i] == NULL) 11885 { 11886 fprintf (stderr, 11887 (_("Error in %s () a NULL pointer was found in the knots array at element %d.\n")), 11888 __FUNCTION__, i); 11889 return (NULL); 11890 } 11891 spline->knots[i] = knots[i]; 11892 } 11893 #if DEBUG 11894 DXF_DEBUG_END 11895 #endif 11896 return (spline); 11897 } 11898 11899 11905 int 11906 dxf_hatch_boundary_path_edge_spline_get_number_of_control_points 11907 ( 11908 DxfHatchBoundaryPathEdgeSpline *spline 11911 ) 11912 { 11913 #if DEBUG 11914 DXF_DEBUG_BEGIN 11915 #endif 11916 int result; 11917 11918 /* Do some basic checks. */ 11919 if (spline == NULL) 11920 { 11921 fprintf (stderr, 11922 (_("Error in %s () a NULL pointer was passed.\n")), 11923 __FUNCTION__); 11924 return (EXIT_FAILURE); 11925 } 11926 if (spline->number_of_control_points < 0) 11927 { 11928 fprintf (stderr, 11929 (_("Error in %s () a negative number_of_control_points value was found.\n")), 11930 __FUNCTION__); 11931 return (EXIT_FAILURE); 11932 } 11933 result = spline->number_of_control_points; 11934 #if DEBUG 11935 DXF_DEBUG_END 11936 #endif 11937 return (result); 11938 } 11939 11940 11945 DxfHatchBoundaryPathEdgeSpline * 11946 dxf_hatch_boundary_path_edge_spline_set_number_of_control_points 11947 ( 11948 DxfHatchBoundaryPathEdgeSpline *spline, 11951 int number_of_control_points 11953 ) 11954 { 11955 #if DEBUG 11956 DXF_DEBUG_BEGIN 11957 #endif 11958 /* Do some basic checks. */ 11959 if (spline == NULL) 11960 { 11961 fprintf (stderr, 11962 (_("Error in %s () a NULL pointer was passed.\n")), 11963 __FUNCTION__); 11964 return (NULL); 11965 } 11966 if (number_of_control_points < 0) 11967 { 11968 fprintf (stderr, 11969 (_("Error in %s () a negative number_of_control_points value was passed.\n")), 11970 __FUNCTION__); 11971 return (NULL); 11972 } 11973 spline->number_of_control_points = number_of_control_points; 11974 #if DEBUG 11975 DXF_DEBUG_END 11976 #endif 11977 return (spline); 11978 } 11979 11980 11988 DxfHatchBoundaryPathEdgeSplineCp * 11989 dxf_hatch_boundary_path_edge_spline_get_control_points 11990 ( 11991 DxfHatchBoundaryPathEdgeSpline *spline 11994 ) 11995 { 11996 #if DEBUG 11997 DXF_DEBUG_BEGIN 11998 #endif 11999 DxfHatchBoundaryPathEdgeSplineCp *result; 12000 12001 /* Do some basic checks. */ 12002 if (spline == NULL) 12003 { 12004 fprintf (stderr, 12005 (_("Error in %s () a NULL pointer was passed.\n")), 12006 __FUNCTION__); 12007 return (NULL); 12008 } 12009 result = (DxfHatchBoundaryPathEdgeSplineCp *) spline->control_points; 12010 #if DEBUG 12011 DXF_DEBUG_END 12012 #endif 12013 return (result); 12014 } 12015 12016 12021 DxfHatchBoundaryPathEdgeSpline * 12022 dxf_hatch_boundary_path_edge_spline_set_control_points 12023 ( 12024 DxfHatchBoundaryPathEdgeSpline *spline, 12027 DxfHatchBoundaryPathEdgeSplineCp *control_points 12029 ) 12030 { 12031 #if DEBUG 12032 DXF_DEBUG_BEGIN 12033 #endif 12034 /* Do some basic checks. */ 12035 if (spline == NULL) 12036 { 12037 fprintf (stderr, 12038 (_("Error in %s () a NULL pointer was passed.\n")), 12039 __FUNCTION__); 12040 return (NULL); 12041 } 12042 if (control_points == NULL) 12043 { 12044 fprintf (stderr, 12045 (_("Error in %s () a NULL pointer was passed.\n")), 12046 __FUNCTION__); 12047 return (NULL); 12048 } 12049 spline->control_points = (struct DxfHatchBoundaryPathEdgeSplineCp *) control_points; 12050 #if DEBUG 12051 DXF_DEBUG_END 12052 #endif 12053 return (spline); 12054 } 12055 12056 12119 int 12120 dxf_hatch_boundary_path_edge_spline_append_control_point 12121 ( 12122 DxfHatchBoundaryPathEdgeSpline *spline, 12124 DxfHatchBoundaryPathEdgeSplineCp *control_point 12127 ) 12128 { 12129 #if DEBUG 12130 DXF_DEBUG_BEGIN 12131 #endif 12132 /* Do some basic checks. */ 12133 if (spline == NULL) 12134 { 12135 fprintf (stderr, 12136 (_("Error in %s () received a NULL pointer value in dxf_hatch_boundary_path_edge_spline.\n")), 12137 __FUNCTION__); 12138 return (EXIT_FAILURE); 12139 } 12140 if (control_point == NULL) 12141 { 12142 fprintf (stderr, 12143 (_("Error in %s () received a NULL pointer value in dxf_hatch_boundary_path_edge_spline_cp.\n")), 12144 __FUNCTION__); 12145 return (EXIT_FAILURE); 12146 } 12147 if (sizeof (spline) < sizeof (DxfHatchBoundaryPathEdgeSpline)) 12148 { 12149 spline = realloc (spline, sizeof (DxfHatchBoundaryPathEdgeSpline)); 12150 } 12151 if (spline->control_points == NULL) 12152 { 12153 /* no control points yet, so append the first control 12154 * point. */ 12155 spline->control_points = (struct DxfHatchBoundaryPathEdgeSplineCp *) control_point; 12156 } 12157 else 12158 { 12159 /* iterate through all existing pointers to control 12160 * points until the pointer to the last control point 12161 * containing a NULL ponter in it's "next" member is 12162 * found. */ 12163 DxfHatchBoundaryPathEdgeSplineCp *iter = NULL; 12164 iter = dxf_hatch_boundary_path_edge_spline_control_point_new (); 12165 iter = (DxfHatchBoundaryPathEdgeSplineCp *) spline->control_points; 12166 for (;;) 12167 { 12168 iter = (DxfHatchBoundaryPathEdgeSplineCp *) iter->next; 12169 if (iter->next == NULL) 12170 { 12171 break; 12172 } 12173 } 12174 /* "iter" now contains the pointer to the last known 12175 * control point, now we can write the pointer to the 12176 * control point that has to be appended in the "next" 12177 * member. */ 12178 DxfHatchBoundaryPathEdgeSplineCp *new = NULL; 12179 new = dxf_hatch_boundary_path_edge_spline_control_point_new (); 12180 new->id_code = control_point->id_code; 12181 new->x0 = control_point->x0; 12182 new->y0 = control_point->y0; 12183 new->weight = control_point->weight; 12184 new->next = NULL; 12185 iter->next = (struct DxfHatchBoundaryPathEdgeSplineCp *) new; 12186 spline->number_of_control_points++; 12187 /* clean up. */ 12188 dxf_hatch_boundary_path_edge_spline_control_point_free (control_point); 12189 control_point = NULL; 12190 dxf_hatch_boundary_path_edge_spline_control_point_free (iter); 12191 } 12192 #if DEBUG 12193 DXF_DEBUG_END 12194 #endif 12195 return (EXIT_SUCCESS); 12196 } 12197 12198 12260 int 12261 dxf_hatch_boundary_path_edge_spline_prepend_control_point 12262 ( 12263 DxfHatchBoundaryPathEdgeSpline *spline, 12265 DxfHatchBoundaryPathEdgeSplineCp *control_point 12268 ) 12269 { 12270 #if DEBUG 12271 DXF_DEBUG_BEGIN 12272 #endif 12273 /* Do some basic checks. */ 12274 if (spline == NULL) 12275 { 12276 fprintf (stderr, 12277 (_("Error in %s () received a NULL pointer value in dxf_hatch_boundary_path_edge_spline.\n")), 12278 __FUNCTION__); 12279 return (EXIT_FAILURE); 12280 } 12281 if (control_point == NULL) 12282 { 12283 fprintf (stderr, 12284 (_("Error in %s () received a NULL pointer value in dxf_hatch_boundary_path_edge_spline_cp.\n")), 12285 __FUNCTION__); 12286 return (EXIT_FAILURE); 12287 } 12288 if (sizeof (spline) < sizeof (DxfHatchBoundaryPathEdgeSpline)) 12289 { 12290 spline = realloc (spline, sizeof (DxfHatchBoundaryPathEdgeSpline)); 12291 } 12292 if (spline->control_points == NULL) 12293 { 12294 /* no control points yet, so prepend the first control 12295 * point. */ 12296 DxfHatchBoundaryPathEdgeSplineCp *new = NULL; 12297 new = dxf_hatch_boundary_path_edge_spline_control_point_new (); 12298 new->id_code = control_point->id_code; 12299 new->x0 = control_point->x0; 12300 new->y0 = control_point->y0; 12301 new->weight = control_point->weight; 12302 new->next = NULL; 12303 spline->control_points = (struct DxfHatchBoundaryPathEdgeSplineCp *) new; 12304 } 12305 else 12306 { 12307 DxfHatchBoundaryPathEdgeSplineCp *new = NULL; 12308 new = dxf_hatch_boundary_path_edge_spline_control_point_new (); 12309 new->id_code = control_point->id_code; 12310 new->x0 = control_point->x0; 12311 new->y0 = control_point->y0; 12312 new->weight = control_point->weight; 12313 new->next = spline->control_points; 12314 spline->control_points = (struct DxfHatchBoundaryPathEdgeSplineCp *) new; 12315 } 12316 spline->number_of_control_points++; 12317 /* clean up. */ 12318 dxf_hatch_boundary_path_edge_spline_control_point_free (control_point); 12319 control_point = NULL; 12320 #if DEBUG 12321 DXF_DEBUG_END 12322 #endif 12323 return (EXIT_SUCCESS); 12324 } 12325 12326 12336 DxfHatchBoundaryPathEdgeSplineCp * 12337 dxf_hatch_boundary_path_edge_spline_get_control_point 12338 ( 12339 DxfHatchBoundaryPathEdgeSpline *spline, 12341 int position 12344 ) 12345 { 12346 #if DEBUG 12347 DXF_DEBUG_BEGIN 12348 #endif 12349 DxfHatchBoundaryPathEdgeSplineCp *control_point = NULL; 12350 int i; 12351 12352 /* Do some basic checks. */ 12353 if (spline == NULL) 12354 { 12355 fprintf (stderr, 12356 (_("Error in %s () received a NULL pointer value in dxf_hatch_boundary_path_edge_spline.\n")), 12357 __FUNCTION__); 12358 return (NULL); 12359 } 12360 if (position <= 0) 12361 { 12362 fprintf (stderr, 12363 (_("Error in %s () received an invalid value in position.\n")), 12364 __FUNCTION__); 12365 return (NULL); 12366 } 12367 if (sizeof (spline) < sizeof (DxfHatchBoundaryPathEdgeSpline)) 12368 { 12369 spline = realloc (spline, sizeof (DxfHatchBoundaryPathEdgeSpline)); 12370 } 12371 if (spline->number_of_control_points <= position) 12372 { 12373 fprintf (stderr, 12374 (_("Error in %s () position is greater than the number of control points.\n")), 12375 __FUNCTION__); 12376 return (NULL); 12377 } 12378 else 12379 { 12380 /* iterate through existing pointers to control points 12381 * until the pointer to the requested control point is 12382 * reached. */ 12383 DxfHatchBoundaryPathEdgeSplineCp *iter = NULL; 12384 control_point = dxf_hatch_boundary_path_edge_spline_control_point_new (); 12385 iter = dxf_hatch_boundary_path_edge_spline_control_point_new (); 12386 iter = (DxfHatchBoundaryPathEdgeSplineCp *) spline->control_points; 12387 for (i = 1; i <= position; i++) 12388 { 12389 iter = (DxfHatchBoundaryPathEdgeSplineCp *) iter->next; 12390 } 12391 /* "iter" now contains a pointer in "iter->next" to the 12392 * requested control point, now we can write the pointer 12393 * to control_point and return the pointer value. */ 12394 control_point = (DxfHatchBoundaryPathEdgeSplineCp *) iter->next; 12395 /* clean up. */ 12396 dxf_hatch_boundary_path_edge_spline_control_point_free (iter); 12397 } 12398 #if DEBUG 12399 DXF_DEBUG_END 12400 #endif 12401 return (control_point); 12402 } 12403 12404 12418 int 12419 dxf_hatch_boundary_path_edge_spline_set_control_point 12420 ( 12421 DxfHatchBoundaryPathEdgeSpline *spline, 12423 int position, 12426 DxfHatchBoundaryPathEdgeSplineCp *control_point 12429 ) 12430 { 12431 #if DEBUG 12432 DXF_DEBUG_BEGIN 12433 #endif 12434 int i; 12435 12436 /* Do some basic checks. */ 12437 if (spline == NULL) 12438 { 12439 fprintf (stderr, 12440 (_("Error in %s () received a NULL pointer value in dxf_hatch_boundary_path_edge_spline.\n")), 12441 __FUNCTION__); 12442 return (EXIT_FAILURE); 12443 } 12444 if (position <= 0) 12445 { 12446 fprintf (stderr, 12447 (_("Error in %s () received an invalid value in position.\n")), 12448 __FUNCTION__); 12449 return (EXIT_FAILURE); 12450 } 12451 if (control_point == NULL) 12452 { 12453 fprintf (stderr, 12454 (_("Error in %s () received a NULL pointer value in control_point.\n")), 12455 __FUNCTION__); 12456 return (EXIT_FAILURE); 12457 } 12458 if (sizeof (spline) < sizeof (DxfHatchBoundaryPathEdgeSpline)) 12459 { 12460 spline = realloc (spline, sizeof (DxfHatchBoundaryPathEdgeSpline)); 12461 } 12462 if (spline->number_of_control_points <= position) 12463 { 12464 fprintf (stderr, 12465 (_("Error in %s () position is greater than the number of control points.\n")), 12466 __FUNCTION__); 12467 return (EXIT_FAILURE); 12468 } 12469 if (spline->control_points == NULL) 12470 { 12471 /* no control points yet, so set at the first control 12472 * point pointer. */ 12473 DxfHatchBoundaryPathEdgeSplineCp *new = NULL; 12474 new = dxf_hatch_boundary_path_edge_spline_control_point_new (); 12475 new->id_code = control_point->id_code; 12476 new->x0 = control_point->x0; 12477 new->y0 = control_point->y0; 12478 new->weight = control_point->weight; 12479 new->next = NULL; 12480 spline->control_points = (struct DxfHatchBoundaryPathEdgeSplineCp *) new; 12481 } 12482 else 12483 { 12484 /* iterate through existing pointers to control points 12485 * until the pointer to the requested control point is 12486 * reached. */ 12487 DxfHatchBoundaryPathEdgeSplineCp *iter = NULL; 12488 iter = dxf_hatch_boundary_path_edge_spline_control_point_new (); 12489 iter = (DxfHatchBoundaryPathEdgeSplineCp *) spline->control_points; 12490 for (i = 1; i <= position; i++) 12491 { 12492 iter = (DxfHatchBoundaryPathEdgeSplineCp *) iter->next; 12493 } 12494 /* "iter" now contains a pointer in "iter->next" to the 12495 * requested control point, now we can write the pointer 12496 * to control_point and return the pointer value. */ 12497 DxfHatchBoundaryPathEdgeSplineCp *new = NULL; 12498 new = dxf_hatch_boundary_path_edge_spline_control_point_new (); 12499 new->id_code = control_point->id_code; 12500 new->x0 = control_point->x0; 12501 new->y0 = control_point->y0; 12502 new->weight = control_point->weight; 12503 new->next = NULL; 12504 iter->next = (struct DxfHatchBoundaryPathEdgeSplineCp *) new; 12505 /* clean up. */ 12506 dxf_hatch_boundary_path_edge_spline_control_point_free (iter); 12507 dxf_hatch_boundary_path_edge_spline_control_point_free (control_point); 12508 control_point = NULL; 12509 } 12510 #if DEBUG 12511 DXF_DEBUG_END 12512 #endif 12513 return (EXIT_SUCCESS); 12514 } 12515 12516 12586 int 12587 dxf_hatch_boundary_path_edge_spline_insert_control_point 12588 ( 12589 DxfHatchBoundaryPathEdgeSpline *spline, 12591 int position, 12594 DxfHatchBoundaryPathEdgeSplineCp *control_point 12597 ) 12598 { 12599 #if DEBUG 12600 DXF_DEBUG_BEGIN 12601 #endif 12602 int i; 12603 12604 /* Do some basic checks. */ 12605 if (spline == NULL) 12606 { 12607 fprintf (stderr, 12608 (_("Error in %s () received a NULL pointer value in dxf_hatch_boundary_path_edge_spline.\n")), 12609 __FUNCTION__); 12610 return (EXIT_FAILURE); 12611 } 12612 if (position <= 0) 12613 { 12614 fprintf (stderr, 12615 (_("Error in %s () received an invalid value in position.\n")), 12616 __FUNCTION__); 12617 return (EXIT_FAILURE); 12618 } 12619 if (position > DXF_MAX_HATCH_BOUNDARY_PATH_EDGE_SPLINE_KNOTS) 12620 { 12621 fprintf (stderr, 12622 (_("Error in %s () received a position greater than DXF_MAX_HATCH_BOUNDARY_PATH_EDGE_SPLINE_KNOTS.\n")), 12623 __FUNCTION__); 12624 return (EXIT_FAILURE); 12625 } 12626 if (control_point == NULL) 12627 { 12628 fprintf (stderr, 12629 (_("Error in %s () received a NULL pointer value in control_point.\n")), 12630 __FUNCTION__); 12631 return (EXIT_FAILURE); 12632 } 12633 if (spline->number_of_control_points <= position) 12634 { 12635 fprintf (stderr, 12636 (_("Error in %s () position is greater than the number of control points.\n")), 12637 __FUNCTION__); 12638 return (EXIT_FAILURE); 12639 } 12640 if (sizeof (spline) < sizeof (DxfHatchBoundaryPathEdgeSpline)) 12641 { 12642 spline = realloc (spline, sizeof (DxfHatchBoundaryPathEdgeSpline)); 12643 } 12644 if (spline->control_points == NULL) 12645 { 12646 /* no control points yet, so insert a copy of "cp" at 12647 * the first control point pointer. */ 12648 DxfHatchBoundaryPathEdgeSplineCp *new = NULL; 12649 new = dxf_hatch_boundary_path_edge_spline_control_point_new (); 12650 new->id_code = control_point->id_code; 12651 new->x0 = control_point->x0; 12652 new->y0 = control_point->y0; 12653 new->weight = control_point->weight; 12654 new->next = NULL; 12655 spline->control_points = (struct DxfHatchBoundaryPathEdgeSplineCp *) new; 12656 } 12657 else 12658 { 12659 DxfHatchBoundaryPathEdgeSplineCp *iter = NULL; 12660 DxfHatchBoundaryPathEdgeSplineCp *temp = NULL; 12661 iter = dxf_hatch_boundary_path_edge_spline_control_point_new (); 12662 temp = dxf_hatch_boundary_path_edge_spline_control_point_new (); 12663 /* iterate through existing pointers to control points 12664 * until the pointer to the requested control point is 12665 * reached. */ 12666 iter = (DxfHatchBoundaryPathEdgeSplineCp *) spline->control_points; 12667 for (i = 2; i <= position; i++) 12668 { 12669 iter = (DxfHatchBoundaryPathEdgeSplineCp *) iter->next; 12670 } 12671 /* "iter" now contains a pointer (in "iter->next") to 12672 * the control point with the requested position. 12673 * first we have to get a pointer to the next control 12674 * point "downward" (if any) of the position of the 12675 * requested control point and store this one in a 12676 * temporary variable. */ 12677 temp = (DxfHatchBoundaryPathEdgeSplineCp *) iter->next; 12678 if (temp == NULL) 12679 { 12680 /* "iter" points to the last control point, just 12681 * append a copy of "cp". */ 12682 DxfHatchBoundaryPathEdgeSplineCp *new = NULL; 12683 new = dxf_hatch_boundary_path_edge_spline_control_point_new (); 12684 new->id_code = control_point->id_code; 12685 new->x0 = control_point->x0; 12686 new->y0 = control_point->y0; 12687 new->weight = control_point->weight; 12688 new->next = NULL; 12689 iter->next = (struct DxfHatchBoundaryPathEdgeSplineCp *) new; 12690 } 12691 else 12692 { 12693 DxfHatchBoundaryPathEdgeSplineCp *new = NULL; 12694 new = dxf_hatch_boundary_path_edge_spline_control_point_new (); 12695 new->id_code = control_point->id_code; 12696 new->x0 = control_point->x0; 12697 new->y0 = control_point->y0; 12698 new->weight = control_point->weight; 12699 /* the next step is to connect the "downward chain" to 12700 * the to be inserted "control_point->next". */ 12701 new->next = temp->next; 12702 /* the final step is to connect the "upward chain" to 12703 * the to be inserted control point. */ 12704 temp = new; 12705 } 12706 /* clean up. */ 12707 dxf_hatch_boundary_path_edge_spline_control_point_free (control_point); 12708 control_point = NULL; 12709 dxf_hatch_boundary_path_edge_spline_control_point_free (iter); 12710 } 12711 #if DEBUG 12712 DXF_DEBUG_END 12713 #endif 12714 return (EXIT_SUCCESS); 12715 } 12716 12717 12728 int 12729 dxf_hatch_boundary_path_edge_spline_remove_control_point 12730 ( 12731 DxfHatchBoundaryPathEdgeSpline *spline, 12733 int position 12736 ) 12737 { 12738 #if DEBUG 12739 DXF_DEBUG_BEGIN 12740 #endif 12741 int i; 12742 12743 /* Do some basic checks. */ 12744 if (spline == NULL) 12745 { 12746 fprintf (stderr, 12747 (_("Error in %s () received a NULL pointer value in dxf_hatch_boundary_path_edge_spline.\n")), 12748 __FUNCTION__); 12749 return (EXIT_FAILURE); 12750 } 12751 if (position <= 0) 12752 { 12753 fprintf (stderr, 12754 (_("Error in %s () received an invalid value in position.\n")), 12755 __FUNCTION__); 12756 return (EXIT_FAILURE); 12757 } 12758 if (position >= DXF_MAX_HATCH_BOUNDARY_PATH_EDGE_SPLINE_KNOTS) 12759 { 12760 fprintf (stderr, 12761 (_("Error in %s () received a position greater than DXF_MAX_HATCH_BOUNDARY_PATH_EDGE_SPLINE_KNOTS.\n")), 12762 __FUNCTION__); 12763 return (EXIT_FAILURE); 12764 } 12765 if (spline->number_of_control_points <= position) 12766 { 12767 fprintf (stderr, 12768 (_("Error in %s () position is greater than the number of control points.\n")), 12769 __FUNCTION__); 12770 return (EXIT_FAILURE); 12771 } 12772 if (sizeof (spline) < sizeof (DxfHatchBoundaryPathEdgeSpline)) 12773 { 12774 spline = realloc (spline, sizeof (DxfHatchBoundaryPathEdgeSpline)); 12775 } 12776 if (spline->control_points == NULL) 12777 { 12778 /* no control points yet, so there is no control point to 12779 * remove. */ 12780 fprintf (stderr, 12781 (_("Error in %s () spline contins no control points.\n")), 12782 __FUNCTION__); 12783 return (EXIT_FAILURE); 12784 } 12785 else 12786 { 12787 DxfHatchBoundaryPathEdgeSplineCp *iter = NULL; 12788 DxfHatchBoundaryPathEdgeSplineCp *temp = NULL; 12789 iter = dxf_hatch_boundary_path_edge_spline_control_point_new (); 12790 temp = dxf_hatch_boundary_path_edge_spline_control_point_new (); 12791 /* iterate through existing pointers to control points 12792 * until the pointer to the requested control point is 12793 * reached. */ 12794 iter = (DxfHatchBoundaryPathEdgeSplineCp *) spline->control_points; 12795 for (i = 0; i <= (position - 1); i++) 12796 { 12797 iter = (DxfHatchBoundaryPathEdgeSplineCp *) iter->next; 12798 /* "iter" now contains a pointer to the control point 12799 * prior to the requested position (the requested 12800 * pointer is in "iter->next"). */ 12801 } 12802 /* first we have to get a pointer to the next control 12803 * point in the "downward chain" after the position 12804 * of the requested control point and store this one in 12805 * a temporary variable. */ 12806 temp = (DxfHatchBoundaryPathEdgeSplineCp *) iter->next; 12807 /* the next step is to connect the "downward chain" to 12808 * the the contol point before the requested control 12809 * point (the pointer to the last control point in the 12810 * "upward chain" is in "iter"). */ 12811 iter = (DxfHatchBoundaryPathEdgeSplineCp *) temp->next; 12812 /* clean up. */ 12813 dxf_hatch_boundary_path_edge_spline_control_point_free (iter); 12814 } 12815 #if DEBUG 12816 DXF_DEBUG_END 12817 #endif 12818 return (EXIT_SUCCESS); 12819 } 12820 12821 12913 DxfHatchBoundaryPathEdgeSplineCp * 12914 dxf_hatch_boundary_path_edge_spline_copy_control_points 12915 ( 12916 DxfHatchBoundaryPathEdgeSpline *spline 12919 ) 12920 { 12921 #if DEBUG 12922 DXF_DEBUG_BEGIN 12923 #endif 12924 DxfHatchBoundaryPathEdgeSplineCp *control_point = NULL; 12925 12926 /* Do some basic checks. */ 12927 if (spline == NULL) 12928 { 12929 fprintf (stderr, 12930 (_("Error in %s () received a NULL pointer value in dxf_hatch_boundary_path_edge_spline.\n")), 12931 __FUNCTION__); 12932 return (NULL); 12933 } 12934 if (sizeof (spline) < sizeof (DxfHatchBoundaryPathEdgeSpline)) 12935 { 12936 spline = realloc (spline, sizeof (DxfHatchBoundaryPathEdgeSpline)); 12937 } 12938 if (spline->control_points == NULL) 12939 { 12940 /* no control points yet, so there is no control point 12941 * to copy. */ 12942 fprintf (stderr, 12943 (_("Error in %s () spline contains no control points.\n")), 12944 __FUNCTION__); 12945 return (NULL); 12946 } 12947 else 12948 { 12949 /* iterate through all existing pointers to control 12950 * points until the pointer to the last control point 12951 * containing a NULL pointer in it's "next" member is 12952 * found. */ 12953 DxfHatchBoundaryPathEdgeSplineCp *iter = NULL; 12954 DxfHatchBoundaryPathEdgeSplineCp *iter_new = NULL; 12955 iter = dxf_hatch_boundary_path_edge_spline_control_point_new (); 12956 iter = (DxfHatchBoundaryPathEdgeSplineCp *) spline->control_points; 12957 iter_new = dxf_hatch_boundary_path_edge_spline_control_point_new (); 12958 control_point = iter_new; 12959 for (;;) 12960 { 12961 /* copy member contents into new control point. */ 12962 iter_new->id_code = iter->id_code; 12963 iter_new->x0 = iter->x0; 12964 iter_new->y0 = iter->y0; 12965 iter_new->weight = iter->weight; 12966 if (iter->next == NULL) 12967 { 12968 /* the last control point of the spline 12969 * is reached. */ 12970 iter_new->next = NULL; 12971 break; 12972 } 12973 else 12974 { 12975 /* create a new control point in the chain. */ 12976 iter_new->next = (struct DxfHatchBoundaryPathEdgeSplineCp *) dxf_hatch_boundary_path_edge_spline_control_point_new (); 12977 } 12978 /* set both iterators to the next control point 12979 * in their chain. */ 12980 iter = (DxfHatchBoundaryPathEdgeSplineCp *) iter->next; 12981 iter_new = (DxfHatchBoundaryPathEdgeSplineCp *) iter_new->next; 12982 } 12983 } 12984 #if DEBUG 12985 DXF_DEBUG_END 12986 #endif 12987 return (control_point); 12988 } 12989 12990 13002 int 13003 dxf_hatch_boundary_path_edge_spline_append_knot_value 13004 ( 13005 DxfHatchBoundaryPathEdgeSpline *spline, 13007 double knot_value 13009 ) 13010 { 13011 #if DEBUG 13012 DXF_DEBUG_BEGIN 13013 #endif 13014 /* Do some basic checks. */ 13015 if (spline == NULL) 13016 { 13017 fprintf (stderr, 13018 (_("Error in %s () received a NULL pointer value in dxf_hatch_boundary_path_edge_spline.\n")), 13019 __FUNCTION__); 13020 return (EXIT_FAILURE); 13021 } 13022 if ((spline->number_of_knots + 1) > DXF_MAX_HATCH_BOUNDARY_PATH_EDGE_SPLINE_KNOTS) 13023 { 13024 fprintf (stderr, 13025 (("Error in %s () resulted in a array pointer overflow.\n")), 13026 __FUNCTION__); 13027 return (EXIT_FAILURE); 13028 } 13029 spline->knots[spline->number_of_knots + 1] = knot_value; 13030 spline->number_of_knots++; 13031 #if DEBUG 13032 DXF_DEBUG_END 13033 #endif 13034 return (EXIT_SUCCESS); 13035 } 13036 13037 13049 int 13050 dxf_hatch_boundary_path_edge_spline_prepend_knot_value 13051 ( 13052 DxfHatchBoundaryPathEdgeSpline *spline, 13054 double knot_value 13056 ) 13057 { 13058 #if DEBUG 13059 DXF_DEBUG_BEGIN 13060 #endif 13061 int i; 13062 13063 /* Do some basic checks. */ 13064 if (spline == NULL) 13065 { 13066 fprintf (stderr, 13067 (_("Error in %s () received a NULL pointer value in dxf_hatch_boundary_path_edge_spline.\n")), 13068 __FUNCTION__); 13069 return (EXIT_FAILURE); 13070 } 13071 if ((spline->number_of_knots + 1) > DXF_MAX_HATCH_BOUNDARY_PATH_EDGE_SPLINE_KNOTS) 13072 { 13073 fprintf (stderr, 13074 (_("Error in %s () resulted in a array pointer overflow.\n")), 13075 __FUNCTION__); 13076 return (EXIT_FAILURE); 13077 } 13078 for (i = spline->number_of_knots; i > 0; i--) 13079 { 13080 spline->knots[i + 1] = spline->knots[i]; 13081 } 13082 spline->knots[0] = knot_value; 13083 spline->number_of_knots++; 13084 #if DEBUG 13085 DXF_DEBUG_END 13086 #endif 13087 return (EXIT_SUCCESS); 13088 } 13089 13090 13100 double 13101 dxf_hatch_boundary_path_edge_spline_get_knot_value 13102 ( 13103 DxfHatchBoundaryPathEdgeSpline *spline, 13105 int position 13107 ) 13108 { 13109 #if DEBUG 13110 DXF_DEBUG_BEGIN 13111 #endif 13112 double knot_value; 13113 13114 /* Do some basic checks. */ 13115 if (spline == NULL) 13116 { 13117 fprintf (stderr, 13118 (_("Error in %s () received a NULL pointer value in dxf_hatch_boundary_path_edge_spline.\n")), 13119 __FUNCTION__); 13120 return (EXIT_FAILURE); 13121 } 13122 if (position <= 0) 13123 { 13124 fprintf (stderr, 13125 (_("Error in %s () received an invalid value in position.\n")), 13126 __FUNCTION__); 13127 return (EXIT_FAILURE); 13128 } 13129 if (position > DXF_MAX_HATCH_BOUNDARY_PATH_EDGE_SPLINE_KNOTS) 13130 { 13131 fprintf (stderr, 13132 (_("Error in %s () received a position greater than DXF_MAX_HATCH_BOUNDARY_PATH_EDGE_SPLINE_KNOTS.\n")), 13133 __FUNCTION__); 13134 return (EXIT_FAILURE); 13135 } 13136 knot_value = spline->knots[position]; 13137 #if DEBUG 13138 DXF_DEBUG_END 13139 #endif 13140 return (knot_value); 13141 } 13142 13143 13153 int 13154 dxf_hatch_boundary_path_edge_spline_set_knot_value 13155 ( 13156 DxfHatchBoundaryPathEdgeSpline *spline, 13158 int position, 13160 double knot_value 13162 ) 13163 { 13164 #if DEBUG 13165 DXF_DEBUG_BEGIN 13166 #endif 13167 /* Do some basic checks. */ 13168 if (spline == NULL) 13169 { 13170 fprintf (stderr, 13171 (_("Error in %s () received a NULL pointer value in dxf_hatch_boundary_path_edge_spline.\n")), 13172 __FUNCTION__); 13173 return (EXIT_FAILURE); 13174 } 13175 if (position <= 0) 13176 { 13177 fprintf (stderr, 13178 (_("Error in %s () received an invalid value in position.\n")), 13179 __FUNCTION__); 13180 return (EXIT_FAILURE); 13181 } 13182 if (position > DXF_MAX_HATCH_BOUNDARY_PATH_EDGE_SPLINE_KNOTS) 13183 { 13184 fprintf (stderr, 13185 (_("Error in %s () received a position greater than DXF_MAX_HATCH_BOUNDARY_PATH_EDGE_SPLINE_KNOTS.\n")), 13186 __FUNCTION__); 13187 return (EXIT_FAILURE); 13188 } 13189 spline->knots[position] = knot_value; 13190 #if DEBUG 13191 DXF_DEBUG_END 13192 #endif 13193 return (EXIT_SUCCESS); 13194 } 13195 13196 13209 int 13210 dxf_hatch_boundary_path_edge_spline_insert_knot_value 13211 ( 13212 DxfHatchBoundaryPathEdgeSpline *spline, 13214 int position, 13216 double knot_value 13218 ) 13219 { 13220 #if DEBUG 13221 DXF_DEBUG_BEGIN 13222 #endif 13223 int i; 13224 13225 /* Do some basic checks. */ 13226 if (spline == NULL) 13227 { 13228 fprintf (stderr, 13229 (_("Error in %s () received a NULL pointer value in dxf_hatch_boundary_path_edge_spline.\n")), 13230 __FUNCTION__); 13231 return (EXIT_FAILURE); 13232 } 13233 if ((spline->number_of_knots + 1) > DXF_MAX_HATCH_BOUNDARY_PATH_EDGE_SPLINE_KNOTS) 13234 { 13235 fprintf (stderr, 13236 (_("Error in %s () resulted in a array pointer overflow.\n")), 13237 __FUNCTION__); 13238 return (EXIT_FAILURE); 13239 } 13240 if (position <= 0) 13241 { 13242 fprintf (stderr, 13243 (_("Error in %s () received an invalid value in position.\n")), 13244 __FUNCTION__); 13245 return (EXIT_FAILURE); 13246 } 13247 if (position >= DXF_MAX_HATCH_BOUNDARY_PATH_EDGE_SPLINE_KNOTS) 13248 { 13249 fprintf (stderr, 13250 (_("Error in %s () received a position greater than DXF_MAX_HATCH_BOUNDARY_PATH_EDGE_SPLINE_KNOTS.\n")), 13251 __FUNCTION__); 13252 return (EXIT_FAILURE); 13253 } 13254 for (i = spline->number_of_knots; i <= position; i--) 13255 { 13256 spline->knots[i + 1] = spline->knots[i]; 13257 } 13258 spline->knots[position] = knot_value; 13259 spline->number_of_knots++; 13260 #if DEBUG 13261 DXF_DEBUG_END 13262 #endif 13263 return (EXIT_SUCCESS); 13264 } 13265 13266 13278 int 13279 dxf_hatch_boundary_path_edge_spline_remove_knot_value 13280 ( 13281 DxfHatchBoundaryPathEdgeSpline *spline, 13283 int position 13285 ) 13286 { 13287 #if DEBUG 13288 DXF_DEBUG_BEGIN 13289 #endif 13290 int i; 13291 13292 /* Do some basic checks. */ 13293 if (spline == NULL) 13294 { 13295 fprintf (stderr, 13296 (_("Error in %s () received a NULL pointer value in dxf_hatch_boundary_path_edge_spline.\n")), 13297 __FUNCTION__); 13298 return (EXIT_FAILURE); 13299 } 13300 if (spline->number_of_knots > DXF_MAX_HATCH_BOUNDARY_PATH_EDGE_SPLINE_KNOTS) 13301 { 13302 fprintf (stderr, 13303 (_("Error in %s () resulted in a array pointer overflow.\n")), 13304 __FUNCTION__); 13305 return (EXIT_FAILURE); 13306 } 13307 if ((spline->number_of_knots - 1) < 0) 13308 { 13309 fprintf (stderr, 13310 (_("Error in %s () resulted in a array pointer underflow.\n")), 13311 __FUNCTION__); 13312 return (EXIT_FAILURE); 13313 } 13314 if (position <= 0) 13315 { 13316 fprintf (stderr, 13317 (_("Error in %s () received an invalid value in position.\n")), 13318 __FUNCTION__); 13319 return (EXIT_FAILURE); 13320 } 13321 if (position >= DXF_MAX_HATCH_BOUNDARY_PATH_EDGE_SPLINE_KNOTS) 13322 { 13323 fprintf (stderr, 13324 (_("Error in %s () received a position greater than DXF_MAX_HATCH_BOUNDARY_PATH_EDGE_SPLINE_KNOTS.\n")), 13325 __FUNCTION__); 13326 return (EXIT_FAILURE); 13327 } 13328 for (i = position; i >= spline->number_of_knots; i++) 13329 { 13330 spline->knots[i] = spline->knots[i + 1]; 13331 } 13332 spline->number_of_knots--; 13333 #if DEBUG 13334 DXF_DEBUG_END 13335 #endif 13336 return (EXIT_SUCCESS); 13337 } 13338 13339 13354 int 13355 dxf_hatch_boundary_path_edge_spline_copy_knot_values 13356 ( 13357 DxfHatchBoundaryPathEdgeSpline *spline, 13359 double *knot_values[DXF_MAX_HATCH_BOUNDARY_PATH_EDGE_SPLINE_KNOTS] 13361 ) 13362 { 13363 #if DEBUG 13364 DXF_DEBUG_BEGIN 13365 #endif 13366 int i; 13367 13368 /* Do some basic checks. */ 13369 if (spline == NULL) 13370 { 13371 fprintf (stderr, 13372 (_("Error in %s () received a NULL pointer value in dxf_hatch_boundary_path_edge_spline.\n")), 13373 __FUNCTION__); 13374 return (EXIT_FAILURE); 13375 } 13376 if (spline->number_of_knots > DXF_MAX_HATCH_BOUNDARY_PATH_EDGE_SPLINE_KNOTS) 13377 { 13378 fprintf (stderr, 13379 (_("Error in %s () resulted in a array pointer overflow.\n")), 13380 __FUNCTION__); 13381 return (EXIT_FAILURE); 13382 } 13383 for (i = 0; i < spline->number_of_knots; i++) 13384 { 13385 *knot_values[i] = spline->knots[i]; 13386 } 13387 #if DEBUG 13388 DXF_DEBUG_END 13389 #endif 13390 return (EXIT_SUCCESS); 13391 } 13392 13393 13402 DxfHatchBoundaryPathEdgeSpline * 13403 dxf_hatch_boundary_path_edge_spline_get_next 13404 ( 13405 DxfHatchBoundaryPathEdgeSpline *spline 13407 ) 13408 { 13409 #if DEBUG 13410 DXF_DEBUG_BEGIN 13411 #endif 13412 /* Do some basic checks. */ 13413 if (spline == NULL) 13414 { 13415 fprintf (stderr, 13416 (_("Error in %s () a NULL pointer was passed.\n")), 13417 __FUNCTION__); 13418 return (NULL); 13419 } 13420 if (spline->next == NULL) 13421 { 13422 fprintf (stderr, 13423 (_("Error in %s () a NULL pointer was found in the next member.\n")), 13424 __FUNCTION__); 13425 return (NULL); 13426 } 13427 #if DEBUG 13428 DXF_DEBUG_END 13429 #endif 13430 return ((DxfHatchBoundaryPathEdgeSpline *) spline->next); 13431 } 13432 13433 13438 DxfHatchBoundaryPathEdgeSpline * 13439 dxf_hatch_boundary_path_edge_spline_set_next 13440 ( 13441 DxfHatchBoundaryPathEdgeSpline *spline, 13443 DxfHatchBoundaryPathEdgeSpline *next 13445 ) 13446 { 13447 #if DEBUG 13448 DXF_DEBUG_BEGIN 13449 #endif 13450 /* Do some basic checks. */ 13451 if (spline == NULL) 13452 { 13453 fprintf (stderr, 13454 (_("Error in %s () a NULL pointer was passed.\n")), 13455 __FUNCTION__); 13456 return (NULL); 13457 } 13458 if (next == NULL) 13459 { 13460 fprintf (stderr, 13461 (_("Error in %s () a NULL pointer was passed.\n")), 13462 __FUNCTION__); 13463 return (NULL); 13464 } 13465 spline->next = (struct DxfHatchBoundaryPathEdgeSpline *) next; 13466 #if DEBUG 13467 DXF_DEBUG_END 13468 #endif 13469 return (spline); 13470 } 13471 13472 13481 DxfHatchBoundaryPathEdgeSpline * 13482 dxf_hatch_boundary_path_edge_spline_get_last 13483 ( 13484 DxfHatchBoundaryPathEdgeSpline *spline 13486 ) 13487 { 13488 #if DEBUG 13489 DXF_DEBUG_BEGIN 13490 #endif 13491 /* Do some basic checks. */ 13492 if (spline == NULL) 13493 { 13494 fprintf (stderr, 13495 (_("Error in %s () a NULL pointer was passed.\n")), 13496 __FUNCTION__); 13497 return (NULL); 13498 } 13499 if (spline->next == NULL) 13500 { 13501 fprintf (stderr, 13502 (_("Warning in %s () a NULL pointer was found in the next member.\n")), 13503 __FUNCTION__); 13504 return ((DxfHatchBoundaryPathEdgeSpline *) spline); 13505 } 13506 DxfHatchBoundaryPathEdgeSpline *iter = (DxfHatchBoundaryPathEdgeSpline *) spline->next; 13507 while (iter->next != NULL) 13508 { 13509 iter = (DxfHatchBoundaryPathEdgeSpline *) iter->next; 13510 } 13511 #if DEBUG 13512 DXF_DEBUG_END 13513 #endif 13514 return ((DxfHatchBoundaryPathEdgeSpline *) iter); 13515 } 13516 13517 13518 /* dxf_hatch_boundary_path_edge_splie_control_point functions. */ 13519 13526 DxfHatchBoundaryPathEdgeSplineCp * 13527 dxf_hatch_boundary_path_edge_spline_control_point_new () 13528 { 13529 #if DEBUG 13530 DXF_DEBUG_BEGIN 13531 #endif 13532 DxfHatchBoundaryPathEdgeSplineCp *control_point = NULL; 13533 size_t size; 13534 13535 size = sizeof (DxfHatchBoundaryPathEdgeSplineCp); 13536 /* avoid malloc of 0 bytes */ 13537 if (size == 0) size = 1; 13538 if ((control_point = malloc (size)) == NULL) 13539 { 13540 fprintf (stderr, 13541 (_("Error in %s () could not allocate memory for a DxfHatchBoundaryPathEdgeSplineCp struct.\n")), 13542 __FUNCTION__); 13543 control_point = NULL; 13544 } 13545 else 13546 { 13547 memset (control_point, 0, size); 13548 } 13549 #if DEBUG 13550 DXF_DEBUG_END 13551 #endif 13552 return (control_point); 13553 } 13554 13555 13563 DxfHatchBoundaryPathEdgeSplineCp * 13564 dxf_hatch_boundary_path_edge_spline_control_point_init 13565 ( 13566 DxfHatchBoundaryPathEdgeSplineCp *control_point 13568 ) 13569 { 13570 #if DEBUG 13571 DXF_DEBUG_BEGIN 13572 #endif 13573 /* Do some basic checks. */ 13574 if (control_point == NULL) 13575 { 13576 fprintf (stderr, 13577 (_("Warning in %s () a NULL pointer was passed.\n")), 13578 __FUNCTION__); 13579 control_point = dxf_hatch_boundary_path_edge_spline_control_point_new (); 13580 } 13581 if (control_point == NULL) 13582 { 13583 fprintf (stderr, 13584 (_("Error in %s () could not allocate memory for a DxfHatchBoundaryPathEdgeSplineCp struct.\n")), 13585 __FUNCTION__); 13586 return (NULL); 13587 } 13588 control_point->id_code = 0; 13589 control_point->x0 = 0.0; 13590 control_point->y0 = 0.0; 13591 control_point->weight = 0.0; 13592 control_point->next = NULL; 13593 #if DEBUG 13594 DXF_DEBUG_END 13595 #endif 13596 return (control_point); 13597 } 13598 13599 13607 int 13608 dxf_hatch_boundary_path_edge_spline_control_point_free 13609 ( 13610 DxfHatchBoundaryPathEdgeSplineCp *control_point 13613 ) 13614 { 13615 #if DEBUG 13616 DXF_DEBUG_BEGIN 13617 #endif 13618 /* Do some basic checks. */ 13619 if (control_point == NULL) 13620 { 13621 fprintf (stderr, 13622 (_("Error in %s () a NULL pointer was passed.\n")), 13623 __FUNCTION__); 13624 return (EXIT_FAILURE); 13625 } 13626 if (control_point->next != NULL) 13627 { 13628 fprintf (stderr, 13629 (_("Error in %s () pointer to next was not NULL.\n")), 13630 __FUNCTION__); 13631 return (EXIT_FAILURE); 13632 } 13633 free (control_point); 13634 control_point = NULL; 13635 #if DEBUG 13636 DXF_DEBUG_END 13637 #endif 13638 return (EXIT_SUCCESS); 13639 } 13640 13641 13646 void 13647 dxf_hatch_boundary_path_edge_spline_control_point_free_chain 13648 ( 13649 DxfHatchBoundaryPathEdgeSplineCp *hatch_boundary_path_edge_spline_control_points 13652 ) 13653 { 13654 #ifdef DEBUG 13655 DXF_DEBUG_BEGIN 13656 #endif 13657 /* Do some basic checks. */ 13658 if (hatch_boundary_path_edge_spline_control_points == NULL) 13659 { 13660 fprintf (stderr, 13661 (_("Warning in %s () a NULL pointer was passed.\n")), 13662 __FUNCTION__); 13663 } 13664 while (hatch_boundary_path_edge_spline_control_points != NULL) 13665 { 13666 struct DxfHatchBoundaryPathEdgeSplineCp *iter = hatch_boundary_path_edge_spline_control_points->next; 13667 dxf_hatch_boundary_path_edge_spline_control_point_free (hatch_boundary_path_edge_spline_control_points); 13668 hatch_boundary_path_edge_spline_control_points = (DxfHatchBoundaryPathEdgeSplineCp *) iter; 13669 } 13670 #if DEBUG 13671 DXF_DEBUG_END 13672 #endif 13673 } 13674 13675 13682 int 13683 dxf_hatch_boundary_path_edge_spline_cp_get_id_code 13684 ( 13685 DxfHatchBoundaryPathEdgeSplineCp *control_point 13688 ) 13689 { 13690 #if DEBUG 13691 DXF_DEBUG_BEGIN 13692 #endif 13693 int result; 13694 13695 /* Do some basic checks. */ 13696 if (control_point == NULL) 13697 { 13698 fprintf (stderr, 13699 (_("Error in %s () a NULL pointer was passed.\n")), 13700 __FUNCTION__); 13701 return (EXIT_FAILURE); 13702 } 13703 if (control_point->id_code < 0) 13704 { 13705 fprintf (stderr, 13706 (_("Error in %s () a negative value was found in the id_code member.\n")), 13707 __FUNCTION__); 13708 return (EXIT_FAILURE); 13709 } 13710 result = control_point->id_code; 13711 #if DEBUG 13712 DXF_DEBUG_END 13713 #endif 13714 return (result); 13715 } 13716 13717 13722 DxfHatchBoundaryPathEdgeSplineCp * 13723 dxf_hatch_boundary_path_edge_spline_cp_set_id_code 13724 ( 13725 DxfHatchBoundaryPathEdgeSplineCp *control_point, 13728 int id_code 13732 ) 13733 { 13734 #if DEBUG 13735 DXF_DEBUG_BEGIN 13736 #endif 13737 /* Do some basic checks. */ 13738 if (control_point == NULL) 13739 { 13740 fprintf (stderr, 13741 (_("Error in %s () a NULL pointer was passed.\n")), 13742 __FUNCTION__); 13743 return (NULL); 13744 } 13745 if (id_code < 0) 13746 { 13747 fprintf (stderr, 13748 (_("Error in %s () a negative id-code value was passed.\n")), 13749 __FUNCTION__); 13750 return (NULL); 13751 } 13752 control_point->id_code = id_code; 13753 #if DEBUG 13754 DXF_DEBUG_END 13755 #endif 13756 return (control_point); 13757 } 13758 13759 13766 double 13767 dxf_hatch_boundary_path_edge_spline_cp_get_x0 13768 ( 13769 DxfHatchBoundaryPathEdgeSplineCp *control_point 13772 ) 13773 { 13774 #if DEBUG 13775 DXF_DEBUG_BEGIN 13776 #endif 13777 double result; 13778 13779 /* Do some basic checks. */ 13780 if (control_point == NULL) 13781 { 13782 fprintf (stderr, 13783 (_("Error in %s () a NULL pointer was passed.\n")), 13784 __FUNCTION__); 13785 return (EXIT_FAILURE); 13786 } 13787 result = control_point->x0; 13788 #if DEBUG 13789 DXF_DEBUG_END 13790 #endif 13791 return (result); 13792 } 13793 13794 13799 DxfHatchBoundaryPathEdgeSplineCp * 13800 dxf_hatch_boundary_path_edge_spline_cp_set_x0 13801 ( 13802 DxfHatchBoundaryPathEdgeSplineCp *control_point, 13805 double x0 13808 ) 13809 { 13810 #if DEBUG 13811 DXF_DEBUG_BEGIN 13812 #endif 13813 /* Do some basic checks. */ 13814 if (control_point == NULL) 13815 { 13816 fprintf (stderr, 13817 (_("Error in %s () a NULL pointer was passed.\n")), 13818 __FUNCTION__); 13819 return (NULL); 13820 } 13821 control_point->x0 = x0; 13822 #if DEBUG 13823 DXF_DEBUG_END 13824 #endif 13825 return (control_point); 13826 } 13827 13828 13835 double 13836 dxf_hatch_boundary_path_edge_spline_cp_get_y0 13837 ( 13838 DxfHatchBoundaryPathEdgeSplineCp *control_point 13841 ) 13842 { 13843 #if DEBUG 13844 DXF_DEBUG_BEGIN 13845 #endif 13846 double result; 13847 13848 /* Do some basic checks. */ 13849 if (control_point == NULL) 13850 { 13851 fprintf (stderr, 13852 (_("Error in %s () a NULL pointer was passed.\n")), 13853 __FUNCTION__); 13854 return (EXIT_FAILURE); 13855 } 13856 result = control_point->y0; 13857 #if DEBUG 13858 DXF_DEBUG_END 13859 #endif 13860 return (result); 13861 } 13862 13863 13868 DxfHatchBoundaryPathEdgeSplineCp * 13869 dxf_hatch_boundary_path_edge_spline_cp_set_y0 13870 ( 13871 DxfHatchBoundaryPathEdgeSplineCp *control_point, 13874 double y0 13877 ) 13878 { 13879 #if DEBUG 13880 DXF_DEBUG_BEGIN 13881 #endif 13882 /* Do some basic checks. */ 13883 if (control_point == NULL) 13884 { 13885 fprintf (stderr, 13886 (_("Error in %s () a NULL pointer was passed.\n")), 13887 __FUNCTION__); 13888 return (NULL); 13889 } 13890 control_point->y0 = y0; 13891 #if DEBUG 13892 DXF_DEBUG_END 13893 #endif 13894 return (control_point); 13895 } 13896 13897 13904 DxfPoint * 13905 dxf_hatch_boundary_path_edge_spline_cp_get_point 13906 ( 13907 DxfHatchBoundaryPathEdgeSplineCp *control_point, 13910 int id_code 13914 ) 13915 { 13916 #ifdef DEBUG 13917 DXF_DEBUG_BEGIN 13918 #endif 13919 DxfPoint *p1 = NULL; 13920 13921 /* Do some basic checks. */ 13922 if (control_point == NULL) 13923 { 13924 fprintf (stderr, 13925 (_("Error in %s () a NULL pointer was passed.\n")), 13926 __FUNCTION__); 13927 return (NULL); 13928 } 13929 p1 = dxf_point_init (p1); 13930 if (p1 == NULL) 13931 { 13932 fprintf (stderr, 13933 (_("Error in %s () could not allocate memory for a DxfPoint struct.\n")), 13934 __FUNCTION__); 13935 return (NULL); 13936 } 13937 if (id_code < 0) 13938 { 13939 fprintf (stderr, 13940 (_("Warning in %s () passed id_code is smaller than 0.\n")), 13941 __FUNCTION__); 13942 } 13943 p1->id_code = id_code; 13944 p1->x0 = control_point->x0; 13945 p1->y0 = control_point->y0; 13946 #if DEBUG 13947 DXF_DEBUG_END 13948 #endif 13949 return (p1); 13950 } 13951 13952 13960 DxfHatchBoundaryPathEdgeSplineCp * 13961 dxf_hatch_boundary_path_edge_spline_cp_set_point 13962 ( 13963 DxfHatchBoundaryPathEdgeSplineCp *control_point, 13966 DxfPoint *point 13968 ) 13969 { 13970 #ifdef DEBUG 13971 DXF_DEBUG_BEGIN 13972 #endif 13973 /* Do some basic checks. */ 13974 if (control_point == NULL) 13975 { 13976 fprintf (stderr, 13977 (_("Error in %s () a NULL pointer was passed.\n")), 13978 __FUNCTION__); 13979 return (NULL); 13980 } 13981 if (point == NULL) 13982 { 13983 fprintf (stderr, 13984 (_("Error in %s () a NULL pointer was passed.\n")), 13985 __FUNCTION__); 13986 return (NULL); 13987 } 13988 control_point->x0 = point->x0; 13989 control_point->y0 = point->y0; 13990 #if DEBUG 13991 DXF_DEBUG_END 13992 #endif 13993 return (control_point); 13994 } 13995 13996 14003 double 14004 dxf_hatch_boundary_path_edge_spline_cp_get_weight 14005 ( 14006 DxfHatchBoundaryPathEdgeSplineCp *control_point 14009 ) 14010 { 14011 #if DEBUG 14012 DXF_DEBUG_BEGIN 14013 #endif 14014 double result; 14015 14016 /* Do some basic checks. */ 14017 if (control_point == NULL) 14018 { 14019 fprintf (stderr, 14020 (_("Error in %s () received a NULL pointer value in dxf_hatch_boundary_path_edge_spline.\n")), 14021 __FUNCTION__); 14022 return (EXIT_FAILURE); 14023 } 14024 result = control_point->weight; 14025 #if DEBUG 14026 DXF_DEBUG_END 14027 #endif 14028 return (result); 14029 } 14030 14031 14039 DxfHatchBoundaryPathEdgeSplineCp * 14040 dxf_hatch_boundary_path_edge_spline_cp_set_weight 14041 ( 14042 DxfHatchBoundaryPathEdgeSplineCp *control_point, 14045 double weight 14047 ) 14048 { 14049 #if DEBUG 14050 DXF_DEBUG_BEGIN 14051 #endif 14052 /* Do some basic checks. */ 14053 if (control_point == NULL) 14054 { 14055 fprintf (stderr, 14056 (_("Error in %s () received a NULL pointer value in dxf_hatch_boundary_path_edge_spline.\n")), 14057 __FUNCTION__); 14058 return (NULL); 14059 } 14060 control_point->weight = weight; 14061 #if DEBUG 14062 DXF_DEBUG_END 14063 #endif 14064 return (control_point); 14065 } 14066 14067 14077 DxfHatchBoundaryPathEdgeSplineCp * 14078 dxf_hatch_boundary_path_edge_spline_cp_get_next 14079 ( 14080 DxfHatchBoundaryPathEdgeSplineCp *control_point 14083 ) 14084 { 14085 #if DEBUG 14086 DXF_DEBUG_BEGIN 14087 #endif 14088 DxfHatchBoundaryPathEdgeSplineCp *result; 14089 14090 /* Do some basic checks. */ 14091 if (control_point == NULL) 14092 { 14093 fprintf (stderr, 14094 (_("Error in %s () a NULL pointer was passed.\n")), 14095 __FUNCTION__); 14096 return (NULL); 14097 } 14098 if (control_point->next == NULL) 14099 { 14100 fprintf (stderr, 14101 (_("Error in %s () a NULL pointer was found in the next member.\n")), 14102 __FUNCTION__); 14103 return (NULL); 14104 } 14105 result = (DxfHatchBoundaryPathEdgeSplineCp *) control_point->next; 14106 #if DEBUG 14107 DXF_DEBUG_END 14108 #endif 14109 return (result); 14110 } 14111 14112 14118 DxfHatchBoundaryPathEdgeSplineCp * 14119 dxf_hatch_boundary_path_edge_spline_cp_set_next 14120 ( 14121 DxfHatchBoundaryPathEdgeSplineCp *control_point, 14124 DxfHatchBoundaryPathEdgeSplineCp *next 14127 ) 14128 { 14129 #if DEBUG 14130 DXF_DEBUG_BEGIN 14131 #endif 14132 /* Do some basic checks. */ 14133 if (control_point == NULL) 14134 { 14135 fprintf (stderr, 14136 (_("Error in %s () a NULL pointer was passed.\n")), 14137 __FUNCTION__); 14138 return (NULL); 14139 } 14140 if (next == NULL) 14141 { 14142 fprintf (stderr, 14143 (_("Error in %s () a NULL pointer was passed.\n")), 14144 __FUNCTION__); 14145 return (NULL); 14146 } 14147 control_point->next = (struct DxfHatchBoundaryPathEdgeSplineCp *) next; 14148 #if DEBUG 14149 DXF_DEBUG_END 14150 #endif 14151 return (control_point); 14152 } 14153 14154 14165 DxfHatchBoundaryPathEdgeSplineCp * 14166 dxf_hatch_boundary_path_edge_spline_cp_get_last 14167 ( 14168 DxfHatchBoundaryPathEdgeSplineCp *control_point 14171 ) 14172 { 14173 #if DEBUG 14174 DXF_DEBUG_BEGIN 14175 #endif 14176 /* Do some basic checks. */ 14177 if (control_point == NULL) 14178 { 14179 fprintf (stderr, 14180 (_("Error in %s () a NULL pointer was passed.\n")), 14181 __FUNCTION__); 14182 return (NULL); 14183 } 14184 if (control_point->next == NULL) 14185 { 14186 fprintf (stderr, 14187 (_("Warning in %s () a NULL pointer was found in the next member.\n")), 14188 __FUNCTION__); 14189 return ((DxfHatchBoundaryPathEdgeSplineCp *) control_point); 14190 } 14191 DxfHatchBoundaryPathEdgeSplineCp *iter = (DxfHatchBoundaryPathEdgeSplineCp *) control_point->next; 14192 while (iter->next != NULL) 14193 { 14194 iter = (DxfHatchBoundaryPathEdgeSplineCp *) iter->next; 14195 } 14196 #if DEBUG 14197 DXF_DEBUG_END 14198 #endif 14199 return ((DxfHatchBoundaryPathEdgeSplineCp *) iter); 14200 } 14201 14202 14203 /* EOF */