For all issues regarding the Forums use, please, refer to the Forum Rules.

Our Solutions

Need professional assistance?
Consider our:

Support Offerings

 

Need to speed up your development?
Have a look at our:

Samples & Tools

 

Need some functionality extending standard OCCT capabilities?
Check out our:

Adv. Components

Related pages

BRepClass_FaceClassifier

Macedo's picture
Forums: 

Hi

I'm using BRepClass_FaceClassifier to see if a point is IN a face or not.
So, I did two steps

1) Converted my gp_Pnt to gp_Pnt2d using ValueOfUV function(ShapeAnalysis_Surface)
2) Used BRepClass_FaceClassifier passing my face and my gp_Pnt2d point (and the tolerance)

I'm sure the point is IN the face, but the State() function always returns OUT.
(I played with the tolerance and I got a ON return! =/)

Someone could help me in this issue?
Thanks in advace! ;)

Lodyzhensky's picture

Dear Thiago Macedo.

Try to check the properties of your face (DRAW command 'sprops').
It seems that the face has negative area ('Mass' value).

Macedo's picture

Hi Lodyzhensky Evgeny Nicolaich,

Thank you for your prompt answer.
I don't know about this DRAW command. Where is it?
But, anyway, I did this in my code:

BRepGProp::SurfaceProperties(TempFace,System);
Standard_Real dMass = System.Mass();

and I got a big value, like 13000.0 .
Is it correct? Or no, I need to find this DRAW command?
(This "error" happens only in some BRep files.)

Thanks in Advance,
Regards

Lodyzhensky's picture

Dear Thiago Macedo.

Mass value > 0, so your face is good (it is growth but not hole).
Try to check U,V parameters of your 2D-point.
Use Geom_Surface::D0(U, V, P3D) for checking whether your 3D-point and P3D is equal.
If yes and you are sure that your 3D-point is inside the face:
There is a bug in BRepClass_FaceClassifier;
If no:
Try to obtain 2D-point using the class GeomAPI_ProjectPointOnSurf.

Macedo's picture

Hi Lodyzhensky Evgeny Nicolaich,

I'm projecting a point on a face. But this face has 2 holes. I want to know if the projected point is IN or OUT of this face.
Is this the best way (using BRepClass_FaceClassifier) to do?

To know where in 2D space is my 3D point, I'm using ValueOfUV method from ShapeAnalysis_Surface class. Is it enough?

Thank you again for your prompt answer! =)
Regards,

Lodyzhensky's picture

Dear Thiago Macedo.

- "I'm projecting a point on a face. But this face has 2 holes. I want to know if the projected point is IN or OUT of this face.
Is this the best way (using BRepClass_FaceClassifier) to do?"

Yes.

"To know where in 2D space is my 3D point, I'm using ValueOfUV method from ShapeAnalysis_Surface class. Is it enough?"

To obtain U,V I'm using
GeomAPI_ProjectPointOnSurf::LowerDistanceParameters(U,V) .

Macedo's picture

Dear Lodyzhensky Evgeny Nicolaich,

First I'd like to thank you, very much, because you are spending your time helping me! I'm glad to have you helping me, you are a good person! =)

I used BRepTools::UVBounds(tdsfTempFace, UMin, UMax, VMin, VMax); command to find boundary parameters, and got these values
UMin = -30.5472
UMax = 30.5472
VMin = -210.5540
VMax = 30.5540

And with P.LowerDistanceParameters(TempU,TempV); I got these values:
TempU = 9.2646
TempV = 99.5293

It's clear to me that this point is outside of the face.
But I'm sure, that this point is IN the face.

What else I can check?

Thank you in advance!
Regards,

Cauchy Ding's picture

As I know, to verify a point is in or out of a face is to check whether the 2d point is in or out of all 2d polygons(tessellation form wires). In Computer Geometry, it's classical algorithm and it's robust enough. From your data, the point is like in the surface but out of the face domain. I just wonder know how do verify the point is in the face. Since you got the 2d point of projected point, try to calculate the 3d point. If the distance of the two 3d point(raw point and new projected point) is less than the tolerance, the projection algorithm is correct.

Lodyzhensky's picture

Dear Thiago Macedo.

1. I agree with François Lauzon. The class IntTools_FClass2d is quite suitable to classify 2D-point in 2D space of face using boundaries of the face.
Furthermore, to classify 3D-point directly you can use the class IntTools_Context.
Have a look the method:

Standard_Boolean
IntTools_Context::IsValidPointForFace(const gp_Pnt& aP,
const TopoDS_Face& aF,
const Standard_Real aTol);

2. Judging by UMin, UMax, VMin, VMax the value TempV seems to be strange
because it is out of interval VMin, VMax. There is an error but where?
Could you upload your 3D-point face (tdsfTempFace) somewhere in inet?

I'l try to explore the case during my free time.

Francois Lauzon's picture

Hello,
we are using IntTools_FClass2d as a classifier, and to project the point on a topology, we are using BRepExtrema_DistShapeShape, with one shape as the face, and the other as a vertex build from a 3d point.

Good Luck,
Francois.

Macedo's picture

Hello All,

I found the problem! I'm using a non OpenCascade Display Interface, and I'm creating a point to be projected in a different coordinates system.
Thus, when I'm seeing the point I realize this point is on the face, but geometrically is not!
(I changed the position of the point and got a TopAbs_IN as a return)

I'm trying to set face and point with the same coordinate system! Do someone have a hint?

Thanks in advance!
Regards,