Salome HOME
Merge branch 'BR_LAND_COVER_MAP' of ssh://git.salome-platform.org/modules/hydro into...
authormkr <mkr@opencascade.com>
Fri, 23 Oct 2015 08:22:19 +0000 (11:22 +0300)
committermkr <mkr@opencascade.com>
Fri, 23 Oct 2015 08:22:19 +0000 (11:22 +0300)
51 files changed:
CMake/UsePyQt4EXT.cmake
src/HYDROData/HYDROData_BSplineOperation.cxx
src/HYDROData/HYDROData_Document.cxx
src/HYDROData/HYDROData_Entity.cxx
src/HYDROData/HYDROData_LandCoverMap.cxx
src/HYDROData/HYDROData_LandCoverMap.h
src/HYDROData/HYDROData_Object.cxx
src/HYDROData/HYDROData_Object.h
src/HYDROData/HYDROData_PolylineOperator.cxx
src/HYDROData/HYDROData_PolylineOperator.h
src/HYDROData/HYDROData_PolylineXY.cxx
src/HYDROData/HYDROData_PolylineXY.h
src/HYDROData/HYDROData_ShapeFile.cxx
src/HYDROData/HYDROData_Tool.cxx
src/HYDROData/HYDROData_Tool.h
src/HYDROGUI/HYDROGUI_LandCoverMapPrs.cxx
src/HYDROGUI/HYDROGUI_LandCoverMapPrs.h
src/HYDROGUI/HYDROGUI_Polyline.cxx
src/HYDROGUI/HYDROGUI_PolylineExtractionOp.cxx
src/HYDROGUI/HYDROGUI_PolylineExtractionOp.h
src/HYDROPy/CMakeLists.txt
src/HYDROPy/HYDROData.sip
src/HYDROPy/HYDROData_AltitudeObject.sip
src/HYDROPy/HYDROData_Application.sip
src/HYDROPy/HYDROData_ArtificialObject.sip
src/HYDROPy/HYDROData_Bathymetry.sip
src/HYDROPy/HYDROData_CalculationCase.sip
src/HYDROPy/HYDROData_LandCoverMap.sip [new file with mode: 0644]
src/HYDROPy/HYDROData_Zone.sip
src/HYDRO_tests/CMakeLists.txt
src/HYDRO_tests/ExternalFiles.cmake
src/HYDRO_tests/TestShape.cxx [new file with mode: 0644]
src/HYDRO_tests/TestShape.h [new file with mode: 0644]
src/HYDRO_tests/TestViewer.cxx
src/HYDRO_tests/TestViewer.h
src/HYDRO_tests/reference_data/Channel.png [new file with mode: 0644]
src/HYDRO_tests/reference_data/Extraction_Channel.png [new file with mode: 0644]
src/HYDRO_tests/reference_data/Extraction_ImmZone.png [new file with mode: 0644]
src/HYDRO_tests/reference_data/LandCoverMap_PrsByTypes.png
src/HYDRO_tests/reference_data/LandCoverMap_Split_Polyline.png [new file with mode: 0644]
src/HYDRO_tests/reference_data/LandCoverMap_TransparentPrs.png [new file with mode: 0644]
src/HYDRO_tests/reference_data/Polyline_Presentation.png [new file with mode: 0644]
src/HYDRO_tests/reference_data/Split_Polylines_Colors.png [new file with mode: 0644]
src/HYDRO_tests/test_HYDROData_Channel.cxx [new file with mode: 0644]
src/HYDRO_tests/test_HYDROData_Channel.h [new file with mode: 0644]
src/HYDRO_tests/test_HYDROData_LandCoverMap.cxx
src/HYDRO_tests/test_HYDROData_LandCoverMap.h
src/HYDRO_tests/test_HYDROData_PolylineXY.cxx
src/HYDRO_tests/test_HYDROData_PolylineXY.h
src/HYDRO_tests/test_HYDROData_StricklerTable.cxx
src/shapelib/CMakeLists.txt

index c85230fe4557c1e72b63f11097b22d67c4d3cb6b..bd1875f6aa869e3977df2fc18838d15a1f02c767 100644 (file)
@@ -177,6 +177,9 @@ MACRO(PYQT4_WRAP_SIP_EXT outfiles)
 
     LIST(APPEND _output ${CMAKE_CURRENT_BINARY_DIR}/sipHYDROPyHYDROData_StricklerTable.cc)
     SET(${outfiles} ${${outfiles}} ${CMAKE_CURRENT_BINARY_DIR}/sipHYDROPyHYDROData_StricklerTable.cc)
