+// 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 "HYDROData_PolylineXY.h"
{
const Point& aSectPoint = aSectPointsList.Value( k );
+ QString anXStr = QString::number( aSectPoint.X(), 'f', 2 );
+ QString anYStr = QString::number( aSectPoint.Y(), 'f', 2 );
aResList << QString( "%1.AddPoint( %2, gp_XY( %3, %4 ) );" ).arg( aPolylineName )
- .arg( i - 1 ).arg( aSectPoint.X() ).arg( aSectPoint.Y() );
+ .arg( i - 1 ).arg( anXStr ).arg( anYStr );
}
}
}
if ( thePoints.Size() > 1 )
{
- HYDROData_BSplineOperation aBSpline( thePoints, theIsClosed, LOCAL_SELECTION_TOLERANCE );
+ Handle(Geom_BSplineCurve) aCurve =
+ HYDROData_BSplineOperation::ComputeCurve( thePoints, theIsClosed, LOCAL_SELECTION_TOLERANCE );
- TopoDS_Edge anEdge = BRepBuilderAPI_MakeEdge( aBSpline.Curve() ).Edge();
+ TopoDS_Edge anEdge = BRepBuilderAPI_MakeEdge( aCurve ).Edge();
aMakeWire.Add( anEdge );
}
aMakeWire.Build();
}
else
{
- HYDROData_BSplineOperation aBSpline( thePoints, theIsClosed, LOCAL_SELECTION_TOLERANCE );
- aBSpline.ComputePath( thePath );
+ Handle(Geom_BSplineCurve) aCurve =
+ HYDROData_BSplineOperation::ComputeCurve( thePoints, theIsClosed, LOCAL_SELECTION_TOLERANCE );
+ HYDROData_BSplineOperation::ComputePath( aCurve, thePath );
}
}
aPointToTest = aPoint;
}
- HYDROData_BSplineOperation aBSpline( aPoints, anIsSectionClosed, LOCAL_SELECTION_TOLERANCE );
+ Handle(Geom_BSplineCurve) aCurve =
+ HYDROData_BSplineOperation::ComputeCurve( aPoints, anIsSectionClosed, LOCAL_SELECTION_TOLERANCE );
- Quantity_Parameter aFirstParam = aBSpline.Curve()->FirstParameter();
- Quantity_Parameter aSecondParam = aBSpline.Curve()->LastParameter();
+ Quantity_Parameter aFirstParam = aCurve->FirstParameter();
+ Quantity_Parameter aSecondParam = aCurve->LastParameter();
if ( thePointIndex != aSectNbPoints - 1 )
{
- GeomAPI_ProjectPointOnCurve aProject( aPointToTest, aBSpline.Curve() );
+ GeomAPI_ProjectPointOnCurve aProject( aPointToTest, aCurve );
aSecondParam = aProject.LowerDistanceParameter();
}
- GeomAdaptor_Curve anAdap( aBSpline.Curve() );
+ GeomAdaptor_Curve anAdap( aCurve );
aResDistance = GCPnts_AbscissaPoint::Length( anAdap, aFirstParam, aSecondParam );
}
SetToUpdate( true );
}
+void HYDROData_PolylineXY::Transform( const QTransform& theTrsf )
+{
+ NCollection_Sequence<TCollection_AsciiString> aSectNames;
+ NCollection_Sequence<HYDROData_PolylineXY::SectionType> aSectTypes;
+ NCollection_Sequence<bool> aSectClosures;
+ GetSections( aSectNames, aSectTypes, aSectClosures );
+
+ for ( int i = 0, aNbSects = aSectNames.Size(); i < aNbSects; i++ ) {
+ PointsList aPoints = GetPoints( i );
+ for( int j = 1, n = aPoints.Size(); j <= n; ++j ) {
+ Point& aPoint = aPoints.ChangeValue( j );
+
+ QPointF aTrsfPoint = theTrsf.map( QPointF( aPoint.X(), aPoint.Y() ) );
+ aPoint.SetX( aTrsfPoint.x() );
+ aPoint.SetY( aTrsfPoint.y() );
+ }
+ SetPoints( i, aPoints );
+ }
+
+ Update();
+}