X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FHYDROData%2FHYDROData_LCM_FaceClassifier.cxx;h=adfa27e3ed1c03fc99b3385bff2abd1c80e8232a;hb=3ad1721baafb8864b968fe6ef6ab68ecf49a669e;hp=9e3a8f913b0d8565f1cc00b59e0cd5f3133ac629;hpb=e2a86f95793c73c1e2339d42ce38bb07af0f0bff;p=modules%2Fhydro.git diff --git a/src/HYDROData/HYDROData_LCM_FaceClassifier.cxx b/src/HYDROData/HYDROData_LCM_FaceClassifier.cxx index 9e3a8f91..adfa27e3 100644 --- a/src/HYDROData/HYDROData_LCM_FaceClassifier.cxx +++ b/src/HYDROData/HYDROData_LCM_FaceClassifier.cxx @@ -26,7 +26,10 @@ #include #include #include - +#include +#include +#include +#include Standard_Boolean HYDROData_FaceClassifier_BndBoxTreeSelector::Accept (const Standard_Integer& theObj) { @@ -37,9 +40,12 @@ Standard_Boolean HYDROData_FaceClassifier_BndBoxTreeSelector::Accept (const Stan if(f.IsNull()) return Standard_False; - BRepTopAdaptor_FClass2d* class2d = myMapF2Class2d.FindFromKey(f); + BRepTopAdaptor_FClass2d* class2d = myMapF2Class2d.FindFromKey(f); - TopAbs_State aState = class2d->Perform( myP, Standard_False ); + Handle(Geom_Plane) Pl = HYDROData_LCM_FaceClassifier::GetPlane(f); + Standard_Real u, v; + ElSLib::Parameters(Pl->Pln(), gp_Pnt(myP.X(), myP.Y(), 0.0), u, v); + TopAbs_State aState = class2d->Perform( gp_Pnt2d(u, v), Standard_False ); if (aState == TopAbs_IN) { @@ -57,6 +63,14 @@ Standard_Boolean HYDROData_FaceClassifier_BndBoxTreeSelector::Accept (const Stan } +Handle(Geom_Plane) HYDROData_LCM_FaceClassifier::GetPlane(const TopoDS_Face& F) +{ + TopLoc_Location L; + Handle(Geom_Surface) S = BRep_Tool::Surface(F, L); + Handle(Geom_Plane) Pl = Handle(Geom_Plane)::DownCast(S->Transformed(L.Transformation())); + return Pl; +} + void HYDROData_LCM_FaceClassifier::Classify( const std::vector& thePoints, std::vector >& theTypes, std::vector >* theFaces) const @@ -84,8 +98,25 @@ void HYDROData_LCM_FaceClassifier::Classify( const std::vector& thePoints Bnd_Box2d B; const TopoDS_Face& F = TopoDS::Face(aFaces(i)); BRepTools::AddUVBounds(F, B); - aTreeFiller.Add(i, B); - BRepTopAdaptor_FClass2d* aClass2d = new BRepTopAdaptor_FClass2d( F, 0 ); + + //convert 2d space of planar face to the 3d space of given points + //this is more faster way then getting of bnd3d of faces and project them on plane... + Handle(Geom_Plane) Pl = HYDROData_LCM_FaceClassifier::GetPlane(F); + gp_Trsf RT; + RT.SetTransformation(Pl->Position()); + RT.Invert(); + double xmin, ymin, xmax, ymax; + B.Get(xmin, ymin, xmax, ymax); + gp_Pnt MinP(xmin, ymin, 0), MaxP(xmax, ymax, 0); + MinP.Transform(RT); + MaxP.Transform(RT); + gp_Pnt2d MinPT(MinP.X(), MinP.Y()); + gp_Pnt2d MaxPT(MaxP.X(), MaxP.Y()); + Bnd_Box2d NB; + NB.Update(MinPT.X(), MinPT.Y(), MaxPT.X(), MaxPT.Y() ); + + aTreeFiller.Add(i, NB); + BRepTopAdaptor_FClass2d* aClass2d = new BRepTopAdaptor_FClass2d( F, 1E-7 ); aMapF2Class2d.Add(F, aClass2d); fclass2dpointers.push_back(aClass2d); }