+
+    LIST(APPEND _output ${CMAKE_CURRENT_BINARY_DIR}/sipHYDROPyHYDROData_LandCoverMap.cc)
+    SET(${outfiles} ${${outfiles}} ${CMAKE_CURRENT_BINARY_DIR}/sipHYDROPyHYDROData_LandCoverMap.cc)
     
     ADD_CUSTOM_COMMAND(
       OUTPUT ${_output}
index 058005d9fdc62d228ad29fc929ecba8f07ac42c7..64ae37d4cb6ce8342354165aaafc3bf44e8d304b 100644 (file)
@@ -23,9 +23,7 @@
 #include <TColgp_HArray1OfPnt.hxx>
 #include <QPainterPath>
 
-#ifndef LIGHT_MODE
 #include <CurveCreator_Utils.hxx>
-#endif
 
 Handle(Geom_BSplineCurve) HYDROData_BSplineOperation::ComputeCurve(
   const NCollection_Sequence<gp_XYZ>& thePoints,
@@ -58,11 +56,9 @@ Handle(Geom_BSplineCurve) HYDROData_BSplineOperation::ComputeCurve(
 
   // compute BSpline
   Handle(Geom_BSplineCurve) aBSpline;
-#ifndef LIGHT_MODE
   if( CurveCreator_Utils::constructBSpline( aHCurvePoints, theIsClosed, aBSpline ) )
     return aBSpline;
   else
-#endif
     return Handle(Geom_BSplineCurve)();
 }
 
index 0cf4c403258ebc2c8dffdbf4913aca7922b66b57..93457716225fdd41c6166418d181343bae9f0950 100644 (file)
@@ -267,6 +267,7 @@ bool HYDROData_Document::DumpToPython( const QString& theFileName,
   aRes = aRes && dumpPartitionToPython( aFile, theIsMultiFile, aTreatedObjects, KIND_CHANNEL );
   aRes = aRes && dumpPartitionToPython( aFile, theIsMultiFile, aTreatedObjects, KIND_DIGUE );
   aRes = aRes && dumpPartitionToPython( aFile, theIsMultiFile, aTreatedObjects, KIND_OBSTACLE );
+  aRes = aRes && dumpPartitionToPython( aFile, theIsMultiFile, aTreatedObjects, KIND_LAND_COVER_MAP );
   aRes = aRes && dumpPartitionToPython( aFile, theIsMultiFile, aTreatedObjects, KIND_CALCULATION );
 
   // Dump code to close python fuction
index 99667f318fa8f178fdd5c154f09c1b7e236fd25c..f0b9e5fb034a06e9b26123375f8f69eab2fe0fc2 100644 (file)
@@ -165,6 +165,8 @@ void HYDROData_Entity::Changed( Geometry theChangedGeometry )
   for ( ; anIter.More(); anIter.Next() )
   {
     Handle(HYDROData_Entity) anObject = anIter.Current();
+    if( anObject.IsNull() )
+      continue;
     HYDROData_SequenceOfObjects aRefSeq = anObject->GetAllReferenceObjects();
     for ( int i = 1, n = aRefSeq.Length(); i <= n; ++i )
     {
index d7703a87e1d0d14f75237ce07d5a4cf82bdbe87f..a429e381ae43931784e002cf925fac6169926e8a 100644 (file)
@@ -208,7 +208,7 @@ HYDROData_LandCoverMap::DBFStatus HYDROData_LandCoverMap::ImportDBF( const QStri
                                                                      const QString& theFieldName, 
                                                                      const QStringList& theDBFValues,
                                                                      const QStringList& theStricklerTypes,
-                                                                     QMap<int, int> theIndices )
+                                                                     const QList<int>& theIndices )
 {
   if (theDBFValues.size() != theStricklerTypes.size())
     return DBFStatus_DIFF_SIZE_ERROR;
@@ -749,3 +749,27 @@ TopoDS_Face HYDROData_LandCoverMap::FindByPoint( const gp_Pnt2d& thePoint, QStri
   theType = "";
   return TopoDS_Face();
 }
+
+/**
+  Dump to Python
+  @param theTreatedObjects the map of treated objects
+*/
+QStringList HYDROData_LandCoverMap::DumpToPython( MapOfTreatedObjects& theTreatedObjects ) const
+{
+  QStringList aResList = dumpObjectCreation( theTreatedObjects );
+  QString aName = GetObjPyName();
+
+  //Handle(HYDROData_PolylineXY) aHydAxis = GetHydraulicAxis();
+  //setPythonReferenceObject( theTreatedObjects, aResList, aHydAxis, "SetHydraulicAxis" );
+
+  //HYDROData_SequenceOfObjects aSeqOfProfiles = GetProfiles();
+  //for ( int i = 1, aNb = aSeqOfProfiles.Size(); i <= aNb; ++i )
+  //{
+    //const Handle(HYDROData_Entity) aProfile = aSeqOfProfiles.Value( i );
+    //setPythonReferenceObject( theTreatedObjects, aResList, aProfile, "AddProfile" );
+  //}
+
+  //TODO
+
+  return aResList;
+}
index 2439c2de08dcbff72a87453baa530a33cc5384e7..cf6b7ca508dd1e4d2704f2af03d30438da92c58f 100644 (file)
@@ -21,7 +21,6 @@
 
 #include <HYDROData_Entity.h>
 #include <TDataStd_ExtStringArray.hxx>
-#include <QMap>
 
 DEFINE_STANDARD_HANDLE( HYDROData_LandCoverMap, HYDROData_Entity )
 
@@ -78,23 +77,23 @@ public:
     DBFStatus_NO_DBFVALUES_CORRESPONDENCE_WARNING
   };
 
-  HYDROData_LandCoverMap();
-  ~HYDROData_LandCoverMap();
+  HYDRODATA_EXPORT HYDROData_LandCoverMap();
+  HYDRODATA_EXPORT virtual ~HYDROData_LandCoverMap();
 
-  virtual const ObjectKind GetKind() const;
+  HYDRODATA_EXPORT virtual const ObjectKind GetKind() const;
 
-  DBFStatus ImportDBF( const QString& theDBFFileName, 
-    const QString& theFieldName, 
-    const QStringList& DBFValues,
-    const QStringList& StricklerTypes,
-    QMap<int, int> theIndices );
+  HYDRODATA_EXPORT DBFStatus ImportDBF( const QString& theDBFFileName, 
+                                        const QString& theFieldName, 
+                                        const QStringList& DBFValues,
+                                        const QStringList& StricklerTypes,
+                                        const QList<int>& theIndices );
  
-  void ExportDBF( const QString& theDBFFileName,
-    const QString& theFieldName, 
-    const QStringList& theDBFValues,
-    const QStringList& theStricklerTypes) const;
+  HYDRODATA_EXPORT void ExportDBF( const QString& theDBFFileName,
+                                   const QString& theFieldName, 
+                                   const QStringList& theDBFValues,
+                                   const QStringList& theStricklerTypes ) const;
 
-  bool ExportTelemac( const QString& theFileName, double theDeflection ) const;
+  HYDRODATA_EXPORT bool ExportTelemac( const QString& theFileName, double theDeflection ) const;
 
   HYDRODATA_EXPORT bool Add( const Handle( HYDROData_Object )&, const QString& theType );
   HYDRODATA_EXPORT bool Add( const Handle( HYDROData_PolylineXY )&, const QString& theType );
@@ -105,10 +104,12 @@ public:
   HYDRODATA_EXPORT bool Split( const Handle( HYDROData_PolylineXY )& );
   HYDRODATA_EXPORT bool Merge( const TopTools_ListOfShape&, const QString& theType );
 
-  TopoDS_Face FindByPoint( const gp_Pnt2d&, QString& theType ) const;
+  HYDRODATA_EXPORT TopoDS_Face FindByPoint( const gp_Pnt2d&, QString& theType ) const;
 
   HYDRODATA_EXPORT TopoDS_Shape GetShape() const;
 
+  HYDRODATA_EXPORT virtual QStringList DumpToPython( MapOfTreatedObjects& theTreatedObjects ) const;
+
 protected:
   void SetShape( const TopoDS_Shape& );
 
index 78f734ea0a9b387d71b020c1fbae3f0c5e3ed986..20eead85ab2a6ab08dbbced470a32b015fe94632 100644 (file)
@@ -374,3 +374,26 @@ void HYDROData_Object::SetIsSubmersible( bool isSubmersible ) const
 {
   TDataStd_Integer::Set( myLab, isSubmersible ? 1 : 0 );
 }
+
+void HYDROData_Object::GetBoundaries( QList<TopoDS_Shape>& theBoundShapes,
+                                      QStringList& theBoundNames ) const
+{
+  HYDROData_SequenceOfObjects aGroups = GetGroups();
+    HYDROData_SequenceOfObjects::Iterator anIter( aGroups );
+    for ( ; anIter.More(); anIter.Next() )
+    {
+      Handle(HYDROData_ShapesGroup) aGroup =
+        Handle(HYDROData_ShapesGroup)::DownCast( anIter.Value() );
+      if( aGroup.IsNull() )
+        continue;
+
+      QString aName = aGroup->GetName();
+      TopTools_SequenceOfShape aShapes;
+      aGroup->GetShapes( aShapes );
+      for( int i=1, n=aShapes.Length(); i<=n; i++ )
+      {
+        theBoundShapes.append( aShapes( i ) );
+        theBoundNames.append( aName );
+      }
+    }
+}
index aa85d5aca966356f30e06cc5243c9ea1ad7320f1..0c217f274a6464e8e44d93c5271e4c7de578453b 100644 (file)
@@ -160,6 +160,9 @@ public:
   HYDRODATA_EXPORT bool IsSubmersible() const;
   HYDRODATA_EXPORT void SetIsSubmersible( bool ) const;
 
+  HYDRODATA_EXPORT virtual void GetBoundaries( QList<TopoDS_Shape>& theBoundShapes,
+                                               QStringList& theBoundNames ) const;
+
 protected:
 
   /**
index 7e44abefa551166741ff52efc984e12951d4047a..0bc2d326069380329d9f92e0bb4d15626c24eff5 100644 (file)
@@ -19,6 +19,7 @@
 #include <HYDROData_PolylineOperator.h>
 #include <HYDROData_Document.h>
 #include <HYDROData_TopoCurve.h>
+#include <HYDROData_Object.h>
 
 #ifndef LIGHT_MODE
 #include <CurveCreator_Utils.hxx>
@@ -46,7 +47,8 @@
 #include <TopExp.hxx>
 #include <TopExp_Explorer.hxx>
 #include <TopTools_IndexedDataMapOfShapeListOfShape.hxx>
-#include <QString>
+#include <QStringList>
+#include <QColor>
 #include <Geom_BSplineCurve.hxx>
 
 template<class T> void append( std::vector<T>& theList, const std::vector<T>& theList2 )
@@ -80,8 +82,9 @@ bool HYDROData_PolylineOperator::Split( const Handle( HYDROData_Document )& theD
   for( int i=0, n=aCurves.size(); i<n; i++ )
   {
     std::vector<TopoDS_Shape> aCurvesList;
-    Split(aCurves[i], thePoint, theTolerance, aCurvesList);
-    bool isLocalOK = CreatePolylines( theDoc, thePolyline->GetName(), aCurvesList, true );
+    Split( aCurves[i], thePoint, theTolerance, aCurvesList );
+    bool isLocalOK = CreatePolylines( theDoc, thePolyline->GetName(),
+      aCurvesList, true, thePolyline->GetWireColor() );
     isOK = isOK && isLocalOK;
   }
   return isOK;
@@ -160,7 +163,7 @@ bool HYDROData_PolylineOperator::Merge( const Handle( HYDROData_Document )& theD
 
   std::vector<TopoDS_Shape> aPolylines(1);
   aPolylines[0] = aWireSet;
-  CreatePolylines(theDoc, theName, aPolylines, false);
+  CreatePolylines( theDoc, theName, aPolylines, false, QColor() );
   return true;
 }
 
@@ -228,7 +231,7 @@ bool HYDROData_PolylineOperator::split( const Handle( HYDROData_Document )& theD
     }
   }
 
-  CreatePolylines(theDoc, thePolyline->GetName(), aResult, true);
+  CreatePolylines( theDoc, thePolyline->GetName(), aResult, true, thePolyline->GetWireColor() );
   return true;
 }
 
@@ -280,7 +283,8 @@ void HYDROData_PolylineOperator::Split(
 bool HYDROData_PolylineOperator::CreatePolylines( const Handle( HYDROData_Document )& theDoc,
                                                   const QString& theNamePrefix,
                                                   const std::vector<TopoDS_Shape>& theShapes,
-                                                  bool isUseIndices )
+                                                  bool isUseIndices,
+                                                  const QColor& theColor )
 {
   if( theDoc.IsNull() )
     return false;
@@ -307,6 +311,9 @@ bool HYDROData_PolylineOperator::CreatePolylines( const Handle( HYDROData_Docume
     {
       aPolyline->SetName( theNamePrefix );
     }
+
+    if( theColor.isValid() )
+      aPolyline->SetWireColor( theColor );
   }
   return true;
 }
@@ -412,3 +419,43 @@ double HYDROData_PolylineOperator::ReduceDeflection(
   }
   return aMaxDefl;
 }
+
+bool HYDROData_PolylineOperator::Extract( const Handle(HYDROData_Document)& theDocument,
+                                          const Handle(HYDROData_Object)& theObject )
+{
+  if( theObject.IsNull() || theDocument.IsNull() )
+    return false;
+
+  QList<TopoDS_Shape> aBoundShapes;
+  QStringList aBoundNames;
+
+  theObject->GetBoundaries( aBoundShapes, aBoundNames );
+
+  for( int i=0, n=aBoundShapes.size(); i<n; i++ )
+  {
+    TopoDS_Shape aShape = aBoundShapes[i];
+    if( aShape.IsNull() )
+      continue;
+
+    QString aBoundName = i<aBoundNames.size() ? aBoundNames[i] : "";
+
+    Handle( HYDROData_PolylineXY ) aPolyline = 
+      Handle( HYDROData_PolylineXY )::DownCast( theDocument->CreateObject( KIND_POLYLINEXY ) );
+    
+    if( aPolyline.IsNull() )
+      return false;
+
+    aPolyline->SetShape( aShape );
+
+    int anIndex = 0;
+    QString aName = aBoundName;
+    while( !theDocument->FindObjectByName( aName ).IsNull() )
+    {
+      anIndex++;
+      aName = aBoundName + "_" + QString::number( anIndex );
+    }
+    aPolyline->SetName( aName );
+  }
+
+  return true;
+}
index 8e27796cea78a6f98165bbf531534985fc482ca3..eefac88bad05e67ac5c3237f353eeda87b97c04d 100644 (file)
@@ -26,6 +26,7 @@
 
 class Handle( HYDROData_Document );
 class HYDROData_TopoCurve;
+class Handle(HYDROData_Object);
 
 class HYDRODATA_EXPORT HYDROData_PolylineOperator
 {
@@ -64,6 +65,9 @@ public:
     HYDROData_TopoCurve& theCurve,
     int& thePieceCount);
 
+  bool Extract( const Handle(HYDROData_Document)& theDocument,
+                const Handle(HYDROData_Object)& theObject );
+
 protected:
   bool split( const Handle( HYDROData_Document )& theDoc,
               const Handle( HYDROData_PolylineXY )& thePolyline,
@@ -81,7 +85,8 @@ protected:
   static bool CreatePolylines( const Handle( HYDROData_Document )& theDoc,
                                const QString& theNamePrefix,
                                const std::vector<TopoDS_Shape>& theShape,
-                               bool isUseIndices );
+                               bool isUseIndices,
+                               const QColor& theColor );
 };
 
 #endif
index d47f2cb8c19a058ac0b1857bc47948507e4361a8..559947e684ce444fb16022fbd976538962c507f5 100755 (executable)
@@ -29,6 +29,7 @@
 #include <BRepBuilderAPI_MakePolygon.hxx>
 #include <BRepBuilderAPI_MakeFace.hxx>
 #include <BRepOffsetAPI_NormalProjection.hxx>
+#include <BRepAdaptor_Curve.hxx>
 
 #ifndef LIGHT_MODE
 #include <GEOMBase.h>
@@ -40,6 +41,7 @@
 #include <Geom_BSplineCurve.hxx>
 
 #include <GCPnts_AbscissaPoint.hxx>
+#include <GCPnts_QuasiUniformDeflection.hxx>
 
 #include <ImageComposer_MetaTypes.h>
 
@@ -56,6 +58,7 @@
 #include <TColStd_ListIteratorOfListOfReal.hxx>
 
 #include <TColStd_Array1OfReal.hxx>
+#include <TColgp_Array1OfPnt.hxx>
 
 #include <TDataStd_AsciiString.hxx>
 #include <TDataStd_BooleanList.hxx>
@@ -118,7 +121,8 @@ IMPLEMENT_STANDARD_HANDLE(HYDROData_PolylineXY, HYDROData_IPolyline)
 IMPLEMENT_STANDARD_RTTIEXT(HYDROData_PolylineXY, HYDROData_IPolyline)
 
 HYDROData_PolylineXY::HYDROData_PolylineXY()
-: HYDROData_IPolyline()
+: HYDROData_IPolyline(),
+  myIsInCustomFlag( false )
 {
 }
 
@@ -253,7 +257,9 @@ bool convertEdgeToSection( const TopoDS_Edge&
                            NCollection_Sequence<HYDROData_PolylineXY::SectionType>& theSectTypes,
                            NCollection_Sequence<bool>&                              theSectClosures,
                            NCollection_Sequence<HYDROData_PolylineXY::PointsList>&  theSectPoints,
-                           const bool                                               theIsCanBeClosed )
+                           bool                                                     IsCanBeClosed,
+                           bool                                                     IsInterpolationAllowed,
+                           double                                                   theDeflection )
 {
   Standard_Real aFirst = 0.0, aLast = 0.0;
   Handle(Geom_Curve) anEdgeGeomCurve = BRep_Tool::Curve( theEdge, aFirst, aLast );
@@ -266,7 +272,7 @@ bool convertEdgeToSection( const TopoDS_Edge&
   HYDROData_PolylineXY::SectionType aSectionType = HYDROData_PolylineXY::SECTION_POLYLINE;
   HYDROData_PolylineXY::PointsList aPointsList;
 
-  if ( anEdgeGeomCurve->IsKind( STANDARD_TYPE(Geom_Line) ) )
+  if( anEdgeGeomCurve->IsKind( STANDARD_TYPE(Geom_Line) ) )
   {
     Handle(Geom_Line) aGeomLine = Handle(Geom_Line)::DownCast( anEdgeGeomCurve );
 
@@ -280,28 +286,22 @@ bool convertEdgeToSection( const TopoDS_Edge&
     HYDROData_PolylineXY::Point aSectLastPoint( aLastPoint.X(), aLastPoint.Y() );
     aPointsList.Append( aSectLastPoint );
   }
-  else if ( anEdgeGeomCurve->IsKind( STANDARD_TYPE(Geom_BSplineCurve) ) )
+  else if ( anEdgeGeomCurve->IsKind( STANDARD_TYPE(Geom_BSplineCurve) ) || IsInterpolationAllowed )
   {
     aSectionType = HYDROData_PolylineXY::SECTION_SPLINE;
 
-    Handle(Geom_BSplineCurve) aGeomSpline = 
-      Handle(Geom_BSplineCurve)::DownCast( anEdgeGeomCurve );
+    BRepAdaptor_Curve anAdaptorCurve( theEdge );
+    GCPnts_QuasiUniformDeflection aDiscrete( anAdaptorCurve, theDeflection );
 
-    int aNbKnots = aGeomSpline->NbKnots();
+    int aNbPoints = aDiscrete.NbPoints();
 
-    TColStd_Array1OfReal aSplineKnots( 1, aNbKnots );
-    aGeomSpline->Knots( aSplineKnots );
+    // Decrease the number of imported poles because of last one 
+    // pole is the closing point which are the start point
+    if ( anIsEdgeClosed ) aNbPoints--;
 
-    // Decrease the number of imported knots because of last one 
-    // knot is the closing point which are the start point
-    if ( anIsEdgeClosed ) aNbKnots--;
-
-    for ( int i = 1; i <= aNbKnots; ++i )
+    for ( int i = 1; i <= aNbPoints; ++i )
     {
-      const Standard_Real& aKnot = aSplineKnots.Value( i );
-
-      gp_Pnt aPoint;
-      aGeomSpline->D0( aKnot, aPoint );
+      const gp_Pnt& aPoint = aDiscrete.Value( i );
 
       HYDROData_PolylineXY::Point aSectPoint( aPoint.X(), aPoint.Y() );
       aPointsList.Append( aSectPoint );
@@ -324,7 +324,9 @@ bool convertEdgeToSection( const TopoDS_Edge&
   return true;
 }
 
-bool HYDROData_PolylineXY::ImportShape( const TopoDS_Shape& theShape )
+bool HYDROData_PolylineXY::ImportShape( const TopoDS_Shape& theShape,
+                                        bool IsInterpolationAllowed,
+                                        double theDeviation )
 {
   if ( theShape.IsNull() )
     return false;
@@ -341,7 +343,8 @@ bool HYDROData_PolylineXY::ImportShape( const TopoDS_Shape& theShape )
   if ( theShape.ShapeType() == TopAbs_EDGE )
   {
     TopoDS_Edge anEdge = TopoDS::Edge( theShape );
-    anIsCanBeImported = convertEdgeToSection( anEdge, aSectNames, aSectTypes, aSectClosures, aSectPoints, true );
+    anIsCanBeImported = convertEdgeToSection( anEdge, aSectNames, aSectTypes,
+      aSectClosures, aSectPoints, true, IsInterpolationAllowed, theDeviation );
   }
   else if ( theShape.ShapeType() == TopAbs_WIRE )
   {
@@ -352,7 +355,8 @@ bool HYDROData_PolylineXY::ImportShape( const TopoDS_Shape& theShape )
     for ( int i = 1, n = anEdges.Length(); i <= n && anIsCanBeImported; ++i )
     {
       TopoDS_Edge aWireEdge = TopoDS::Edge( anEdges.Value( i ) );
-      anIsCanBeImported = convertEdgeToSection( aWireEdge, aSectNames, aSectTypes, aSectClosures, aSectPoints, false );
+      anIsCanBeImported = convertEdgeToSection( aWireEdge, aSectNames, aSectTypes,
+        aSectClosures, aSectPoints, false, IsInterpolationAllowed, theDeviation );
     }
   }
 
@@ -835,6 +839,11 @@ void HYDROData_PolylineXY::GetSections( NCollection_Sequence<TCollection_AsciiSt
   theSectTypes.Clear();
   theSectClosures.Clear();
 
+  if( IsCustom() )
+  {
+    const_cast<HYDROData_PolylineXY*>( this )->Interpolate();
+  }
+
   Handle(TDataStd_ExtStringList) aNamesList;
   Handle(TDataStd_IntegerList) aTypesList;
   Handle(TDataStd_BooleanList) aClosuresList;
@@ -1075,7 +1084,7 @@ HYDROData_PolylineXY::PointsList HYDROData_PolylineXY::GetPoints( const int theS
 
   if( IsCustom() )
   {
-    //TODO: make interpolation to fill the list
+    const_cast<HYDROData_PolylineXY*>( this )->Interpolate();
   }
  
   Handle(TDataStd_RealList) aListX, aListY;
@@ -1177,12 +1186,22 @@ void HYDROData_PolylineXY::Transform( const QTransform& theTrsf )
 
 bool HYDROData_PolylineXY::IsCustom() const
 {
+  if( myIsInCustomFlag )
+    return false;
+
   bool isNull = GetShape().IsNull();
   int aNbPoints = 0;
 
-  //TODO: to check if there is no points
-  //for( int i=0, n=NbSections(); i<n; i++ )
-  //  aNbPoints += NbPoints( i );
+  HYDROData_PolylineXY* aThat = const_cast<HYDROData_PolylineXY*>( this );
+  aThat->myIsInCustomFlag = true;
+  for( int i=0, n=NbSections(); i<n; i++ )
+    aNbPoints += NbPoints( i );
+  aThat->myIsInCustomFlag = false;
 
   return !isNull && aNbPoints == 0;
 }
+
+void HYDROData_PolylineXY::Interpolate()
+{
+  ImportShape( GetShape(), true );
+}
index 57ff8cadb614bc2054971431ea672e2cbae36f6c..611a2a30f51a8eb3a2683937da67e5842a9c871b 100644 (file)
@@ -127,7 +127,9 @@ public:
   /**
    * Returns the 3D presentation of all points.
    */
-  HYDRODATA_EXPORT virtual bool ImportShape( const TopoDS_Shape& theShape );
+  HYDRODATA_EXPORT virtual bool ImportShape( const TopoDS_Shape& theShape,
+                                             bool IsInterpolationAllowed = false,
+                                             double theDeviation = 1E-3 );
 
   /**
    * Returns flag indicating that polyline can be edited or not.
@@ -297,6 +299,8 @@ protected:
    */
   HYDRODATA_EXPORT virtual void setEditable( const bool theIsEditable );
 
+  HYDRODATA_EXPORT void Interpolate();
+
 protected:
 
   friend class HYDROData_Profile;
@@ -312,6 +316,9 @@ protected:
    * Destructs properties of the object and object itself, removes it from the document.
    */
   HYDRODATA_EXPORT ~HYDROData_PolylineXY();
+
+private:
+  bool myIsInCustomFlag;
 };
 
 #endif
index 3aa6ac7e589ef88c5e4d1bb13abdcae9c1a68c6b..357ceedd567be540bd9e3d841d982ea8bab8f91f 100644 (file)
 #include <QColor>
 #include <BRepTopAdaptor_FClass2d.hxx>
 
+#ifdef WIN32
+  #pragma warning( disable: 4996 )
+#endif
+
 HYDROData_ShapeFile::HYDROData_ShapeFile() : myHSHP(NULL)
 { 
 }
index def682d94cc6900d6cc1ad2aaccf967460f70edc..f6f0f5a84525e887700d7357bb79c09c5822e1cd 100644 (file)
@@ -282,6 +282,14 @@ Quantity_Color HYDROData_Tool::toOccColor( const QColor& theColor )
   return Quantity_Color( r, g, b, Quantity_TOC_RGB );
 }
 
+QColor HYDROData_Tool::toQtColor( const Quantity_Color& theColor )
+{
+  int r = 255 * theColor.Red();
+  int g = 255 * theColor.Green();
+  int b = 255 * theColor.Blue();
+  return QColor( r, g, b );
+}
+
 std::ostream& operator<<( std::ostream& theStream, const QString& theText )
 {
   theStream << theText.toStdString();
@@ -306,3 +314,17 @@ std::ostream& operator<<( std::ostream& theStream, const TopoDS_Face& theFace )
   return theStream;
 }
 
+std::ostream& operator<<( std::ostream& theStream, const gp_XY& theXY )
+{
+  theStream << "(" << theXY.X() << "; " << theXY.Y() << ")";
+  return theStream;
+}
+
+bool operator == ( const gp_XY& thePoint1, const gp_XY& thePoint2 )
+{
+  const double EPS = 1E-3;
+  return
+    fabs( thePoint1.X() - thePoint2.X() ) < EPS &&
+    fabs( thePoint1.Y() - thePoint2.Y() ) < EPS;
+
+}
index efff055d66a2849944108836fa98461e1e203285..b9b6d6d7658d7ba01ebfb7eb9946d8d2444007e7 100644 (file)
@@ -119,7 +119,8 @@ public:
   static TCollection_ExtendedString toExtString( const QString& );
   static QString                    toQString( const TCollection_ExtendedString& );
 
-  static Quantity_Color             toOccColor( const QColor& );
+  static Quantity_Color toOccColor( const QColor& );
+  static QColor toQtColor( const Quantity_Color& );
 };
 
 inline bool ValuesEquals( const double& theFirst, const double& theSecond )
@@ -142,6 +143,8 @@ HYDRODATA_EXPORT std::ostream& operator<<( std::ostream& theStream, const QStrin
 HYDRODATA_EXPORT std::ostream& operator<<( std::ostream& theStream, const QColor& theText );
 HYDRODATA_EXPORT std::ostream& operator<<( std::ostream& theStream, const TopoDS_Shape& theShape );
 HYDRODATA_EXPORT std::ostream& operator<<( std::ostream& theStream, const TopoDS_Face& theFace );
+HYDRODATA_EXPORT bool operator == ( const gp_XY& thePoint1, const gp_XY& thePoint2 );
+HYDRODATA_EXPORT std::ostream& operator<<( std::ostream& theStream, const gp_XY& theXY );
 
 #endif
 
index 7a005c24d78239fa2239ed0aa267268c984cffd7..6f654a6d1888563bfb0dad24030c19489d644d02 100644 (file)
 #include <HYDROData_Tool.h>
 #include <AIS_DisplayMode.hxx>
 #include <Prs3d_IsoAspect.hxx>
+#include <SelectMgr_SequenceOfOwner.hxx>
 #include <StdPrs_WFDeflectionShape.hxx>
+#include <StdSelect_BRepOwner.hxx>
 #include <TopoDS_Face.hxx>
 #include <QColor>
 #include <QString>
 
+const Quantity_Color EDGES_COLOR = Quantity_NOC_WHITE;
+const int HILIGHT_ISO_NB = 10;
+
 IMPLEMENT_STANDARD_HANDLE( HYDROGUI_LandCoverMapPrs, AIS_ColoredShape )
 IMPLEMENT_STANDARD_RTTIEXT( HYDROGUI_LandCoverMapPrs, AIS_ColoredShape )
 
@@ -33,6 +38,8 @@ HYDROGUI_LandCoverMapPrs::HYDROGUI_LandCoverMapPrs( const Handle(HYDROData_LandC
   : AIS_ColoredShape( theMap->GetShape() )
 {
   SetLandCoverMap( theMap );
+  SetAutoHilight( Standard_False );
+  SetHilightAttributes( EDGES_COLOR );
 }
 
 HYDROGUI_LandCoverMapPrs::~HYDROGUI_LandCoverMapPrs()
@@ -135,13 +142,11 @@ void HYDROGUI_LandCoverMapPrs::Compute( const Handle(PrsMgr_PresentationManager3
 {
   thePresentation->Clear();
 
-  Quantity_Color anEdgeColor = Quantity_NOC_WHITE;
-
   myDrawer->UIsoAspect()->SetNumber( 0 );
   myDrawer->VIsoAspect()->SetNumber( 0 );
-  myDrawer->LineAspect()->SetColor( anEdgeColor );
-  myDrawer->FaceBoundaryAspect()->SetColor( anEdgeColor );
-  myDrawer->FreeBoundaryAspect()->SetColor( anEdgeColor );
+  myDrawer->LineAspect()->SetColor( EDGES_COLOR );
+  myDrawer->FaceBoundaryAspect()->SetColor( EDGES_COLOR );
+  myDrawer->FreeBoundaryAspect()->SetColor( EDGES_COLOR );
 
   switch( theMode )
   {
@@ -155,3 +160,34 @@ void HYDROGUI_LandCoverMapPrs::Compute( const Handle(PrsMgr_PresentationManager3
     StdPrs_WFDeflectionShape::Add( thePresentation, Shape(), myDrawer );
 }
 
+void HYDROGUI_LandCoverMapPrs::HilightSelected( const Handle(PrsMgr_PresentationManager3d)& thePresentationManager,
+                                                const SelectMgr_SequenceOfOwner& theOwners )
+{
+  Handle(Prs3d_Presentation) aSelectPrs = GetSelectPresentation( thePresentationManager );
+
+  SetHilightAttributes( EDGES_COLOR );
+
+  for( int i=1, n=theOwners.Length(); i<=n; i++ )
+  {
+    Handle(StdSelect_BRepOwner) anOwner = Handle(StdSelect_BRepOwner)::DownCast( theOwners.Value( i ) );
+    if( !anOwner.IsNull() )
+      StdPrs_WFDeflectionShape::Add( aSelectPrs, anOwner->Shape(), HilightAttributes() );
+  }
+
+  HilightAttributes()->UIsoAspect()->SetNumber( 0 );
+  HilightAttributes()->VIsoAspect()->SetNumber( 0 );
+
+  aSelectPrs->SetDisplayPriority( 9 );
+  aSelectPrs->Display();
+}
+
+void HYDROGUI_LandCoverMapPrs::SetHilightAttributes( const Quantity_Color& theEdgesColor )
+{
+  HilightAttributes()->UIsoAspect()->SetNumber( HILIGHT_ISO_NB );
+  HilightAttributes()->UIsoAspect()->SetColor( theEdgesColor );
+  HilightAttributes()->VIsoAspect()->SetNumber( HILIGHT_ISO_NB );
+  HilightAttributes()->VIsoAspect()->SetColor( theEdgesColor );
+  HilightAttributes()->LineAspect()->SetColor( theEdgesColor );
+  HilightAttributes()->FaceBoundaryAspect()->SetColor( theEdgesColor );
+  HilightAttributes()->FreeBoundaryAspect()->SetColor( theEdgesColor );
+}
index 0e9888a1b8ee6ffb7c91a58f0c544478f4bd67a6..e1acc832233537f8a33a1df5da74bd7c4492cc9e 100644 (file)
@@ -47,10 +47,14 @@ public:
                         const Handle(Prs3d_Presentation)& thePresentation,
                         const Standard_Integer theMode );
 
+  virtual void HilightSelected( const Handle(PrsMgr_PresentationManager3d)& thePresentationManager,
+                                const SelectMgr_SequenceOfOwner& theOwners );
+
   Quantity_Color GetColor( const QString& theStricklerType ) const;
 
 protected:
   void UpdateColors();
+  void SetHilightAttributes( const Quantity_Color& theEdgesColor );
 
 private:
   Handle(HYDROData_LandCoverMap)   myLCMap;
index 91e0a06ab5c10de7e1653de9b4776db9f950ce4c..4f070b47c634761832d79a24ef1b43df8269f823 100644 (file)
@@ -26,6 +26,7 @@
 #include <BRep_Tool.hxx>
 #include <GCPnts_AbscissaPoint.hxx>
 #include <GeomAdaptor_Curve.hxx>
+#include <Graphic3d_AspectLine3d.hxx>
 #include <gp_Pnt.hxx>
 #include <gp_Dir.hxx>
 #include <Prs3d_Arrow.hxx>
@@ -82,8 +83,11 @@ void HYDROGUI_Polyline::Compute(const Handle(PrsMgr_PresentationManager3d)& aPre
 
   aPrs->Clear();
   Handle(Graphic3d_Group) aGroup = Prs3d_Root::CurrentGroup( aPrs );
-  Handle(Graphic3d_AspectLine3d) anAspect = Attributes()->FaceBoundaryAspect()->Aspect();
-  aGroup->SetGroupPrimitivesAspect( anAspect );
+  Quantity_Color aColor;
+  Aspect_TypeOfLine aType;
+  Standard_Real anWidth;
+  Attributes()->LineAspect()->Aspect()->Values( aColor, aType, anWidth );
+  Handle(Graphic3d_AspectLine3d) anAspect = new Graphic3d_AspectLine3d( aColor, aType, anWidth );
 
   TopExp_Explorer Exp1 ( myshape, TopAbs_EDGE );
   for ( ; Exp1.More(); Exp1.Next() )
@@ -91,7 +95,10 @@ void HYDROGUI_Polyline::Compute(const Handle(PrsMgr_PresentationManager3d)& aPre
     TopoDS_Edge anEdge = TopoDS::Edge( Exp1.Current() );
     Handle( Graphic3d_ArrayOfPolylines ) anArray = BuildEdgePresentation( anEdge, 0.1 );
     if( !anArray.IsNull() )
-      aGroup->AddPrimitiveArray ( anArray );
+    {
+      aGroup->SetPrimitivesAspect( anAspect );
+      aGroup->AddPrimitiveArray( anArray );
+    }
   }
 
    
index ac0a39ade019ca88f4cd19139050e4739c110fe1..591ae2de9d67c8c0b89a05fe0c8155641ea111be 100644 (file)
 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
 //
 
-#include "HYDROGUI_PolylineExtractionOp.h"
-
-#include <GraphicsView_Viewer.h>
-
-#include "HYDROGUI_Module.h"
-#include "HYDROGUI_Operations.h"
-#include "HYDROGUI_Tool.h"
-#include "HYDROGUI_UpdateFlags.h"
-
-#include <HYDROData_Profile.h>
+#include <HYDROGUI_PolylineExtractionOp.h>
+#include <HYDROGUI_Module.h>
+#include <HYDROGUI_Tool.h>
+#include <HYDROGUI_UpdateFlags.h>
 #include <HYDROData_Document.h>
-#include <HYDROData_PolylineXY.h>
-#include <HYDROData_ShapesGroup.h>
-
-#include <LightApp_Application.h>
-#include <LightApp_Displayer.h>
-
-#include <OCCViewer_ViewModel.h>
-#include <OCCViewer_ViewManager.h>
-
-#include <BRep_Builder.hxx>
+#include <HYDROData_PolylineOperator.h>
 
 HYDROGUI_PolylineExtractionOp::HYDROGUI_PolylineExtractionOp( HYDROGUI_Module* theModule )
 : HYDROGUI_Operation( theModule )
@@ -59,124 +44,16 @@ void HYDROGUI_PolylineExtractionOp::startOperation()
     if ( aSeq.IsEmpty() )
         return;
 
+    startDocOperation();
+    HYDROData_PolylineOperator anOp;
     for ( Standard_Integer anIndex = 1, aLength = aSeq.Length(); anIndex <= aLength; anIndex++ )
     {
-        Handle(HYDROData_Entity) anObject = aSeq.Value( anIndex );
-        if ( anObject.IsNull() )
-            continue;
-
-        ShapeInfoList aList;
-
-        switch ( anObject->GetKind() )
-        {
-        case KIND_STREAM:
-            aList = extract( Handle(HYDROData_Stream)::DownCast( anObject ) );
-            break;
-        case KIND_DIGUE:
-        case KIND_CHANNEL:
-            aList = extract( Handle(HYDROData_Channel)::DownCast( anObject ) );
-            break;
-        case KIND_OBSTACLE:
-            aList = extract( Handle(HYDROData_Obstacle)::DownCast( anObject ) );
-            break;
-        }
-
-        startDocOperation();
-
-        for ( ShapeInfoList::const_iterator it = aList.begin(); it != aList.end(); ++it )
-        {
-            const ShapeInfo& inf = *it;
-            TopoDS_Shape aLine = inf.shape();
-            QString aName = QString( "%1_%2" ).arg( anObject->GetName() ).arg( inf.name() );
-            if ( !HYDROGUI_Tool::FindObjectByName( aModule, aName ).IsNull() )
-            {
-                int num = 1;
-                while ( !HYDROGUI_Tool::FindObjectByName( aModule, aName + QString( "_%1" ).arg( num ) ).IsNull() )
-                    num++;
-
-                aName += QString( "_%1" ).arg( num );
-            }
-
-            Handle(HYDROData_PolylineXY) aPolylineObj = Handle(HYDROData_PolylineXY)::DownCast( doc()->CreateObject( KIND_POLYLINEXY ) );
-            if ( !aPolylineObj.IsNull() )
-            {
-                aPolylineObj->SetName( aName );
-                aPolylineObj->ImportShape( aLine );
-                aPolylineObj->Update();
-            }
-        }
-
-        commitDocOperation();
+      Handle(HYDROData_Object) anObject = Handle(HYDROData_Object)::DownCast( aSeq.Value( anIndex ) );
+      if( !anObject.IsNull() )
+        anOp.Extract( doc(), anObject );      
     }
 
+    commitDocOperation();
     aModule->update( anUpdateFlags );
-
     commit();
 }
-
-HYDROGUI_PolylineExtractionOp::ShapeInfoList HYDROGUI_PolylineExtractionOp::extract( const Handle(HYDROData_Stream)& theStream ) const
-{
-    ShapeInfoList aList;
-    if ( !theStream.IsNull() )
-    {
-        aList.append( ShapeInfo( theStream->GetLeftShape(), QString( "Left bank" ) ) );
-        aList.append( ShapeInfo( theStream->GetRightShape(), QString( "Right bank" ) ) );
-
-        HYDROData_SequenceOfObjects aProfiles = theStream->GetProfiles();
-        for ( int i = 1; i <= aProfiles.Length(); i++ )
-        {
-            Handle(HYDROData_Profile) aProfile = Handle(HYDROData_Profile)::DownCast( aProfiles.Value( i ) );
-            aList.append( ShapeInfo( aProfile->GetTopShape(), QString( "Profile_%1" ).arg( i ) ) );
-        }
-    }
-    return aList;
-}
-
-HYDROGUI_PolylineExtractionOp::ShapeInfoList HYDROGUI_PolylineExtractionOp::extract( const Handle(HYDROData_Channel)& aChannel ) const
-{
-    ShapeInfoList aList;
-    if ( !aChannel.IsNull() )
-    {
-        HYDROData_SequenceOfObjects aGroups = aChannel->GetGroups();
-        int aNum = qMin( aGroups.Length(), 2 );
-        for ( int i = 1; i <= aNum; i++ )
-        {
-            Handle(HYDROData_ShapesGroup) aGroup = Handle(HYDROData_ShapesGroup)::DownCast( aGroups.Value( i ) );
-            TopTools_SequenceOfShape aShapes;
-            aGroup->GetShapes( aShapes );
-            if ( !aShapes.IsEmpty() )
-            {
-                TopoDS_Wire aWire;
-                BRep_Builder aBuilder;
-                aBuilder.MakeWire( aWire );
-
-                for ( int s = 1; s <= aShapes.Length(); s++ )
-                    aBuilder.Add( aWire, aShapes.Value( s ) );
-                aList.append( ShapeInfo( aWire, i > 1 ? "Right bank" : "Left bank" ) );
-            }
-        }
-    }
-    return aList;
-}
-
-HYDROGUI_PolylineExtractionOp::ShapeInfoList HYDROGUI_PolylineExtractionOp::extract( const Handle(HYDROData_Obstacle)& theObstacle ) const
-{
-    ShapeInfoList aList;
-    if ( !theObstacle.IsNull() )
-    {
-        TopoDS_Wire aWire;
-        BRep_Builder aBuilder;
-        aBuilder.MakeWire( aWire );
-        HYDROData_SequenceOfObjects aGroups = theObstacle->GetGroups();
-        for ( int i = 1; i <= aGroups.Length(); i++ )
-        {
-            Handle(HYDROData_ShapesGroup) aGroup = Handle(HYDROData_ShapesGroup)::DownCast( aGroups.Value( i ) );
-            TopTools_SequenceOfShape aShapes;
-            aGroup->GetShapes( aShapes );
-            for ( int s = 1; s <= aShapes.Length(); s++ )
-                aBuilder.Add( aWire, aShapes.Value( s ) );
-        }
-        aList.append( ShapeInfo( aWire, QString( "Contour" ) ) );
-    }
-    return aList;
-}
index 414799e5bcdfeda6d7c91399d5913d8692dbf00a..1258e1f1aa9609b3cf143b6ca947ff51fc0d121b 100644 (file)
@@ -37,27 +37,7 @@ public:
   virtual ~HYDROGUI_PolylineExtractionOp();
 
 protected:
-  virtual void               startOperation();
-
-private:
-  class ShapeInfo
-  {
-  public:
-      ShapeInfo( const TopoDS_Shape s, const QString& n ) : myShape( s ), myName( n ) {}
-      TopoDS_Shape shape() const { return myShape; }
-      QString      name() const { return myName; }
-
-  private:
-      TopoDS_Shape myShape;
-      QString      myName;
-  };
-
-  typedef QList<ShapeInfo> ShapeInfoList;
-
-private:
-  ShapeInfoList              extract( const Handle(HYDROData_Stream)& ) const;
-  ShapeInfoList              extract( const Handle(HYDROData_Channel)& ) const;
-  ShapeInfoList              extract( const Handle(HYDROData_Obstacle)& ) const;
+  virtual void startOperation();
 };
 
 #endif
index d91a58346f9a9aa5efe9b2e18da95f547db65a91..013a4a9e06a4c0dfc4b87bef82c36ae6a0ffa083 100644 (file)
@@ -92,6 +92,7 @@ SET(_sip_files2
   HYDROData_Document.sip
   HYDROData_Application.sip
   HYDROData_IProfilesInterpolator.sip
+  HYDROData_LandCoverMap.sip
 )
 
 # --- sources ---
index e0235298104c1c8a62653d7ec2941cc0dcc183a1..84f94621aea2babc40e26865dbe255c6c23ca5d7 100644 (file)
 %Include CAS/gp_XYZ.sip
 %Include CAS/NCollection_Sequence.sip
 %Include CAS/TCollection_AsciiString.sip
-%Include HYDROData_SequenceOfObjects.sip
-%Include HYDROData_IInterpolator.sip
-%Include HYDROData_Entity.sip
-%Include HYDROData_ShapesGroup.sip
-%Include HYDROData_SplittedShapesGroup.sip
-%Include HYDROData_IPolyline.sip
-%Include HYDROData_IAltitudeObject.sip
+
 %Include HYDROData_AltitudeObject.sip
-%Include HYDROData_ObstacleAltitude.sip
-%Include HYDROData_StreamAltitude.sip
-%Include HYDROData_Object.sip
-%Include HYDROData_Profile.sip
-%Include HYDROData_Polyline3D.sip
-%Include HYDROData_ProfileUZ.sip
-%Include HYDROData_PolylineXY.sip
+%Include HYDROData_Application.sip
 %Include HYDROData_ArtificialObject.sip
-%Include HYDROData_Obstacle.sip
+%Include HYDROData_Bathymetry.sip
+%Include HYDROData_CalculationCase.sip
 %Include HYDROData_Channel.sip
-%Include HYDROData_Digue.sip
-%Include HYDROData_NaturalObject.sip
 %Include HYDROData_Confluence.sip
-%Include HYDROData_River.sip
-%Include HYDROData_Stream.sip
+%Include HYDROData_Digue.sip
+%Include HYDROData_Document.sip
+%Include HYDROData_Entity.sip
+%Include HYDROData_IAltitudeObject.sip
+%Include HYDROData_IInterpolator.sip
 %Include HYDROData_Image.sip
-%Include HYDROData_PolylineXY.sip
-%Include HYDROData_Bathymetry.sip
 %Include HYDROData_ImmersibleZone.sip
-%Include HYDROData_Zone.sip
-%Include HYDROData_Region.sip
-%Include HYDROData_CalculationCase.sip
+%Include HYDROData_IPolyline.sip
 %Include HYDROData_IProfilesInterpolator.sip
+%Include HYDROData_LandCoverMap.sip
+%Include HYDROData_NaturalObject.sip
+%Include HYDROData_Object.sip
+%Include HYDROData_Obstacle.sip
+%Include HYDROData_ObstacleAltitude.sip
+%Include HYDROData_PolylineXY.sip
+%Include HYDROData_Polyline3D.sip
+%Include HYDROData_Profile.sip
+%Include HYDROData_ProfileUZ.sip
+%Include HYDROData_Region.sip
+%Include HYDROData_River.sip
+%Include HYDROData_SequenceOfObjects.sip
+%Include HYDROData_ShapesGroup.sip
+%Include HYDROData_SplittedShapesGroup.sip
+%Include HYDROData_Stream.sip
+%Include HYDROData_StreamAltitude.sip
 %Include HYDROData_StricklerTable.sip
-
-%Include HYDROData_Document.sip
-%Include HYDROData_Application.sip
-
+%Include HYDROData_Zone.sip
 
index da99346b7d6124e18c88aa3c03f473f62e5aaf90..3ad15bd33bfd2dbd0f287e1811934364a1f5245c 100644 (file)
@@ -28,15 +28,6 @@ class HYDROData_AltitudeObject : public HYDROData_IAltitudeObject
 %End
 
 protected:
-
-  /**
-   * Creates new object in the internal data structure. Use higher level objects 
-   * to create objects with real content.
-   */
   HYDROData_AltitudeObject();
-
-  /**
-   * Destructs properties of the object and object itself, removes it from the document.
-   */
    ~HYDROData_AltitudeObject();
 };
index d9499915f6a802d9e95c32fb428709ac035dcf12..c34c89768a85d5c88b32c8f3aa009ed621801049 100644 (file)
@@ -27,16 +27,9 @@ class HYDROData_Application
 #include <HYDROData_Application.h>
 %End
 
-public: // useful methods inside of the package
-
-  //! Retuns the application: one per process    
+public:
   static HYDROData_Application* GetApplication();   
 
-public: // Redefined OCAF methods
-  //! Return name of resource (i.e. "Standard")
   const char* ResourcesName();
-  //! Constructor
-  //! Use method GetInstance() method to obtain 
-  //! the static instance of the object (or derive your own application)
   HYDROData_Application();
-};
\ No newline at end of file
+};
index 87526ec3ae21acc244a5572bb6ae3178a79ada71..0720b6c32ca06d90bf4836a8bab71bee00bed1b6 100644 (file)
@@ -52,20 +52,7 @@ class HYDROData_ArtificialObject : public HYDROData_Object /Abstract/
     }
 %End
 
-public:
-
-
 protected:
-
-  /**
-   * Creates new object in the internal data structure. Use higher level objects 
-   * to create objects with real content.
-   */
   HYDROData_ArtificialObject();
-
-  /**
-   * Destructs properties of the object and object itself, removes it from the document.
-   */
   virtual ~HYDROData_ArtificialObject();
-  
 };
index d9e4e10828ea9bc39732ad14cfc929382d60f2b9..e23029181dddbc9b9476af8227dab068511e0733 100644 (file)
@@ -44,62 +44,19 @@ class HYDROData_Bathymetry : public HYDROData_IAltitudeObject
 %End
 
 public:      
-  // Public methods to work with Bathymetry altitudes.
-
-  /**
-   * Replace current altitude points by new one.
-   * \param thePoints the altitude points list
-   */
-  virtual void             SetAltitudePoints( const HYDROData_Bathymetry::AltitudePoints& );
-
-  /**
-   * Returns altitude points list.
-   * \return points list
-   */
+  virtual void SetAltitudePoints( const HYDROData_Bathymetry::AltitudePoints& );
   HYDROData_Bathymetry::AltitudePoints GetAltitudePoints() const;
 
-  /**
-   * Remove all altitude points.
-   */
-  void             RemoveAltitudePoints();
-
+  void RemoveAltitudePoints();
 
 public:
-  // Public methods to work with files.
-
-  /**
-   * Set flag indicating needs to invert altitude values
-   * \param theIsInverted new invert value
-   * \param theIsUpdate flag indicating necessity to update points
-   */
-  void             SetAltitudesInverted( const bool theIsInverted,
-                                         const bool theIsUpdate = true );
-
-  /**
-   * Returns flag indicating needs to invert altitude values.
-   */
-  bool             IsAltitudesInverted() const;
-
-  /**
-   * Imports Bathymetry data from file. The supported file types:
-   *  - xyz
-   * \param theFileName the path to file
-   * \return \c true if file has been successfully read
-   */
-  bool             ImportFromFile( const TCollection_AsciiString& theFileName );
+  void SetAltitudesInverted( const bool theIsInverted, const bool theIsUpdate = true );
+  bool IsAltitudesInverted() const;
 
+  bool ImportFromFile( const TCollection_AsciiString& theFileName );
 
 protected:
-
-  /**
-   * Creates new object in the internal data structure. Use higher level objects 
-   * to create objects with real content.
-   */
   HYDROData_Bathymetry();
-
-  /**
-   * Destructs properties of the object and object itself, removes it from the document.
-   */
   ~HYDROData_Bathymetry();
 };
 
index c1ebd5ce2309b61fae11cf41d8abc5c8c826f75d..9ed401988486480b14b05c1d982e02a555b70fb9 100644 (file)
@@ -108,7 +108,8 @@ public:
   /**
    * Removes reference geometry object from calculation case.
    */
-  void RemoveGeometryObject( HYDROData_Object theObject ) [void ( const Handle_HYDROData_Object& )];
+  void RemoveGeometryObject( HYDROData_Object theObject )
+  [void ( const Handle_HYDROData_Object& )];
   %MethodCode
     Handle(HYDROData_Object) aRef =
       Handle(HYDROData_Object)::DownCast( createHandle( a0 ) );
diff --git a/src/HYDROPy/HYDROData_LandCoverMap.sip b/src/HYDROPy/HYDROData_LandCoverMap.sip
new file mode 100644 (file)
index 0000000..734565e
--- /dev/null
@@ -0,0 +1,109 @@
+// Copyright (C) 2014-2015  EDF-R&D
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+%ExportedHeaderCode
+#include <HYDROData_LandCoverMap.h>
+%End
+
+class HYDROData_LandCoverMap : public HYDROData_Entity
+{
+%TypeHeaderCode
+#include <HYDROData_LandCoverMap.h>
+%End
+
+%ConvertToSubClassCode
+    switch ( sipCpp->GetKind() )
+    {
+      case KIND_LAND_COVER_MAP:
+        sipClass = sipClass_HYDROData_LandCoverMap;
+        break;
+
+      default:
+        // We don't recognise the type.
+        sipClass = NULL;
+    }
+%End
+
+public:
+  enum DBFStatus
+  {
+    DBFStatus_OK,
+    DBFStatus_DIFF_SIZE_ERROR,
+    DBFStatus_OPEN_FILE_ERROR,
+    DBFStatus_NO_SUCH_FIELD_ERROR,
+    DBFStatus_NO_DBFVALUES_CORRESPONDENCE_WARNING
+  };
+
+  HYDROData_LandCoverMap();
+  ~HYDROData_LandCoverMap();
+
+  DBFStatus ImportDBF( const QString& theDBFFileName, 
+    const QString& theFieldName, 
+    const QStringList& DBFValues,
+    const QStringList& StricklerTypes,
+    const QList<int>& theIndices );
+  void ExportDBF( const QString& theDBFFileName,
+    const QString& theFieldName, 
+    const QStringList& theDBFValues,
+    const QStringList& theStricklerTypes ) const;
+
+  bool ExportTelemac( const QString& theFileName, double theDeflection ) const;
+
+  bool Add( HYDROData_Object theObject, const QString& theType )
+  [bool ( const Handle_HYDROData_Object&, const QString& )];
+  %MethodCode
+    Handle(HYDROData_Object) aRef =
+      Handle(HYDROData_Object)::DownCast( createHandle( a0 ) );
+    if ( !aRef.IsNull() )
+    {
+      Py_BEGIN_ALLOW_THREADS
+      sipRes = sipSelfWasArg ? sipCpp->HYDROData_LandCoverMap::Add( aRef, *a1 ):
+                               sipCpp->Add( aRef, *a1 );
+      Py_END_ALLOW_THREADS
+    }
+  %End
+
+  bool Add( HYDROData_PolylineXY thePolyline, const QString& theType )
+  [bool ( const Handle_HYDROData_PolylineXY&, const QString& )];
+  %MethodCode
+    Handle(HYDROData_PolylineXY) aRef =
+      Handle(HYDROData_PolylineXY)::DownCast( createHandle( a0 ) );
+    if ( !aRef.IsNull() )
+    {
+      Py_BEGIN_ALLOW_THREADS
+      sipRes = sipSelfWasArg ? sipCpp->HYDROData_LandCoverMap::Add( aRef, *a1 ):
+                               sipCpp->Add( aRef, *a1 );
+      Py_END_ALLOW_THREADS
+    }
+  %End
+
+  bool Split( HYDROData_PolylineXY thePolyline )
+  [bool ( const Handle_HYDROData_PolylineXY& )];
+  %MethodCode
+    Handle(HYDROData_PolylineXY) aRef =
+      Handle(HYDROData_PolylineXY)::DownCast( createHandle( a0 ) );
+    if ( !aRef.IsNull() )
+    {
+      Py_BEGIN_ALLOW_THREADS
+      sipRes = sipSelfWasArg ? sipCpp->HYDROData_LandCoverMap::Split( aRef ):
+                               sipCpp->Split( aRef );
+      Py_END_ALLOW_THREADS
+    }
+  %End
+};
index 31e1dd2c711ba9d9431615a83a4f34edcbbf6437..070354cd7262a66a1f079c6fb0ba54f4da2cc0b3 100644 (file)
@@ -52,25 +52,12 @@ public:
 
 public:      
 
-  /**
-   * Sets the merging type for conflict altitudes.
-   * By default it is set to Merge_ZMIN.
-   */
   void SetMergeType( const MergeType& theType );
-
-  /**
-   * Returns the merging type for conflict altitudes.
-   */
   MergeType GetMergeType() const;
 
-
-  /**
-   * Sets the reference altitude to resolve the conflict.
-   * This object is used only in case of "Merge_Object" merge type.
-   */
-  void SetMergeAltitude( HYDROData_IAltitudeObject theAltitude ) [void (const Handle_HYDROData_IAltitudeObject&)];
+  void SetMergeAltitude( HYDROData_IAltitudeObject theAltitude )
+  [void (const Handle_HYDROData_IAltitudeObject&)];
   %MethodCode
-
     Handle(HYDROData_IAltitudeObject) aRefAltitude =
       Handle(HYDROData_IAltitudeObject)::DownCast( createHandle( a0 ) );
     if ( !aRefAltitude.IsNull() )
@@ -80,47 +67,29 @@ public:
                       sipCpp->SetMergeObject( aRefAltitude );
       Py_END_ALLOW_THREADS
     }
