From: isn Date: Tue, 15 Nov 2016 12:01:20 +0000 (+0300) Subject: create stream - check wires intersections X-Git-Tag: v1.6~42 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=90e9d2fcf2bf7a10f1152f7a97f6406a0936adb1;p=modules%2Fhydro.git create stream - check wires intersections --- diff --git a/src/HYDROData/HYDROData_DTM.cxx b/src/HYDROData/HYDROData_DTM.cxx index c3246969..96475a1b 100644 --- a/src/HYDROData/HYDROData_DTM.cxx +++ b/src/HYDROData/HYDROData_DTM.cxx @@ -46,6 +46,7 @@ #include #include #include +#include @@ -214,7 +215,8 @@ void HYDROData_DTM::Update() double ddz = GetDDZ(); double step = GetSpatialStep(); std::set 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& 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& TopoDS_Shape& OutOutlet, bool Create3dPres, bool Create2dPres, - std::set& InvInd) + std::set& InvInd, + bool& WireIntersections) { if (theProfiles.empty()) return; @@ -390,7 +398,7 @@ void HYDROData_DTM::CreateProfiles(const std::vector& if (Create2dPres) { TopoDS_Face outF; - Get2dFaceFrom3dPres(cmp, outF); + WireIntersections = Get2dFaceFrom3dPres(cmp, outF); //__TODO Out2dPres = outF; }; } diff --git a/src/HYDROData/HYDROData_DTM.h b/src/HYDROData/HYDROData_DTM.h index e10b286b..2a60f75a 100644 --- a/src/HYDROData/HYDROData_DTM.h +++ b/src/HYDROData/HYDROData_DTM.h @@ -176,9 +176,10 @@ protected: TopoDS_Shape& OutOutlet, bool Create3dPres, bool Create2dPres, - std::set& InvInd ); + std::set& 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& theProfiles, double theDDZ, double theSpatialStep ); @@ -204,7 +205,8 @@ public: bool Create3dPres, bool Create2dPres, std::set& InvInd, - int thePntsLimit ); + int thePntsLimit, + bool& WireIntersections); }; diff --git a/src/HYDROData/HYDROData_Stream.cxx b/src/HYDROData/HYDROData_Stream.cxx index ed5af9f6..022cc306 100644 --- a/src/HYDROData/HYDROData_Stream.cxx +++ b/src/HYDROData/HYDROData_Stream.cxx @@ -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 diff --git a/src/HYDROGUI/HYDROGUI_StreamDlg.cxx b/src/HYDROGUI/HYDROGUI_StreamDlg.cxx index 9a4419ab..a07c5fe7 100644 --- a/src/HYDROGUI/HYDROGUI_StreamDlg.cxx +++ b/src/HYDROGUI/HYDROGUI_StreamDlg.cxx @@ -36,6 +36,7 @@ #include #include #include +#include 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(); +} + diff --git a/src/HYDROGUI/HYDROGUI_StreamDlg.h b/src/HYDROGUI/HYDROGUI_StreamDlg.h index 2e4e4626..3d49be1b 100644 --- a/src/HYDROGUI/HYDROGUI_StreamDlg.h +++ b/src/HYDROGUI/HYDROGUI_StreamDlg.h @@ -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 diff --git a/src/HYDROGUI/HYDROGUI_StreamOp.cxx b/src/HYDROGUI/HYDROGUI_StreamOp.cxx index bceea8f7..932065d6 100755 --- a/src/HYDROGUI/HYDROGUI_StreamOp.cxx +++ b/src/HYDROGUI/HYDROGUI_StreamOp.cxx @@ -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::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 ); } diff --git a/src/HYDROGUI/resources/HYDROGUI_msg_en.ts b/src/HYDROGUI/resources/HYDROGUI_msg_en.ts index 94f9b019..9681b5a0 100644 --- a/src/HYDROGUI/resources/HYDROGUI_msg_en.ts +++ b/src/HYDROGUI/resources/HYDROGUI_msg_en.ts @@ -250,6 +250,14 @@ All supported formats (*.brep *.iges *.igs *.step *.stp) STREAM_PROFILES Profiles + + STREAM_WARNINGS + Stream Warnings + + + STREAM_SELF_INTERSECTIONS + Warning: intersection(s) of banks/profiles are found + PREF_TAB_GENERAL General