#define _DEVDEBUG_
#include "HYDRO_trace.hxx"
-IMPLEMENT_STANDARD_HANDLE(HYDROData_Bathymetry, HYDROData_IAltitudeObject)
+ const int BLOCK_SIZE = 1000;
+
IMPLEMENT_STANDARD_RTTIEXT(HYDROData_Bathymetry, HYDROData_IAltitudeObject)
//HYDROData_QuadtreeNode* HYDROData_Bathymetry::myQuadtree = 0;
return aRes;
}
- bool HYDROData_Bathymetry::ImportFromFile( const TCollection_AsciiString& theFileName )
+ bool HYDROData_Bathymetry::ImportFromFile( const QString& theFileName )
{
- // Try to open the file
- QFile aFile( theFileName.ToCString() );
- if ( !aFile.exists() || !aFile.open( QIODevice::ReadOnly ) )
- return false;
+ return ImportFromFiles(QStringList(theFileName));
+ }
- bool aRes = false;
+ bool HYDROData_Bathymetry::ImportFromFiles( const QStringList& theFileNames )
+ {
+ AltitudePoints AllPoints;
+ bool Stat = false;
- QString aFileSuf = QFileInfo( aFile ).suffix().toLower();
+ foreach (QString theFileName, theFileNames)
+ {
+ // Try to open the file
+ QFile aFile( theFileName );
+ if ( !aFile.exists() || !aFile.open( QIODevice::ReadOnly ) )
+ continue;
- AltitudePoints aPoints;
+ QString aFileSuf = QFileInfo( aFile ).suffix().toLower();
- // Try to import the file
- if ( aFileSuf == "xyz" )
- aRes = importFromXYZFile( aFile, aPoints );
- else if ( aFileSuf == "asc" )
- aRes = importFromASCFile( aFile, aPoints );
+ HYDROData_Bathymetry::AltitudePoints aPoints;
- // Close the file
- aFile.close();
-
+ // Try to import the file
+ if ( aFileSuf == "xyz" )
+ Stat = importFromXYZFile( aFile, aPoints );
+ else if ( aFileSuf == "asc" )
+ Stat = importFromASCFile( aFile, aPoints );
+
+ if (!Stat)
+ continue; //ignore this points
+
+ // Close the file
+ aFile.close();
+
+ AllPoints.insert(AllPoints.end(), aPoints.begin(), aPoints.end());
+ }
// Convert from global to local CS
- Handle_HYDROData_Document aDoc = HYDROData_Document::Document( myLab );
+ Handle(HYDROData_Document) aDoc = HYDROData_Document::Document( myLab );
- AltitudePoints::Iterator anIter( aPoints );
- for ( ; anIter.More(); anIter.Next() )
+ HYDROData_Bathymetry::AltitudePoints::iterator anIter = AllPoints.begin(), aLast = AllPoints.end();
+ for ( ; anIter!=aLast; ++anIter )
{
- AltitudePoint& aPoint = anIter.ChangeValue();
- aDoc->Transform( aPoint, true );
+ HYDROData_Bathymetry::AltitudePoint& aPoint = *anIter;
+ aDoc->Transform( aPoint.X, aPoint.Y, aPoint.Z, true );
}
- if ( aRes )
+ if ( Stat )
{
// Update file path and altitude points of this Bathymetry
- SetFilePath( theFileName );
- SetAltitudePoints( aPoints );
+ SetFilePaths (theFileNames );
+ SetAltitudePoints( AllPoints );
}
- return aRes && !aPoints.IsEmpty();
+ return Stat && !AllPoints.empty();
}
bool HYDROData_Bathymetry::importFromXYZFile( QFile& theFile,
class QFile;
class gp_XYZ;
class gp_XY;
-class Handle_HYDROData_PolylineXY;
+class HYDROData_PolylineXY;
-
+ class HYDROData_QuadtreeNode;
+ class vtkPolyData;
+ class vtkIdList;
-DEFINE_STANDARD_HANDLE(HYDROData_Bathymetry, HYDROData_IAltitudeObject)
-
/**\class HYDROData_Bathymetry
* \brief Class that stores/retreives information about the Bathymetry.
* \param theFileName the path to file
* \return \c true if file has been successfully read
*/
- HYDRODATA_EXPORT virtual bool ImportFromFile( const TCollection_AsciiString& theFileName );
+ HYDRODATA_EXPORT virtual bool ImportFromFiles( const QStringList& theFileNames );
+
+ HYDRODATA_EXPORT virtual bool ImportFromFile( const QString& theFileName );
- HYDRODATA_EXPORT Handle_HYDROData_PolylineXY CreateBoundaryPolyline() const;
+ HYDRODATA_EXPORT Handle(HYDROData_PolylineXY) CreateBoundaryPolyline() const;
HYDRODATA_EXPORT virtual void UpdateLocalCS( double theDx, double theDy );
--- /dev/null
-#include <Geom_Plane.hxx>
+
+ #include <HYDROData_DTM.h>
+ #include <HYDROData_Profile.h>
+
+ #include <Geom2d_BSplineCurve.hxx>
+ #include <Geom2dAPI_Interpolate.hxx>
+ #include <TColgp_HArray1OfPnt2d.hxx>
+ #include <TColgp_Array1OfVec2d.hxx>
+ #include <TColStd_HArray1OfBoolean.hxx>
+ #include <TopoDS.hxx>
+ #include <TopoDS_Edge.hxx>
+ #include <TopoDS_Wire.hxx>
+ #include <TopExp_Explorer.hxx>
+ #include <BRep_Tool.hxx>
+ #include <gp_Ax3.hxx>
+ #include <Geom_Line.hxx>
+ #include <Geom2d_Line.hxx>
+ #include <Geom2d_TrimmedCurve.hxx>
+ #include <Geom_BSplineCurve.hxx>
+ #include <Geom2d_BSplineCurve.hxx>
+ #include <GeomAPI_Interpolate.hxx>
+ #include <TColStd_Array1OfReal.hxx>
+ #include <TColStd_Array1OfInteger.hxx>
+ #include <TColgp_Array1OfPnt.hxx>
+ #include <TColgp_Array1OfVec.hxx>
+ #include <TColgp_HArray1OfPnt.hxx>
+ #include <Geom2dAPI_InterCurveCurve.hxx>
+ #include <Geom2dAPI_ProjectPointOnCurve.hxx>
+ #include <Geom2dAdaptor_Curve.hxx>
+ #include <GCPnts_AbscissaPoint.hxx>
+ #include <BRepBuilderAPI_MakeEdge.hxx>
+ #include <limits>
+
+ #include <BRepLib_MakeEdge.hxx>
+ #include <BRepLib_MakeWire.hxx>
+ #include <BRep_Builder.hxx>
+ #include <GeomProjLib.hxx>
+ #include <Geom_TrimmedCurve.hxx>
-#include <TopTools_IndexedMapOfOrientedShape.hxx>
+ #include <BRepTools_WireExplorer.hxx>
+ #include <TopTools_IndexedMapOfShape.hxx>
+ #include <BRepBuilderAPI_MakeFace.hxx>
+ #include <TopExp.hxx>
-#include <TopTools_SequenceOfShape.hxx>
+
+ #include <BRepLib_MakeEdge.hxx>
+ #include <BRepLib_MakeWire.hxx>
+ #include <BRep_Builder.hxx>
+ #include <ShapeAnalysis_Wire.hxx>
+ #include <BRepAlgo_NormalProjection.hxx>
+ #include <ShapeUpgrade_UnifySameDomain.hxx>
+ #include <BRepBuilderAPI_MakePolygon.hxx>
+ #include <BOPAlgo_Builder.hxx>
+
+ #include <TopTools_IndexedDataMapOfShapeShape.hxx>
+ #include <TopTools_ListIteratorOfListOfShape.hxx>
-IMPLEMENT_STANDARD_HANDLE( HYDROData_DTM, HYDROData_Bathymetry )
-IMPLEMENT_STANDARD_RTTIEXT( HYDROData_DTM, HYDROData_Bathymetry )
+
- std::vector<Handle_HYDROData_Profile> profiles;
++//@MZN zzz IMPLEMENT_STANDARD_HANDLE( HYDROData_DTM, HYDROData_Bathymetry )
++//@MZN zzz IMPLEMENT_STANDARD_RTTIEXT( HYDROData_DTM, HYDROData_Bathymetry )
+
+ HYDROData_DTM::CurveUZ::CurveUZ( double theXCurv, const gp_Vec2d& theProfileDir, double theDeltaZ )
+ : myXcurv( theXCurv ), myProfileDir( theProfileDir ), myDeltaZ( theDeltaZ )
+ {
+ }
+
+ HYDROData_DTM::CurveUZ::~CurveUZ()
+ {
+ }
+
+ double HYDROData_DTM::CurveUZ::Xcurv() const
+ {
+ return myXcurv;
+ }
+
+ gp_Vec2d HYDROData_DTM::CurveUZ::ProfileDir() const
+ {
+ return myProfileDir;
+ }
+
+ double HYDROData_DTM::CurveUZ::DeltaZ() const
+ {
+ return myDeltaZ;
+ }
+
+ HYDROData_DTM::CurveUZ HYDROData_DTM::CurveUZ::operator + ( const CurveUZ& c ) const
+ {
+ HYDROData_DTM::CurveUZ res( Xcurv() + c.Xcurv(), ProfileDir() + c.ProfileDir(), DeltaZ() + c.DeltaZ() );
+ size_t n = size(), n1 = c.size();
+ if( n!=n1 )
+ {
+ std::cout << "Warning: different number of points in curves: " << n << ", " << n1 << std::endl;
+ }
+ res.reserve( n );
+ for( int i=0; i<n; i++ )
+ {
+ PointUZ p;
+ p.U = operator[]( i ).U + c[i].U;
+ p.Z = operator[]( i ).Z;
+ res.push_back( p );
+ }
+ return res;
+ }
+
+ HYDROData_DTM::CurveUZ HYDROData_DTM::CurveUZ::operator * ( double d ) const
+ {
+ HYDROData_DTM::CurveUZ res( Xcurv()*d, ProfileDir()*d, DeltaZ()*d );
+ size_t n = size();
+ res.reserve( n );
+ for( int i=0; i<n; i++ )
+ {
+ PointUZ p;
+ p.U = operator[]( i ).U * d;
+ p.Z = operator[]( i ).Z;
+ res.push_back( p );
+ }
+ return res;
+ }
+
+
+
+
+ HYDROData_DTM::HYDROData_DTM()
+ {
+ }
+
+ HYDROData_DTM::~HYDROData_DTM()
+ {
+ }
+
+ HYDROData_SequenceOfObjects HYDROData_DTM::GetProfiles() const
+ {
+ return GetReferenceObjects( DataTag_Profiles );
+ }
+
+ void HYDROData_DTM::SetProfiles( const HYDROData_SequenceOfObjects& theProfiles )
+ {
+ SetReferenceObjects( theProfiles, DataTag_Profiles );
+ Changed( Geom_3d );
+ }
+
+ double HYDROData_DTM::GetDDZ() const
+ {
+ return GetDouble( DataTag_DDZ );
+ }
+
+ void HYDROData_DTM::SetDDZ( double theDDZ )
+ {
+ SetDouble( DataTag_DDZ, theDDZ );
+ Changed( Geom_3d );
+ }
+
+ double HYDROData_DTM::GetSpatialStep() const
+ {
+ return GetDouble( DataTag_SpatialStep );
+ }
+
+ void HYDROData_DTM::SetSpatialStep( double theSpatialStep )
+ {
+ SetDouble( DataTag_SpatialStep, theSpatialStep );
+ Changed( Geom_3d );
+ }
+
+ void HYDROData_DTM::PointToWire(const AltitudePoints& pnts, TopoDS_Wire& W )
+ {
+ /*BRepLib_MakeWire WM;
+ if (pnts.empty())
+ return;
+ for (int i = 0; i < pnts.size() - 1; i++)
+ {
+ gp_Pnt p1(pnts[i].X, pnts[i].Y, pnts[i].Z);
+ gp_Pnt p2(pnts[i+1].X, pnts[i+1].Y, pnts[i+1].Z);
+ WM.Add(BRepLib_MakeEdge(p1, p2).Edge());
+ }
+ if (WM.IsDone())*/
+
+ BRepBuilderAPI_MakePolygon PM;
+ for (int i = 0; i < pnts.size(); i++)
+ PM.Add(gp_Pnt(pnts[i].X, pnts[i].Y, pnts[i].Z));
+
+ W = PM.Wire();
+ }
+
+ TopTools_IndexedMapOfOrientedShape HYDROData_DTM::Create3DShape(const AltitudePoints& left,
+ const AltitudePoints& right,
+ const std::vector<AltitudePoints>& main_profiles)
+ {
+ TopTools_IndexedMapOfOrientedShape ll;
+ TopoDS_Wire LWire, RWire;
+ PointToWire(left, LWire);
+ PointToWire(right, RWire);
+ if (!LWire.IsNull())
+ ll.Add(LWire.Oriented(TopAbs_FORWARD));
+
+ for (int k = 0; k < main_profiles.size(); k++)
+ {
+ TopoDS_Wire W;
+ PointToWire(main_profiles[k], W);
+ TopAbs_Orientation Ori = TopAbs_INTERNAL;
+ if (k == 0 || k == main_profiles.size() - 1)
+ Ori = TopAbs_FORWARD;
+ ll.Add(W.Oriented(Ori));
+ }
+
+ if (!RWire.IsNull())
+ ll.Add(RWire.Oriented(TopAbs_FORWARD));
+ //yes, add subshapes in this order (left + profiles + right)
+ //otherwise the projected wire will be non-manifold
+
+ return ll;
+ }
+
+
+ void HYDROData_DTM::Update()
+ {
+ AltitudePoints points;
+ TopoDS_Shape Out3dPres;
+ TopoDS_Shape Out2dPres;
+ TopoDS_Shape OutLeftB;
+ TopoDS_Shape OutRightB;
+ TopoDS_Shape OutInlet;
+ TopoDS_Shape OutOutlet;
+
+ HYDROData_SequenceOfObjects objs = GetProfiles();
+ double ddz = GetDDZ();
+ double step = GetSpatialStep();
+ std::set<int> InvInd;
+ bool WireIntersections; //__TODO
+ CreateProfilesFromDTM( objs, ddz, step, points, Out3dPres, Out2dPres, OutLeftB, OutRightB, OutInlet, OutOutlet, true, true, InvInd, -1, WireIntersections );
+ SetAltitudePoints( points );
+
+ SetShape( DataTag_LeftBankShape, OutLeftB);
+ SetShape( DataTag_RightBankShape, OutRightB);
+ SetShape( DataTag_InletShape, OutInlet);
+ SetShape( DataTag_OutletShape, OutOutlet );
+ SetShape( DataTag_3DShape, Out3dPres );
+ SetShape( DataTag_2DShape, Out2dPres );
+
+ HYDROData_Bathymetry::Update();
+ }
+
+ void HYDROData_DTM::GetPresentationShapes( TopoDS_Shape& Out3dPres,
+ TopoDS_Shape& Out2dPres,
+ TopoDS_Shape& OutLeftB,
+ TopoDS_Shape& OutRightB,
+ TopoDS_Shape& OutInlet,
+ TopoDS_Shape& OutOutlet )
+ {
+ //without update!
+ OutLeftB = GetShape( DataTag_LeftBankShape);
+ OutRightB = GetShape( DataTag_RightBankShape);
+ OutInlet = GetShape( DataTag_InletShape);
+ OutOutlet = GetShape( DataTag_OutletShape );
+ Out3dPres = GetShape( DataTag_3DShape );
+ Out2dPres = GetShape( DataTag_2DShape );
+ }
+ void HYDROData_DTM::CreateProfilesFromDTM (const HYDROData_SequenceOfObjects& InpProfiles,
+ double ddz,
+ double step,
+ AltitudePoints& points,
+ TopoDS_Shape& Out3dPres,
+ TopoDS_Shape& Out2dPres,
+ TopoDS_Shape& OutLeftB,
+ TopoDS_Shape& OutRightB,
+ TopoDS_Shape& OutInlet,
+ TopoDS_Shape& OutOutlet,
+ bool Create3dPres,
+ bool Create2dPres,
+ std::set<int>& InvInd,
+ int thePntsLimit,
+ bool& WireIntersections)
+ {
+ int aLower = InpProfiles.Lower(), anUpper = InpProfiles.Upper();
+ size_t n = anUpper - aLower + 1;
+
-void HYDROData_DTM::ProjWireOnPlane(const TopoDS_Shape& inpWire, const Handle_Geom_Plane& RefPlane,
++ std::vector<Handle(HYDROData_Profile)> profiles;
+ profiles.reserve( n );
+ for( int i=aLower; i<=anUpper; i++ )
+ {
+ Handle(HYDROData_Profile) aProfile = Handle(HYDROData_Profile)::DownCast( InpProfiles.Value( i ) );
+ if( !aProfile.IsNull() )
+ profiles.push_back( aProfile );
+ }
+ const double EPS = 1E-3;
+ AltitudePoints left;
+ AltitudePoints right;
+ std::vector<AltitudePoints> main_profiles;
+
+ if( thePntsLimit > 0 )
+ {
+ int aNbPoints = EstimateNbPoints( profiles, ddz, step );
+ if( aNbPoints < 0 || aNbPoints > thePntsLimit )
+ return;
+ }
+
+ if( ddz>EPS && step>EPS )
+ CreateProfiles(profiles, ddz, step, left, right, points, main_profiles,
+ Out3dPres, Out2dPres, OutLeftB, OutRightB, OutInlet, OutOutlet, Create3dPres, Create2dPres, InvInd, WireIntersections );
+ }
+
- Handle_Geom_Plane refpl = new Geom_Plane(gp_Pnt(0,0,0), gp_Dir(0,0,1));
++void HYDROData_DTM::ProjWireOnPlane(const TopoDS_Shape& inpWire, const Handle(Geom_Plane)& RefPlane,
+ TopTools_DataMapOfShapeListOfShape* E2PE)
+ {
+ BRep_Builder BB;
+
+ //project shape (edges) on planar face
+ TopoDS_Face F;
+ BB.MakeFace(F, RefPlane, Precision::Confusion());
+ BRepAlgo_NormalProjection nproj(F);
+ nproj.Add(inpWire);
+ nproj.SetDefaultParams();
+ nproj.Build();
+ if(!nproj.IsDone())
+ return;
+
+ TopoDS_Shape projRes = nproj.Projection();
+
+ // unite all vertexes/edges from projected result
+ BOPAlgo_Builder anAlgo;
+ TopExp_Explorer exp(projRes, TopAbs_EDGE);
+ for (;exp.More(); exp.Next())
+ {
+ const TopoDS_Edge& E = TopoDS::Edge(exp.Current());
+ if (E.Orientation() != TopAbs_INTERNAL)
+ anAlgo.AddArgument(E);
+ }
+ anAlgo.Perform();
+ int stat = anAlgo.ErrorStatus();
+ TopoDS_Shape projResConn = anAlgo.Shape();
+
+ // make wire => vertexes and edges should be untouched after this operation!
+ exp.Init(projResConn, TopAbs_EDGE);
+ //TopTools_ListOfShape llE;
+ //TopoDS_Wire RW;
+ //BRepLib_MakeWire WM;
+
+ //for (;exp.More();exp.Next())
+ // llE.Append(exp.Current());
+ //
+ //WM.Add(llE);
+ //outWire = WM.Wire();
+
+ //outWire.Orientation(inpWire.Orientation()); //take from the original wire
+
+ //history mode: edge to projected edges
+ if (E2PE)
+ {
+ TopExp_Explorer ex(inpWire, TopAbs_EDGE);
+ for (;ex.More();ex.Next())
+ {
+ const TopoDS_Edge& CE = TopoDS::Edge(ex.Current());
+ TopTools_ListOfShape NEL;
+ const TopTools_ListOfShape& LS = nproj.Generated(CE);
+ TopTools_ListIteratorOfListOfShape it(LS);
+ for (;it.More();it.Next())
+ {
+ const TopoDS_Shape& PCE = it.Value();
+ TopTools_ListOfShape PLS = anAlgo.Modified(PCE);
+ if (PLS.IsEmpty())
+ PLS.Append(PCE);
+ TopTools_ListIteratorOfListOfShape itp(PLS);
+ for (;itp.More();itp.Next())
+ NEL.Append(itp.Value());
+ }
+
+ E2PE->Bind(CE, NEL);
+ }
+ }
+ }
+ #include <TopTools_IndexedDataMapOfShapeListOfShape.hxx>
+ bool HYDROData_DTM::Get2dFaceFrom3dPres(const TopoDS_Compound& cmp, TopoDS_Face& outF,
+ TopTools_SequenceOfShape* Boundr, std::set<int> ind )
+ {
+ //ind : set of indices (starts with 0). index == number of boundary (inlet, outlet, etc..)
+ //in compound cmp.
+ //if Boundr is not null => this method will return sequence of boundary wires (inlet, outlet...)
+
-void HYDROData_DTM::CreateProfiles(const std::vector<Handle_HYDROData_Profile>& theProfiles,
++ Handle(Geom_Plane) refpl = new Geom_Plane(gp_Pnt(0,0,0), gp_Dir(0,0,1));
+ TopTools_DataMapOfShapeListOfShape E2PE;
+ ProjWireOnPlane(cmp, refpl, &E2PE);
+ TopTools_ListOfShape ELL;
+
+ TopoDS_Iterator it(cmp);
+ int i = 0;
+ for (;it.More(); it.Next())
+ {
+ const TopoDS_Wire& W = TopoDS::Wire(it.Value());
+ if (W.Orientation() != TopAbs_INTERNAL)
+ {
+ TopoDS_Wire PW;
+ TopExp_Explorer ex(W, TopAbs_EDGE);
+ TopTools_ListOfShape LEpW;
+ TopTools_ListOfShape LEpWDummy;
+ for (;ex.More();ex.Next())
+ {
+ const TopoDS_Edge& CE = TopoDS::Edge(ex.Current());
+ TopTools_ListOfShape LS = E2PE.Find(CE);
+ LEpW.Append(LS);
+ }
+
+ if (ind.count(i) != 0)
+ {
+ BRepLib_MakeWire WM;
+ WM.Add(LEpW);
+ const TopoDS_Wire& WMW = WM.Wire();
+ //assume that wire is a straight line,
+ //take first and last vertex and make simple edge (RE)
+ TopoDS_Vertex VF, VL;
+ TopExp::Vertices(WMW, VF, VL);
+ TopoDS_Edge RE = BRepLib_MakeEdge(VF, VL).Edge();
+ if (RE.IsNull())
+ {
+ LEpWDummy = LEpW; //LEpW will be nullified after appending to ELL
+ ELL.Append(LEpW);
+ }
+ else
+ {
+ LEpWDummy.Append(RE);
+ ELL.Append(RE);
+ }
+ //TODO: in the new version of OCCT, USD can process separate wires
+ //ShapeUpgrade_UnifySameDomain USD(WMW, 1U, 0U, 1U); //concat bsplines
+ //USD.Build();
+ //const TopoDS_Shape& RSU = USD.Shape();
+ //TopExp_Explorer exp(RSU, TopAbs_EDGE);
+ //TopTools_ListOfShape DummyL;
+ //for (;it.More();it.Next())
+ // DummyL.Append(it.Value());
+ //if (DummyL.Extent() == 1)
+ // ELL.Append(DummyL.First()); //if one edge => accept this result
+ //else
+ // ELL.Append(LEpW); //else put 'as is'
+ }
+ else
+ {
+ LEpWDummy = LEpW;
+ ELL.Append(LEpW);
+ }
+
+ if (Boundr)
+ {
+ //make inlet, outlet, left/tight banks [wires]
+ //shouldn't change topology of the edges
+ BRepLib_MakeWire IWM;
+ IWM.Add(LEpWDummy);
+ Boundr->Append(IWM.Wire());
+ }
+ }
+ i++;
+ }
+
+ //make primary wire
+ BRepLib_MakeWire WME;
+ WME.Add(ELL);
+
+ const TopoDS_Wire& resW = WME.Wire();
+ BRepBuilderAPI_MakeFace mf(refpl, resW, true); //check inside is true by def
+ outF = mf.Face();
+
+ ShapeAnalysis_Wire WA(resW, outF, Precision::Confusion());
+ bool res = WA.CheckSelfIntersection(); //TODO check that this return false if OK
+ return res;
+
+ ///!!! the internal wires cant be added with 'internal' ori.
+ // it's possible to do with brep builder yet the result will not be correct!
+ // more proper way is to use BOP operation here.
+ /*for (int i = 1; i <= IntW.Extent(); i++)
+ {
+ TopoDS_Wire outIW;
+ const TopoDS_Wire& W = TopoDS::Wire(IntW(i));
+ ProjWireOnPlane(W, refpl, outIW);
+ BB.Add(outF, outIW);
+ }*/
+ }
+
-void HYDROData_DTM::GetProperties( const Handle_HYDROData_Profile& theProfile,
++void HYDROData_DTM::CreateProfiles(const std::vector<Handle(HYDROData_Profile)>& theProfiles,
+ double theDDZ,
+ double theSpatialStep,
+ AltitudePoints& theOutLeft,
+ AltitudePoints& theOutRight,
+ AltitudePoints& theOutPoints,
+ std::vector<AltitudePoints>& theOutMainProfiles,
+ TopoDS_Shape& Out3dPres,
+ TopoDS_Shape& Out2dPres,
+ TopoDS_Shape& OutLeftB,
+ TopoDS_Shape& OutRightB,
+ TopoDS_Shape& OutInlet,
+ TopoDS_Shape& OutOutlet,
+ bool Create3dPres,
+ bool Create2dPres,
+ std::set<int>& InvInd,
+ bool& WireIntersections)
+ {
+ if (theProfiles.empty())
+ return;
+ theOutPoints = Interpolate( theProfiles, theDDZ, theSpatialStep, theOutLeft, theOutRight, theOutMainProfiles, InvInd );
+ //note that if Create3dPres is false => Create2dPres flag is meaningless!
+ if (Create3dPres)
+ {
+ TopTools_IndexedMapOfOrientedShape ll = Create3DShape( theOutLeft, theOutRight, theOutMainProfiles);
+
+ if (ll.IsEmpty())
+ return;
+ BRep_Builder BB;
+ TopoDS_Compound cmp;
+ BB.MakeCompound(cmp);
+ for (int i = 1; i <= ll.Extent(); i++)
+ BB.Add(cmp, ll(i));
+
+ Out3dPres = cmp;
+
+ //same order as in HYDROData_DTM::Update()
+ OutLeftB = ll(1);
+ OutRightB = ll(ll.Extent());
+ OutInlet = ll(2);
+ OutOutlet = ll(ll.Extent() - 1);
+
+ if (Create2dPres)
+ {
+ TopoDS_Face outF;
+ WireIntersections = Get2dFaceFrom3dPres(cmp, outF); //__TODO
+ Out2dPres = outF;
+ };
+ }
+ }
+
+
+
+
- Handle_Geom2d_Line aLine2d = new Geom2d_Line( aFirst2d, gp_Dir2d( dir.X(), dir.Y() ) );
++void HYDROData_DTM::GetProperties( const Handle(HYDROData_Profile)& theProfile,
+ gp_Pnt& theLowestPoint, gp_Vec2d& theDir,
+ bool isNormalDir,
+ double& theZMin, double& theZMax )
+ {
+ theLowestPoint = theProfile->GetBottomPoint();
+
+ gp_XY aLeft, aRight;
+ theProfile->GetLeftPoint( aLeft, true, true );
+ theProfile->GetRightPoint( aRight, true, true );
+ double x = aRight.X()-aLeft.X();
+ double y = aRight.Y()-aLeft.Y();
+ if( isNormalDir )
+ theDir = gp_Vec2d( -y, x );
+ else
+ theDir = gp_Vec2d( x, y );
+
+ HYDROData_Profile::ProfilePoints points = theProfile->GetProfilePoints();
+ int lo = points.Lower();
+ int up = points.Upper();
+ theZMin = std::numeric_limits<double>::max();
+ theZMax = -theZMin;
+ for( int i=lo; i<=up; i++ )
+ {
+ double z = points.Value( i ).Z();
+ if( z>theZMax )
+ theZMax = z;
+ if( z<theZMin )
+ theZMin = z;
+ }
+ }
+
+ inline gp_Pnt2d To2D( const gp_Pnt& thePnt, const gp_Trsf& theTr,
+ double& theUMin, double& theUMax )
+ {
+ gp_Pnt p = thePnt.Transformed( theTr );
+ double u = p.X();
+ double z = p.Z();
+ if( u<theUMin )
+ theUMin = u;
+ if( u>theUMax )
+ theUMax = u;
+ return gp_Pnt2d( u, z );
+ }
+
+ Handle(TColgp_HArray1OfPnt2d) To2D( const TColgp_Array1OfPnt& thePoints,
+ const gp_Trsf& theTr,
+ double& theUMin, double& theUMax )
+ {
+ int low = thePoints.Lower(), up = thePoints.Upper();
+ Handle(TColgp_HArray1OfPnt2d) points = new TColgp_HArray1OfPnt2d( low, up );
+ for( int i=low; i<=up; i++ )
+ points->SetValue( i, To2D( thePoints.Value( i ), theTr, theUMin, theUMax ) );
+ return points;
+ }
+
+ Handle(Geom2d_Curve) CurveTo2D( const Handle(Geom_Curve)& theCurve,
+ Standard_Real theFirst, Standard_Real theLast,
+ const gp_Trsf& theTr,
+ double& theUMin, double& theUMax )
+ {
+ if( theCurve->IsKind( STANDARD_TYPE( Geom_Line ) ) )
+ {
+ gp_Pnt aFirstPnt, aLastPnt;
+ theCurve->D0( theFirst, aFirstPnt );
+ theCurve->D0( theLast, aLastPnt );
+
+ gp_Pnt2d
+ aFirst2d = To2D( aFirstPnt, theTr, theUMin, theUMax ),
+ aLast2d = To2D( aLastPnt, theTr, theUMin, theUMax );
+
+ gp_Vec2d dir( aFirst2d, aLast2d );
-Handle_Geom2d_BSplineCurve HYDROData_DTM::CreateHydraulicAxis(
- const std::vector<Handle_HYDROData_Profile>& theProfiles,
++ Handle(Geom2d_Line) aLine2d = new Geom2d_Line( aFirst2d, gp_Dir2d( dir.X(), dir.Y() ) );
+ return new Geom2d_TrimmedCurve( aLine2d, 0, aLast2d.Distance( aFirst2d ) );
+ }
+
+ if( theCurve->IsKind( STANDARD_TYPE( Geom_BSplineCurve ) ) )
+ {
+ Handle(Geom_BSplineCurve) aSpline = Handle(Geom_BSplineCurve)::DownCast( theCurve );
+
+ Handle(TColgp_HArray1OfPnt2d) poles = To2D( aSpline->Poles(), theTr, theUMin, theUMax );
+ const TColStd_Array1OfReal& knots = aSpline->Knots();
+ const TColStd_Array1OfInteger& multiplicities = aSpline->Multiplicities();
+ int aDegree = aSpline->Degree();
+
+ return new Geom2d_BSplineCurve( poles->Array1(), knots, multiplicities, aDegree );
+ }
+
+ return Handle(Geom2d_Curve)();
+ }
+
- Handle_Geom2d_BSplineCurve aResult;
++Handle(Geom2d_BSplineCurve) HYDROData_DTM::CreateHydraulicAxis(
++ const std::vector<Handle(HYDROData_Profile)>& theProfiles,
+ std::vector<double>& theDistances )
+ {
+ size_t n = theProfiles.size();
- Handle_HYDROData_Profile aProfile = theProfiles[i-1];
++ Handle(Geom2d_BSplineCurve) aResult;
+
+ Handle(TColgp_HArray1OfPnt2d) points = new TColgp_HArray1OfPnt2d( 1, (int)n );
+ TColgp_Array1OfVec2d tangents( 1, (int)n );
+ Handle(TColStd_HArray1OfBoolean) flags = new TColStd_HArray1OfBoolean( 1, (int)n );
+
+ for( size_t i = 1; i <= n; i++ )
+ {
-std::vector<Handle_Geom2d_Curve> HYDROData_DTM::ProfileToParametric(
- const Handle_HYDROData_Profile& theProfile,
++ Handle(HYDROData_Profile) aProfile = theProfiles[i-1];
+ aProfile->Update();
+
+ gp_Pnt aLowest;
+ gp_Vec2d aTangent;
+ double zmin, zmax;
+ GetProperties( aProfile, aLowest, aTangent, true, zmin, zmax );
+ aTangent.Normalize();
+
+ points->SetValue( (int)i, gp_Pnt2d( aLowest.X(), aLowest.Y() ) );
+ tangents.SetValue( (int)i, aTangent );
+ flags->SetValue( (int)i, Standard_True );
+ }
+
+ Geom2dAPI_Interpolate anInterpolator( points, Standard_False, Standard_False );
+ anInterpolator.Load( tangents, flags );
+ anInterpolator.Perform();
+ if( anInterpolator.IsDone() )
+ {
+ aResult = anInterpolator.Curve();
+
+ //fill the distances vector
+ Geom2dAdaptor_Curve anAdaptor( aResult );
+
+ theDistances.clear();
+ theDistances.reserve( n );
+ Standard_Real aParamFirst = anAdaptor.FirstParameter(), aParamLast = anAdaptor.LastParameter();
+ for( size_t i = 1; i <= n; i++ )
+ {
+ gp_Pnt2d aPnt = points->Value( (Standard_Integer)i );
+ Geom2dAPI_ProjectPointOnCurve aProject( aPnt, aResult );
+ Standard_Real aParam = aProject.LowerDistanceParameter();
+ double aDistance = GCPnts_AbscissaPoint::Length( anAdaptor, aParamFirst, aParam );
+ theDistances.push_back( aDistance );
+ }
+ }
+ return aResult;
+ }
+
- std::vector<Handle_Geom2d_Curve> curves;
++std::vector<Handle(Geom2d_Curve)> HYDROData_DTM::ProfileToParametric(
++ const Handle(HYDROData_Profile)& theProfile,
+ double& theUMin, double& theUMax, gp_Vec2d& theDir )
+ {
-void HYDROData_DTM::ProfileDiscretization( const Handle_HYDROData_Profile& theProfile,
++ std::vector<Handle(Geom2d_Curve)> curves;
+
+ // Transformation of the coordinate systems
+ gp_Pnt aLowest;
+ double zmin, zmax;
+ GetProperties( theProfile, aLowest, theDir, false, zmin, zmax );
+
+ gp_Ax3 aStd3d( gp_Pnt( 0, 0, 0 ), gp_Dir( 0, 0, 1 ), gp_Dir( 1, 0, 0 ) );
+ gp_Ax3 aLocal( gp_Pnt( aLowest.X(), aLowest.Y(), 0 ), gp_Dir( 0, 0, 1 ), gp_Dir( theDir.X(), theDir.Y(), 0 ) );
+
+ gp_Trsf aTransf;
+ aTransf.SetTransformation( aStd3d, aLocal );
+
+ // Iteration via edges
+ TopoDS_Wire aWire = TopoDS::Wire( theProfile->GetShape3D() );
+ TopExp_Explorer anExp( aWire, TopAbs_EDGE );
+ for( ; anExp.More(); anExp.Next() )
+ {
+ // Extract an edge from wire
+ TopoDS_Edge anEdge = TopoDS::Edge( anExp.Current() );
+
+ // Extract a curve corresponding to the edge
+ TopLoc_Location aLoc;
+ Standard_Real aFirst, aLast;
+ Handle(Geom_Curve) aCurve = BRep_Tool::Curve( anEdge, aLoc, aFirst, aLast );
+
+ // Convert the curve to 2d CS
+ Handle(Geom2d_Curve) aCurve2d = CurveTo2D( aCurve, aFirst, aLast, aTransf, theUMin, theUMax );
+ if( !aCurve2d.IsNull() )
+ curves.push_back( aCurve2d );
+ }
+ return curves;
+ }
+
+
+ bool CalcMidWidth( const std::set<double>& intersections, double& theMid, double& theWid )
+ {
+ double umin = std::numeric_limits<double>::max(),
+ umax = -umin;
+
+ size_t n = intersections.size();
+ if( n <= 0 )
+ return false;
+
+ std::set<double>::const_iterator it = intersections.begin(), last = intersections.end();
+ for( ; it!=last; it++ )
+ {
+ double u = *it;
+ if( u<umin )
+ umin = u;
+ if( u>umax )
+ umax = u;
+ }
+ theMid = ( umin+umax )/2;
+ theWid = umax-umin;
+ return true;
+ }
+
- std::vector<Handle_Geom2d_Curve> curves = ProfileToParametric( theProfile, aUMin, aUMax, aProfileDir );
++void HYDROData_DTM::ProfileDiscretization( const Handle(HYDROData_Profile)& theProfile,
+ double theXCurv, double theMinZ, double theMaxZ, double theDDZ,
+ CurveUZ& theMidPointCurve,
+ CurveUZ& theWidthCurve,
+ int& intersection_nb,
+ double theTolerance)
+ {
+ double aDblMax = std::numeric_limits<double>::max(),
+ aUMin = aDblMax,
+ aUMax = -aUMin,
+ aVMax = 1000000;
+
+ gp_Vec2d aProfileDir;
- Handle_Geom2d_Curve aCurve = curves[i];
++ std::vector<Handle(Geom2d_Curve)> curves = ProfileToParametric( theProfile, aUMin, aUMax, aProfileDir );
+ size_t n = curves.size();
+
+ if( n==0 )
+ return;
+
+ // we add the "virtual" vertical lines to simulate the intersection with profile
+ gp_Pnt2d aFirst, aLast;
+ curves[0]->D0( curves[0]->FirstParameter(), aFirst );
+ curves[n-1]->D0( curves[n-1]->LastParameter(), aLast );
+ Handle(Geom2d_Line) aV1 = new Geom2d_Line( aFirst, gp_Dir2d( 0, 1 ) );
+ Handle(Geom2d_TrimmedCurve) aT1 = new Geom2d_TrimmedCurve( aV1, 0.0, aVMax );
+
+ Handle(Geom2d_Line) aV2 = new Geom2d_Line( aLast, gp_Dir2d( 0, 1 ) );
+ Handle(Geom2d_TrimmedCurve) aT2 = new Geom2d_TrimmedCurve( aV2, 0.0, aVMax );
+
+ curves.push_back( aT1 );
+ curves.push_back( aT2 );
+
+ int psize = ( int )( ( theMaxZ-theMinZ ) / theDDZ + 1 );
+ theMidPointCurve = CurveUZ( theXCurv, aProfileDir, theMinZ );
+ theMidPointCurve.reserve( psize );
+ theWidthCurve = CurveUZ( theXCurv, aProfileDir, theMinZ );
+ theWidthCurve.reserve( psize );
+
+ n = curves.size();
+ // for each discrete value of z we search intersection with profile
+ for( double z1 = theMinZ; z1 <= theMaxZ; z1 += theDDZ )
+ {
+ Handle(Geom2d_Line) aLine = new Geom2d_Line( gp_Pnt2d( 0, z1 ), gp_Dir2d( 1, 0 ) );
+ std::set<double> intersections;
+ for( size_t i = 0; i < n; i++ )
+ {
-void HYDROData_DTM::CurveTo3D( const Handle_Geom2d_BSplineCurve& theHydraulicAxis,
++ Handle(Geom2d_Curve) aCurve = curves[i];
+ Geom2dAPI_InterCurveCurve anIntersect( aCurve, aLine, theTolerance );
+ for( int k=1, m=anIntersect.NbPoints(); k<=m; k++ )
+ intersections.insert( anIntersect.Point( k ).X() );
+ }
+
+ intersection_nb = intersections.size();
+ if( intersection_nb >= 1 )
+ {
+ double u_mid, u_wid;
+ if( !CalcMidWidth( intersections, u_mid, u_wid ) )
+ continue;
+
+ double z = z1 - theMinZ;
+ PointUZ p_mid;
+ p_mid.U = u_mid;
+ p_mid.Z = z;
+ theMidPointCurve.push_back( p_mid );
+
+ PointUZ p_wid;
+ p_wid.U = u_wid;
+ p_wid.Z = z;
+ theWidthCurve.push_back( p_wid );
+ }
+ }
+ }
+
+ void HYDROData_DTM::Interpolate( const CurveUZ& theCurveA, const CurveUZ& theCurveB,
+ int theNbSteps, std::vector<CurveUZ>& theInterpolation,
+ bool isAddSecond )
+ {
+ theInterpolation.clear();
+ int d = isAddSecond ? 2 : 1;
+ theInterpolation.reserve( theNbSteps+d );
+ double dt = 1.0 / double( theNbSteps + 1 );
+ double t = dt;
+ theInterpolation.push_back( theCurveA );
+ for( int i=0; i<theNbSteps; i++, t+=dt )
+ {
+ CurveUZ anInterp = theCurveA*(1-t) + theCurveB*t;
+ theInterpolation.push_back( anInterp );
+ }
+ if( isAddSecond )
+ theInterpolation.push_back( theCurveB );
+ }
+ #include <BRepLib_MakeEdge2d.hxx>
- ( const Handle_Geom2d_BSplineCurve& theHydraulicAxis,
- const Handle_HYDROData_Profile& theProfileA,
++void HYDROData_DTM::CurveTo3D( const Handle(Geom2d_BSplineCurve)& theHydraulicAxis,
+ const CurveUZ& theMidCurve, const CurveUZ& theWidthCurve,
+ AltitudePoints& thePoints )
+ {
+ Geom2dAdaptor_Curve anAdaptor( theHydraulicAxis );
+ TopoDS_Edge E2d = BRepLib_MakeEdge2d(theHydraulicAxis).Edge();
+ GCPnts_AbscissaPoint ap( anAdaptor, theMidCurve.Xcurv(), anAdaptor.FirstParameter() );
+ double aParam = ap.Parameter();
+
+ gp_Pnt2d point;
+ anAdaptor.D0( aParam, point );
+ gp_Vec2d profile_dir = theMidCurve.ProfileDir();
+ //gp_Dir tangent_n( -profile_dir.Y(), profile_dir.X(), dz );
+ profile_dir.Normalize();
+
+ size_t n = theMidCurve.size();
+ std::map<double, AltitudePoint> sorted_points;
+ for( size_t i=0; i<n; i++ )
+ {
+ double param1 = theMidCurve[i].U - theWidthCurve[i].U / 2;
+ double param2 = theMidCurve[i].U + theWidthCurve[i].U / 2;
+
+ gp_Pnt2d p1 = point.Translated( param1 * profile_dir);
+ gp_Pnt2d p2 = point.Translated( param2 * profile_dir);
+
+ double z = theMidCurve[i].Z + theMidCurve.DeltaZ();
+
+ AltitudePoint p3d_1( p1.X(), p1.Y(), z ), p3d_2( p2.X(), p2.Y(), z );
+
+ sorted_points[param1] = p3d_1;
+ sorted_points[param2] = p3d_2;
+ }
+
+ thePoints.reserve( sorted_points.size() );
+ const double EPS = 1E-12;
+ std::map<double, AltitudePoint>::const_iterator it = sorted_points.begin(), last = sorted_points.end();
+ for( ; it!=last; it++ )
+ if( thePoints.empty() || thePoints.back().SquareDistance( it->second ) > EPS )
+ thePoints.push_back( it->second );
+ }
+
+ inline double max( double a, double b )
+ {
+ if( a>b )
+ return a;
+ else
+ return b;
+ }
+
+ inline double min( double a, double b )
+ {
+ if( a<b )
+ return a;
+ else
+ return b;
+ }
+
+ #include <BRepLib_MakeWire.hxx>
+
+ std::vector<HYDROData_Bathymetry::AltitudePoints> HYDROData_DTM::Interpolate
- const Handle_HYDROData_Profile& theProfileB,
++ ( const Handle(Geom2d_BSplineCurve)& theHydraulicAxis,
++ const Handle(HYDROData_Profile)& theProfileA,
+ double theXCurvA,
- ( const std::vector<Handle_HYDROData_Profile>& theProfiles,
++ const Handle(HYDROData_Profile)& theProfileB,
+ double theXCurvB,
+ double theDDZ, int theNbSteps, bool isAddSecond,
+ int& inter_nb_1, int& inter_nb_2)
+ {
+ double zminA, zmaxA, zminB, zmaxB;
+ gp_Pnt lowestA, lowestB;
+ gp_Vec2d dirA, dirB;
+
+ GetProperties( theProfileA, lowestA, dirA, false, zminA, zmaxA );
+ GetProperties( theProfileB, lowestB, dirB, false, zminB, zmaxB );
+
+
+ double hmax = max( zmaxA-zminA, zmaxB-zminB );
+
+ //double dz = zminB - zminA;
+ //double zmin = min( zminA, zminB );
+ //double zmax = max( zmaxA, zmaxB );
+
+ CurveUZ midA(0, gp_Vec2d(), 0), midB(0, gp_Vec2d(), 0);
+ CurveUZ widA(0, gp_Vec2d(), 0), widB(0, gp_Vec2d(), 0);
+
+ ProfileDiscretization( theProfileA, theXCurvA, zminA, zminA+hmax, theDDZ, midA, widA, inter_nb_1 );
+ ProfileDiscretization( theProfileB, theXCurvB, zminB, zminB+hmax, theDDZ, midB, widB, inter_nb_2 );
+
+ std::vector<CurveUZ> mid, wid;
+ Interpolate( midA, midB, theNbSteps, mid, isAddSecond );
+ Interpolate( widA, widB, theNbSteps, wid, isAddSecond );
+
+ size_t p = mid.size();
+ size_t q = p>0 ? 2*mid[0].size() : 1;
+ std::vector<AltitudePoints> points;
+ points.resize( p );
+
+ for( size_t i=0; i<p; i++ )
+ {
+ points[i].reserve( q );
+ CurveTo3D( theHydraulicAxis, mid[i], wid[i], points[i] );
+ }
+
+ return points;
+ }
+
+ HYDROData_Bathymetry::AltitudePoints HYDROData_DTM::Interpolate
- Handle_Geom2d_BSplineCurve aHydraulicAxis = CreateHydraulicAxis( theProfiles, distances );
++ ( const std::vector<Handle(HYDROData_Profile)>& theProfiles,
+ double theDDZ, double theSpatialStep,
+ AltitudePoints& theLeft,
+ AltitudePoints& theRight,
+ std::vector<AltitudePoints>& theMainProfiles,
+ std::set<int>& invalInd)
+ {
+ AltitudePoints points;
+ size_t n = theProfiles.size();
+ if( n<=1 )
+ return points;
+
+ std::vector<double> distances;
-int HYDROData_DTM::EstimateNbPoints( const std::vector<Handle_HYDROData_Profile>& theProfiles,
++ Handle(Geom2d_BSplineCurve) aHydraulicAxis = CreateHydraulicAxis( theProfiles, distances );
+ if( aHydraulicAxis.IsNull() )
+ return points;
+
+ theMainProfiles.reserve( n );
+
+ for( size_t i=0, n1=n-1; i<n1; i++ )
+ {
+ double aDistance = distances[i+1]-distances[i];
+ int aNbSteps = int(aDistance/theSpatialStep);
+ bool isAddSecond = i==n1-1;
+
+ // 1. Calculate interpolated profiles
+ int inter_nb_1, inter_nb_2;
+ std::vector<AltitudePoints> local_points = Interpolate( aHydraulicAxis, theProfiles[i], distances[i],
+ theProfiles[i+1], distances[i+1], theDDZ, aNbSteps, isAddSecond, inter_nb_1, inter_nb_2 );
+ int lps = local_points.size();
+
+ if (inter_nb_1 > 2)
+ invalInd.insert(i);
+
+ if (inter_nb_2 > 2)
+ invalInd.insert(i+1);
+
+ // 2. Put all points into the global container
+ for( size_t j=0; j<lps; j++ )
+ {
+ const AltitudePoints& lp = local_points[j];
+ if( i==0 && j==0 )
+ points.reserve( lp.size() * n );
+ for( size_t k=0, ks=lp.size(); k<ks; k++ )
+ points.push_back( lp[k] );
+ }
+
+ // 3. Get left/right banks' points
+ if( i==0 )
+ {
+ theLeft.reserve( lps * n );
+ theRight.reserve( lps * n );
+ }
+ for( size_t j=0; j<lps; j++ )
+ {
+ const AltitudePoints& lp = local_points[j];
+ theLeft.push_back( lp[0] );
+ theRight.push_back( lp[lp.size()-1] );
+ }
+
+ // 4. Get main profiles points
+ theMainProfiles.push_back( local_points[0] );
+ if( isAddSecond )
+ theMainProfiles.push_back( local_points[lps-1] );
+ }
+ return points;
+ }
+
- Handle_Geom2d_BSplineCurve aHydraulicAxis = CreateHydraulicAxis( theProfiles, distances );
++int HYDROData_DTM::EstimateNbPoints( const std::vector<Handle(HYDROData_Profile)>& theProfiles,
+ double theDDZ, double theSpatialStep )
+ {
+ size_t n = theProfiles.size();
+ if( n<=1 )
+ return 0;
+ if( theDDZ<1E-6 || theSpatialStep<1E-6 )
+ return 1 << 20;
+
+ std::vector<double> distances;
++ Handle(Geom2d_BSplineCurve) aHydraulicAxis = CreateHydraulicAxis( theProfiles, distances );
+ if( aHydraulicAxis.IsNull() )
+ return 0;
+
+ double aCompleteDistance = distances[n-1];
+ int aNbSteps = int( aCompleteDistance / theSpatialStep ) + 1;
+ gp_Pnt aLowest;
+ gp_Vec2d aDir;
+ double aZMin, aZMax;
+ GetProperties( theProfiles[0], aLowest, aDir, true, aZMin, aZMax );
+ int aNbZSteps = (aZMax-aZMin)/theDDZ;
+
+ if( aNbSteps > ( 1<<16 ) || aNbZSteps > ( 1<<16 ) )
+ return 1 << 20;
+
+ return aNbSteps * aNbZSteps;
+ }
--- /dev/null
-#include <gp_Pnt2d.hxx>
+ // 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
+ //
+
+ #ifndef HYDROData_DTM_HeaderFile
+ #define HYDROData_DTM_HeaderFile
+
+ #include "HYDROData_Bathymetry.h"
++#include "HYDROData_Profile.h"
++
++#include <gp_Pnt2d.hxx>
++
++#include<Geom2d_BSplineCurve.hxx>
++#include<Geom2d_Curve.hxx>
++#include<Geom_Plane.hxx>
++
++#include <TopTools_DataMapOfShapeListOfShape.hxx>
++#include <TopTools_IndexedMapOfOrientedShape.hxx>
++#include <TopTools_SequenceOfShape.hxx>
++
+ #include <vector>
+ #include <set>
-class Handle_HYDROData_Profile;
-class Handle_Geom2d_BSplineCurve;
-class Handle_Geom2d_Curve;
+
-class Handle_Geom_Plane;
-class TopTools_IndexedMapOfOrientedShape;
-class TopTools_DataMapOfShapeListOfShape;
-class TopTools_SequenceOfShape;
+ class gp_Pnt;
+ class gp_Vec2d;
+ class TopoDS_Edge;
+ class TopoDS_Wire;
+ class TopoDS_Face;
+ class TopoDS_Compound;
-DEFINE_STANDARD_HANDLE( HYDROData_DTM, HYDROData_Bathymetry )
+
- DEFINE_STANDARD_RTTI( HYDROData_DTM );
+
+ /**\class HYDROData_DTM
+ * \brief Class that represents the Digital Terrain Model
+ */
+ class HYDROData_DTM : public HYDROData_Bathymetry
+ {
+ protected:
+ /**
+ * Enumeration of tags corresponding to the persistent object parameters.
+ */
+ enum DataTag
+ {
+ DataTag_First = HYDROData_Bathymetry::DataTag_First + 100, ///< first tag, to reserve
+ DataTag_Profiles,
+ DataTag_DDZ,
+ DataTag_SpatialStep,
+ DataTag_LeftBankShape,
+ DataTag_RightBankShape,
+ DataTag_InletShape,
+ DataTag_OutletShape,
+ DataTag_3DShape,
+ DataTag_2DShape
+ };
+
+ public:
- static Handle_Geom2d_BSplineCurve CreateHydraulicAxis(
- const std::vector<Handle_HYDROData_Profile>& theProfiles,
++ DEFINE_STANDARD_RTTIEXT( HYDROData_DTM, HYDROData_Bathymetry );
+
+ HYDRODATA_EXPORT HYDROData_SequenceOfObjects GetProfiles() const;
+ HYDRODATA_EXPORT void SetProfiles( const HYDROData_SequenceOfObjects& );
+
+ HYDRODATA_EXPORT double GetDDZ() const;
+ HYDRODATA_EXPORT void SetDDZ( double );
+
+ HYDRODATA_EXPORT double GetSpatialStep() const;
+ HYDRODATA_EXPORT void SetSpatialStep( double );
+
+ HYDRODATA_EXPORT virtual void Update();
+
+ public:
+ struct PointUZ
+ {
+ PointUZ( double u=0, double z=0 ) { U=u; Z=z; }
+ double U;
+ double Z;
+ };
+ class CurveUZ : public std::vector<PointUZ>
+ {
+ public:
+ CurveUZ( double theXcurv, const gp_Vec2d& theProfileDir, double theDeltaZ );
+ ~CurveUZ();
+
+ double Xcurv() const;
+ gp_Vec2d ProfileDir() const;
+ double DeltaZ() const;
+
+ CurveUZ operator + ( const CurveUZ& ) const;
+ CurveUZ operator * ( double ) const;
+
+ private:
+ double myXcurv;
+ gp_Vec2d myProfileDir;
+ double myDeltaZ;
+ };
+
+ protected:
+ friend class HYDROData_Stream;
+ friend class HYDROData_Iterator;
+ friend class test_HYDROData_DTM;
+
+ HYDRODATA_EXPORT HYDROData_DTM();
+ virtual HYDRODATA_EXPORT ~HYDROData_DTM();
+
- static std::vector<Handle_Geom2d_Curve> ProfileToParametric( const Handle_HYDROData_Profile& theProfile,
- double& theUMin, double& theUMax,
- gp_Vec2d& theDir );
++ static Handle(Geom2d_BSplineCurve) CreateHydraulicAxis(
++ const std::vector<Handle(HYDROData_Profile)>& theProfiles,
+ std::vector<double>& theDistances );
+
- static void GetProperties( const Handle_HYDROData_Profile& theProfile,
++ static std::vector<Handle(Geom2d_Curve)> ProfileToParametric( const Handle(HYDROData_Profile)& theProfile,
++ double& theUMin, double& theUMax,
++ gp_Vec2d& theDir );
+
- static void ProfileDiscretization( const Handle_HYDROData_Profile& theProfile,
++ static void GetProperties( const Handle(HYDROData_Profile)& theProfile,
+ gp_Pnt& theLowestPoint, gp_Vec2d& theDir,
+ bool isNormalDir,
+ double& theZMin, double& theZMax );
+
- static void CurveTo3D( const Handle_Geom2d_BSplineCurve& theHydraulicAxis,
++ static void ProfileDiscretization( const Handle(HYDROData_Profile)& theProfile,
+ double theXCurv, double theMinZ, double theMaxZ, double theDDZ,
+ CurveUZ& theMidPointCurve,
+ CurveUZ& theWidthCurve,
+ int& intersection_nb,
+ double theTolerance = 1E-6 );
+
- ( const Handle_Geom2d_BSplineCurve& theHydraulicAxis,
- const Handle_HYDROData_Profile& theProfileA,
++ static void CurveTo3D( const Handle(Geom2d_BSplineCurve)& theHydraulicAxis,
+ const CurveUZ& theMidCurve, const CurveUZ& theWidthCurve,
+ AltitudePoints& thePoints );
+
+ static void Interpolate( const CurveUZ& theCurveA, const CurveUZ& theCurveB,
+ int theNbSteps, std::vector<CurveUZ>& theInterpolation,
+ bool isAddSecond );
+
+ static std::vector<AltitudePoints> Interpolate
- const Handle_HYDROData_Profile& theProfileB,
++ ( const Handle(Geom2d_BSplineCurve)& theHydraulicAxis,
++ const Handle(HYDROData_Profile)& theProfileA,
+ double theXCurvA,
- static AltitudePoints Interpolate( const std::vector<Handle_HYDROData_Profile>& theProfiles,
++ const Handle(HYDROData_Profile)& theProfileB,
+ double theXCurvB,
+ double theDDZ, int theNbSteps, bool isAddSecond,
+ int& inter_nb_1, int& inter_nb_2 );
+
- static void ProjWireOnPlane(const TopoDS_Shape& inpWire, const Handle_Geom_Plane& RefPlane,
++ static AltitudePoints Interpolate( const std::vector<Handle(HYDROData_Profile)>& theProfiles,
+ double theDDZ, double theSpatialStep,
+ AltitudePoints& theLeft,
+ AltitudePoints& theRight,
+ std::vector<AltitudePoints>& theMainProfiles,
+ std::set<int>& invalInd );
+
+ static void PointToWire(const AltitudePoints& pnts, TopoDS_Wire& W );
+
- static void CreateProfiles(const std::vector<Handle_HYDROData_Profile>& theProfiles,
++ static void ProjWireOnPlane(const TopoDS_Shape& inpWire, const Handle(Geom_Plane)& RefPlane,
+ TopTools_DataMapOfShapeListOfShape* E2PE);
+
+ static TopTools_IndexedMapOfOrientedShape Create3DShape(const AltitudePoints& left,
+ const AltitudePoints& right,
+ const std::vector<AltitudePoints>& main_profiles);
+
- static int EstimateNbPoints( const std::vector<Handle_HYDROData_Profile>& theProfiles,
++ static void CreateProfiles(const std::vector<Handle(HYDROData_Profile)>& theProfiles,
+ double theDDZ,
+ double theSpatialStep,
+ AltitudePoints& theOutLeft,
+ AltitudePoints& theOutRight,
+ AltitudePoints& theOutPoints,
+ std::vector<AltitudePoints>& theOutMainProfiles,
+ TopoDS_Shape& Out3dPres,
+ TopoDS_Shape& Out2dPres,
+ TopoDS_Shape& OutLeftB,
+ TopoDS_Shape& OutRightB,
+ TopoDS_Shape& OutInlet,
+ TopoDS_Shape& OutOutlet,
+ bool Create3dPres,
+ bool Create2dPres,
+ std::set<int>& InvInd,
+ bool& WireIntersections);
+
+ static bool Get2dFaceFrom3dPres(const TopoDS_Compound& cmp, TopoDS_Face& outF,
+ TopTools_SequenceOfShape* Boundr = NULL, std::set<int> ind = std::set<int>() );
+
++ static int EstimateNbPoints( const std::vector<Handle(HYDROData_Profile)>& theProfiles,
+ double theDDZ, double theSpatialStep );
+
+ void GetPresentationShapes( TopoDS_Shape& Out3dPres,
+ TopoDS_Shape& Out2dPres,
+ TopoDS_Shape& OutLeftB,
+ TopoDS_Shape& OutRightB,
+ TopoDS_Shape& OutInlet,
+ TopoDS_Shape& OutOutlet );
+ public:
+
+ HYDRODATA_EXPORT static void CreateProfilesFromDTM ( const HYDROData_SequenceOfObjects& InpProfiles,
+ double ddz,
+ double step,
+ AltitudePoints& points,
+ TopoDS_Shape& Out3dPres,
+ TopoDS_Shape& Out2dPres,
+ TopoDS_Shape& OutLeftB,
+ TopoDS_Shape& OutRightB,
+ TopoDS_Shape& OutInlet,
+ TopoDS_Shape& OutOutlet,
+ bool Create3dPres,
+ bool Create2dPres,
+ std::set<int>& InvInd,
+ int thePntsLimit,
+ bool& WireIntersections);
+ };
+
+
+
+
+ #endif
const ObjectKind KIND_LAND_COVER_OBSOLETE = 27;
const ObjectKind KIND_CHANNEL_ALTITUDE = 28;
const ObjectKind KIND_LAND_COVER_MAP = 29;
+ const ObjectKind KIND_DTM = 30;
const ObjectKind KIND_LAST = KIND_LAND_COVER_MAP;
-DEFINE_STANDARD_HANDLE(HYDROData_Entity, MMgt_TShared)
-
class MapOfTreatedObjects : public QMap<QString,Handle(Standard_Transient)>
{
};
#include <QString>
#include <TopoDS_Face.hxx>
#include <TopExp_Explorer.hxx>
+ #include <vector>
+ #include <set>
-class Handle_HYDROData_StricklerTable;
+class HYDROData_StricklerTable;
#include <TopTools_IndexedDataMapOfShapeListOfShape.hxx>
typedef NCollection_IndexedDataMap<TopoDS_Face, QString> HYDROData_MapOfFaceToStricklerType;
class TopoDS_Shape;
class TopoDS_Wire;
class TopoDS_Iterator;
-class TopTools_ListOfShape;
-class Handle( HYDROData_PolylineXY );
-class Handle( HYDROData_Object );
+class HYDROData_PolylineXY;
+class HYDROData_Object;
- class gp_Pnt2d;
+ class gp_XY;
class HYDROData_LandCoverMap : public HYDROData_Entity
{
HYDRODATA_EXPORT bool ExportTelemac( const QString& theFileName,
double theDeflection,
- const Handle(HYDROData_StricklerTable)& theTable ) const;
- const Handle_HYDROData_StricklerTable& theTable,
++ const Handle(HYDROData_StricklerTable)& theTable,
+ QString& statMessage) const;
HYDRODATA_EXPORT bool Add( const Handle( HYDROData_Object )&, const QString& theType );
HYDRODATA_EXPORT bool Add( const Handle( HYDROData_PolylineXY )&, const QString& theType );
#define HYDROData_Profile_HeaderFile
#include "HYDROData_Object.h"
-
#include "HYDROData_ProfileUZ.h"
-DEFINE_STANDARD_HANDLE(HYDROData_Profile, HYDROData_Object)
-
class gp_XYZ;
class OSD_File;
-class Handle(HYDROData_Document);
+class HYDROData_Document;
/**\class HYDROData_Profile
* \brief Class that stores/retreives information about the profile.
#include <QStringList>
#include <QColor>
-#include "Handle_Geom_Plane.hxx"
+ #include "Geom_Plane.hxx"
+ #include "gp_Pln.hxx"
+ #include "BRepTools_ReShape.hxx"
+
//#define DEB_GET_REGION_SHAPE
-IMPLEMENT_STANDARD_HANDLE(HYDROData_Region, HYDROData_Entity)
IMPLEMENT_STANDARD_RTTIEXT(HYDROData_Region, HYDROData_Entity)
void HYDROData_ShapeFile::ReadSHPPolyXY(Handle(HYDROData_Document) theDocument, SHPObject* anObj, QString theFileName,
- int theInd, NCollection_Sequence<Handle(HYDROData_Entity)>& theEntities)
- int theInd, NCollection_Sequence<Handle_HYDROData_Entity>& theEntities, bool bReadAsPolyline)
++ int theInd, NCollection_Sequence<Handle(HYDROData_Entity)>& theEntities, bool bReadAsPolyline)
{
Handle(HYDROData_PolylineXY) aPolylineXY = Handle(HYDROData_PolylineXY)::DownCast( theDocument->CreateObject( KIND_POLYLINEXY ) );
else
EndIndex = anObj->nVertices;
- bool IsClosed = false;
HYDROData_PolylineXY::SectionType aSectType = HYDROData_PolylineXY::SECTION_POLYLINE;
- if (anObj->padfX[StartIndex] == anObj->padfX[EndIndex - 1] &&
- anObj->padfY[StartIndex] == anObj->padfY[EndIndex - 1] )
+ if (!bReadAsPolyline)
{
- IsClosed = true;
- aPolylineXY->AddSection( TCollection_AsciiString( ("poly_section_" + QString::number(i)).data()->toLatin1()), aSectType, true);
+ bool IsClosed = false;
+ if (anObj->padfX[StartIndex] == anObj->padfX[EndIndex - 1] &&
+ anObj->padfY[StartIndex] == anObj->padfY[EndIndex - 1] )
+ {
+ IsClosed = true;
- aPolylineXY->AddSection( TCollection_AsciiString( ("poly_section_" + QString::number(i)).data()->toAscii()), aSectType, true);
++ aPolylineXY->AddSection( TCollection_AsciiString( ("poly_section_" + QString::number(i)).data()->toLatin1()), aSectType, true);
+ }
+ else
- aPolylineXY->AddSection( TCollection_AsciiString( ("poly_section_" + QString::number(i)).data()->toAscii()), aSectType, false);
++ aPolylineXY->AddSection( TCollection_AsciiString( ("poly_section_" + QString::number(i)).data()->toLatin1()), aSectType, false);
+
+ if (IsClosed)
+ EndIndex--;
}
else
- aPolylineXY->AddSection( TCollection_AsciiString( ("poly_section_" + QString::number(i)).data()->toLatin1()), aSectType, false);
-
- if (IsClosed)
+ {
+ //polygon; contours always closed
- aPolylineXY->AddSection( TCollection_AsciiString( ("poly_section_" + QString::number(i)).data()->toAscii()), aSectType, true);
++ aPolylineXY->AddSection( TCollection_AsciiString( ("poly_section_" + QString::number(i)).data()->toLatin1()), aSectType, true);
EndIndex--;
+ }
for ( int k = StartIndex; k < EndIndex ; k++ )
{
HYDROData_PolylineXY::Point aSectPoint = gp_XY(anObj->padfX[k], anObj->padfY[k]);
}
-
+ void HYDROData_ShapeFile::GetFreeIndices(std::vector<int>& theAllowedIndexes, QString strName, size_t theObjsSize,
+ QStringList theExistingNames, QString theBaseFileName)
+ {
+ int anInd = 0;
+ for (;theAllowedIndexes.size() < theObjsSize;)
+ {
+ if (!theExistingNames.contains(theBaseFileName + strName + QString::number(anInd)))
+ {
+ theAllowedIndexes.push_back(anInd);
+ anInd++;
+ }
+ else
+ anInd++;
+ }
+ }
int HYDROData_ShapeFile::ImportPolylines(Handle(HYDROData_Document) theDocument, const QString& theFileName,
- NCollection_Sequence<Handle_HYDROData_Entity>& theEntities, int& theShapeTypeOfFile)
+ NCollection_Sequence<Handle(HYDROData_Entity)>& theEntities, int& theShapeTypeOfFile)
{
//Free();
int aStat = TryOpenShapeFile(theFileName);
#ifndef HYDRODATA_SHAPEFILE_H
#define HYDRODATA_SHAPEFILE_H
--#include <vector>
- #include <NCollection_Sequence.hxx>
- #include <QStringList>
+#include "HYDROData.h"
++
+ #include <NCollection_Sequence.hxx>
++
+#include <TopTools_SequenceOfShape.hxx>
+
+ #include <QStringList>
-#include "HYDROData.h"
++
++#include <vector>
++
+
//extern "C" {
#include <shapefil.h>
//};
//Import Polyline
void ReadSHPPolyXY(Handle(HYDROData_Document) theDocument, SHPObject* anObj, QString theFileName,
- int theInd, NCollection_Sequence<Handle(HYDROData_Entity)>& theEntities);
- int theInd, NCollection_Sequence<Handle_HYDROData_Entity>& theEntities, bool bReadAsPolyline = false);
++ int theInd, NCollection_Sequence<Handle(HYDROData_Entity)>& theEntities,
++ bool bReadAsPolylin = false);
void ReadSHPPoly3D(Handle(HYDROData_Document) theDocument, SHPObject* anObj, QString theFileName,
- int theInd, NCollection_Sequence<Handle_HYDROData_Entity>& theEntities);
+ int theInd, NCollection_Sequence<Handle(HYDROData_Entity)>& theEntities);
HYDRODATA_EXPORT int ImportPolylines(Handle(HYDROData_Document) theDocument, const QString& theFileName,
- NCollection_Sequence<Handle_HYDROData_Entity>& theEntities, int& theShapeTypeOfFile);
+ NCollection_Sequence<Handle(HYDROData_Entity)>& theEntities, int& theShapeTypeOfFile);
HYDRODATA_EXPORT QString GetShapeTypeName(int theType);
#include <TopTools_ListOfShape.hxx>
#include <TopTools_ListIteratorOfListOfShape.hxx>
#include <ShapeUpgrade_UnifySameDomain.hxx>
+ #include <BRepTools_ReShape.hxx>
-IMPLEMENT_STANDARD_HANDLE(HYDROData_ShapesGroup,HYDROData_Entity)
IMPLEMENT_STANDARD_RTTIEXT(HYDROData_ShapesGroup,HYDROData_Entity)
void HYDROData_ShapesGroup::GroupDefinition::Update( SeqOfGroupsDefs* theGroupsDefs,
#include <QString>
class TopoDS_Shape;
-class TopTools_ListOfShape;
class BRepBuilderAPI_MakeShape;
class ShapeUpgrade_UnifySameDomain;
+ class BRepTools_ReShape;
-DEFINE_STANDARD_HANDLE(HYDROData_ShapesGroup, HYDROData_Entity)
-
/**\class HYDROData_ShapesGroup
* \brief Class that stores/retreives the sequence of shapes.
*/
#include <TopoDS_Face.hxx>
#include <TopTools_ShapeMapHasher.hxx>
#include <NCollection_IndexedMap.hxx>
- #include <NCollection_IndexedDataMap.hxx>
+ #include <TopTools_IndexedDataMapOfShapeShape.hxx>
+ #include <TopTools_IndexedDataMapOfShapeListOfShape.hxx>
#include <TopTools_ListOfShape.hxx>
#include <QStringList>
+ #include <NCollection_DataMap.hxx>
-class Handle(HYDROData_PolylineXY);
+class HYDROData_PolylineXY;
/**
* \class HYDROData_SplitToZonesTool
#include <Geom_BSplineCurve.hxx>
#include <TopTools_HArray1OfShape.hxx>
+ #include <TopTools_IndexedMapOfOrientedShape.hxx>
+ #include <TopTools_ListIteratorOfListOfShape.hxx>
+ #include <TopTools_SequenceOfShape.hxx>
+ #include <TopTools_IndexedMapOfShape.hxx>
-#include <SortTools_QuickSortOfReal.hxx>
-
#include <QColor>
#include <QStringList>
+#include <QVector>
//#define DEB_STREAM 1
#ifdef DEB_STREAM
#include <TCollection_AsciiString.hxx>
#endif
+ #include <assert.h>
+
typedef NCollection_DataMap<Standard_Real, Handle(HYDROData_Profile)> HYDROData_DataMapOfRealOfHDProfile;
-IMPLEMENT_STANDARD_HANDLE(HYDROData_Stream,HYDROData_NaturalObject)
IMPLEMENT_STANDARD_RTTIEXT(HYDROData_Stream,HYDROData_NaturalObject)
}
}
- UpdatePrs();
- Handle_HYDROData_DTM dtm = DTM();
++ Handle(HYDROData_DTM) dtm = DTM();
+ dtm->Update();
+ UpdatePrs( dtm );
+
+ HYDROData_NaturalObject::Update();
}
bool HYDROData_Stream::IsHas2dPrs() const
return true;
}
- bool HYDROData_Stream::CreatePresentations( const Handle(HYDROData_PolylineXY)& theHydAxis,
- const HYDROData_SequenceOfObjects& theProfiles,
- PrsDefinition& thePrs )
-bool HYDROData_Stream::CreatePresentations( const Handle_HYDROData_DTM& theDTM,
++bool HYDROData_Stream::CreatePresentations( const Handle(HYDROData_DTM)& theDTM,
+ PrsDefinition& thePrs )
{
- if ( theHydAxis.IsNull() || theProfiles.Length() < 2 )
+ if ( theDTM.IsNull() )
+ return false;
+
+ HYDROData_SequenceOfObjects profiles = theDTM->GetProfiles();
+ if( profiles.Length() < 2 )
return false;
- Handle(TColgp_HArray1OfPnt) anArrayOfFPnt = new TColgp_HArray1OfPnt(1, theProfiles.Length());
- Handle(TColgp_HArray1OfPnt) anArrayOfLPnt = new TColgp_HArray1OfPnt(1, theProfiles.Length());
- Handle(TopTools_HArray1OfShape) anArrOfProfiles = new TopTools_HArray1OfShape(1, theProfiles.Length());
- Handle(TopTools_HArray1OfShape) anArrOf2DProfiles = new TopTools_HArray1OfShape(1, theProfiles.Length());
+ TopoDS_Shape Out3dPres;
+ TopoDS_Shape Out2dPres;
+ TopoDS_Shape OutLeftB;
+ TopoDS_Shape OutRightB;
+ TopoDS_Shape OutInlet;
+ TopoDS_Shape OutOutlet;
+
+ theDTM->GetPresentationShapes(Out3dPres, Out2dPres, OutLeftB, OutRightB, OutInlet, OutOutlet);
+
+ thePrs.myInlet = TopoDS::Wire(OutInlet);
+ thePrs.myOutlet = TopoDS::Wire(OutOutlet);
+ thePrs.myLeftBank = TopoDS::Wire(OutLeftB);
+ thePrs.myRightBank = TopoDS::Wire(OutRightB);
+ thePrs.myPrs2D = Out2dPres;
+ thePrs.myPrs3D = Out3dPres;
+ /*std::vector<TopoDS_Wire> profiles3d;
+ profiles3d.reserve(profiles.Length());
// Pre-processing
- HYDROData_SequenceOfObjects::Iterator anIter( theProfiles );
+ HYDROData_SequenceOfObjects::Iterator anIter( profiles );
for (int i=1 ; anIter.More(); anIter.Next(),i++ )
{
Handle(HYDROData_Profile) aProfile =
Handle(HYDROData_Profile)::DownCast( anIter.Value() );
- if ( aProfile.IsNull() )
- continue;
- const TopoDS_Shape& aProf3d = aProfile->GetShape3D();
- gp_XY aPnt1, aPnt2;
- if ( !aProfile->GetLeftPoint( aPnt1, false ) || !aProfile->GetRightPoint( aPnt2, false ) )
+ if ( aProfile.IsNull() )
continue;
- anArrOfProfiles->SetValue(i,aProfile->GetShape3D());//aProfile->GetTopShape();
- anArrOf2DProfiles->SetValue(i,aProfile->GetTopShape());
+ const TopoDS_Shape& aProfileShape = aProfile->GetShape3D();
+ //TopExp_Explorer exp(aProfileShape, TopAbs_EDGE);
+ profiles3d.push_back( TopoDS::Wire(aProfileShape) );
+ }*/
- gp_Pnt aCurFP, aCurLP;
- TopoDS_Vertex aV1, aV2;
- TopExp::Vertices(TopoDS::Wire(aProf3d), aV1, aV2);
- gp_Pnt aP1 = BRep_Tool::Pnt(aV1);
- if(aP1.X() == aPnt1.X() && aP1.Y() == aPnt1.Y())
- aCurFP = aP1;
- else
- aCurLP = aP1;
- aP1 = BRep_Tool::Pnt(aV2);
- if(aP1.X() == aPnt2.X() && aP1.Y() == aPnt2.Y())
- aCurLP = aP1;
- else
- aCurFP = aP1;
- anArrayOfFPnt->SetValue(i,aCurFP);
- anArrayOfLPnt->SetValue(i,aCurLP);
- }
-
- return CreatePresentations( anArrayOfFPnt, anArrayOfLPnt, anArrOfProfiles, anArrOf2DProfiles, thePrs );
+ return true;
}
- void HYDROData_Stream::UpdatePrs()
-void HYDROData_Stream::UpdatePrs( const Handle_HYDROData_DTM& theDTM )
++void HYDROData_Stream::UpdatePrs( const Handle(HYDROData_DTM)& theDTM )
{
HYDROData_NaturalObject::Update();
-
- Handle(HYDROData_PolylineXY) aHydAxis = GetHydraulicAxis();
- HYDROData_SequenceOfObjects aRefProfiles = GetProfiles();
-
+
PrsDefinition aResultPrs;
- if ( !CreatePresentations( aHydAxis, aRefProfiles, aResultPrs ) )
+ if ( !CreatePresentations( theDTM, aResultPrs ) )
return;
SetShape3D( aResultPrs.myPrs3D );
return HYDROData_Tool::getFirstShapeFromGroup( aGroups, 4);
}
-Handle_HYDROData_DTM HYDROData_Stream::DTM() const
++Handle(HYDROData_DTM) HYDROData_Stream::DTM() const
+ {
+ const_cast<HYDROData_Stream*>( this )->checkAndSetAltitudeObject();
+ return Handle(HYDROData_DTM)::DownCast( GetAltitudeObject() );
+ }
+
+ double HYDROData_Stream::GetDDZ() const
+ {
+ return DTM()->GetDDZ();
+ }
+
+ void HYDROData_Stream::SetDDZ( double theDDZ )
+ {
+ DTM()->SetDDZ( theDDZ );
+ Changed( Geom_3d );
+ }
+
+ double HYDROData_Stream::GetSpatialStep() const
+ {
+ return DTM()->GetSpatialStep();
+ }
+
+ void HYDROData_Stream::SetSpatialStep( double theSpatialStep )
+ {
+ DTM()->SetSpatialStep( theSpatialStep );
+ Changed( Geom_3d );
+ }
+
bool HYDROData_Stream::SetHydraulicAxis( const Handle(HYDROData_PolylineXY)& theAxis )
{
if ( !IsValidAsAxis( theAxis ) )
ObjectKind HYDROData_Stream::getAltitudeObjectType() const
{
- return KIND_STREAM_ALTITUDE;
+ return KIND_DTM;
}
-void HYDROData_Stream::setParametersArray( const TColStd_Array1OfReal& theArray )
+void HYDROData_Stream::setParametersArray( const QVector<double>& theArray )
{
- if ( theArray.Length() == 0 )
+ if ( theArray.size() == 0 )
{
removeParametersArray();
return;
}
}
}
-
- bool HYDROData_Stream::CreatePresentations( const Handle(TColgp_HArray1OfPnt) theArrayOfFPnt,
+ void HYDROData_Stream::CreatePresentations( const Handle(TColgp_HArray1OfPnt) theArrayOfFPnt,
const Handle(TColgp_HArray1OfPnt) theArrayOfLPnt,
const Handle(TopTools_HArray1OfShape) theArrOfProfiles,
- const Handle(TopTools_HArray1OfShape) theArrOf2DProfiles,
PrsDefinition& thePrs )
{
- if ( theArrayOfFPnt.IsNull() || theArrayOfLPnt.IsNull() || theArrOfProfiles.IsNull() ) {
- return false;
- }
- if ( theArrayOfFPnt->Length() != theArrayOfLPnt->Length() ) {
- return false;
- }
-
- // Construct of the 3D presentation
- Handle(Geom_BSplineCurve) aBSpline = buildInterpolationCurve (theArrayOfFPnt);
- if(aBSpline.IsNull())
- return false;
-
- TopoDS_Edge anEdgLeft, anEdgRight;
-
- BRepBuilderAPI_MakeEdge aMakeEdge(aBSpline);
- if(aMakeEdge.IsDone())
- anEdgLeft = aMakeEdge.Edge();
-
- if(anEdgLeft.IsNull())
- return false;
-
- aBSpline.Nullify();
- aBSpline = buildInterpolationCurve (theArrayOfLPnt);
- if(aBSpline.IsNull())
- return false;
-
- aMakeEdge.Init(aBSpline);
- if(aMakeEdge.IsDone())
- anEdgRight = aMakeEdge.Edge();
-
- if(anEdgRight.IsNull())
- return false;
-
- BRep_Builder aBB;
- TopoDS_Compound aCmp;
- aBB.MakeCompound(aCmp);
- for (int i=1 ; i < theArrOfProfiles->Length() +1; i++ )
- aBB.Add(aCmp, theArrOfProfiles->Value(i));
-
- aBB.Add(aCmp,anEdgLeft);
- aBB.Add(aCmp,anEdgRight);
- BRepCheck_Analyzer aCh(aCmp);
- if(aCh.IsValid())
- thePrs.myPrs3D = aCmp;
- #ifdef DEB_UPDATE
- else {
- BRepTools::Write(aCmp, "str3d.brep");
- thePrs.myPrs3D = aCmp;
+ HYDROData_Bathymetry::AltitudePoints left;
+ for (int i = theArrayOfLPnt->Lower(); i <= theArrayOfLPnt->Upper(); i++)
+ {
+ left.push_back(HYDROData_Bathymetry::AltitudePoint(theArrayOfLPnt->Value(i).X(),
+ theArrayOfLPnt->Value(i).Y(),
+ theArrayOfLPnt->Value(i).Z()));
}
- #endif
- // Construct the top presentation
- int aNbPoints = theArrayOfFPnt->Length();
- Handle(TColgp_HArray1OfPnt) anArrayOfFPnt = new TColgp_HArray1OfPnt(1, aNbPoints);
- Handle(TColgp_HArray1OfPnt) anArrayOfLPnt = new TColgp_HArray1OfPnt(1, aNbPoints);
- for( int i=1; i <= aNbPoints; i++ ) {
- gp_Pnt aPnt = theArrayOfFPnt->Value(i);
- aPnt.SetZ(.0); // make 2d
- anArrayOfFPnt->SetValue(i, aPnt);
- aPnt = theArrayOfLPnt->Value(i);
- aPnt.SetZ(.0);
- anArrayOfLPnt->SetValue(i, aPnt);
+ HYDROData_Bathymetry::AltitudePoints right;
+ for (int i = theArrayOfFPnt->Lower(); i <= theArrayOfFPnt->Upper(); i++)
+ {
+ right.push_back(HYDROData_Bathymetry::AltitudePoint(theArrayOfFPnt->Value(i).X(),
+ theArrayOfFPnt->Value(i).Y(),
+ theArrayOfFPnt->Value(i).Z()));
}
- aBSpline.Nullify();
- aBSpline = buildInterpolationCurve (anArrayOfFPnt);
- if(aBSpline.IsNull())
- return false;
-
- aMakeEdge.Init(aBSpline);
- if(aMakeEdge.IsDone())
- anEdgLeft = aMakeEdge.Edge();
-
- aBSpline.Nullify();
- aBSpline = buildInterpolationCurve (anArrayOfLPnt);
- if(aBSpline.IsNull())
- return false;
-
- aMakeEdge.Init(aBSpline);
- if(aMakeEdge.IsDone())
- anEdgRight = aMakeEdge.Edge();
- if(anEdgRight.IsNull())
- return false;
-
- BRepBuilderAPI_MakeEdge aMakeEdge2(anArrayOfFPnt->Value(1),anArrayOfLPnt->Value(1));
- TopoDS_Edge aBotEdge, aTopEdge;
- if(aMakeEdge2.IsDone())
- aBotEdge = aMakeEdge2.Edge();
-
- BRepBuilderAPI_MakeEdge aMakeEdge3(anArrayOfFPnt->Value(anArrayOfFPnt->Length()),anArrayOfLPnt->Value(anArrayOfLPnt->Length()));
- if(aMakeEdge3.IsDone())
- aTopEdge = aMakeEdge3.Edge();
+ std::vector<HYDROData_Bathymetry::AltitudePoints> dummy;
+ TopTools_IndexedMapOfOrientedShape ll = HYDROData_DTM::Create3DShape(left, right, dummy);
- // Make wire for 2D presentation with updating of corresponding edges
- BRepBuilderAPI_MakeWire aMakeWire;
-
- aMakeWire.Add( aBotEdge );
- thePrs.myInlet = aMakeWire.Edge();
-
- aMakeWire.Add( anEdgLeft );
- thePrs.myLeftBank = aMakeWire.Edge();
-
- aMakeWire.Add( aTopEdge );
- thePrs.myOutlet = aMakeWire.Edge();
-
- aMakeWire.Add( anEdgRight );
- thePrs.myRightBank = aMakeWire.Edge();
-
- TopoDS_Wire aSectProfileWire;
- if(aMakeWire.IsDone())
- aSectProfileWire = aMakeWire.Wire();
-
- BRepBuilderAPI_MakeFace aMakeFace( aSectProfileWire, Standard_True );
- TopoDS_Face aFace;
- aMakeFace.Build();
- if( aMakeFace.IsDone() )
- aFace = aMakeFace.Face();
+ TopoDS_Shape LB, RB, IL, OL;
- TopoDS_Shape aPrs2D;
-
- if ( !theArrOf2DProfiles.IsNull() ) {
- aCmp.Nullify();
- aBB.MakeCompound(aCmp);
- aBB.Add(aCmp,aFace);
- for(int i=1;i <= theArrOf2DProfiles->Length(); i++)
- aBB.Add(aCmp, theArrOf2DProfiles->Value(i));
-
- aPrs2D = aCmp;
- } else {
- aPrs2D = aFace;
+ if (!ll.IsEmpty())
+ {
+ LB = TopoDS::Wire(ll(1));
+ RB = TopoDS::Wire(ll(2));
}
- aCh.Init(aPrs2D);
- if(aCh.IsValid())
- thePrs.myPrs2D = aPrs2D;
- #ifdef DEB_UPDATE
- else {
- BRepTools::Write(aPrs2D, "str2d.brep");
- thePrs.myPrs2D = aPrs2D;
+ IL = TopoDS::Wire(theArrOfProfiles->Value(theArrOfProfiles->Lower())); //TODO check that
+ OL = TopoDS::Wire(theArrOfProfiles->Value(theArrOfProfiles->Upper()));
+
+ //make new compound so it's shapes will be in known order to build correct projection
+ BRep_Builder BB;
+ TopoDS_Compound newCmp;
+ BB.MakeCompound(newCmp);
+ BB.Add(newCmp, LB);
+ BB.Add(newCmp, IL);
+ BB.Add(newCmp, OL);
+ BB.Add(newCmp, RB);
+
+ thePrs.myPrs3D = newCmp;
+ std::set<int> ind;
+ ind.insert(1); //inlet ind
+ ind.insert(2); //outlet ind
+
+ TopTools_SequenceOfShape LS;
+ HYDROData_DTM::Get2dFaceFrom3dPres( newCmp, TopoDS::Face(thePrs.myPrs2D), &LS, ind );
+
+ #ifndef NDEBUG
+ TopTools_IndexedMapOfShape EE;
+ TopExp::MapShapes(thePrs.myPrs2D, TopAbs_EDGE, EE);
+ int noncontNb = 0;
+ for (int i = 1; i <= 4; i++)
+ {
+ TopoDS_Shape W = LS(i);
+ TopTools_IndexedMapOfShape EW;
+ TopExp::MapShapes(W, TopAbs_EDGE, EW);
+ for (int k = 1; k <= EW.Extent(); k++)
+ noncontNb += !EE.Contains(EW(k));
}
+ //noncontNb > 0 => some problem with edge history
+ assert(noncontNb == 0);
#endif
- return true;
+ thePrs.myLeftBank = TopoDS::Wire(LS(1));
+ thePrs.myInlet = TopoDS::Wire(LS(2));
+ thePrs.myOutlet = TopoDS::Wire(LS(3));
+ thePrs.myRightBank = TopoDS::Wire(LS(4));
+
-}
+}
#include <TopoDS_Face.hxx>
#include <TopoDS_Edge.hxx>
+ #include <TopoDS_Wire.hxx>
#include <Geom_BSplineCurve.hxx>
+ #include <vector>
-DEFINE_STANDARD_HANDLE(HYDROData_Stream, HYDROData_NaturalObject)
-
-class Handle(HYDROData_PolylineXY);
-class Handle(HYDROData_Polyline3D);
-class Handle(HYDROData_Profile);
++class HYDROData_DTM;
+class HYDROData_PolylineXY;
+class HYDROData_Polyline3D;
+class HYDROData_Profile;
class HYDROData_IProfilesInterpolator;
-class TColStd_Array1OfReal;
-class Handle(TopTools_HArray1OfShape);
-class Handle_HYDROData_DTM;
-class TopTools_ListOfShape;
+class TopTools_HArray1OfShape;
/**\class HYDROData_Stream
/**
* Creates the presentations(2D and 3D) by given hydraulic axis and profiles.
*/
- HYDRODATA_EXPORT static bool CreatePresentations( const Handle(HYDROData_PolylineXY)& theHydAxis,
- const HYDROData_SequenceOfObjects& theProfiles,
- PrsDefinition& thePrs );
- HYDRODATA_EXPORT static bool CreatePresentations( const Handle_HYDROData_DTM& theDTM,
- PrsDefinition& thePrs );
++ HYDRODATA_EXPORT static bool CreatePresentations( const Handle(HYDROData_DTM)& theDTM,
++ PrsDefinition& thePrs );
- /**
- * Creates the presentations(2D and 3D) by given first points, last points and profiles.
- * If 2D profiles is null - they will not used in the presentation.
- */
- HYDRODATA_EXPORT static bool CreatePresentations( const Handle(TColgp_HArray1OfPnt) theArrayOfFPnt,
+ HYDRODATA_EXPORT static void CreatePresentations( const Handle(TColgp_HArray1OfPnt) theArrayOfFPnt,
const Handle(TColgp_HArray1OfPnt) theArrayOfLPnt,
const Handle(TopTools_HArray1OfShape) theArrOfProfiles,
- const Handle(TopTools_HArray1OfShape) theArrOf2DProfiles,
PrsDefinition& thePrs );
public:
/**
* Update the shape presentations of stream.
*/
- HYDRODATA_EXPORT virtual void UpdatePrs();
- HYDRODATA_EXPORT void UpdatePrs( const Handle_HYDROData_DTM& );
++ HYDRODATA_EXPORT void UpdatePrs( const Handle(HYDROData_DTM)& );
/**
*
void removeParameter( const int& theIndex );
- protected:
- Handle_HYDROData_DTM DTM() const;
++ Handle(HYDROData_DTM) DTM() const;
+
+ protected:
friend class HYDROData_Iterator;
+ friend class test_HYDROData_Stream;
/**
* Creates new object in the internal data structure. Use higher level objects
HYDROData_SequenceOfObjects::Iterator anIter( aSeq );
for ( ; anIter.More(); anIter.Next() )
{
- setObjectVisibility( anIter.Value(), true );
- const Handle_HYDROData_Entity& ent = anIter.Value();
++ const Handle(HYDROData_Entity)& ent = anIter.Value();
+ if (!ent.IsNull())
+ setObjectVisibility( ent, true );
}
//Process the draw events for viewer
const Quantity_Color EDGES_COLOR = Quantity_NOC_SLATEGRAY;
const int HILIGHT_ISO_NB = 10;
--IMPLEMENT_STANDARD_HANDLE( HYDROGUI_LandCoverMapPrs, AIS_ColoredShape )
--IMPLEMENT_STANDARD_RTTIEXT( HYDROGUI_LandCoverMapPrs, AIS_ColoredShape )
++//@MZN zzz IMPLEMENT_STANDARD_HANDLE( HYDROGUI_LandCoverMapPrs, AIS_ColoredShape )
++//@MZN zzz IMPLEMENT_STANDARD_RTTIEXT( HYDROGUI_LandCoverMapPrs, AIS_ColoredShape )
HYDROGUI_LandCoverMapPrs::HYDROGUI_LandCoverMapPrs( const Handle(HYDROData_LandCoverMap)& theMap )
: AIS_ColoredShape( theMap->GetShape() )
aThat->myCoords = new TColgp_HArray1OfPnt( aLower, anUpper );
aThat->myColors = new Quantity_HArray1OfColor( aLower, anUpper );
for( int i=aLower; i<=anUpper; i++ )
- aThat->myCoords->SetValue( i, aBathPoints.Value( i ) );
+ aThat->myCoords->SetValue( i, gp_Pnt( aBathPoints[i].X, aBathPoints[i].Y, aBathPoints[i].Z ) );
-
- return aPntCloud;
}
- else
- return Handle_AIS_InteractiveObject();
+
+ return aPntCloud;
}
void HYDROGUI_ShapeBathymetry::GetRange( double& theMin, double& theMax ) const
}
}
-void HYDROGUI_ShapeBathymetry::UpdateWithColorScale( const Handle(Aspect_ColorScale)& theColorScale )
+void HYDROGUI_ShapeBathymetry::UpdateWithColorScale( const Handle(AIS_ColorScale)& theColorScale )
{
+ if (!myCoords)
+ return;
for( int i=myCoords->Lower(), n=myCoords->Upper(); i<=n; i++ )
{
double z = myCoords->Value( i ).Z();
virtual void setVisible( const bool theState,
const bool theIsUpdateViewer = true );
protected:
- virtual Handle_AIS_InteractiveObject createShape() const;
+ virtual Handle(AIS_InteractiveObject) createShape() const;
virtual void displayShape( const bool theIsUpdateViewer );
+ void setToUpdateColorScale( bool isChanged );
+
private:
HYDROGUI_OCCDisplayer* myDisplayer;
- Handle_TColgp_HArray1OfPnt myCoords;
- Handle_Quantity_HArray1OfColor myColors;
+ Handle(TColgp_HArray1OfPnt) myCoords;
+ Handle(Quantity_HArray1OfColor) myColors;
};
#endif
include(../../CMake/Common.cmake)
-include(UsePyQt4)
+INCLUDE(UsePyQt)
- # --- options ---
-
# additional include directories
INCLUDE_DIRECTORIES(
${CAS_INCLUDE_DIRS}
)
SET(_add_SOURCES
- sipHYDROPyNCollection_Sequence0100HYDROData_IPolylineSectionType.cc
+ sipHYDROPycmodule.cc
- sipHYDROPygp_XY.cc
+ sipHYDROPyNCollection_Sequence0600opencascadehandle0100HYDROData_Entity.cc
- sipHYDROPyNCollection_Sequence0100TCollection_AsciiString.cc
+ sipHYDROPygp_XYZ.cc
+ sipHYDROPyHYDROData_AltitudeObject.cc
+ sipHYDROPyHYDROData_Application.cc
+ sipHYDROPyHYDROData_ArtificialObject.cc
+ sipHYDROPyHYDROData_BathymetryAltitudePoint.cc
+ sipHYDROPyHYDROData_Bathymetry.cc
+ sipHYDROPyHYDROData_CalculationCase.cc
+ sipHYDROPyHYDROData_Channel.cc
+ sipHYDROPyHYDROData_Confluence.cc
+ sipHYDROPyHYDROData_Digue.cc
+ sipHYDROPyHYDROData_Document.cc
+ sipHYDROPyHYDROData_Entity.cc
+ sipHYDROPyHYDROData_IAltitudeObject.cc
+ sipHYDROPyHYDROData_IInterpolator.cc
+ sipHYDROPyHYDROData_Image.cc
+ sipHYDROPyHYDROData_ImmersibleZone.cc
+ sipHYDROPyHYDROData_IPolyline.cc
+ sipHYDROPyHYDROData_IProfilesInterpolator.cc
+ sipHYDROPyHYDROData_LandCoverMap.cc
+ sipHYDROPyHYDROData_NaturalObject.cc
+ sipHYDROPyHYDROData_Object.cc
+ sipHYDROPyHYDROData_ObstacleAltitude.cc
+ sipHYDROPyHYDROData_Obstacle.cc
+ sipHYDROPyHYDROData_Polyline3D.cc
+ sipHYDROPyHYDROData_PolylineXY.cc
+ sipHYDROPyHYDROData_Profile.cc
+ sipHYDROPyHYDROData_ProfileUZ.cc
+ sipHYDROPyHYDROData_Region.cc
+ sipHYDROPyHYDROData_River.cc
+ sipHYDROPyHYDROData_ShapesGroup.cc
+ sipHYDROPyHYDROData_SplitShapesGroup.cc
+ sipHYDROPyHYDROData_StreamAltitude.cc
+ sipHYDROPyHYDROData_Stream.cc
+ sipHYDROPyHYDROData_StricklerTable.cc
+ sipHYDROPyHYDROData_Zone.cc
sipHYDROPyNCollection_Sequence0100gp_XY.cc
sipHYDROPyNCollection_Sequence0100gp_XYZ.cc
+ sipHYDROPyNCollection_Sequence0100Handle_HYDROData_Entity.cc
+ sipHYDROPyNCollection_Sequence0100HYDROData_IPolylineSectionType.cc
+ sipHYDROPyNCollection_Sequence0100TCollection_AsciiString.cc
sipHYDROPyNCollection_Sequence1800.cc
sipHYDROPyNCollection_Sequence2400.cc
sipHYDROPyNCollection_Sequence2600.cc
sipHYDROPyTCollection_AsciiString.cc
)
- # --- sources ---
-
# sources / sip wrappings
-PYQT4_WRAP_SIP(_sip_SOURCES ${_sip_input_file} SOURCES ${_add_SOURCES})
+PYQT_WRAP_SIP(_sip_SOURCES ${_sip_files} SOURCES ${_add_SOURCES})
# sources / to compile
SET(HYDROPy_SOURCES ${_sip_SOURCES})
*/
static int ImportFromFile( HYDROData_Document theDoc,
const TCollection_AsciiString& theFileName,
- NCollection_Sequence<int>& theBadProfilesIds )
+ NCollection_Sequence<int>& theBadProfilesIds,
- bool isToProject = true )
- [int ( const Handle_HYDROData_Document&,
++ bool isToProject = true )
+ [int ( const opencascade::handle<HYDROData_Document>&,
const TCollection_AsciiString&,
NCollection_Sequence<int>& )];
%MethodCode
TestLib_Runner.cxx
)
- add_definitions(
- -DLIGHT_MODE -DHYDRODATA_STATIC -DHYDROGUI_STATIC
- )
+ add_definitions( -DLIGHT_MODE -DHYDRODATA_STATIC -DHYDROGUI_STATIC )
IF( ${WIN32} )
- add_definitions( -DWNT )
+ add_definitions( -DWNT -D__WIN32__ -D__x86__ -D_WIN64 -D_WIN32_WINNT=0x0400 -D__NT__ -D__OSVERSION__=4 )
ENDIF()
- SET( CPPUNIT_INCLUDES $ENV{cppUNIT_ROOT}/include )
+ SET( CPPUNIT_INCLUDES $ENV{CPPUNIT_ROOT}/include )
SET( CAS_INCLUDES $ENV{CASROOT}/inc )
-SET( QT_INCLUDES $ENV{QTDIR}/include $ENV{QTDIR}/include/QtCore $ENV{QTDIR}/include/QtGui $ENV{QTDIR}/include/QtTest )
+SET( QT_INCLUDES $ENV{QT5_ROOT_DIR}/include $ENV{QT5_ROOT_DIR}/include/QtCore $ENV{QT5_ROOT_DIR}/include/QtGui $ENV{QT5_ROOT_DIR}/include/QtTest )
SET( KERNEL_INCLUDES $ENV{KERNEL_ROOT_DIR}/include/salome )
SET( GUI_INCLUDES $ENV{GUI_ROOT_DIR}/include/salome )
SET( GEOM_INCLUDES $ENV{GEOM_ROOT_DIR}/include/salome )
set( MOC_HEADERS
../HYDROGUI/HYDROGUI_InputPanel.h
../HYDROGUI/HYDROGUI_StricklerTableDlg.h
+ ../HYDROGUI/HYDROGUI_StreamDlg.h
+ ../HYDROGUI/HYDROGUI_ListSelector.h
+ ../HYDROGUI/HYDROGUI_OrderedListWidget.h
)
-QT4_WRAP_CPP( PROJECT_MOC_HEADERS ${MOC_HEADERS} )
+QT_WRAP_MOC( PROJECT_MOC_HEADERS ${MOC_HEADERS} )
}
}
- Handle(V3d_View) aView = myViewWindow->getViewPort()->getView();
- if( aView.IsNull() )
- return false;
- return aView->ColorScaleIsDisplayed();
+ bool TestViewer::ColorScaleIsDisplayed()
+ {
++ return context()->IsDisplayed( colorScale() );
+ }
+
void TestViewer::select( int theViewX, int theViewY )
{
Handle(V3d_View) aView = myViewWindow->getViewPort()->getView();
class TopoDS_Shape;
class QString;
class QColor;
-class Handle_AIS_InteractiveContext;
-class Handle_AIS_InteractiveObject;
-class Handle_Aspect_ColorScale;
+ class QImage;
+class AIS_InteractiveObject;
+class AIS_ColorScale;
class TestViewer
{
int theMode, int theSelectionMode, bool isFitAll, const char* theKey );
static void show( const TopoDS_Shape& theShape, int theMode, bool isFitAll, const QColor& theColor );
static void show( const TopoDS_Shape& theShape, int theMode, bool isFitAll, const char* theKey );
- static bool AssertImages( QString& theMessage );
+ static bool AssertImages( QString& theMessage, const QImage* = 0, const char* theCase = 0 );
static QColor GetColor(int i);
- static Handle_Aspect_ColorScale colorScale();
+ static Handle(AIS_ColorScale) colorScale();
static void showColorScale( bool );
+ static bool ColorScaleIsDisplayed();
static void select( int theViewX, int theViewY );
--- /dev/null
-#include <Aspect_ColorScale.hxx>
+ // 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_CalcCase.h>
+ #include <HYDROData_CalculationCase.h>
+ #include <HYDROData_Document.h>
+ #include <HYDROData_Tool.h>
+ #include <TopoDS_Edge.hxx>
+ #include <TopoDS_Wire.hxx>
+ #include <TopoDS_Face.hxx>
+ #include <TopoDS.hxx>
+ #include <TestViewer.h>
+ #include <TestShape.h>
+ #include <TopTools_ListOfShape.hxx>
+ #include <AIS_DisplayMode.hxx>
+ #include <QString>
+ #include <QColor>
+ #include <BRep_Builder.hxx>
+ #include <BRepTools.hxx>
+
+
+ QString REF_DATA_PATH = qgetenv( "HYDRO_ROOT_DIR" ) + "/bin/salome/test";
+
+
+ void test_HYDROData_CalcCase::test_add_int_wires()
+ {
+ {
+ TopoDS_Shape out;
+ TopTools_ListOfShape Wires;
+
+ BRep_Builder B;
+ TopoDS_Shape InF;
+ TopoDS_Shape InP;
+ BRepTools::Read(InP, (REF_DATA_PATH + "/p1.brep").toStdString().c_str(), B);
+ BRepTools::Read(InF, (REF_DATA_PATH + "/r2.brep").toStdString().c_str(), B);
+ Wires.Append(InP);
+
+ TopTools_ListOfShape OutSh;
+ TopTools_IndexedDataMapOfShapeShape ls;
+ HYDROData_SplitToZonesTool::CutByEdges(InF, Wires, OutSh, &ls, NULL);
+
+ CPPUNIT_ASSERT_EQUAL(2, OutSh.Extent());
+ TopoDS_Compound cmp;
+ B.MakeCompound(cmp);
+ B.Add(cmp, OutSh.First());
+ B.Add(cmp, OutSh.Last());
+ TestViewer::show( cmp, AIS_Shaded, true, "cc_int_w_1" );
+ //CPPUNIT_ASSERT_IMAGES
+ }
+
+ {
+ TopoDS_Shape out;
+ TopTools_ListOfShape Wires;
+
+ BRep_Builder B;
+ TopoDS_Shape InF;
+ TopoDS_Shape InP;
+ BRepTools::Read(InP, (REF_DATA_PATH + "/p2.brep").toStdString().c_str(), B);
+ BRepTools::Read(InF, (REF_DATA_PATH + "/r2.brep").toStdString().c_str(), B);
+ Wires.Append(InP);
+
+ TopTools_ListOfShape OutSh;
+ TopTools_IndexedDataMapOfShapeShape ls;
+ HYDROData_SplitToZonesTool::CutByEdges(InF, Wires, OutSh, &ls, NULL);
+ CPPUNIT_ASSERT_EQUAL(1, OutSh.Extent());
+ TestViewer::show( OutSh.First(), AIS_WireFrame, true, "cc_int_w_2" );
+ //CPPUNIT_ASSERT_IMAGES
+ }
+
+ {
+ TopoDS_Shape out;
+ TopTools_ListOfShape Wires;
+
+ BRep_Builder B;
+ TopoDS_Shape InF;
+ TopoDS_Shape InP;
+ BRepTools::Read(InP, (REF_DATA_PATH + "/p3.brep").toStdString().c_str(), B);
+ BRepTools::Read(InF, (REF_DATA_PATH + "/r2.brep").toStdString().c_str(), B);
+ Wires.Append(InP);
+
+ TopTools_ListOfShape OutSh;
+ TopTools_IndexedDataMapOfShapeShape ls;
+ HYDROData_SplitToZonesTool::CutByEdges(InF, Wires, OutSh, &ls, NULL);
+ CPPUNIT_ASSERT_EQUAL(1, OutSh.Extent());
+ TestViewer::show( OutSh.First(), AIS_WireFrame, true, "cc_int_w_3" );
+ CPPUNIT_ASSERT_IMAGES
+ }
+
+ }
+
+
+
--- /dev/null
-#include <Aspect_ColorScale.hxx>
+ // 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_DTM.h>
+ #include <HYDROData_Document.h>
+ #include <HYDROData_Profile.h>
+ #include <HYDROData_DTM.h>
+ #include <HYDROData_Iterator.h>
+ #include <Geom2d_Curve.hxx>
+ #include <Geom2d_BSplineCurve.hxx>
+ #include <gp_XY.hxx>
+ #include <gp_Pnt2d.hxx>
+ #include <TColgp_Array1OfPnt2d.hxx>
+ #include <TestViewer.h>
+ #include <AIS_InteractiveContext.hxx>
+ #include <AIS_PointCloud.hxx>
+ #include <HYDROGUI_ShapeBathymetry.h>
- Handle_Aspect_ColorScale aCS = TestViewer::colorScale();
++#include <AIS_ColorScale.hxx>
+ #include <QGraphicsItem>
+ #include <QGraphicsScene>
+ #include <QGraphicsView>
+ #include <QPixmap>
+ #include <QApplication>
+
+ const double EPS = 1E-3;
+
+ extern QString REF_DATA_PATH;
+ NCollection_Sequence<HYDROData_IPolyline::Point> points;
+
+ class DTM_item : public QGraphicsItem
+ {
+ public:
+ DTM_item( HYDROGUI_ShapeBathymetry* theDTM, double d )
+ {
+ Handle(AIS_PointCloud) pc = Handle(AIS_PointCloud)::DownCast( theDTM->getAISObject() );
+ Handle(Graphic3d_ArrayOfPoints) pp = pc->GetPoints();
+ myBB = QRectF();
+ double xmin, xmax, ymin, ymax;
+ myD = d;
+
+ int n = pp->VertexNumber();
+
+ for( int i=1; i<=n; i++ )
+ {
+ gp_Pnt pnt = pp->Vertice( i );
+ Quantity_Color col = pp->VertexColor( i );
+
+ int r = col.Red()*255;
+ int g = col.Green()*255;
+ int b = col.Blue()*255;
+ int val = ( r << 16 ) + ( g << 8 ) + b;
+ double x = pnt.X();
+ double y = -pnt.Y();
+ QPointF aPnt( x, y );
+ myPoints[val].append( aPnt );
+ if( i==1 )
+ {
+ xmin = x;
+ xmax = x;
+ ymin = y;
+ ymax = y;
+ }
+ else
+ {
+ if( x>xmax )
+ xmax = x;
+ if( x<xmin )
+ xmin = x;
+ if( y>ymax )
+ ymax = y;
+ if( y<ymin )
+ ymin = y;
+ }
+ }
+
+ xmin -= 10;
+ xmax += 10;
+ ymin -= 10;
+ ymax += 10;
+ myBB.setRect( xmin, ymin, xmax-xmin, ymax-ymin );
+ }
+
+ virtual QRectF boundingRect() const
+ {
+ return myBB;
+ }
+
+ virtual void paint( QPainter* p, const QStyleOptionGraphicsItem*, QWidget* )
+ {
+ QMap<int, QList<QPointF> >::const_iterator it = myPoints.begin(), last = myPoints.end();
+ for( ; it!=last; it++ )
+ {
+ int r = ( it.key() >> 16 ) % 256;
+ int g = ( it.key() >> 8 ) % 256;
+ int b = ( it.key() >> 0 ) % 256;
+ QColor aColor( r, g, b );
+ QBrush aBrush( aColor );
+ foreach( QPointF pnt, it.value() )
+ {
+ QRectF r( pnt.x()-myD/2, pnt.y()-myD/2, myD, myD );
+ p->fillRect( r, aBrush );
+ }
+ }
+ }
+
+ private:
+ QRectF myBB;
+ double myD;
+ QMap<int, QList<QPointF> > myPoints;
+ };
+
+ QImage draw_DTM( HYDROGUI_ShapeBathymetry* theDTM, double theD, int theWidth, int theHeight )
+ {
+ QGraphicsScene aScene;
+ QGraphicsView aView;
+ DTM_item anItem( theDTM, theD );
+
+ aView.setScene( &aScene );
+ aView.setHorizontalScrollBarPolicy( Qt::ScrollBarAlwaysOff );
+ aView.setVerticalScrollBarPolicy( Qt::ScrollBarAlwaysOff );
+ aScene.addItem( &anItem );
+
+ aView.resize( theWidth, theHeight );
+ QRectF bb = anItem.boundingRect();
+ aView.fitInView( bb, Qt::KeepAspectRatio );
+ QApplication::processEvents();
+
+ QPixmap aPixmap = QPixmap::grabWidget( &aView );
+ return aPixmap.toImage();
+ }
+
+
+ void test_HYDROData_DTM::setUp()
+ {
+ points.Clear();
+ points.Append( gp_XY( 0.0, 5.0 ) );
+ points.Append( gp_XY( 1.0, 1.0 ) );
+ points.Append( gp_XY( 1.5, 0.0 ) );
+ points.Append( gp_XY( 4.0, 4.0 ) );
+ }
+
+ void test_HYDROData_DTM::test_creation()
+ {
+ Handle(HYDROData_Document) aDoc = HYDROData_Document::Document(1);
+
+ Handle(HYDROData_DTM) DTM =
+ Handle(HYDROData_DTM)::DownCast( aDoc->CreateObject( KIND_DTM ) );
+
+ CPPUNIT_ASSERT_EQUAL( false, (bool)DTM.IsNull() );
+
+ aDoc->Close();
+ }
+
+ void test_HYDROData_DTM::test_hydraulic_axis()
+ {
+ Handle(HYDROData_Document) aDoc = HYDROData_Document::Document(1);
+
+ Handle(HYDROData_Profile) aProfile1 =
+ Handle(HYDROData_Profile)::DownCast( aDoc->CreateObject( KIND_PROFILE ) );
+
+ Handle(HYDROData_Profile) aProfile2 =
+ Handle(HYDROData_Profile)::DownCast( aDoc->CreateObject( KIND_PROFILE ) );
+
+ Handle(HYDROData_Profile) aProfile3 =
+ Handle(HYDROData_Profile)::DownCast( aDoc->CreateObject( KIND_PROFILE ) );
+
+ aProfile1->SetParametricPoints( points );
+ aProfile1->GetProfileUZ()->SetSectionType( 0, HYDROData_IPolyline::SECTION_POLYLINE );
+ aProfile1->SetLeftPoint( gp_XY( 10, 10 ) );
+ aProfile1->SetRightPoint( gp_XY( 20, 0 ) );
+
+ aProfile2->SetParametricPoints( points );
+ aProfile2->GetProfileUZ()->SetSectionType( 0, HYDROData_IPolyline::SECTION_POLYLINE );
+ aProfile2->SetLeftPoint( gp_XY( 50, 0 ) );
+ aProfile2->SetRightPoint( gp_XY( 60, 10 ) );
+
+ aProfile3->SetParametricPoints( points );
+ aProfile3->GetProfileUZ()->SetSectionType( 0, HYDROData_IPolyline::SECTION_POLYLINE );
+ aProfile3->SetLeftPoint( gp_XY( 200, 50 ) );
+ aProfile3->SetRightPoint( gp_XY( 210, 40 ) );
+
+ std::vector<double> distances;
+ std::vector<Handle(HYDROData_Profile)> profiles;
+ profiles.push_back( aProfile1 );
+ profiles.push_back( aProfile2 );
+ profiles.push_back( aProfile3 );
+
+ Handle_Geom2d_BSplineCurve HA = HYDROData_DTM::CreateHydraulicAxis( profiles, distances );
+ CPPUNIT_ASSERT_EQUAL( false, (bool)HA.IsNull() );
+ CPPUNIT_ASSERT_EQUAL( 3, (int)distances.size() );
+
+ CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.0, distances[0], EPS );
+ CPPUNIT_ASSERT_DOUBLES_EQUAL( 43.499, distances[1], EPS );
+ CPPUNIT_ASSERT_DOUBLES_EQUAL( 211.474, distances[2], EPS );
+
+ gp_Pnt2d p;
+ gp_Vec2d q;
+ HA->D1( 0, p, q );
+ CPPUNIT_ASSERT_DOUBLES_EQUAL( 13.75, p.X(), EPS );
+ CPPUNIT_ASSERT_DOUBLES_EQUAL( 6.25, p.Y(), EPS );
+ CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.568, q.X(), EPS );
+ CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.568, q.Y(), EPS );
+
+ aDoc->Close();
+ }
+
+ void test_HYDROData_DTM::test_profile_conversion_to_2d()
+ {
+ Handle(HYDROData_Document) aDoc = HYDROData_Document::Document(1);
+
+ Handle(HYDROData_Profile) aProfile1 =
+ Handle(HYDROData_Profile)::DownCast( aDoc->CreateObject( KIND_PROFILE ) );
+
+ Handle(HYDROData_Profile) aProfile2 =
+ Handle(HYDROData_Profile)::DownCast( aDoc->CreateObject( KIND_PROFILE ) );
+
+ aProfile1->SetParametricPoints( points );
+ aProfile1->GetProfileUZ()->SetSectionType( 0, HYDROData_IPolyline::SECTION_POLYLINE );
+ aProfile1->SetLeftPoint( gp_XY( 10, 10 ) );
+ aProfile1->SetRightPoint( gp_XY( 20, 20 ) );
+
+ aProfile2->SetParametricPoints( points );
+ aProfile2->GetProfileUZ()->SetSectionType( 0, HYDROData_IPolyline::SECTION_SPLINE );
+ aProfile2->SetLeftPoint( gp_XY( 10, 10 ) );
+ aProfile2->SetRightPoint( gp_XY( 20, 20 ) );
+
+ double aUMin1 = std::numeric_limits<double>::max(),
+ aUMax1 = -aUMin1,
+ aUMin2 = aUMin1,
+ aUMax2 = aUMax1;
+ gp_Vec2d aProfileDir;
+ std::vector<Handle_Geom2d_Curve> curves1 = HYDROData_DTM::ProfileToParametric( aProfile1, aUMin1, aUMax1, aProfileDir );
+ std::vector<Handle_Geom2d_Curve> curves2 = HYDROData_DTM::ProfileToParametric( aProfile2, aUMin2, aUMax2, aProfileDir );
+
+ gp_Pnt2d aFirst, aLast;
+ CPPUNIT_ASSERT_EQUAL( 3, (int)curves1.size() );
+ CPPUNIT_ASSERT_DOUBLES_EQUAL( -5.303, aUMin1, EPS );
+ CPPUNIT_ASSERT_DOUBLES_EQUAL( 8.839, aUMax1, EPS );
+ curves1[0]->D0( curves1[0]->FirstParameter(), aFirst );
+ curves1[0]->D0( curves1[0]->LastParameter(), aLast );
+ CPPUNIT_ASSERT_DOUBLES_EQUAL( -5.303, aFirst.X(), EPS );
+ CPPUNIT_ASSERT_DOUBLES_EQUAL( 5.0, aFirst.Y(), EPS );
+ CPPUNIT_ASSERT_DOUBLES_EQUAL( -1.768, aLast.X(), EPS );
+ CPPUNIT_ASSERT_DOUBLES_EQUAL( 1.0, aLast.Y(), EPS );
+ curves1[1]->D0( curves1[1]->FirstParameter(), aFirst );
+ curves1[1]->D0( curves1[1]->LastParameter(), aLast );
+ CPPUNIT_ASSERT_DOUBLES_EQUAL( -1.768, aFirst.X(), EPS );
+ CPPUNIT_ASSERT_DOUBLES_EQUAL( 1.0, aFirst.Y(), EPS );
+ CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.0, aLast.X(), EPS );
+ CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.0, aLast.Y(), EPS );
+ curves1[2]->D0( curves1[2]->FirstParameter(), aFirst );
+ curves1[2]->D0( curves1[2]->LastParameter(), aLast );
+ CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.0, aFirst.X(), EPS );
+ CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.0, aFirst.Y(), EPS );
+ CPPUNIT_ASSERT_DOUBLES_EQUAL( 8.839, aLast.X(), EPS );
+ CPPUNIT_ASSERT_DOUBLES_EQUAL( 4.0, aLast.Y(), EPS );
+
+ CPPUNIT_ASSERT_EQUAL( 1, (int)curves2.size() );
+ CPPUNIT_ASSERT_DOUBLES_EQUAL( -5.303, aUMin2, EPS );
+ CPPUNIT_ASSERT_DOUBLES_EQUAL( 8.839, aUMax2, EPS );
+ Handle(Geom2d_BSplineCurve) aBSpline = Handle(Geom2d_BSplineCurve)::DownCast( curves2[0] );
+ CPPUNIT_ASSERT_EQUAL( false, (bool)aBSpline.IsNull() );
+ const TColgp_Array1OfPnt2d& poles = aBSpline->Poles();
+ CPPUNIT_ASSERT_EQUAL( 1, (int)poles.Lower() );
+ CPPUNIT_ASSERT_EQUAL( 8, (int)poles.Upper() );
+ CPPUNIT_ASSERT_DOUBLES_EQUAL( -5.303, poles.Value( 1 ).X(), EPS );
+ CPPUNIT_ASSERT_DOUBLES_EQUAL( 5.0, poles.Value( 1 ).Y(), EPS );
+ CPPUNIT_ASSERT_DOUBLES_EQUAL( -4.125, poles.Value( 2 ).X(), EPS );
+ CPPUNIT_ASSERT_DOUBLES_EQUAL( 3.667, poles.Value( 2 ).Y(), EPS );
+ CPPUNIT_ASSERT_DOUBLES_EQUAL( -3.150, poles.Value( 3 ).X(), EPS );
+ CPPUNIT_ASSERT_DOUBLES_EQUAL( 2.120, poles.Value( 3 ).Y(), EPS );
+ CPPUNIT_ASSERT_DOUBLES_EQUAL( -1.242, poles.Value( 4 ).X(), EPS );
+ CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.574, poles.Value( 4 ).Y(), EPS );
+
+ aDoc->Close();
+ }
+
+ void test_HYDROData_DTM::test_profile_properties()
+ {
+ Handle(HYDROData_Document) aDoc = HYDROData_Document::Document(1);
+
+ Handle(HYDROData_Profile) aProfile =
+ Handle(HYDROData_Profile)::DownCast( aDoc->CreateObject( KIND_PROFILE ) );
+
+ aProfile->SetParametricPoints( points );
+ aProfile->GetProfileUZ()->SetSectionType( 0, HYDROData_IPolyline::SECTION_POLYLINE );
+ aProfile->SetLeftPoint( gp_XY( 10, 10 ) );
+ aProfile->SetRightPoint( gp_XY( 20, 25 ) );
+
+ gp_Pnt lp;
+ gp_Vec2d dd;
+ double zmin, zmax;
+ HYDROData_DTM::GetProperties( aProfile, lp, dd, false, zmin, zmax );
+ CPPUNIT_ASSERT_DOUBLES_EQUAL( 13.75, lp.X(), EPS );
+ CPPUNIT_ASSERT_DOUBLES_EQUAL( 15.625, lp.Y(), EPS );
+ CPPUNIT_ASSERT_DOUBLES_EQUAL( 0, lp.Z(), EPS );
+ CPPUNIT_ASSERT_DOUBLES_EQUAL( 10, dd.X(), EPS );
+ CPPUNIT_ASSERT_DOUBLES_EQUAL( 15, dd.Y(), EPS );
+ CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.0, zmin, EPS );
+ CPPUNIT_ASSERT_DOUBLES_EQUAL( 5.0, zmax, EPS );
+
+ HYDROData_DTM::GetProperties( aProfile, lp, dd, true, zmin, zmax );
+ CPPUNIT_ASSERT_DOUBLES_EQUAL( 13.75, lp.X(), EPS );
+ CPPUNIT_ASSERT_DOUBLES_EQUAL( 15.625, lp.Y(), EPS );
+ CPPUNIT_ASSERT_DOUBLES_EQUAL( 0, lp.Z(), EPS );
+ CPPUNIT_ASSERT_DOUBLES_EQUAL( -15, dd.X(), EPS );
+ CPPUNIT_ASSERT_DOUBLES_EQUAL( 10, dd.Y(), EPS );
+ CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.0, zmin, EPS );
+ CPPUNIT_ASSERT_DOUBLES_EQUAL( 5.0, zmax, EPS );
+
+ aDoc->Close();
+ }
+
+ void test_HYDROData_DTM::test_profile_discretization_polyline()
+ {
+ Handle(HYDROData_Document) aDoc = HYDROData_Document::Document(1);
+
+ Handle(HYDROData_Profile) aProfile =
+ Handle(HYDROData_Profile)::DownCast( aDoc->CreateObject( KIND_PROFILE ) );
+
+ aProfile->SetParametricPoints( points );
+ aProfile->GetProfileUZ()->SetSectionType( 0, HYDROData_IPolyline::SECTION_POLYLINE );
+ aProfile->SetLeftPoint( gp_XY( 10, 10 ) );
+ aProfile->SetRightPoint( gp_XY( 20, 20 ) );
+
+ HYDROData_DTM::CurveUZ aMid( 0.0, gp_Vec2d(), 0 ), aWid( 0.0, gp_Vec2d(), 0 );
+ int dummy = 0;
+ HYDROData_DTM::ProfileDiscretization( aProfile, 0.0, 0.0, 5.0, 0.5, aMid, aWid, dummy );
+ CPPUNIT_ASSERT_EQUAL( 11, (int)aMid.size() );
+ CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.0, aMid[0].U, EPS );
+ CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.0, aMid[0].Z, EPS );
+ CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.11, aMid[1].U, EPS );
+ CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.5, aMid[1].Z, EPS );
+ CPPUNIT_ASSERT_DOUBLES_EQUAL( 1.215, aMid[5].U, EPS );
+ CPPUNIT_ASSERT_DOUBLES_EQUAL( 2.5, aMid[5].Z, EPS );
+ CPPUNIT_ASSERT_DOUBLES_EQUAL( 1.768, aMid[10].U, EPS );
+ CPPUNIT_ASSERT_DOUBLES_EQUAL( 5.0, aMid[10].Z, EPS );
+
+ CPPUNIT_ASSERT_EQUAL( 11, (int)aWid.size() );
+ CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.0, aWid[0].U, EPS );
+ CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.0, aWid[0].Z, EPS );
+ CPPUNIT_ASSERT_DOUBLES_EQUAL( 1.989, aWid[1].U, EPS );
+ CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.5, aWid[1].Z, EPS );
+ CPPUNIT_ASSERT_DOUBLES_EQUAL( 8.618, aWid[5].U, EPS );
+ CPPUNIT_ASSERT_DOUBLES_EQUAL( 2.5, aWid[5].Z, EPS );
+ CPPUNIT_ASSERT_DOUBLES_EQUAL( 14.142, aWid[10].U, EPS );
+ CPPUNIT_ASSERT_DOUBLES_EQUAL( 5.0, aWid[10].Z, EPS );
+
+ aDoc->Close();
+ }
+
+ void test_HYDROData_DTM::test_profile_discretization_spline()
+ {
+ Handle(HYDROData_Document) aDoc = HYDROData_Document::Document(1);
+
+ Handle(HYDROData_Profile) aProfile =
+ Handle(HYDROData_Profile)::DownCast( aDoc->CreateObject( KIND_PROFILE ) );
+
+ aProfile->SetParametricPoints( points );
+ aProfile->GetProfileUZ()->SetSectionType( 0, HYDROData_IPolyline::SECTION_SPLINE );
+ aProfile->SetLeftPoint( gp_XY( 10, 10 ) );
+ aProfile->SetRightPoint( gp_XY( 20, 20 ) );
+
+ HYDROData_DTM::CurveUZ aMid( 0.0, gp_Vec2d(), 0 ), aWid( 0.0, gp_Vec2d(), 0 );
+ int dummy = 0 ;
+ HYDROData_DTM::ProfileDiscretization( aProfile, 0.0, 0.0, 5.0, 0.5, aMid, aWid, dummy );
+ CPPUNIT_ASSERT_EQUAL( 11, (int)aMid.size() );
+ CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.242, aMid[0].U, EPS );
+ CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.0, aMid[0].Z, EPS );
+ CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.755, aMid[1].U, EPS );
+ CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.5, aMid[1].Z, EPS );
+ CPPUNIT_ASSERT_DOUBLES_EQUAL( 1.473, aMid[5].U, EPS );
+ CPPUNIT_ASSERT_DOUBLES_EQUAL( 2.5, aMid[5].Z, EPS );
+ CPPUNIT_ASSERT_DOUBLES_EQUAL( 1.768, aMid[10].U, EPS );
+ CPPUNIT_ASSERT_DOUBLES_EQUAL( 5.0, aMid[10].Z, EPS );
+
+ CPPUNIT_ASSERT_EQUAL( 11, (int)aWid.size() );
+ CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.484, aWid[0].U, EPS );
+ CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.0, aWid[0].Z, EPS );
+ CPPUNIT_ASSERT_DOUBLES_EQUAL( 3.809, aWid[1].U, EPS );
+ CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.5, aWid[1].Z, EPS );
+ CPPUNIT_ASSERT_DOUBLES_EQUAL( 9.472, aWid[5].U, EPS );
+ CPPUNIT_ASSERT_DOUBLES_EQUAL( 2.5, aWid[5].Z, EPS );
+ CPPUNIT_ASSERT_DOUBLES_EQUAL( 14.142, aWid[10].U, EPS );
+ CPPUNIT_ASSERT_DOUBLES_EQUAL( 5.0, aWid[10].Z, EPS );
+
+ aDoc->Close();
+ }
+
+ void operator << ( std::ostream& s, const HYDROData_DTM::PointUZ& p )
+ {
+ s << "(" << p.U << "; " << p.Z << ") ";
+ }
+
+ void operator << ( std::ostream& s, const HYDROData_DTM::AltitudePoint& p )
+ {
+ s << "(" << p.X << "; " << p.Y << "; " << p.Z << ") ";
+ }
+
+ bool operator == ( const HYDROData_DTM::PointUZ& p1, const HYDROData_DTM::PointUZ& p2 )
+ {
+ return fabs(p1.U-p2.U)<EPS && fabs(p1.Z-p2.Z)<EPS;
+ }
+
+ bool operator == ( const HYDROData_DTM::AltitudePoint& p1, const HYDROData_DTM::AltitudePoint& p2 )
+ {
+ return fabs(p1.X-p2.X)<EPS && fabs(p1.Y-p2.Y)<EPS && fabs(p1.Z-p2.Z)<EPS;
+ }
+
+ void operator << ( std::ostream& s, const HYDROData_DTM::CurveUZ& c )
+ {
+ size_t n = c.size();
+ for( size_t i=0; i<n; i++ )
+ s << c[i];
+ }
+
+ void test_HYDROData_DTM::test_curves_interpolation()
+ {
+ HYDROData_DTM::CurveUZ A(1.0, gp_Vec2d(), 0), B(2.0, gp_Vec2d(), 0);
+ A.push_back( HYDROData_DTM::PointUZ( 0, 0 ) );
+ A.push_back( HYDROData_DTM::PointUZ( 1, 1 ) );
+ A.push_back( HYDROData_DTM::PointUZ( 2, 2 ) );
+ B.push_back( HYDROData_DTM::PointUZ( 10, 0 ) );
+ B.push_back( HYDROData_DTM::PointUZ( 15, 1 ) );
+ B.push_back( HYDROData_DTM::PointUZ( 20, 2 ) );
+
+ std::vector<HYDROData_DTM::CurveUZ> i1;
+ HYDROData_DTM::Interpolate( A, B, 1, i1, false );
+
+ CPPUNIT_ASSERT_EQUAL( 2, (int)i1.size() );
+ CPPUNIT_ASSERT_EQUAL( A, i1[0] );
+ CPPUNIT_ASSERT_EQUAL( 3, (int)i1[1].size() );
+ CPPUNIT_ASSERT_EQUAL( HYDROData_DTM::PointUZ( 5, 0 ), i1[1][0] );
+ CPPUNIT_ASSERT_EQUAL( HYDROData_DTM::PointUZ( 8, 1 ), i1[1][1] );
+ CPPUNIT_ASSERT_EQUAL( HYDROData_DTM::PointUZ( 11, 2 ), i1[1][2] );
+
+ std::vector<HYDROData_DTM::CurveUZ> i2;
+ HYDROData_DTM::Interpolate( A, B, 1, i2, true );
+
+ CPPUNIT_ASSERT_EQUAL( 3, (int)i2.size() );
+ CPPUNIT_ASSERT_EQUAL( A, i2[0] );
+ CPPUNIT_ASSERT_EQUAL( 3, (int)i2[1].size() );
+ CPPUNIT_ASSERT_EQUAL( HYDROData_DTM::PointUZ( 5, 0 ), i2[1][0] );
+ CPPUNIT_ASSERT_EQUAL( HYDROData_DTM::PointUZ( 8, 1 ), i2[1][1] );
+ CPPUNIT_ASSERT_EQUAL( HYDROData_DTM::PointUZ( 11, 2 ), i2[1][2] );
+ CPPUNIT_ASSERT_EQUAL( B, i2[2] );
+
+ std::vector<HYDROData_DTM::CurveUZ> i3;
+ HYDROData_DTM::Interpolate( A, B, 3, i3, false );
+
+ CPPUNIT_ASSERT_EQUAL( 4, (int)i3.size() );
+ CPPUNIT_ASSERT_EQUAL( A, i3[0] );
+ CPPUNIT_ASSERT_EQUAL( 3, (int)i3[1].size() );
+ CPPUNIT_ASSERT_EQUAL( HYDROData_DTM::PointUZ( 2.5, 0 ), i3[1][0] );
+ CPPUNIT_ASSERT_EQUAL( HYDROData_DTM::PointUZ( 4.5, 1 ), i3[1][1] );
+ CPPUNIT_ASSERT_EQUAL( HYDROData_DTM::PointUZ( 6.5, 2 ), i3[1][2] );
+ }
+
+ void test_HYDROData_DTM::test_curve_to_3d()
+ {
+ Handle(HYDROData_Document) aDoc = HYDROData_Document::Document(1);
+
+ Handle(HYDROData_Profile) aProfile1 =
+ Handle(HYDROData_Profile)::DownCast( aDoc->CreateObject( KIND_PROFILE ) );
+
+ Handle(HYDROData_Profile) aProfile2 =
+ Handle(HYDROData_Profile)::DownCast( aDoc->CreateObject( KIND_PROFILE ) );
+
+ aProfile1->SetParametricPoints( points );
+ aProfile1->GetProfileUZ()->SetSectionType( 0, HYDROData_IPolyline::SECTION_POLYLINE );
+ aProfile1->SetLeftPoint( gp_XY( 20, 0 ) );
+ aProfile1->SetRightPoint( gp_XY( 10, 10 ) );
+
+ aProfile2->SetParametricPoints( points );
+ aProfile2->GetProfileUZ()->SetSectionType( 0, HYDROData_IPolyline::SECTION_POLYLINE );
+ aProfile2->SetLeftPoint( gp_XY( 100, 0 ) );
+ aProfile2->SetRightPoint( gp_XY( 110, 0 ) );
+
+ std::vector<double> distances;
+ std::vector<Handle(HYDROData_Profile)> profiles;
+ profiles.push_back( aProfile1 );
+ profiles.push_back( aProfile2 );
+
+ Handle_Geom2d_BSplineCurve HA = HYDROData_DTM::CreateHydraulicAxis( profiles, distances );
+ HYDROData_DTM::AltitudePoints points;
+ HYDROData_DTM::CurveUZ mid( 5.0, gp_Vec2d(-10,10), 0 );
+ mid.push_back( HYDROData_DTM::PointUZ( 0, 5 ) );
+ mid.push_back( HYDROData_DTM::PointUZ( 1, 6 ) );
+ HYDROData_DTM::CurveUZ wid( 5.0, gp_Vec2d(-10,10), 0 );
+ wid.push_back( HYDROData_DTM::PointUZ( 2, 5 ) );
+ wid.push_back( HYDROData_DTM::PointUZ( 6, 6 ) );
+ HYDROData_DTM::CurveTo3D( HA, mid, wid, points );
+
+ CPPUNIT_ASSERT_EQUAL( 4, (int)points.size() );
+ CPPUNIT_ASSERT_EQUAL( HYDROData_DTM::AltitudePoint( 16.380, -2.186, 6.0 ), points[0] );
+ CPPUNIT_ASSERT_EQUAL( HYDROData_DTM::AltitudePoint( 15.673, -1.479, 5.0 ), points[1] );
+ CPPUNIT_ASSERT_EQUAL( HYDROData_DTM::AltitudePoint( 14.259, -0.065, 5.0 ), points[2] );
+ CPPUNIT_ASSERT_EQUAL( HYDROData_DTM::AltitudePoint( 12.137, 2.056, 6.0 ), points[3] );
+
+ aDoc->Close();
+ }
+
+ void test_HYDROData_DTM::test_presentation()
+ {
+ Handle(HYDROData_Document) aDoc = HYDROData_Document::Document(1);
+
+ Handle(HYDROData_DTM) DTM = Handle(HYDROData_DTM)::DownCast( aDoc->CreateObject( KIND_DTM ) );
+
+ Handle(HYDROData_Profile) aProfile1 =
+ Handle(HYDROData_Profile)::DownCast( aDoc->CreateObject( KIND_PROFILE ) );
+
+ Handle(HYDROData_Profile) aProfile2 =
+ Handle(HYDROData_Profile)::DownCast( aDoc->CreateObject( KIND_PROFILE ) );
+
+ aProfile1->SetParametricPoints( points );
+ aProfile1->GetProfileUZ()->SetSectionType( 0, HYDROData_IPolyline::SECTION_SPLINE );
+ aProfile1->SetLeftPoint( gp_XY( 10, 10 ) );
+ aProfile1->SetRightPoint( gp_XY( 20, 0 ) );
+
+ aProfile2->SetParametricPoints( points );
+ aProfile2->GetProfileUZ()->SetSectionType( 0, HYDROData_IPolyline::SECTION_SPLINE );
+ aProfile2->SetLeftPoint( gp_XY( 110, 10 ) );
+ aProfile2->SetRightPoint( gp_XY( 100, 0 ) );
+
+ HYDROData_SequenceOfObjects seq;
+ seq.Append( aProfile1 );
+ seq.Append( aProfile2 );
+ DTM->SetProfiles( seq );
+ DTM->SetDDZ( 0.1 );
+ CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.1, DTM->GetDDZ(), EPS );
+ DTM->SetSpatialStep( 1.0 );
+ CPPUNIT_ASSERT_DOUBLES_EQUAL( 1.0, DTM->GetSpatialStep(), EPS );
+ DTM->Update();
+
+ CPPUNIT_ASSERT_EQUAL( 9177, (int)DTM->GetAltitudePoints().size() );
+
+ Handle_AIS_InteractiveContext aContext = TestViewer::context();
+ HYDROGUI_ShapeBathymetry* aBathPrs = new HYDROGUI_ShapeBathymetry( 0, aContext, DTM );
+ aBathPrs->update( true, false );
+
+ bool ColorScaleIsDisp = TestViewer::ColorScaleIsDisplayed();
+ TestViewer::showColorScale( true );
- Handle_Aspect_ColorScale aCS = TestViewer::colorScale();
++ Handle(AIS_ColorScale) aCS = TestViewer::colorScale();
+ aCS->SetMin( 0.0 );
+ aCS->SetMax( 5.0 );
+ aCS->SetNumberOfIntervals( 10 );
+ aBathPrs->UpdateWithColorScale( aCS );
+
+ QImage aDTMPrs = draw_DTM( aBathPrs, 0.5, 600, 600 );
+ CPPUNIT_ASSERT_IMAGES2( &aDTMPrs, "DTM_1" );
+ delete aBathPrs;
+ TestViewer::showColorScale( ColorScaleIsDisp );
+
+ aDoc->Close();
+ }
+
+ void test_HYDROData_DTM::test_garonne()
+ {
+ Handle(HYDROData_Document) aDoc = HYDROData_Document::Document(1);
+
+ TCollection_AsciiString fname = REF_DATA_PATH.toLatin1().data();
+ fname += "/Profiles.xyz";
+ NCollection_Sequence<int> bad_ids;
+
+ int aSize = HYDROData_Profile::ImportFromFile( aDoc, fname, bad_ids, true );
+
+ CPPUNIT_ASSERT_EQUAL( 0, bad_ids.Size() );
+ CPPUNIT_ASSERT_EQUAL( 46, aSize );
+
+ HYDROData_SequenceOfObjects profiles;
+ HYDROData_Iterator it( aDoc, KIND_PROFILE );
+ for( int i=0; it.More(); it.Next(), i++ )
+ {
+ if( i>=25 && i<=35 )
+ profiles.Append( Handle(HYDROData_Profile)::DownCast( it.Current() ) );
+ }
+
+ CPPUNIT_ASSERT_EQUAL( 11, (int)profiles.Size() );
+
+ Handle(HYDROData_DTM) DTM = Handle(HYDROData_DTM)::DownCast( aDoc->CreateObject( KIND_DTM ) );
+ DTM->SetProfiles( profiles );
+ DTM->SetDDZ( 0.1 );
+ DTM->SetSpatialStep( 1.0 );
+ CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.1, DTM->GetDDZ(), EPS );
+ CPPUNIT_ASSERT_DOUBLES_EQUAL( 1.0, DTM->GetSpatialStep(), EPS );
+ DTM->Update();
+
+ CPPUNIT_ASSERT_EQUAL( 282338, (int)DTM->GetAltitudePoints().size() );
+
+ Handle_AIS_InteractiveContext aContext = TestViewer::context();
+ HYDROGUI_ShapeBathymetry* aBathPrs = new HYDROGUI_ShapeBathymetry( 0, aContext, DTM );
+ aBathPrs->update( true, false );
+
+ bool ColorScaleIsDisp = TestViewer::ColorScaleIsDisplayed();
+
+ TestViewer::showColorScale( true );
++ Handle(AIS_ColorScale) aCS = TestViewer::colorScale();
+ aCS->SetMin( 0.0 );
+ aCS->SetMax( 25.0 );
+ aCS->SetNumberOfIntervals( 30 );
+ aBathPrs->UpdateWithColorScale( aCS );
+
+ QImage aDTMPrs = draw_DTM( aBathPrs, 0.5, 600, 600 );
+ CPPUNIT_ASSERT_IMAGES2( &aDTMPrs, "DTM_2" );
+ TestViewer::showColorScale( ColorScaleIsDisp );
+ delete aBathPrs;
+ aDoc->Close();
+
+ }
--- /dev/null
- Handle(HYDROData_DTM) aDTM =
- Handle(HYDROData_DTM)::DownCast( aStream->DTM() );
+ // 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_Stream.h>
+ #include <HYDROGUI_StreamDlg.h>
+ #include <HYDROData_Document.h>
+ #include <HYDROData_DTM.h>
+ #include <HYDROData_Stream.h>
+ #include <HYDROData_IPolyline.h>
+ #include <HYDROData_Profile.h>
+ #include <HYDROData_PolylineXY.h>
+ #include <HYDROData_Iterator.h>
+ #include <AIS_InteractiveContext.hxx>
+ #include <TestViewer.h>
+ #include <QApplication>
+ #include <QTest>
+
+ extern QString REF_DATA_PATH;
+ NCollection_Sequence<HYDROData_IPolyline::Point> points2;
+ const double EPS = 1E-3;
+
+ void test_HYDROData_Stream::setUp()
+ {
+ points2.Clear();
+ points2.Append( gp_XY( 0.0, 5.0 ) );
+ points2.Append( gp_XY( 1.0, 1.0 ) );
+ points2.Append( gp_XY( 1.5, 0.0 ) );
+ points2.Append( gp_XY( 4.0, 4.0 ) );
+ }
+
+ void test_HYDROData_Stream::tearDown()
+ {
+ }
+
+ void test_HYDROData_Stream::test_dialog()
+ {
+ HYDROGUI_StreamDlg* aDlg = new HYDROGUI_StreamDlg( 0, "stream" );
+ aDlg->show();
+ qApp->processEvents();
+
+ QImage aStreamDlgImage = QPixmap::grabWidget( aDlg ).toImage();
+ CPPUNIT_ASSERT_IMAGES2( &aStreamDlgImage, "StreamDlg" );
+
+ aDlg->setDDZ( 12.34 );
+ CPPUNIT_ASSERT_DOUBLES_EQUAL( 12.34, aDlg->getDDZ(), EPS );
+
+ aDlg->setSpatialStep( 56.78 );
+ CPPUNIT_ASSERT_DOUBLES_EQUAL( 56.78, aDlg->getSpatialStep(), EPS );
+
+ delete aDlg;
+ }
+
+ void test_HYDROData_Stream::test_alt_object()
+ {
+ Handle(HYDROData_Document) aDoc = HYDROData_Document::Document(1);
+
+ Handle(HYDROData_Stream) aStream =
+ Handle(HYDROData_Stream)::DownCast( aDoc->CreateObject( KIND_STREAM ) );
+
+ CPPUNIT_ASSERT_EQUAL( false, (bool)aStream.IsNull() );
+ CPPUNIT_ASSERT_EQUAL( true, (bool)aStream->GetAltitudeObject().IsNull() );
+ CPPUNIT_ASSERT_EQUAL( false, (bool)aStream->DTM().IsNull() );
+ CPPUNIT_ASSERT_EQUAL( false, (bool)aStream->GetAltitudeObject().IsNull() );
+ CPPUNIT_ASSERT_EQUAL( KIND_DTM, aStream->getAltitudeObjectType() );
+
+ Handle(HYDROData_DTM) aDTM =
+ Handle(HYDROData_DTM)::DownCast( aStream->GetAltitudeObject() );
+ CPPUNIT_ASSERT_EQUAL( false, (bool)aDTM.IsNull() );
+
+ aDoc->Close();
+ }
+
+ void test_HYDROData_Stream::test_params_sync()
+ {
+ Handle(HYDROData_Document) aDoc = HYDROData_Document::Document(1);
+
+ Handle(HYDROData_Stream) aStream =
+ Handle(HYDROData_Stream)::DownCast( aDoc->CreateObject( KIND_STREAM ) );
++ Handle(HYDROData_DTM) aDTM = aStream->DTM();
+ CPPUNIT_ASSERT_EQUAL( false, (bool)aDTM.IsNull() );
+
+ Handle(HYDROData_Profile) aProfile1 =
+ Handle(HYDROData_Profile)::DownCast( aDoc->CreateObject( KIND_PROFILE ) );
+
+ Handle(HYDROData_Profile) aProfile2 =
+ Handle(HYDROData_Profile)::DownCast( aDoc->CreateObject( KIND_PROFILE ) );
+
+ aProfile1->SetParametricPoints( points2 );
+ aProfile1->GetProfileUZ()->SetSectionType( 0, HYDROData_IPolyline::SECTION_POLYLINE );
+ aProfile1->SetLeftPoint( gp_XY( 10, 10 ) );
+ aProfile1->SetRightPoint( gp_XY( 20, 0 ) );
+
+ aProfile2->SetParametricPoints( points2 );
+ aProfile2->GetProfileUZ()->SetSectionType( 0, HYDROData_IPolyline::SECTION_POLYLINE );
+ aProfile2->SetLeftPoint( gp_XY( 50, 0 ) );
+ aProfile2->SetRightPoint( gp_XY( 60, 10 ) );
+
+ HYDROData_SequenceOfObjects profiles;
+ profiles.Append( aProfile1 );
+ profiles.Append( aProfile2 );
+
+ aStream->SetProfiles( profiles, false );
+ aStream->SetDDZ( 3.14 );
+ aStream->SetSpatialStep( 4.14 );
+
+ CPPUNIT_ASSERT_DOUBLES_EQUAL( 3.14, aStream->GetDDZ(), EPS );
+ CPPUNIT_ASSERT_DOUBLES_EQUAL( 3.14, aDTM->GetDDZ(), EPS );
+ CPPUNIT_ASSERT_DOUBLES_EQUAL( 4.14, aStream->GetSpatialStep(), EPS );
+ CPPUNIT_ASSERT_DOUBLES_EQUAL( 4.14, aDTM->GetSpatialStep(), EPS );
+
+ HYDROData_SequenceOfObjects profiles1 = aStream->GetProfiles();
+ CPPUNIT_ASSERT_EQUAL( 2, profiles1.Size() );
+ CPPUNIT_ASSERT( profiles.Value(1)->Label() == profiles1.Value(1)->Label() );
+ CPPUNIT_ASSERT( profiles.Value(2)->Label() == profiles1.Value(2)->Label() );
+
+ HYDROData_SequenceOfObjects profiles2 = aDTM->GetProfiles();
+ CPPUNIT_ASSERT_EQUAL( 2, profiles2.Size() );
+ CPPUNIT_ASSERT( profiles.Value(1)->Label() == profiles2.Value(1)->Label() );
+ CPPUNIT_ASSERT( profiles.Value(2)->Label() == profiles2.Value(2)->Label() );
+
+ aDoc->Close();
+ }
+
+ void test_HYDROData_Stream::test_dump()
+ {
+ // Case 1. Without hydraulic axis
+ Handle(HYDROData_Document) aDoc = HYDROData_Document::Document(1);
+
+ Handle(HYDROData_Stream) aStream1 =
+ Handle(HYDROData_Stream)::DownCast( aDoc->CreateObject( KIND_STREAM ) );
+ aStream1->SetName( "stream_1" );
+
+ Handle(HYDROData_Profile) aProfile1 =
+ Handle(HYDROData_Profile)::DownCast( aDoc->CreateObject( KIND_PROFILE ) );
+ aProfile1->SetName( "p1" );
+
+ Handle(HYDROData_Profile) aProfile2 =
+ Handle(HYDROData_Profile)::DownCast( aDoc->CreateObject( KIND_PROFILE ) );
+ aProfile2->SetName( "p2" );
+
+ aProfile1->SetParametricPoints( points2 );
+ aProfile1->GetProfileUZ()->SetSectionType( 0, HYDROData_IPolyline::SECTION_POLYLINE );
+ aProfile1->SetLeftPoint( gp_XY( 10, 10 ) );
+ aProfile1->SetRightPoint( gp_XY( 20, 0 ) );
+
+ aProfile2->SetParametricPoints( points2 );
+ aProfile2->GetProfileUZ()->SetSectionType( 0, HYDROData_IPolyline::SECTION_POLYLINE );
+ aProfile2->SetLeftPoint( gp_XY( 50, 0 ) );
+ aProfile2->SetRightPoint( gp_XY( 60, 10 ) );
+
+ HYDROData_SequenceOfObjects profiles;
+ profiles.Append( aProfile1 );
+ profiles.Append( aProfile2 );
+
+ aStream1->SetProfiles( profiles, false );
+ aStream1->SetDDZ( 0.2 );
+ aStream1->SetSpatialStep( 3.0 );
+
+ MapOfTreatedObjects objs;
+ objs["p1"] = aProfile1;
+ objs["p2"] = aProfile2;
+
+ QStringList aScript1 = aStream1->DumpToPython( "", objs );
+ CPPUNIT_ASSERT_EQUAL( 10, aScript1.size() );
+ CPPUNIT_ASSERT_EQUAL( std::string( "stream_1 = hydro_doc.CreateObject( KIND_STREAM )" ), aScript1[0].toStdString() );
+ CPPUNIT_ASSERT_EQUAL( std::string( "stream_1.SetName( \"stream_1\" )" ), aScript1[1].toStdString() );
+ CPPUNIT_ASSERT_EQUAL( std::string( "" ), aScript1[2].toStdString() );
+ CPPUNIT_ASSERT_EQUAL( std::string( "stream_1.AddProfile( p1 )" ), aScript1[3].toStdString() );
+ CPPUNIT_ASSERT_EQUAL( std::string( "stream_1.AddProfile( p2 )" ), aScript1[4].toStdString() );
+ CPPUNIT_ASSERT_EQUAL( std::string( "stream_1.SetDDZ( 0.200 )" ), aScript1[5].toStdString() );
+ CPPUNIT_ASSERT_EQUAL( std::string( "stream_1.SetSpatialStep( 3.000 )" ), aScript1[6].toStdString() );
+ CPPUNIT_ASSERT_EQUAL( std::string( "" ), aScript1[7].toStdString() );
+ CPPUNIT_ASSERT_EQUAL( std::string( "stream_1.Update()" ), aScript1[8].toStdString() );
+ CPPUNIT_ASSERT_EQUAL( std::string( "" ), aScript1[9].toStdString() );
+
+ // Case 2. With hydraulic axis
+
+ Handle(HYDROData_Stream) aStream2 =
+ Handle(HYDROData_Stream)::DownCast( aDoc->CreateObject( KIND_STREAM ) );
+ aStream2->SetName( "stream_2" );
+
+ Handle(HYDROData_PolylineXY) anHAxis =
+ Handle(HYDROData_PolylineXY)::DownCast( aDoc->CreateObject( KIND_POLYLINEXY ) );
+ anHAxis->SetName( "axis" );
+
+ aStream2->SetProfiles( profiles, false );
+ aStream2->SetDDZ( 0.2 );
+ aStream2->SetSpatialStep( 3.0 );
+ aStream2->SetReferenceObject( anHAxis, HYDROData_Stream::DataTag_HydraulicAxis );
+
+ objs.clear();
+ objs["p1"] = aProfile1;
+ objs["p2"] = aProfile2;
+ objs["axis"] = anHAxis;
+
+ QStringList aScript2 = aStream2->DumpToPython( "", objs );
+ CPPUNIT_ASSERT_EQUAL( 11, aScript2.size() );
+ CPPUNIT_ASSERT_EQUAL( std::string( "stream_2 = hydro_doc.CreateObject( KIND_STREAM )" ), aScript2[0].toStdString() );
+ CPPUNIT_ASSERT_EQUAL( std::string( "stream_2.SetName( \"stream_2\" )" ), aScript2[1].toStdString() );
+ CPPUNIT_ASSERT_EQUAL( std::string( "" ), aScript2[2].toStdString() );
+ CPPUNIT_ASSERT_EQUAL( std::string( "stream_2.SetHydraulicAxis( axis )" ), aScript2[3].toStdString() );
+ CPPUNIT_ASSERT_EQUAL( std::string( "stream_2.AddProfile( p1 )" ), aScript2[4].toStdString() );
+ CPPUNIT_ASSERT_EQUAL( std::string( "stream_2.AddProfile( p2 )" ), aScript2[5].toStdString() );
+ CPPUNIT_ASSERT_EQUAL( std::string( "stream_2.SetDDZ( 0.200 )" ), aScript2[6].toStdString() );
+ CPPUNIT_ASSERT_EQUAL( std::string( "stream_2.SetSpatialStep( 3.000 )" ), aScript2[7].toStdString() );
+ CPPUNIT_ASSERT_EQUAL( std::string( "" ), aScript2[8].toStdString() );
+ CPPUNIT_ASSERT_EQUAL( std::string( "stream_2.Update()" ), aScript2[9].toStdString() );
+ CPPUNIT_ASSERT_EQUAL( std::string( "" ), aScript2[10].toStdString() );
+
+ aDoc->Close();
+ }
+
+ void test_HYDROData_Stream::test_presentation()
+ {
+ Handle(HYDROData_Document) aDoc = HYDROData_Document::Document(1);
+
+ TCollection_AsciiString fname = REF_DATA_PATH.toLatin1().data();
+ fname += "/Profiles.xyz";
+ NCollection_Sequence<int> bad_ids;
+
+ int aSize = HYDROData_Profile::ImportFromFile( aDoc, fname, bad_ids, true );
+
+ CPPUNIT_ASSERT_EQUAL( 0, bad_ids.Size() );
+ CPPUNIT_ASSERT_EQUAL( 46, aSize );
+
+ HYDROData_SequenceOfObjects profiles;
+ HYDROData_Iterator it( aDoc, KIND_PROFILE );
+ for( int i=0; it.More(); it.Next(), i++ )
+ {
+ if( i>=25 && i<=35 )
+ {
+ it.Current()->Update();
+ profiles.Append( Handle(HYDROData_Profile)::DownCast( it.Current() ) );
+ }
+ }
+
+ Handle(HYDROData_Stream) aStream =
+ Handle(HYDROData_Stream)::DownCast( aDoc->CreateObject( KIND_STREAM ) );
+
+ aStream->SetProfiles( profiles, false );
+ aStream->SetDDZ( 0.2 );
+ aStream->SetSpatialStep( 10 );
+ aStream->Update();
+
+ TopoDS_Shape aPrs3d = aStream->GetShape3D();
+ TopoDS_Shape aPrs2d = aStream->GetTopShape();
+
+ TestViewer::show( aPrs2d, 0, true, "stream_dtm_2d" );
+ CPPUNIT_ASSERT_IMAGES;
+
+ TestViewer::eraseAll( true );
+ TestViewer::show( aPrs3d, 0, true, "stream_dtm_3d" );
+ CPPUNIT_ASSERT_IMAGES
+
+ aDoc->Close();
+ }
+