static GEOSGeometry *collectFacesWithEvenAncestors( Face **faces, int nfaces ) { GEOSContextHandle_t handle = QgsGeos::getGEOSHandler(); unsigned int ngeoms = 0; GEOSGeometry **geoms = new GEOSGeometry*[nfaces]; for ( int i = 0; i < nfaces; ++i ) { Face *f = faces[i]; if ( countParens( f ) % 2 ) continue; // we skip odd parents geoms geoms[ngeoms++] = GEOSGeom_clone_r( handle, f->geom ); } GEOSGeometry *ret = GEOSGeom_createCollection_r( handle, GEOS_MULTIPOLYGON, geoms, ngeoms ); delete [] geoms; return ret; }
static GEOSGeometry* collectFacesWithEvenAncestors(Face** faces, int nfaces) { GEOSGeometry **geoms = lwalloc(sizeof(GEOSGeometry*)*nfaces); GEOSGeometry *ret; unsigned int ngeoms = 0; int i; for (i=0; i<nfaces; ++i) { Face *f = faces[i]; if ( countParens(f) % 2 ) continue; /* we skip odd parents geoms */ geoms[ngeoms++] = GEOSGeom_clone(f->geom); } ret = GEOSGeom_createCollection(GEOS_MULTIPOLYGON, geoms, ngeoms); lwfree(geoms); return ret; }