Beispiel #1
0
wxRegion::wxRegion( size_t n, const wxPoint *points, wxPolygonFillMode fillStyle )
{
    XPoint *xpoints = new XPoint[n];
#if defined(__INTEL_COMPILER) && 1 /* VDM auto patch */
#   pragma ivdep
#   pragma swp
#   pragma unroll
#   pragma prefetch
#   if 0
#       pragma simd noassert
#   endif
#endif /* VDM auto patch */
    for ( size_t i = 0 ; i < n ; i++ )
    {
        xpoints[i].x = points[i].x;
        xpoints[i].y = points[i].y;
    }

    m_refData = new wxRegionRefData();

    if ( fillStyle == wxODDEVEN_RULE )
        M_REGIONDATA->m_region = XPolygonRegion(xpoints, n, EvenOddRule);
    else if ( fillStyle == wxWINDING_RULE )
        M_REGIONDATA->m_region = XPolygonRegion(xpoints, n, WindingRule);
}
Beispiel #2
0
/*****
* Name: 		createPoly
* Return Type: 	Region
* Description: 	creates a polygon region given the polygon's coordinates
* In: 
*	npoints:	total no of points
*	points:		array of points defining the polygon.
*				The last point automatically connects to the first.
* Returns:
*	a newly created region
*****/
static Region
createPoly(int npoints, int *points)
{
	static Region region;
	XPoint *xpoints;		/* GdkPoint is equivalent to XPoint */
	int i, half;

	/* create array of XPoint's required for region generation */
	half = npoints/2.;
	xpoints = (XPoint*)calloc(half+1, sizeof(XPoint));
	for(i = 0; i < half; i++)
	{
		xpoints[i].x = points[i*2];
		xpoints[i].y = points[i*2+1];
	}
	/* last point is same as first point */
	xpoints[half].x = points[0];
	xpoints[half].y = points[1];
	
	/* create the region */
	region = XPolygonRegion(xpoints, half+1, WindingRule);

	/* no longer needed, free it */
	free(xpoints);

	return(region);
}
Beispiel #3
0
wxRegion::wxRegion( size_t n, const wxPoint *points, wxPolygonFillMode fillStyle )
{
    XPoint *xpoints = new XPoint[n];
    for ( size_t i = 0 ; i < n ; i++ )
    {
        xpoints[i].x = points[i].x;
        xpoints[i].y = points[i].y;
    }

    m_refData = new wxRegionRefData();

    if ( fillStyle == wxODDEVEN_RULE )
        M_REGIONDATA->m_region = XPolygonRegion(xpoints, n, EvenOddRule);
    else if ( fillStyle == wxWINDING_RULE )
        M_REGIONDATA->m_region = XPolygonRegion(xpoints, n, WindingRule);
}
Beispiel #4
0
static Bool
rgn_polygon(Handle self, PolygonRegionRec * r)
{
	int i, max;
	XPoint * xp;

	if ( !( xp = malloc( sizeof(XPoint) * r->n_points ))) {
		warn("Not enough memory");
		return false;
	}

	for ( i = 0, max = 0; i < r->n_points; i++) {
		if ( max < r->points[i].y)
			max = r->points[i].y;
	}
	for ( i = 0; i < r->n_points; i++) {
		xp[i].x = r->points[i].x;
		xp[i].y = max - r->points[i].y;
	}

	HEIGHT = max;
	REGION = XPolygonRegion( xp, r->n_points, r-> winding ? WindingRule : EvenOddRule );

	free( xp );
	return true;
}
Beispiel #5
0
QRegion::QRegion( const QPointArray &a, bool winding )
{
    data = new QRegionData;
    CHECK_PTR( data );
    data->is_null = FALSE;
    data->rgn = XPolygonRegion( (XPoint*)a.data(), a.size(),
				winding ? WindingRule : EvenOddRule );
}
Beispiel #6
0
/* lpStruct - address of array XPoints */
DWORD
DrvRegionsCreatePolyRegion(LPARAM dwParm1, LPARAM dwParm2, LPVOID lpStruct)
{
	LPPOINT lppt;

	if (!(lppt = (LPPOINT)lpStruct))
		return (DWORD)0;
	else
		return (DWORD)XPolygonRegion(
			DrvConvertPoints(lppt,(int)dwParm1),
			(int)dwParm1,
			(int)dwParm2 == WINDING?WindingRule:EvenOddRule);
}
// Construct polygon region
FXRegion::FXRegion(const FXPoint* points,FXuint npoints,FXbool winding){
#ifdef WIN32
  register FXuint i;
  POINT pts[1024];
  for(i=0; i<npoints; i++){
    pts[i].x=points[i].x;
    pts[i].y=points[i].y;
    }
  region=(void*)CreatePolygonRgn(pts,npoints,winding?WINDING:ALTERNATE);
#else
  region=XPolygonRegion((XPoint*)points,npoints,winding?WindingRule:EvenOddRule);
#endif
  }
