1 // Copyright (C) 2014-2015 EDF-R&D
2 // This library is free software; you can redistribute it and/or
3 // modify it under the terms of the GNU Lesser General Public
4 // License as published by the Free Software Foundation; either
5 // version 2.1 of the License, or (at your option) any later version.
7 // This library is distributed in the hope that it will be useful,
8 // but WITHOUT ANY WARRANTY; without even the implied warranty of
9 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
10 // Lesser General Public License for more details.
12 // You should have received a copy of the GNU Lesser General Public
13 // License along with this library; if not, write to the Free Software
14 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
19 #include "HYDROData_PolylineXY.h"
21 #include "HYDROData_BSplineOperation.h"
22 #include "HYDROData_Document.h"
23 #include "HYDROData_ShapesTool.h"
24 #include "HYDROData_Tool.h"
25 #include "HYDROData_PolylineOperator.h"
26 #include "HYDROData_TopoCurve.h"
28 #include <BRep_Builder.hxx>
29 #include <BRepBuilderAPI_MakeEdge.hxx>
30 #include <BRepBuilderAPI_MakeWire.hxx>
31 #include <BRepBuilderAPI_MakePolygon.hxx>
32 #include <BRepBuilderAPI_MakeFace.hxx>
33 #include <BRepOffsetAPI_NormalProjection.hxx>
34 #include <BRepAdaptor_Curve.hxx>
40 #include <GeomAPI_ProjectPointOnCurve.hxx>
41 #include <GeomAdaptor_Curve.hxx>
42 #include <Geom_Line.hxx>
43 #include <Geom_BSplineCurve.hxx>
45 #include <GCPnts_AbscissaPoint.hxx>
46 #include <GCPnts_QuasiUniformDeflection.hxx>
47 #include <GCPnts_UniformDeflection.hxx>
49 #include <ImageComposer_MetaTypes.h>
55 #include <NCollection_Map.hxx>
57 #include <TCollection_ExtendedString.hxx>
59 #include <TDataStd_ListIteratorOfListOfByte.hxx>
60 #include <TColStd_ListIteratorOfListOfInteger.hxx>
61 #include <TColStd_ListIteratorOfListOfReal.hxx>
63 #include <TColStd_Array1OfReal.hxx>
64 #include <TColgp_Array1OfPnt.hxx>
66 #include <TDataStd_AsciiString.hxx>
67 #include <TDataStd_BooleanList.hxx>
68 #include <TDataStd_ExtStringList.hxx>
69 #include <TDataStd_IntegerList.hxx>
70 #include <TDataStd_ListIteratorOfListOfExtendedString.hxx>
71 #include <TDataStd_RealList.hxx>
72 #include <TDataStd_UAttribute.hxx>
74 #include <TopoDS_Iterator.hxx>
75 #include <TopTools_ListIteratorOfListOfShape.hxx>
76 #include <TopTools_HSequenceOfShape.hxx>
77 #include <TopExp_Explorer.hxx>
78 #include <ShapeAnalysis_FreeBounds.hxx>
82 #include <QPainterPath>
86 #include "HYDRO_trace.hxx"
87 #include <BRepTools.hxx>
90 static const Standard_GUID GUID_IS_UNEDITABLE("e5799736-9030-4051-91a4-2e58321fa153");
92 const double LOCAL_SELECTION_TOLERANCE = 0.0001;
94 TCollection_AsciiString getUniqueSectionName( const NCollection_Sequence<TCollection_AsciiString>& theNamesSeq )
96 NCollection_Map<TCollection_AsciiString> aNamesMap;
98 for ( int i = 1, n = theNamesSeq.Size(); i <= n; ++i )
100 const TCollection_AsciiString& aSectName = theNamesSeq.Value( i );
101 aNamesMap.Add( aSectName );
104 TCollection_AsciiString aResName;
109 aResName = TCollection_AsciiString( "Section_" ) + aPrefIdx;
112 while ( aNamesMap.Contains( aResName ) );
117 TCollection_AsciiString getUniqueSectionName( const Handle(TDataStd_ExtStringList)& theNamesList )
119 NCollection_Sequence<TCollection_AsciiString> aNamesSeq;
121 TDataStd_ListIteratorOfListOfExtendedString aNamesIter( theNamesList->List() );
122 for ( ; aNamesIter.More(); aNamesIter.Next() )
123 aNamesSeq.Append( aNamesIter.Value() );
125 return getUniqueSectionName( aNamesSeq );
128 IMPLEMENT_STANDARD_HANDLE(HYDROData_PolylineXY, HYDROData_IPolyline)
129 IMPLEMENT_STANDARD_RTTIEXT(HYDROData_PolylineXY, HYDROData_IPolyline)
131 HYDROData_PolylineXY::HYDROData_PolylineXY()
132 : HYDROData_IPolyline(),
133 myIsInCustomFlag( false )
137 HYDROData_PolylineXY::~HYDROData_PolylineXY()
141 QStringList HYDROData_PolylineXY::DumpToPython( const QString& thePyScriptPath,
142 MapOfTreatedObjects& theTreatedObjects ) const
144 QStringList aResList = dumpObjectCreation( theTreatedObjects );
145 QString aPolylineName = GetObjPyName();
147 // Set the wire color
148 QStringList aWireColorDef;
150 QColor aWireColor = GetWireColor();
151 setPythonObjectColor( aWireColorDef, aWireColor, DefaultWireColor(), "SetWireColor" );
153 if ( !aWireColorDef.isEmpty() )
155 aResList << aWireColorDef;
156 aResList << QString( "" );
159 bool anIsEditable = IsEditable();
162 // If polyline is not editable we try to import the shape from geom
163 TCollection_AsciiString aGeomObjectEntry = GetGeomObjectEntry();
164 if ( !aGeomObjectEntry.IsEmpty() )
166 QString aSalomeObjName = HYDROData_Tool::GenerateNameForPython( theTreatedObjects, "polyline_sobj" );
167 aResList << QString( "%1 = salome.myStudy.FindObjectID( \"%2\" )" )
168 .arg( aSalomeObjName ).arg( aGeomObjectEntry.ToCString() );
170 aResList << QString( "%1.ImportFromGeomIOR( %2.GetIOR() )" )
171 .arg( aPolylineName ).arg( aSalomeObjName );
173 aResList << QString( "%1.SetGeomObjectEntry( \"%2\" )" )
174 .arg( aPolylineName ).arg( aGeomObjectEntry.ToCString() );
180 NCollection_Sequence<TCollection_AsciiString> aSectNames;
181 NCollection_Sequence<HYDROData_PolylineXY::SectionType> aSectTypes;
182 NCollection_Sequence<bool> aSectClosures;
183 GetSections( aSectNames, aSectTypes, aSectClosures );
185 for ( int i = 1, n = aSectNames.Size(); i <= n; ++i )
187 const TCollection_AsciiString& aSectName = aSectNames.Value( i );
188 const SectionType& aSectType = aSectTypes.Value( i );
189 bool aSectClosure = aSectClosures.Value( i );
191 aResList << QString( "%1.AddSection( \"%2\", %3, %4 )" ).arg( aPolylineName )
192 .arg( aSectName.ToCString() ).arg( aSectType ).arg( aSectClosure );
194 HYDROData_IPolyline::PointsList aSectPointsList = GetPoints( i - 1 );
195 for ( int k = 1, aNbPoints = aSectPointsList.Size(); k <= aNbPoints; ++k )
197 const Point& aSectPoint = aSectPointsList.Value( k );
199 QString anXStr = QString::number( aSectPoint.X(), 'f', 2 );
200 QString anYStr = QString::number( aSectPoint.Y(), 'f', 2 );
201 aResList << QString( "%1.AddPoint( %2, gp_XY( %3, %4 ) )" ).arg( aPolylineName )
202 .arg( i - 1 ).arg( anXStr ).arg( anYStr );
206 aResList << QString( "" );
207 aResList << QString( "%1.Update()" ).arg( aPolylineName );
208 aResList << QString( "" );
213 QVariant HYDROData_PolylineXY::GetDataVariant()
215 QPainterPath aPath = GetPainterPath();
218 aVarData.setValue<QPainterPath>( aPath );
223 QColor HYDROData_PolylineXY::DefaultWireColor()
225 return QColor( Qt::black );
228 bool HYDROData_PolylineXY::ImportFromGeomIOR( const TCollection_AsciiString& theIOR )
233 if ( theIOR.IsEmpty() )
236 TopoDS_Shape aShape = GEOMBase::GetShapeFromIOR( theIOR.ToCString() );
237 if ( aShape.IsNull() )
240 return ImportShape( aShape, false );
244 void HYDROData_PolylineXY::SetGeomObjectEntry( const TCollection_AsciiString& theEntry )
246 TDataStd_AsciiString::Set( myLab.FindChild( DataTag_GeomObjectEntry ), theEntry );
249 TCollection_AsciiString HYDROData_PolylineXY::GetGeomObjectEntry() const
251 TCollection_AsciiString aRes;
253 TDF_Label aLabel = myLab.FindChild( DataTag_GeomObjectEntry, false );
254 if ( !aLabel.IsNull() )
256 Handle(TDataStd_AsciiString) anAsciiStr;
257 if ( aLabel.FindAttribute( TDataStd_AsciiString::GetID(), anAsciiStr ) )
258 aRes = anAsciiStr->Get();
264 bool convertEdgeToSection( const TopoDS_Edge& theEdge,
265 NCollection_Sequence<TCollection_AsciiString>& theSectNames,
266 NCollection_Sequence<HYDROData_PolylineXY::SectionType>& theSectTypes,
267 NCollection_Sequence<bool>& theSectClosures,
268 NCollection_Sequence<HYDROData_PolylineXY::PointsList>& theSectPoints,
270 bool IsInterpolationAllowed,
271 double theDeflection )
273 Standard_Real aFirst = 0.0, aLast = 0.0;
274 Handle(Geom_Curve) anEdgeGeomCurve = BRep_Tool::Curve( theEdge, aFirst, aLast );
275 if ( anEdgeGeomCurve.IsNull() )
278 TCollection_AsciiString aSectName = getUniqueSectionName( theSectNames );
279 bool anIsEdgeClosed = anEdgeGeomCurve->IsClosed();
281 HYDROData_PolylineXY::SectionType aSectionType = HYDROData_PolylineXY::SECTION_POLYLINE;
282 HYDROData_PolylineXY::PointsList aPointsList;
284 if( anEdgeGeomCurve->IsKind( STANDARD_TYPE(Geom_Line) ) )
286 Handle(Geom_Line) aGeomLine = Handle(Geom_Line)::DownCast( anEdgeGeomCurve );
288 gp_Pnt aFirstPoint, aLastPoint;
289 aGeomLine->D0( aFirst, aFirstPoint );
290 aGeomLine->D0( aLast, aLastPoint );
292 HYDROData_PolylineXY::Point aSectFirstPoint( aFirstPoint.X(), aFirstPoint.Y() );
293 aPointsList.Append( aSectFirstPoint );
295 HYDROData_PolylineXY::Point aSectLastPoint( aLastPoint.X(), aLastPoint.Y() );
296 aPointsList.Append( aSectLastPoint );
298 else if ( anEdgeGeomCurve->IsKind( STANDARD_TYPE(Geom_BSplineCurve) ) || IsInterpolationAllowed )
300 aSectionType = HYDROData_PolylineXY::SECTION_SPLINE;
302 BRepAdaptor_Curve anAdaptorCurve( theEdge );
303 GCPnts_QuasiUniformDeflection aDiscrete( anAdaptorCurve, theDeflection );
304 //GCPnts_UniformDeflection aDiscrete( anAdaptorCurve, theDeflection );
306 int aNbPoints = aDiscrete.NbPoints();
308 // Decrease the number of imported poles because of last one
309 // pole is the closing point which are the start point
310 if ( anIsEdgeClosed ) aNbPoints--;
312 for ( int i = 1; i <= aNbPoints; ++i )
314 const gp_Pnt& aPoint = aDiscrete.Value( i );
316 HYDROData_PolylineXY::Point aSectPoint( aPoint.X(), aPoint.Y() );
317 aPointsList.Append( aSectPoint );
322 // Other curve types are not supported
326 if ( aPointsList.IsEmpty() )
329 theSectNames.Append( aSectName );
330 theSectTypes.Append( aSectionType );
331 theSectClosures.Append( anIsEdgeClosed );
332 theSectPoints.Append( aPointsList );
338 bool convertEdgesToSections( const TopoDS_Edge& theEdge,
339 NCollection_Sequence<TCollection_AsciiString>& theSectNames,
340 NCollection_Sequence<HYDROData_PolylineXY::SectionType>& theSectTypes,
341 NCollection_Sequence<bool>& theSectClosures,
342 NCollection_Sequence<HYDROData_PolylineXY::PointsList>& theSectPoints,
344 bool IsInterpolationAllowed,
345 double theDeflection )
347 DEBTRACE("convertEdgesToSections")
348 Standard_Real aFirst = 0.0, aLast = 0.0;
349 Handle(Geom_Curve) anEdgeGeomCurve = BRep_Tool::Curve( theEdge, aFirst, aLast );
350 if ( anEdgeGeomCurve.IsNull() )
353 bool isPrevious = (theSectTypes.Size() > 0);
354 DEBTRACE("nb sections: " << theSectTypes.Size());
355 HYDROData_PolylineXY::SectionType prevSectType = HYDROData_PolylineXY::SECTION_SPLINE;;
356 HYDROData_PolylineXY::PointsList prevPointList;
357 bool isPrevClosed = true;
360 prevSectType = theSectTypes.Last();
361 prevPointList = theSectPoints.Last();
362 isPrevClosed = theSectClosures.Last();
365 bool anIsEdgeClosed = anEdgeGeomCurve->IsClosed();
366 anIsEdgeClosed &= IsCanBeClosed; // on split, resulting edges are normally not closed...
367 HYDROData_PolylineXY::SectionType aSectionType ;
368 if( anEdgeGeomCurve->IsKind( STANDARD_TYPE(Geom_Line) ) )
370 aSectionType = HYDROData_PolylineXY::SECTION_POLYLINE;
372 else if ( anEdgeGeomCurve->IsKind( STANDARD_TYPE(Geom_BSplineCurve) ) || IsInterpolationAllowed )
374 aSectionType = HYDROData_PolylineXY::SECTION_SPLINE;
378 // Other curve types are not supported
382 bool isNewSection = !isPrevious || isPrevClosed || anIsEdgeClosed || prevSectType != aSectionType;
383 DEBTRACE(isNewSection <<": " << !isPrevious << " " << isPrevClosed << " " << anIsEdgeClosed << " " << (prevSectType != aSectionType));
385 HYDROData_PolylineXY::PointsList aPointsList;
388 aPointsList = prevPointList;
391 if( aSectionType == HYDROData_PolylineXY::SECTION_POLYLINE )
393 DEBTRACE("SECTION_POLYLINE");
394 Handle(Geom_Line) aGeomLine = Handle(Geom_Line)::DownCast( anEdgeGeomCurve );
396 gp_Pnt aFirstPoint, aLastPoint;
397 aGeomLine->D0( aFirst, aFirstPoint );
398 aGeomLine->D0( aLast, aLastPoint );
399 HYDROData_PolylineXY::Point aSectFirstPoint( aFirstPoint.X(), aFirstPoint.Y() );
400 HYDROData_PolylineXY::Point aSectLastPoint( aLastPoint.X(), aLastPoint.Y() );
403 if (aSectFirstPoint == prevPointList.Last())
405 DEBTRACE("points shared: a");//aPointsList.Append( aSectFirstPoint );
406 aPointsList.Append( aSectLastPoint );
408 else if (aSectLastPoint == prevPointList.Last())
410 DEBTRACE("points shared: b");//aPointsList.Append( aSectLastPoint );
411 aPointsList.Append( aSectFirstPoint );
413 else if (aSectFirstPoint == prevPointList.First())
415 DEBTRACE("points shared: c");//aPointsList.Prepend( aSectFirstPoint );
416 aPointsList.Prepend( aSectLastPoint );
418 else if (aSectLastPoint == prevPointList.First())
420 DEBTRACE("points shared: d");//aPointsList.Prepend( aSectLastPoint );
421 aPointsList.Prepend( aSectFirstPoint );
425 DEBTRACE("no point shared")
426 isNewSection = true; // no point shared, new section
428 aPointsList.Append( aSectFirstPoint );
429 aPointsList.Append( aSectLastPoint );
434 DEBTRACE("new section");
435 aPointsList.Append( aSectFirstPoint );
436 aPointsList.Append( aSectLastPoint );
439 else // aSectionType == HYDROData_PolylineXY::SECTION_SPLINE
441 DEBTRACE("SECTION_SPLINE");
445 BRepAdaptor_Curve anAdaptorCurve( theEdge );
446 GCPnts_QuasiUniformDeflection aDiscrete( anAdaptorCurve, theDeflection );
448 int aNbPoints = aDiscrete.NbPoints();
450 // Decrease the number of imported poles because of last one
451 // pole is the closing point which are the start point
452 if ( anIsEdgeClosed ) aNbPoints--;
454 for ( int i = 1; i <= aNbPoints; ++i )
456 const gp_Pnt& aPoint = aDiscrete.Value( i );
458 HYDROData_PolylineXY::Point aSectPoint( aPoint.X(), aPoint.Y() );
459 aPointsList.Append( aSectPoint );
463 if ( aPointsList.IsEmpty() )
466 TCollection_AsciiString aSectName = getUniqueSectionName( theSectNames );
469 DEBTRACE("isNewSection");
470 theSectNames.Append( aSectName );
471 theSectTypes.Append( aSectionType );
472 theSectClosures.Append( anIsEdgeClosed );
473 theSectPoints.Append( aPointsList );
477 DEBTRACE("sameSection");
478 theSectPoints.SetValue(theSectPoints.Length(), aPointsList);
484 bool HYDROData_PolylineXY::ImportShape( const TopoDS_Shape& theShape,
485 bool IsInterpolationAllowed,
486 bool IsClosureAllowed,
487 double theDeviation )
489 DEBTRACE("ImportShape");
490 if ( theShape.IsNull() )
495 bool anIsCanBeImported = false;
497 NCollection_Sequence<TCollection_AsciiString> aSectNames;
498 NCollection_Sequence<SectionType> aSectTypes;
499 NCollection_Sequence<bool> aSectClosures;
500 NCollection_Sequence<PointsList> aSectPoints;
502 if ( theShape.ShapeType() == TopAbs_EDGE )
504 DEBTRACE("TopAbs_EDGE");
505 TopoDS_Edge anEdge = TopoDS::Edge( theShape );
506 // anIsCanBeImported = convertEdgeToSection( anEdge, aSectNames, aSectTypes,
507 // aSectClosures, aSectPoints, true, IsInterpolationAllowed, theDeviation );
508 anIsCanBeImported = convertEdgesToSections( anEdge, aSectNames, aSectTypes,
509 aSectClosures, aSectPoints, IsClosureAllowed, IsInterpolationAllowed, theDeviation );
511 else if ( theShape.ShapeType() == TopAbs_WIRE )
513 DEBTRACE("TopAbs_WIRE");
514 TopTools_SequenceOfShape anEdges;
515 HYDROData_ShapesTool::ExploreShapeToShapes( theShape, TopAbs_EDGE, anEdges );
517 anIsCanBeImported = !anEdges.IsEmpty();
518 for ( int i = 1, n = anEdges.Length(); i <= n && anIsCanBeImported; ++i )
520 TopoDS_Edge aWireEdge = TopoDS::Edge( anEdges.Value( i ) );
521 anIsCanBeImported = convertEdgesToSections( aWireEdge, aSectNames, aSectTypes,
522 aSectClosures, aSectPoints, IsClosureAllowed, IsInterpolationAllowed, theDeviation );
526 if ( anIsCanBeImported )
528 for ( int i = 1, n = aSectNames.Length(); i <= n; ++i )
530 const TCollection_AsciiString& aSectName = aSectNames.Value( i );
531 const SectionType& aSectType = aSectTypes.Value( i );
532 bool anIsSectionClosed = aSectClosures.Value( i );
533 const PointsList& aSectPointsList = aSectPoints( i );
535 AddSection( aSectName, aSectType, anIsSectionClosed );
536 SetPoints( i - 1, aSectPointsList );
541 TopoDS_Shape aShape = theShape;
543 if ( theShape.ShapeType() == TopAbs_EDGE )
545 // We make the wire from incoming edge because of other algorithms
546 // are waiting at least the wire from polyline
547 TopoDS_Edge anEdge = TopoDS::Edge( theShape );
548 BRepBuilderAPI_MakeWire aMakeWire( anEdge );
550 if ( aMakeWire.IsDone() )
551 aShape = aMakeWire.Wire();
554 gp_Pln aPlane( gp_Pnt( 0, 0, 0 ), gp_Dir( 0, 0, 1 ) );
555 BRepBuilderAPI_MakeFace aMakeFace( aPlane );
557 BRepOffsetAPI_NormalProjection aProj( aMakeFace.Face() );
560 TopoDS_Shape aResult;
562 aResult = aProj.Shape();
567 setEditable( anIsCanBeImported );
572 TopoDS_Wire HYDROData_PolylineXY::BuildWire( const SectionType& theType,
573 const bool& theIsClosed,
574 const NCollection_Sequence<gp_XYZ>& thePoints )
577 if( theType == SECTION_POLYLINE )
579 int aNbPoints = thePoints.Length();
580 BRepBuilderAPI_MakePolygon aMakeWire;
581 for ( int i = 1, n = aNbPoints; i <= n ; ++i )
583 gp_XYZ aPoint = thePoints.Value( i );
584 gp_Pnt aPnt( aPoint.X(), aPoint.Y(), aPoint.Z() );
585 aMakeWire.Add( aPnt );
587 if( theIsClosed && ( aNbPoints > 2 ) )
590 if ( aMakeWire.IsDone() )
591 aWire = aMakeWire.Wire();
593 else //if( theType == PolylineSection::SECTION_SPLINE )
595 BRepBuilderAPI_MakeWire aMakeWire;
597 if ( thePoints.Size() > 1 )
599 Handle(Geom_BSplineCurve) aCurve =
600 HYDROData_BSplineOperation::ComputeCurve( thePoints, theIsClosed, LOCAL_SELECTION_TOLERANCE );
602 TopoDS_Edge anEdge = BRepBuilderAPI_MakeEdge( aCurve ).Edge();
603 aMakeWire.Add( anEdge );
606 if ( aMakeWire.IsDone() )
613 void HYDROData_PolylineXY::BuildPainterPath( QPainterPath& thePath,
614 const SectionType& theType,
615 const bool& theIsClosed,
616 const NCollection_Sequence<gp_XYZ>& thePoints )
618 if ( thePoints.IsEmpty() )
621 if ( theType == SECTION_POLYLINE )
623 const gp_XYZ& aFirstPoint = thePoints.Value( 1 );
624 thePath.moveTo( aFirstPoint.X(), aFirstPoint.Y() );
626 for( int i = 2, n = thePoints.Size(); i <= n; ++i )
628 const gp_XYZ& aSectPoint = thePoints.Value( i );
630 thePath.lineTo( aSectPoint.X(), aSectPoint.Y() );
634 thePath.closeSubpath();
638 Handle(Geom_BSplineCurve) aCurve =
639 HYDROData_BSplineOperation::ComputeCurve( thePoints, theIsClosed, LOCAL_SELECTION_TOLERANCE );
640 HYDROData_BSplineOperation::ComputePath( aCurve, thePath );
644 void HYDROData_PolylineXY::Update()
648 // If polyline is not editable we no need to update it wire
653 HYDROData_IPolyline::Update();
655 NCollection_Sequence<TCollection_AsciiString> aSectNames;
656 NCollection_Sequence<HYDROData_PolylineXY::SectionType> aSectTypes;
657 NCollection_Sequence<bool> aSectClosures;
658 GetSections( aSectNames, aSectTypes, aSectClosures );
660 //BRepBuilderAPI_MakeWire aMakeWire;
662 TopTools_ListOfShape aSectionWiresList;
664 for ( int aSectionId = 1, aNbSects = aSectNames.Size(); aSectionId <= aNbSects; aSectionId++ )
666 TCollection_AsciiString aSectName = aSectNames.Value( aSectionId );
667 SectionType aSectionType = aSectTypes.Value( aSectionId );
668 bool anIsSectionClosed = aSectClosures.Value( aSectionId );
670 PointsList aSectPointsList = GetPoints( aSectionId - 1 );
671 if ( aSectPointsList.IsEmpty() )
674 NCollection_Sequence<gp_XYZ> aPoints;
675 for( int i = 1, n = aSectPointsList.Size(); i <= n; ++i )
677 const Point& aSectPoint = aSectPointsList.Value( i );
679 gp_XYZ aPoint( aSectPoint.X(), aSectPoint.Y(), 0.0 );
680 aPoints.Append( aPoint );
683 TopoDS_Wire aSectionWire = BuildWire( aSectionType, anIsSectionClosed, aPoints );
684 if ( !aSectionWire.IsNull() ) {
685 aSectionWiresList.Append( aSectionWire );
686 //aMakeWire.Add( aSectionWire );
689 // all input wires in the <aSectionWiresList>
690 Handle(TopTools_HSequenceOfShape) aSeqWires = new TopTools_HSequenceOfShape;
691 Handle(TopTools_HSequenceOfShape) aSeqEdges = new TopTools_HSequenceOfShape;
692 TopTools_ListIteratorOfListOfShape it(aSectionWiresList);
693 for(;it.More();it.Next())
695 TopExp_Explorer it2(it.Value(), TopAbs_EDGE);
696 for(;it2.More();it2.Next())
697 aSeqEdges->Append(it2.Current());
701 TopoDS_Compound aCmp;
702 TopoDS_Shape aResult;
703 aBB.MakeCompound(aCmp);
704 if(aSeqEdges->Length() >1)
706 ShapeAnalysis_FreeBounds::ConnectEdgesToWires( aSeqEdges, 1E-5, Standard_True, aSeqWires );
708 if( aSeqWires->Length()==1 )
709 aResult = aSeqWires->Value( 1 );
712 for (Standard_Integer i = 1; i <= aSeqWires->Length();i++)
714 const TopoDS_Shape& aS1 = aSeqWires->Value(i);
720 else if (aSeqEdges->Length() == 1)
722 BRepBuilderAPI_MakeWire mkWire (TopoDS::Edge(aSeqEdges->Value(1)));
724 aResult = mkWire.Wire();
730 bool HYDROData_PolylineXY::IsHas2dPrs() const
735 bool HYDROData_PolylineXY::IsEditable() const
737 return !myLab.IsAttribute( GUID_IS_UNEDITABLE );
740 void HYDROData_PolylineXY::setEditable( const bool theIsEditable )
742 if ( !theIsEditable )
743 TDataStd_UAttribute::Set( myLab, GUID_IS_UNEDITABLE );
745 myLab.ForgetAttribute( GUID_IS_UNEDITABLE );
749 * Returns true if polyline is closed
751 bool HYDROData_PolylineXY::IsClosed( const bool theIsSimpleCheck ) const
753 bool anIsClosed = false;
755 TopoDS_Shape aShape = GetShape();
756 if ( aShape.IsNull() )
759 TopTools_SequenceOfShape aWires;
760 HYDROData_ShapesTool::ExploreShapeToShapes( aShape, TopAbs_WIRE, aWires );
762 int aNbWires = aWires.Length();
763 if ( theIsSimpleCheck )
765 anIsClosed = aNbWires > 0;
766 for ( int i = 1; i <= aNbWires && anIsClosed; ++i )
768 const TopoDS_Shape& aWire = aWires.Value( i );
769 anIsClosed = BRep_Tool::IsClosed( aWire );
774 anIsClosed = aNbWires == 1 && BRep_Tool::IsClosed( aWires.First() );
780 double HYDROData_PolylineXY::GetDistance( const int theSectionIndex,
781 const int thePointIndex ) const
783 double aResDistance = -1;
784 if ( theSectionIndex < 0 || theSectionIndex >= NbSections() )
787 if ( thePointIndex == 0 )
790 SectionType aSectionType = GetSectionType( theSectionIndex );
791 bool anIsSectionClosed = IsClosedSection( theSectionIndex );
792 PointsList aSectPointsList = GetPoints( theSectionIndex );
793 if ( thePointIndex < 0 || thePointIndex >= aSectPointsList.Size() )
796 if ( aSectionType == SECTION_POLYLINE )
800 Point aPrevPoint = aSectPointsList.Value( 1 );
801 for ( int i = 2, aNbPoints = aSectPointsList.Size(); i <= aNbPoints; ++i )
803 const Point& aSectPoint = aSectPointsList.Value( i );
804 aResDistance += gp_Pnt2d( aPrevPoint ).Distance( aSectPoint );
805 aPrevPoint = aSectPoint;
807 if ( thePointIndex == i - 1 )
815 int aSectNbPoints = aSectPointsList.Size();
816 NCollection_Sequence<gp_XYZ> aPoints;
817 for( int i = 1 ; i <= aSectNbPoints; ++i )
819 const Point& aSectPoint = aSectPointsList.Value( i );
821 gp_XYZ aPoint( aSectPoint.X(), aSectPoint.Y(), 0.0 );
822 aPoints.Append( aPoint );
824 if ( thePointIndex == i - 1 )
825 aPointToTest = aPoint;
828 Handle(Geom_BSplineCurve) aCurve =
829 HYDROData_BSplineOperation::ComputeCurve( aPoints, anIsSectionClosed, LOCAL_SELECTION_TOLERANCE );
831 Quantity_Parameter aFirstParam = aCurve->FirstParameter();
832 Quantity_Parameter aSecondParam = aCurve->LastParameter();
834 if ( thePointIndex != aSectNbPoints - 1 )
836 GeomAPI_ProjectPointOnCurve aProject( aPointToTest, aCurve );
837 aSecondParam = aProject.LowerDistanceParameter();
840 GeomAdaptor_Curve anAdap( aCurve );
842 aResDistance = GCPnts_AbscissaPoint::Length( anAdap, aFirstParam, aSecondParam );
848 //double HYDROData_PolylineXY::GetMinDistance( const int theSectionIndex,
849 // const Point& thePoint ) const
851 // double aResDistance = -1;
852 // if ( theSectionIndex < 0 || theSectionIndex >= NbSections() )
853 // return aResDistance;
855 // std::vector<TopoDS_Wire> aCurves;
856 // HYDROData_PolylineOperator::GetWires(this, aCurves);
857 // if (aCurves.size() != NbSections())
859 // DEBTRACE("nbCurves != nbSections " << aCurves.size() << " " << NbSections());
860 // return aResDistance;
862 // TopoDS_Wire aWire = aCurves[theSectionIndex];
863 // TopTools_SequenceOfShape anEdges;
864 // HYDROData_ShapesTool::ExploreShapeToShapes( aWire, TopAbs_EDGE, anEdges );
865 // for ( int i = 1, n = anEdges.Length(); i <= n; ++i )
867 // DEBTRACE("i: "<< i);
868 // TopoDS_Edge aWireEdge = TopoDS::Edge( anEdges.Value( i ) );
869 // gp_XYZ aPointz = gp_XYZ(thePoint.X(), thePoint.Y(), 0);
870 // Adaptor3d_Curve theCurve = BRepAdaptor_Curve(aWireEdge);
871 // double theParameter = -1;
872 // double d = ProjectPointToCurve(aPointz, theCurve, theParameter);
873 // if (d<aResDistance) aResDistance = d;
874 // DEBTRACE("d[" << i <<"]=" << d);
876 // DEBTRACE("distance section "<<theSectionIndex<<" point="<<aResDistance<<" ("<<thePoint.X()<<", "<< thePoint.Y()<<")");
877 // return aResDistance;
880 int HYDROData_PolylineXY::NbSections() const
882 Handle(TDataStd_ExtStringList) aNamesList;
883 Handle(TDataStd_IntegerList) aTypesList;
884 Handle(TDataStd_BooleanList) aClosuresList;
885 getSectionsLists( aNamesList, aTypesList, aClosuresList, false );
887 return !aClosuresList.IsNull() ? aClosuresList->Extent() : 0;
890 void HYDROData_PolylineXY::AddSection( const TCollection_AsciiString& theSectName,
891 const SectionType theSectionType,
892 const bool theIsClosed )
894 Handle(TDataStd_ExtStringList) aNamesList;
895 Handle(TDataStd_IntegerList) aTypesList;
896 Handle(TDataStd_BooleanList) aClosuresList;
897 getSectionsLists( aNamesList, aTypesList, aClosuresList );
899 TCollection_ExtendedString aSectName( theSectName );
900 if ( aSectName.Length() <= 0 )
901 aSectName = getUniqueSectionName( aNamesList );
903 aNamesList->Append( aSectName );
904 aTypesList->Append( theSectionType );
905 aClosuresList->Append( theIsClosed );
910 TCollection_AsciiString HYDROData_PolylineXY::GetSectionName( const int theSectionIndex ) const
912 TCollection_AsciiString aResName;
914 Handle(TDataStd_ExtStringList) aNamesList;
915 Handle(TDataStd_IntegerList) aTypesList;
916 Handle(TDataStd_BooleanList) aClosuresList;
917 getSectionsLists( aNamesList, aTypesList, aClosuresList, false );
918 if ( aNamesList.IsNull() || theSectionIndex >= aNamesList->Extent() )
921 TDataStd_ListIteratorOfListOfExtendedString aNamesIter( aNamesList->List() );
922 for ( int i = 0; aNamesIter.More() && i != theSectionIndex; aNamesIter.Next(), ++i );
924 if ( aNamesIter.More() )
925 aResName = aNamesIter.Value();
930 void HYDROData_PolylineXY::SetSectionName( const int theSectionIndex,
931 const TCollection_AsciiString& theSectionName )
933 Handle(TDataStd_ExtStringList) aNamesList;
934 Handle(TDataStd_IntegerList) aTypesList;
935 Handle(TDataStd_BooleanList) aClosuresList;
936 getSectionsLists( aNamesList, aTypesList, aClosuresList, false );
937 if ( aNamesList.IsNull() || theSectionIndex >= aNamesList->Extent() )
940 TDataStd_ListOfExtendedString anOldNamesList;
941 anOldNamesList = aNamesList->List();
943 // Refill the existing list
946 TCollection_ExtendedString aNewSectName = theSectionName;
948 TDataStd_ListIteratorOfListOfExtendedString aNamesIter( anOldNamesList );
949 for ( int i = 0; aNamesIter.More(); aNamesIter.Next(), ++i )
950 aNamesList->Append( i == theSectionIndex ? aNewSectName : aNamesIter.Value() );
953 HYDROData_PolylineXY::SectionType HYDROData_PolylineXY::GetSectionType( const int theSectionIndex ) const
955 Handle(TDataStd_ExtStringList) aNamesList;
956 Handle(TDataStd_IntegerList) aTypesList;
957 Handle(TDataStd_BooleanList) aClosuresList;
958 getSectionsLists( aNamesList, aTypesList, aClosuresList, false );
959 if ( aTypesList.IsNull() || theSectionIndex >= aTypesList->Extent() )
960 return SECTION_POLYLINE;
962 TColStd_ListIteratorOfListOfInteger aTypesIter( aTypesList->List() );
963 for ( int i = 0; aTypesIter.More() && i != theSectionIndex; aTypesIter.Next(), ++i );
965 return aTypesIter.More() ? (SectionType)aTypesIter.Value() : SECTION_POLYLINE;
968 void HYDROData_PolylineXY::SetSectionType( const int theSectionIndex,
969 const SectionType theSectionType )
971 Handle(TDataStd_ExtStringList) aNamesList;
972 Handle(TDataStd_IntegerList) aTypesList;
973 Handle(TDataStd_BooleanList) aClosuresList;
974 getSectionsLists( aNamesList, aTypesList, aClosuresList, false );
975 if ( aTypesList.IsNull() || theSectionIndex >= aTypesList->Extent() )
978 TColStd_ListOfInteger anOldTypesList;
979 anOldTypesList = aTypesList->List();
981 // Refill the existing list
984 TColStd_ListIteratorOfListOfInteger aTypesIter( anOldTypesList );
985 for ( int i = 0; aTypesIter.More(); aTypesIter.Next(), ++i )
986 aTypesList->Append( i == theSectionIndex ? theSectionType : aTypesIter.Value() );
991 bool HYDROData_PolylineXY::IsClosedSection( const int theSectionIndex ) const
993 Handle(TDataStd_ExtStringList) aNamesList;
994 Handle(TDataStd_IntegerList) aTypesList;
995 Handle(TDataStd_BooleanList) aClosuresList;
996 getSectionsLists( aNamesList, aTypesList, aClosuresList, false );
997 if ( aClosuresList.IsNull() || theSectionIndex >= aClosuresList->Extent() )
1000 TDataStd_ListIteratorOfListOfByte aClosuresIter( aClosuresList->List() );
1001 for ( int i = 0; aClosuresIter.More() && i != theSectionIndex; aClosuresIter.Next(), ++i );
1003 return aClosuresIter.More() ? (bool)aClosuresIter.Value() : false;
1006 void HYDROData_PolylineXY::SetSectionClosed( const int theSectionIndex,
1007 const bool theIsClosed )
1009 Handle(TDataStd_ExtStringList) aNamesList;
1010 Handle(TDataStd_IntegerList) aTypesList;
1011 Handle(TDataStd_BooleanList) aClosuresList;
1012 getSectionsLists( aNamesList, aTypesList, aClosuresList, false );
1013 if ( aClosuresList.IsNull() || theSectionIndex >= aClosuresList->Extent() )
1016 TDataStd_ListOfByte anOldClosuresList;
1017 anOldClosuresList = aClosuresList->List();
1019 // Refill the existing list
1020 aClosuresList->Clear();
1022 TDataStd_ListIteratorOfListOfByte aClosuresIter( anOldClosuresList );
1023 for ( int i = 0; aClosuresIter.More(); aClosuresIter.Next(), ++i )
1024 aClosuresList->Append( i == theSectionIndex ? theIsClosed : (bool)aClosuresIter.Value() );
1029 void HYDROData_PolylineXY::GetSections( NCollection_Sequence<TCollection_AsciiString>& theSectNames,
1030 NCollection_Sequence<SectionType>& theSectTypes,
1031 NCollection_Sequence<bool>& theSectClosures ) const
1033 theSectNames.Clear();
1034 theSectTypes.Clear();
1035 theSectClosures.Clear();
1039 const_cast<HYDROData_PolylineXY*>( this )->Interpolate();
1042 Handle(TDataStd_ExtStringList) aNamesList;
1043 Handle(TDataStd_IntegerList) aTypesList;
1044 Handle(TDataStd_BooleanList) aClosuresList;
1045 getSectionsLists( aNamesList, aTypesList, aClosuresList, false );
1046 if ( aNamesList.IsNull() || aTypesList.IsNull() || aClosuresList.IsNull() )
1049 TDataStd_ListIteratorOfListOfExtendedString aNamesIter( aNamesList->List() );
1050 TColStd_ListIteratorOfListOfInteger aTypesIter( aTypesList->List() );
1051 TDataStd_ListIteratorOfListOfByte aClosuresIter( aClosuresList->List() );
1052 for ( ; aNamesIter.More() && aTypesIter.More() && aClosuresIter.More();
1053 aNamesIter.Next(), aTypesIter.Next(), aClosuresIter.Next() )
1055 const TCollection_ExtendedString& aSectName = aNamesIter.Value();
1056 SectionType aSectType = (SectionType)aTypesIter.Value();
1057 bool aSectClosures = aClosuresIter.Value();
1059 theSectNames.Append( aSectName );
1060 theSectTypes.Append( aSectType );
1061 theSectClosures.Append( aSectClosures );
1065 void HYDROData_PolylineXY::RemoveSection( const int theSectionIndex )
1067 Handle(TDataStd_ExtStringList) aNamesList;
1068 Handle(TDataStd_IntegerList) aTypesList;
1069 Handle(TDataStd_BooleanList) aClosuresList;
1070 getSectionsLists( aNamesList, aTypesList, aClosuresList, false );
1071 if ( aNamesList.IsNull() || theSectionIndex >= aNamesList->Extent() )
1074 if ( aNamesList->Extent() == 1 )
1076 removeSectionsLists();
1077 removePointsLists();
1081 TDataStd_ListOfExtendedString anOldNamesList;
1082 anOldNamesList = aNamesList->List();
1084 TColStd_ListOfInteger anOldTypesList;
1085 anOldTypesList = aTypesList->List();
1087 TDataStd_ListOfByte anOldClosuresList;
1088 anOldClosuresList = aClosuresList->List();
1090 // Refill the existing lists
1091 aNamesList->Clear();
1092 aTypesList->Clear();
1093 aClosuresList->Clear();
1095 TDataStd_ListIteratorOfListOfExtendedString aNamesIter( anOldNamesList );
1096 TColStd_ListIteratorOfListOfInteger aTypesIter( anOldTypesList );
1097 TDataStd_ListIteratorOfListOfByte aClosuresIter( anOldClosuresList );
1098 for ( int i = 0; aNamesIter.More() && aTypesIter.More() && aClosuresIter.More();
1099 aNamesIter.Next(), aTypesIter.Next(), aClosuresIter.Next(), ++i )
1101 if ( i == theSectionIndex )
1102 continue; // skip index to remove
1104 aNamesList->Append( aNamesIter.Value() );
1105 aTypesList->Append( aTypesIter.Value() );
1106 aClosuresList->Append( (bool)aClosuresIter.Value() );
1109 // Remove points that belongs to removed section
1110 removePointsLists( theSectionIndex );
1116 void HYDROData_PolylineXY::RemoveSections()
1118 removeSectionsLists();
1119 removePointsLists();
1123 void HYDROData_PolylineXY::AddPoint( const int theSectionIndex,
1124 const Point& thePoint,
1125 const int thePointIndex )
1127 Handle(TDataStd_RealList) aListX, aListY;
1128 getPointsLists( theSectionIndex, aListX, aListY );
1130 if ( thePointIndex < 0 || thePointIndex >= aListX->Extent() )
1132 aListX->Append( thePoint.X() );
1133 aListY->Append( thePoint.Y() );
1137 TColStd_ListOfReal anOldListX;
1138 anOldListX = aListX->List();
1140 TColStd_ListOfReal anOldListY;
1141 anOldListY = aListY->List();
1143 // Refill the existing lists
1147 TColStd_ListIteratorOfListOfReal anIterX( anOldListX );
1148 TColStd_ListIteratorOfListOfReal anIterY( anOldListY );
1149 for ( int i = 0; anIterX.More() && anIterY.More(); anIterX.Next(), anIterY.Next(), ++i )
1151 double aCoordX = anIterX.Value();
1152 double aCoordY = anIterY.Value();
1154 if ( i == thePointIndex )
1156 // Insert our new point
1157 aListX->Append( thePoint.X() );
1158 aListY->Append( thePoint.Y() );
1161 aListX->Append( aCoordX );
1162 aListY->Append( aCoordY );
1169 void HYDROData_PolylineXY::SetPoint( const int theSectionIndex,
1170 const Point& thePoint,
1171 const int thePointIndex )
1173 Handle(TDataStd_RealList) aListX, aListY;
1174 getPointsLists( theSectionIndex, aListX, aListY );
1176 if ( thePointIndex < 0 )
1178 aListX->Prepend( thePoint.X() );
1179 aListY->Prepend( thePoint.Y() );
1181 else if ( thePointIndex >= aListX->Extent() )
1183 aListX->Append( thePoint.X() );
1184 aListY->Append( thePoint.Y() );
1188 TColStd_ListOfReal anOldListX;
1189 anOldListX = aListX->List();
1191 TColStd_ListOfReal anOldListY;
1192 anOldListY = aListY->List();
1194 // Refill the existing lists
1198 TColStd_ListIteratorOfListOfReal anIterX( anOldListX );
1199 TColStd_ListIteratorOfListOfReal anIterY( anOldListY );
1200 for ( int i = 0; anIterX.More() && anIterY.More(); anIterX.Next(), anIterY.Next(), ++i )
1202 double aCoordX = anIterX.Value();
1203 double aCoordY = anIterY.Value();
1205 if ( i == thePointIndex )
1207 // Insert our new point instead of old one
1208 aCoordX = thePoint.X();
1209 aCoordY = thePoint.Y();
1212 aListX->Append( aCoordX );
1213 aListY->Append( aCoordY );
1220 void HYDROData_PolylineXY::SetPoints( const int theSectionIndex,
1221 const PointsList& thePoints )
1223 Handle(TDataStd_RealList) aListX, aListY;
1224 getPointsLists( theSectionIndex, aListX, aListY );
1229 for ( int i = 1, n = thePoints.Length(); i <= n; ++i )
1231 const Point& aPoint = thePoints.Value( i );
1232 aListX->Append( aPoint.X() );
1233 aListY->Append( aPoint.Y() );
1237 void HYDROData_PolylineXY::RemovePoint( const int theSectionIndex,
1238 const int thePointIndex )
1240 Handle(TDataStd_RealList) aListX, aListY;
1241 getPointsLists( theSectionIndex, aListX, aListY, false );
1242 if ( aListX.IsNull() || aListY.IsNull() || aListX->IsEmpty() )
1245 if ( aListX->Extent() == 1 )
1247 removePointsLists( theSectionIndex );
1251 TColStd_ListOfReal anOldListX;
1252 anOldListX = aListX->List();
1254 TColStd_ListOfReal anOldListY;
1255 anOldListY = aListY->List();
1257 // Refill the existing lists
1261 TColStd_ListIteratorOfListOfReal anIterX( anOldListX );
1262 TColStd_ListIteratorOfListOfReal anIterY( anOldListY );
1263 for ( int i = 0; anIterX.More() && anIterY.More(); anIterX.Next(), anIterY.Next(), ++i )
1265 if ( i == thePointIndex )
1266 continue; // skip index to remove
1268 aListX->Append( anIterX.Value() );
1269 aListY->Append( anIterY.Value() );
1276 HYDROData_PolylineXY::PointsList HYDROData_PolylineXY::GetPoints( const int theSectionIndex, bool IsConvertToGlobal ) const
1278 PointsList aResList;
1282 const_cast<HYDROData_PolylineXY*>( this )->Interpolate();
1285 Handle(TDataStd_RealList) aListX, aListY;
1286 getPointsLists( theSectionIndex, aListX, aListY, false );
1287 if ( aListX.IsNull() || aListY.IsNull() || aListX->IsEmpty() )
1290 TColStd_ListIteratorOfListOfReal anIterX( aListX->List() );
1291 TColStd_ListIteratorOfListOfReal anIterY( aListY->List() );
1292 Handle(HYDROData_Document) aDoc = HYDROData_Document::Document( myLab );
1293 for ( ; anIterX.More() && anIterY.More(); anIterX.Next(), anIterY.Next() )
1295 Point aPoint( anIterX.Value(), anIterY.Value() );
1296 if (IsConvertToGlobal)
1297 aDoc->Transform( aPoint, false );
1298 aResList.Append( aPoint );
1304 QPainterPath HYDROData_PolylineXY::GetPainterPath() const
1308 NCollection_Sequence<TCollection_AsciiString> aSectNames;
1309 NCollection_Sequence<HYDROData_PolylineXY::SectionType> aSectTypes;
1310 NCollection_Sequence<bool> aSectClosures;
1311 GetSections( aSectNames, aSectTypes, aSectClosures );
1313 for ( int aSectionId = 1, aNbSects = aSectNames.Size(); aSectionId <= aNbSects; aSectionId++ )
1315 TCollection_AsciiString aSectName = aSectNames.Value( aSectionId );
1316 SectionType aSectionType = aSectTypes.Value( aSectionId );
1317 bool anIsSectionClosed = aSectClosures.Value( aSectionId );
1319 PointsList aSectPointsList = GetPoints( aSectionId - 1 );
1320 if ( aSectPointsList.IsEmpty() )
1323 NCollection_Sequence<gp_XYZ> aPoints;
1324 for( int i = 1, n = aSectPointsList.Size(); i <= n; ++i )
1326 const Point& aSectPoint = aSectPointsList.Value( i );
1328 gp_XYZ aPoint( aSectPoint.X(), aSectPoint.Y(), 0.0 );
1329 aPoints.Append( aPoint );
1332 BuildPainterPath( aPath, aSectionType, anIsSectionClosed, aPoints );
1338 void HYDROData_PolylineXY::UpdateLocalCS( double theDx, double theDy )
1340 NCollection_Sequence<TCollection_AsciiString> aSectNames;
1341 NCollection_Sequence<HYDROData_PolylineXY::SectionType> aSectTypes;
1342 NCollection_Sequence<bool> aSectClosures;
1343 GetSections( aSectNames, aSectTypes, aSectClosures );
1345 gp_XY aDelta( theDx, theDy );
1346 for ( int i = 0, aNbSects = aSectNames.Size(); i < aNbSects; i++ )
1348 PointsList aPoints = GetPoints( i );
1349 for( int j = 1, n = aPoints.Size(); j <= n; ++j )
1351 Point& aPoint = aPoints.ChangeValue( j );
1354 SetPoints( i, aPoints );
1359 void HYDROData_PolylineXY::Transform( const QTransform& theTrsf )
1361 NCollection_Sequence<TCollection_AsciiString> aSectNames;
1362 NCollection_Sequence<HYDROData_PolylineXY::SectionType> aSectTypes;
1363 NCollection_Sequence<bool> aSectClosures;
1364 GetSections( aSectNames, aSectTypes, aSectClosures );
1366 for ( int i = 0, aNbSects = aSectNames.Size(); i < aNbSects; i++ ) {
1367 PointsList aPoints = GetPoints( i );
1368 for( int j = 1, n = aPoints.Size(); j <= n; ++j ) {
1369 Point& aPoint = aPoints.ChangeValue( j );
1371 QPointF aTrsfPoint = theTrsf.map( QPointF( aPoint.X(), aPoint.Y() ) );
1373 aPoint.SetX( aTrsfPoint.x() );
1374 aPoint.SetY( aTrsfPoint.y() );
1376 SetPoints( i, aPoints );
1382 bool HYDROData_PolylineXY::IsCustom() const
1384 if( myIsInCustomFlag )
1387 bool isNull = GetShape().IsNull();
1390 HYDROData_PolylineXY* aThat = const_cast<HYDROData_PolylineXY*>( this );
1391 aThat->myIsInCustomFlag = true;
1392 for( int i=0, n=NbSections(); i<n; i++ )
1393 aNbPoints += NbPoints( i );
1394 aThat->myIsInCustomFlag = false;
1396 return !isNull && aNbPoints == 0;
1399 bool HYDROData_PolylineXY::GetIsInCustomFlag() const
1401 return myIsInCustomFlag;
1404 void HYDROData_PolylineXY::SetIsInCustomFlag( bool theValue )
1406 myIsInCustomFlag = theValue;
1409 void HYDROData_PolylineXY::Interpolate()
1411 ImportShape( GetShape(), true );