-
   %End
 
-  /**
-   * Returns the reference altitude to resolve the conflict.
-   */
   HYDROData_IAltitudeObject GetMergeAltitude() const [Handle_HYDROData_IAltitudeObject ()];
   %MethodCode
-
     Handle(HYDROData_IAltitudeObject) aRefAltitude;
-    
     Py_BEGIN_ALLOW_THREADS
     Handle(HYDROData_Entity) aRefObject = sipSelfWasArg ? sipCpp->HYDROData_Zone::GetMergeObject() : 
                                                           sipCpp->GetMergeObject();
        aRefAltitude = Handle(HYDROData_IAltitudeObject)::DownCast( aRefObject );
     Py_END_ALLOW_THREADS
-    
     sipRes = (HYDROData_IAltitudeObject*)createPointer( aRefAltitude );
-  
   %End
 
-  /**
-   * Removes the reference altitude for resolving the conflict.
-   */
   void RemoveMergeAltitude();
   %MethodCode
-
     Py_BEGIN_ALLOW_THREADS
       sipSelfWasArg ? sipCpp->HYDROData_Zone::RemoveMergeObject() : 
                       sipCpp->RemoveMergeObject();
     Py_END_ALLOW_THREADS
-
   %End
 
-  /**
-   * Sets the reference object to resolve the conflict.
-   * This object is used only in case of "Merge_Object" merge type.
-   */
   void SetMergeObject( HYDROData_Entity theObject ) [void (const Handle_HYDROData_Entity&)];
   %MethodCode
