]> SALOME platform Git repositories - modules/hydro.git/commitdiff
Salome HOME
create stream - check wires intersections
authorisn <isn@opencascade.com>
Tue, 15 Nov 2016 12:01:20 +0000 (15:01 +0300)
committerisn <isn@opencascade.com>
Tue, 15 Nov 2016 12:01:56 +0000 (15:01 +0300)
src/HYDROData/HYDROData_DTM.cxx
src/HYDROData/HYDROData_DTM.h
src/HYDROData/HYDROData_Stream.cxx
src/HYDROGUI/HYDROGUI_StreamDlg.cxx
src/HYDROGUI/HYDROGUI_StreamDlg.h
src/HYDROGUI/HYDROGUI_StreamOp.cxx
src/HYDROGUI/resources/HYDROGUI_msg_en.ts

index c3246969857e05ea697f775d02e3a815ad306b9f..96475a1bee1c9034af72fc1b4cd8100e9cd41a51 100644 (file)
@@ -46,6 +46,7 @@
 #include <BRepLib_MakeEdge.hxx>
 #include <BRepLib_MakeWire.hxx>
 #include <BRep_Builder.hxx>
+#include <ShapeAnalysis_Wire.hxx>
 
 
 
@@ -214,7 +215,8 @@ void HYDROData_DTM::Update()
   double ddz = GetDDZ();
   double step = GetSpatialStep();
   std::set<int> InvInd;
-  CreateProfilesFromDTM( objs, ddz, step, points, Out3dPres, Out2dPres, OutLeftB, OutRightB, OutInlet, OutOutlet, true, true, InvInd, -1 );
+  bool WireIntersections; //__TODO
+  CreateProfilesFromDTM( objs, ddz, step, points, Out3dPres, Out2dPres, OutLeftB, OutRightB, OutInlet, OutOutlet, true, true, InvInd, -1, WireIntersections );
   SetAltitudePoints( points );  
 
   SetShape( DataTag_LeftBankShape, OutLeftB);
@@ -256,7 +258,8 @@ void HYDROData_DTM::CreateProfilesFromDTM (const HYDROData_SequenceOfObjects& In
                                            bool Create3dPres,
                                            bool Create2dPres,
                                            std::set<int>& InvInd,
-                                           int thePntsLimit )
+                                           int thePntsLimit,
+                                           bool& WireIntersections)
 {
   int aLower = InpProfiles.Lower(), anUpper = InpProfiles.Upper();
   size_t n = anUpper - aLower + 1;
@@ -283,7 +286,7 @@ void HYDROData_DTM::CreateProfilesFromDTM (const HYDROData_SequenceOfObjects& In
 
   if( ddz>EPS && step>EPS )
     CreateProfiles(profiles, ddz, step, left, right, points, main_profiles, 
-    Out3dPres, Out2dPres, OutLeftB, OutRightB, OutInlet, OutOutlet, Create3dPres, Create2dPres, InvInd );
+    Out3dPres, Out2dPres, OutLeftB, OutRightB, OutInlet, OutOutlet, Create3dPres, Create2dPres, InvInd, WireIntersections );
 }
 
 void HYDROData_DTM::ProjWireOnPlane(const TopoDS_Wire& inpWire, const Handle_Geom_Plane& RefPlane, TopoDS_Wire& outWire)
@@ -305,7 +308,7 @@ void HYDROData_DTM::ProjWireOnPlane(const TopoDS_Wire& inpWire, const Handle_Geo
 }
 
 
