Determine if a point lies inside the polygon of an element that has a support area (hatching, slab, 3d mesh, etc.)

Call:

bool res = ac_request("geometry_calc_2d","is_point_on_element_polygon",double x1,double y1, int iElemDedcr, bool mainContOnly, double grow_contour, double, grow_holes);


Here:

x1 and y1 - coordinates of the examined point, iElemDescr - object descriptor, whose polygon is checked for point content.

mainContOnly - if yes, then consider only the outer contour of the second polygon,

grow_contour and grow_holes - how much to expand or narrow the contour and holes of the second polygon.


Example.

Read the elements of 3d-grids with ID="Relief" into the list of elements, take the first one, create an ac_eleemnt_guid object on its base, get the ac_element object from it. Get terrain into coordinate table. And check if the point lies inside the polygon.


// read the table of coordinates for the 3d mesh relief element with ID="Relief"
int iMeshCoordTable; // polygon coordinates table handle
// read elements of type 3d-grid with ID="Relief" into list #2
ac_request("load_elements_list",2,"MeshType","ID","Bump","MainFilter",2);
// determine how many elements the list #2 contains
ac_request("get_loaded_elements_list_count",2);
int iicount = ac_getnumvalue();
if(iicount == 0)
{
   cout << "There is no 3d mesh with ID=Relief in the project.\nProgram stopped";
   return -1;
}
// create a dynamic table object for polygon coordinates
object("create","ts_table",MeshCoordTable);
// set focus to the first element (index 0) of list #2
ac_request("set_current_element_from_list",2, 0);
// create an object for the element's guid
int iMeshGuidDescr; // object handle guid
object("create","ac_element_guid",iMeshGuidDescr);
// write the guid from the current element in the list #2 to the iMeshGuidDescr object
ac_request("store_cur_element_to_descr", iMeshGuidDescr);
int iMeshElemDedcr; // element object handle
// create an object to work with the element
object("create","ac_element",iMeshElemDedcr);
// load element object from guid
ac_request("load_element_from_guid",iMeshElemDedcr,iMeshGuidDescr);
// read the table of polygon coordinates
ac_request("get_element_value","SimpleCoordTable",iMeshCoordTable);
// check how many points the resulting table of polygon coordinates contains
int irowcount;
ts_table(iMeshCoordTable, "get_rows_count", irowcount);
cout << "Number of points in terrain contour=" << irowcount << "\n";
object("delete",MeshCoordTable);
double x1=1.1, y1=2.2; // coordinates of the studied point
// check if the point with coordinates x1, y1 lies
int res = ac_request("geometry_calc_2d","is_point_on_element_polygon",x1,y1, iMeshElemDedcr);
if(res == 1)
{
   cout << "The point is inside the polygon outline of the element";
}