-
     Handle(HYDROData_Entity) aRefObject =
       Handle(HYDROData_Entity)::DownCast( createHandle( a0 ) );
     if ( !aRefObject.IsNull() )
@@ -130,34 +99,20 @@ public:
                       sipCpp->SetMergeObject( aRefObject );
       Py_END_ALLOW_THREADS
     }
-
   %End
 
-  /**
-   * Returns the reference object to resolve the conflict.
-   */
   HYDROData_Entity GetMergeObject() const [Handle_HYDROData_Entity ()];
   %MethodCode
-
     Handle(HYDROData_Entity) aRefObject;
-    
     Py_BEGIN_ALLOW_THREADS
     aRefObject = sipSelfWasArg ? sipCpp->HYDROData_Zone::GetMergeObject() : 
                                  sipCpp->GetMergeObject();
     Py_END_ALLOW_THREADS
-    
     sipRes = (HYDROData_Entity*)createPointer( aRefObject );
-  
   %End
 
-  /**
-   * Removes the reference object for resolving the conflict.
-   */
   void RemoveMergeObject();
 
-  /**
-   * Add new one object for zone.
-   */
   void AddObject( HYDROData_Entity theObject ) [void (const Handle_HYDROData_Entity&)];
   %MethodCode
 
@@ -173,42 +128,14 @@ public:
 
   %End
 
-  /**
-   * Returns all objects of zone.
-   */
   HYDROData_SequenceOfObjects GetObjects() const;
 
-  /**
-   * Removes all objects from zone.
-   */
   void RemoveObjects();
