Salome HOME
patch for crash in channel
[modules/hydro.git] / src / HYDROData / HYDROData_StreamAltitude.cxx
index bbcbb566e4f26ac0848811878b90f3d5f9f25d5b..bb8aa4e7610b4a9e2a474e770273ede71569edad 100644 (file)
@@ -5,11 +5,9 @@
 #include "HYDROData_Profile.h"
 #include "HYDROData_Stream.h"
 #include "HYDROData_ShapesTool.h"
-
+#include <HYDROData_Tool.h>
 #include <BRep_Tool.hxx>
 
-#include <BRepTopAdaptor_FClass2d.hxx>
-
 #include <BRepBuilderAPI_MakeEdge.hxx>
 #include <BRepBuilderAPI_MakeFace.hxx>
 #include <BRepBuilderAPI_MakeWire.hxx>
 
 #include <QStringList>
 
+#ifdef DEB_CLASS2D
+#include <BRepTools.hxx>
+#include <BRep_Builder.hxx>
+#include <BRepBuilderAPI_MakeVertex.hxx>
+#endif
 IMPLEMENT_STANDARD_HANDLE(HYDROData_StreamAltitude, HYDROData_IAltitudeObject)
 IMPLEMENT_STANDARD_RTTIEXT(HYDROData_StreamAltitude, HYDROData_IAltitudeObject)
 
@@ -44,15 +47,6 @@ HYDROData_StreamAltitude::~HYDROData_StreamAltitude()
 {
 }
 
-QStringList HYDROData_StreamAltitude::DumpToPython( MapOfTreatedObjects& theTreatedObjects ) const
-{
-  QStringList aResList = dumpObjectCreation( theTreatedObjects );
-
-  // TODO
-
-  return aResList;
-}
-
 Standard_Real getAltitudeFromProfile( const Handle(HYDROData_Profile)& theProfile,
                                       const Standard_Real&             theLeftDist,
                                       const Standard_Real&             theRightDist )
@@ -164,11 +158,24 @@ bool HYDROData_StreamAltitude::getBoundaryProfilesForPoint(
                                          aRightMakeEdge.Edge(), aTopMakeEdge.Edge() );
 
       BRepBuilderAPI_MakeFace aMakeFace( aMakeWire.Wire() );
-
+       
       TopoDS_Face aProfilesFace = aMakeFace.Face();
-
-      BRepTopAdaptor_FClass2d aClassifier( aProfilesFace, Precision::Confusion() );
-      TopAbs_State aPointState = aClassifier.Perform( gp_Pnt2d( thePoint ), Standard_False );
+#ifdef DEB_CLASS2D
+         TopoDS_Compound aCmp;
+      BRep_Builder aBB;
+      aBB.MakeCompound(aCmp);
+         aBB.Add(aCmp, aProfilesFace);
+         gp_Pnt aPnt (thePoint.X(), thePoint.Y(), 0.);
+         BRepBuilderAPI_MakeVertex aMk(aPnt);
+         aBB.Add(aCmp, aMk.Vertex());
+         BRepTools::Write(aCmp, "ProfileFace.brep");
+#endif     
+
+         TopAbs_State aPointState =  HYDROData_Tool::ComputePointState(thePoint, aProfilesFace);
+
+#ifdef DEB_CLASS2D
+         cout << "Point status is = " << aPointState <<endl;
+#endif
       if ( aPointState != TopAbs_OUT )
       {
         theLeftProfile = aPrevProfile;
@@ -206,8 +213,19 @@ double HYDROData_StreamAltitude::GetAltitudeForPoint( const gp_XY& thePoint ) co
   TopoDS_Face aStreamFace = TopoDS::Face( aStreamFaceExp.Current() );
 
   // Check if point is inside of stream presentation
-  BRepTopAdaptor_FClass2d aClassifier( aStreamFace, Precision::Confusion() );
-  TopAbs_State aPointState = aClassifier.Perform( gp_Pnt2d( thePoint ), Standard_False );
+  TopAbs_State aPointState = HYDROData_Tool::ComputePointState(thePoint, aStreamFace);
+
+#ifdef DEB_CLASS2D
+      cout << "Point status is = " << aPointState <<endl;
+         TopoDS_Compound aCmp;
+      BRep_Builder aBB;
+      aBB.MakeCompound(aCmp);
+         aBB.Add(aCmp, aStreamFace);
+         gp_Pnt aPnt (thePoint.X(), thePoint.Y(), 0.);
+         BRepBuilderAPI_MakeVertex aMk(aPnt);
+         aBB.Add(aCmp, aMk.Vertex());
+         BRepTools::Write(aCmp, "FCL2d.brep");
+#endif
   if ( aPointState == TopAbs_OUT )
     return aResAltitude;