libredwg
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[libredwg] Sample functions


From: gagan
Subject: [libredwg] Sample functions
Date: Thu, 13 Jun 2013 23:50:59 +0530

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

[Prev in Thread] Current Thread [Next in Thread]