Salome HOME
Merge remote-tracking branch 'origin/pre/IMPS_2016' into BR_HYDRO_IMPS_2016
[modules/hydro.git] / src / HYDROData / HYDROData_Stream.cxx
index ed5af9f6ed9e7804ad1caf8801fc2e9a57e11b63..9ffb8596baf5fefd6cc93515cf0bf13e63b874ea 100644 (file)
@@ -77,6 +77,9 @@
 
 #include <TopTools_HArray1OfShape.hxx>
 #include <TopTools_IndexedMapOfOrientedShape.hxx>
+#include <TopTools_ListIteratorOfListOfShape.hxx>
+#include <TopTools_SequenceOfShape.hxx>
+#include <TopTools_IndexedMapOfShape.hxx>
 
 #include <SortTools_QuickSortOfReal.hxx>
 
@@ -91,6 +94,8 @@
 #include <TCollection_AsciiString.hxx>
 #endif
 
+#include <assert.h>
+
 typedef NCollection_DataMap<Standard_Real, Handle(HYDROData_Profile)> HYDROData_DataMapOfRealOfHDProfile;
 
 IMPLEMENT_STANDARD_HANDLE(HYDROData_Stream,HYDROData_NaturalObject)
@@ -1045,7 +1050,6 @@ void HYDROData_Stream::CopyTo( const Handle(HYDROData_Entity)& theDestination,
     }
   }
 }
-
 void HYDROData_Stream::CreatePresentations( const Handle(TColgp_HArray1OfPnt)     theArrayOfFPnt,
                                             const Handle(TColgp_HArray1OfPnt)     theArrayOfLPnt,
                                             const Handle(TopTools_HArray1OfShape) theArrOfProfiles,
@@ -1071,26 +1075,53 @@ void HYDROData_Stream::CreatePresentations( const Handle(TColgp_HArray1OfPnt)
   std::vector<HYDROData_Bathymetry::AltitudePoints> dummy;
   TopTools_IndexedMapOfOrientedShape ll = HYDROData_DTM::Create3DShape(left, right, dummy);
 
+  TopoDS_Shape LB, RB, IL, OL;
+
   if (!ll.IsEmpty())
   {
-    thePrs.myLeftBank = TopoDS::Wire(ll(1));
-    thePrs.myRightBank = TopoDS::Wire(ll(2));
+    LB = TopoDS::Wire(ll(1));
+    RB = TopoDS::Wire(ll(2));
   }
 
-  thePrs.myInlet = TopoDS::Wire(theArrOfProfiles->Value(theArrOfProfiles->Lower())); //TODO check that
-  thePrs.myOutlet = TopoDS::Wire(theArrOfProfiles->Value(theArrOfProfiles->Upper()));
+  IL = TopoDS::Wire(theArrOfProfiles->Value(theArrOfProfiles->Lower())); //TODO check that
+  OL = TopoDS::Wire(theArrOfProfiles->Value(theArrOfProfiles->Upper()));
 
   //make new compound so it's shapes will be in known order to build correct projection
   BRep_Builder BB;
   TopoDS_Compound newCmp;
   BB.MakeCompound(newCmp);
-  BB.Add(newCmp, thePrs.myLeftBank);
-  BB.Add(newCmp, thePrs.myInlet);
-  BB.Add(newCmp, thePrs.myOutlet);
-  BB.Add(newCmp, thePrs.myRightBank);
+  BB.Add(newCmp, LB);
+  BB.Add(newCmp, IL);
+  BB.Add(newCmp, OL);
+  BB.Add(newCmp, RB);
 
   thePrs.myPrs3D = newCmp;
+  std::set<int> ind;
+  ind.insert(1); //inlet ind
+  ind.insert(2); //outlet ind
+
+  TopTools_SequenceOfShape LS;
+  HYDROData_DTM::Get2dFaceFrom3dPres( newCmp, TopoDS::Face(thePrs.myPrs2D), &LS, ind );
+
+#ifndef NDEBUG
+  TopTools_IndexedMapOfShape EE;
+  TopExp::MapShapes(thePrs.myPrs2D, TopAbs_EDGE, EE);
+  int noncontNb = 0;
+  for (int i = 1; i <= 4; i++)
+  {
+    TopoDS_Shape W = LS(i);
+    TopTools_IndexedMapOfShape EW;
+    TopExp::MapShapes(W, TopAbs_EDGE, EW);
+    for (int k = 1; k <= EW.Extent(); k++)
+      noncontNb += !EE.Contains(EW(k));
+  }
+  //noncontNb > 0 => some problem with edge history
+  assert(noncontNb == 0);
+#endif
 
-  HYDROData_DTM::Get2dFaceFrom3dPres( newCmp, TopoDS::Face(thePrs.myPrs2D) );
+  thePrs.myLeftBank = TopoDS::Wire(LS(1));  
+  thePrs.myInlet = TopoDS::Wire(LS(2));  
+  thePrs.myOutlet = TopoDS::Wire(LS(3));  
+  thePrs.myRightBank = TopoDS::Wire(LS(4));
 
 }
\ No newline at end of file