1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59
| /*
méthode créant le polygone "GPC" 2D p à partir d'un Polygone poly
*/
void creer_polygone_gpc(gpc_polygon *p, Polygone poly)
{
int i;
p->num_contours=1; // 1 seul contour
MALLOC(p->hole, p->num_contours * sizeof(int),"hole flag array creation", int);
MALLOC(p->contour, p->num_contours * sizeof(gpc_vertex_list), "contour creation", gpc_vertex_list);
p->contour[0].num_vertices = static_cast<int>(poly.size());
p->hole[0]= false; /*contour extérieur*/
MALLOC(p->contour[0].vertex, p->contour[0].num_vertices * sizeof(gpc_vertex), "vertex creation", gpc_vertex);
for (i = 0; i < p->contour[0].num_vertices; i++)
{
p->contour[0].vertex[i].x = poly[i].x;
p->contour[0].vertex[i].y = poly[i].y;
}
}
/*
méthode créant le polygone "GPC" 2D p à partir d'un Polygone2D poly
*/
void creer_polygone_gpc(gpc_polygon *p, Polygone2D poly)
{
int i;
p->num_contours = 1; // 1 seul contour
MALLOC(p->hole, p->num_contours * sizeof(int),"hole flag array creation", int);
MALLOC(p->contour, p->num_contours * sizeof(gpc_vertex_list), "contour creation", gpc_vertex_list);
p->contour[0].num_vertices = static_cast<int>(poly.size());
p->hole[0]= false; /*contour extérieur*/
MALLOC(p->contour[0].vertex, p->contour[0].num_vertices * sizeof(gpc_vertex), "vertex creation", gpc_vertex);
for (i = 0; i < p->contour[0].num_vertices; i++)
{
p->contour[0].vertex[i].x = poly[i].x;
p->contour[0].vertex[i].y = poly[i].y;
}
}
/*
méthode créant une liste de polygones GPC 2D à partir d'une liste d'objets Polygone
*/
void creer_liste_polygones_gpc(vector<Polygone_GPC>& listePolygonesGPC,const vector<Polygone>& listePolygones)
{
for(vector<Polygone>::const_iterator it_p = listePolygones.begin(); it_p != listePolygones.end(); ++it_p)
{
gpc_polygon p;
creer_polygone_gpc(&p,*it_p);
Polygone_GPC poly(&p);
listePolygonesGPC.push_back(poly);
} // <-- ici le destructeur de Polygone_GPC est bien appelé pourtant
} |
Partager