libDXF 0.0.1
A library with DXF related functions written in C.
|
00001 00051 #include "3dsolid.h" 00052 00053 00059 Dxf3dsolid * 00060 dxf_3dsolid_new () 00061 { 00062 #if DEBUG 00063 DXF_DEBUG_BEGIN 00064 #endif 00065 Dxf3dsolid *solid = NULL; 00066 size_t size; 00067 00068 size = sizeof (Dxf3dsolid); 00069 /* avoid malloc of 0 bytes */ 00070 if (size == 0) size = 1; 00071 if ((solid = malloc (size)) == NULL) 00072 { 00073 fprintf (stderr, 00074 (_("Error in %s () could not allocate memory.\n")), 00075 __FUNCTION__); 00076 return (NULL); 00077 } 00078 else 00079 { 00080 memset (solid, 0, size); 00081 } 00082 #if DEBUG 00083 DXF_DEBUG_END 00084 #endif 00085 return (solid); 00086 } 00087 00088 00096 Dxf3dsolid * 00097 dxf_3dsolid_init 00098 ( 00099 Dxf3dsolid *solid 00101 ) 00102 { 00103 #if DEBUG 00104 DXF_DEBUG_BEGIN 00105 #endif 00106 /* Do some basic checks. */ 00107 if (solid == NULL) 00108 { 00109 fprintf (stderr, 00110 (_("Warning in %s () a NULL pointer was passed.\n")), 00111 __FUNCTION__); 00112 solid = dxf_3dsolid_new (); 00113 } 00114 if (solid == NULL) 00115 { 00116 fprintf (stderr, 00117 (_("Error in %s () could not allocate memory.\n")), 00118 __FUNCTION__); 00119 return (NULL); 00120 } 00121 dxf_3dsolid_set_id_code (solid, 0); 00122 dxf_3dsolid_set_linetype (solid, strdup (DXF_DEFAULT_LINETYPE)); 00123 dxf_3dsolid_set_layer (solid, strdup (DXF_DEFAULT_LAYER)); 00124 dxf_3dsolid_set_elevation (solid, 0.0); 00125 dxf_3dsolid_set_thickness (solid, 0.0); 00126 dxf_3dsolid_set_linetype_scale (solid, DXF_DEFAULT_LINETYPE_SCALE); 00127 dxf_3dsolid_set_visibility (solid, DXF_DEFAULT_VISIBILITY); 00128 dxf_3dsolid_set_color (solid, DXF_COLOR_BYLAYER); 00129 dxf_3dsolid_set_paperspace (solid, DXF_MODELSPACE); 00130 dxf_3dsolid_set_graphics_data_size (solid, 0); 00131 dxf_3dsolid_set_shadow_mode (solid, 0); 00132 dxf_3dsolid_set_binary_graphics_data (solid, (DxfBinaryGraphicsData *) dxf_binary_graphics_data_new ()); 00133 dxf_binary_graphics_data_init ((DxfBinaryGraphicsData *) dxf_3dsolid_get_binary_graphics_data (solid)); 00134 dxf_3dsolid_set_dictionary_owner_soft (solid, strdup ("")); 00135 dxf_3dsolid_set_material (solid, strdup ("")); 00136 dxf_3dsolid_set_dictionary_owner_hard (solid, strdup ("")); 00137 dxf_3dsolid_set_lineweight (solid, 0); 00138 dxf_3dsolid_set_plot_style_name (solid, strdup ("")); 00139 dxf_3dsolid_set_color_value (solid, 0); 00140 dxf_3dsolid_set_color_name (solid, strdup ("")); 00141 dxf_3dsolid_set_transparency (solid, 0); 00142 dxf_3dsolid_set_proprietary_data (solid, (DxfProprietaryData *) dxf_proprietary_data_init (solid->proprietary_data)); 00143 dxf_3dsolid_set_additional_proprietary_data (solid, (DxfProprietaryData *) dxf_proprietary_data_init (solid->additional_proprietary_data)); 00144 dxf_3dsolid_set_modeler_format_version_number (solid, 1); 00145 dxf_3dsolid_set_history (solid, strdup ("")); 00146 dxf_3dsolid_set_next (solid, NULL); 00147 #if DEBUG 00148 DXF_DEBUG_END 00149 #endif 00150 return (solid); 00151 } 00152 00153 00165 Dxf3dsolid * 00166 dxf_3dsolid_read 00167 ( 00168 DxfFile *fp, 00170 Dxf3dsolid *solid 00172 ) 00173 { 00174 #if DEBUG 00175 DXF_DEBUG_BEGIN 00176 #endif 00177 char *temp_string = NULL; 00178 int i; 00179 00180 /* Do some basic checks. */ 00181 if (fp == NULL) 00182 { 00183 fprintf (stderr, 00184 (_("Error in %s () a NULL file pointer was passed.\n")), 00185 __FUNCTION__); 00186 /* Clean up. */ 00187 free (temp_string); 00188 return (NULL); 00189 } 00190 if (fp->acad_version_number < AutoCAD_13) 00191 { 00192 fprintf (stderr, 00193 (_("Warning in %s () illegal DXF version for this entity.\n")), 00194 __FUNCTION__); 00195 } 00196 if (solid == NULL) 00197 { 00198 fprintf (stderr, 00199 (_("Warning in %s () a NULL pointer was passed.\n")), 00200 __FUNCTION__); 00201 solid = dxf_3dsolid_new (); 00202 solid = dxf_3dsolid_init (solid); 00203 } 00204 i = 1; 00205 solid->proprietary_data->order = 0; 00206 solid->additional_proprietary_data->order = 0; 00207 (fp->line_number)++; 00208 fscanf (fp->fp, "%[^\n]", temp_string); 00209 while (strcmp (temp_string, "0") != 0) 00210 { 00211 if (ferror (fp->fp)) 00212 { 00213 fprintf (stderr, 00214 (_("Error in %s () while reading from: %s in line: %d.\n")), 00215 __FUNCTION__, fp->filename, fp->line_number); 00216 /* Clean up. */ 00217 free (temp_string); 00218 fclose (fp->fp); 00219 return (NULL); 00220 } 00221 else if (strcmp (temp_string, " 1") == 0) 00222 { 00223 /* Now follows a string containing proprietary 00224 * data. */ 00225 (fp->line_number)++; 00226 fscanf (fp->fp, "%s\n", solid->proprietary_data->line); 00227 solid->proprietary_data->order = i; 00228 i++; 00229 dxf_proprietary_data_init ((DxfProprietaryData *) solid->proprietary_data->next); 00230 solid->proprietary_data = (DxfProprietaryData *) solid->proprietary_data->next; 00231 } 00232 else if (strcmp (temp_string, " 3") == 0) 00233 { 00234 /* Now follows a string containing additional 00235 * proprietary data. */ 00236 (fp->line_number)++; 00237 fscanf (fp->fp, "%s\n", solid->additional_proprietary_data->line); 00238 solid->additional_proprietary_data->order = i; 00239 i++; 00240 dxf_proprietary_data_init ((DxfProprietaryData *) solid->additional_proprietary_data->next); 00241 solid->additional_proprietary_data = (DxfProprietaryData *) solid->additional_proprietary_data->next; 00242 } 00243 if (strcmp (temp_string, "5") == 0) 00244 { 00245 /* Now follows a string containing a sequential 00246 * id number. */ 00247 (fp->line_number)++; 00248 fscanf (fp->fp, "%x\n", &solid->id_code); 00249 } 00250 else if (strcmp (temp_string, "6") == 0) 00251 { 00252 /* Now follows a string containing a linetype 00253 * name. */ 00254 (fp->line_number)++; 00255 fscanf (fp->fp, "%s\n", solid->linetype); 00256 } 00257 else if (strcmp (temp_string, "8") == 0) 00258 { 00259 /* Now follows a string containing a layer name. */ 00260 (fp->line_number)++; 00261 fscanf (fp->fp, "%s\n", solid->layer); 00262 } 00263 else if (strcmp (temp_string, "38") == 0) 00264 { 00265 /* Now follows a string containing the 00266 * elevation. */ 00267 (fp->line_number)++; 00268 fscanf (fp->fp, "%lf\n", &solid->elevation); 00269 } 00270 else if (strcmp (temp_string, "39") == 0) 00271 { 00272 /* Now follows a string containing the 00273 * thickness. */ 00274 (fp->line_number)++; 00275 fscanf (fp->fp, "%lf\n", &solid->thickness); 00276 } 00277 else if (strcmp (temp_string, "48") == 0) 00278 { 00279 /* Now follows a string containing the linetype 00280 * scale. */ 00281 (fp->line_number)++; 00282 fscanf (fp->fp, "%lf\n", &solid->linetype_scale); 00283 } 00284 else if (strcmp (temp_string, "60") == 0) 00285 { 00286 /* Now follows a string containing the 00287 * visibility value. */ 00288 (fp->line_number)++; 00289 fscanf (fp->fp, "%hd\n", &solid->visibility); 00290 } 00291 else if (strcmp (temp_string, "62") == 0) 00292 { 00293 /* Now follows a string containing the 00294 * color value. */ 00295 (fp->line_number)++; 00296 fscanf (fp->fp, "%d\n", &solid->color); 00297 } 00298 else if (strcmp (temp_string, "67") == 0) 00299 { 00300 /* Now follows a string containing the 00301 * paperspace value. */ 00302 (fp->line_number)++; 00303 fscanf (fp->fp, "%d\n", &solid->paperspace); 00304 } 00305 else if (strcmp (temp_string, "70") == 0) 00306 { 00307 /* Now follows a string containing the modeler 00308 * format version number. */ 00309 (fp->line_number)++; 00310 fscanf (fp->fp, "%d\n", &solid->modeler_format_version_number); 00311 } 00312 else if (strcmp (temp_string, "92") == 0) 00313 { 00314 /* Now follows a string containing the 00315 * graphics data size value. */ 00316 (fp->line_number)++; 00317 fscanf (fp->fp, "%d\n", &solid->graphics_data_size); 00318 } 00319 else if (strcmp (temp_string, "100") == 0) 00320 { 00321 /* Now follows a string containing the 00322 * subclass marker value. */ 00323 (fp->line_number)++; 00324 fscanf (fp->fp, "%s\n", temp_string); 00325 if (strcmp (temp_string, "AcDbModelerGeometry") != 0) 00326 { 00327 fprintf (stderr, 00328 (_("Warning in %s () found a bad subclass marker in: %s in line: %d.\n")), 00329 __FUNCTION__, fp->filename, fp->line_number); 00330 } 00331 } 00332 else if (strcmp (temp_string, "100") == 0) 00333 { 00334 /* Now follows a string containing the 00335 * subclass marker value. */ 00336 (fp->line_number)++; 00337 fscanf (fp->fp, "%s\n", temp_string); 00338 if (strcmp (temp_string, "AcDb3dSolid") != 0) 00339 { 00340 fprintf (stderr, 00341 (_("Warning in %s () found a bad subclass marker in: %s in line: %d.\n")), 00342 __FUNCTION__, fp->filename, fp->line_number); 00343 } 00344 } 00345 else if (strcmp (temp_string, "160") == 0) 00346 { 00347 /* Now follows a string containing the 00348 * graphics data size value. */ 00349 (fp->line_number)++; 00350 fscanf (fp->fp, "%d\n", &solid->graphics_data_size); 00351 } 00352 else if (strcmp (temp_string, "284") == 0) 00353 { 00354 /* Now follows a string containing the shadow 00355 * mode value. */ 00356 (fp->line_number)++; 00357 fscanf (fp->fp, "%hd\n", &solid->shadow_mode); 00358 } 00359 else if (strcmp (temp_string, "310") == 0) 00360 { 00361 /* Now follows a string containing binary 00362 * graphics data. */ 00363 (fp->line_number)++; 00364 fscanf (fp->fp, "%s\n", solid->binary_graphics_data->data_line); 00365 dxf_binary_graphics_data_init ((DxfBinaryGraphicsData *) solid->binary_graphics_data->next); 00366 solid->binary_graphics_data = (DxfBinaryGraphicsData *) solid->binary_graphics_data->next; 00367 } 00368 else if (strcmp (temp_string, "330") == 0) 00369 { 00370 /* Now follows a string containing Soft-pointer 00371 * ID/handle to owner dictionary. */ 00372 (fp->line_number)++; 00373 fscanf (fp->fp, "%s\n", solid->dictionary_owner_soft); 00374 } 00375 else if (strcmp (temp_string, "347") == 0) 00376 { 00377 /* Now follows a string containing a 00378 * hard-pointer ID/handle to material object. */ 00379 (fp->line_number)++; 00380 fscanf (fp->fp, "%s\n", solid->material); 00381 } 00382 else if (strcmp (temp_string, "350") == 0) 00383 { 00384 /* Now follows a string containing a handle to a 00385 * history object. */ 00386 (fp->line_number)++; 00387 fscanf (fp->fp, "%s\n", solid->history); 00388 } 00389 else if (strcmp (temp_string, "360") == 0) 00390 { 00391 /* Now follows a string containing Hard owner 00392 * ID/handle to owner dictionary. */ 00393 (fp->line_number)++; 00394 fscanf (fp->fp, "%s\n", solid->dictionary_owner_hard); 00395 } 00396 else if (strcmp (temp_string, "370") == 0) 00397 { 00398 /* Now follows a string containing the lineweight 00399 * value. */ 00400 (fp->line_number)++; 00401 fscanf (fp->fp, "%hd\n", &solid->lineweight); 00402 } 00403 else if (strcmp (temp_string, "390") == 0) 00404 { 00405 /* Now follows a string containing a plot style 00406 * name value. */ 00407 (fp->line_number)++; 00408 fscanf (fp->fp, "%s\n", solid->plot_style_name); 00409 } 00410 else if (strcmp (temp_string, "420") == 0) 00411 { 00412 /* Now follows a string containing a color value. */ 00413 (fp->line_number)++; 00414 fscanf (fp->fp, "%ld\n", &solid->color_value); 00415 } 00416 else if (strcmp (temp_string, "430") == 0) 00417 { 00418 /* Now follows a string containing a color 00419 * name value. */ 00420 (fp->line_number)++; 00421 fscanf (fp->fp, "%s\n", solid->color_name); 00422 } 00423 else if (strcmp (temp_string, "440") == 0) 00424 { 00425 /* Now follows a string containing a transparency 00426 * value. */ 00427 (fp->line_number)++; 00428 fscanf (fp->fp, "%ld\n", &solid->transparency); 00429 } 00430 else if (strcmp (temp_string, "999") == 0) 00431 { 00432 /* Now follows a string containing a comment. */ 00433 (fp->line_number)++; 00434 fscanf (fp->fp, "%s\n", temp_string); 00435 fprintf (stdout, (_("DXF comment: %s\n")), temp_string); 00436 } 00437 else 00438 { 00439 fprintf (stderr, 00440 (_("Warning in %s () unknown string tag found while reading from: %s in line: %d.\n")), 00441 __FUNCTION__, fp->filename, fp->line_number); 00442 } 00443 } 00444 /* Handle omitted members and/or illegal values. */ 00445 if (strcmp (solid->linetype, "") == 0) 00446 { 00447 solid->linetype = strdup (DXF_DEFAULT_LINETYPE); 00448 } 00449 if (strcmp (solid->layer, "") == 0) 00450 { 00451 solid->layer = strdup (DXF_DEFAULT_LAYER); 00452 } 00453 /* Clean up. */ 00454 free (temp_string); 00455 #if DEBUG 00456 DXF_DEBUG_END 00457 #endif 00458 return (solid); 00459 } 00460 00461 00468 int 00469 dxf_3dsolid_write 00470 ( 00471 DxfFile *fp, 00473 Dxf3dsolid *solid 00475 ) 00476 { 00477 #if DEBUG 00478 DXF_DEBUG_BEGIN 00479 #endif 00480 char *dxf_entity_name = strdup ("3DSOLID"); 00481 DxfProprietaryData *iter = NULL; 00482 DxfProprietaryData *additional_iter = NULL; 00483 int i; 00484 00485 /* Do some basic checks. */ 00486 if (fp == NULL) 00487 { 00488 fprintf (stderr, 00489 (_("Error in %s () a NULL file pointer was passed.\n")), 00490 __FUNCTION__); 00491 /* Clean up. */ 00492 free (dxf_entity_name); 00493 return (EXIT_FAILURE); 00494 } 00495 if (solid == NULL) 00496 { 00497 fprintf (stderr, 00498 (_("Error in %s () a NULL pointer was passed.\n")), 00499 __FUNCTION__); 00500 /* Clean up. */ 00501 free (dxf_entity_name); 00502 return (EXIT_FAILURE); 00503 } 00504 if (fp->acad_version_number < AutoCAD_13) 00505 { 00506 fprintf (stderr, 00507 (_("Warning in %s () illegal DXF version for this %s entity with id-code: %x.\n")), 00508 __FUNCTION__, dxf_entity_name, dxf_3dsolid_get_id_code (solid)); 00509 } 00510 if (strcmp (dxf_3dsolid_get_linetype (solid), "") == 0) 00511 { 00512 fprintf (stderr, 00513 (_("Warning in %s () empty linetype string for the %s entity with id-code: %x\n")), 00514 __FUNCTION__, dxf_entity_name, dxf_3dsolid_get_id_code (solid)); 00515 fprintf (stderr, 00516 (_("\t%s entity is reset to default linetype")), 00517 dxf_entity_name); 00518 dxf_3dsolid_set_linetype (solid, strdup (DXF_DEFAULT_LINETYPE)); 00519 } 00520 if (strcmp (dxf_3dsolid_get_layer (solid), "") == 0) 00521 { 00522 fprintf (stderr, 00523 (_("Warning in %s () empty layer string for the %s entity with id-code: %x\n")), 00524 __FUNCTION__, dxf_entity_name, dxf_3dsolid_get_id_code (solid)); 00525 fprintf (stderr, 00526 (_("\t%s entity is relocated to layer 0")), 00527 dxf_entity_name); 00528 dxf_3dsolid_set_layer (solid, (strdup (DXF_DEFAULT_LAYER))); 00529 } 00530 /* Start writing output. */ 00531 i = 1; 00532 fprintf (fp->fp, " 0\n%s\n", dxf_entity_name); 00533 if (dxf_3dsolid_get_id_code (solid) != -1) 00534 { 00535 fprintf (fp->fp, " 5\n%x\n", dxf_3dsolid_get_id_code (solid)); 00536 } 00547 if ((strcmp (dxf_3dsolid_get_dictionary_owner_soft (solid), "") != 0) 00548 && (fp->acad_version_number >= AutoCAD_14)) 00549 { 00550 fprintf (fp->fp, "102\n{ACAD_REACTORS\n"); 00551 fprintf (fp->fp, "330\n%s\n", dxf_3dsolid_get_dictionary_owner_soft (solid)); 00552 fprintf (fp->fp, "102\n}\n"); 00553 } 00554 if ((strcmp (dxf_3dsolid_get_dictionary_owner_hard (solid), "") != 0) 00555 && (fp->acad_version_number >= AutoCAD_14)) 00556 { 00557 fprintf (fp->fp, "102\n{ACAD_XDICTIONARY\n"); 00558 fprintf (fp->fp, "360\n%s\n", dxf_3dsolid_get_dictionary_owner_hard (solid)); 00559 fprintf (fp->fp, "102\n}\n"); 00560 } 00561 if (fp->acad_version_number >= AutoCAD_13) 00562 { 00563 fprintf (fp->fp, "100\nAcDbEntity\n"); 00564 } 00565 if (dxf_3dsolid_get_paperspace (solid) == DXF_PAPERSPACE) 00566 { 00567 fprintf (fp->fp, " 67\n%d\n", DXF_PAPERSPACE); 00568 } 00569 fprintf (fp->fp, " 8\n%s\n", dxf_3dsolid_get_layer (solid)); 00570 if (strcmp (dxf_3dsolid_get_linetype (solid), DXF_DEFAULT_LINETYPE) != 0) 00571 { 00572 fprintf (fp->fp, " 6\n%s\n", dxf_3dsolid_get_linetype (solid)); 00573 } 00574 if ((fp->acad_version_number >= AutoCAD_2008) 00575 && (strcmp (dxf_3dsolid_get_material (solid), "") != 0)) 00576 { 00577 fprintf (fp->fp, "347\n%s\n", dxf_3dsolid_get_material (solid)); 00578 } 00579 if (dxf_3dsolid_get_color (solid) != DXF_COLOR_BYLAYER) 00580 { 00581 fprintf (fp->fp, " 62\n%d\n", dxf_3dsolid_get_color (solid)); 00582 } 00583 if (fp->acad_version_number >= AutoCAD_2002) 00584 { 00585 fprintf (fp->fp, "370\n%d\n", dxf_3dsolid_get_lineweight (solid)); 00586 } 00587 if ((fp->acad_version_number <= AutoCAD_11) 00588 && DXF_FLATLAND 00589 && (dxf_3dsolid_get_elevation (solid) != 0.0)) 00590 { 00591 fprintf (fp->fp, " 38\n%f\n", dxf_3dsolid_get_elevation (solid)); 00592 } 00593 if (dxf_3dsolid_get_thickness (solid) != 0.0) 00594 { 00595 fprintf (fp->fp, " 39\n%f\n", dxf_3dsolid_get_thickness (solid)); 00596 } 00597 if (dxf_3dsolid_get_linetype_scale (solid) != 1.0) 00598 { 00599 fprintf (fp->fp, " 48\n%f\n", dxf_3dsolid_get_linetype_scale (solid)); 00600 } 00601 if (dxf_3dsolid_get_visibility (solid) != 0) 00602 { 00603 fprintf (fp->fp, " 60\n%d\n", dxf_3dsolid_get_visibility (solid)); 00604 } 00605 if (fp->acad_version_number >= AutoCAD_2000) 00606 { 00607 #ifdef BUILD_64 00608 fprintf (fp->fp, "160\n%d\n", dxf_3dsolid_get_graphics_data_size (solid)); 00609 #else 00610 fprintf (fp->fp, " 92\n%d\n", dxf_3dsolid_get_graphics_data_size (solid)); 00611 #endif 00612 DxfBinaryGraphicsData *bgd_iter = (DxfBinaryGraphicsData *) dxf_3dsolid_get_binary_graphics_data (solid); 00613 while (dxf_binary_graphics_data_get_data_line (bgd_iter) != NULL) 00614 { 00615 fprintf (fp->fp, "310\n%s\n", dxf_binary_graphics_data_get_data_line (bgd_iter)); 00616 bgd_iter = (DxfBinaryGraphicsData *) dxf_binary_graphics_data_get_next (bgd_iter); 00617 } 00618 } 00619 if (fp->acad_version_number >= AutoCAD_2004) 00620 { 00621 fprintf (fp->fp, "420\n%ld\n", dxf_3dsolid_get_color_value (solid)); 00622 fprintf (fp->fp, "430\n%s\n", dxf_3dsolid_get_color_name (solid)); 00623 fprintf (fp->fp, "440\n%ld\n", dxf_3dsolid_get_transparency (solid)); 00624 } 00625 if (fp->acad_version_number >= AutoCAD_2009) 00626 { 00627 fprintf (fp->fp, "390\n%s\n", dxf_3dsolid_get_plot_style_name (solid)); 00628 fprintf (fp->fp, "284\n%d\n", dxf_3dsolid_get_shadow_mode (solid)); 00629 } 00630 if (fp->acad_version_number >= AutoCAD_13) 00631 { 00632 fprintf (fp->fp, "100\nAcDbModelerGeometry\n"); 00633 } 00634 if (fp->acad_version_number >= AutoCAD_2008) 00635 { 00636 fprintf (fp->fp, "100\nAcDb3dSolid\n"); 00637 } 00638 if (fp->acad_version_number >= AutoCAD_13) 00639 { 00640 fprintf (fp->fp, " 70\n%d\n", dxf_3dsolid_get_modeler_format_version_number (solid)); 00641 } 00642 iter = (DxfProprietaryData *) dxf_3dsolid_get_proprietary_data (solid); 00643 additional_iter = (DxfProprietaryData *) dxf_3dsolid_get_additional_proprietary_data (solid); 00644 while ((iter != NULL) || (additional_iter != NULL)) 00645 { 00646 if (iter->order == i) 00647 { 00648 fprintf (fp->fp, " 1\n%s\n", dxf_proprietary_data_get_line (iter)); 00649 iter = (DxfProprietaryData *) dxf_proprietary_data_get_next (iter); 00650 i++; 00651 } 00652 if (additional_iter->order == i) 00653 { 00654 fprintf (fp->fp, " 3\n%s\n", dxf_proprietary_data_get_line (additional_iter)); 00655 additional_iter = (DxfProprietaryData *) dxf_proprietary_data_get_next (additional_iter); 00656 i++; 00657 } 00658 } 00659 if (fp->acad_version_number >= AutoCAD_2008) 00660 { 00661 fprintf (fp->fp, "350\n%s\n", dxf_3dsolid_get_history (solid)); 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_3dsolid_free 00681 ( 00682 Dxf3dsolid *solid 00685 ) 00686 { 00687 #if DEBUG 00688 DXF_DEBUG_BEGIN 00689 #endif 00690 /* Do some basic checks. */ 00691 if (solid == NULL) 00692 { 00693 fprintf (stderr, 00694 (_("Error in %s () a NULL pointer was passed.\n")), 00695 __FUNCTION__); 00696 return (EXIT_FAILURE); 00697 } 00698 if (solid->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_3dsolid_get_linetype (solid)); 00706 free (dxf_3dsolid_get_layer (solid)); 00707 dxf_binary_graphics_data_free_chain (dxf_3dsolid_get_binary_graphics_data (solid)); 00708 free (dxf_3dsolid_get_dictionary_owner_soft (solid)); 00709 free (dxf_3dsolid_get_material (solid)); 00710 free (dxf_3dsolid_get_dictionary_owner_hard (solid)); 00711 free (dxf_3dsolid_get_plot_style_name (solid)); 00712 free (dxf_3dsolid_get_color_name (solid)); 00713 dxf_proprietary_data_free_chain (dxf_3dsolid_get_proprietary_data (solid)); 00714 dxf_proprietary_data_free_chain (dxf_3dsolid_get_additional_proprietary_data (solid)); 00715 free (dxf_3dsolid_get_history (solid)); 00716 free (solid); 00717 solid = NULL; 00718 #if DEBUG 00719 DXF_DEBUG_END 00720 #endif 00721 return (EXIT_SUCCESS); 00722 } 00723 00724 00729 void 00730 dxf_3dsolid_free_chain 00731 ( 00732 Dxf3dsolid *solids 00734 ) 00735 { 00736 #ifdef DEBUG 00737 DXF_DEBUG_BEGIN 00738 #endif 00739 if (solids == NULL) 00740 { 00741 fprintf (stderr, 00742 (_("Warning in %s () a NULL pointer was passed.\n")), 00743 __FUNCTION__); 00744 } 00745 while (solids != NULL) 00746 { 00747 struct Dxf3dsolid *iter = solids->next; 00748 dxf_3dsolid_free (solids); 00749 solids = (Dxf3dsolid *) iter; 00750 } 00751 #if DEBUG 00752 DXF_DEBUG_END 00753 #endif 00754 } 00755 00756 00762 int 00763 dxf_3dsolid_get_id_code 00764 ( 00765 Dxf3dsolid *solid 00767 ) 00768 { 00769 #if DEBUG 00770 DXF_DEBUG_BEGIN 00771 #endif 00772 /* Do some basic checks. */ 00773 if (solid == NULL) 00774 { 00775 fprintf (stderr, 00776 (_("Error in %s () a NULL pointer was passed.\n")), 00777 __FUNCTION__); 00778 return (EXIT_FAILURE); 00779 } 00780 if (solid->id_code < 0) 00781 { 00782 fprintf (stderr, 00783 (_("Error in %s () a negative value was found.\n")), 00784 __FUNCTION__); 00785 return (EXIT_FAILURE); 00786 } 00787 #if DEBUG 00788 DXF_DEBUG_END 00789 #endif 00790 return (solid->id_code); 00791 } 00792 00793 00797 Dxf3dsolid * 00798 dxf_3dsolid_set_id_code 00799 ( 00800 Dxf3dsolid *solid, 00802 int id_code 00806 ) 00807 { 00808 #if DEBUG 00809 DXF_DEBUG_BEGIN 00810 #endif 00811 /* Do some basic checks. */ 00812 if (solid == NULL) 00813 { 00814 fprintf (stderr, 00815 (_("Error in %s () a NULL pointer was passed.\n")), 00816 __FUNCTION__); 00817 return (NULL); 00818 } 00819 if (id_code < 0) 00820 { 00821 fprintf (stderr, 00822 (_("Error in %s () a negative value was passed.\n")), 00823 __FUNCTION__); 00824 return (NULL); 00825 } 00826 solid->id_code = id_code; 00827 #if DEBUG 00828 DXF_DEBUG_END 00829 #endif 00830 return (solid); 00831 } 00832 00833 00839 char * 00840 dxf_3dsolid_get_linetype 00841 ( 00842 Dxf3dsolid *solid 00844 ) 00845 { 00846 #if DEBUG 00847 DXF_DEBUG_BEGIN 00848 #endif 00849 /* Do some basic checks. */ 00850 if (solid == NULL) 00851 { 00852 fprintf (stderr, 00853 (_("Error in %s () a NULL pointer was passed.\n")), 00854 __FUNCTION__); 00855 return (NULL); 00856 } 00857 if (solid->linetype == NULL) 00858 { 00859 fprintf (stderr, 00860 (_("Error in %s () a NULL pointer was found.\n")), 00861 __FUNCTION__); 00862 return (NULL); 00863 } 00864 #if DEBUG 00865 DXF_DEBUG_END 00866 #endif 00867 return (strdup (solid->linetype)); 00868 } 00869 00870 00874 Dxf3dsolid * 00875 dxf_3dsolid_set_linetype 00876 ( 00877 Dxf3dsolid *solid, 00879 char *linetype 00881 ) 00882 { 00883 #if DEBUG 00884 DXF_DEBUG_BEGIN 00885 #endif 00886 /* Do some basic checks. */ 00887 if (solid == NULL) 00888 { 00889 fprintf (stderr, 00890 (_("Error in %s () a NULL pointer was passed.\n")), 00891 __FUNCTION__); 00892 return (NULL); 00893 } 00894 if (linetype == NULL) 00895 { 00896 fprintf (stderr, 00897 (_("Error in %s () a NULL pointer was passed.\n")), 00898 __FUNCTION__); 00899 return (NULL); 00900 } 00901 solid->linetype = strdup (linetype); 00902 #if DEBUG 00903 DXF_DEBUG_END 00904 #endif 00905 return (solid); 00906 } 00907 00908 00914 char * 00915 dxf_3dsolid_get_layer 00916 ( 00917 Dxf3dsolid *solid 00919 ) 00920 { 00921 #if DEBUG 00922 DXF_DEBUG_BEGIN 00923 #endif 00924 /* Do some basic checks. */ 00925 if (solid == NULL) 00926 { 00927 fprintf (stderr, 00928 (_("Error in %s () a NULL pointer was passed.\n")), 00929 __FUNCTION__); 00930 return (NULL); 00931 } 00932 if (solid->layer == NULL) 00933 { 00934 fprintf (stderr, 00935 (_("Error in %s () a NULL pointer was found.\n")), 00936 __FUNCTION__); 00937 return (NULL); 00938 } 00939 #if DEBUG 00940 DXF_DEBUG_END 00941 #endif 00942 return (strdup (solid->layer)); 00943 } 00944 00945 00949 Dxf3dsolid * 00950 dxf_3dsolid_set_layer 00951 ( 00952 Dxf3dsolid *solid, 00954 char *layer 00956 ) 00957 { 00958 #if DEBUG 00959 DXF_DEBUG_BEGIN 00960 #endif 00961 /* Do some basic checks. */ 00962 if (solid == NULL) 00963 { 00964 fprintf (stderr, 00965 (_("Error in %s () a NULL pointer was passed.\n")), 00966 __FUNCTION__); 00967 return (NULL); 00968 } 00969 if (layer == NULL) 00970 { 00971 fprintf (stderr, 00972 (_("Error in %s () a NULL pointer was passed.\n")), 00973 __FUNCTION__); 00974 return (NULL); 00975 } 00976 solid->layer = strdup (layer); 00977 #if DEBUG 00978 DXF_DEBUG_END 00979 #endif 00980 return (solid); 00981 } 00982 00983 00989 double 00990 dxf_3dsolid_get_elevation 00991 ( 00992 Dxf3dsolid *solid 00994 ) 00995 { 00996 #if DEBUG 00997 DXF_DEBUG_BEGIN 00998 #endif 00999 /* Do some basic checks. */ 01000 if (solid == NULL) 01001 { 01002 fprintf (stderr, 01003 (_("Error in %s () a NULL pointer was passed.\n")), 01004 __FUNCTION__); 01005 return (EXIT_FAILURE); 01006 } 01007 #if DEBUG 01008 DXF_DEBUG_END 01009 #endif 01010 return (solid->elevation); 01011 } 01012 01013 01017 Dxf3dsolid * 01018 dxf_3dsolid_set_elevation 01019 ( 01020 Dxf3dsolid *solid, 01022 double elevation 01024 ) 01025 { 01026 #if DEBUG 01027 DXF_DEBUG_BEGIN 01028 #endif 01029 /* Do some basic checks. */ 01030 if (solid == NULL) 01031 { 01032 fprintf (stderr, 01033 (_("Error in %s () a NULL pointer was passed.\n")), 01034 __FUNCTION__); 01035 return (NULL); 01036 } 01037 solid->elevation = elevation; 01038 #if DEBUG 01039 DXF_DEBUG_END 01040 #endif 01041 return (solid); 01042 } 01043 01044 01050 double 01051 dxf_3dsolid_get_thickness 01052 ( 01053 Dxf3dsolid *solid 01055 ) 01056 { 01057 #if DEBUG 01058 DXF_DEBUG_BEGIN 01059 #endif 01060 /* Do some basic checks. */ 01061 if (solid == NULL) 01062 { 01063 fprintf (stderr, 01064 (_("Error in %s () a NULL pointer was passed.\n")), 01065 __FUNCTION__); 01066 return (EXIT_FAILURE); 01067 } 01068 if (solid->thickness < 0.0) 01069 { 01070 fprintf (stderr, 01071 (_("Error in %s () a negative value was found.\n")), 01072 __FUNCTION__); 01073 return (EXIT_FAILURE); 01074 } 01075 #if DEBUG 01076 DXF_DEBUG_END 01077 #endif 01078 return (solid->thickness); 01079 } 01080 01081 01085 Dxf3dsolid * 01086 dxf_3dsolid_set_thickness 01087 ( 01088 Dxf3dsolid *solid, 01090 double thickness 01092 ) 01093 { 01094 #if DEBUG 01095 DXF_DEBUG_BEGIN 01096 #endif 01097 /* Do some basic checks. */ 01098 if (solid == NULL) 01099 { 01100 fprintf (stderr, 01101 (_("Error in %s () a NULL pointer was passed.\n")), 01102 __FUNCTION__); 01103 return (NULL); 01104 } 01105 if (thickness < 0.0) 01106 { 01107 fprintf (stderr, 01108 (_("Error in %s () a negative value was passed.\n")), 01109 __FUNCTION__); 01110 return (NULL); 01111 } 01112 solid->thickness = thickness; 01113 #if DEBUG 01114 DXF_DEBUG_END 01115 #endif 01116 return (solid); 01117 } 01118 01119 01125 double 01126 dxf_3dsolid_get_linetype_scale 01127 ( 01128 Dxf3dsolid *solid 01130 ) 01131 { 01132 #if DEBUG 01133 DXF_DEBUG_BEGIN 01134 #endif 01135 /* Do some basic checks. */ 01136 if (solid == NULL) 01137 { 01138 fprintf (stderr, 01139 (_("Error in %s () a NULL pointer was passed.\n")), 01140 __FUNCTION__); 01141 return (EXIT_FAILURE); 01142 } 01143 if (solid->linetype_scale < 0.0) 01144 { 01145 fprintf (stderr, 01146 (_("Error in %s () a negative value was found.\n")), 01147 __FUNCTION__); 01148 return (EXIT_FAILURE); 01149 } 01150 #if DEBUG 01151 DXF_DEBUG_END 01152 #endif 01153 return (solid->linetype_scale); 01154 } 01155 01156 01160 Dxf3dsolid * 01161 dxf_3dsolid_set_linetype_scale 01162 ( 01163 Dxf3dsolid *solid, 01165 double linetype_scale 01167 ) 01168 { 01169 #if DEBUG 01170 DXF_DEBUG_BEGIN 01171 #endif 01172 /* Do some basic checks. */ 01173 if (solid == NULL) 01174 { 01175 fprintf (stderr, 01176 (_("Error in %s () a NULL pointer was passed.\n")), 01177 __FUNCTION__); 01178 return (NULL); 01179 } 01180 if (linetype_scale < 0.0) 01181 { 01182 fprintf (stderr, 01183 (_("Error in %s () a negative value was passed.\n")), 01184 __FUNCTION__); 01185 return (NULL); 01186 } 01187 solid->linetype_scale = linetype_scale; 01188 #if DEBUG 01189 DXF_DEBUG_END 01190 #endif 01191 return (solid); 01192 } 01193 01194 01200 int16_t 01201 dxf_3dsolid_get_visibility 01202 ( 01203 Dxf3dsolid *solid 01205 ) 01206 { 01207 #if DEBUG 01208 DXF_DEBUG_BEGIN 01209 #endif 01210 /* Do some basic checks. */ 01211 if (solid == NULL) 01212 { 01213 fprintf (stderr, 01214 (_("Error in %s () a NULL pointer was passed.\n")), 01215 __FUNCTION__); 01216 return (EXIT_FAILURE); 01217 } 01218 if (solid->visibility < 0) 01219 { 01220 fprintf (stderr, 01221 (_("Error in %s () a negative value was found.\n")), 01222 __FUNCTION__); 01223 return (EXIT_FAILURE); 01224 } 01225 if (solid->visibility > 1) 01226 { 01227 fprintf (stderr, 01228 (_("Error in %s () an out of range value was found.\n")), 01229 __FUNCTION__); 01230 return (EXIT_FAILURE); 01231 } 01232 #if DEBUG 01233 DXF_DEBUG_END 01234 #endif 01235 return (solid->visibility); 01236 } 01237 01238 01242 Dxf3dsolid * 01243 dxf_3dsolid_set_visibility 01244 ( 01245 Dxf3dsolid *solid, 01247 int16_t visibility 01249 ) 01250 { 01251 #if DEBUG 01252 DXF_DEBUG_BEGIN 01253 #endif 01254 /* Do some basic checks. */ 01255 if (solid == NULL) 01256 { 01257 fprintf (stderr, 01258 (_("Error in %s () a NULL pointer was passed.\n")), 01259 __FUNCTION__); 01260 return (NULL); 01261 } 01262 if (visibility < 0) 01263 { 01264 fprintf (stderr, 01265 (_("Error in %s () a negative value was passed.\n")), 01266 __FUNCTION__); 01267 return (NULL); 01268 } 01269 if (visibility > 1) 01270 { 01271 fprintf (stderr, 01272 (_("Error in %s () an out of range value was passed.\n")), 01273 __FUNCTION__); 01274 return (NULL); 01275 } 01276 solid->visibility = visibility; 01277 #if DEBUG 01278 DXF_DEBUG_END 01279 #endif 01280 return (solid); 01281 } 01282 01283 01289 int 01290 dxf_3dsolid_get_color 01291 ( 01292 Dxf3dsolid *solid 01294 ) 01295 { 01296 #if DEBUG 01297 DXF_DEBUG_BEGIN 01298 #endif 01299 /* Do some basic checks. */ 01300 if (solid == NULL) 01301 { 01302 fprintf (stderr, 01303 (_("Error in %s () a NULL pointer was passed.\n")), 01304 __FUNCTION__); 01305 return (EXIT_FAILURE); 01306 } 01307 if (solid->color < 0) 01308 { 01309 fprintf (stderr, 01310 (_("Warning in %s () a negative value was found.\n")), 01311 __FUNCTION__); 01312 } 01313 #if DEBUG 01314 DXF_DEBUG_END 01315 #endif 01316 return (solid->color); 01317 } 01318 01319 01323 Dxf3dsolid * 01324 dxf_3dsolid_set_color 01325 ( 01326 Dxf3dsolid *solid, 01328 int color 01330 ) 01331 { 01332 #if DEBUG 01333 DXF_DEBUG_BEGIN 01334 #endif 01335 /* Do some basic checks. */ 01336 if (solid == NULL) 01337 { 01338 fprintf (stderr, 01339 (_("Error in %s () a NULL pointer was passed.\n")), 01340 __FUNCTION__); 01341 return (NULL); 01342 } 01343 if (color < 0) 01344 { 01345 fprintf (stderr, 01346 (_("Warning in %s () a negativevalue was passed.\n")), 01347 __FUNCTION__); 01348 } 01349 solid->color = color; 01350 #if DEBUG 01351 DXF_DEBUG_END 01352 #endif 01353 return (solid); 01354 } 01355 01356 01362 int 01363 dxf_3dsolid_get_paperspace 01364 ( 01365 Dxf3dsolid *solid 01367 ) 01368 { 01369 #if DEBUG 01370 DXF_DEBUG_BEGIN 01371 #endif 01372 /* Do some basic checks. */ 01373 if (solid == NULL) 01374 { 01375 fprintf (stderr, 01376 (_("Error in %s () a NULL pointer was passed.\n")), 01377 __FUNCTION__); 01378 return (EXIT_FAILURE); 01379 } 01380 if (solid->paperspace < 0) 01381 { 01382 fprintf (stderr, 01383 (_("Warning in %s () a negative value was found.\n")), 01384 __FUNCTION__); 01385 } 01386 if (solid->paperspace > 1) 01387 { 01388 fprintf (stderr, 01389 (_("Warning in %s () an out of range value was found.\n")), 01390 __FUNCTION__); 01391 } 01392 #if DEBUG 01393 DXF_DEBUG_END 01394 #endif 01395 return (solid->paperspace); 01396 } 01397 01398 01402 Dxf3dsolid * 01403 dxf_3dsolid_set_paperspace 01404 ( 01405 Dxf3dsolid *solid, 01407 int paperspace 01409 ) 01410 { 01411 #if DEBUG 01412 DXF_DEBUG_BEGIN 01413 #endif 01414 /* Do some basic checks. */ 01415 if (solid == NULL) 01416 { 01417 fprintf (stderr, 01418 (_("Error in %s () a NULL pointer was passed.\n")), 01419 __FUNCTION__); 01420 return (NULL); 01421 } 01422 if (paperspace < 0) 01423 { 01424 fprintf (stderr, 01425 (_("Error in %s () a negative value was passed.\n")), 01426 __FUNCTION__); 01427 return (NULL); 01428 } 01429 if (paperspace > 1) 01430 { 01431 fprintf (stderr, 01432 (_("Error in %s () an out of range value was passed.\n")), 01433 __FUNCTION__); 01434 return (NULL); 01435 } 01436 solid->paperspace = paperspace; 01437 #if DEBUG 01438 DXF_DEBUG_END 01439 #endif 01440 return (solid); 01441 } 01442 01443 01450 int 01451 dxf_3dsolid_get_graphics_data_size 01452 ( 01453 Dxf3dsolid *solid 01455 ) 01456 { 01457 #if DEBUG 01458 DXF_DEBUG_BEGIN 01459 #endif 01460 /* Do some basic checks. */ 01461 if (solid == NULL) 01462 { 01463 fprintf (stderr, 01464 (_("Error in %s () a NULL pointer was passed.\n")), 01465 __FUNCTION__); 01466 return (EXIT_FAILURE); 01467 } 01468 if (solid->graphics_data_size < 0) 01469 { 01470 fprintf (stderr, 01471 (_("Warning in %s () a negative value was found.\n")), 01472 __FUNCTION__); 01473 } 01474 if (solid->graphics_data_size == 0) 01475 { 01476 fprintf (stderr, 01477 (_("Warning in %s () a zero value was found.\n")), 01478 __FUNCTION__); 01479 } 01480 #if DEBUG 01481 DXF_DEBUG_END 01482 #endif 01483 return (solid->graphics_data_size); 01484 } 01485 01486 01493 Dxf3dsolid * 01494 dxf_3dsolid_set_graphics_data_size 01495 ( 01496 Dxf3dsolid *solid, 01498 int graphics_data_size 01501 ) 01502 { 01503 #if DEBUG 01504 DXF_DEBUG_BEGIN 01505 #endif 01506 /* Do some basic checks. */ 01507 if (solid == NULL) 01508 { 01509 fprintf (stderr, 01510 (_("Error in %s () a NULL pointer was passed.\n")), 01511 __FUNCTION__); 01512 return (NULL); 01513 } 01514 if (graphics_data_size < 0) 01515 { 01516 fprintf (stderr, 01517 (_("Error in %s () a negative value was passed.\n")), 01518 __FUNCTION__); 01519 return (NULL); 01520 } 01521 if (graphics_data_size == 0) 01522 { 01523 fprintf (stderr, 01524 (_("Error in %s () a zero value was passed.\n")), 01525 __FUNCTION__); 01526 return (NULL); 01527 } 01528 solid->graphics_data_size = graphics_data_size; 01529 #if DEBUG 01530 DXF_DEBUG_END 01531 #endif 01532 return (solid); 01533 } 01534 01535 01542 int16_t 01543 dxf_3dsolid_get_shadow_mode 01544 ( 01545 Dxf3dsolid *solid 01547 ) 01548 { 01549 #if DEBUG 01550 DXF_DEBUG_BEGIN 01551 #endif 01552 /* Do some basic checks. */ 01553 if (solid == NULL) 01554 { 01555 fprintf (stderr, 01556 (_("Error in %s () a NULL pointer was passed.\n")), 01557 __FUNCTION__); 01558 return (EXIT_FAILURE); 01559 } 01560 if (solid->shadow_mode < 0) 01561 { 01562 fprintf (stderr, 01563 (_("Error in %s () a negative value was found.\n")), 01564 __FUNCTION__); 01565 return (EXIT_FAILURE); 01566 } 01567 if (solid->shadow_mode > 3) 01568 { 01569 fprintf (stderr, 01570 (_("Error in %s () an out of range value was found.\n")), 01571 __FUNCTION__); 01572 return (EXIT_FAILURE); 01573 } 01574 #if DEBUG 01575 DXF_DEBUG_END 01576 #endif 01577 return (solid->shadow_mode); 01578 } 01579 01580 01587 Dxf3dsolid * 01588 dxf_3dsolid_set_shadow_mode 01589 ( 01590 Dxf3dsolid *solid, 01592 int16_t shadow_mode 01594 ) 01595 { 01596 #if DEBUG 01597 DXF_DEBUG_BEGIN 01598 #endif 01599 /* Do some basic checks. */ 01600 if (solid == NULL) 01601 { 01602 fprintf (stderr, 01603 (_("Error in %s () a NULL pointer was passed.\n")), 01604 __FUNCTION__); 01605 return (NULL); 01606 } 01607 if (shadow_mode < 0) 01608 { 01609 fprintf (stderr, 01610 (_("Error in %s () a negative value was passed.\n")), 01611 __FUNCTION__); 01612 return (NULL); 01613 } 01614 if (shadow_mode > 3) 01615 { 01616 fprintf (stderr, 01617 (_("Error in %s () an out of range value was passed.\n")), 01618 __FUNCTION__); 01619 return (NULL); 01620 } 01621 solid->shadow_mode = shadow_mode; 01622 #if DEBUG 01623 DXF_DEBUG_END 01624 #endif 01625 return (solid); 01626 } 01627 01628 01637 DxfBinaryGraphicsData * 01638 dxf_3dsolid_get_binary_graphics_data 01639 ( 01640 Dxf3dsolid *solid 01642 ) 01643 { 01644 #if DEBUG 01645 DXF_DEBUG_BEGIN 01646 #endif 01647 /* Do some basic checks. */ 01648 if (solid == NULL) 01649 { 01650 fprintf (stderr, 01651 (_("Error in %s () a NULL pointer was passed.\n")), 01652 __FUNCTION__); 01653 return (NULL); 01654 } 01655 if (solid->binary_graphics_data == NULL) 01656 { 01657 fprintf (stderr, 01658 (_("Error in %s () a NULL pointer was found.\n")), 01659 __FUNCTION__); 01660 return (NULL); 01661 } 01662 #if DEBUG 01663 DXF_DEBUG_END 01664 #endif 01665 return ((DxfBinaryGraphicsData *) solid->binary_graphics_data); 01666 } 01667 01668 01676 Dxf3dsolid * 01677 dxf_3dsolid_set_binary_graphics_data 01678 ( 01679 Dxf3dsolid *solid, 01681 DxfBinaryGraphicsData *data 01684 ) 01685 { 01686 #if DEBUG 01687 DXF_DEBUG_BEGIN 01688 #endif 01689 /* Do some basic checks. */ 01690 if (solid == NULL) 01691 { 01692 fprintf (stderr, 01693 (_("Error in %s () a NULL pointer was passed.\n")), 01694 __FUNCTION__); 01695 return (NULL); 01696 } 01697 if (data == NULL) 01698 { 01699 fprintf (stderr, 01700 (_("Error in %s () a NULL pointer was passed.\n")), 01701 __FUNCTION__); 01702 return (NULL); 01703 } 01704 solid->binary_graphics_data = (DxfBinaryGraphicsData *) data; 01705 #if DEBUG 01706 DXF_DEBUG_END 01707 #endif 01708 return (solid); 01709 } 01710 01711 01720 char * 01721 dxf_3dsolid_get_dictionary_owner_soft 01722 ( 01723 Dxf3dsolid *solid 01725 ) 01726 { 01727 #if DEBUG 01728 DXF_DEBUG_BEGIN 01729 #endif 01730 /* Do some basic checks. */ 01731 if (solid == NULL) 01732 { 01733 fprintf (stderr, 01734 (_("Error in %s () a NULL pointer was passed.\n")), 01735 __FUNCTION__); 01736 return (NULL); 01737 } 01738 if (solid->dictionary_owner_soft == NULL) 01739 { 01740 fprintf (stderr, 01741 (_("Error in %s () a NULL pointer was found.\n")), 01742 __FUNCTION__); 01743 return (NULL); 01744 } 01745 #if DEBUG 01746 DXF_DEBUG_END 01747 #endif 01748 return (strdup (solid->dictionary_owner_soft)); 01749 } 01750 01751 01756 Dxf3dsolid * 01757 dxf_3dsolid_set_dictionary_owner_soft 01758 ( 01759 Dxf3dsolid *solid, 01761 char *dictionary_owner_soft 01764 ) 01765 { 01766 #if DEBUG 01767 DXF_DEBUG_BEGIN 01768 #endif 01769 /* Do some basic checks. */ 01770 if (solid == NULL) 01771 { 01772 fprintf (stderr, 01773 (_("Error in %s () a NULL pointer was passed.\n")), 01774 __FUNCTION__); 01775 return (NULL); 01776 } 01777 if (dictionary_owner_soft == NULL) 01778 { 01779 fprintf (stderr, 01780 (_("Error in %s () a NULL pointer was passed.\n")), 01781 __FUNCTION__); 01782 return (NULL); 01783 } 01784 solid->dictionary_owner_soft = strdup (dictionary_owner_soft); 01785 #if DEBUG 01786 DXF_DEBUG_END 01787 #endif 01788 return (solid); 01789 } 01790 01791 01801 char * 01802 dxf_3dsolid_get_material 01803 ( 01804 Dxf3dsolid *solid 01806 ) 01807 { 01808 #if DEBUG 01809 DXF_DEBUG_BEGIN 01810 #endif 01811 /* Do some basic checks. */ 01812 if (solid == NULL) 01813 { 01814 fprintf (stderr, 01815 (_("Error in %s () a NULL pointer was passed.\n")), 01816 __FUNCTION__); 01817 return (NULL); 01818 } 01819 if (solid->material == NULL) 01820 { 01821 fprintf (stderr, 01822 (_("Error in %s () a NULL pointer was found.\n")), 01823 __FUNCTION__); 01824 return (NULL); 01825 } 01826 #if DEBUG 01827 DXF_DEBUG_END 01828 #endif 01829 return (strdup (solid->material)); 01830 } 01831 01832 01839 Dxf3dsolid * 01840 dxf_3dsolid_set_material 01841 ( 01842 Dxf3dsolid *solid, 01844 char *material 01847 ) 01848 { 01849 #if DEBUG 01850 DXF_DEBUG_BEGIN 01851 #endif 01852 /* Do some basic checks. */ 01853 if (solid == 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 solid->material = strdup (material); 01868 #if DEBUG 01869 DXF_DEBUG_END 01870 #endif 01871 return (solid); 01872 } 01873 01874 01883 char * 01884 dxf_3dsolid_get_dictionary_owner_hard 01885 ( 01886 Dxf3dsolid *solid 01888 ) 01889 { 01890 #if DEBUG 01891 DXF_DEBUG_BEGIN 01892 #endif 01893 /* Do some basic checks. */ 01894 if (solid == NULL) 01895 { 01896 fprintf (stderr, 01897 (_("Error in %s () a NULL pointer was passed.\n")), 01898 __FUNCTION__); 01899 return (NULL); 01900 } 01901 if (solid->dictionary_owner_hard == NULL) 01902 { 01903 fprintf (stderr, 01904 (_("Error in %s () a NULL pointer was found.\n")), 01905 __FUNCTION__); 01906 return (NULL); 01907 } 01908 #if DEBUG 01909 DXF_DEBUG_END 01910 #endif 01911 return (strdup (solid->dictionary_owner_hard)); 01912 } 01913 01914 01919 Dxf3dsolid * 01920 dxf_3dsolid_set_dictionary_owner_hard 01921 ( 01922 Dxf3dsolid *solid, 01924 char *dictionary_owner_hard 01927 ) 01928 { 01929 #if DEBUG 01930 DXF_DEBUG_BEGIN 01931 #endif 01932 /* Do some basic checks. */ 01933 if (solid == 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 solid->dictionary_owner_hard = strdup (dictionary_owner_hard); 01948 #if DEBUG 01949 DXF_DEBUG_END 01950 #endif 01951 return (solid); 01952 } 01953 01954 01961 int16_t 01962 dxf_3dsolid_get_lineweight 01963 ( 01964 Dxf3dsolid *solid 01966 ) 01967 { 01968 #if DEBUG 01969 DXF_DEBUG_BEGIN 01970 #endif 01971 /* Do some basic checks. */ 01972 if (solid == 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 (solid->lineweight); 01983 } 01984 01985 01992 Dxf3dsolid * 01993 dxf_3dsolid_set_lineweight 01994 ( 01995 Dxf3dsolid *solid, 01997 int16_t lineweight 01999 ) 02000 { 02001 #if DEBUG 02002 DXF_DEBUG_BEGIN 02003 #endif 02004 /* Do some basic checks. */ 02005 if (solid == NULL) 02006 { 02007 fprintf (stderr, 02008 (_("Error in %s () a NULL pointer was passed.\n")), 02009 __FUNCTION__); 02010 return (NULL); 02011 } 02012 solid->lineweight = lineweight; 02013 #if DEBUG 02014 DXF_DEBUG_END 02015 #endif 02016 return (solid); 02017 } 02018 02019 02026 char * 02027 dxf_3dsolid_get_plot_style_name 02028 ( 02029 Dxf3dsolid *solid 02031 ) 02032 { 02033 #if DEBUG 02034 DXF_DEBUG_BEGIN 02035 #endif 02036 /* Do some basic checks. */ 02037 if (solid == NULL) 02038 { 02039 fprintf (stderr, 02040 (_("Error in %s () a NULL pointer was passed.\n")), 02041 __FUNCTION__); 02042 return (NULL); 02043 } 02044 if (solid->plot_style_name == NULL) 02045 { 02046 fprintf (stderr, 02047 (_("Error in %s () a NULL pointer was found.\n")), 02048 __FUNCTION__); 02049 return (NULL); 02050 } 02051 #if DEBUG 02052 DXF_DEBUG_END 02053 #endif 02054 return (strdup (solid->plot_style_name)); 02055 } 02056 02057 02064 Dxf3dsolid * 02065 dxf_3dsolid_set_plot_style_name 02066 ( 02067 Dxf3dsolid *solid, 02069 char *plot_style_name 02072 ) 02073 { 02074 #if DEBUG 02075 DXF_DEBUG_BEGIN 02076 #endif 02077 /* Do some basic checks. */ 02078 if (solid == 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 solid->plot_style_name = strdup (plot_style_name); 02093 #if DEBUG 02094 DXF_DEBUG_END 02095 #endif 02096 return (solid); 02097 } 02098 02099 02106 long 02107 dxf_3dsolid_get_color_value 02108 ( 02109 Dxf3dsolid *solid 02111 ) 02112 { 02113 #if DEBUG 02114 DXF_DEBUG_BEGIN 02115 #endif 02116 /* Do some basic checks. */ 02117 if (solid == 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 (solid->color_value); 02128 } 02129 02130 02137 Dxf3dsolid * 02138 dxf_3dsolid_set_color_value 02139 ( 02140 Dxf3dsolid *solid, 02142 long color_value 02144 ) 02145 { 02146 #if DEBUG 02147 DXF_DEBUG_BEGIN 02148 #endif 02149 /* Do some basic checks. */ 02150 if (solid == NULL) 02151 { 02152 fprintf (stderr, 02153 (_("Error in %s () a NULL pointer was passed.\n")), 02154 __FUNCTION__); 02155 return (NULL); 02156 } 02157 solid->color_value = color_value; 02158 #if DEBUG 02159 DXF_DEBUG_END 02160 #endif 02161 return (solid); 02162 } 02163 02164 02171 char * 02172 dxf_3dsolid_get_color_name 02173 ( 02174 Dxf3dsolid *solid 02176 ) 02177 { 02178 #if DEBUG 02179 DXF_DEBUG_BEGIN 02180 #endif 02181 /* Do some basic checks. */ 02182 if (solid == NULL) 02183 { 02184 fprintf (stderr, 02185 (_("Error in %s () a NULL pointer was passed.\n")), 02186 __FUNCTION__); 02187 return (NULL); 02188 } 02189 if (solid->color_name == NULL) 02190 { 02191 fprintf (stderr, 02192 (_("Error in %s () a NULL pointer was found.\n")), 02193 __FUNCTION__); 02194 return (NULL); 02195 } 02196 #if DEBUG 02197 DXF_DEBUG_END 02198 #endif 02199 return (strdup (solid->color_name)); 02200 } 02201 02202 02209 Dxf3dsolid * 02210 dxf_3dsolid_set_color_name 02211 ( 02212 Dxf3dsolid *solid, 02214 char *color_name 02217 ) 02218 { 02219 #if DEBUG 02220 DXF_DEBUG_BEGIN 02221 #endif 02222 /* Do some basic checks. */ 02223 if (solid == 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 solid->color_name = strdup (color_name); 02238 #if DEBUG 02239 DXF_DEBUG_END 02240 #endif 02241 return (solid); 02242 } 02243 02244 02251 long 02252 dxf_3dsolid_get_transparency 02253 ( 02254 Dxf3dsolid *solid 02256 ) 02257 { 02258 #if DEBUG 02259 DXF_DEBUG_BEGIN 02260 #endif 02261 /* Do some basic checks. */ 02262 if (solid == 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 (solid->transparency); 02273 } 02274 02275 02282 Dxf3dsolid * 02283 dxf_3dsolid_set_transparency 02284 ( 02285 Dxf3dsolid *solid, 02287 long transparency 02289 ) 02290 { 02291 #if DEBUG 02292 DXF_DEBUG_BEGIN 02293 #endif 02294 /* Do some basic checks. */ 02295 if (solid == NULL) 02296 { 02297 fprintf (stderr, 02298 (_("Error in %s () a NULL pointer was passed.\n")), 02299 __FUNCTION__); 02300 return (NULL); 02301 } 02302 solid->transparency = transparency; 02303 #if DEBUG 02304 DXF_DEBUG_END 02305 #endif 02306 return (solid); 02307 } 02308 02309 02318 DxfProprietaryData * 02319 dxf_3dsolid_get_proprietary_data 02320 ( 02321 Dxf3dsolid *solid 02323 ) 02324 { 02325 #if DEBUG 02326 DXF_DEBUG_BEGIN 02327 #endif 02328 /* Do some basic checks. */ 02329 if (solid == NULL) 02330 { 02331 fprintf (stderr, 02332 (_("Error in %s () a NULL pointer was passed.\n")), 02333 __FUNCTION__); 02334 return (NULL); 02335 } 02336 if (solid->proprietary_data == NULL) 02337 { 02338 fprintf (stderr, 02339 (_("Error in %s () a NULL pointer was found.\n")), 02340 __FUNCTION__); 02341 return (NULL); 02342 } 02343 #if DEBUG 02344 DXF_DEBUG_END 02345 #endif 02346 return ((DxfProprietaryData *) solid->proprietary_data); 02347 } 02348 02349 02353 Dxf3dsolid * 02354 dxf_3dsolid_set_proprietary_data 02355 ( 02356 Dxf3dsolid *solid, 02358 DxfProprietaryData *proprietary_data 02360 ) 02361 { 02362 #if DEBUG 02363 DXF_DEBUG_BEGIN 02364 #endif 02365 /* Do some basic checks. */ 02366 if (solid == NULL) 02367 { 02368 fprintf (stderr, 02369 (_("Error in %s () a NULL pointer was passed.\n")), 02370 __FUNCTION__); 02371 return (NULL); 02372 } 02373 if (proprietary_data == NULL) 02374 { 02375 fprintf (stderr, 02376 (_("Error in %s () a NULL pointer was passed.\n")), 02377 __FUNCTION__); 02378 return (NULL); 02379 } 02380 solid->proprietary_data = proprietary_data; 02381 #if DEBUG 02382 DXF_DEBUG_END 02383 #endif 02384 return (solid); 02385 } 02386 02387 02396 DxfProprietaryData * 02397 dxf_3dsolid_get_additional_proprietary_data 02398 ( 02399 Dxf3dsolid *solid 02401 ) 02402 { 02403 #if DEBUG 02404 DXF_DEBUG_BEGIN 02405 #endif 02406 /* Do some basic checks. */ 02407 if (solid == NULL) 02408 { 02409 fprintf (stderr, 02410 (_("Error in %s () a NULL pointer was passed.\n")), 02411 __FUNCTION__); 02412 return (NULL); 02413 } 02414 if (solid->additional_proprietary_data == NULL) 02415 { 02416 fprintf (stderr, 02417 (_("Error in %s () a NULL pointer was found.\n")), 02418 __FUNCTION__); 02419 return (NULL); 02420 } 02421 #if DEBUG 02422 DXF_DEBUG_END 02423 #endif 02424 return ((DxfProprietaryData *) solid->additional_proprietary_data); 02425 } 02426 02427 02432 Dxf3dsolid * 02433 dxf_3dsolid_set_additional_proprietary_data 02434 ( 02435 Dxf3dsolid *solid, 02437 DxfProprietaryData *additional_proprietary_data 02439 ) 02440 { 02441 #if DEBUG 02442 DXF_DEBUG_BEGIN 02443 #endif 02444 /* Do some basic checks. */ 02445 if (solid == NULL) 02446 { 02447 fprintf (stderr, 02448 (_("Error in %s () a NULL pointer was passed.\n")), 02449 __FUNCTION__); 02450 return (NULL); 02451 } 02452 if (additional_proprietary_data == NULL) 02453 { 02454 fprintf (stderr, 02455 (_("Error in %s () a NULL pointer was passed.\n")), 02456 __FUNCTION__); 02457 return (NULL); 02458 } 02459 solid->additional_proprietary_data = additional_proprietary_data; 02460 #if DEBUG 02461 DXF_DEBUG_END 02462 #endif 02463 return (solid); 02464 } 02465 02466 02473 int 02474 dxf_3dsolid_get_modeler_format_version_number 02475 ( 02476 Dxf3dsolid *solid 02478 ) 02479 { 02480 #if DEBUG 02481 DXF_DEBUG_BEGIN 02482 #endif 02483 /* Do some basic checks. */ 02484 if (solid == NULL) 02485 { 02486 fprintf (stderr, 02487 (_("Error in %s () a NULL pointer was passed.\n")), 02488 __FUNCTION__); 02489 return (EXIT_FAILURE); 02490 } 02491 if (solid->modeler_format_version_number < 0) 02492 { 02493 fprintf (stderr, 02494 (_("Warning in %s () a negative value was found.\n")), 02495 __FUNCTION__); 02496 } 02497 if (solid->modeler_format_version_number > DXF_MODELER_FORMAT_CURRENT_VERSION) 02498 { 02499 fprintf (stderr, 02500 (_("Warning in %s () an out of range value was found.\n")), 02501 __FUNCTION__); 02502 } 02503 #if DEBUG 02504 DXF_DEBUG_END 02505 #endif 02506 return (solid->modeler_format_version_number); 02507 } 02508 02509 02514 Dxf3dsolid * 02515 dxf_3dsolid_set_modeler_format_version_number 02516 ( 02517 Dxf3dsolid *solid, 02519 int modeler_format_version_number 02522 ) 02523 { 02524 #if DEBUG 02525 DXF_DEBUG_BEGIN 02526 #endif 02527 /* Do some basic checks. */ 02528 if (solid == NULL) 02529 { 02530 fprintf (stderr, 02531 (_("Error in %s () a NULL pointer was passed.\n")), 02532 __FUNCTION__); 02533 return (NULL); 02534 } 02535 if (modeler_format_version_number < 0) 02536 { 02537 fprintf (stderr, 02538 (_("Error in %s () a negative value was passed.\n")), 02539 __FUNCTION__); 02540 return (NULL); 02541 } 02542 if (modeler_format_version_number > DXF_MODELER_FORMAT_CURRENT_VERSION) 02543 { 02544 fprintf (stderr, 02545 (_("Error in %s () an out of range value was passed.\n")), 02546 __FUNCTION__); 02547 return (NULL); 02548 } 02549 solid->modeler_format_version_number = modeler_format_version_number; 02550 #if DEBUG 02551 DXF_DEBUG_END 02552 #endif 02553 return (solid); 02554 } 02555 02556 02564 char * 02565 dxf_3dsolid_get_history 02566 ( 02567 Dxf3dsolid *solid 02569 ) 02570 { 02571 #if DEBUG 02572 DXF_DEBUG_BEGIN 02573 #endif 02574 /* Do some basic checks. */ 02575 if (solid == NULL) 02576 { 02577 fprintf (stderr, 02578 (_("Error in %s () a NULL pointer was passed.\n")), 02579 __FUNCTION__); 02580 return (NULL); 02581 } 02582 if (solid->history == NULL) 02583 { 02584 fprintf (stderr, 02585 (_("Error in %s () a NULL pointer was found.\n")), 02586 __FUNCTION__); 02587 return (NULL); 02588 } 02589 #if DEBUG 02590 DXF_DEBUG_END 02591 #endif 02592 return (strdup (solid->history)); 02593 } 02594 02595 02599 Dxf3dsolid * 02600 dxf_3dsolid_set_history 02601 ( 02602 Dxf3dsolid *solid, 02604 char *history 02606 ) 02607 { 02608 #if DEBUG 02609 DXF_DEBUG_BEGIN 02610 #endif 02611 /* Do some basic checks. */ 02612 if (solid == NULL) 02613 { 02614 fprintf (stderr, 02615 (_("Error in %s () a NULL pointer was passed.\n")), 02616 __FUNCTION__); 02617 return (NULL); 02618 } 02619 if (history == NULL) 02620 { 02621 fprintf (stderr, 02622 (_("Error in %s () a NULL pointer was passed.\n")), 02623 __FUNCTION__); 02624 return (NULL); 02625 } 02626 solid->history = strdup (history); 02627 #if DEBUG 02628 DXF_DEBUG_END 02629 #endif 02630 return (solid); 02631 } 02632 02633 02642 Dxf3dsolid * 02643 dxf_3dsolid_get_next 02644 ( 02645 Dxf3dsolid *solid 02647 ) 02648 { 02649 #if DEBUG 02650 DXF_DEBUG_BEGIN 02651 #endif 02652 /* Do some basic checks. */ 02653 if (solid == NULL) 02654 { 02655 fprintf (stderr, 02656 (_("Error in %s () a NULL pointer was passed.\n")), 02657 __FUNCTION__); 02658 return (NULL); 02659 } 02660 if (solid->next == NULL) 02661 { 02662 fprintf (stderr, 02663 (_("Error in %s () a NULL pointer was found.\n")), 02664 __FUNCTION__); 02665 return (NULL); 02666 } 02667 #if DEBUG 02668 DXF_DEBUG_END 02669 #endif 02670 return ((Dxf3dsolid *) solid->next); 02671 } 02672 02673 02678 Dxf3dsolid * 02679 dxf_3dsolid_set_next 02680 ( 02681 Dxf3dsolid *solid, 02683 Dxf3dsolid *next 02685 ) 02686 { 02687 #if DEBUG 02688 DXF_DEBUG_BEGIN 02689 #endif 02690 /* Do some basic checks. */ 02691 if (solid == NULL) 02692 { 02693 fprintf (stderr, 02694 (_("Error in %s () a NULL pointer was passed.\n")), 02695 __FUNCTION__); 02696 return (NULL); 02697 } 02698 if (next == NULL) 02699 { 02700 fprintf (stderr, 02701 (_("Error in %s () a NULL pointer was passed.\n")), 02702 __FUNCTION__); 02703 return (NULL); 02704 } 02705 solid->next = (struct Dxf3dsolid *) next; 02706 #if DEBUG 02707 DXF_DEBUG_END 02708 #endif 02709 return (solid); 02710 } 02711 02712 02721 Dxf3dsolid * 02722 dxf_3dsolid_get_last 02723 ( 02724 Dxf3dsolid *solid 02726 ) 02727 { 02728 #if DEBUG 02729 DXF_DEBUG_BEGIN 02730 #endif 02731 /* Do some basic checks. */ 02732 if (solid == NULL) 02733 { 02734 fprintf (stderr, 02735 (_("Error in %s () a NULL pointer was passed.\n")), 02736 __FUNCTION__); 02737 return (NULL); 02738 } 02739 if (solid->next == NULL) 02740 { 02741 fprintf (stderr, 02742 (_("Warning in %s () a NULL pointer was found.\n")), 02743 __FUNCTION__); 02744 return ((Dxf3dsolid *) solid); 02745 } 02746 Dxf3dsolid *iter = (Dxf3dsolid *) solid->next; 02747 while (iter->next != NULL) 02748 { 02749 iter = (Dxf3dsolid *) iter->next; 02750 } 02751 #if DEBUG 02752 DXF_DEBUG_END 02753 #endif 02754 return ((Dxf3dsolid *) iter); 02755 } 02756 02757 02758 /* EOF */