Salome HOME
Fix for the bug #45: check and warning when the same image is used in 2 arguments.
[modules/hydro.git] / src / HYDROGUI / HYDROGUI_StreamOp.cxx
index 36a50ca716c99ddb49a88d8960c181cc736544c0..f23b1c03a614b67907772463e8d9081efa6a05c6 100755 (executable)
 #include <OCCViewer_ViewManager.h>
 #include <OCCViewer_ViewModel.h>
 #include <OCCViewer_ViewWindow.h>
-
+#include <gp_Ax1.hxx>
+#include <gp_Ax2.hxx>
+#include <gp_Ax3.hxx>
+#include <gp_Vec.hxx>
+#include <gp_Pnt.hxx>
+#include <gp_Pln.hxx>
+#include <gp.hxx>
+#include <TopoDS_Face.hxx>
+#include <TopoDS.hxx>
+#include <BRepBuilderAPI_MakeFace.hxx>
 HYDROGUI_StreamOp::HYDROGUI_StreamOp( HYDROGUI_Module* theModule, bool theIsEdit )
 : HYDROGUI_Operation( theModule ), 
   myIsEdit( theIsEdit ),
@@ -237,6 +246,13 @@ void HYDROGUI_StreamOp::onAddProfiles()
 
   HYDROData_SequenceOfObjects aVerifiedProfiles;
   HYDROData_SequenceOfObjects aSelectedProfiles = HYDROGUI_Tool::GetSelectedObjects( module() );
+  gp_Ax2 aX2(gp::XOY());
+  gp_Ax3 aX3(aX2);
+  gp_Pln aPln(aX3);
+  BRepBuilderAPI_MakeFace aMkr(aPln);
+  if(!aMkr.IsDone())   return;
+  const TopoDS_Face& aPlane = TopoDS::Face(aMkr.Shape());
+  Standard_Real aPar(.0);
   for( int i = 1, n = aSelectedProfiles.Length(); i <= n; i++ ) {
     Handle(HYDROData_Profile) aProfile = 
       Handle(HYDROData_Profile)::DownCast( aSelectedProfiles.Value( i ) );
@@ -248,7 +264,7 @@ void HYDROGUI_StreamOp::onAddProfiles()
         anInvalidProfiles << aProfileName;
       } else if ( aCurrentProfiles.contains( aProfileName ) ) { // check whether the profile is already added
         anExistingProfiles << aProfileName;
-      } else if ( !myEditedObject->HasIntersection( aProfile ) ) {  // check whether the profile has intersection
+      } else if ( !myEditedObject->HasIntersection( aProfile, aPlane, aPar ) ) {  // check whether the profile has intersection
         aHasNoIntersectionProfiles << aProfileName;
       } else {
         aVerifiedProfiles.Append( aProfile );
@@ -257,7 +273,8 @@ void HYDROGUI_StreamOp::onAddProfiles()
   }
  
   // Show message box with the ignored profiles
-  if ( aVerifiedProfiles.Length() < aSelectedProfiles.Length() ) {
+  if ( !anInvalidProfiles.isEmpty() || !anExistingProfiles.isEmpty() ||
+       !aHasNoIntersectionProfiles.isEmpty() ) {
     QString aMessage = tr( "IGNORED_PROFILES" );
     if ( !anInvalidProfiles.isEmpty() ) {
       aMessage.append( "\n\n" );