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 );
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 HYDROData_PolylineXY::SectionType aSectionType ;
367 if( anEdgeGeomCurve->IsKind( STANDARD_TYPE(Geom_Line) ) )
369 aSectionType = HYDROData_PolylineXY::SECTION_POLYLINE;
371 else if ( anEdgeGeomCurve->IsKind( STANDARD_TYPE(Geom_BSplineCurve) ) || IsInterpolationAllowed )
373 aSectionType = HYDROData_PolylineXY::SECTION_SPLINE;
377 // Other curve types are not supported
381 bool isNewSection = !isPrevious || isPrevClosed || anIsEdgeClosed || prevSectType != aSectionType;
382 DEBTRACE(isNewSection <<": " << !isPrevious << " " << isPrevClosed << " " << anIsEdgeClosed << " " << (prevSectType != aSectionType));
384 HYDROData_PolylineXY::PointsList aPointsList;
387 aPointsList = prevPointList;
390 if( aSectionType == HYDROData_PolylineXY::SECTION_POLYLINE )
392 DEBTRACE("SECTION_POLYLINE");
393 Handle(Geom_Line) aGeomLine = Handle(Geom_Line)::DownCast( anEdgeGeomCurve );
395 gp_Pnt aFirstPoint, aLastPoint;
396 aGeomLine->D0( aFirst, aFirstPoint );
397 aGeomLine->D0( aLast, aLastPoint );
398 HYDROData_PolylineXY::Point aSectFirstPoint( aFirstPoint.X(), aFirstPoint.Y() );
399 HYDROData_PolylineXY::Point aSectLastPoint( aLastPoint.X(), aLastPoint.Y() );
402 if (aSectFirstPoint == prevPointList.Last())
404 DEBTRACE("points shared: a");//aPointsList.Append( aSectFirstPoint );
405 aPointsList.Append( aSectLastPoint );
407 else if (aSectLastPoint == prevPointList.Last())
409 DEBTRACE("points shared: b");//aPointsList.Append( aSectLastPoint );
410 aPointsList.Append( aSectFirstPoint );
412 else if (aSectFirstPoint == prevPointList.First())
414 DEBTRACE("points shared: c");//aPointsList.Prepend( aSectFirstPoint );
415 aPointsList.Prepend( aSectLastPoint );
417 else if (aSectLastPoint == prevPointList.First())
419 DEBTRACE("points shared: d");//aPointsList.Prepend( aSectLastPoint );
420 aPointsList.Prepend( aSectFirstPoint );
424 DEBTRACE("no point shared")
425 isNewSection = true; // no point shared, new section
427 aPointsList.Append( aSectFirstPoint );
428 aPointsList.Append( aSectLastPoint );
433 DEBTRACE("new section");
434 aPointsList.Append( aSectFirstPoint );
435 aPointsList.Append( aSectLastPoint );
438 else // aSectionType == HYDROData_PolylineXY::SECTION_SPLINE
440 DEBTRACE("SECTION_SPLINE");
444 BRepAdaptor_Curve anAdaptorCurve( theEdge );
445 GCPnts_QuasiUniformDeflection aDiscrete( anAdaptorCurve, theDeflection );
447 int aNbPoints = aDiscrete.NbPoints();
449 // Decrease the number of imported poles because of last one
450 // pole is the closing point which are the start point
451 if ( anIsEdgeClosed ) aNbPoints--;
453 for ( int i = 1; i <= aNbPoints; ++i )
455 const gp_Pnt& aPoint = aDiscrete.Value( i );
457 HYDROData_PolylineXY::Point aSectPoint( aPoint.X(), aPoint.Y() );
458 aPointsList.Append( aSectPoint );
462 if ( aPointsList.IsEmpty() )
465 TCollection_AsciiString aSectName = getUniqueSectionName( theSectNames );
468 DEBTRACE("isNewSection");
469 theSectNames.Append( aSectName );
470 theSectTypes.Append( aSectionType );
471 theSectClosures.Append( anIsEdgeClosed );
472 theSectPoints.Append( aPointsList );
476 DEBTRACE("sameSection");
477 theSectPoints.SetValue(theSectPoints.Length(), aPointsList);
483 bool HYDROData_PolylineXY::ImportShape( const TopoDS_Shape& theShape,
484 bool IsInterpolationAllowed,
485 double theDeviation )
487 DEBTRACE("ImportShape");
488 if ( theShape.IsNull() )
493 bool anIsCanBeImported = false;
495 NCollection_Sequence<TCollection_AsciiString> aSectNames;
496 NCollection_Sequence<SectionType> aSectTypes;
497 NCollection_Sequence<bool> aSectClosures;
498 NCollection_Sequence<PointsList> aSectPoints;
500 if ( theShape.ShapeType() == TopAbs_EDGE )
502 DEBTRACE("TopAbs_EDGE");
503 TopoDS_Edge anEdge = TopoDS::Edge( theShape );
504 anIsCanBeImported = convertEdgeToSection( anEdge, aSectNames, aSectTypes,
505 aSectClosures, aSectPoints, true, IsInterpolationAllowed, theDeviation );
507 else if ( theShape.ShapeType() == TopAbs_WIRE )
509 DEBTRACE("TopAbs_WIRE");
510 TopTools_SequenceOfShape anEdges;
511 HYDROData_ShapesTool::ExploreShapeToShapes( theShape, TopAbs_EDGE, anEdges );
513 anIsCanBeImported = !anEdges.IsEmpty();
514 for ( int i = 1, n = anEdges.Length(); i <= n && anIsCanBeImported; ++i )
516 TopoDS_Edge aWireEdge = TopoDS::Edge( anEdges.Value( i ) );
517 anIsCanBeImported = convertEdgesToSections( aWireEdge, aSectNames, aSectTypes,
518 aSectClosures, aSectPoints, false, IsInterpolationAllowed, theDeviation );
522 if ( anIsCanBeImported )
524 for ( int i = 1, n = aSectNames.Length(); i <= n; ++i )
526 const TCollection_AsciiString& aSectName = aSectNames.Value( i );
527 const SectionType& aSectType = aSectTypes.Value( i );
528 bool anIsSectionClosed = aSectClosures.Value( i );
529 const PointsList& aSectPointsList = aSectPoints( i );
531 AddSection( aSectName, aSectType, anIsSectionClosed );
532 SetPoints( i - 1, aSectPointsList );
537 TopoDS_Shape aShape = theShape;
539 if ( theShape.ShapeType() == TopAbs_EDGE )
541 // We make the wire from incoming edge because of other algorithms
542 // are waiting at least the wire from polyline
543 TopoDS_Edge anEdge = TopoDS::Edge( theShape );
544 BRepBuilderAPI_MakeWire aMakeWire( anEdge );
546 if ( aMakeWire.IsDone() )
547 aShape = aMakeWire.Wire();
550 gp_Pln aPlane( gp_Pnt( 0, 0, 0 ), gp_Dir( 0, 0, 1 ) );
551 BRepBuilderAPI_MakeFace aMakeFace( aPlane );
553 BRepOffsetAPI_NormalProjection aProj( aMakeFace.Face() );
556 TopoDS_Shape aResult;
558 aResult = aProj.Shape();
563 setEditable( anIsCanBeImported );
568 TopoDS_Wire HYDROData_PolylineXY::BuildWire( const SectionType& theType,
569 const bool& theIsClosed,
570 const NCollection_Sequence<gp_XYZ>& thePoints )
573 if( theType == SECTION_POLYLINE )
575 int aNbPoints = thePoints.Length();
576 BRepBuilderAPI_MakePolygon aMakeWire;
577 for ( int i = 1, n = aNbPoints; i <= n ; ++i )
579 gp_XYZ aPoint = thePoints.Value( i );
580 gp_Pnt aPnt( aPoint.X(), aPoint.Y(), aPoint.Z() );
581 aMakeWire.Add( aPnt );
583 if( theIsClosed && ( aNbPoints > 2 ) )
586 if ( aMakeWire.IsDone() )
587 aWire = aMakeWire.Wire();
589 else //if( theType == PolylineSection::SECTION_SPLINE )
591 BRepBuilderAPI_MakeWire aMakeWire;
593 if ( thePoints.Size() > 1 )
595 Handle(Geom_BSplineCurve) aCurve =
596 HYDROData_BSplineOperation::ComputeCurve( thePoints, theIsClosed, LOCAL_SELECTION_TOLERANCE );
598 TopoDS_Edge anEdge = BRepBuilderAPI_MakeEdge( aCurve ).Edge();
599 aMakeWire.Add( anEdge );
602 if ( aMakeWire.IsDone() )
609 void HYDROData_PolylineXY::BuildPainterPath( QPainterPath& thePath,
610 const SectionType& theType,
611 const bool& theIsClosed,
612 const NCollection_Sequence<gp_XYZ>& thePoints )
614 if ( thePoints.IsEmpty() )
617 if ( theType == SECTION_POLYLINE )
619 const gp_XYZ& aFirstPoint = thePoints.Value( 1 );
620 thePath.moveTo( aFirstPoint.X(), aFirstPoint.Y() );
622 for( int i = 2, n = thePoints.Size(); i <= n; ++i )
624 const gp_XYZ& aSectPoint = thePoints.Value( i );
626 thePath.lineTo( aSectPoint.X(), aSectPoint.Y() );
630 thePath.closeSubpath();
634 Handle(Geom_BSplineCurve) aCurve =
635 HYDROData_BSplineOperation::ComputeCurve( thePoints, theIsClosed, LOCAL_SELECTION_TOLERANCE );
636 HYDROData_BSplineOperation::ComputePath( aCurve, thePath );
640 void HYDROData_PolylineXY::Update()
644 // If polyline is not editable we no need to update it wire
649 HYDROData_IPolyline::Update();
651 NCollection_Sequence<TCollection_AsciiString> aSectNames;
652 NCollection_Sequence<HYDROData_PolylineXY::SectionType> aSectTypes;
653 NCollection_Sequence<bool> aSectClosures;
654 GetSections( aSectNames, aSectTypes, aSectClosures );
656 //BRepBuilderAPI_MakeWire aMakeWire;
658 TopTools_ListOfShape aSectionWiresList;
660 for ( int aSectionId = 1, aNbSects = aSectNames.Size(); aSectionId <= aNbSects; aSectionId++ )
662 TCollection_AsciiString aSectName = aSectNames.Value( aSectionId );
663 SectionType aSectionType = aSectTypes.Value( aSectionId );
664 bool anIsSectionClosed = aSectClosures.Value( aSectionId );
666 PointsList aSectPointsList = GetPoints( aSectionId - 1 );
667 if ( aSectPointsList.IsEmpty() )
670 NCollection_Sequence<gp_XYZ> aPoints;
671 for( int i = 1, n = aSectPointsList.Size(); i <= n; ++i )
673 const Point& aSectPoint = aSectPointsList.Value( i );
675 gp_XYZ aPoint( aSectPoint.X(), aSectPoint.Y(), 0.0 );
676 aPoints.Append( aPoint );
679 TopoDS_Wire aSectionWire = BuildWire( aSectionType, anIsSectionClosed, aPoints );
680 if ( !aSectionWire.IsNull() ) {
681 aSectionWiresList.Append( aSectionWire );
682 //aMakeWire.Add( aSectionWire );
685 // all input wires in the <aSectionWiresList>
686 Handle(TopTools_HSequenceOfShape) aSeqWires = new TopTools_HSequenceOfShape;
687 Handle(TopTools_HSequenceOfShape) aSeqEdges = new TopTools_HSequenceOfShape;
688 TopTools_ListIteratorOfListOfShape it(aSectionWiresList);
689 for(;it.More();it.Next())
691 TopExp_Explorer it2(it.Value(), TopAbs_EDGE);
692 for(;it2.More();it2.Next())
693 aSeqEdges->Append(it2.Current());
697 TopoDS_Compound aCmp;
698 TopoDS_Shape aResult;
699 aBB.MakeCompound(aCmp);
700 if(aSeqEdges->Length() >1)
702 ShapeAnalysis_FreeBounds::ConnectEdgesToWires( aSeqEdges, 1E-5, Standard_True, aSeqWires );
704 if( aSeqWires->Length()==1 )
705 aResult = aSeqWires->Value( 1 );
708 for (Standard_Integer i = 1; i <= aSeqWires->Length();i++)
710 const TopoDS_Shape& aS1 = aSeqWires->Value(i);
716 else if (aSeqEdges->Length() == 1)
718 BRepBuilderAPI_MakeWire mkWire (TopoDS::Edge(aSeqEdges->Value(1)));
720 aResult = mkWire.Wire();
726 bool HYDROData_PolylineXY::IsHas2dPrs() const
731 bool HYDROData_PolylineXY::IsEditable() const
733 return !myLab.IsAttribute( GUID_IS_UNEDITABLE );
736 void HYDROData_PolylineXY::setEditable( const bool theIsEditable )
738 if ( !theIsEditable )
739 TDataStd_UAttribute::Set( myLab, GUID_IS_UNEDITABLE );
741 myLab.ForgetAttribute( GUID_IS_UNEDITABLE );
745 * Returns true if polyline is closed
747 bool HYDROData_PolylineXY::IsClosed( const bool theIsSimpleCheck ) const
749 bool anIsClosed = false;
751 TopoDS_Shape aShape = GetShape();
752 if ( aShape.IsNull() )
755 TopTools_SequenceOfShape aWires;
756 HYDROData_ShapesTool::ExploreShapeToShapes( aShape, TopAbs_WIRE, aWires );
758 int aNbWires = aWires.Length();
759 if ( theIsSimpleCheck )
761 anIsClosed = aNbWires > 0;
762 for ( int i = 1; i <= aNbWires && anIsClosed; ++i )
764 const TopoDS_Shape& aWire = aWires.Value( i );
765 anIsClosed = BRep_Tool::IsClosed( aWire );
770 anIsClosed = aNbWires == 1 && BRep_Tool::IsClosed( aWires.First() );
776 double HYDROData_PolylineXY::GetDistance( const int theSectionIndex,
777 const int thePointIndex ) const
779 double aResDistance = -1;
780 if ( theSectionIndex < 0 || theSectionIndex >= NbSections() )
783 if ( thePointIndex == 0 )
786 SectionType aSectionType = GetSectionType( theSectionIndex );
787 bool anIsSectionClosed = IsClosedSection( theSectionIndex );
788 PointsList aSectPointsList = GetPoints( theSectionIndex );
789 if ( thePointIndex < 0 || thePointIndex >= aSectPointsList.Size() )
792 if ( aSectionType == SECTION_POLYLINE )
796 Point aPrevPoint = aSectPointsList.Value( 1 );
797 for ( int i = 2, aNbPoints = aSectPointsList.Size(); i <= aNbPoints; ++i )
799 const Point& aSectPoint = aSectPointsList.Value( i );
800 aResDistance += gp_Pnt2d( aPrevPoint ).Distance( aSectPoint );
801 aPrevPoint = aSectPoint;
803 if ( thePointIndex == i - 1 )
811 int aSectNbPoints = aSectPointsList.Size();
812 NCollection_Sequence<gp_XYZ> aPoints;
813 for( int i = 1 ; i <= aSectNbPoints; ++i )
815 const Point& aSectPoint = aSectPointsList.Value( i );
817 gp_XYZ aPoint( aSectPoint.X(), aSectPoint.Y(), 0.0 );
818 aPoints.Append( aPoint );
820 if ( thePointIndex == i - 1 )
821 aPointToTest = aPoint;
824 Handle(Geom_BSplineCurve) aCurve =
825 HYDROData_BSplineOperation::ComputeCurve( aPoints, anIsSectionClosed, LOCAL_SELECTION_TOLERANCE );
827 Quantity_Parameter aFirstParam = aCurve->FirstParameter();
828 Quantity_Parameter aSecondParam = aCurve->LastParameter();
830 if ( thePointIndex != aSectNbPoints - 1 )
832 GeomAPI_ProjectPointOnCurve aProject( aPointToTest, aCurve );
833 aSecondParam = aProject.LowerDistanceParameter();
836 GeomAdaptor_Curve anAdap( aCurve );
838 aResDistance = GCPnts_AbscissaPoint::Length( anAdap, aFirstParam, aSecondParam );
844 //double HYDROData_PolylineXY::GetMinDistance( const int theSectionIndex,
845 // const Point& thePoint ) const
847 // double aResDistance = -1;
848 // if ( theSectionIndex < 0 || theSectionIndex >= NbSections() )
849 // return aResDistance;
851 // std::vector<TopoDS_Wire> aCurves;
852 // HYDROData_PolylineOperator::GetWires(this, aCurves);
853 // if (aCurves.size() != NbSections())
855 // DEBTRACE("nbCurves != nbSections " << aCurves.size() << " " << NbSections());
856 // return aResDistance;
858 // TopoDS_Wire aWire = aCurves[theSectionIndex];
859 // TopTools_SequenceOfShape anEdges;
860 // HYDROData_ShapesTool::ExploreShapeToShapes( aWire, TopAbs_EDGE, anEdges );
861 // for ( int i = 1, n = anEdges.Length(); i <= n; ++i )
863 // DEBTRACE("i: "<< i);
864 // TopoDS_Edge aWireEdge = TopoDS::Edge( anEdges.Value( i ) );
865 // gp_XYZ aPointz = gp_XYZ(thePoint.X(), thePoint.Y(), 0);
866 // Adaptor3d_Curve theCurve = BRepAdaptor_Curve(aWireEdge);
867 // double theParameter = -1;
868 // double d = ProjectPointToCurve(aPointz, theCurve, theParameter);
869 // if (d<aResDistance) aResDistance = d;
870 // DEBTRACE("d[" << i <<"]=" << d);
872 // DEBTRACE("distance section "<<theSectionIndex<<" point="<<aResDistance<<" ("<<thePoint.X()<<", "<< thePoint.Y()<<")");
873 // return aResDistance;
876 int HYDROData_PolylineXY::NbSections() const
878 Handle(TDataStd_ExtStringList) aNamesList;
879 Handle(TDataStd_IntegerList) aTypesList;
880 Handle(TDataStd_BooleanList) aClosuresList;
881 getSectionsLists( aNamesList, aTypesList, aClosuresList, false );
883 return !aClosuresList.IsNull() ? aClosuresList->Extent() : 0;
886 void HYDROData_PolylineXY::AddSection( const TCollection_AsciiString& theSectName,
887 const SectionType theSectionType,
888 const bool theIsClosed )
890 Handle(TDataStd_ExtStringList) aNamesList;
891 Handle(TDataStd_IntegerList) aTypesList;
892 Handle(TDataStd_BooleanList) aClosuresList;
893 getSectionsLists( aNamesList, aTypesList, aClosuresList );
895 TCollection_ExtendedString aSectName( theSectName );
896 if ( aSectName.Length() <= 0 )
897 aSectName = getUniqueSectionName( aNamesList );
899 aNamesList->Append( aSectName );
900 aTypesList->Append( theSectionType );
901 aClosuresList->Append( theIsClosed );
906 TCollection_AsciiString HYDROData_PolylineXY::GetSectionName( const int theSectionIndex ) const
908 TCollection_AsciiString aResName;
910 Handle(TDataStd_ExtStringList) aNamesList;
911 Handle(TDataStd_IntegerList) aTypesList;
912 Handle(TDataStd_BooleanList) aClosuresList;
913 getSectionsLists( aNamesList, aTypesList, aClosuresList, false );
914 if ( aNamesList.IsNull() || theSectionIndex >= aNamesList->Extent() )
917 TDataStd_ListIteratorOfListOfExtendedString aNamesIter( aNamesList->List() );
918 for ( int i = 0; aNamesIter.More() && i != theSectionIndex; aNamesIter.Next(), ++i );
920 if ( aNamesIter.More() )
921 aResName = aNamesIter.Value();
926 void HYDROData_PolylineXY::SetSectionName( const int theSectionIndex,
927 const TCollection_AsciiString& theSectionName )
929 Handle(TDataStd_ExtStringList) aNamesList;
930 Handle(TDataStd_IntegerList) aTypesList;
931 Handle(TDataStd_BooleanList) aClosuresList;
932 getSectionsLists( aNamesList, aTypesList, aClosuresList, false );
933 if ( aNamesList.IsNull() || theSectionIndex >= aNamesList->Extent() )
936 TDataStd_ListOfExtendedString anOldNamesList;
937 anOldNamesList = aNamesList->List();
939 // Refill the existing list
942 TCollection_ExtendedString aNewSectName = theSectionName;
944 TDataStd_ListIteratorOfListOfExtendedString aNamesIter( anOldNamesList );
945 for ( int i = 0; aNamesIter.More(); aNamesIter.Next(), ++i )
946 aNamesList->Append( i == theSectionIndex ? aNewSectName : aNamesIter.Value() );
949 HYDROData_PolylineXY::SectionType HYDROData_PolylineXY::GetSectionType( const int theSectionIndex ) const
951 Handle(TDataStd_ExtStringList) aNamesList;
952 Handle(TDataStd_IntegerList) aTypesList;
953 Handle(TDataStd_BooleanList) aClosuresList;
954 getSectionsLists( aNamesList, aTypesList, aClosuresList, false );
955 if ( aTypesList.IsNull() || theSectionIndex >= aTypesList->Extent() )
956 return SECTION_POLYLINE;
958 TColStd_ListIteratorOfListOfInteger aTypesIter( aTypesList->List() );
959 for ( int i = 0; aTypesIter.More() && i != theSectionIndex; aTypesIter.Next(), ++i );
961 return aTypesIter.More() ? (SectionType)aTypesIter.Value() : SECTION_POLYLINE;
964 void HYDROData_PolylineXY::SetSectionType( const int theSectionIndex,
965 const SectionType theSectionType )
967 Handle(TDataStd_ExtStringList) aNamesList;
968 Handle(TDataStd_IntegerList) aTypesList;
969 Handle(TDataStd_BooleanList) aClosuresList;
970 getSectionsLists( aNamesList, aTypesList, aClosuresList, false );
971 if ( aTypesList.IsNull() || theSectionIndex >= aTypesList->Extent() )
974 TColStd_ListOfInteger anOldTypesList;
975 anOldTypesList = aTypesList->List();
977 // Refill the existing list
980 TColStd_ListIteratorOfListOfInteger aTypesIter( anOldTypesList );
981 for ( int i = 0; aTypesIter.More(); aTypesIter.Next(), ++i )
982 aTypesList->Append( i == theSectionIndex ? theSectionType : aTypesIter.Value() );
987 bool HYDROData_PolylineXY::IsClosedSection( const int theSectionIndex ) const
989 Handle(TDataStd_ExtStringList) aNamesList;
990 Handle(TDataStd_IntegerList) aTypesList;
991 Handle(TDataStd_BooleanList) aClosuresList;
992 getSectionsLists( aNamesList, aTypesList, aClosuresList, false );
993 if ( aClosuresList.IsNull() || theSectionIndex >= aClosuresList->Extent() )
996 TDataStd_ListIteratorOfListOfByte aClosuresIter( aClosuresList->List() );
997 for ( int i = 0; aClosuresIter.More() && i != theSectionIndex; aClosuresIter.Next(), ++i );
999 return aClosuresIter.More() ? (bool)aClosuresIter.Value() : false;
1002 void HYDROData_PolylineXY::SetSectionClosed( const int theSectionIndex,
1003 const bool theIsClosed )
1005 Handle(TDataStd_ExtStringList) aNamesList;
1006 Handle(TDataStd_IntegerList) aTypesList;
1007 Handle(TDataStd_BooleanList) aClosuresList;
1008 getSectionsLists( aNamesList, aTypesList, aClosuresList, false );
1009 if ( aClosuresList.IsNull() || theSectionIndex >= aClosuresList->Extent() )
1012 TDataStd_ListOfByte anOldClosuresList;
1013 anOldClosuresList = aClosuresList->List();
1015 // Refill the existing list
1016 aClosuresList->Clear();
1018 TDataStd_ListIteratorOfListOfByte aClosuresIter( anOldClosuresList );
1019 for ( int i = 0; aClosuresIter.More(); aClosuresIter.Next(), ++i )
1020 aClosuresList->Append( i == theSectionIndex ? theIsClosed : (bool)aClosuresIter.Value() );
1025 void HYDROData_PolylineXY::GetSections( NCollection_Sequence<TCollection_AsciiString>& theSectNames,
1026 NCollection_Sequence<SectionType>& theSectTypes,
1027 NCollection_Sequence<bool>& theSectClosures ) const
1029 theSectNames.Clear();
1030 theSectTypes.Clear();
1031 theSectClosures.Clear();
1035 const_cast<HYDROData_PolylineXY*>( this )->Interpolate();
1038 Handle(TDataStd_ExtStringList) aNamesList;
1039 Handle(TDataStd_IntegerList) aTypesList;
1040 Handle(TDataStd_BooleanList) aClosuresList;
1041 getSectionsLists( aNamesList, aTypesList, aClosuresList, false );
1042 if ( aNamesList.IsNull() || aTypesList.IsNull() || aClosuresList.IsNull() )
1045 TDataStd_ListIteratorOfListOfExtendedString aNamesIter( aNamesList->List() );
1046 TColStd_ListIteratorOfListOfInteger aTypesIter( aTypesList->List() );
1047 TDataStd_ListIteratorOfListOfByte aClosuresIter( aClosuresList->List() );
1048 for ( ; aNamesIter.More() && aTypesIter.More() && aClosuresIter.More();
1049 aNamesIter.Next(), aTypesIter.Next(), aClosuresIter.Next() )
1051 const TCollection_ExtendedString& aSectName = aNamesIter.Value();
1052 SectionType aSectType = (SectionType)aTypesIter.Value();
1053 bool aSectClosures = aClosuresIter.Value();
1055 theSectNames.Append( aSectName );
1056 theSectTypes.Append( aSectType );
1057 theSectClosures.Append( aSectClosures );
1061 void HYDROData_PolylineXY::RemoveSection( const int theSectionIndex )
1063 Handle(TDataStd_ExtStringList) aNamesList;
1064 Handle(TDataStd_IntegerList) aTypesList;
1065 Handle(TDataStd_BooleanList) aClosuresList;
1066 getSectionsLists( aNamesList, aTypesList, aClosuresList, false );
1067 if ( aNamesList.IsNull() || theSectionIndex >= aNamesList->Extent() )
1070 if ( aNamesList->Extent() == 1 )
1072 removeSectionsLists();
1073 removePointsLists();
1077 TDataStd_ListOfExtendedString anOldNamesList;
1078 anOldNamesList = aNamesList->List();
1080 TColStd_ListOfInteger anOldTypesList;
1081 anOldTypesList = aTypesList->List();
1083 TDataStd_ListOfByte anOldClosuresList;
1084 anOldClosuresList = aClosuresList->List();
1086 // Refill the existing lists
1087 aNamesList->Clear();
1088 aTypesList->Clear();
1089 aClosuresList->Clear();
1091 TDataStd_ListIteratorOfListOfExtendedString aNamesIter( anOldNamesList );
1092 TColStd_ListIteratorOfListOfInteger aTypesIter( anOldTypesList );
1093 TDataStd_ListIteratorOfListOfByte aClosuresIter( anOldClosuresList );
1094 for ( int i = 0; aNamesIter.More() && aTypesIter.More() && aClosuresIter.More();
1095 aNamesIter.Next(), aTypesIter.Next(), aClosuresIter.Next(), ++i )
1097 if ( i == theSectionIndex )
1098 continue; // skip index to remove
1100 aNamesList->Append( aNamesIter.Value() );
1101 aTypesList->Append( aTypesIter.Value() );
1102 aClosuresList->Append( (bool)aClosuresIter.Value() );
1105 // Remove points that belongs to removed section
1106 removePointsLists( theSectionIndex );
1112 void HYDROData_PolylineXY::RemoveSections()
1114 removeSectionsLists();
1115 removePointsLists();
1119 void HYDROData_PolylineXY::AddPoint( const int theSectionIndex,
1120 const Point& thePoint,
1121 const int thePointIndex )
1123 Handle(TDataStd_RealList) aListX, aListY;
1124 getPointsLists( theSectionIndex, aListX, aListY );
1126 if ( thePointIndex < 0 || thePointIndex >= aListX->Extent() )
1128 aListX->Append( thePoint.X() );
1129 aListY->Append( thePoint.Y() );
1133 TColStd_ListOfReal anOldListX;
1134 anOldListX = aListX->List();
1136 TColStd_ListOfReal anOldListY;
1137 anOldListY = aListY->List();
1139 // Refill the existing lists
1143 TColStd_ListIteratorOfListOfReal anIterX( anOldListX );
1144 TColStd_ListIteratorOfListOfReal anIterY( anOldListY );
1145 for ( int i = 0; anIterX.More() && anIterY.More(); anIterX.Next(), anIterY.Next(), ++i )
1147 double aCoordX = anIterX.Value();
1148 double aCoordY = anIterY.Value();
1150 if ( i == thePointIndex )
1152 // Insert our new point
1153 aListX->Append( thePoint.X() );
1154 aListY->Append( thePoint.Y() );
1157 aListX->Append( aCoordX );
1158 aListY->Append( aCoordY );
1165 void HYDROData_PolylineXY::SetPoint( const int theSectionIndex,
1166 const Point& thePoint,
1167 const int thePointIndex )
1169 Handle(TDataStd_RealList) aListX, aListY;
1170 getPointsLists( theSectionIndex, aListX, aListY );
1172 if ( thePointIndex < 0 )
1174 aListX->Prepend( thePoint.X() );
1175 aListY->Prepend( thePoint.Y() );
1177 else if ( thePointIndex >= aListX->Extent() )
1179 aListX->Append( thePoint.X() );
1180 aListY->Append( thePoint.Y() );
1184 TColStd_ListOfReal anOldListX;
1185 anOldListX = aListX->List();
1187 TColStd_ListOfReal anOldListY;
1188 anOldListY = aListY->List();
1190 // Refill the existing lists
1194 TColStd_ListIteratorOfListOfReal anIterX( anOldListX );
1195 TColStd_ListIteratorOfListOfReal anIterY( anOldListY );
1196 for ( int i = 0; anIterX.More() && anIterY.More(); anIterX.Next(), anIterY.Next(), ++i )
1198 double aCoordX = anIterX.Value();
1199 double aCoordY = anIterY.Value();
1201 if ( i == thePointIndex )
1203 // Insert our new point instead of old one
1204 aCoordX = thePoint.X();
1205 aCoordY = thePoint.Y();
1208 aListX->Append( aCoordX );
1209 aListY->Append( aCoordY );
1216 void HYDROData_PolylineXY::SetPoints( const int theSectionIndex,
1217 const PointsList& thePoints )
1219 Handle(TDataStd_RealList) aListX, aListY;
1220 getPointsLists( theSectionIndex, aListX, aListY );
1225 for ( int i = 1, n = thePoints.Length(); i <= n; ++i )
1227 const Point& aPoint = thePoints.Value( i );
1228 aListX->Append( aPoint.X() );
1229 aListY->Append( aPoint.Y() );
1233 void HYDROData_PolylineXY::RemovePoint( const int theSectionIndex,
1234 const int thePointIndex )
1236 Handle(TDataStd_RealList) aListX, aListY;
1237 getPointsLists( theSectionIndex, aListX, aListY, false );
1238 if ( aListX.IsNull() || aListY.IsNull() || aListX->IsEmpty() )
1241 if ( aListX->Extent() == 1 )
1243 removePointsLists( theSectionIndex );
1247 TColStd_ListOfReal anOldListX;
1248 anOldListX = aListX->List();
1250 TColStd_ListOfReal anOldListY;
1251 anOldListY = aListY->List();
1253 // Refill the existing lists
1257 TColStd_ListIteratorOfListOfReal anIterX( anOldListX );
1258 TColStd_ListIteratorOfListOfReal anIterY( anOldListY );
1259 for ( int i = 0; anIterX.More() && anIterY.More(); anIterX.Next(), anIterY.Next(), ++i )
1261 if ( i == thePointIndex )
1262 continue; // skip index to remove
1264 aListX->Append( anIterX.Value() );
1265 aListY->Append( anIterY.Value() );
1272 HYDROData_PolylineXY::PointsList HYDROData_PolylineXY::GetPoints( const int theSectionIndex, bool IsConvertToGlobal ) const
1274 PointsList aResList;
1278 const_cast<HYDROData_PolylineXY*>( this )->Interpolate();
1281 Handle(TDataStd_RealList) aListX, aListY;
1282 getPointsLists( theSectionIndex, aListX, aListY, false );
1283 if ( aListX.IsNull() || aListY.IsNull() || aListX->IsEmpty() )
1286 TColStd_ListIteratorOfListOfReal anIterX( aListX->List() );
1287 TColStd_ListIteratorOfListOfReal anIterY( aListY->List() );
1288 Handle(HYDROData_Document) aDoc = HYDROData_Document::Document( myLab );
1289 for ( ; anIterX.More() && anIterY.More(); anIterX.Next(), anIterY.Next() )
1291 Point aPoint( anIterX.Value(), anIterY.Value() );
1292 if (IsConvertToGlobal)
1293 aDoc->Transform( aPoint, false );
1294 aResList.Append( aPoint );
1300 QPainterPath HYDROData_PolylineXY::GetPainterPath() const
1304 NCollection_Sequence<TCollection_AsciiString> aSectNames;
1305 NCollection_Sequence<HYDROData_PolylineXY::SectionType> aSectTypes;
1306 NCollection_Sequence<bool> aSectClosures;
1307 GetSections( aSectNames, aSectTypes, aSectClosures );
1309 for ( int aSectionId = 1, aNbSects = aSectNames.Size(); aSectionId <= aNbSects; aSectionId++ )
1311 TCollection_AsciiString aSectName = aSectNames.Value( aSectionId );
1312 SectionType aSectionType = aSectTypes.Value( aSectionId );
1313 bool anIsSectionClosed = aSectClosures.Value( aSectionId );
1315 PointsList aSectPointsList = GetPoints( aSectionId - 1 );
1316 if ( aSectPointsList.IsEmpty() )
1319 NCollection_Sequence<gp_XYZ> aPoints;
1320 for( int i = 1, n = aSectPointsList.Size(); i <= n; ++i )
1322 const Point& aSectPoint = aSectPointsList.Value( i );
1324 gp_XYZ aPoint( aSectPoint.X(), aSectPoint.Y(), 0.0 );
1325 aPoints.Append( aPoint );
1328 BuildPainterPath( aPath, aSectionType, anIsSectionClosed, aPoints );
1334 void HYDROData_PolylineXY::UpdateLocalCS( double theDx, double theDy )
1336 NCollection_Sequence<TCollection_AsciiString> aSectNames;
1337 NCollection_Sequence<HYDROData_PolylineXY::SectionType> aSectTypes;
1338 NCollection_Sequence<bool> aSectClosures;
1339 GetSections( aSectNames, aSectTypes, aSectClosures );
1341 gp_XY aDelta( theDx, theDy );
1342 for ( int i = 0, aNbSects = aSectNames.Size(); i < aNbSects; i++ )
1344 PointsList aPoints = GetPoints( i );
1345 for( int j = 1, n = aPoints.Size(); j <= n; ++j )
1347 Point& aPoint = aPoints.ChangeValue( j );
1350 SetPoints( i, aPoints );
1355 void HYDROData_PolylineXY::Transform( const QTransform& theTrsf )
1357 NCollection_Sequence<TCollection_AsciiString> aSectNames;
1358 NCollection_Sequence<HYDROData_PolylineXY::SectionType> aSectTypes;
1359 NCollection_Sequence<bool> aSectClosures;
1360 GetSections( aSectNames, aSectTypes, aSectClosures );
1362 for ( int i = 0, aNbSects = aSectNames.Size(); i < aNbSects; i++ ) {
1363 PointsList aPoints = GetPoints( i );
1364 for( int j = 1, n = aPoints.Size(); j <= n; ++j ) {
1365 Point& aPoint = aPoints.ChangeValue( j );
1367 QPointF aTrsfPoint = theTrsf.map( QPointF( aPoint.X(), aPoint.Y() ) );
1369 aPoint.SetX( aTrsfPoint.x() );
1370 aPoint.SetY( aTrsfPoint.y() );
1372 SetPoints( i, aPoints );
1378 bool HYDROData_PolylineXY::IsCustom() const
1380 if( myIsInCustomFlag )
1383 bool isNull = GetShape().IsNull();
1386 HYDROData_PolylineXY* aThat = const_cast<HYDROData_PolylineXY*>( this );
1387 aThat->myIsInCustomFlag = true;
1388 for( int i=0, n=NbSections(); i<n; i++ )
1389 aNbPoints += NbPoints( i );
1390 aThat->myIsInCustomFlag = false;
1392 return !isNull && aNbPoints == 0;
1395 bool HYDROData_PolylineXY::GetIsInCustomFlag() const
1397 return myIsInCustomFlag;
1400 void HYDROData_PolylineXY::SetIsInCustomFlag( bool theValue )
1402 myIsInCustomFlag = theValue;
1405 void HYDROData_PolylineXY::Interpolate()
1407 ImportShape( GetShape(), true );