-void HYDROData_DTM::Get2dFaceFrom3dPres(const TopoDS_Compound& cmp, TopoDS_Face& outF )
+bool HYDROData_DTM::Get2dFaceFrom3dPres(const TopoDS_Compound& cmp, TopoDS_Face& outF )
 {
   Handle_Geom_Plane refpl = new Geom_Plane(gp_Pnt(0,0,0), gp_Dir(0,0,1));
   BRepLib_MakeWire WM;
@@ -331,9 +334,13 @@ void HYDROData_DTM::Get2dFaceFrom3dPres(const TopoDS_Compound& cmp, TopoDS_Face&
 
   TopoDS_Wire outW;
   ProjWireOnPlane(WM.Wire(), refpl, outW);
-  BRepBuilderAPI_MakeFace mf(refpl, outW); //check inside is true by def
+  BRepBuilderAPI_MakeFace mf(refpl, outW, true); //check inside is true by def
   outF = mf.Face();
 
+  ShapeAnalysis_Wire WA(outW, outF, Precision::Confusion());
+  bool res = WA.CheckSelfIntersection();
+  return res;
+
   ///!!! the internal wires cant be added with 'internal' ori.
   // it's possible to do with brep builder yet the result will not be correct!
   // more proper way is to use BOP operation here.
@@ -361,7 +368,8 @@ void HYDROData_DTM::CreateProfiles(const std::vector<Handle_HYDROData_Profile>&
                                    TopoDS_Shape& OutOutlet,
                                    bool Create3dPres,
                                    bool Create2dPres,
-                                   std::set<int>& InvInd)
+                                   std::set<int>& InvInd,
+                                   bool& WireIntersections)
 {
   if (theProfiles.empty())
     return;
@@ -390,7 +398,7 @@ void HYDROData_DTM::CreateProfiles(const std::vector<Handle_HYDROData_Profile>&
     if (Create2dPres)
     {
       TopoDS_Face outF;
-      Get2dFaceFrom3dPres(cmp, outF);
+      WireIntersections = Get2dFaceFrom3dPres(cmp, outF); //__TODO
       Out2dPres = outF;
     };
   }
index e10b286b61d5b7c8f4980281ddc820e9e28ab04a..2a60f75a9335caa10c45e3b01fb009dc37f35ec0 100644 (file)
@@ -176,9 +176,10 @@ protected:
                              TopoDS_Shape& OutOutlet,
                              bool Create3dPres,
                              bool Create2dPres,
-                             std::set<int>& InvInd );
+                             std::set<int>& InvInd,
+                             bool& WireIntersections);
 
-  static void Get2dFaceFrom3dPres(const TopoDS_Compound& cmp, TopoDS_Face& outF );
+  static bool Get2dFaceFrom3dPres(const TopoDS_Compound& cmp, TopoDS_Face& outF );
   
   static int EstimateNbPoints( const std::vector<Handle_HYDROData_Profile>& theProfiles,
                                double theDDZ, double theSpatialStep );
@@ -204,7 +205,8 @@ public:
                                                        bool Create3dPres,
                                                        bool Create2dPres,
                                                        std::set<int>& InvInd,
-                                                       int thePntsLimit );
+                                                       int thePntsLimit,
+                                                       bool& WireIntersections);
 };
 
 
index ed5af9f6ed9e7804ad1caf8801fc2e9a57e11b63..022cc30664aecc4bf3708c748afc7dab995dd0f0 100644 (file)
@@ -1091,6 +1091,6 @@ void HYDROData_Stream::CreatePresentations( const Handle(TColgp_HArray1OfPnt)
 
   thePrs.myPrs3D = newCmp;
 
-  HYDROData_DTM::Get2dFaceFrom3dPres( newCmp, TopoDS::Face(thePrs.myPrs2D) );
+  HYDROData_DTM::Get2dFaceFrom3dPres( newCmp, TopoDS::Face(thePrs.myPrs2D) ); //__TODO
 
 }
\ No newline at end of file
index 9a4419ab69747e1af5dc394110d97fd9263c6556..a07c5fe7e79b5e5a178bfead856e8a6a2bf7e62c 100644 (file)
@@ -36,6 +36,7 @@
 #include <QListWidget>
 #include <QPushButton>
 #include <QDoubleSpinBox>
+#include <QTextEdit>
 
 HYDROGUI_StreamDlg::HYDROGUI_StreamDlg( HYDROGUI_Module* theModule, const QString& theTitle )
 : HYDROGUI_InputPanel( theModule, theTitle )
@@ -100,9 +101,18 @@ HYDROGUI_StreamDlg::HYDROGUI_StreamDlg( HYDROGUI_Module* theModule, const QStrin
   
   aParamGroup->setLayout( aParamLayout );
 
+  // Warnings
+  QGroupBox* aWarnGroup = new QGroupBox( tr( "STREAM_WARNINGS" ), mainFrame() );
+  myWarnText = new QTextEdit(); 
+  myWarnText->setReadOnly(true);
+  QBoxLayout* aWarnLayout = new QVBoxLayout();
+  aWarnLayout->addWidget( myWarnText );  
+  aWarnGroup->setLayout( aWarnLayout );
+
   // Common
   addWidget( myObjectNameGroup );
   addWidget( aParamGroup );
+  addWidget( aWarnGroup );
   addStretch();
 
   // Create selector
@@ -262,3 +272,13 @@ void HYDROGUI_StreamDlg::clearAllBackgroundColorsForProfileList ()
   myProfiles->clearAllBackgroundColors();
 }
 
