how to determine the position of a vertex with respect to a region.

The TopAbs_State enumeration described the position of a vertex or a set of vertices with respect to a region. There are four terms:

IN The point is interior.
OUT The point is exterior.
ON The point is on the boundary (within tolerance). UNKNOWN The state of the point is indeterminate.

Does anyone know what packages and classes I can use to determine the position state(in, out, on or unknown) of a vertex with respect to a region.

You are interested in the BRepClass and BRepClass3D packages. For example, to see if a point falls within the bounds of a face:

BRepClass_FaceClassifier classify(myFace, myPt, Precision::Confusion());
TopAbs_State state = classify.State();
if ((state == TopAbs_ON) || (state == TopAbs_IN)) {
...
}

When I try to do this, I laways got the State that is "out" no matter where is pnt. Except when pnt is (0,0,0), I will get State that is "on". could u help me solve it? THank you!

gp_Ax2 ax;
gp_Circ circle(ax,3);
TopoDS_Edge myCircle = BRepBuilderAPI_MakeEdge(circle);
TopoDS_Wire myCircleWire = BRepBuilderAPI_MakeWire(myCircle);
const TopoDS_Face myCircleWireFace = BRepBuilderAPI_MakeFace(myCircleWire);

Standard_Real Tol=0.002;
gp_Pnt pnt(1,1,0);

BRepClass_FaceClassifier classify(myCircleWireFace, pnt, Tol);
TopAbs_State st = classify.State();
if (st == TopAbs_ON) {
std::cout <<"on 1" <<"\n";
}else if(st == TopAbs_IN){
std::cout <<"in 2"<<"\n";
}else if(st == TopAbs_OUT){
std::cout <<"out 3" <<"\n";
}else {
std::cout <<"unkown 4"<<"\n";
}

I'm stumped on this one. Your code looks reasonable. To be honest, I only use FaceClassifier by passing in a 2D parametric point on the surface to find out if it exists within the face. I've never used it this way and it appears to have problems. Can anyone else help with this?

A less informative option would be to use BRepExtrema_DistShapeShape to look for a distance of 0.0.

Hi, I got the solution, the following code should work

// 1.a. Classify relatively Surface
Handle(Geom_Surface) aSurf = BRep_Tool::Surface(TopoDS::Face(aFace));
Handle(ShapeAnalysis_Surface) aSurfAna = new ShapeAnalysis_Surface (aSurf);
gp_Pnt2d p2dOnSurf = aSurfAna->ValueOfUV(aPnt, Precision::Confusion());
gp_Pnt p3dOnSurf = aSurfAna->Value(p2dOnSurf);
// OUT of Surface
} else {
// 1.b. Classify relatively the face itself
BRepClass_FaceClassifier FC (TopoDS::Face(aFace), p2dOnSurf, Precision::Confusion());
if (FC.State() == TopAbs_IN) {
} else if (FC.State() == TopAbs_ON) {
} else { // OUT
}
}

I tried the

void BRepClass_FaceClassifier::Perform(const TopoDS_Face& face,
const gp_Pnt& P,
const Standard_Real Tol)
It does not work.
I looked at the implementation and it ever uses the parameter P in the code.
I used the
void BRepClass_FaceClassifier::Perform(const TopoDS_Face& F,
const gp_Pnt2d& P,
const Standard_Real Tol)
where P is uv parameters.
This Works :-)