From c041f46fae7aff3b8a3b1054b7c592bc3440ddb8 Mon Sep 17 00:00:00 2001 From: isn Date: Thu, 8 Dec 2016 20:53:25 +0300 Subject: [PATCH] debug of classifier --- src/HYDROData/HYDROData_DTM.cxx | 2 +- .../HYDROData_LCM_FaceClassifier.cxx | 35 +++++++++++++++---- src/HYDROData/HYDROData_LCM_FaceClassifier.h | 3 ++ 3 files changed, 33 insertions(+), 7 deletions(-) diff --git a/src/HYDROData/HYDROData_DTM.cxx b/src/HYDROData/HYDROData_DTM.cxx index a41dc277..eb981d14 100644 --- a/src/HYDROData/HYDROData_DTM.cxx +++ b/src/HYDROData/HYDROData_DTM.cxx @@ -645,7 +645,7 @@ Handle_Geom2d_BSplineCurve HYDROData_DTM::CreateHydraulicAxis( { size_t n = theProfiles.size(); if( n==1 ) - Handle_Geom2d_BSplineCurve(); + return Handle_Geom2d_BSplineCurve(); Handle_Geom2d_BSplineCurve aResult; diff --git a/src/HYDROData/HYDROData_LCM_FaceClassifier.cxx b/src/HYDROData/HYDROData_LCM_FaceClassifier.cxx index b2c7a11a..3fd68493 100644 --- a/src/HYDROData/HYDROData_LCM_FaceClassifier.cxx +++ b/src/HYDROData/HYDROData_LCM_FaceClassifier.cxx @@ -40,11 +40,9 @@ Standard_Boolean HYDROData_FaceClassifier_BndBoxTreeSelector::Accept (const Stan if(f.IsNull()) return Standard_False; - BRepTopAdaptor_FClass2d* class2d = myMapF2Class2d.FindFromKey(f); - - TopLoc_Location L; - Handle(Geom_Surface) C = BRep_Tool::Surface(f, L); - Handle(Geom_Plane) Pl = Handle(Geom_Plane)::DownCast(C->Transformed(L.Transformation())); + BRepTopAdaptor_FClass2d* class2d = myMapF2Class2d.FindFromKey(f); + + 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); @@ -66,6 +64,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 @@ -93,7 +99,24 @@ 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); + + //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, 0 ); aMapF2Class2d.Add(F, aClass2d); fclass2dpointers.push_back(aClass2d); diff --git a/src/HYDROData/HYDROData_LCM_FaceClassifier.h b/src/HYDROData/HYDROData_LCM_FaceClassifier.h index 1a83a7ef..30e78886 100644 --- a/src/HYDROData/HYDROData_LCM_FaceClassifier.h +++ b/src/HYDROData/HYDROData_LCM_FaceClassifier.h @@ -33,6 +33,7 @@ class BRepTopAdaptor_FClass2d; class HYDROData_LandCoverMap; +class Handle(Geom_Plane); typedef NCollection_UBTree HYDROData_FaceClassifier_BndBoxTree; @@ -93,6 +94,8 @@ public: std::vector >& theTypes, std::vector >* theFaces) const; + static Handle(Geom_Plane) GetPlane(const TopoDS_Face& F); + private: const HYDROData_LandCoverMap* const myLCM; -- 2.39.2