+void HYDROGUI_StreamDlg::addWarning( const QString& theWarnMess )
+{
+  myWarnText->append( theWarnMess );
+}
+
+void HYDROGUI_StreamDlg::clearWarnings()
+{
+  myWarnText->clear();
+}
+
index 2e4e4626d7459c5f7cd1558056fb1b0ffed56827..3d49be1befa6c561d42b612297ed7c5551285c06 100644 (file)
@@ -29,6 +29,7 @@ class QLineEdit;
 class QListWidget;
 class QPushButton;
 class QDoubleSpinBox;
+class QTextEdit;
 
 class HYDROGUI_StreamDlg : public HYDROGUI_InputPanel
 {
@@ -56,6 +57,9 @@ public:
   void                       setSpatialStep( const double );
   double                     getSpatialStep() const;
 
+  void                       addWarning( const QString& theWarnMess );
+  void                       clearWarnings();
+
   void setBackgroundColorForProfileList (int theInd, QColor theColor);
   QColor getBackgroundColorForProfileList (int theInd) const;
   void clearAllBackgroundColorsForProfileList ();
@@ -82,6 +86,8 @@ private:
   HYDROGUI_OrderedListWidget* myProfiles;
   QPushButton*                myRemoveButton;
   QPushButton*                myAddButton;
+  QTextEdit*                  myWarnText;
+
 };
 
 #endif
index bceea8f7666b1c4d176981bb58ad0abfa9b3d9ec..932065d607b84c07258dcb06a3d19005f16acdc2 100755 (executable)
@@ -365,8 +365,10 @@ void HYDROGUI_StreamOp::createPreview()
 #endif
 
   HYDROData_Bathymetry::AltitudePoints points;
+
+  bool WireIntersections = false;
   HYDROData_DTM::CreateProfilesFromDTM( aRefProfiles, ddz, ss, points, Out3dPres, Out2dPres, OutLeftB, OutRightB,
-    OutInlet, OutOutlet, true, true, InvInd, MAX_POINTS_IN_PREVIEW );
+    OutInlet, OutOutlet, true, true, InvInd, MAX_POINTS_IN_PREVIEW, WireIntersections );
 
   aPanel->clearAllBackgroundColorsForProfileList();
   for (std::set<int>::const_iterator it = InvInd.begin(); it != InvInd.end(); it++)
@@ -376,9 +378,13 @@ void HYDROGUI_StreamOp::createPreview()
   aPrsDef.myOutlet = TopoDS::Wire(OutOutlet);
   aPrsDef.myLeftBank = TopoDS::Wire(OutLeftB);
   aPrsDef.myRightBank = TopoDS::Wire(OutRightB);
-  aPrsDef.myPrs2D = Out2dPres;
+  if (!WireIntersections)
+    aPrsDef.myPrs2D = Out2dPres;
   aPrsDef.myPrs3D = Out3dPres;
 
+  if (WireIntersections)
+    aPanel->addWarning(tr("STREAM_SELF_INTERSECTIONS"));
+
   myPreviewPrs->setShape( aPrsDef.myPrs2D );
 }
 
index 94f9b019ac5ff1dec3008012dde2495eeb88867e..9681b5a0eb685240b67e05ccbc4928a1f0888f85 100644 (file)
@@ -250,6 +250,14 @@ All supported formats (*.brep *.iges *.igs *.step *.stp)</translation>
       <source>STREAM_PROFILES</source>
       <translation>Profiles</translation>
     </message>
+    <message>
+      <source>STREAM_WARNINGS</source>
+      <translation>Stream Warnings</translation>
+    </message>
+     <message>
+      <source>STREAM_SELF_INTERSECTIONS</source>
+      <translation>Warning: intersection(s) of banks/profiles are found</translation>
+    </message>
     <message>
       <source>PREF_TAB_GENERAL</source>
       <translation>General</translation>