double reg_calc_area_complex_polygon( regShape* shape ) { regRegion *temp; regShape *copy; double area; fprintf(stderr, "WARNING: Calculating area of a complex polygon "); fprintf(stderr,"using brute force method. This may take a long time.\n"); // Create a new region with just the polygon temp = regCreateRegion(NULL, NULL); copy = shape->copy(shape); // Analytic area calculations always computes the area of the interior // of the shape. copy->include = regInclude; regAddShape(temp, regAND, copy); // Calc the extent of the polygon then trim the bounds to fit within // the original region if available regCalcExtentPolygon(shape, temp->xregbounds, temp->yregbounds); if (shape->region) { reg_trim_extent(temp->xregbounds, temp->yregbounds, shape->region->xregbounds, shape->region->yregbounds, 0); } area = regComputePixellatedArea(temp, temp->xregbounds, temp->yregbounds, 1); // Free and return regFree(temp); return area; }
static void ruleFree(struct matchRule *rule) { regFree(rule->path); regFree(rule->magic); argvFree(rule->flags); }