![Steph's picture Steph's picture](/sites/default/files/images/userpic_default.png)
Tue, 06/14/2011 - 20:17
I encountered some problem with the BRepTopAdaptor_FClass2d class. For a new created face, all the results are correct. But if i make a translation of the created face and check the position of a point according the translated face, the classifier seems to work on the original shape and not the transformed one.
It doesn't seems to take in account the location of the translated shape.
Is it normal? What can i do to get it work?
Modify the original geometry (i don't want that but if it is the only way...)?
I give an example. All the tests_case return OK. The 3 last must return false.
void BRepTopAdaptorFClass2dTest::BRepTopAdaptorFClass2dTest()
{
const gp_Pnt p1(0.0,0.0,0.0);
const gp_Pnt p2(1.0,0.0,0.0);
const gp_Pnt p3(1.0,1.0,0.0);
const gp_Pnt p4(0.0,1.0,0.0);
TopoDS_Vertex V1 = BRepBuilderAPI_MakeVertex(p1);
TopoDS_Vertex V2 = BRepBuilderAPI_MakeVertex(p2);
TopoDS_Vertex V3 = BRepBuilderAPI_MakeVertex(p3);
TopoDS_Vertex V4 = BRepBuilderAPI_MakeVertex(p4);
BRepBuilderAPI_MakePolygon polygon;
polygon.Add(V1);
polygon.Add(V2);
polygon.Add(V3);
polygon.Add(V4);
polygon.Close();
const TopoDS_Wire& wire = polygon.Wire();
BRepBuilderAPI_MakeFace faceBuilder(gp_Pln(gp::XOY()),wire,Standard_True);
const TopoDS_Face& face = faceBuilder.Face();
const gp_Pnt2d pIn(0.5,0.5);
const gp_Pnt2d pOut(2.0,2.0);
const gp_Pnt2d pOn(0.0,0.0);
BRepTopAdaptor_FClass2d aClassifier (face, Precision::Approximation()) ;
TopAbs_State aPtInState = aClassifier.Perform ( pIn );
TopAbs_State aPtOutState = aClassifier.Perform ( pOut );
TopAbs_State aPtOnState = aClassifier.Perform ( pOn );
CPPUNIT_ASSERT_EQUAL(TopAbs_IN,aPtInState);
CPPUNIT_ASSERT_EQUAL(TopAbs_OUT,aPtOutState);
CPPUNIT_ASSERT_EQUAL(TopAbs_ON,aPtOnState);
//Transform the face
const gp_Pnt2d p5(5.0,5.0);
gp_Trsf trsf;
trsf.SetTranslation(gp_Pnt(p1.X(),p1.Y(),0.0),gp_Pnt(p5.X(),p5.Y(),0.0));
TopoDS_Face transformedFace = TopoDS::Face(face.Moved(trsf));
BRepTopAdaptor_FClass2d aClassifier2 (transformedFace, Precision::Approximation()) ;
aPtInState = aClassifier2.Perform( pIn );
aPtOutState = aClassifier2.Perform ( pOut );
aPtOnState = aClassifier2.Perform ( pOn );
CPPUNIT_ASSERT_EQUAL(TopAbs_IN,aPtInState);
CPPUNIT_ASSERT_EQUAL(TopAbs_OUT,aPtOutState);
CPPUNIT_ASSERT_EQUAL(TopAbs_ON,aPtOnState);
}
Thanks in advance to explain me what is wrong. If it is me or it is a bug?
Stéphane.
Wed, 06/15/2011 - 09:33
Hi Steph,
I don't think it's a bug. When the face is transformed, all pcurves will not be modified at all. pIn, pOut, pOn are all 2d points. So the results of BRepTopAdaptor_FClass2d will keep the same with original face.
Ding
Wed, 06/15/2011 - 12:52
Hi Cauchy,
Thanks for the answer.
Is there a way to get it works? It is possible to modify all the pvurves according the transformation applied to the face?
I don't care if i modify the original geometry but i need to know if this point are inside, outside or on the modified shape.
Or i can compute the inverse transformation matrix, apply it on the point i want to check and call the BRepTopAdaptor_FClass2d on the transformed point?
What do you thinks about these two possibilities?
Regards.
Stéphane.
Thu, 06/16/2011 - 02:44
Hi Steph,
The pIn, pOut, pOn are all 2d points, they should be calculated from 3d point projection to transformed face. I mean pIn, pOut and pOn should not be specified manually. Flow chart should be as: given a 3d point and a transformed face, try to project the 3d point to the surface of the face and get the 2d projection point in surface, finally use BRepTopAdaptor_FClass2d to judge whether the 2d point is in or out the face domain.
Ding