Salome HOME
Get altitude from region implementation.
[modules/hydro.git] / src / HYDROData / HYDROData_CalculationCase.cxx
index a418024d6f5c685a090fa941453d3227fad02b8d..509c2c5fb0bb63ffbd4ca5dd173f9d7aa5d15aa0 100644 (file)
 #define CALCULATION_REGIONS_PREF GetName() + "_Reg"
 #define CALCULATION_ZONES_PREF GetName() + "_Zone"
 #define CALCULATION_GROUPS_PREF GetName() + "_"
+//#define DEB_CLASS2D 1
+#ifdef DEB_CLASS2D
+#include <BRepBuilderAPI_MakeVertex.hxx>
+#endif
 
 #define EXPORT_NAME "HYDRO_" + GetName()
 
@@ -87,7 +91,7 @@ void HYDROData_CalculationCase::SetName( const QString& theName )
       }
     }
 
-    HYDROData_SequenceOfObjects aGroups = GetGeometryGroups();
+    HYDROData_SequenceOfObjects aGroups = GetSplittedGroups();
 
     anIter.Init( aGroups );
     for ( ; anIter.More(); anIter.Next() )
@@ -523,6 +527,22 @@ double HYDROData_CalculationCase::GetAltitudeForPoint( const gp_XY& thePoint ) c
   return GetAltitudeForPoint( thePoint, aZone );
 }
 
+double HYDROData_CalculationCase::GetAltitudeForPoint( const gp_XY&                    thePoint,
+                                                       const Handle(HYDROData_Region)& theRegion ) const
+{
+  double aResAltitude = HYDROData_IAltitudeObject::GetInvalidAltitude();
+
+  Handle(HYDROData_Zone) aZone = GetZoneFromPoint( thePoint );
+  if ( !aZone.IsNull() )
+  {
+    Handle(HYDROData_Region) aRefRegion = Handle(HYDROData_Region)::DownCast( aZone->GetFatherObject() );
+    if ( IsEqual( aRefRegion, theRegion ) )
+      aResAltitude = GetAltitudeForPoint( thePoint, aZone );
+  }
+
+  return aResAltitude;
+}
+
 double HYDROData_CalculationCase::GetAltitudeForPoint( const gp_XY&                  thePoint,
                                                        const Handle(HYDROData_Zone)& theZone ) const
 {
@@ -609,6 +629,23 @@ double HYDROData_CalculationCase::GetAltitudeForPoint( const gp_XY&
   return aResAltitude;
 }
 
+NCollection_Sequence<double> HYDROData_CalculationCase::GetAltitudesForPoints( 
+  const NCollection_Sequence<gp_XY>& thePoints,
+  const Handle(HYDROData_Region)&    theRegion ) const
+{
+  NCollection_Sequence<double> aResSeq;
+
+  for ( int i = 1, n = thePoints.Length(); i <= n; ++i )
+  {
+    const gp_XY& thePnt = thePoints.Value( i );
+    
+    double anAltitude = GetAltitudeForPoint( thePnt, theRegion );
+    aResSeq.Append( anAltitude );
+  }
+
+  return aResSeq;
+}
+
 NCollection_Sequence<double> HYDROData_CalculationCase::GetAltitudesForPoints( 
   const NCollection_Sequence<gp_XY>& thePoints,
   const Handle(HYDROData_Zone)&      theZone ) const
@@ -626,6 +663,17 @@ NCollection_Sequence<double> HYDROData_CalculationCase::GetAltitudesForPoints(
   return aResSeq;
 }
 
+Handle(HYDROData_Region) HYDROData_CalculationCase::GetRegionFromPoint( const gp_XY& thePoint ) const
+{
+  Handle(HYDROData_Region) aResRegion;
+
+  Handle(HYDROData_Zone) aZone = GetZoneFromPoint( thePoint );
+  if ( !aZone.IsNull() )
+    aResRegion = Handle(HYDROData_Region)::DownCast( aZone->GetFatherObject() );
+
+  return aResRegion;
+}
+
 Handle(HYDROData_Zone) HYDROData_CalculationCase::GetZoneFromPoint( const gp_XY& thePoint ) const
 {
   Handle(HYDROData_Zone) aResZone;
@@ -669,7 +717,16 @@ HYDROData_CalculationCase::PointClassification HYDROData_CalculationCase::GetPoi
   TopoDS_Face aZoneFace = TopoDS::Face( theZone->GetShape() );
   if ( aZoneFace.IsNull() )
     return aRes;
-  
+#ifdef DEB_CLASS2D      
+         TopoDS_Compound aCmp;
+      BRep_Builder aBB;
+      aBB.MakeCompound(aCmp);
+         aBB.Add(aCmp, aZoneFace);
+         gp_Pnt aPnt (thePoint.X(), thePoint.Y(), 0.);
+         BRepBuilderAPI_MakeVertex aMk(aPnt);
+         aBB.Add(aCmp, aMk.Vertex());
+         BRepTools::Write(aCmp, "FCL2d.brep");
+#endif  
   TopAbs_State State = HYDROData_Tool::ComputePointState(thePoint, aZoneFace);
   if (State == TopAbs_OUT)
     aRes =  POINT_OUT;
@@ -828,9 +885,12 @@ bool HYDROData_CalculationCase::Export( GEOM::GEOM_Gen_var
 #ifdef DEB_CALCULATION
       cout << "\nOld shape(" << i << ") = " << aShape.TShape() <<endl;
 #endif
-      const TopoDS_Shape& aModifiedShape = aSewing.Modified( aShape );
-      if ( aModifiedShape.IsNull() )
-        continue;
+      
+      TopoDS_Shape aModifiedShape = aShape;
+      if ( aSewing.IsModified( aShape ) )
+        aModifiedShape = aSewing.Modified( aShape );
+      else if ( aSewing.IsModifiedSubShape( aShape ) )
+        aModifiedShape = aSewing.ModifiedSubShape( aShape );
 
 #ifdef DEB_CALCULATION
       const TopLoc_Location& aL1 = aShape.Location();