Beispiel #8
0
QRegion::QRegion( const QRect &r, RegionType t )
{
    QRect rr = r.normalize();
    data = new QRegionData;
    CHECK_PTR( data );
    data->is_null = FALSE;
    if ( t == Rectangle ) {			// rectangular region
	data->rgn = XCreateRegion();
	XRectangle xr;
	xr.x = rr.x();
	xr.y = rr.y();
	xr.width  = rr.width();
	xr.height = rr.height();
	XUnionRectWithRegion( &xr, data->rgn, data->rgn );
    } else if ( t == Ellipse ) {		// elliptic region
	QPointArray a;
	a.makeEllipse( rr.x(), rr.y(), rr.width(), rr.height() );
	data->rgn = XPolygonRegion( (XPoint*)a.data(), a.size(), EvenOddRule );
    }
}
Beispiel #9
0
static PyObject *
tkwin_PolygonRegion(TkWinObject *self, PyObject *args)
{
    Region reg;
    PyObject *list;
    XPoint *points;
    int npoints, fill_rule = EvenOddRule;

    if (!PyArg_ParseTuple(args, "O|i", &list, &fill_rule))
	return NULL;
    if (!pax_checkshortlist(2, list, (short**)&points, &npoints))
    {
	if (!PyErr_Occurred())
	    PyErr_SetString(PyExc_TypeError, "arg1 should be XPoint[]");
	return NULL;
    }
    reg = XPolygonRegion(points, npoints, fill_rule);
    PyMem_Free(points);
    if (reg == NULL)
	return PyErr_NoMemory();
    return PaxRegion_FromRegion(reg);
}
Beispiel #10
0
TREEPTR split(short deviation, short x, short y, short level)
{
    short  i, j, height, width, intensity;
    long   size;
    double mean, sqr_mean;
    float  dev, dev1, variance;

    XPoint region_points[4];
    TREEPTR new_node;

    /* Allocate memory for the new defined region */
    new_node = (TREEPTR)malloc(sizeof(TREE));
    new_node->region  = NULL;
    new_node->subreg0 = NULL;
    new_node->subreg1 = NULL;
    new_node->subreg2 = NULL;
    new_node->subreg3 = NULL;
    new_node->pmerge  = NULL;
    new_node->included = no;
    new_node->mean=0;
    new_node->sqr_mean=0;
    new_node->level=level;

    /* Get the size of the region according to the level */
    height = IMAGE_HEIGHT/pow(2,level);
    width  = IMAGE_WIDTH /pow(2,level);
    size = height*width;

    /* Initialize some variables */
    mean=0; sqr_mean=0;

    /*Compute the mean and the mean of the squared pixels intensity*/
    for (i=x; i<x+width; i++)
	for (j=y; j<y+height; j++) {
	    intensity=XGetPixel(theXImage_1,i,j);
	    XPutPixel(theXImage_2,i,j,intensity);
	    mean=mean+intensity;
	    sqr_mean=sqr_mean+pow(intensity,2);
	};
    mean = mean/size;
    sqr_mean = sqr_mean/size;

    /*Store the mean and sqr_mean values*/
    new_node->mean = mean;
    new_node->sqr_mean = sqr_mean;

    /*Compute standard deviation of the region*/
    dev = get_deviation(mean,sqr_mean);

    /*Recursive splitting process*/
    if (dev>deviation) {
	/*The condition is not satisfied so split region*/
        num_split++;
	new_node->subreg0 = split(deviation,x,y,level+1);
	new_node->subreg1 = split(deviation,x+(width/2),y,level+1);
	new_node->subreg2 = split(deviation,x,y+(height/2),level+1);
	new_node->subreg3 = split(deviation,x+(width/2),y+(height/2),level+1);
    } else {
	/*Condition satisfied. Insert region in the quadtree structure*/
	num_reg++;
	region_points[0].x=x; region_points[0].y=y;
	region_points[1].x=x; region_points[1].y=y+height;
	region_points[2].x=x+width; region_points[2].y=y+height;
	region_points[3].x=x+width; region_points[3].y=y;
	new_node->region = XPolygonRegion (region_points, 4, WindingRule);
    }
    return (new_node);
}