-
-
-  /**
-   * Sets the interpolator for zone. By default it is NULL and original
-   * interpolation algorithms are used to calculate points altitudes.
-   * If you set interpolator it won't be stored in the data model structure,
-   * it will be deleted during that time as this zone will be freed.
-   */
   void SetInterpolator( HYDROData_IInterpolator* theInter );
-
-  /**
-   * * Returns the interpolator of zone object.
-   */
   HYDROData_IInterpolator* GetInterpolator() const;
 
 protected:
 
-  /**
-   * Creates new object in the internal data structure. Use higher level objects 
-   * to create objects with real content.
-   */
   HYDROData_Zone();
-
-  /**
-   * Destructs properties of the object and object itself, removes it from the document.
-   */
   ~HYDROData_Zone();
 };
-
-
index feb497da4449bf6760a548018a49eb0f66fc84a8..167285a9af7792c73996734f3b7a67d797a8a323 100644 (file)
@@ -3,6 +3,7 @@ include(ExternalFiles.cmake)
 
 set(PROJECT_HEADERS
   test_HYDROData_Bathymetry.h
+  test_HYDROData_Channel.h
   test_HYDROData_Document.h
   test_HYDROData_Entity.h
   test_HYDROData_Image.h
@@ -16,6 +17,7 @@ set(PROJECT_HEADERS
   test_HYDROGUI_ListModel.h
   test_Dependencies.h
 
+  TestShape.h
   TestViewer.h
   TestLib_Listener.h
   TestLib_Runner.h
@@ -23,6 +25,7 @@ set(PROJECT_HEADERS
 
 set(PROJECT_SOURCES 
   test_HYDROData_Bathymetry.cxx
+  test_HYDROData_Channel.cxx
   test_HYDROData_Document.cxx
   test_HYDROData_Entity.cxx
   test_HYDROData_Image.cxx
@@ -37,6 +40,7 @@ set(PROJECT_SOURCES
   test_HYDROGUI_ListModel.cxx
   test_Dependencies.cxx
 
+  TestShape.cxx
   TestViewer.cxx
   TestLib_Listener.cxx
   TestLib_Runner.cxx
@@ -55,6 +59,7 @@ SET( CPPUNIT_INCLUDES $ENV{CPPUNIT_ROOT_DIR}/include )
 SET( CAS_INCLUDES $ENV{CAS_ROOT_DIR}/inc )
 SET( QT_INCLUDES $ENV{QT4_ROOT_DIR}/include $ENV{QT4_ROOT_DIR}/include/QtCore $ENV{QT4_ROOT_DIR}/include/QtGui $ENV{QT4_ROOT_DIR}/include/QtTest )
 SET( GUI_INCLUDES $ENV{GUI_ROOT_DIR}/include/salome )
+SET( GEOM_INCLUDES $ENV{GEOM_ROOT_DIR}/include/salome )
 
 IF( ${WIN32} )
   link_directories( $ENV{CAS_ROOT_DIR}/win32/libd )
@@ -77,15 +82,17 @@ ELSE()
   SET( CPPUNIT_LIBRARIES cppunit )
 ENDIF()
 
-link_directories( $ENV{GUI_ROOT_DIR}/lib/salome )
+link_directories( $ENV{GUI_ROOT_DIR}/lib/salome $ENV{GEOM_ROOT_DIR}/lib/salome )
 SET( GUI_LIBRARIES ImageComposer qtx suit LightApp CAM OCCViewer )
+SET( GEOM_LIBRARIES CurveCreator )
 
 include_directories(
   ${BOOST_INCLUDES}
-  ${CAS_INCLUDE_DIRS}
+  ${CAS_INCLUDES}
   ${QT_INCLUDES}
   ${CPPUNIT_INCLUDES}
   ${GUI_INCLUDES}
+  ${GEOM_INCLUDES}
   ${CMAKE_CURRENT_SOURCE_DIR}/../HYDROData
   ${CMAKE_CURRENT_SOURCE_DIR}/../HYDROGUI
   ${CMAKE_CURRENT_SOURCE_DIR}/../shapelib
@@ -94,7 +101,7 @@ include_directories(
 source_group( "External files" FILES ${EXTERNAL_FILES} )
 
 add_executable( HYDROData_tests ${PROJECT_SOURCES} ${PROJECT_HEADERS} ${EXTERNAL_FILES} )
-target_link_libraries( HYDROData_tests ${GUI_LIBRARIES} ${CAS_LIBRARIES} ${QT_LIBRARIES} ${CPPUNIT_LIBRARIES} shapelib )
+target_link_libraries( HYDROData_tests ${GUI_LIBRARIES} ${GEOM_LIBRARIES} ${CAS_LIBRARIES} ${QT_LIBRARIES} ${CPPUNIT_LIBRARIES} shapelib )
 
 IF( ${WIN32} )
   add_custom_command( TARGET HYDROData_tests POST_BUILD COMMAND $(TargetPath) COMMENT "Running tests" )
index 663cd087710813dcf6c8417bff76ea16a1aae3c9..7ccb5c2661fec8db99807a35ca53e797de636b3e 100644 (file)
@@ -56,4 +56,5 @@ set( EXTERNAL_FILES
   ../HYDROGUI/HYDROGUI_ListModel.cxx
   ../HYDROGUI/HYDROGUI_DataObject.cxx
   ../HYDROGUI/HYDROGUI_LandCoverMapPrs.cxx
+  ../HYDROGUI/HYDROGUI_Polyline.cxx
 )
diff --git a/src/HYDRO_tests/TestShape.cxx b/src/HYDRO_tests/TestShape.cxx
new file mode 100644 (file)
index 0000000..1054ead
--- /dev/null
@@ -0,0 +1,51 @@
+
+#include <TestShape.h>
+#include <BRepBuilderAPI_MakeEdge.hxx>
+#include <BRepBuilderAPI_MakeFace.hxx>
+#include <BRepBuilderAPI_MakeWire.hxx>
+#include <TopoDS_Edge.hxx>
+#include <TopoDS_Wire.hxx>
+#include <TopoDS_Face.hxx>
+#include <TColgp_HArray1OfPnt.hxx>
+#include <GeomAPI_Interpolate.hxx>
+#include <gp_Circ.hxx>
+
+TopoDS_Edge Edge( const QList<double>& theXYList, bool isClosed )
+{
+  int n = theXYList.size()/2;
+  Handle(TColgp_HArray1OfPnt) aPointsArray = new TColgp_HArray1OfPnt( 1, n );
+  for( int i=1; i<=n; i++ )
+  {
+    double x = theXYList[2*i-2];
+    double y = theXYList[2*i-1];
+    gp_Pnt aPnt( x, y, 0 );
+    aPointsArray->SetValue( i, aPnt );
+  }
+  GeomAPI_Interpolate anInterpolator( aPointsArray, isClosed, 1E-3 );
+  anInterpolator.Perform();
+  bool aResult = anInterpolator.IsDone() == Standard_True;
+  if( aResult )
+  {
+    Handle( Geom_BSplineCurve ) aCurve = anInterpolator.Curve();
+    return BRepBuilderAPI_MakeEdge( aCurve ).Edge();
+  }
+  else
+    return TopoDS_Edge();
+}
+
+TopoDS_Wire Wire( const QList<double>& theXYList, bool isClosed )
+{
+  return BRepBuilderAPI_MakeWire( Edge( theXYList, isClosed ) ).Wire();
+}
+
+TopoDS_Face Face( const QList<double>& theXYList )
+{
+  return BRepBuilderAPI_MakeFace( Wire( theXYList, true ), Standard_True ).Face();
+}
+
+TopoDS_Wire WireCirc( const gp_Pnt& theCenter, double theRadius )
+{
+  gp_Circ aCircle( gp_Ax2( theCenter, gp_Dir( 0, 0, 1 ) ), theRadius );
+  TopoDS_Edge anEdge = BRepBuilderAPI_MakeEdge( aCircle ).Edge();
+  return BRepBuilderAPI_MakeWire( anEdge ).Wire();
+}
diff --git a/src/HYDRO_tests/TestShape.h b/src/HYDRO_tests/TestShape.h
new file mode 100644 (file)
index 0000000..17acf61
--- /dev/null
@@ -0,0 +1,15 @@
+
+#pragma once
+
+#include <QList>
+
+class TopoDS_Edge;
+class TopoDS_Wire;
+class TopoDS_Face;
+class gp_Pnt;
+
+TopoDS_Edge Edge( const QList<double>& theXYList, bool isClosed = false );
+TopoDS_Wire Wire( const QList<double>& theXYList, bool isClosed = false );
+TopoDS_Wire WireCirc( const gp_Pnt& theCenter, double theRadius );
+TopoDS_Face Face( const QList<double>& theXYList );
+
index f54fdfc064a7b80137e9c1de65fa5c1f91a484cf..8315d811ff5d02c3cfccbe535c3a6d775c89b465 100644 (file)
@@ -20,6 +20,7 @@
 #include <AIS_InteractiveContext.hxx>
 #include <AIS_Shape.hxx>
 #include <Aspect_ColorScale.hxx>
+#include <Prs3d_PointAspect.hxx>
 #include <TopoDS_Iterator.hxx>
 #include <QDir>
 #include <QPainter>
@@ -88,17 +89,21 @@ QColor TestViewer::GetColor(int i)
 void TestViewer::show( const Handle(AIS_InteractiveObject)& theObject,
                        int theMode, int theSelectionMode, bool isFitAll, const char* theKey )
 {
-  context()->CloseLocalContext();
-  context()->EraseAll( Standard_False );
+  QString aNewKey = theKey;
+  if( !aNewKey.isEmpty() )
+  {
+    myKey = aNewKey;
+    context()->CloseLocalContext();
+    context()->EraseAll( Standard_False );
+  }
+  
+  context()->Display( theObject, theMode, theSelectionMode );
   if( theSelectionMode > 0 )
   {
-    context()->Display( theObject, theMode, theSelectionMode );
     context()->OpenLocalContext();
     context()->Activate( theObject, theSelectionMode, Standard_True );
   }
 
-  myKey = theKey;
-
   if( isFitAll )
   {
     viewWindow()->onTopView();
@@ -109,6 +114,8 @@ void TestViewer::show( const Handle(AIS_InteractiveObject)& theObject,
 void TestViewer::show( const TopoDS_Shape& theShape, int theMode, bool isFitAll, const QColor& theColor )
 {
   Handle(AIS_Shape) aShape = new AIS_Shape( theShape );
+  if( theShape.ShapeType()==TopAbs_VERTEX )
+    aShape->Attributes()->PointAspect()->SetTypeOfMarker( Aspect_TOM_X );
   aShape->SetMaterial( Graphic3d_NOM_PLASTIC );
   aShape->SetColor( HYDROData_Tool::toOccColor( theColor ) );
   context()->Display( aShape, theMode, 0, Standard_False );
@@ -122,9 +129,14 @@ void TestViewer::show( const TopoDS_Shape& theShape, int theMode, bool isFitAll,
 
 void TestViewer::show( const TopoDS_Shape& theShape, int theMode, bool isFitAll, const char* theKey )
 {
+  context()->CloseLocalContext();
   context()->EraseAll( Standard_False );
   
   myKey = theKey;
+
+  if( theShape.IsNull() )
+    return;
+
   int i = 0;
   if( theShape.ShapeType()==TopAbs_SHELL )
   {
@@ -235,3 +247,10 @@ Handle_Aspect_ColorScale TestViewer::showColorScale( bool isShow )
   }
   return aColorScale;
 }
+
+void TestViewer::select( int theViewX, int theViewY )
+{
+  Handle(V3d_View) aView = myViewWindow->getViewPort()->getView();
+  context()->MoveTo( theViewX, theViewY, aView );
+  context()->Select();
+}
index 61f0d6bb6d9e67cec2ba5996d95a1c14e556c86e..d5bd15d6aed14ff9f39c237f3f1792843dc4dcba 100644 (file)
@@ -26,6 +26,8 @@ public:
 
   static Handle_Aspect_ColorScale showColorScale( bool );
 
+  static void select( int theViewX, int theViewY );
+
 private:
   static OCCViewer_ViewManager* myViewManager;
   static OCCViewer_ViewWindow* myViewWindow;
diff --git a/src/HYDRO_tests/reference_data/Channel.png b/src/HYDRO_tests/reference_data/Channel.png
new file mode 100644 (file)
index 0000000..f30b494
Binary files /dev/null and b/src/HYDRO_tests/reference_data/Channel.png differ
diff --git a/src/HYDRO_tests/reference_data/Extraction_Channel.png b/src/HYDRO_tests/reference_data/Extraction_Channel.png
new file mode 100644 (file)
index 0000000..f30b494
Binary files /dev/null and b/src/HYDRO_tests/reference_data/Extraction_Channel.png differ
diff --git a/src/HYDRO_tests/reference_data/Extraction_ImmZone.png b/src/HYDRO_tests/reference_data/Extraction_ImmZone.png
new file mode 100644 (file)
index 0000000..9e91978
Binary files /dev/null and b/src/HYDRO_tests/reference_data/Extraction_ImmZone.png differ
index 218a62161542c2f0854a3e7ecda63b327631dd41..2d7da92e5365cde7aafbb44f4fa9e677976fdc55 100644 (file)
Binary files a/src/HYDRO_tests/reference_data/LandCoverMap_PrsByTypes.png and b/src/HYDRO_tests/reference_data/LandCoverMap_PrsByTypes.png differ
diff --git a/src/HYDRO_tests/reference_data/LandCoverMap_Split_Polyline.png b/src/HYDRO_tests/reference_data/LandCoverMap_Split_Polyline.png
new file mode 100644 (file)
index 0000000..98c5e92
Binary files /dev/null and b/src/HYDRO_tests/reference_data/LandCoverMap_Split_Polyline.png differ
diff --git a/src/HYDRO_tests/reference_data/LandCoverMap_TransparentPrs.png b/src/HYDRO_tests/reference_data/LandCoverMap_TransparentPrs.png
new file mode 100644 (file)
index 0000000..f0723e1
Binary files /dev/null and b/src/HYDRO_tests/reference_data/LandCoverMap_TransparentPrs.png differ
diff --git a/src/HYDRO_tests/reference_data/Polyline_Presentation.png b/src/HYDRO_tests/reference_data/Polyline_Presentation.png
new file mode 100644 (file)
index 0000000..acbf866
Binary files /dev/null and b/src/HYDRO_tests/reference_data/Polyline_Presentation.png differ
diff --git a/src/HYDRO_tests/reference_data/Split_Polylines_Colors.png b/src/HYDRO_tests/reference_data/Split_Polylines_Colors.png
new file mode 100644 (file)
index 0000000..2ec01c5
Binary files /dev/null and b/src/HYDRO_tests/reference_data/Split_Polylines_Colors.png differ
diff --git a/src/HYDRO_tests/test_HYDROData_Channel.cxx b/src/HYDRO_tests/test_HYDROData_Channel.cxx
new file mode 100644 (file)
index 0000000..82ca433
--- /dev/null
@@ -0,0 +1,84 @@
+// Copyright (C) 2014-2015  EDF-R&D
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+#include <test_HYDROData_Channel.h>
+#include <HYDROData_Document.h>
+#include <HYDROData_Channel.h>
+#include <HYDROData_PolylineXY.h>
+#include <HYDROData_Polyline3D.h>
+#include <HYDROData_Profile.h>
+
+#include <TestShape.h>
+#include <TestViewer.h>
+
+#include <AIS_DisplayMode.hxx>
+#include <TopoDS_Edge.hxx>
+#include <TopoDS_Wire.hxx>
+#include <QColor>
+#include <QString>
+
+TopoDS_Edge Spline( const QList<double>& theXYList, bool isClosed = false );
+
+void test_HYDROData_Channel::test_2d_prs()
+{
+  Handle(HYDROData_Document) aDoc = HYDROData_Document::Document(1);
+
+  Handle(HYDROData_PolylineXY) aPolyline2d = 
+    Handle(HYDROData_PolylineXY)::DownCast( aDoc->CreateObject( KIND_POLYLINEXY ) );
+  aPolyline2d->SetName( "polyline2d_1" );
+  aPolyline2d->AddSection( "", HYDROData_IPolyline::SECTION_SPLINE, false );
+
+  Handle(HYDROData_Polyline3D) aPolyline3d = 
+    Handle(HYDROData_Polyline3D)::DownCast( aDoc->CreateObject( KIND_POLYLINE ) );
+  aPolyline3d->SetName( "polyline3d_1" );
+  aPolyline3d->SetPolylineXY( aPolyline2d );
+
+  QList<double> aCoords = QList<double>() << 10 << 10 << 20 << 10 << 20 << 20 << 10 << 20;
+  TopoDS_Wire aWire = Wire( aCoords, false );
+  aPolyline2d->SetShape( aWire );
+  aPolyline3d->SetTopShape( aWire );
+  aPolyline3d->SetShape3D( aWire );
+
+  Handle(HYDROData_Profile) aProfile = 
+    Handle(HYDROData_Profile)::DownCast( aDoc->CreateObject( KIND_PROFILE ) );
+  aProfile->SetName( "profile_1" );
+
+  QList<double> aCoordsPr = QList<double>() << 0.0 << 0.1 << 0.5 << 0.0 << 1.0 << 0.1;
+  TopoDS_Wire aWirePr = Wire( aCoordsPr, false );
+  aProfile->SetTopShape( aWirePr );
+  aProfile->SetShape3D( aWirePr );
+
+
+  Handle(HYDROData_Channel) aChannel = 
+    Handle(HYDROData_Channel)::DownCast( aDoc->CreateObject( KIND_CHANNEL ) );
+  aChannel->SetName( "channel_1" );
+  
+  aChannel->SetGuideLine( aPolyline3d );
+  aChannel->SetProfile( aProfile );
+  aChannel->Update();
+  CPPUNIT_ASSERT_EQUAL( false, (bool)aChannel->GetTopShape().IsNull() );
+  CPPUNIT_ASSERT_EQUAL( false, (bool)aChannel->GetShape3D().IsNull() );
+
+  TestViewer::show( aChannel->GetTopShape(), AIS_Shaded, true, "Channel" );
+  TestViewer::show( aChannel->GetLeftShape(), AIS_WireFrame, true, Qt::red );
+  TestViewer::show( aChannel->GetRightShape(), AIS_WireFrame, true, Qt::red );
+  //TestViewer::show( aWire, AIS_Shaded, true, "Channel" );
+  CPPUNIT_ASSERT_IMAGES
+
+  aDoc->Close();
+}
diff --git a/src/HYDRO_tests/test_HYDROData_Channel.h b/src/HYDRO_tests/test_HYDROData_Channel.h
new file mode 100644 (file)
index 0000000..c4e22a8
--- /dev/null
@@ -0,0 +1,33 @@
+// Copyright (C) 2014-2015  EDF-R&D
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+#include <cppunit/extensions/HelperMacros.h>
+
+class test_HYDROData_Channel : public CppUnit::TestFixture {
+  CPPUNIT_TEST_SUITE( test_HYDROData_Channel );
+  CPPUNIT_TEST( test_2d_prs );
+  CPPUNIT_TEST_SUITE_END();
+
+private:
+
+public:
+  void test_2d_prs();
+};
+
+CPPUNIT_TEST_SUITE_REGISTRATION( test_HYDROData_Channel );
+CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( test_HYDROData_Channel, "HYDROData_Channel");
index 5726f2966296b27398fbc66e3e1a6dd0601e3a47..1ae4bd40d0eb23d0ee5dcc620fec4370bbda463a 100644 (file)
@@ -19,6 +19,7 @@
 #include <test_HYDROData_LandCoverMap.h>
 #include <HYDROData_Document.h>
 #include <HYDROData_LandCoverMap.h>
+#include <HYDROData_ImmersibleZone.h>
 #include <HYDROData_PolylineXY.h>
 #include <HYDROData_StricklerTable.h>
 #include <HYDROData_Tool.h>
 #include <TopoDS_Edge.hxx>
 #include <TopoDS_Wire.hxx>
 #include <TopoDS_Face.hxx>
-#include <TColgp_HArray1OfPnt.hxx>
-#include <GeomAPI_Interpolate.hxx>
-#include <BRepBuilderAPI_MakeEdge.hxx>
-#include <BRepBuilderAPI_MakeFace.hxx>
-#include <BRepBuilderAPI_MakeWire.hxx>
 #include <TestViewer.h>
+#include <TestShape.h>
 #include <TopTools_ListOfShape.hxx>
 #include <AIS_DisplayMode.hxx>
 #include <Aspect_ColorScale.hxx>
 #include <QString>
 #include <QColor>
 #include <QMap>
+#include <QDir>
 #include <BRepTools.hxx>
 #include <BRep_Builder.hxx>
 
 const QString REF_DATA_PATH = qgetenv( "HYDRO_REFERENCE_DATA" );
-const QString DEF_STR_PATH = qgetenv( "HYDRO_ROOT_DIR" ) + "/share/salome/resources/hydro/def_strickler_table.txt";
-
-TopoDS_Edge Spline( const QList<double>& theXYList, bool isClosed = false )
-{
-  int n = theXYList.size()/2;
-  Handle(TColgp_HArray1OfPnt) aPointsArray = new TColgp_HArray1OfPnt( 1, n );
-  for( int i=1; i<=n; i++ )
-  {
-    double x = theXYList[2*i-2];
-    double y = theXYList[2*i-1];
-    gp_Pnt aPnt( x, y, 0 );
-    aPointsArray->SetValue( i, aPnt );
-  }
-  GeomAPI_Interpolate anInterpolator( aPointsArray, isClosed, 1E-3 );
-  anInterpolator.Perform();
-  bool aResult = anInterpolator.IsDone() == Standard_True;
-  if( aResult )
-  {
-    Handle( Geom_BSplineCurve ) aCurve = anInterpolator.Curve();
-    return BRepBuilderAPI_MakeEdge( aCurve ).Edge();
-  }
-  else
-    return TopoDS_Edge();
-}
-
-TopoDS_Face LandCover( const QList<double>& theXYList )
-{
-  TopoDS_Edge anEdge = Spline( theXYList, true );
-  if( anEdge.IsNull() )
-    return TopoDS_Face();
-
-  TopoDS_Wire aWire = BRepBuilderAPI_MakeWire( anEdge ).Wire();
-  TopoDS_Face aFace = BRepBuilderAPI_MakeFace( aWire, Standard_True ).Face();
-  return aFace;
-}
+const QString DEF_STR_PATH = qgetenv( "HYDRO_SRC_DIR" ) + "/src/HYDROGUI/resources/def_strickler_table.txt";
 
 void test_HYDROData_LandCoverMap::test_add_2_objects()
 {
@@ -87,10 +51,10 @@ void test_HYDROData_LandCoverMap::test_add_2_objects()
 
   CPPUNIT_ASSERT_EQUAL( KIND_LAND_COVER_MAP, aMap->GetKind() );
 
-  TopoDS_Face aLC1 = LandCover( QList<double>() << 10 << 10 << 50 << 20 << 30 << 50 << 15 << 30 );
+  TopoDS_Face aLC1 = Face( QList<double>() << 10 << 10 << 50 << 20 << 30 << 50 << 15 << 30 );
   CPPUNIT_ASSERT_EQUAL( true, aMap->LocalPartition( aLC1, "test1" ) );
 
-  TopoDS_Face aLC2 = LandCover( QList<double>() << 30 << 20 << 60 << 10 << 70 << 35 << 40 << 40 );
+  TopoDS_Face aLC2 = Face( QList<double>() << 30 << 20 << 60 << 10 << 70 << 35 << 40 << 40 );
   CPPUNIT_ASSERT_EQUAL( true, aMap->LocalPartition( aLC2, "test2" ) );
 
   TestViewer::show( aMap->GetShape(), AIS_Shaded, true, "LandCoverMap_Add_2_Objects" );
@@ -117,12 +81,12 @@ void test_HYDROData_LandCoverMap::test_split()
 
   CPPUNIT_ASSERT_EQUAL( KIND_LAND_COVER_MAP, aMap->GetKind() );
 
-  TopoDS_Face aLC = LandCover( QList<double>() << 10 << 10 << 50 << 20 << 30 << 50 << 15 << 30 );
+  TopoDS_Face aLC = Face( QList<double>() << 10 << 10 << 50 << 20 << 30 << 50 << 15 << 30 );
   CPPUNIT_ASSERT_EQUAL( true, aMap->LocalPartition( aLC, "test1" ) );
 
   Handle(HYDROData_PolylineXY) aPolyline =
     Handle(HYDROData_PolylineXY)::DownCast( aDoc->CreateObject( KIND_POLYLINEXY ) );
-  TopoDS_Wire aWire = BRepBuilderAPI_MakeWire( Spline( QList<double>() << 10 << 40 << 30 << 10 << 40 << 10 << 60 << 10 ) ).Wire();
+  TopoDS_Wire aWire = Wire( QList<double>() << 10 << 40 << 30 << 10 << 40 << 10 << 60 << 10, false );
   aPolyline->SetShape( aWire );
 
   CPPUNIT_ASSERT_EQUAL( true, aMap->Split( aPolyline ) );
@@ -152,12 +116,12 @@ void test_HYDROData_LandCoverMap::test_incomplete_split()
 
   CPPUNIT_ASSERT_EQUAL( KIND_LAND_COVER_MAP, aMap->GetKind() );
 
-  TopoDS_Face aLC = LandCover( QList<double>() << 10 << 10 << 50 << 20 << 30 << 50 << 15 << 30 );
+  TopoDS_Face aLC = Face( QList<double>() << 10 << 10 << 50 << 20 << 30 << 50 << 15 << 30 );
   CPPUNIT_ASSERT_EQUAL( true, aMap->LocalPartition( aLC, "test1" ) );
 
   Handle(HYDROData_PolylineXY) aPolyline =
     Handle(HYDROData_PolylineXY)::DownCast( aDoc->CreateObject( KIND_POLYLINEXY ) );
-  TopoDS_Wire aWire = BRepBuilderAPI_MakeWire( Spline( QList<double>() << 10 << 40 << 30 << 10 << 40 << 10 ) ).Wire();
+  TopoDS_Wire aWire = Wire( QList<double>() << 10 << 40 << 30 << 10 << 40 << 10, false );
   aPolyline->SetShape( aWire );
 
   CPPUNIT_ASSERT_EQUAL( true, aMap->Split( aPolyline ) );
@@ -184,18 +148,18 @@ void test_HYDROData_LandCoverMap::test_merge()
 
   CPPUNIT_ASSERT_EQUAL( KIND_LAND_COVER_MAP, aMap->GetKind() );
 
-  TopoDS_Face aLC1 = LandCover( QList<double>() << 12 << 19 << 82 << 9 << 126 << 53 << 107 << 80 << 29 << 75 );
+  TopoDS_Face aLC1 = Face( QList<double>() << 12 << 19 << 82 << 9 << 126 << 53 << 107 << 80 << 29 << 75 );
 
   CPPUNIT_ASSERT_EQUAL( true, aMap->LocalPartition( aLC1, "test1" ) );
 
-  TopoDS_Face aLC2 = LandCover( QList<double>() << 21 << 34 << 24 << 25 << 37   << 37 << 40  << 61 <<
-                                                   44 << 95 << 85 << 100 << 104 << 66 << 107 << 33 <<
-                                                  128 << 18 << 140 << 50 << 131 << 89 << 104 << 111 <<
-                                                  31 << 114 );
+  TopoDS_Face aLC2 = Face( QList<double>() << 21 << 34 << 24 << 25 << 37   << 37 << 40  << 61 <<
+                                              44 << 95 << 85 << 100 << 104 << 66 << 107 << 33 <<
+                                             128 << 18 << 140 << 50 << 131 << 89 << 104 << 111 <<
+                                              31 << 114 );
   CPPUNIT_ASSERT_EQUAL( true, aMap->LocalPartition( aLC2, "test2" ) );
 
-  TopoDS_Face aLC3 = LandCover( QList<double>() << 4 << 54 << 1   << 47 << 51  << 45 <<
-                                                 127 << 42 << 145 << 43 << 148 << 60 << 90 << 65 );
+  TopoDS_Face aLC3 = Face( QList<double>() << 4 << 54 << 1   << 47 << 51  << 45 <<
+                                            127 << 42 << 145 << 43 << 148 << 60 << 90 << 65 );
   CPPUNIT_ASSERT_EQUAL( true, aMap->LocalPartition( aLC3, "test3" ) );
 
   //TestViewer::show( aMap->GetShape(), AIS_Shaded, true );
@@ -229,18 +193,18 @@ void test_HYDROData_LandCoverMap::test_remove()
 
   CPPUNIT_ASSERT_EQUAL( KIND_LAND_COVER_MAP, aMap->GetKind() );
 
-  TopoDS_Face aLC1 = LandCover( QList<double>() << 12 << 19 << 82 << 9 << 126 << 53 << 107 << 80 << 29 << 75 );
+  TopoDS_Face aLC1 = Face( QList<double>() << 12 << 19 << 82 << 9 << 126 << 53 << 107 << 80 << 29 << 75 );
 
   CPPUNIT_ASSERT_EQUAL( true, aMap->LocalPartition( aLC1, "test1" ) );
 
-  TopoDS_Face aLC2 = LandCover( QList<double>() << 21 << 34 << 24 << 25 << 37   << 37 << 40  << 61 <<
-                                                   44 << 95 << 85 << 100 << 104 << 66 << 107 << 33 <<
-                                                  128 << 18 << 140 << 50 << 131 << 89 << 104 << 111 <<
-                                                  31 << 114 );
+  TopoDS_Face aLC2 = Face( QList<double>() << 21 << 34 << 24 << 25 << 37   << 37 << 40  << 61 <<
+                                              44 << 95 << 85 << 100 << 104 << 66 << 107 << 33 <<
+                                             128 << 18 << 140 << 50 << 131 << 89 << 104 << 111 <<
+                                              31 << 114 );
   CPPUNIT_ASSERT_EQUAL( true, aMap->LocalPartition( aLC2, "test2" ) );
 
-  TopoDS_Face aLC3 = LandCover( QList<double>() << 4 << 54 << 1   << 47 << 51  << 45 <<
-                                                 127 << 42 << 145 << 43 << 148 << 60 << 90 << 65 );
+  TopoDS_Face aLC3 = Face( QList<double>() << 4 << 54 << 1   << 47 << 51  << 45 <<
+                                            127 << 42 << 145 << 43 << 148 << 60 << 90 << 65 );
   CPPUNIT_ASSERT_EQUAL( true, aMap->LocalPartition( aLC3, "test3" ) );
 
   QString aType1, aType2;
@@ -471,25 +435,21 @@ void test_HYDROData_LandCoverMap::test_import_dbf()
   // aST.size() == aDBFV.size()!!
   Handle(HYDROData_PolylineXY) aPolyline =
     Handle(HYDROData_PolylineXY)::DownCast( aDoc->CreateObject( KIND_POLYLINEXY ) );
-  TopoDS_Wire aWire = BRepBuilderAPI_MakeWire( Spline( QList<double>() << 10 << 40 << 30 << 10 << 40 << 10 << 60 << 10 ) ).Wire();
+  TopoDS_Wire aWire = Wire( QList<double>() << 10 << 40 << 30 << 10 << 40 << 10 << 60 << 10 );
   aPolyline->SetShape( aWire );
   for (int i = 0; i < 3; i++)
     aMap->Add(aPolyline, "");
-  TopoDS_Face aLC1 = LandCover( QList<double>() << 10 << 10 << 50 << 20 << 30 << 50 << 15 << 30 );
+  TopoDS_Face aLC1 = Face( QList<double>() << 10 << 10 << 50 << 20 << 30 << 50 << 15 << 30 );
   CPPUNIT_ASSERT_EQUAL( true, aMap->LocalPartition( aLC1, "test1" ) );
   
   CPPUNIT_ASSERT_EQUAL( true, aMap->Split( aPolyline ) );
-  QMap<int, int> Inds;
-  Inds.insert(1, 1);
-  Inds.insert(2, 2);
-  Inds.insert(3, 3);
+  QList<int> Inds = QList<int>() << 1 << 2 << 3;
   aMap->ImportDBF(aFileName, "TESTFIELD1", aDBFV, aST, Inds);
   HYDROData_LandCoverMap::Iterator anIt( aMap );
  
-  CPPUNIT_ASSERT_EQUAL(true, "water" == anIt.StricklerType());
+  CPPUNIT_ASSERT_EQUAL( QString( "forest" ), anIt.StricklerType() );
   anIt.Next();
-  CPPUNIT_ASSERT_EQUAL(true, "forest" == anIt.StricklerType());
-
+  CPPUNIT_ASSERT_EQUAL( QString( "road" ), anIt.StricklerType() );
 }
 
 void test_HYDROData_LandCoverMap::test_land_cover_prs_by_types()
@@ -503,22 +463,26 @@ void test_HYDROData_LandCoverMap::test_land_cover_prs_by_types()
   Handle(HYDROData_LandCoverMap) aMap =
     Handle(HYDROData_LandCoverMap)::DownCast( aDoc->CreateObject( KIND_LAND_COVER_MAP ) );
 
-  TopoDS_Face aLC1 = LandCover( QList<double>() << 12 << 19 << 82 << 9 << 126 << 53 << 107 << 80 << 29 << 75 );
+  TopoDS_Face aLC1 = Face( QList<double>() << 12 << 19 << 82 << 9 << 126 << 53 << 107 << 80 << 29 << 75 );
   CPPUNIT_ASSERT_EQUAL( true, aMap->LocalPartition( aLC1, "Zones de champs cultivé à végétation basse" ) );
 
-  TopoDS_Face aLC2 = LandCover( QList<double>() << 21 << 34 << 24 << 25 << 37   << 37 << 40  << 61 <<
-                                                   44 << 95 << 85 << 100 << 104 << 66 << 107 << 33 <<
-                                                  128 << 18 << 140 << 50 << 131 << 89 << 104 << 111 <<
-                                                  31 << 114 );
+  TopoDS_Face aLC2 = Face( QList<double>() << 21 << 34 << 24 << 25 << 37   << 37 << 40  << 61 <<
+                                              44 << 95 << 85 << 100 << 104 << 66 << 107 << 33 <<
+                                             128 << 18 << 140 << 50 << 131 << 89 << 104 << 111 <<
+                                              31 << 114 );
   CPPUNIT_ASSERT_EQUAL( true, aMap->LocalPartition( aLC2, "Zones de champs cultivé à végétation haute" ) );
 
-  TopoDS_Face aLC3 = LandCover( QList<double>() << 4 << 54 << 1   << 47 << 51  << 45 <<
-                                                 127 << 42 << 145 << 43 << 148 << 60 << 90 << 65 );
+  TopoDS_Face aLC3 = Face( QList<double>() << 4 << 54 << 1   << 47 << 51  << 45 <<
+                                            127 << 42 << 145 << 43 << 148 << 60 << 90 << 65 );
   CPPUNIT_ASSERT_EQUAL( true, aMap->LocalPartition( aLC3, "Zones de champs, prairies, sans cultures" ) );
 
+  // build presentation object 
   Handle(HYDROGUI_LandCoverMapPrs) aPrs = new HYDROGUI_LandCoverMapPrs( aMap );
   aPrs->SetTable( aTable );
+  // show presentation in viewer
   TestViewer::show( aPrs, AIS_Shaded, 4, true, "LandCoverMap_PrsByTypes" );
+  // select one of faces (first)
+  TestViewer::select( 200, 300 );
   CPPUNIT_ASSERT_IMAGES
 
   aDoc->Close();
@@ -535,17 +499,17 @@ void test_HYDROData_LandCoverMap::test_land_cover_prs_by_coeff()
   Handle(HYDROData_LandCoverMap) aMap =
     Handle(HYDROData_LandCoverMap)::DownCast( aDoc->CreateObject( KIND_LAND_COVER_MAP ) );
 
-  TopoDS_Face aLC1 = LandCover( QList<double>() << 12 << 19 << 82 << 9 << 126 << 53 << 107 << 80 << 29 << 75 );
+  TopoDS_Face aLC1 = Face( QList<double>() << 12 << 19 << 82 << 9 << 126 << 53 << 107 << 80 << 29 << 75 );
   CPPUNIT_ASSERT_EQUAL( true, aMap->LocalPartition( aLC1, "Zones de champs cultivé à végétation basse" ) );
 
-  TopoDS_Face aLC2 = LandCover( QList<double>() << 21 << 34 << 24 << 25 << 37   << 37 << 40  << 61 <<
-                                                   44 << 95 << 85 << 100 << 104 << 66 << 107 << 33 <<
-                                                  128 << 18 << 140 << 50 << 131 << 89 << 104 << 111 <<
-                                                  31 << 114 );
+  TopoDS_Face aLC2 = Face( QList<double>() << 21 << 34 << 24 << 25 << 37   << 37 << 40  << 61 <<
+                                              44 << 95 << 85 << 100 << 104 << 66 << 107 << 33 <<
+                                             128 << 18 << 140 << 50 << 131 << 89 << 104 << 111 <<
+                                              31 << 114 );
   CPPUNIT_ASSERT_EQUAL( true, aMap->LocalPartition( aLC2, "Zones de champs cultivé à végétation haute" ) );
 
-  TopoDS_Face aLC3 = LandCover( QList<double>() << 4 << 54 << 1   << 47 << 51  << 45 <<
-                                                 127 << 42 << 145 << 43 << 148 << 60 << 90 << 65 );
+  TopoDS_Face aLC3 = Face( QList<double>() << 4 << 54 << 1   << 47 << 51  << 45 <<
+                                            127 << 42 << 145 << 43 << 148 << 60 << 90 << 65 );
   CPPUNIT_ASSERT_EQUAL( true, aMap->LocalPartition( aLC3, "Zones de champs, prairies, sans cultures" ) );
 
   Handle(HYDROGUI_LandCoverMapPrs) aPrs = new HYDROGUI_LandCoverMapPrs( aMap );
@@ -558,3 +522,69 @@ void test_HYDROData_LandCoverMap::test_land_cover_prs_by_coeff()
   aDoc->Close();
 }
 
+void test_HYDROData_LandCoverMap::test_dump_python()
+{
+  Handle(HYDROData_Document) aDoc = HYDROData_Document::Document(1);
+
+  Handle(HYDROData_LandCoverMap) aMap =
+    Handle(HYDROData_LandCoverMap)::DownCast( aDoc->CreateObject( KIND_LAND_COVER_MAP ) );
+  aMap->SetName( "test_LCM" );
+
+  CPPUNIT_ASSERT_EQUAL( KIND_LAND_COVER_MAP, aMap->GetKind() );
+
+  TopoDS_Face aLC1 = Face( QList<double>() << 12 << 19 << 82 << 9 << 126 << 53 << 107 << 80 << 29 << 75 );
+
+  CPPUNIT_ASSERT_EQUAL( true, aMap->LocalPartition( aLC1, "test1" ) );
+
+  TopoDS_Face aLC2 = Face( QList<double>() << 21 << 34 << 24 << 25 << 37   << 37 << 40  << 61 <<
+                                              44 << 95 << 85 << 100 << 104 << 66 << 107 << 33 <<
+                                             128 << 18 << 140 << 50 << 131 << 89 << 104 << 111 <<
+                                              31 << 114 );
+  CPPUNIT_ASSERT_EQUAL( true, aMap->LocalPartition( aLC2, "test2" ) );
+
+  TopoDS_Face aLC3 = Face( QList<double>() << 4 << 54 << 1   << 47 << 51  << 45 <<
+                                            127 << 42 << 145 << 43 << 148 << 60 << 90 << 65 );
+  CPPUNIT_ASSERT_EQUAL( true, aMap->LocalPartition( aLC3, "test3" ) );
+
+  QString aTmpPath = QDir::tempPath() + "/lc_dump.py";
+  CPPUNIT_ASSERT_EQUAL( true, aDoc->DumpToPython( aTmpPath, false ) );
+
+  //TODO: compare files
+}
+
+void test_HYDROData_LandCoverMap::test_transparent_prs()
+{
+  Handle(HYDROData_Document) aDoc = HYDROData_Document::Document(1);
+
+  Handle(HYDROData_StricklerTable) aTable =
+    Handle(HYDROData_StricklerTable)::DownCast( aDoc->CreateObject( KIND_STRICKLER_TABLE ) );
+  CPPUNIT_ASSERT_EQUAL( true, aTable->Import( DEF_STR_PATH ) );
+
+  Handle(HYDROData_PolylineXY) aPoly =
+    Handle(HYDROData_PolylineXY)::DownCast( aDoc->CreateObject( KIND_POLYLINEXY ) );
+  aPoly->AddSection( "", HYDROData_PolylineXY::SECTION_SPLINE, true );
+  aPoly->AddPoint( 0, gp_XY( 0, 0 ) );
+  aPoly->AddPoint( 0, gp_XY( 20, 0 ) );
+  aPoly->AddPoint( 0, gp_XY( 10, 10 ) );
+  aPoly->Update();
+
+  Handle(HYDROData_ImmersibleZone) aZone =
+    Handle(HYDROData_ImmersibleZone)::DownCast( aDoc->CreateObject( KIND_IMMERSIBLE_ZONE ) );
+  aZone->SetPolyline( aPoly );
+  aZone->Update();
+
+  Handle(HYDROData_LandCoverMap) aMap =
+    Handle(HYDROData_LandCoverMap)::DownCast( aDoc->CreateObject( KIND_LAND_COVER_MAP ) );
+  aMap->LocalPartition( Face( QList<double>() << 1 << 1 << 10 << 10 << 10 << 20 ), "Zones de champs cultivé à végétation haute" );
+  aMap->LocalPartition( Face( QList<double>() << 5 << 5 << 10 << 5 << 10 << 8 << 5 << 12 << 5 << 8 ), "Zones de champs cultivé à végétation haute" );
+  aMap->SetName( "test_LCM" );
+
+  TestViewer::show( aZone->GetTopShape(), AIS_Shaded, true, "LandCoverMap_TransparentPrs" );
+
+  Handle(HYDROGUI_LandCoverMapPrs) aPrs = new HYDROGUI_LandCoverMapPrs( aMap );
+  aPrs->SetTable( aTable );
+  aPrs->SetTransparency( 0.5 );
+  TestViewer::show( aPrs, AIS_Shaded, 0, true, "" );
+
+  CPPUNIT_ASSERT_IMAGES
+}
index 95ea4d4b753ffb397d367d590c520fc5f2b1d9ef..609a1802e23f52050a097a6c517077accb8befda 100644 (file)
@@ -35,6 +35,8 @@ class test_HYDROData_LandCoverMap : public CppUnit::TestFixture
   CPPUNIT_TEST( test_import_dbf );
   CPPUNIT_TEST( test_land_cover_prs_by_types );
   CPPUNIT_TEST( test_land_cover_prs_by_coeff );
+  CPPUNIT_TEST( test_dump_python );
+  CPPUNIT_TEST( test_transparent_prs );
   CPPUNIT_TEST_SUITE_END();
 
 public:
@@ -48,6 +50,8 @@ public:
   void test_import_dbf();
   void test_land_cover_prs_by_types();
   void test_land_cover_prs_by_coeff();
+  void test_dump_python();
+  void test_transparent_prs();
 };
 
 CPPUNIT_TEST_SUITE_REGISTRATION( test_HYDROData_LandCoverMap );
index 95a89ee86bb8bc1074e2554fb872a164a8b19e2b..c44a9f5b574b70317c4af030a187dd0df868fd29 100644 (file)
 
 #include<test_HYDROData_PolylineXY.h>
 
+#include <HYDROData_Channel.h>
 #include <HYDROData_Document.h>
 #include <HYDROData_PolylineXY.h>
+#include <HYDROData_Polyline3D.h>
+#include <HYDROData_PolylineOperator.h>
+#include <HYDROData_Profile.h>
+#include <HYDROData_Iterator.h>
+#include <HYDROData_ImmersibleZone.h>
+#include <HYDROData_Tool.h>
+#include <HYDROGUI_Polyline.h>
 
+#include <AIS_DisplayMode.hxx>
+#include <AIS_PointCloud.hxx>
+#include <Prs3d_LineAspect.hxx>
+#include <Prs3d_PointAspect.hxx>
+#include <TColgp_HArray1OfPnt.hxx>
+#include <QColor>
 #include <QList>
 #include <QPointF>
 
+#include <TestShape.h>
+#include <TestViewer.h>
+#include <TopoDS_Edge.hxx>
+#include <TopoDS_Vertex.hxx>
+#include <TopoDS_Wire.hxx>
+#include <gp_XY.hxx>
+
 void test_HYDROData_PolylineXY::testPolyline()
 {
   Handle(HYDROData_Document) aDoc = HYDROData_Document::Document( 1 );
@@ -70,5 +91,282 @@ void test_HYDROData_PolylineXY::testCopy()
   aPolyline1->CopyTo(aPolyline2, true);
 
 
+  aDoc->Close();
+}
+
+void test_HYDROData_PolylineXY::testSplit_refs_624()
+{
+  Handle(HYDROData_Document) aDoc = HYDROData_Document::Document( 1 );
+
+  Handle(HYDROData_PolylineXY) aPolyline = 
+    Handle(HYDROData_PolylineXY)::DownCast( aDoc->CreateObject( KIND_POLYLINEXY ) );
+  aPolyline->SetName( "test" );
+
+  QList<double> aCoords = QList<double>() << 10 << 10 << 20 << 10 << 20 << 20 << 10 << 20;
+  TopoDS_Wire aWire = Wire( aCoords, true );
+  aPolyline->SetShape( aWire );
+
+  gp_Pnt2d aPnt( 20, 20 );
+
+  TestViewer::show( aPolyline->GetShape(), 0, true, "LandCoverMap_Split_Polyline" );
+  //TestViewer::show( BRepBuilderAPI_MakeVertex( aPnt ).Vertex(), 1, true, Qt::green );
+  CPPUNIT_ASSERT_IMAGES
+
+  HYDROData_PolylineOperator anOp;
+  CPPUNIT_ASSERT_EQUAL( true, anOp.Split( aDoc, aPolyline, aPnt, 1E-3 ) );
+
+  HYDROData_Iterator anIt( aDoc, KIND_POLYLINEXY );
+  CPPUNIT_ASSERT_EQUAL( true, anIt.More() );
+  CPPUNIT_ASSERT_EQUAL( QString( "test" ), anIt.Current()->GetName() );
+  anIt.Next();
+  CPPUNIT_ASSERT_EQUAL( true, anIt.More() );
+  CPPUNIT_ASSERT_EQUAL( QString( "test_1" ), anIt.Current()->GetName() );
+  anIt.Next();
+  CPPUNIT_ASSERT_EQUAL( false, anIt.More() );
+
+  aDoc->Close();
+}
+
+void test_HYDROData_PolylineXY::test_extraction_immersible_zone()
+{
+  Handle(HYDROData_Document) aDoc = HYDROData_Document::Document( 1 );
+
+  Handle(HYDROData_PolylineXY) aPolyline = 
+    Handle(HYDROData_PolylineXY)::DownCast( aDoc->CreateObject( KIND_POLYLINEXY ) );
+  aPolyline->SetName( "test" );
+
+  QList<double> aCoords = QList<double>() << 10 << 10 << 20 << 10 << 20 << 20 << 10 << 20;
+  TopoDS_Wire aWire = Wire( aCoords, true );
+  aPolyline->SetShape( aWire );
+
+  Handle(HYDROData_ImmersibleZone) aZone = 
+    Handle(HYDROData_ImmersibleZone)::DownCast( aDoc->CreateObject( KIND_IMMERSIBLE_ZONE ) );
+  aZone->SetName( "zone" );
+  aZone->SetPolyline( aPolyline );
+  aZone->Update();
+
+  CPPUNIT_ASSERT_EQUAL( false, (bool)aZone->GetTopShape().IsNull() );
+
+  HYDROData_PolylineOperator anOp;
+  CPPUNIT_ASSERT_EQUAL( true, anOp.Extract( aDoc, aZone ) );
+
+  Handle(HYDROData_PolylineXY) anOuter = 
+    Handle(HYDROData_PolylineXY)::DownCast( aDoc->FindObjectByName( "zone_Outer_1", KIND_POLYLINEXY ) );
+  CPPUNIT_ASSERT_EQUAL( false, (bool)anOuter.IsNull() );
+
+  TestViewer::show( aZone->GetTopShape(), 1, true, "Extraction_ImmZone" );
+  TestViewer::show( anOuter->GetShape(), 0, true, Qt::red );
+  CPPUNIT_ASSERT_IMAGES
+
+  aDoc->Close();
+}
+
+void test_HYDROData_PolylineXY::test_extraction_channel_refs_611()
+{
+  Handle(HYDROData_Document) aDoc = HYDROData_Document::Document(1);
+
+  Handle(HYDROData_PolylineXY) aPolyline2d = 
+    Handle(HYDROData_PolylineXY)::DownCast( aDoc->CreateObject( KIND_POLYLINEXY ) );
+  aPolyline2d->SetName( "polyline2d_1" );
+  aPolyline2d->AddSection( "", HYDROData_IPolyline::SECTION_SPLINE, false );
+
+  Handle(HYDROData_Polyline3D) aPolyline3d = 
+    Handle(HYDROData_Polyline3D)::DownCast( aDoc->CreateObject( KIND_POLYLINE ) );
+  aPolyline3d->SetName( "polyline3d_1" );
+  aPolyline3d->SetPolylineXY( aPolyline2d );
+
+  QList<double> aCoords = QList<double>() << 10 << 10 << 20 << 10 << 20 << 20 << 10 << 20;
+  TopoDS_Wire aWire = Wire( aCoords, false );
+  aPolyline2d->SetShape( aWire );
+  aPolyline3d->SetTopShape( aWire );
+  aPolyline3d->SetShape3D( aWire );
+
+  Handle(HYDROData_Profile) aProfile = 
+    Handle(HYDROData_Profile)::DownCast( aDoc->CreateObject( KIND_PROFILE ) );
+  aProfile->SetName( "profile_1" );
+
+  QList<double> aCoordsPr = QList<double>() << 0.0 << 0.1 << 0.5 << 0.0 << 1.0 << 0.1;
+  TopoDS_Wire aWirePr = Wire( aCoordsPr, false );
+  aProfile->SetTopShape( aWirePr );
+  aProfile->SetShape3D( aWirePr );
+
+
+  Handle(HYDROData_Channel) aChannel = 
+    Handle(HYDROData_Channel)::DownCast( aDoc->CreateObject( KIND_CHANNEL ) );
+  aChannel->SetName( "channel_1" );
+  
+  aChannel->SetGuideLine( aPolyline3d );
+  aChannel->SetProfile( aProfile );
+  aChannel->Update();
+  CPPUNIT_ASSERT_EQUAL( false, (bool)aChannel->GetTopShape().IsNull() );
+  CPPUNIT_ASSERT_EQUAL( false, (bool)aChannel->GetShape3D().IsNull() );
+
+  HYDROData_PolylineOperator anOp;
+  CPPUNIT_ASSERT_EQUAL( true, anOp.Extract( aDoc, aChannel ) );
+
+  Handle(HYDROData_PolylineXY) aLeft = 
+    Handle(HYDROData_PolylineXY)::DownCast( aDoc->FindObjectByName( "channel_1_Left_Bank_1", KIND_POLYLINEXY ) );
+  Handle(HYDROData_PolylineXY) aRight = 
+    Handle(HYDROData_PolylineXY)::DownCast( aDoc->FindObjectByName( "channel_1_Right_Bank_1", KIND_POLYLINEXY ) );
+  CPPUNIT_ASSERT_EQUAL( false, (bool)aRight.IsNull() );
+
+  TestViewer::show( aChannel->GetTopShape(), 1, true, "Extraction_Channel" );
+  TestViewer::show( aLeft->GetShape(), 0, true, Qt::red );
+  TestViewer::show( aRight->GetShape(), 0, true, Qt::red );
+  CPPUNIT_ASSERT_IMAGES
+
+  aDoc->Close();
+}
+
+void test_HYDROData_PolylineXY::test_presentation()
+{
+  Handle(HYDROData_Document) aDoc = HYDROData_Document::Document(1);
+
+  Handle(HYDROData_PolylineXY) aPolyline2d = 
+    Handle(HYDROData_PolylineXY)::DownCast( aDoc->CreateObject( KIND_POLYLINEXY ) );
+  aPolyline2d->SetName( "polyline2d_1" );
+  aPolyline2d->AddSection( "", HYDROData_IPolyline::SECTION_SPLINE, false );
+
+  QList<gp_XY> aPoints = QList<gp_XY>() << gp_XY(  0,  0 )
+                                        << gp_XY( 10, 10 )
+                                        << gp_XY( 20, 40 )
+                                        << gp_XY( 30, 10 )
+                                        << gp_XY( 40, 50 )
+                                        << gp_XY( 50, 60 )
+                                        << gp_XY( -10, 40 )
+                                        << gp_XY( -9, 39 )
+                                        << gp_XY( -8, 38 )
+                                        << gp_XY(  0, 20 );
+  Handle(TColgp_HArray1OfPnt) aPnts = new TColgp_HArray1OfPnt( 1, aPoints.size() );
+  int i = 1;
+  foreach( gp_XY aPoint, aPoints )
+  {
+    aPolyline2d->AddPoint( 0, aPoint );
+    aPnts->SetValue( i, gp_Pnt( aPoint.X(), aPoint.Y(), 0 ) );
+    i++;
+  }
+  aPolyline2d->Update();
+
+  CPPUNIT_ASSERT_EQUAL( false, (bool)aPolyline2d->GetShape().IsNull() );
+
+  Handle(AIS_PointCloud) aPointsPrs = new AIS_PointCloud();
+  aPointsPrs->SetPoints( aPnts );
+  aPointsPrs->SetColor( Quantity_NOC_BLUE1 );
+  aPointsPrs->Attributes()->PointAspect()->SetTypeOfMarker( Aspect_TOM_O );
+
+  Handle(HYDROGUI_Polyline) aNewPolylinePrs = new HYDROGUI_Polyline( aPolyline2d->GetShape() );
+  aNewPolylinePrs->SetColor( Quantity_NOC_DARKGREEN );
+
+  TestViewer::show( aPointsPrs, AIS_PointCloud::DM_Points, 0, true, "Polyline_Presentation" );
+  TestViewer::show( aPolyline2d->GetShape(), 0, true, Qt::red );
+  TestViewer::show( aNewPolylinePrs, AIS_PointCloud::DM_Points, 0, true, "" );
+  CPPUNIT_ASSERT_IMAGES
+
+  aDoc->Close();
+}
+
+void test_HYDROData_PolylineXY::testSplit_refs_627()
+{
+  Handle(HYDROData_Document) aDoc = HYDROData_Document::Document( 1 );
+
+  Handle(HYDROData_PolylineXY) aPolyline = 
+    Handle(HYDROData_PolylineXY)::DownCast( aDoc->CreateObject( KIND_POLYLINEXY ) );
+  aPolyline->SetName( "test" );
+
+  QList<double> aCoords = QList<double>() << 10 << 10 << 20 << 10 << 20 << 20 << 10 << 20;
+  TopoDS_Wire aWire = Wire( aCoords, false );
+  aPolyline->SetShape( aWire );
+  aPolyline->SetWireColor( Qt::red );
+
+  gp_Pnt2d aPnt( 20, 20 );
+  
+  HYDROData_PolylineOperator anOp;
+  CPPUNIT_ASSERT_EQUAL( true, anOp.Split( aDoc, aPolyline, aPnt, 1E-3 ) );
+
+  TestViewer::show( TopoDS_Shape(), 0, true, "Split_Polylines_Colors" );
+  HYDROData_Iterator anIt( aDoc, KIND_POLYLINEXY );
+  for( ; anIt.More(); anIt.Next() )
+  {
+    Handle(HYDROData_PolylineXY) anObj = Handle(HYDROData_PolylineXY)::DownCast( anIt.Current() );
+    if( aPolyline->Label() != anObj->Label() )
+      TestViewer::show( anObj->GetShape(), 0, true, anObj->GetWireColor() );
+  }
+  CPPUNIT_ASSERT_IMAGES
+    
+  HYDROData_Iterator anIt2( aDoc, KIND_POLYLINEXY );
+  CPPUNIT_ASSERT_EQUAL( true, anIt2.More() );
+  CPPUNIT_ASSERT_EQUAL( QString( "test" ), anIt2.Current()->GetName() );
+  CPPUNIT_ASSERT_EQUAL( QColor( Qt::red ),
+    Handle(HYDROData_PolylineXY)::DownCast( anIt2.Current() )->GetWireColor() );
+  anIt2.Next();
+  CPPUNIT_ASSERT_EQUAL( true, anIt2.More() );
+  CPPUNIT_ASSERT_EQUAL( QString( "test_1" ), anIt2.Current()->GetName() );
+  CPPUNIT_ASSERT_EQUAL( QColor( Qt::red ), 
+    Handle(HYDROData_PolylineXY)::DownCast( anIt2.Current() )->GetWireColor() );
+  anIt2.Next();
+  CPPUNIT_ASSERT_EQUAL( true, anIt2.More() );
+  CPPUNIT_ASSERT_EQUAL( QString( "test_2" ), anIt2.Current()->GetName() );
+  CPPUNIT_ASSERT_EQUAL( QColor( Qt::red ), 
+    Handle(HYDROData_PolylineXY)::DownCast( anIt2.Current() )->GetWireColor() );
+  anIt2.Next();
+  CPPUNIT_ASSERT_EQUAL( false, anIt2.More() );
+  anIt2.Next();
+
+  aDoc->Close();
+}
+
+void test_HYDROData_PolylineXY::test_custom_polylines()
+{
+  Handle(HYDROData_Document) aDoc = HYDROData_Document::Document( 1 );
+
+  Handle(HYDROData_PolylineXY) aPolyline1 = 
+    Handle(HYDROData_PolylineXY)::DownCast( aDoc->CreateObject( KIND_POLYLINEXY ) );
+  Handle(HYDROData_PolylineXY) aPolyline2 = 
+    Handle(HYDROData_PolylineXY)::DownCast( aDoc->CreateObject( KIND_POLYLINEXY ) );
+  Handle(HYDROData_PolylineXY) aPolyline3 = 
+    Handle(HYDROData_PolylineXY)::DownCast( aDoc->CreateObject( KIND_POLYLINEXY ) );
+
+  aPolyline1->SetName( "test1" );
+  aPolyline2->SetName( "test2" );
+  aPolyline3->SetName( "test3" );
+
+  CPPUNIT_ASSERT_EQUAL( false, aPolyline1->IsCustom() );
+  aPolyline1->AddSection( "", HYDROData_IPolyline::SECTION_SPLINE, false );
+  aPolyline1->Update();
+  CPPUNIT_ASSERT_EQUAL( false, aPolyline1->IsCustom() );
+  aPolyline1->AddPoint( 0, gp_XY( 0, 0 ) );
+  aPolyline1->Update();
+  CPPUNIT_ASSERT_EQUAL( false, aPolyline1->IsCustom() );
+
+  CPPUNIT_ASSERT_EQUAL( false, aPolyline2->IsCustom() );
+  aPolyline2->SetShape( Wire( QList<double>() << 0 << 0 << 1 << 1 << 2 << 0 ) );
+  CPPUNIT_ASSERT_EQUAL( true, aPolyline2->IsCustom() );
+  HYDROData_PolylineXY::PointsList aPointsList = aPolyline2->GetPoints( 0 );
+
+  CPPUNIT_ASSERT_EQUAL( false, aPolyline2->IsCustom() );
+  CPPUNIT_ASSERT_EQUAL( 33, aPointsList.Size() );
+  CPPUNIT_ASSERT_EQUAL( gp_XY( 0, 0 ), aPointsList.Value( 1 ) );
+  CPPUNIT_ASSERT_EQUAL( gp_XY( 0.5625, 0.808594 ), aPointsList.Value( 10 ) );
+  CPPUNIT_ASSERT_EQUAL( gp_XY( 1.1875, 0.964844 ), aPointsList.Value( 20 ) );
+  CPPUNIT_ASSERT_EQUAL( gp_XY( 2, 0 ), aPointsList.Value( 33 ) );
+
+
+  CPPUNIT_ASSERT_EQUAL( false, aPolyline3->IsCustom() );
+  aPolyline3->SetShape( WireCirc( gp_Pnt(), 1.0 ) );
+  CPPUNIT_ASSERT_EQUAL( true, aPolyline3->IsCustom() );
+  aPointsList = aPolyline3->GetPoints( 0 );
+
+  CPPUNIT_ASSERT_EQUAL( HYDROData_PolylineXY::SECTION_SPLINE, aPolyline3->GetSectionType( 0 ) );
+  CPPUNIT_ASSERT_EQUAL( true, aPolyline3->IsClosedSection( 0 ) );
+  CPPUNIT_ASSERT_EQUAL( 71, aPointsList.Size() );
+  CPPUNIT_ASSERT_EQUAL( gp_XY( 1, 0 ), aPointsList.Value( 1 ) );
+  CPPUNIT_ASSERT_EQUAL( gp_XY( 0.699242, 0.714885 ), aPointsList.Value( 10 ) );
+  CPPUNIT_ASSERT_EQUAL( gp_XY( -0.110394, 0.993888 ), aPointsList.Value( 20 ) );
+  CPPUNIT_ASSERT_EQUAL( gp_XY( -0.839072, 0.54402 ), aPointsList.Value( 30 ) );
+  CPPUNIT_ASSERT_EQUAL( gp_XY( -0.952415, -0.304806 ), aPointsList.Value( 40 ) );
+  CPPUNIT_ASSERT_EQUAL( gp_XY( -0.367302, -0.930102 ), aPointsList.Value( 50 ) );
+  CPPUNIT_ASSERT_EQUAL( gp_XY( 0.487173, -0.873306 ), aPointsList.Value( 60 ) );
+  CPPUNIT_ASSERT_EQUAL( gp_XY( 0.996087, -0.0883801 ), aPointsList.Value( 71 ) );
+
   aDoc->Close();
 }
index 24623b3c5e200da6e4ae4ddc71676353d874596e..3a7b53bb1eb9c1c09d405a02614260da3a73121e 100644 (file)
 #include <cppunit/extensions/HelperMacros.h>
 
 class test_HYDROData_PolylineXY : public CppUnit::TestFixture {
-  CPPUNIT_TEST_SUITE(test_HYDROData_PolylineXY);
-  CPPUNIT_TEST(testPolyline);
-  CPPUNIT_TEST(testCopy);
+  CPPUNIT_TEST_SUITE( test_HYDROData_PolylineXY );
+  CPPUNIT_TEST( testPolyline );
+  CPPUNIT_TEST( testCopy );
+  CPPUNIT_TEST( testSplit_refs_624 );
+  CPPUNIT_TEST( testSplit_refs_627 );
+  CPPUNIT_TEST( test_presentation );
+  CPPUNIT_TEST( test_extraction_immersible_zone );
+  CPPUNIT_TEST( test_extraction_channel_refs_611 );
+  CPPUNIT_TEST( test_custom_polylines );
   CPPUNIT_TEST_SUITE_END();
 
 private:
@@ -37,6 +43,14 @@ public:
 
   // checks the image properties copy/paste
   void testCopy();
+
+  void testSplit_refs_624();
+  void testSplit_refs_627();
+
+  void test_extraction_immersible_zone();
+  void test_extraction_channel_refs_611();
+  void test_presentation();
+  void test_custom_polylines();
 };
 
 CPPUNIT_TEST_SUITE_REGISTRATION(test_HYDROData_PolylineXY);
index a7c2da126e81bec5763c0da90480f39290d411fd..05b2dc4b1c2124508522407161606b75653daacd 100644 (file)
@@ -24,7 +24,7 @@
 #include <QColor>
 #include <QDir>
 
-const QString DEF_STR_PATH = qgetenv( "HYDRO_ROOT_DIR" ) + "/share/salome/resources/hydro/def_strickler_table.txt";
+const QString DEF_STR_PATH = qgetenv( "HYDRO_SRC_DIR" ) + "/src/HYDROGUI/resources/def_strickler_table.txt";
 
 void test_HYDROData_StricklerTable::test_import()
 {
index 419c3c4c6b548bf4ac0b87efb7279667d21cd409..2c5cf258b43e47f705d539dde073179460e56013 100644 (file)
@@ -13,13 +13,13 @@ set(PROJECT_SOURCES
 )
 
 add_definitions(
-  -DSHAPELIB_DLLEXPORT
+  -DSHAPELIB_DLLEXPORT -fPIC
 )
 
 include_directories(
 )
 
-add_library(shapelib SHARED ${PROJECT_SOURCES} ${PROJECT_HEADERS})
+add_library(shapelib STATIC ${PROJECT_SOURCES} ${PROJECT_HEADERS})
 INSTALL(TARGETS shapelib EXPORT ${PROJECT_NAME}TargetGroup DESTINATION ${SALOME_INSTALL_LIBS})
 
 set(PROJECT_LIBRARIES shapelib)