I have made a function for high level line entity access, Can we have
functions like this for all entities.

Function:-

Dwg_Entity_LINE **
extract_lines(Dwg_Data *dwg)
{
  int i,x=0;
  Dwg_Entity_LINE ** lines = (Dwg_Entity_LINE **) malloc(
  count_data(dwg, "LINE") * (sizeof (Dwg_Entity_LINE*) + 2));
  for (i = 0; i < dwg->num_objects; i++)
    {
      Dwg_Entity_LINE *line;
        if(DWG_TYPE_LINE==dwg->object[i].type)
        {
          lines[x] = dwg->object[i].tio.entity->tio.LINE;
          x++;
        }
    }
  return lines;
}

Usage :-

Dwg_Entity_LINE **all_lines;
  all_lines = extract_lines(&dwg);
    for (i = 0; i < count_data(&dwg,"LINE") ; i++)
      {
        printf("%f \n",all_lines[i]->start.x);
      }

I have created a count_data function that counts different types of
entities according to input to the function
Please check it here [0]. Function was large so I showed here.

example usage is like :-
count_data(&dwg,"LINE")
count_data(&dwg,"ARC")
count_data(&dwg,"LAYER")
count_data(&dwg,"LAYER_CONTROL")
count_data(&dwg,"BLOCK_CONTROL")

[0] http://202.164.53.122/~gagan/sample.txt

-- 
Thanks
Gaganjyot

Reply via email to