libDXF 0.0.1
A library with DXF related functions written in C.

line.c

Go to the documentation of this file.
00001 
00042 #include "line.h"
00043 
00044 
00053 DxfLine *
00054 dxf_line_new ()
00055 {
00056 #if DEBUG
00057         DXF_DEBUG_BEGIN
00058 #endif
00059         DxfLine *line = NULL;
00060         size_t size;
00061 
00062         size = sizeof (DxfLine);
00063         /* avoid malloc of 0 bytes */
00064         if (size == 0) size = 1;
00065         if ((line = malloc (size)) == NULL)
00066         {
00067                 fprintf (stderr,
00068                   (_("Error in %s () could not allocate memory for a DxfLine struct.\n")),
00069                   __FUNCTION__);
00070                 line = NULL;
00071         }
00072         else
00073         {
00074                 memset (line, 0, size);
00075         }
00076 #if DEBUG
00077         DXF_DEBUG_END
00078 #endif
00079         return (line);
00080 }
00081 
00082 
00090 DxfLine *
00091 dxf_line_init
00092 (
00093         DxfLine *line
00095 )
00096 {
00097 #if DEBUG
00098         DXF_DEBUG_BEGIN
00099 #endif
00100         /* Do some basic checks. */
00101         if (line == NULL)
00102         {
00103                 fprintf (stderr,
00104                   (_("Warning in %s () a NULL pointer was passed.\n")),
00105                   __FUNCTION__);
00106                 line = dxf_line_new ();
00107         }
00108         if (line == NULL)
00109         {
00110               fprintf (stderr,
00111                 (_("Error in %s () could not allocate memory for a DxfLine struct.\n")),
00112                 __FUNCTION__);
00113               return (NULL);
00114         }
00115         dxf_line_set_id_code (line, 0);
00116         dxf_line_set_linetype (line, strdup (DXF_DEFAULT_LINETYPE));
00117         dxf_line_set_layer (line, strdup (DXF_DEFAULT_LAYER));
00118         dxf_line_set_elevation (line, 0.0);
00119         dxf_line_set_thickness (line, 0.0);
00120         dxf_line_set_linetype_scale (line, DXF_DEFAULT_LINETYPE_SCALE);
00121         dxf_line_set_visibility (line, DXF_DEFAULT_VISIBILITY);
00122         dxf_line_set_color (line, DXF_COLOR_BYLAYER);
00123         dxf_line_set_paperspace (line, DXF_MODELSPACE);
00124         dxf_line_set_graphics_data_size (line, 0);
00125         dxf_line_set_shadow_mode (line, 0);
00126         dxf_line_set_binary_graphics_data (line, (DxfBinaryGraphicsData *) dxf_binary_graphics_data_new());
00127         dxf_line_set_dictionary_owner_soft (line, strdup (""));
00128         dxf_line_set_material (line, strdup (""));
00129         dxf_line_set_dictionary_owner_hard (line, strdup (""));
00130         dxf_line_set_lineweight (line, 0);
00131         dxf_line_set_plot_style_name (line, strdup (""));
00132         dxf_line_set_color_value (line, 0);
00133         dxf_line_set_color_name (line, strdup (""));
00134         dxf_line_set_transparency (line, 0);
00135         dxf_line_set_p0 (line, (DxfPoint *) dxf_point_new());
00136         dxf_point_init ((DxfPoint *) dxf_line_get_p0 (line));
00137         dxf_line_set_x0 (line, 0.0);
00138         dxf_line_set_y0 (line, 0.0);
00139         dxf_line_set_z0 (line, 0.0);
00140         dxf_line_set_p1 (line, (DxfPoint *) dxf_point_new());
00141         dxf_point_init ((DxfPoint *) dxf_line_get_p0 (line));
00142         dxf_line_set_x1 (line, 0.0);
00143         dxf_line_set_y1 (line, 0.0);
00144         dxf_line_set_z1 (line, 0.0);
00145         dxf_line_set_extr_x0 (line, 0.0);
00146         dxf_line_set_extr_y0 (line, 0.0);
00147         dxf_line_set_extr_z0 (line, 0.0);
00148         dxf_line_set_next (line, NULL);
00149 #if DEBUG
00150         DXF_DEBUG_END
00151 #endif
00152         return (line);
00153 }
00154 
00155 
00167 DxfLine *
00168 dxf_line_read
00169 (
00170         DxfFile *fp,
00172         DxfLine *line
00174 )
00175 {
00176 #if DEBUG
00177         DXF_DEBUG_BEGIN
00178 #endif
00179         char *temp_string = NULL;
00180 
00181         /* Do some basic checks. */
00182         if (fp == NULL)
00183         {
00184                 fprintf (stderr,
00185                   (_("Error in %s () a NULL file pointer was passed.\n")),
00186                   __FUNCTION__);
00187                 /* Clean up. */
00188                 free (temp_string);
00189                 return (NULL);
00190         }
00191         if (line == NULL)
00192         {
00193                 fprintf (stderr,
00194                   (_("Warning in %s () a NULL pointer was passed.\n")),
00195                   __FUNCTION__);
00196                 line = dxf_line_new ();
00197                 line = dxf_line_init (line);
00198         }
00199         (fp->line_number)++;
00200         fscanf (fp->fp, "%[^\n]", temp_string);
00201         while (strcmp (temp_string, "0") != 0)
00202         {
00203                 if (ferror (fp->fp))
00204                 {
00205                         fprintf (stderr,
00206                           (_("Error in %s () while reading from: %s in line: %d.\n")),
00207                           __FUNCTION__, fp->filename, fp->line_number);
00208                         fclose (fp->fp);
00209                         /* Clean up. */
00210                         free (temp_string);
00211                         return (NULL);
00212                 }
00213                 if (strcmp (temp_string, "5") == 0)
00214                 {
00215                         /* Now follows a string containing a sequential
00216                          * id number. */
00217                         (fp->line_number)++;
00218                         fscanf (fp->fp, "%x\n", &line->id_code);
00219                 }
00220                 else if (strcmp (temp_string, "6") == 0)
00221                 {
00222                         /* Now follows a string containing a linetype
00223                          * name. */
00224                         (fp->line_number)++;
00225                         fscanf (fp->fp, "%s\n", line->linetype);
00226                 }
00227                 else if (strcmp (temp_string, "8") == 0)
00228                 {
00229                         /* Now follows a string containing a layer name. */
00230                         (fp->line_number)++;
00231                         fscanf (fp->fp, "%s\n", line->layer);
00232                 }
00233                 else if (strcmp (temp_string, "10") == 0)
00234                 {
00235                         /* Now follows a string containing the
00236                          * X-coordinate of the start point. */
00237                         (fp->line_number)++;
00238                         fscanf (fp->fp, "%lf\n", &line->p0->x0);
00239                 }
00240                 else if (strcmp (temp_string, "20") == 0)
00241                 {
00242                         /* Now follows a string containing the
00243                          * Y-coordinate of the start point. */
00244                         (fp->line_number)++;
00245                         fscanf (fp->fp, "%lf\n", &line->p0->y0);
00246                 }
00247                 else if (strcmp (temp_string, "30") == 0)
00248                 {
00249                         /* Now follows a string containing the
00250                          * Z-coordinate of the start point. */
00251                         (fp->line_number)++;
00252                         fscanf (fp->fp, "%lf\n", &line->p0->z0);
00253                 }
00254                 else if (strcmp (temp_string, "11") == 0)
00255                 {
00256                         /* Now follows a string containing the
00257                          * X-coordinate of the end point. */
00258                         (fp->line_number)++;
00259                         fscanf (fp->fp, "%lf\n", &line->p1->x0);
00260                 }
00261                 else if (strcmp (temp_string, "21") == 0)
00262                 {
00263                         /* Now follows a string containing the
00264                          * Y-coordinate of the end point. */
00265                         (fp->line_number)++;
00266                         fscanf (fp->fp, "%lf\n", &line->p1->y0);
00267                 }
00268                 else if (strcmp (temp_string, "31") == 0)
00269                 {
00270                         /* Now follows a string containing the
00271                          * Z-coordinate of the end point. */
00272                         (fp->line_number)++;
00273                         fscanf (fp->fp, "%lf\n", &line->p1->z0);
00274                 }
00275                 else if (strcmp (temp_string, "38") == 0)
00276                 {
00277                         /* Now follows a string containing the
00278                          * elevation. */
00279                         (fp->line_number)++;
00280                         fscanf (fp->fp, "%lf\n", &line->elevation);
00281                 }
00282                 else if (strcmp (temp_string, "39") == 0)
00283                 {
00284                         /* Now follows a string containing the
00285                          * thickness. */
00286                         (fp->line_number)++;
00287                         fscanf (fp->fp, "%lf\n", &line->thickness);
00288                 }
00289                 else if (strcmp (temp_string, "48") == 0)
00290                 {
00291                         /* Now follows a string containing the linetype
00292                          * scale. */
00293                         (fp->line_number)++;
00294                         fscanf (fp->fp, "%lf\n", &line->linetype_scale);
00295                 }
00296                 else if (strcmp (temp_string, "60") == 0)
00297                 {
00298                         /* Now follows a string containing the
00299                          * visibility value. */
00300                         (fp->line_number)++;
00301                         fscanf (fp->fp, "%hd\n", &line->visibility);
00302                 }
00303                 else if (strcmp (temp_string, "62") == 0)
00304                 {
00305                         /* Now follows a string containing the
00306                          * color value. */
00307                         (fp->line_number)++;
00308                         fscanf (fp->fp, "%d\n", &line->color);
00309                 }
00310                 else if (strcmp (temp_string, "67") == 0)
00311                 {
00312                         /* Now follows a string containing the
00313                          * paperspace value. */
00314                         (fp->line_number)++;
00315                         fscanf (fp->fp, "%d\n", &line->paperspace);
00316                 }
00317                 else if (strcmp (temp_string, "92") == 0)
00318                 {
00319                         /* Now follows a string containing the
00320                          * graphics data size value. */
00321                         (fp->line_number)++;
00322                         fscanf (fp->fp, "%d\n", &line->graphics_data_size);
00323                 }
00324                 else if (strcmp (temp_string, "100") == 0)
00325                 {
00326                         /* Now follows a string containing the
00327                          * subclass marker value. */
00328                         (fp->line_number)++;
00329                         fscanf (fp->fp, "%s\n", temp_string);
00330                         if ((strcmp (temp_string, "AcDbEntity") != 0)
00331                         && ((strcmp (temp_string, "AcDbLine") != 0)))
00332                         {
00333                                 fprintf (stderr,
00334                                   (_("Warning in %s () found a bad subclass marker in: %s in line: %d.\n")),
00335                                   __FUNCTION__, fp->filename, fp->line_number);
00336                         }
00337                 }
00338                 else if (strcmp (temp_string, "160") == 0)
00339                 {
00340                         /* Now follows a string containing the
00341                          * graphics data size value. */
00342                         (fp->line_number)++;
00343                         fscanf (fp->fp, "%d\n", &line->graphics_data_size);
00344                 }
00345                 else if (strcmp (temp_string, "210") == 0)
00346                 {
00347                         /* Now follows a string containing the
00348                          * X-value of the extrusion vector. */
00349                         (fp->line_number)++;
00350                         fscanf (fp->fp, "%lf\n", &line->extr_x0);
00351                 }
00352                 else if (strcmp (temp_string, "220") == 0)
00353                 {
00354                         /* Now follows a string containing the
00355                          * Y-value of the extrusion vector. */
00356                         (fp->line_number)++;
00357                         fscanf (fp->fp, "%lf\n", &line->extr_y0);
00358                 }
00359                 else if (strcmp (temp_string, "230") == 0)
00360                 {
00361                         /* Now follows a string containing the
00362                          * Z-value of the extrusion vector. */
00363                         (fp->line_number)++;
00364                         fscanf (fp->fp, "%lf\n", &line->extr_z0);
00365                 }
00366                 else if (strcmp (temp_string, "284") == 0)
00367                 {
00368                         /* Now follows a string containing the shadow
00369                          * mode value. */
00370                         (fp->line_number)++;
00371                         fscanf (fp->fp, "%hd\n", &line->shadow_mode);
00372                 }
00373                 else if (strcmp (temp_string, "310") == 0)
00374                 {
00375                         /* Now follows a string containing binary
00376                          * graphics data. */
00377                         (fp->line_number)++;
00378                         fscanf (fp->fp, "%s\n", line->binary_graphics_data->data_line);
00379                         dxf_binary_graphics_data_init ((DxfBinaryGraphicsData *) line->binary_graphics_data->next);
00380                         line->binary_graphics_data = (DxfBinaryGraphicsData *) line->binary_graphics_data->next;
00381                 }
00382                 else if (strcmp (temp_string, "330") == 0)
00383                 {
00384                         /* Now follows a string containing Soft-pointer
00385                          * ID/handle to owner dictionary. */
00386                         (fp->line_number)++;
00387                         fscanf (fp->fp, "%s\n", line->dictionary_owner_soft);
00388                 }
00389                 else if (strcmp (temp_string, "347") == 0)
00390                 {
00391                         /* Now follows a string containing a
00392                          * hard-pointer ID/handle to material object. */
00393                         (fp->line_number)++;
00394                         fscanf (fp->fp, "%s\n", line->material);
00395                 }
00396                 else if (strcmp (temp_string, "360") == 0)
00397                 {
00398                         /* Now follows a string containing Hard owner
00399                          * ID/handle to owner dictionary. */
00400                         (fp->line_number)++;
00401                         fscanf (fp->fp, "%s\n", line->dictionary_owner_hard);
00402                 }
00403                 else if (strcmp (temp_string, "370") == 0)
00404                 {
00405                         /* Now follows a string containing the lineweight
00406                          * value. */
00407                         (fp->line_number)++;
00408                         fscanf (fp->fp, "%hd\n", &line->lineweight);
00409                 }
00410                 else if (strcmp (temp_string, "390") == 0)
00411                 {
00412                         /* Now follows a string containing a plot style
00413                          * name value. */
00414                         (fp->line_number)++;
00415                         fscanf (fp->fp, "%s\n", line->plot_style_name);
00416                 }
00417                 else if (strcmp (temp_string, "420") == 0)
00418                 {
00419                         /* Now follows a string containing a color value. */
00420                         (fp->line_number)++;
00421                         fscanf (fp->fp, "%ld\n", &line->color_value);
00422                 }
00423                 else if (strcmp (temp_string, "430") == 0)
00424                 {
00425                         /* Now follows a string containing a color
00426                          * name value. */
00427                         (fp->line_number)++;
00428                         fscanf (fp->fp, "%s\n", line->color_name);
00429                 }
00430                 else if (strcmp (temp_string, "440") == 0)
00431                 {
00432                         /* Now follows a string containing a transparency
00433                          * value. */
00434                         (fp->line_number)++;
00435                         fscanf (fp->fp, "%ld\n", &line->transparency);
00436                 }
00437                 else if (strcmp (temp_string, "999") == 0)
00438                 {
00439                         /* Now follows a string containing a comment. */
00440                         (fp->line_number)++;
00441                         fscanf (fp->fp, "%s\n", temp_string);
00442                         fprintf (stdout, "DXF comment: %s\n", temp_string);
00443                 }
00444                 else
00445                 {
00446                         fprintf (stderr,
00447                           (_("Warning in %s () unknown string tag found while reading from: %s in line: %d.\n")),
00448                           __FUNCTION__, fp->filename, fp->line_number);
00449                 }
00450         }
00451         /* Handle omitted members and/or illegal values. */
00452         if (strcmp (dxf_line_get_linetype (line), "") == 0)
00453         {
00454                 dxf_line_set_linetype (line, strdup (DXF_DEFAULT_LINETYPE));
00455         }
00456         if (strcmp (dxf_line_get_layer (line), "") == 0)
00457         {
00458                 dxf_line_set_layer (line, strdup (DXF_DEFAULT_LAYER));
00459         }
00460         /* Clean up. */
00461         free (temp_string);
00462 #if DEBUG
00463         DXF_DEBUG_END
00464 #endif
00465         return (line);
00466 }
00467 
00468 
00475 int
00476 dxf_line_write
00477 (
00478         DxfFile *fp,
00480         DxfLine *line
00482 )
00483 {
00484 #if DEBUG
00485         DXF_DEBUG_BEGIN
00486 #endif
00487         char *dxf_entity_name = strdup ("LINE");
00488 
00489         /* Do some basic checks. */
00490         if (fp == NULL)
00491         {
00492                 fprintf (stderr,
00493                   (_("Error in %s () a NULL file pointer was passed.\n")),
00494                   __FUNCTION__);
00495                 /* Clean up. */
00496                 free (dxf_entity_name);
00497                 return (EXIT_FAILURE);
00498         }
00499         if (line == NULL)
00500         {
00501                 fprintf (stderr,
00502                   (_("Error in %s () a NULL pointer was passed.\n")),
00503                   __FUNCTION__);
00504                 /* Clean up. */
00505                 free (dxf_entity_name);
00506                 return (EXIT_FAILURE);
00507         }
00508         if ((dxf_line_get_x0 (line) == dxf_line_get_x1 (line))
00509                 && (dxf_line_get_y0 (line) == dxf_line_get_y1 (line))
00510                 && (dxf_line_get_z0 (line) == dxf_line_get_z1 (line)))
00511         {
00512                 fprintf (stderr,
00513                   (_("Error in %s () start point and end point are identical for the %s entity with id-code: %x\n")),
00514                   __FUNCTION__, dxf_entity_name, dxf_line_get_id_code (line));
00515                 dxf_entity_skip (dxf_entity_name);
00516                 /* Clean up. */
00517                 free (dxf_entity_name);
00518                 return (EXIT_FAILURE);
00519         }
00520         if (strcmp (dxf_line_get_linetype (line), "") == 0)
00521         {
00522                 fprintf (stderr,
00523                   (_("Warning in %s () empty linetype string for the %s entity with id-code: %x\n")),
00524                   __FUNCTION__, dxf_entity_name, dxf_line_get_id_code (line));
00525                 fprintf (stderr,
00526                   (_("    %s entity is relocated to layer 0\n")),
00527                   dxf_entity_name);
00528                 dxf_line_set_linetype (line, strdup (DXF_DEFAULT_LINETYPE));
00529         }
00530         if (strcmp (dxf_line_get_layer (line), "") == 0)
00531         {
00532                 fprintf (stderr,
00533                   (_("Warning in %s () empty layer string for the %s entity with id-code: %x\n")),
00534                   __FUNCTION__, dxf_entity_name, dxf_line_get_id_code (line));
00535                 fprintf (stderr,
00536                   (_("    %s entity is relocated to layer 0\n")),
00537                   dxf_entity_name);
00538                 dxf_line_set_layer (line, strdup (DXF_DEFAULT_LAYER));
00539         }
00540         /* Start writing output. */
00541         fprintf (fp->fp, "  0\n%s\n", dxf_entity_name);
00542         if (dxf_line_get_id_code (line) != -1)
00543         {
00544                 fprintf (fp->fp, "  5\n%x\n", dxf_line_get_id_code (line));
00545         }
00556         if ((strcmp (dxf_line_get_dictionary_owner_soft (line), "") != 0)
00557           && (fp->acad_version_number >= AutoCAD_14))
00558         {
00559                 fprintf (fp->fp, "102\n{ACAD_REACTORS\n");
00560                 fprintf (fp->fp, "330\n%s\n", dxf_line_get_dictionary_owner_soft (line));
00561                 fprintf (fp->fp, "102\n}\n");
00562         }
00563         if ((strcmp (dxf_line_get_dictionary_owner_hard (line), "") != 0)
00564           && (fp->acad_version_number >= AutoCAD_14))
00565         {
00566                 fprintf (fp->fp, "102\n{ACAD_XDICTIONARY\n");
00567                 fprintf (fp->fp, "360\n%s\n", dxf_line_get_dictionary_owner_hard (line));
00568                 fprintf (fp->fp, "102\n}\n");
00569         }
00570         if (fp->acad_version_number >= AutoCAD_13)
00571         {
00572                 fprintf (fp->fp, "100\nAcDbEntity\n");
00573         }
00574         if (dxf_line_get_paperspace (line) == DXF_PAPERSPACE)
00575         {
00576                 fprintf (fp->fp, " 67\n%d\n", DXF_PAPERSPACE);
00577         }
00578         fprintf (fp->fp, "  8\n%s\n", dxf_line_get_layer (line));
00579         if (strcmp (dxf_line_get_linetype (line), DXF_DEFAULT_LINETYPE) != 0)
00580         {
00581                 fprintf (fp->fp, "  6\n%s\n", dxf_line_get_linetype (line));
00582         }
00583         if ((fp->acad_version_number >= AutoCAD_2008)
00584           && (strcmp (dxf_line_get_material (line), "") != 0))
00585         {
00586                 fprintf (fp->fp, "347\n%s\n", dxf_line_get_material (line));
00587         }
00588         if (dxf_line_get_color (line) != DXF_COLOR_BYLAYER)
00589         {
00590                 fprintf (fp->fp, " 62\n%d\n", dxf_line_get_color (line));
00591         }
00592         if (fp->acad_version_number >= AutoCAD_2002)
00593         {
00594                 fprintf (fp->fp, "370\n%d\n", dxf_line_get_lineweight (line));
00595         }
00596         if ((fp->acad_version_number <= AutoCAD_11)
00597           && DXF_FLATLAND
00598           && (dxf_line_get_elevation (line) != 0.0))
00599         {
00600                 fprintf (fp->fp, " 38\n%f\n", dxf_line_get_elevation (line));
00601         }
00602         if (dxf_line_get_thickness (line) != 0.0)
00603         {
00604                 fprintf (fp->fp, " 39\n%f\n", dxf_line_get_thickness (line));
00605         }
00606         if (dxf_line_get_linetype_scale (line) != 1.0)
00607         {
00608                 fprintf (fp->fp, " 48\n%f\n", dxf_line_get_linetype_scale (line));
00609         }
00610         if (dxf_line_get_visibility (line) != 0)
00611         {
00612                 fprintf (fp->fp, " 60\n%d\n", dxf_line_get_visibility (line));
00613         }
00614         if ((fp->acad_version_number >= AutoCAD_2000)
00615           && (dxf_line_get_graphics_data_size (line) > 0))
00616         {
00617 #ifdef BUILD_64
00618                 fprintf (fp->fp, "160\n%d\n", dxf_line_get_graphics_data_size (line));
00619 #else
00620                 fprintf (fp->fp, " 92\n%d\n", dxf_line_get_graphics_data_size (line));
00621 #endif
00622                 if (dxf_line_get_binary_graphics_data (line) != NULL)
00623                 {
00624                         DxfBinaryGraphicsData *iter;
00625                         iter = dxf_line_get_binary_graphics_data (line);
00626                         while (iter != NULL)
00627                         {
00628                                 fprintf (fp->fp, "310\n%s\n", dxf_binary_graphics_data_get_data_line (iter));
00629                                 iter = (DxfBinaryGraphicsData *) dxf_binary_graphics_data_get_next (iter);
00630                         }
00631                 }
00632         }
00633         if (fp->acad_version_number >= AutoCAD_2004)
00634         {
00635                 fprintf (fp->fp, "420\n%ld\n", dxf_line_get_color_value (line));
00636                 fprintf (fp->fp, "430\n%s\n", dxf_line_get_color_name (line));
00637                 fprintf (fp->fp, "440\n%ld\n", dxf_line_get_transparency (line));
00638         }
00639         if (fp->acad_version_number >= AutoCAD_2009)
00640         {
00641                 fprintf (fp->fp, "390\n%s\n", dxf_line_get_plot_style_name (line));
00642                 fprintf (fp->fp, "284\n%d\n", dxf_line_get_shadow_mode (line));
00643         }
00644         if (fp->acad_version_number >= AutoCAD_13)
00645         {
00646                 fprintf (fp->fp, "100\nAcDbLine\n");
00647         }
00648         fprintf (fp->fp, " 10\n%f\n", dxf_line_get_x0 (line));
00649         fprintf (fp->fp, " 20\n%f\n", dxf_line_get_y0 (line));
00650         fprintf (fp->fp, " 30\n%f\n", dxf_line_get_z0 (line));
00651         fprintf (fp->fp, " 11\n%f\n", dxf_line_get_x1 (line));
00652         fprintf (fp->fp, " 21\n%f\n", dxf_line_get_y1 (line));
00653         fprintf (fp->fp, " 31\n%f\n", dxf_line_get_z1 (line));
00654         if ((fp->acad_version_number >= AutoCAD_12)
00655                 && (dxf_line_get_extr_x0 (line) != 0.0)
00656                 && (dxf_line_get_extr_y0 (line) != 0.0)
00657                 && (dxf_line_get_extr_z0 (line) != 1.0))
00658         {
00659                 fprintf (fp->fp, "210\n%f\n", dxf_line_get_extr_x0 (line));
00660                 fprintf (fp->fp, "220\n%f\n", dxf_line_get_extr_y0 (line));
00661                 fprintf (fp->fp, "230\n%f\n", dxf_line_get_extr_z0 (line));
00662         }
00663         /* Clean up. */
00664         free (dxf_entity_name);
00665 #if DEBUG
00666         DXF_DEBUG_END
00667 #endif
00668         return (EXIT_SUCCESS);
00669 }
00670 
00671 
00679 int
00680 dxf_line_free
00681 (
00682         DxfLine *line
00685 )
00686 {
00687 #if DEBUG
00688         DXF_DEBUG_BEGIN
00689 #endif
00690         /* Do some basic checks. */
00691         if (line == NULL)
00692         {
00693                 fprintf (stderr,
00694                   (_("Error in %s () a NULL pointer was passed.\n")),
00695                   __FUNCTION__);
00696                 return (EXIT_FAILURE);
00697         }
00698         if (line->next != NULL)
00699         {
00700                 fprintf (stderr,
00701                   (_("Error in %s () pointer to next was not NULL.\n")),
00702                   __FUNCTION__);
00703                 return (EXIT_FAILURE);
00704         }
00705         free (dxf_line_get_linetype (line));
00706         free (dxf_line_get_layer (line));
00707         dxf_binary_graphics_data_free_chain (dxf_line_get_binary_graphics_data (line));
00708         free (dxf_line_get_dictionary_owner_soft (line));
00709         free (dxf_line_get_material (line));
00710         free (dxf_line_get_dictionary_owner_hard (line));
00711         free (dxf_line_get_plot_style_name (line));
00712         free (dxf_line_get_color_name (line));
00713         dxf_point_free (dxf_line_get_p0 (line));
00714         dxf_point_free (dxf_line_get_p1 (line));
00715         free (line);
00716         line = NULL;
00717 #if DEBUG
00718         DXF_DEBUG_END
00719 #endif
00720         return (EXIT_SUCCESS);
00721 }
00722 
00723 
00728 void
00729 dxf_line_free_chain
00730 (
00731         DxfLine *lines
00733 )
00734 {
00735 #ifdef DEBUG
00736         DXF_DEBUG_BEGIN
00737 #endif
00738         if (lines == NULL)
00739         {
00740                 fprintf (stderr,
00741                   (_("Warning in %s () a NULL pointer was passed.\n")),
00742                   __FUNCTION__);
00743         }
00744         while (lines != NULL)
00745         {
00746                 struct DxfLine *iter = lines->next;
00747                 dxf_line_free (lines);
00748                 lines = (DxfLine *) iter;
00749         }
00750 #if DEBUG
00751         DXF_DEBUG_END
00752 #endif
00753 }
00754 
00755 
00761 int
00762 dxf_line_get_id_code
00763 (
00764         DxfLine *line
00766 )
00767 {
00768 #if DEBUG
00769         DXF_DEBUG_BEGIN
00770 #endif
00771         /* Do some basic checks. */
00772         if (line == NULL)
00773         {
00774                 fprintf (stderr,
00775                   (_("Error in %s () a NULL pointer was passed.\n")),
00776                   __FUNCTION__);
00777                 return (EXIT_FAILURE);
00778         }
00779         if (line->id_code < 0)
00780         {
00781                 fprintf (stderr,
00782                   (_("Error in %s () a negative value was found in the id-code member.\n")),
00783                   __FUNCTION__);
00784                 return (EXIT_FAILURE);
00785         }
00786 #if DEBUG
00787         DXF_DEBUG_END
00788 #endif
00789         return (line->id_code);
00790 }
00791 
00792 
00796 DxfLine *
00797 dxf_line_set_id_code
00798 (
00799         DxfLine *line,
00801         int id_code
00805 )
00806 {
00807 #if DEBUG
00808         DXF_DEBUG_BEGIN
00809 #endif
00810         /* Do some basic checks. */
00811         if (line == NULL)
00812         {
00813                 fprintf (stderr,
00814                   (_("Error in %s () a NULL pointer was passed.\n")),
00815                   __FUNCTION__);
00816                 return (NULL);
00817         }
00818         if (id_code < 0)
00819         {
00820                 fprintf (stderr,
00821                   (_("Error in %s () a negative id-code value was passed.\n")),
00822                   __FUNCTION__);
00823                 return (NULL);
00824         }
00825         line->id_code = id_code;
00826 #if DEBUG
00827         DXF_DEBUG_END
00828 #endif
00829         return (line);
00830 }
00831 
00832 
00838 char *
00839 dxf_line_get_linetype
00840 (
00841         DxfLine *line
00843 )
00844 {
00845 #if DEBUG
00846         DXF_DEBUG_BEGIN
00847 #endif
00848         /* Do some basic checks. */
00849         if (line == NULL)
00850         {
00851                 fprintf (stderr,
00852                   (_("Error in %s () a NULL pointer was passed.\n")),
00853                   __FUNCTION__);
00854                 return (NULL);
00855         }
00856         if (line->linetype ==  NULL)
00857         {
00858                 fprintf (stderr,
00859                   (_("Error in %s () a NULL pointer was found in the linetype member.\n")),
00860                   __FUNCTION__);
00861                 return (NULL);
00862         }
00863 #if DEBUG
00864         DXF_DEBUG_END
00865 #endif
00866         return (strdup (line->linetype));
00867 }
00868 
00869 
00873 DxfLine *
00874 dxf_line_set_linetype
00875 (
00876         DxfLine *line,
00878         char *linetype
00880 )
00881 {
00882 #if DEBUG
00883         DXF_DEBUG_BEGIN
00884 #endif
00885         /* Do some basic checks. */
00886         if (line == NULL)
00887         {
00888                 fprintf (stderr,
00889                   (_("Error in %s () a NULL pointer was passed.\n")),
00890                   __FUNCTION__);
00891                 return (NULL);
00892         }
00893         if (linetype == NULL)
00894         {
00895                 fprintf (stderr,
00896                   (_("Error in %s () a NULL pointer was passed.\n")),
00897                   __FUNCTION__);
00898                 return (NULL);
00899         }
00900         line->linetype = strdup (linetype);
00901 #if DEBUG
00902         DXF_DEBUG_END
00903 #endif
00904         return (line);
00905 }
00906 
00907 
00913 char *
00914 dxf_line_get_layer
00915 (
00916         DxfLine *line
00918 )
00919 {
00920 #if DEBUG
00921         DXF_DEBUG_BEGIN
00922 #endif
00923         /* Do some basic checks. */
00924         if (line == NULL)
00925         {
00926                 fprintf (stderr,
00927                   (_("Error in %s () a NULL pointer was passed.\n")),
00928                   __FUNCTION__);
00929                 return (NULL);
00930         }
00931         if (line->layer ==  NULL)
00932         {
00933                 fprintf (stderr,
00934                   (_("Error in %s () a NULL pointer was found in the layer member.\n")),
00935                   __FUNCTION__);
00936                 return (NULL);
00937         }
00938 #if DEBUG
00939         DXF_DEBUG_END
00940 #endif
00941         return (strdup (line->layer));
00942 }
00943 
00944 
00948 DxfLine *
00949 dxf_line_set_layer
00950 (
00951         DxfLine *line,
00953         char *layer
00955 )
00956 {
00957 #if DEBUG
00958         DXF_DEBUG_BEGIN
00959 #endif
00960         /* Do some basic checks. */
00961         if (line == NULL)
00962         {
00963                 fprintf (stderr,
00964                   (_("Error in %s () a NULL pointer was passed.\n")),
00965                   __FUNCTION__);
00966                 return (NULL);
00967         }
00968         if (layer == NULL)
00969         {
00970                 fprintf (stderr,
00971                   (_("Error in %s () a NULL pointer was passed.\n")),
00972                   __FUNCTION__);
00973                 return (NULL);
00974         }
00975         line->layer = strdup (layer);
00976 #if DEBUG
00977         DXF_DEBUG_END
00978 #endif
00979         return (line);
00980 }
00981 
00982 
00988 double
00989 dxf_line_get_elevation
00990 (
00991         DxfLine *line
00993 )
00994 {
00995 #if DEBUG
00996         DXF_DEBUG_BEGIN
00997 #endif
00998         /* Do some basic checks. */
00999         if (line == NULL)
01000         {
01001                 fprintf (stderr,
01002                   (_("Error in %s () a NULL pointer was passed.\n")),
01003                   __FUNCTION__);
01004                 return (EXIT_FAILURE);
01005         }
01006 #if DEBUG
01007         DXF_DEBUG_END
01008 #endif
01009         return (line->elevation);
01010 }
01011 
01012 
01016 DxfLine *
01017 dxf_line_set_elevation
01018 (
01019         DxfLine *line,
01021         double elevation
01023 )
01024 {
01025 #if DEBUG
01026         DXF_DEBUG_BEGIN
01027 #endif
01028         /* Do some basic checks. */
01029         if (line == NULL)
01030         {
01031                 fprintf (stderr,
01032                   (_("Error in %s () a NULL pointer was passed.\n")),
01033                   __FUNCTION__);
01034                 return (NULL);
01035         }
01036         line->elevation = elevation;
01037 #if DEBUG
01038         DXF_DEBUG_END
01039 #endif
01040         return (line);
01041 }
01042 
01043 
01049 double
01050 dxf_line_get_thickness
01051 (
01052         DxfLine *line
01054 )
01055 {
01056 #if DEBUG
01057         DXF_DEBUG_BEGIN
01058 #endif
01059         /* Do some basic checks. */
01060         if (line == NULL)
01061         {
01062                 fprintf (stderr,
01063                   (_("Error in %s () a NULL pointer was passed.\n")),
01064                   __FUNCTION__);
01065                 return (EXIT_FAILURE);
01066         }
01067         if (line->thickness < 0.0)
01068         {
01069                 fprintf (stderr,
01070                   (_("Error in %s () a negative value was found in the thickness member.\n")),
01071                   __FUNCTION__);
01072                 return (EXIT_FAILURE);
01073         }
01074 #if DEBUG
01075         DXF_DEBUG_END
01076 #endif
01077         return (line->thickness);
01078 }
01079 
01080 
01084 DxfLine *
01085 dxf_line_set_thickness
01086 (
01087         DxfLine *line,
01089         double thickness
01091 )
01092 {
01093 #if DEBUG
01094         DXF_DEBUG_BEGIN
01095 #endif
01096         /* Do some basic checks. */
01097         if (line == NULL)
01098         {
01099                 fprintf (stderr,
01100                   (_("Error in %s () a NULL pointer was passed.\n")),
01101                   __FUNCTION__);
01102                 return (NULL);
01103         }
01104         if (thickness < 0.0)
01105         {
01106                 fprintf (stderr,
01107                   (_("Error in %s () a negative thickness value was passed.\n")),
01108                   __FUNCTION__);
01109                 return (NULL);
01110         }
01111         line->thickness = thickness;
01112 #if DEBUG
01113         DXF_DEBUG_END
01114 #endif
01115         return (line);
01116 }
01117 
01118 
01124 double
01125 dxf_line_get_linetype_scale
01126 (
01127         DxfLine *line
01129 )
01130 {
01131 #if DEBUG
01132         DXF_DEBUG_BEGIN
01133 #endif
01134         /* Do some basic checks. */
01135         if (line == NULL)
01136         {
01137                 fprintf (stderr,
01138                   (_("Error in %s () a NULL pointer was passed.\n")),
01139                   __FUNCTION__);
01140                 return (EXIT_FAILURE);
01141         }
01142         if (line->linetype_scale < 0.0)
01143         {
01144                 fprintf (stderr,
01145                   (_("Error in %s () a negative value was found in the linetype scale member.\n")),
01146                   __FUNCTION__);
01147                 return (EXIT_FAILURE);
01148         }
01149 #if DEBUG
01150         DXF_DEBUG_END
01151 #endif
01152         return (line->linetype_scale);
01153 }
01154 
01155 
01159 DxfLine *
01160 dxf_line_set_linetype_scale
01161 (
01162         DxfLine *line,
01164         double linetype_scale
01166 )
01167 {
01168 #if DEBUG
01169         DXF_DEBUG_BEGIN
01170 #endif
01171         /* Do some basic checks. */
01172         if (line == NULL)
01173         {
01174                 fprintf (stderr,
01175                   (_("Error in %s () a NULL pointer was passed.\n")),
01176                   __FUNCTION__);
01177                 return (NULL);
01178         }
01179         if (linetype_scale < 0.0)
01180         {
01181                 fprintf (stderr,
01182                   (_("Error in %s () a negative linetype scale value was passed.\n")),
01183                   __FUNCTION__);
01184                 return (NULL);
01185         }
01186         line->linetype_scale = linetype_scale;
01187 #if DEBUG
01188         DXF_DEBUG_END
01189 #endif
01190         return (line);
01191 }
01192 
01193 
01199 int16_t
01200 dxf_line_get_visibility
01201 (
01202         DxfLine *line
01204 )
01205 {
01206 #if DEBUG
01207         DXF_DEBUG_BEGIN
01208 #endif
01209         /* Do some basic checks. */
01210         if (line == NULL)
01211         {
01212                 fprintf (stderr,
01213                   (_("Error in %s () a NULL pointer was passed.\n")),
01214                   __FUNCTION__);
01215                 return (EXIT_FAILURE);
01216         }
01217         if (line->visibility < 0)
01218         {
01219                 fprintf (stderr,
01220                   (_("Error in %s () a negative value was found in the visibility member.\n")),
01221                   __FUNCTION__);
01222                 return (EXIT_FAILURE);
01223         }
01224         if (line->visibility > 1)
01225         {
01226                 fprintf (stderr,
01227                   (_("Error in %s () an out of range value was found in the visibility member.\n")),
01228                   __FUNCTION__);
01229                 return (EXIT_FAILURE);
01230         }
01231 #if DEBUG
01232         DXF_DEBUG_END
01233 #endif
01234         return (line->visibility);
01235 }
01236 
01237 
01241 DxfLine *
01242 dxf_line_set_visibility
01243 (
01244         DxfLine *line,
01246         int16_t visibility
01248 )
01249 {
01250 #if DEBUG
01251         DXF_DEBUG_BEGIN
01252 #endif
01253         /* Do some basic checks. */
01254         if (line == NULL)
01255         {
01256                 fprintf (stderr,
01257                   (_("Error in %s () a NULL pointer was passed.\n")),
01258                   __FUNCTION__);
01259                 return (NULL);
01260         }
01261         if (visibility < 0)
01262         {
01263                 fprintf (stderr,
01264                   (_("Error in %s () a negative visibility value was passed.\n")),
01265                   __FUNCTION__);
01266                 return (NULL);
01267         }
01268         if (visibility > 1)
01269         {
01270                 fprintf (stderr,
01271                   (_("Error in %s () an out of range visibility value was passed.\n")),
01272                   __FUNCTION__);
01273                 return (NULL);
01274         }
01275         line->visibility = visibility;
01276 #if DEBUG
01277         DXF_DEBUG_END
01278 #endif
01279         return (line);
01280 }
01281 
01282 
01288 int
01289 dxf_line_get_color
01290 (
01291         DxfLine *line
01293 )
01294 {
01295 #if DEBUG
01296         DXF_DEBUG_BEGIN
01297 #endif
01298         /* Do some basic checks. */
01299         if (line == NULL)
01300         {
01301                 fprintf (stderr,
01302                   (_("Error in %s () a NULL pointer was passed.\n")),
01303                   __FUNCTION__);
01304                 return (EXIT_FAILURE);
01305         }
01306         if (line->color < 0)
01307         {
01308                 fprintf (stderr,
01309                   (_("Warning in %s () a negative value was found in the color member.\n")),
01310                   __FUNCTION__);
01311         }
01312 #if DEBUG
01313         DXF_DEBUG_END
01314 #endif
01315         return (line->color);
01316 }
01317 
01318 
01322 DxfLine *
01323 dxf_line_set_color
01324 (
01325         DxfLine *line,
01327         int color
01329 )
01330 {
01331 #if DEBUG
01332         DXF_DEBUG_BEGIN
01333 #endif
01334         /* Do some basic checks. */
01335         if (line == NULL)
01336         {
01337                 fprintf (stderr,
01338                   (_("Error in %s () a NULL pointer was passed.\n")),
01339                   __FUNCTION__);
01340                 return (NULL);
01341         }
01342         if (color < 0)
01343         {
01344                 fprintf (stderr,
01345                   (_("Warning in %s () a negative color value was passed.\n")),
01346                   __FUNCTION__);
01347                 fprintf (stderr,
01348                   (_("\teffectively turning this entity it's visibility off.\n")));
01349         }
01350         line->color = color;
01351 #if DEBUG
01352         DXF_DEBUG_END
01353 #endif
01354         return (line);
01355 }
01356 
01357 
01363 int
01364 dxf_line_get_paperspace
01365 (
01366         DxfLine *line
01368 )
01369 {
01370 #if DEBUG
01371         DXF_DEBUG_BEGIN
01372 #endif
01373         /* Do some basic checks. */
01374         if (line == NULL)
01375         {
01376                 fprintf (stderr,
01377                   (_("Error in %s () a NULL pointer was passed.\n")),
01378                   __FUNCTION__);
01379                 return (EXIT_FAILURE);
01380         }
01381         if (line->paperspace < 0)
01382         {
01383                 fprintf (stderr,
01384                   (_("Warning in %s () a negative value was found in the paperspace member.\n")),
01385                   __FUNCTION__);
01386         }
01387         if (line->paperspace > 1)
01388         {
01389                 fprintf (stderr,
01390                   (_("Warning in %s () an out of range value was found in the paperspace member.\n")),
01391                   __FUNCTION__);
01392         }
01393 #if DEBUG
01394         DXF_DEBUG_END
01395 #endif
01396         return (line->paperspace);
01397 }
01398 
01399 
01403 DxfLine *
01404 dxf_line_set_paperspace
01405 (
01406         DxfLine *line,
01408         int paperspace
01410 )
01411 {
01412 #if DEBUG
01413         DXF_DEBUG_BEGIN
01414 #endif
01415         /* Do some basic checks. */
01416         if (line == NULL)
01417         {
01418                 fprintf (stderr,
01419                   (_("Error in %s () a NULL pointer was passed.\n")),
01420                   __FUNCTION__);
01421                 return (NULL);
01422         }
01423         if (paperspace < 0)
01424         {
01425                 fprintf (stderr,
01426                   (_("Error in %s () a negative paperspace value was passed.\n")),
01427                   __FUNCTION__);
01428                 return (NULL);
01429         }
01430         if (paperspace > 1)
01431         {
01432                 fprintf (stderr,
01433                   (_("Error in %s () an out of range paperspace value was passed.\n")),
01434                   __FUNCTION__);
01435                 return (NULL);
01436         }
01437         line->paperspace = paperspace;
01438 #if DEBUG
01439         DXF_DEBUG_END
01440 #endif
01441         return (line);
01442 }
01443 
01444 
01452 int
01453 dxf_line_get_graphics_data_size
01454 (
01455         DxfLine *line
01457 )
01458 {
01459 #if DEBUG
01460         DXF_DEBUG_BEGIN
01461 #endif
01462         /* Do some basic checks. */
01463         if (line == NULL)
01464         {
01465                 fprintf (stderr,
01466                   (_("Error in %s () a NULL pointer was passed.\n")),
01467                   __FUNCTION__);
01468                 return (EXIT_FAILURE);
01469         }
01470         if (line->graphics_data_size < 0)
01471         {
01472                 fprintf (stderr,
01473                   (_("Warning in %s () a negative value was found in the graphics_data_size member.\n")),
01474                   __FUNCTION__);
01475         }
01476         if (line->graphics_data_size == 0)
01477         {
01478                 fprintf (stderr,
01479                   (_("Warning in %s () a zero value was found in the graphics_data_size member.\n")),
01480                   __FUNCTION__);
01481         }
01482 #if DEBUG
01483         DXF_DEBUG_END
01484 #endif
01485         return (line->graphics_data_size);
01486 }
01487 
01488 
01496 DxfLine *
01497 dxf_line_set_graphics_data_size
01498 (
01499         DxfLine *line,
01501         int graphics_data_size
01504 )
01505 {
01506 #if DEBUG
01507         DXF_DEBUG_BEGIN
01508 #endif
01509         /* Do some basic checks. */
01510         if (line == NULL)
01511         {
01512                 fprintf (stderr,
01513                   (_("Error in %s () a NULL pointer was passed.\n")),
01514                   __FUNCTION__);
01515                 return (NULL);
01516         }
01517         if (graphics_data_size < 0)
01518         {
01519                 fprintf (stderr,
01520                   (_("Error in %s () a negative graphics_data_size value was passed.\n")),
01521                   __FUNCTION__);
01522                 return (NULL);
01523         }
01524         if (graphics_data_size == 0)
01525         {
01526                 fprintf (stderr,
01527                   (_("Warning in %s () a zero graphics_data_size value was passed.\n")),
01528                   __FUNCTION__);
01529         }
01530         line->graphics_data_size = graphics_data_size;
01531 #if DEBUG
01532         DXF_DEBUG_END
01533 #endif
01534         return (line);
01535 }
01536 
01537 
01544 int16_t
01545 dxf_line_get_shadow_mode
01546 (
01547         DxfLine *line
01549 )
01550 {
01551 #if DEBUG
01552         DXF_DEBUG_BEGIN
01553 #endif
01554         /* Do some basic checks. */
01555         if (line == NULL)
01556         {
01557                 fprintf (stderr,
01558                   (_("Error in %s () a NULL pointer was passed.\n")),
01559                   __FUNCTION__);
01560                 return (EXIT_FAILURE);
01561         }
01562         if (line->shadow_mode < 0)
01563         {
01564                 fprintf (stderr,
01565                   (_("Error in %s () a negative value was found in the shadow_mode member.\n")),
01566                   __FUNCTION__);
01567                 return (EXIT_FAILURE);
01568         }
01569         if (line->shadow_mode > 3)
01570         {
01571                 fprintf (stderr,
01572                   (_("Error in %s () an out of range value was found in the shadow_mode member.\n")),
01573                   __FUNCTION__);
01574                 return (EXIT_FAILURE);
01575         }
01576 #if DEBUG
01577         DXF_DEBUG_END
01578 #endif
01579         return (line->shadow_mode);
01580 }
01581 
01582 
01589 DxfLine *
01590 dxf_line_set_shadow_mode
01591 (
01592         DxfLine *line,
01594         int16_t shadow_mode
01596 )
01597 {
01598 #if DEBUG
01599         DXF_DEBUG_BEGIN
01600 #endif
01601         /* Do some basic checks. */
01602         if (line == NULL)
01603         {
01604                 fprintf (stderr,
01605                   (_("Error in %s () a NULL pointer was passed.\n")),
01606                   __FUNCTION__);
01607                 return (NULL);
01608         }
01609         if (shadow_mode < 0)
01610         {
01611                 fprintf (stderr,
01612                   (_("Error in %s () a negative shadow_mode value was passed.\n")),
01613                   __FUNCTION__);
01614                 return (NULL);
01615         }
01616         if (shadow_mode > 3)
01617         {
01618                 fprintf (stderr,
01619                   (_("Error in %s () an out of range shadow_mode value was passed.\n")),
01620                   __FUNCTION__);
01621                 return (NULL);
01622         }
01623         line->shadow_mode = shadow_mode;
01624 #if DEBUG
01625         DXF_DEBUG_END
01626 #endif
01627         return (line);
01628 }
01629 
01630 
01639 DxfBinaryGraphicsData *
01640 dxf_line_get_binary_graphics_data
01641 (
01642         DxfLine *line
01644 )
01645 {
01646 #if DEBUG
01647         DXF_DEBUG_BEGIN
01648 #endif
01649         /* Do some basic checks. */
01650         if (line == NULL)
01651         {
01652                 fprintf (stderr,
01653                   (_("Error in %s () a NULL pointer was passed.\n")),
01654                   __FUNCTION__);
01655                 return (NULL);
01656         }
01657         if (line->binary_graphics_data ==  NULL)
01658         {
01659                 fprintf (stderr,
01660                   (_("Error in %s () a NULL pointer was found in the binary_graphics_data member.\n")),
01661                   __FUNCTION__);
01662                 return (NULL);
01663         }
01664 #if DEBUG
01665         DXF_DEBUG_END
01666 #endif
01667         return ((DxfBinaryGraphicsData *) line->binary_graphics_data);
01668 }
01669 
01670 
01675 DxfLine *
01676 dxf_line_set_binary_graphics_data
01677 (
01678         DxfLine *line,
01680         DxfBinaryGraphicsData *data
01683 )
01684 {
01685 #if DEBUG
01686         DXF_DEBUG_BEGIN
01687 #endif
01688         /* Do some basic checks. */
01689         if (line == NULL)
01690         {
01691                 fprintf (stderr,
01692                   (_("Error in %s () a NULL pointer was passed.\n")),
01693                   __FUNCTION__);
01694                 return (NULL);
01695         }
01696         if (data == NULL)
01697         {
01698                 fprintf (stderr,
01699                   (_("Error in %s () a NULL pointer was passed.\n")),
01700                   __FUNCTION__);
01701                 return (NULL);
01702         }
01703         line->binary_graphics_data = (DxfBinaryGraphicsData *) data;
01704 #if DEBUG
01705         DXF_DEBUG_END
01706 #endif
01707         return (line);
01708 }
01709 
01710 
01719 char *
01720 dxf_line_get_dictionary_owner_soft
01721 (
01722         DxfLine *line
01724 )
01725 {
01726 #if DEBUG
01727         DXF_DEBUG_BEGIN
01728 #endif
01729         /* Do some basic checks. */
01730         if (line == NULL)
01731         {
01732                 fprintf (stderr,
01733                   (_("Error in %s () a NULL pointer was passed.\n")),
01734                   __FUNCTION__);
01735                 return (NULL);
01736         }
01737         if (line->dictionary_owner_soft ==  NULL)
01738         {
01739                 fprintf (stderr,
01740                   (_("Error in %s () a NULL pointer was found in the dictionary_owner_soft member.\n")),
01741                   __FUNCTION__);
01742                 return (NULL);
01743         }
01744 #if DEBUG
01745         DXF_DEBUG_END
01746 #endif
01747         return (strdup (line->dictionary_owner_soft));
01748 }
01749 
01750 
01755 DxfLine *
01756 dxf_line_set_dictionary_owner_soft
01757 (
01758         DxfLine *line,
01760         char *dictionary_owner_soft
01763 )
01764 {
01765 #if DEBUG
01766         DXF_DEBUG_BEGIN
01767 #endif
01768         /* Do some basic checks. */
01769         if (line == NULL)
01770         {
01771                 fprintf (stderr,
01772                   (_("Error in %s () a NULL pointer was passed.\n")),
01773                   __FUNCTION__);
01774                 return (NULL);
01775         }
01776         if (dictionary_owner_soft == NULL)
01777         {
01778                 fprintf (stderr,
01779                   (_("Error in %s () a NULL pointer was passed.\n")),
01780                   __FUNCTION__);
01781                 return (NULL);
01782         }
01783         line->dictionary_owner_soft = strdup (dictionary_owner_soft);
01784 #if DEBUG
01785         DXF_DEBUG_END
01786 #endif
01787         return (line);
01788 }
01789 
01790 
01800 char *
01801 dxf_line_get_material
01802 (
01803         DxfLine *line
01805 )
01806 {
01807 #if DEBUG
01808         DXF_DEBUG_BEGIN
01809 #endif
01810         /* Do some basic checks. */
01811         if (line == NULL)
01812         {
01813                 fprintf (stderr,
01814                   (_("Error in %s () a NULL pointer was passed.\n")),
01815                   __FUNCTION__);
01816                 return (NULL);
01817         }
01818         if (line->material ==  NULL)
01819         {
01820                 fprintf (stderr,
01821                   (_("Error in %s () a NULL pointer was found in the material member.\n")),
01822                   __FUNCTION__);
01823                 return (NULL);
01824         }
01825 #if DEBUG
01826         DXF_DEBUG_END
01827 #endif
01828         return (strdup (line->material));
01829 }
01830 
01831 
01839 DxfLine *
01840 dxf_line_set_material
01841 (
01842         DxfLine *line,
01844         char *material
01847 )
01848 {
01849 #if DEBUG
01850         DXF_DEBUG_BEGIN
01851 #endif
01852         /* Do some basic checks. */
01853         if (line == NULL)
01854         {
01855                 fprintf (stderr,
01856                   (_("Error in %s () a NULL pointer was passed.\n")),
01857                   __FUNCTION__);
01858                 return (NULL);
01859         }
01860         if (material == NULL)
01861         {
01862                 fprintf (stderr,
01863                   (_("Error in %s () a NULL pointer was passed.\n")),
01864                   __FUNCTION__);
01865                 return (NULL);
01866         }
01867         line->material = strdup (material);
01868 #if DEBUG
01869         DXF_DEBUG_END
01870 #endif
01871         return (line);
01872 }
01873 
01874 
01883 char *
01884 dxf_line_get_dictionary_owner_hard
01885 (
01886         DxfLine *line
01888 )
01889 {
01890 #if DEBUG
01891         DXF_DEBUG_BEGIN
01892 #endif
01893         /* Do some basic checks. */
01894         if (line == NULL)
01895         {
01896                 fprintf (stderr,
01897                   (_("Error in %s () a NULL pointer was passed.\n")),
01898                   __FUNCTION__);
01899                 return (NULL);
01900         }
01901         if (line->dictionary_owner_hard ==  NULL)
01902         {
01903                 fprintf (stderr,
01904                   (_("Error in %s () a NULL pointer was found in the dictionary_owner_hard member.\n")),
01905                   __FUNCTION__);
01906                 return (NULL);
01907         }
01908 #if DEBUG
01909         DXF_DEBUG_END
01910 #endif
01911         return (strdup (line->dictionary_owner_hard));
01912 }
01913 
01914 
01919 DxfLine *
01920 dxf_line_set_dictionary_owner_hard
01921 (
01922         DxfLine *line,
01924         char *dictionary_owner_hard
01927 )
01928 {
01929 #if DEBUG
01930         DXF_DEBUG_BEGIN
01931 #endif
01932         /* Do some basic checks. */
01933         if (line == NULL)
01934         {
01935                 fprintf (stderr,
01936                   (_("Error in %s () a NULL pointer was passed.\n")),
01937                   __FUNCTION__);
01938                 return (NULL);
01939         }
01940         if (dictionary_owner_hard == NULL)
01941         {
01942                 fprintf (stderr,
01943                   (_("Error in %s () a NULL pointer was passed.\n")),
01944                   __FUNCTION__);
01945                 return (NULL);
01946         }
01947         line->dictionary_owner_hard = strdup (dictionary_owner_hard);
01948 #if DEBUG
01949         DXF_DEBUG_END
01950 #endif
01951         return (line);
01952 }
01953 
01954 
01961 int16_t
01962 dxf_line_get_lineweight
01963 (
01964         DxfLine *line
01966 )
01967 {
01968 #if DEBUG
01969         DXF_DEBUG_BEGIN
01970 #endif
01971         /* Do some basic checks. */
01972         if (line == NULL)
01973         {
01974                 fprintf (stderr,
01975                   (_("Error in %s () a NULL pointer was passed.\n")),
01976                   __FUNCTION__);
01977                 return (EXIT_FAILURE);
01978         }
01979 #if DEBUG
01980         DXF_DEBUG_END
01981 #endif
01982         return (line->lineweight);
01983 }
01984 
01985 
01992 DxfLine *
01993 dxf_line_set_lineweight
01994 (
01995         DxfLine *line,
01997         int16_t lineweight
01999 )
02000 {
02001 #if DEBUG
02002         DXF_DEBUG_BEGIN
02003 #endif
02004         /* Do some basic checks. */
02005         if (line == NULL)
02006         {
02007                 fprintf (stderr,
02008                   (_("Error in %s () a NULL pointer was passed.\n")),
02009                   __FUNCTION__);
02010                 return (NULL);
02011         }
02012         line->lineweight = lineweight;
02013 #if DEBUG
02014         DXF_DEBUG_END
02015 #endif
02016         return (line);
02017 }
02018 
02019 
02026 char *
02027 dxf_line_get_plot_style_name
02028 (
02029         DxfLine *line
02031 )
02032 {
02033 #if DEBUG
02034         DXF_DEBUG_BEGIN
02035 #endif
02036         /* Do some basic checks. */
02037         if (line == NULL)
02038         {
02039                 fprintf (stderr,
02040                   (_("Error in %s () a NULL pointer was passed.\n")),
02041                   __FUNCTION__);
02042                 return (NULL);
02043         }
02044         if (line->plot_style_name ==  NULL)
02045         {
02046                 fprintf (stderr,
02047                   (_("Error in %s () a NULL pointer was found in the plot_style_name member.\n")),
02048                   __FUNCTION__);
02049                 return (NULL);
02050         }
02051 #if DEBUG
02052         DXF_DEBUG_END
02053 #endif
02054         return (strdup (line->plot_style_name));
02055 }
02056 
02057 
02064 DxfLine *
02065 dxf_line_set_plot_style_name
02066 (
02067         DxfLine *line,
02069         char *plot_style_name
02072 )
02073 {
02074 #if DEBUG
02075         DXF_DEBUG_BEGIN
02076 #endif
02077         /* Do some basic checks. */
02078         if (line == NULL)
02079         {
02080                 fprintf (stderr,
02081                   (_("Error in %s () a NULL pointer was passed.\n")),
02082                   __FUNCTION__);
02083                 return (NULL);
02084         }
02085         if (plot_style_name == NULL)
02086         {
02087                 fprintf (stderr,
02088                   (_("Error in %s () a NULL pointer was passed.\n")),
02089                   __FUNCTION__);
02090                 return (NULL);
02091         }
02092         line->plot_style_name = strdup (plot_style_name);
02093 #if DEBUG
02094         DXF_DEBUG_END
02095 #endif
02096         return (line);
02097 }
02098 
02099 
02106 long
02107 dxf_line_get_color_value
02108 (
02109         DxfLine *line
02111 )
02112 {
02113 #if DEBUG
02114         DXF_DEBUG_BEGIN
02115 #endif
02116         /* Do some basic checks. */
02117         if (line == NULL)
02118         {
02119                 fprintf (stderr,
02120                   (_("Error in %s () a NULL pointer was passed.\n")),
02121                   __FUNCTION__);
02122                 return (EXIT_FAILURE);
02123         }
02124 #if DEBUG
02125         DXF_DEBUG_END
02126 #endif
02127         return (line->color_value);
02128 }
02129 
02130 
02137 DxfLine *
02138 dxf_line_set_color_value
02139 (
02140         DxfLine *line,
02142         long color_value
02144 )
02145 {
02146 #if DEBUG
02147         DXF_DEBUG_BEGIN
02148 #endif
02149         /* Do some basic checks. */
02150         if (line == NULL)
02151         {
02152                 fprintf (stderr,
02153                   (_("Error in %s () a NULL pointer was passed.\n")),
02154                   __FUNCTION__);
02155                 return (NULL);
02156         }
02157         line->color_value = color_value;
02158 #if DEBUG
02159         DXF_DEBUG_END
02160 #endif
02161         return (line);
02162 }
02163 
02164 
02171 char *
02172 dxf_line_get_color_name
02173 (
02174         DxfLine *line
02176 )
02177 {
02178 #if DEBUG
02179         DXF_DEBUG_BEGIN
02180 #endif
02181         /* Do some basic checks. */
02182         if (line == NULL)
02183         {
02184                 fprintf (stderr,
02185                   (_("Error in %s () a NULL pointer was passed.\n")),
02186                   __FUNCTION__);
02187                 return (NULL);
02188         }
02189         if (line->color_name ==  NULL)
02190         {
02191                 fprintf (stderr,
02192                   (_("Error in %s () a NULL pointer was found in the color_name member.\n")),
02193                   __FUNCTION__);
02194                 return (NULL);
02195         }
02196 #if DEBUG
02197         DXF_DEBUG_END
02198 #endif
02199         return (strdup (line->color_name));
02200 }
02201 
02202 
02209 DxfLine *
02210 dxf_line_set_color_name
02211 (
02212         DxfLine *line,
02214         char *color_name
02217 )
02218 {
02219 #if DEBUG
02220         DXF_DEBUG_BEGIN
02221 #endif
02222         /* Do some basic checks. */
02223         if (line == NULL)
02224         {
02225                 fprintf (stderr,
02226                   (_("Error in %s () a NULL pointer was passed.\n")),
02227                   __FUNCTION__);
02228                 return (NULL);
02229         }
02230         if (color_name == NULL)
02231         {
02232                 fprintf (stderr,
02233                   (_("Error in %s () a NULL pointer was passed.\n")),
02234                   __FUNCTION__);
02235                 return (NULL);
02236         }
02237         line->color_name = strdup (color_name);
02238 #if DEBUG
02239         DXF_DEBUG_END
02240 #endif
02241         return (line);
02242 }
02243 
02244 
02251 long
02252 dxf_line_get_transparency
02253 (
02254         DxfLine *line
02256 )
02257 {
02258 #if DEBUG
02259         DXF_DEBUG_BEGIN
02260 #endif
02261         /* Do some basic checks. */
02262         if (line == NULL)
02263         {
02264                 fprintf (stderr,
02265                   (_("Error in %s () a NULL pointer was passed.\n")),
02266                   __FUNCTION__);
02267                 return (EXIT_FAILURE);
02268         }
02269 #if DEBUG
02270         DXF_DEBUG_END
02271 #endif
02272         return (line->transparency);
02273 }
02274 
02275 
02282 DxfLine *
02283 dxf_line_set_transparency
02284 (
02285         DxfLine *line,
02287         long transparency
02289 )
02290 {
02291 #if DEBUG
02292         DXF_DEBUG_BEGIN
02293 #endif
02294         /* Do some basic checks. */
02295         if (line == NULL)
02296         {
02297                 fprintf (stderr,
02298                   (_("Error in %s () a NULL pointer was passed.\n")),
02299                   __FUNCTION__);
02300                 return (NULL);
02301         }
02302         line->transparency = transparency;
02303 #if DEBUG
02304         DXF_DEBUG_END
02305 #endif
02306         return (line);
02307 }
02308 
02309 
02315 DxfPoint *
02316 dxf_line_get_p0
02317 (
02318         DxfLine *line
02320 )
02321 {
02322 #ifdef DEBUG
02323         DXF_DEBUG_BEGIN
02324 #endif
02325         /* Do some basic checks. */
02326         if (line == NULL)
02327         {
02328                 fprintf (stderr,
02329                   (_("Error in %s () a NULL pointer was passed.\n")),
02330                   __FUNCTION__);
02331                 return (NULL);
02332         }
02333         if (line->p0 == NULL)
02334         {
02335                 fprintf (stderr,
02336                   (_("Error in %s () a NULL pointer was found.\n")),
02337                   __FUNCTION__);
02338                 return (NULL);
02339         }
02340 #if DEBUG
02341         DXF_DEBUG_END
02342 #endif
02343         return ((DxfPoint *) line->p0);
02344 }
02345 
02346 
02352 DxfLine *
02353 dxf_line_set_p0
02354 (
02355         DxfLine *line,
02357         DxfPoint *p0
02359 )
02360 {
02361 #ifdef DEBUG
02362         DXF_DEBUG_BEGIN
02363 #endif
02364         /* Do some basic checks. */
02365         if (line == NULL)
02366         {
02367                 fprintf (stderr,
02368                   (_("Error in %s () a NULL pointer was passed.\n")),
02369                   __FUNCTION__);
02370                 return (NULL);
02371         }
02372         if (p0 == NULL)
02373         {
02374                 fprintf (stderr,
02375                   (_("Error in %s () a NULL pointer was passed.\n")),
02376                   __FUNCTION__);
02377                 return (NULL);
02378         }
02379         line->p0 = p0;
02380 #if DEBUG
02381         DXF_DEBUG_END
02382 #endif
02383         return (line);
02384 }
02385 
02386 
02393 double
02394 dxf_line_get_x0
02395 (
02396         DxfLine *line
02398 )
02399 {
02400 #ifdef DEBUG
02401         DXF_DEBUG_BEGIN
02402 #endif
02403 
02404         /* Do some basic checks. */
02405         if (line == NULL)
02406         {
02407                 fprintf (stderr,
02408                   (_("Error in %s () a NULL pointer was passed.\n")),
02409                   __FUNCTION__);
02410                 return (EXIT_FAILURE);
02411         }
02412         if (line->p0 == NULL)
02413         {
02414                 fprintf (stderr,
02415                   (_("Error in %s () a NULL pointer was passed.\n")),
02416                   __FUNCTION__);
02417                 return (EXIT_FAILURE);
02418         }
02419 #if DEBUG
02420         DXF_DEBUG_END
02421 #endif
02422         return (line->p0->x0);
02423 }
02424 
02425 
02433 DxfLine *
02434 dxf_line_set_x0
02435 (
02436         DxfLine *line,
02438         double x0
02441 )
02442 {
02443 #ifdef DEBUG
02444         DXF_DEBUG_BEGIN
02445 #endif
02446         /* Do some basic checks. */
02447         if (line == NULL)
02448         {
02449                 fprintf (stderr,
02450                   (_("Error in %s () a NULL pointer was passed.\n")),
02451                   __FUNCTION__);
02452                 return (NULL);
02453         }
02454         if (line->p0 == NULL)
02455         {
02456                 fprintf (stderr,
02457                   (_("Error in %s () a NULL pointer was found.\n")),
02458                   __FUNCTION__);
02459                 return (NULL);
02460         }
02461         line->p0->x0 = x0;
02462 #if DEBUG
02463         DXF_DEBUG_END
02464 #endif
02465         return (line);
02466 }
02467 
02468 
02475 double
02476 dxf_line_get_y0
02477 (
02478         DxfLine *line
02480 )
02481 {
02482 #ifdef DEBUG
02483         DXF_DEBUG_BEGIN
02484 #endif
02485 
02486         /* Do some basic checks. */
02487         if (line == NULL)
02488         {
02489                 fprintf (stderr,
02490                   (_("Error in %s () a NULL pointer was passed.\n")),
02491                   __FUNCTION__);
02492                 return (EXIT_FAILURE);
02493         }
02494         if (line->p0 == NULL)
02495         {
02496                 fprintf (stderr,
02497                   (_("Error in %s () a NULL pointer was found.\n")),
02498                   __FUNCTION__);
02499                 return (EXIT_FAILURE);
02500         }
02501 #if DEBUG
02502         DXF_DEBUG_END
02503 #endif
02504         return (line->p0->y0);
02505 }
02506 
02507 
02515 DxfLine *
02516 dxf_line_set_y0
02517 (
02518         DxfLine *line,
02520         double y0
02523 )
02524 {
02525 #ifdef DEBUG
02526         DXF_DEBUG_BEGIN
02527 #endif
02528         /* Do some basic checks. */
02529         if (line == NULL)
02530         {
02531                 fprintf (stderr,
02532                   (_("Error in %s () a NULL pointer was passed.\n")),
02533                   __FUNCTION__);
02534                 return (NULL);
02535         }
02536         if (line->p0 == NULL)
02537         {
02538                 fprintf (stderr,
02539                   (_("Error in %s () a NULL pointer was found.\n")),
02540                   __FUNCTION__);
02541                 return (NULL);
02542         }
02543         line->p0->y0 = y0;
02544 #if DEBUG
02545         DXF_DEBUG_END
02546 #endif
02547         return (line);
02548 }
02549 
02550 
02557 double
02558 dxf_line_get_z0
02559 (
02560         DxfLine *line
02562 )
02563 {
02564 #ifdef DEBUG
02565         DXF_DEBUG_BEGIN
02566 #endif
02567 
02568         /* Do some basic checks. */
02569         if (line == NULL)
02570         {
02571                 fprintf (stderr,
02572                   (_("Error in %s () a NULL pointer was passed.\n")),
02573                   __FUNCTION__);
02574                 return (EXIT_FAILURE);
02575         }
02576         if (line->p0 == NULL)
02577         {
02578                 fprintf (stderr,
02579                   (_("Error in %s () a NULL pointer was found.\n")),
02580                   __FUNCTION__);
02581                 return (EXIT_FAILURE);
02582         }
02583 #if DEBUG
02584         DXF_DEBUG_END
02585 #endif
02586         return (line->p0->z0);
02587 }
02588 
02589 
02597 DxfLine *
02598 dxf_line_set_z0
02599 (
02600         DxfLine *line,
02602         double z0
02605 )
02606 {
02607 #ifdef DEBUG
02608         DXF_DEBUG_BEGIN
02609 #endif
02610         /* Do some basic checks. */
02611         if (line == NULL)
02612         {
02613                 fprintf (stderr,
02614                   (_("Error in %s () a NULL pointer was passed.\n")),
02615                   __FUNCTION__);
02616                 return (NULL);
02617         }
02618         if (line->p0 == NULL)
02619         {
02620                 fprintf (stderr,
02621                   (_("Error in %s () a NULL pointer was found.\n")),
02622                   __FUNCTION__);
02623                 return (NULL);
02624         }
02625         line->p0->z0 = z0;
02626 #if DEBUG
02627         DXF_DEBUG_END
02628 #endif
02629         return (line);
02630 }
02631 
02632 
02638 DxfPoint *
02639 dxf_line_get_p1
02640 (
02641         DxfLine *line
02643 )
02644 {
02645 #ifdef DEBUG
02646         DXF_DEBUG_BEGIN
02647 #endif
02648         /* Do some basic checks. */
02649         if (line == NULL)
02650         {
02651                 fprintf (stderr,
02652                   (_("Error in %s () a NULL pointer was passed.\n")),
02653                   __FUNCTION__);
02654                 return (NULL);
02655         }
02656         if (line->p1 == NULL)
02657         {
02658                 fprintf (stderr,
02659                   (_("Error in %s () a NULL pointer was found.\n")),
02660                   __FUNCTION__);
02661                 return (NULL);
02662         }
02663 #if DEBUG
02664         DXF_DEBUG_END
02665 #endif
02666         return (line->p1);
02667 }
02668 
02669 
02675 DxfLine *
02676 dxf_line_set_p1
02677 (
02678         DxfLine *line,
02680         DxfPoint *p1
02682 )
02683 {
02684 #ifdef DEBUG
02685         DXF_DEBUG_BEGIN
02686 #endif
02687         /* Do some basic checks. */
02688         if (line == NULL)
02689         {
02690                 fprintf (stderr,
02691                   (_("Error in %s () a NULL pointer was passed.\n")),
02692                   __FUNCTION__);
02693                 return (NULL);
02694         }
02695         if (p1 == NULL)
02696         {
02697                 fprintf (stderr,
02698                   (_("Error in %s () a NULL pointer was passed.\n")),
02699                   __FUNCTION__);
02700                 return (NULL);
02701         }
02702         line->p1 = p1;
02703 #if DEBUG
02704         DXF_DEBUG_END
02705 #endif
02706         return (line);
02707 }
02708 
02709 
02716 double
02717 dxf_line_get_x1
02718 (
02719         DxfLine *line
02721 )
02722 {
02723 #ifdef DEBUG
02724         DXF_DEBUG_BEGIN
02725 #endif
02726 
02727         /* Do some basic checks. */
02728         if (line == NULL)
02729         {
02730                 fprintf (stderr,
02731                   (_("Error in %s () a NULL pointer was passed.\n")),
02732                   __FUNCTION__);
02733                 return (EXIT_FAILURE);
02734         }
02735         if (line->p1 == NULL)
02736         {
02737                 fprintf (stderr,
02738                   (_("Error in %s () a NULL pointer was passed.\n")),
02739                   __FUNCTION__);
02740                 return (EXIT_FAILURE);
02741         }
02742 #if DEBUG
02743         DXF_DEBUG_END
02744 #endif
02745         return (line->p1->x0);
02746 }
02747 
02748 
02756 DxfLine *
02757 dxf_line_set_x1
02758 (
02759         DxfLine *line,
02761         double x1
02764 )
02765 {
02766 #ifdef DEBUG
02767         DXF_DEBUG_BEGIN
02768 #endif
02769         /* Do some basic checks. */
02770         if (line == NULL)
02771         {
02772                 fprintf (stderr,
02773                   (_("Error in %s () a NULL pointer was passed.\n")),
02774                   __FUNCTION__);
02775                 return (NULL);
02776         }
02777         if (line->p1 == NULL)
02778         {
02779                 fprintf (stderr,
02780                   (_("Error in %s () a NULL pointer was found.\n")),
02781                   __FUNCTION__);
02782                 return (NULL);
02783         }
02784         line->p1->x0 = x1;
02785 #if DEBUG
02786         DXF_DEBUG_END
02787 #endif
02788         return (line);
02789 }
02790 
02791 
02798 double
02799 dxf_line_get_y1
02800 (
02801         DxfLine *line
02803 )
02804 {
02805 #ifdef DEBUG
02806         DXF_DEBUG_BEGIN
02807 #endif
02808 
02809         /* Do some basic checks. */
02810         if (line == NULL)
02811         {
02812                 fprintf (stderr,
02813                   (_("Error in %s () a NULL pointer was passed.\n")),
02814                   __FUNCTION__);
02815                 return (EXIT_FAILURE);
02816         }
02817         if (line->p1 == NULL)
02818         {
02819                 fprintf (stderr,
02820                   (_("Error in %s () a NULL pointer was found.\n")),
02821                   __FUNCTION__);
02822                 return (EXIT_FAILURE);
02823         }
02824 #if DEBUG
02825         DXF_DEBUG_END
02826 #endif
02827         return (line->p1->y0);
02828 }
02829 
02830 
02838 DxfLine *
02839 dxf_line_set_y1
02840 (
02841         DxfLine *line,
02843         double y1
02846 )
02847 {
02848 #ifdef DEBUG
02849         DXF_DEBUG_BEGIN
02850 #endif
02851         /* Do some basic checks. */
02852         if (line == NULL)
02853         {
02854                 fprintf (stderr,
02855                   (_("Error in %s () a NULL pointer was passed.\n")),
02856                   __FUNCTION__);
02857                 return (NULL);
02858         }
02859         if (line->p1 == NULL)
02860         {
02861                 fprintf (stderr,
02862                   (_("Error in %s () a NULL pointer was found.\n")),
02863                   __FUNCTION__);
02864                 return (NULL);
02865         }
02866         line->p1->y0 = y1;
02867 #if DEBUG
02868         DXF_DEBUG_END
02869 #endif
02870         return (line);
02871 }
02872 
02873 
02880 double
02881 dxf_line_get_z1
02882 (
02883         DxfLine *line
02885 )
02886 {
02887 #ifdef DEBUG
02888         DXF_DEBUG_BEGIN
02889 #endif
02890 
02891         /* Do some basic checks. */
02892         if (line == NULL)
02893         {
02894                 fprintf (stderr,
02895                   (_("Error in %s () a NULL pointer was passed.\n")),
02896                   __FUNCTION__);
02897                 return (EXIT_FAILURE);
02898         }
02899         if (line->p1 == NULL)
02900         {
02901                 fprintf (stderr,
02902                   (_("Error in %s () a NULL pointer was found.\n")),
02903                   __FUNCTION__);
02904                 return (EXIT_FAILURE);
02905         }
02906 #if DEBUG
02907         DXF_DEBUG_END
02908 #endif
02909         return (line->p1->z0);
02910 }
02911 
02912 
02920 DxfLine *
02921 dxf_line_set_z1
02922 (
02923         DxfLine *line,
02925         double z1
02928 )
02929 {
02930 #ifdef DEBUG
02931         DXF_DEBUG_BEGIN
02932 #endif
02933         /* Do some basic checks. */
02934         if (line == NULL)
02935         {
02936                 fprintf (stderr,
02937                   (_("Error in %s () a NULL pointer was passed.\n")),
02938                   __FUNCTION__);
02939                 return (NULL);
02940         }
02941         if (line->p1 == NULL)
02942         {
02943                 fprintf (stderr,
02944                   (_("Error in %s () a NULL pointer was found.\n")),
02945                   __FUNCTION__);
02946                 return (NULL);
02947         }
02948         line->p1->z0 = z1;
02949 #if DEBUG
02950         DXF_DEBUG_END
02951 #endif
02952         return (line);
02953 }
02954 
02955 
02962 double
02963 dxf_line_get_extr_x0
02964 (
02965         DxfLine *line
02967 )
02968 {
02969 #ifdef DEBUG
02970         DXF_DEBUG_BEGIN
02971 #endif
02972 
02973         /* Do some basic checks. */
02974         if (line == NULL)
02975         {
02976                 fprintf (stderr,
02977                   (_("Error in %s () a NULL pointer was passed.\n")),
02978                   __FUNCTION__);
02979                 return (EXIT_FAILURE);
02980         }
02981 #if DEBUG
02982         DXF_DEBUG_END
02983 #endif
02984         return (line->extr_x0);
02985 }
02986 
02987 
02995 DxfLine *
02996 dxf_line_set_extr_x0
02997 (
02998         DxfLine *line,
03000         double extr_x0
03003 )
03004 {
03005 #ifdef DEBUG
03006         DXF_DEBUG_BEGIN
03007 #endif
03008         /* Do some basic checks. */
03009         if (line == NULL)
03010         {
03011                 fprintf (stderr,
03012                   (_("Error in %s () a NULL pointer was passed.\n")),
03013                   __FUNCTION__);
03014                 return (NULL);
03015         }
03016         line->extr_x0 = extr_x0;
03017 #if DEBUG
03018         DXF_DEBUG_END
03019 #endif
03020         return (line);
03021 }
03022 
03023 
03030 double
03031 dxf_line_get_extr_y0
03032 (
03033         DxfLine *line
03035 )
03036 {
03037 #ifdef DEBUG
03038         DXF_DEBUG_BEGIN
03039 #endif
03040 
03041         /* Do some basic checks. */
03042         if (line == NULL)
03043         {
03044                 fprintf (stderr,
03045                   (_("Error in %s () a NULL pointer was passed.\n")),
03046                   __FUNCTION__);
03047                 return (EXIT_FAILURE);
03048         }
03049 #if DEBUG
03050         DXF_DEBUG_END
03051 #endif
03052         return (line->extr_y0);
03053 }
03054 
03055 
03063 DxfLine *
03064 dxf_line_set_extr_y0
03065 (
03066         DxfLine *line,
03068         double extr_y0
03071 )
03072 {
03073 #ifdef DEBUG
03074         DXF_DEBUG_BEGIN
03075 #endif
03076         /* Do some basic checks. */
03077         if (line == NULL)
03078         {
03079                 fprintf (stderr,
03080                   (_("Error in %s () a NULL pointer was passed.\n")),
03081                   __FUNCTION__);
03082                 return (NULL);
03083         }
03084         line->extr_y0 = extr_y0;
03085 #if DEBUG
03086         DXF_DEBUG_END
03087 #endif
03088         return (line);
03089 }
03090 
03091 
03098 double
03099 dxf_line_get_extr_z0
03100 (
03101         DxfLine *line
03103 )
03104 {
03105 #ifdef DEBUG
03106         DXF_DEBUG_BEGIN
03107 #endif
03108 
03109         /* Do some basic checks. */
03110         if (line == NULL)
03111         {
03112                 fprintf (stderr,
03113                   (_("Error in %s () a NULL pointer was passed.\n")),
03114                   __FUNCTION__);
03115                 return (EXIT_FAILURE);
03116         }
03117 #if DEBUG
03118         DXF_DEBUG_END
03119 #endif
03120         return (line->extr_z0);
03121 }
03122 
03123 
03131 DxfLine *
03132 dxf_line_set_extr_z0
03133 (
03134         DxfLine *line,
03136         double extr_z0
03139 )
03140 {
03141 #ifdef DEBUG
03142         DXF_DEBUG_BEGIN
03143 #endif
03144         /* Do some basic checks. */
03145         if (line == NULL)
03146         {
03147                 fprintf (stderr,
03148                   (_("Error in %s () a NULL pointer was passed.\n")),
03149                   __FUNCTION__);
03150                 return (NULL);
03151         }
03152         line->extr_z0 = extr_z0;
03153 #if DEBUG
03154         DXF_DEBUG_END
03155 #endif
03156         return (line);
03157 }
03158 
03159 
03168 DxfPoint *
03169 dxf_line_get_extrusion_vector_as_point
03170 (
03171         DxfLine *line
03173 )
03174 {
03175 #ifdef DEBUG
03176         DXF_DEBUG_BEGIN
03177 #endif
03178         DxfPoint *point = NULL;
03179 
03180         /* Do some basic checks. */
03181         if (line == NULL)
03182         {
03183                 fprintf (stderr,
03184                   (_("Error in %s () a NULL pointer was passed.\n")),
03185                   __FUNCTION__);
03186                 return (NULL);
03187         }
03188         if ((line->p0->x0 == line->p1->x0)
03189           && (line->p0->y0 == line->p1->y0)
03190           && (line->p0->z0 == line->p1->z0))
03191         {
03192                 fprintf (stderr,
03193                   (_("Error in %s () a 3DLINE with points with identical coordinates were passed.\n")),
03194                   __FUNCTION__);
03195                 return (NULL);
03196         }
03197         point = dxf_point_init (point);
03198         if (point == NULL)
03199         {
03200               fprintf (stderr,
03201                   (_("Error in %s () could not allocate memory for a DxfPoint struct.\n")),
03202                 __FUNCTION__);
03203               return (NULL);
03204         }
03205         point->x0 = line->extr_x0;
03206         point->y0 = line->extr_y0;
03207         point->z0 = line->extr_z0;
03208 #if DEBUG
03209         DXF_DEBUG_END
03210 #endif
03211         return (point);
03212 }
03213 
03214 
03218 DxfLine *
03219 dxf_line_set_extrusion_vector
03220 (
03221         DxfLine *line,
03223         double extr_x0,
03225         double extr_y0,
03227         double extr_z0
03229 )
03230 {
03231 #if DEBUG
03232         DXF_DEBUG_BEGIN
03233 #endif
03234         /* Do some basic checks. */
03235         if (line == NULL)
03236         {
03237                 fprintf (stderr,
03238                   (_("Error in %s () a NULL pointer was passed.\n")),
03239                   __FUNCTION__);
03240                 return (NULL);
03241         }
03242         line->extr_x0 = extr_x0;
03243         line->extr_y0 = extr_y0;
03244         line->extr_z0 = extr_z0;
03245 #if DEBUG
03246         DXF_DEBUG_END
03247 #endif
03248         return (line);
03249 }
03250 
03251 
03260 DxfLine *
03261 dxf_line_get_next
03262 (
03263         DxfLine *line
03265 )
03266 {
03267 #if DEBUG
03268         DXF_DEBUG_BEGIN
03269 #endif
03270         /* Do some basic checks. */
03271         if (line == NULL)
03272         {
03273                 fprintf (stderr,
03274                   (_("Error in %s () a NULL pointer was passed.\n")),
03275                   __FUNCTION__);
03276                 return (NULL);
03277         }
03278         if (line->next == NULL)
03279         {
03280                 fprintf (stderr,
03281                   (_("Error in %s () a NULL pointer was found in the next member.\n")),
03282                   __FUNCTION__);
03283                 return (NULL);
03284         }
03285 #if DEBUG
03286         DXF_DEBUG_END
03287 #endif
03288         return ((DxfLine *) line->next);
03289 }
03290 
03291 
03296 DxfLine *
03297 dxf_line_set_next
03298 (
03299         DxfLine *line,
03301         DxfLine *next
03303 )
03304 {
03305 #if DEBUG
03306         DXF_DEBUG_BEGIN
03307 #endif
03308         /* Do some basic checks. */
03309         if (line == NULL)
03310         {
03311                 fprintf (stderr,
03312                   (_("Error in %s () a NULL pointer was passed.\n")),
03313                   __FUNCTION__);
03314                 return (NULL);
03315         }
03316         if (next == NULL)
03317         {
03318                 fprintf (stderr,
03319                   (_("Error in %s () a NULL pointer was passed.\n")),
03320                   __FUNCTION__);
03321                 return (NULL);
03322         }
03323         line->next = (struct DxfLine *) next;
03324 #if DEBUG
03325         DXF_DEBUG_END
03326 #endif
03327         return (line);
03328 }
03329 
03330 
03339 DxfLine *
03340 dxf_line_get_last
03341 (
03342         DxfLine *line
03344 )
03345 {
03346 #if DEBUG
03347         DXF_DEBUG_BEGIN
03348 #endif
03349         /* Do some basic checks. */
03350         if (line == NULL)
03351         {
03352                 fprintf (stderr,
03353                   (_("Error in %s () a NULL pointer was passed.\n")),
03354                   __FUNCTION__);
03355                 return (NULL);
03356         }
03357         if (line->next == NULL)
03358         {
03359                 fprintf (stderr,
03360                   (_("Warning in %s () a NULL pointer was found.\n")),
03361                   __FUNCTION__);
03362                 return ((DxfLine *) line);
03363         }
03364         DxfLine *iter = (DxfLine *) line->next;
03365         while (iter->next != NULL)
03366         {
03367                 iter = (DxfLine *) iter->next;
03368         }
03369 #if DEBUG
03370         DXF_DEBUG_END
03371 #endif
03372         return ((DxfLine *) iter);
03373 }
03374 
03375 
03381 DxfPoint *
03382 dxf_line_calculate_mid_point
03383 (
03384         DxfLine *line,
03386         int id_code,
03390         int inheritance
03398 )
03399 {
03400 #ifdef DEBUG
03401         DXF_DEBUG_BEGIN
03402 #endif
03403         DxfPoint *point = NULL;
03404 
03405         /* Do some basic checks. */
03406         if (line == NULL)
03407         {
03408                 fprintf (stderr,
03409                   (_("Error in %s () a NULL pointer was passed.\n")),
03410                   __FUNCTION__);
03411                 return (NULL);
03412         }
03413         if ((line->p0->x0 == line->p1->x0)
03414           && (line->p0->y0 == line->p1->y0)
03415           && (line->p0->z0 == line->p1->z0))
03416         {
03417                 fprintf (stderr,
03418                   (_("Error in %s () a 3DLINE with points with identical coordinates were passed.\n")),
03419                   __FUNCTION__);
03420                 return (NULL);
03421         }
03422         point = dxf_point_init (point);
03423         if (point == NULL)
03424         {
03425               fprintf (stderr,
03426                   (_("Error in %s () could not allocate memory for a DxfPoint struct.\n")),
03427                 __FUNCTION__);
03428               return (NULL);
03429         }
03430         if (id_code < 0)
03431         {
03432               fprintf (stderr,
03433                   (_("Warning in %s () passed id_code is smaller than 0.\n")),
03434                 __FUNCTION__);
03435         }
03436         point->id_code = id_code;
03437         point->x0 = (line->p0->x0 + line->p1->x0) / 2;
03438         point->y0 = (line->p0->y0 + line->p1->y0) / 2;
03439         point->z0 = (line->p0->z0 + line->p1->z0) / 2;
03440         switch (inheritance)
03441         {
03442                 case 0:
03443                         /* Do nothing. */
03444                         break;
03445                 case 1:
03446                         if (line->linetype != NULL)
03447                         {
03448                                 point->linetype = strdup (line->linetype);
03449                         }
03450                         if (line->layer != NULL)
03451                         {
03452                                 point->layer = strdup (line->layer);
03453                         }
03454                         point->thickness = line->thickness;
03455                         point->linetype_scale = line->linetype_scale;
03456                         point->visibility = line->visibility;
03457                         point->color = line->color;
03458                         point->paperspace = line->paperspace;
03459                         if (line->dictionary_owner_soft != NULL)
03460                         {
03461                                 point->dictionary_owner_soft = strdup (line->dictionary_owner_soft);
03462                         }
03463                         if (line->dictionary_owner_hard != NULL)
03464                         {
03465                                 point->dictionary_owner_hard = strdup (line->dictionary_owner_hard);
03466                         }
03467                         break;
03468                 default:
03469                         fprintf (stderr,
03470                           (_("Warning in %s (): unknown inheritance option passed.\n")),
03471                           __FUNCTION__);
03472                         fprintf (stderr,
03473                           (_("\tResolving to default.\n")));
03474                         break;
03475         }
03476 #if DEBUG
03477         DXF_DEBUG_END
03478 #endif
03479         return (point);
03480 }
03481 
03482 
03489 double
03490 dxf_line_calculate_length
03491 (
03492         DxfLine *line
03494 )
03495 {
03496 #ifdef DEBUG
03497         DXF_DEBUG_BEGIN
03498 #endif
03499         double length;
03500 
03501         /* Do some basic checks. */
03502         if (line == NULL)
03503         {
03504                 fprintf (stderr,
03505                   (_("Error in %s () a NULL pointer was passed.\n")),
03506                   __FUNCTION__);
03507                 return (0.0);
03508         }
03509         if ((line->p0->x0 == line->p1->x0)
03510           && (line->p0->y0 == line->p1->y0)
03511           && (line->p0->z0 == line->p1->z0))
03512         {
03513                 fprintf (stderr,
03514                   (_("Error in %s () endpoints with identical coordinates were passed.\n")),
03515                   __FUNCTION__);
03516                 return (0.0);
03517         }
03518         length = sqrt
03519         (
03520           ((line->p1->x0 - line->p0->x0) * (line->p1->x0 - line->p0->x0))
03521           + ((line->p1->y0 - line->p0->y0) * (line->p1->y0 - line->p0->y0))
03522           + ((line->p1->z0 - line->p0->z0) * (line->p1->z0 - line->p0->z0))
03523         );
03524 #if DEBUG
03525         DXF_DEBUG_END
03526 #endif
03527         return (length);
03528 }
03529 
03530 
03539 DxfLine *
03540 dxf_line_create_from_points
03541 (
03542         DxfPoint *p1,
03544         DxfPoint *p2,
03546         int id_code,
03550         int inheritance
03559 )
03560 {
03561 #if DEBUG
03562         DXF_DEBUG_BEGIN
03563 #endif
03564         DxfLine *line = NULL;
03565 
03566         /* Do some basic checks. */
03567         if ((p1 == NULL) || (p2 == NULL))
03568         {
03569                 fprintf (stderr,
03570                   (_("Error in %s () a NULL pointer was passed.\n")),
03571                   __FUNCTION__);
03572                 return (NULL);
03573         }
03574         if ((p1->x0 == p2->x0) && (p1->y0 == p2->y0) && (p1->z0 == p2->z0))
03575         {
03576                 fprintf (stderr,
03577                   (_("Error in %s () points with identical coordinates were passed.\n")),
03578                   __FUNCTION__);
03579                 return (NULL);
03580         }
03581         if ((inheritance < 0) || (inheritance > 2))
03582         {
03583                 fprintf (stderr,
03584                   (_("Error in %s () an illegal inherit value was passed.\n")),
03585                   __FUNCTION__);
03586                 return (NULL);
03587         }
03588         line = dxf_line_init (line);
03589         if (line == NULL)
03590         {
03591               fprintf (stderr,
03592                   (_("Error in %s () could not allocate memory for a DxfLine struct.\n")),
03593                 __FUNCTION__);
03594               return (NULL);
03595         }
03596         if (id_code < 0)
03597         {
03598               fprintf (stderr,
03599                   (_("Warning in %s () passed id_code is smaller than 0.\n")),
03600                 __FUNCTION__);
03601         }
03602         line->id_code = id_code;
03603         line->p0->x0 = p1->x0;
03604         line->p0->y0 = p1->y0;
03605         line->p0->z0 = p1->z0;
03606         line->p1->x0 = p2->x0;
03607         line->p1->y0 = p2->y0;
03608         line->p1->z0 = p2->z0;
03609         switch (inheritance)
03610         {
03611                 case 0:
03612                         /* Do nothing. */
03613                         break;
03614                 case 1:
03615                         if (p1->linetype != NULL)
03616                         {
03617                                 line->linetype = p1->linetype;
03618                         }
03619                         if (p1->layer != NULL)
03620                         {
03621                                 line->layer = p1->layer;
03622                         }
03623                         line->thickness = p1->thickness;
03624                         line->linetype_scale = p1->linetype_scale;
03625                         line->visibility = p1->visibility;
03626                         line->color = p1->color;
03627                         line->paperspace = p1->paperspace;
03628                         line->graphics_data_size = p1->graphics_data_size;
03629                         line-> shadow_mode = p1->shadow_mode;
03631                         line->binary_graphics_data = p1->binary_graphics_data;
03632                         if (p1->dictionary_owner_soft != NULL)
03633                         {
03634                                 line->dictionary_owner_soft = strdup (p1->dictionary_owner_soft);
03635                         }
03636                         if (p1->material != NULL)
03637                         {
03638                                 line->material = strdup (p1->material);
03639                         }
03640                         if (p1->dictionary_owner_hard != NULL)
03641                         {
03642                                 line->dictionary_owner_hard = strdup (p1->dictionary_owner_hard);
03643                         }
03644                         line->lineweight = p1->lineweight;
03645                         if (p1->plot_style_name != NULL)
03646                         {
03647                                 line->plot_style_name = strdup (p1->plot_style_name);
03648                         }
03649                         line->color_value = p1->color_value;
03650                         if (p1->color_name != NULL)
03651                         {
03652                                 line->color_name = strdup (p1->color_name);
03653                         }
03654                         line->transparency = p1->transparency;
03655                         break;
03656                 case 2:
03657                         if (p2->linetype != NULL)
03658                         {
03659                                 line->linetype = p2->linetype;
03660                         }
03661                         if (p2->layer != NULL)
03662                         {
03663                                 line->layer = p2->layer;
03664                         }
03665                         line->thickness = p2->thickness;
03666                         line->linetype_scale = p2->linetype_scale;
03667                         line->visibility = p2->visibility;
03668                         line->color = p2->color;
03669                         line->paperspace = p2->paperspace;
03670                         line->graphics_data_size = p2->graphics_data_size;
03671                         line-> shadow_mode = p2->shadow_mode;
03673                         line->binary_graphics_data = p2->binary_graphics_data;
03674                         if (p2->dictionary_owner_soft != NULL)
03675                         {
03676                                 line->dictionary_owner_soft = strdup (p2->dictionary_owner_soft);
03677                         }
03678                         if (p2->material != NULL)
03679                         {
03680                                 line->material = strdup (p2->material);
03681                         }
03682                         if (p2->dictionary_owner_hard != NULL)
03683                         {
03684                                 line->dictionary_owner_hard = strdup (p2->dictionary_owner_hard);
03685                         }
03686                         line->lineweight = p2->lineweight;
03687                         if (p2->plot_style_name != NULL)
03688                         {
03689                                 line->plot_style_name = strdup (p2->plot_style_name);
03690                         }
03691                         line->color_value = p2->color_value;
03692                         if (p2->color_name != NULL)
03693                         {
03694                                 line->color_name = strdup (p2->color_name);
03695                         }
03696                         line->transparency = p2->transparency;
03697                         break;
03698                 default:
03699                         fprintf (stderr,
03700                           (_("Warning in %s (): unknown inheritance option passed.\n")),
03701                           __FUNCTION__);
03702                         fprintf (stderr,
03703                           (_("\tResolving to default.\n")));
03704                         break;
03705         }
03706 #if DEBUG
03707         DXF_DEBUG_END
03708 #endif
03709         return (line);
03710 }
03711 
03712 
03713 /* EOF */