(root)/
libredwg-0.13/
test/
unit-testing/
lwpolyline.c
       1  #define DWG_TYPE DWG_TYPE_LWPOLYLINE
       2  #include "common.c"
       3  
       4  void
       5  api_process (dwg_object *obj)
       6  {
       7    int error;
       8    BITCODE_BS flag;
       9    BITCODE_BL num_points, num_bulges, num_widths;
      10    dwg_point_3d extrusion, pt3d;
      11    char flags;
      12    double const_width, elevation, thickness;
      13    double *bulges;
      14    dwg_point_2d *points;
      15    dwg_lwpline_widths *width;
      16    BITCODE_BL *vertexids;
      17    BITCODE_BL num_vertexids, i;
      18  
      19    dwg_ent_lwpline *lwpline = dwg_object_to_LWPOLYLINE (obj);
      20  
      21    CHK_ENTITY_TYPE (lwpline, LWPOLYLINE, flag, BS);
      22  #ifdef USE_DEPRECATED_API
      23    if (dwg_ent_lwpline_get_flag (lwpline, &error) != flag || error)
      24      fail ("old API dwg_ent_lwpline_get_flag");
      25  #endif
      26    CHK_ENTITY_3RD (lwpline, LWPOLYLINE, extrusion);
      27  #ifdef USE_DEPRECATED_API
      28    dwg_ent_lwpline_get_extrusion (lwpline, &pt3d, &error);
      29    if (error || memcmp (&extrusion, &pt3d, sizeof (extrusion)))
      30      fail ("old API dwg_ent_lwpline_get_extrusion");
      31  #endif
      32  
      33    CHK_ENTITY_TYPE (lwpline, LWPOLYLINE, const_width, BD);
      34  #ifdef USE_DEPRECATED_API
      35    if (dwg_ent_lwpline_get_const_width (lwpline, &error) != const_width
      36        || error)
      37      fail ("old API dwg_ent_lwpline_get_const_width");
      38  #endif
      39    CHK_ENTITY_TYPE (lwpline, LWPOLYLINE, thickness, BD);
      40  #ifdef USE_DEPRECATED_API
      41    if (dwg_ent_lwpline_get_thickness (lwpline, &error) != thickness || error)
      42      fail ("old API dwg_ent_lwpline_get_thickness");
      43  #endif
      44    CHK_ENTITY_TYPE (lwpline, LWPOLYLINE, elevation, BD);
      45  #ifdef USE_DEPRECATED_API
      46    if (dwg_ent_lwpline_get_elevation (lwpline, &error) != elevation || error)
      47      fail ("old API dwg_ent_lwpline_get_elevation");
      48  #endif
      49    CHK_ENTITY_TYPE (lwpline, LWPOLYLINE, num_widths, BL);
      50  #ifdef USE_DEPRECATED_API
      51    if (dwg_ent_lwpline_get_numwidths (lwpline, &error) != num_widths || error)
      52      fail ("old API dwg_ent_lwpline_get_numwidths");
      53  #endif
      54    CHK_ENTITY_TYPE (lwpline, LWPOLYLINE, num_bulges, BL);
      55  #ifdef USE_DEPRECATED_API
      56    if (dwg_ent_lwpline_get_numbulges (lwpline, &error) != num_bulges || error)
      57      fail ("old API dwg_ent_lwpline_get_numbulges");
      58  #endif
      59    CHK_ENTITY_TYPE (lwpline, LWPOLYLINE, num_points, BL);
      60  #ifdef USE_DEPRECATED_API
      61    if (dwg_ent_lwpline_get_numpoints (lwpline, &error) != num_points || error)
      62      fail ("old API dwg_ent_lwpline_get_numpoints");
      63  #endif
      64  
      65      // CHK_ENTITY_TYPE (lwpline, LWPOLYLINE, bulges, BD*, bulges);
      66  #ifdef USE_DEPRECATED_API
      67    bulges = dwg_ent_lwpline_get_bulges (lwpline, &error);
      68  #else
      69    bulges = lwpline->bulges;
      70    error = 0;
      71  #endif
      72    if (!error)
      73      {
      74        for (i = 0; i < lwpline->num_bulges; i++)
      75          (void)bulges[i];
      76          // printf ("bulge[%d] of lwpline : %f\n", (int)i, bulges[i]);
      77  #ifdef USE_DEPRECATED_API
      78        free (bulges);
      79  #endif
      80      }
      81    else
      82      fail ("bulges");
      83  
      84  #ifdef USE_DEPRECATED_API
      85    points = dwg_ent_lwpline_get_points (lwpline, &error);
      86  #else
      87    points = (dwg_point_2d *)lwpline->points;
      88  #endif
      89    if (!error)
      90      {
      91        for (i = 0; i < lwpline->num_points; i++)
      92          (void)points[i].x;
      93          // printf ("point[%d] of lwpline : x = %f\ty = %f\n", (int)i,
      94          // points[i].x,
      95          //        points[i].y);
      96  #ifdef USE_DEPRECATED_API
      97        free (points);
      98  #endif
      99      }
     100    else
     101      fail ("points");
     102  
     103  #ifdef USE_DEPRECATED_API
     104    width = dwg_ent_lwpline_get_widths (lwpline, &error);
     105  #else
     106    width = (dwg_lwpline_widths *)lwpline->widths;
     107  #endif
     108    if (!error)
     109      {
     110        for (i = 0; i < lwpline->num_widths; i++)
     111          (void)width[i].start;
     112          // printf ("widths[%d] of lwpline : x = %f\ty = %f\n", (int)i,
     113          //        width[i].start, width[i].end);
     114  #ifdef USE_DEPRECATED_API
     115        free (width);
     116  #endif
     117      }
     118    else
     119      fail ("widths");
     120  
     121    CHK_ENTITY_TYPE (lwpline, LWPOLYLINE, num_vertexids, BL);
     122  }