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}
#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,
// compute BSpline
Handle(Geom_BSplineCurve) aBSpline;
-#ifndef LIGHT_MODE
if( CurveCreator_Utils::constructBSpline( aHCurvePoints, theIsClosed, aBSpline ) )
return aBSpline;
else
-#endif
return Handle(Geom_BSplineCurve)();
}
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
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 )
{
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;
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;
+}
#include <HYDROData_Entity.h>
#include <TDataStd_ExtStringArray.hxx>
-#include <QMap>
DEFINE_STANDARD_HANDLE( HYDROData_LandCoverMap, HYDROData_Entity )
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 );
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& );
{
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 );
+ }
+ }
+}
HYDRODATA_EXPORT bool IsSubmersible() const;
HYDRODATA_EXPORT void SetIsSubmersible( bool ) const;
+ HYDRODATA_EXPORT virtual void GetBoundaries( QList<TopoDS_Shape>& theBoundShapes,
+ QStringList& theBoundNames ) const;
+
protected:
/**
#include <HYDROData_PolylineOperator.h>
#include <HYDROData_Document.h>
#include <HYDROData_TopoCurve.h>
+#include <HYDROData_Object.h>
#ifndef LIGHT_MODE
#include <CurveCreator_Utils.hxx>
#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 )
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;
std::vector<TopoDS_Shape> aPolylines(1);
aPolylines[0] = aWireSet;
- CreatePolylines(theDoc, theName, aPolylines, false);
+ CreatePolylines( theDoc, theName, aPolylines, false, QColor() );
return true;
}
}
}
- CreatePolylines(theDoc, thePolyline->GetName(), aResult, true);
+ CreatePolylines( theDoc, thePolyline->GetName(), aResult, true, thePolyline->GetWireColor() );
return true;
}
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;
{
aPolyline->SetName( theNamePrefix );
}
+
+ if( theColor.isValid() )
+ aPolyline->SetWireColor( theColor );
}
return true;
}
}
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;
+}
class Handle( HYDROData_Document );
class HYDROData_TopoCurve;
+class Handle(HYDROData_Object);
class HYDRODATA_EXPORT HYDROData_PolylineOperator
{
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,
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
#include <BRepBuilderAPI_MakePolygon.hxx>
#include <BRepBuilderAPI_MakeFace.hxx>
#include <BRepOffsetAPI_NormalProjection.hxx>
+#include <BRepAdaptor_Curve.hxx>
#ifndef LIGHT_MODE
#include <GEOMBase.h>
#include <Geom_BSplineCurve.hxx>
#include <GCPnts_AbscissaPoint.hxx>
+#include <GCPnts_QuasiUniformDeflection.hxx>
#include <ImageComposer_MetaTypes.h>
#include <TColStd_ListIteratorOfListOfReal.hxx>
#include <TColStd_Array1OfReal.hxx>
+#include <TColgp_Array1OfPnt.hxx>
#include <TDataStd_AsciiString.hxx>
#include <TDataStd_BooleanList.hxx>
IMPLEMENT_STANDARD_RTTIEXT(HYDROData_PolylineXY, HYDROData_IPolyline)
HYDROData_PolylineXY::HYDROData_PolylineXY()
-: HYDROData_IPolyline()
+: HYDROData_IPolyline(),
+ myIsInCustomFlag( false )
{
}
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 );
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 );
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 );
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;
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 )
{
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 );
}
}
theSectTypes.Clear();
theSectClosures.Clear();
+ if( IsCustom() )
+ {
+ const_cast<HYDROData_PolylineXY*>( this )->Interpolate();
+ }
+
Handle(TDataStd_ExtStringList) aNamesList;
Handle(TDataStd_IntegerList) aTypesList;
Handle(TDataStd_BooleanList) aClosuresList;
if( IsCustom() )
{
- //TODO: make interpolation to fill the list
+ const_cast<HYDROData_PolylineXY*>( this )->Interpolate();
}
Handle(TDataStd_RealList) aListX, aListY;
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 );
+}
/**
* 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.
*/
HYDRODATA_EXPORT virtual void setEditable( const bool theIsEditable );
+ HYDRODATA_EXPORT void Interpolate();
+
protected:
friend class HYDROData_Profile;
* Destructs properties of the object and object itself, removes it from the document.
*/
HYDRODATA_EXPORT ~HYDROData_PolylineXY();
+
+private:
+ bool myIsInCustomFlag;
};
#endif
#include <QColor>
#include <BRepTopAdaptor_FClass2d.hxx>
+#ifdef WIN32
+ #pragma warning( disable: 4996 )
+#endif
+
HYDROData_ShapeFile::HYDROData_ShapeFile() : myHSHP(NULL)
{
}
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();
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;
+
+}
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 )
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
#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 )
: AIS_ColoredShape( theMap->GetShape() )
{
SetLandCoverMap( theMap );
+ SetAutoHilight( Standard_False );
+ SetHilightAttributes( EDGES_COLOR );
}
HYDROGUI_LandCoverMapPrs::~HYDROGUI_LandCoverMapPrs()
{
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 )
{
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 );
+}
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;
#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>
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() )
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 );
+ }
}
// 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 )
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;
-}
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
HYDROData_Document.sip
HYDROData_Application.sip
HYDROData_IProfilesInterpolator.sip
+ HYDROData_LandCoverMap.sip
)
# --- sources ---
%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
%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();
};
#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
+};
}
%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();
-
};
%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();
};
/**
* 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 ) );
--- /dev/null
+// 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
+};
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() )
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() )
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
%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();
};
-
-
set(PROJECT_HEADERS
test_HYDROData_Bathymetry.h
+ test_HYDROData_Channel.h
test_HYDROData_Document.h
test_HYDROData_Entity.h
test_HYDROData_Image.h
test_HYDROGUI_ListModel.h
test_Dependencies.h
+ TestShape.h
TestViewer.h
TestLib_Listener.h
TestLib_Runner.h
set(PROJECT_SOURCES
test_HYDROData_Bathymetry.cxx
+ test_HYDROData_Channel.cxx
test_HYDROData_Document.cxx
test_HYDROData_Entity.cxx
test_HYDROData_Image.cxx
test_HYDROGUI_ListModel.cxx
test_Dependencies.cxx
+ TestShape.cxx
TestViewer.cxx
TestLib_Listener.cxx
TestLib_Runner.cxx
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 )
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
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" )
../HYDROGUI/HYDROGUI_ListModel.cxx
../HYDROGUI/HYDROGUI_DataObject.cxx
../HYDROGUI/HYDROGUI_LandCoverMapPrs.cxx
+ ../HYDROGUI/HYDROGUI_Polyline.cxx
)
--- /dev/null
+
+#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();
+}
--- /dev/null
+
+#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 );
+
#include <AIS_InteractiveContext.hxx>
#include <AIS_Shape.hxx>
#include <Aspect_ColorScale.hxx>
+#include <Prs3d_PointAspect.hxx>
#include <TopoDS_Iterator.hxx>
#include <QDir>
#include <QPainter>
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();
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 );
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 )
{
}
return aColorScale;
}
+
+void TestViewer::select( int theViewX, int theViewY )
+{
+ Handle(V3d_View) aView = myViewWindow->getViewPort()->getView();
+ context()->MoveTo( theViewX, theViewY, aView );
+ context()->Select();
+}
static Handle_Aspect_ColorScale showColorScale( bool );
+ static void select( int theViewX, int theViewY );
+
private:
static OCCViewer_ViewManager* myViewManager;
static OCCViewer_ViewWindow* myViewWindow;
--- /dev/null
+// 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();
+}
--- /dev/null
+// 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");
#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()
{
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" );
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 ) );
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 ) );
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 );
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;
// 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()
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();
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 );
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
+}
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:
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 );
#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 );
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();
}
#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:
// 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);
#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()
{
)
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)