2 #include "HYDROData_IPolyline.h"
6 #include <TDataStd_BooleanList.hxx>
7 #include <TDataStd_ExtStringList.hxx>
8 #include <TDataStd_IntegerList.hxx>
9 #include <TDataStd_RealList.hxx>
11 #include <TopoDS_Shape.hxx>
13 #include <TNaming_Builder.hxx>
14 #include <TNaming_NamedShape.hxx>
16 IMPLEMENT_STANDARD_HANDLE(HYDROData_IPolyline, HYDROData_Entity)
17 IMPLEMENT_STANDARD_RTTIEXT(HYDROData_IPolyline, HYDROData_Entity)
19 HYDROData_IPolyline::HYDROData_IPolyline()
24 HYDROData_IPolyline::~HYDROData_IPolyline()
28 int HYDROData_IPolyline::NbPoints( const int theSectionIndex ) const
30 return GetPoints( theSectionIndex ).Length();
33 TopoDS_Shape HYDROData_IPolyline::getPolylineShape() const
35 TDF_Label aShapeLabel = myLab.FindChild( DataTag_PolylineShape, false );
36 if ( !aShapeLabel.IsNull() )
38 Handle(TNaming_NamedShape) aNamedShape;
39 if ( aShapeLabel.FindAttribute( TNaming_NamedShape::GetID(), aNamedShape ) )
40 return aNamedShape->Get();
42 return TopoDS_Shape();
45 void HYDROData_IPolyline::setPolylineShape( const TopoDS_Shape& theShape )
47 TNaming_Builder aBuilder( myLab.FindChild( DataTag_PolylineShape ) );
48 aBuilder.Generated( theShape );
51 void HYDROData_IPolyline::removePolylineShape()
53 TDF_Label aShapeLabel = myLab.FindChild( DataTag_PolylineShape, false );
54 if ( !aShapeLabel.IsNull() )
55 aShapeLabel.ForgetAllAttributes();
58 void HYDROData_IPolyline::getSectionsLists( Handle(TDataStd_ExtStringList)& theNamesList,
59 Handle(TDataStd_IntegerList)& theTypesList,
60 Handle(TDataStd_BooleanList)& theClosuresList,
61 const bool theIsCreate ) const
63 theNamesList.Nullify();
64 theTypesList.Nullify();
65 theClosuresList.Nullify();
67 TDF_Label aSectLabel = myLab.FindChild( DataTag_Sections, theIsCreate );
68 if ( aSectLabel.IsNull() )
71 if ( !aSectLabel.FindAttribute( TDataStd_ExtStringList::GetID(), theNamesList ) && theIsCreate )
72 theNamesList = TDataStd_ExtStringList::Set( aSectLabel );
74 if ( !aSectLabel.FindAttribute( TDataStd_IntegerList::GetID(), theTypesList ) && theIsCreate )
75 theTypesList = TDataStd_IntegerList::Set( aSectLabel );
77 if ( !aSectLabel.FindAttribute( TDataStd_BooleanList::GetID(), theClosuresList ) && theIsCreate )
78 theClosuresList = TDataStd_BooleanList::Set( aSectLabel );
81 void HYDROData_IPolyline::removeSectionsLists()
83 TDF_Label aSectsLabel = myLab.FindChild( DataTag_Sections, false );
84 if ( !aSectsLabel.IsNull() )
85 aSectsLabel.ForgetAllAttributes();
88 void HYDROData_IPolyline::getPointsLists( const int theSectionIndex,
89 Handle(TDataStd_RealList)& theListX,
90 Handle(TDataStd_RealList)& theListY,
91 const bool theIsCreate ) const
96 TDF_Label aLabel = myLab.FindChild( DataTag_Points, theIsCreate );
97 if ( aLabel.IsNull() )
100 TDF_Label aSectLabel = aLabel.FindChild( theSectionIndex, theIsCreate );
101 if ( aSectLabel.IsNull() )
104 TDF_Label aLabelX = aSectLabel.FindChild( 0, theIsCreate );
105 if ( !aLabelX.IsNull() )
107 if ( !aLabelX.FindAttribute( TDataStd_RealList::GetID(), theListX ) && theIsCreate )
108 theListX = TDataStd_RealList::Set( aLabelX );
111 TDF_Label aLabelY = aSectLabel.FindChild( 1, theIsCreate );
112 if ( !aLabelY.IsNull() )
114 if ( !aLabelY.FindAttribute( TDataStd_RealList::GetID(), theListY ) && theIsCreate )
115 theListY = TDataStd_RealList::Set( aLabelY );
119 void HYDROData_IPolyline::removePointsLists( const int theSectionIndex ) const
121 TDF_Label aLabel = myLab.FindChild( DataTag_Points, false );
122 if ( aLabel.IsNull() )
125 if ( theSectionIndex < 0 )
127 aLabel.ForgetAllAttributes();
131 TDF_Label aSectLabel = aLabel.FindChild( theSectionIndex, false );
132 if ( !aSectLabel.IsNull() )
133 aSectLabel.ForgetAllAttributes();