2.2.3.5.6 curvebase::GetRectPointsGetRectPoints
Description
Find all the points in a Curve which fall on or within a specified rectangle.
Syntax
int GetRectPoints( fpoint & fptTopLeft, fpoint & fptBottomRight, vector<double> & vX, vector<double> & vY, vector<int> & vIndex )
Parameters
- fptTopLeft
- [Input] fpoint identifying the top-left corner of the rectangle
- fptBottomRight
- [Input] fpoint identifying the bottom-right corner of the rectangle
- vX
- [Output] vector containing the X coordinates of all points in the rectangele, paired with vY and vIndex
- vY
- [Output] vector containing the Y coordinates of all points in the rectangele, paired with vX and vIndex
- vIndex
- [Output] vector containing the row index (0 based) into the Curve's X and Y data sets, paired with vX and vY
Return
Returns the number of data points found within the rectangle (0,1,2,3...) on success and returns a negative integer on failure.
Also returns the coordinates and index of all points within the rectangle.
Examples
EX1
int curvebase_GetRectPoints_ex1(string wksName = "Book1")
{
// Assumes Book1_A(X) and Book1_B(Y) exist with the following data:
// Book1_B={1,2,3,4,5,6,7,8,9,10}
// Book1_A={1,2,3,4,5,6,7,8,9,10};
Worksheet wks(wksName);
Dataset ds1(wksName,0), ds2(wksName,1), ds3;
Curve crv(ds1, ds2);
int colnum = wks.AddCol("Index");
ds1.Attach(wksName,colnum);
colnum = wks.AddCol("Xval");
ds2.Attach(wksName,colnum);
colnum = wks.AddCol("Yval");
ds3.Attach(wksName,colnum);
fpoint fptTL(3,8);
fpoint fptBR(7,2);
vector<double> vX, vY;
vector<int> vIndex;
int num = crv.GetRectPoints( fptTL, fptBR, vX, vY, vIndex );
vIndex+=1; //adjust because 0 based
ds1 = vIndex;
ds2 = vX;
ds3 = vY;
return num;
}
Remark
Find all the points in a Curve which fall on or within a specified rectangle. The rectangle is specified by its top-left and bottom-right corners.
See Also
There is a similar method in DataPlot class that is more useful as it is not possible to get curvebase from a data plot. The following example shows how to count number of data points given a rectangle region of the graph layer:
void dd(double x1, double x2, double y1, double y2)
{
fpoint fptTL(x1,y2);
fpoint fptBR(x2,y1);
vector vX, vY;
GraphLayer gl = Project.ActiveLayer();
int ii = 1;
foreach (DataPlot dp in gl.DataPlots)
{
int nn = dp.GetRectPoints(fptTL, fptBR, vX, vY);
printf("%d: Found %d\n", ii++, nn);
}
}
Header to Include
origin.h
|