2 #include "HYDROData_ImmersibleZone.h"
4 #include "HYDROData_Bathymetry.h"
5 #include "HYDROData_Document.h"
6 #include "HYDROData_Polyline.h"
8 #include <BRepBuilderAPI_MakeFace.hxx>
11 #include <TopoDS_Face.hxx>
12 #include <TopoDS_Wire.hxx>
13 #include <TopoDS_Compound.hxx>
14 #include <TopExp_Explorer.hxx>
15 #include <TopTools_ListIteratorOfListOfShape.hxx>
16 #include <BRep_Builder.hxx>
19 #include <QStringList>
21 #define PYTHON_IMMERSIBLE_ZONE_ID "KIND_IMMERSIBLE_ZONE"
23 IMPLEMENT_STANDARD_HANDLE(HYDROData_ImmersibleZone,HYDROData_NaturalObject)
24 IMPLEMENT_STANDARD_RTTIEXT(HYDROData_ImmersibleZone,HYDROData_NaturalObject)
27 HYDROData_ImmersibleZone::HYDROData_ImmersibleZone()
28 : HYDROData_NaturalObject()
32 HYDROData_ImmersibleZone::~HYDROData_ImmersibleZone()
36 QStringList HYDROData_ImmersibleZone::DumpToPython( MapOfTreatedObjects& theTreatedObjects ) const
40 Handle(HYDROData_Document) aDocument = HYDROData_Document::Document( myLab );
41 if ( aDocument.IsNull() )
44 QString aDocName = aDocument->GetDocPyName();
45 QString aZoneName = GetName();
47 aResList << QString( "%1 = %2.CreateObject( %3 );" )
48 .arg( aZoneName ).arg( aDocName ).arg( PYTHON_IMMERSIBLE_ZONE_ID );
49 aResList << QString( "%1.SetName( \"%2\" );" )
50 .arg( aZoneName ).arg( aZoneName );
51 aResList << QString( "" );
53 QColor aFillingColor = GetFillingColor();
54 aResList << QString( "filling_color = QColor( %1, %2, %3, %4 );" )
55 .arg( aFillingColor.red() ).arg( aFillingColor.green() )
56 .arg( aFillingColor.blue() ).arg( aFillingColor.alpha() );
57 aResList << QString( "%1.SetFillingColor( filling_color );" ).arg( aZoneName );
58 aResList << QString( "" );
60 QColor aBorderColor = GetBorderColor();
61 aResList << QString( "border_color = QColor( %1, %2, %3, %4 );" )
62 .arg( aBorderColor.red() ).arg( aBorderColor.green() )
63 .arg( aBorderColor.blue() ).arg( aBorderColor.alpha() );
64 aResList << QString( "%1.SetBorderColor( border_color );" ).arg( aZoneName );
65 aResList << QString( "" );
67 Handle(HYDROData_Bathymetry) aRefBathymetry = GetBathymetry();
68 setPythonReferenceObject( theTreatedObjects, aResList, aRefBathymetry, "SetBathymetry" );
70 Handle(HYDROData_Polyline) aRefPolyline = GetPolyline();
71 setPythonReferenceObject( theTreatedObjects, aResList, aRefPolyline, "SetPolyline" );
76 TopoDS_Shape HYDROData_ImmersibleZone::GetTopShape() const
78 TopoDS_Shape aResShape = TopoDS_Face();
80 Handle(HYDROData_Polyline) aPolyline = GetPolyline();
81 if( !aPolyline.IsNull() )
83 TopoDS_Shape aPolylineShape = aPolyline->GetTopShape();
84 TopTools_ListOfShape aWiresList;
86 TopExp_Explorer anExp( aPolylineShape, TopAbs_WIRE );
87 if ( !anExp.More() ) {
88 TopoDS_Wire aPolylineWire = TopoDS::Wire( aPolylineShape );
89 if ( !aPolylineWire.IsNull() ) {
90 BRepBuilderAPI_MakeFace aMakeFace( aPolylineWire, Standard_True );
92 if( aMakeFace.IsDone() ) {
93 return aMakeFace.Face();
97 for ( ; anExp.More(); anExp.Next() ) {
98 TopoDS_Wire aWire = TopoDS::Wire( anExp.Current() );
99 aWiresList.Append( aWire );
103 TopoDS_Compound aCompound;
104 BRep_Builder aBuilder;
105 aBuilder.MakeCompound( aCompound );
107 TopTools_ListIteratorOfListOfShape anIter( aWiresList );
108 for ( ; anIter.More(); anIter.Next() ) {
109 TopoDS_Wire aWire = TopoDS::Wire( anIter.Value() );
110 if ( aWire.IsNull() ) {
114 BRepBuilderAPI_MakeFace aMakeFace( aWire, Standard_True );
116 if( aMakeFace.IsDone() ) {
117 aBuilder.Add( aCompound, aMakeFace.Face() );
121 aResShape = aCompound;
127 TopoDS_Shape HYDROData_ImmersibleZone::GetShape3D() const
130 return getTopShape();
133 QColor HYDROData_ImmersibleZone::DefaultFillingColor()
135 return QColor( Qt::green );
138 QColor HYDROData_ImmersibleZone::DefaultBorderColor()
140 return QColor( Qt::transparent );
143 void HYDROData_ImmersibleZone::SetPolyline( const Handle(HYDROData_Polyline)& thePolyline )
145 SetReferenceObject( thePolyline, DataTag_Polyline );
148 Handle(HYDROData_Polyline) HYDROData_ImmersibleZone::GetPolyline() const
150 return Handle(HYDROData_Polyline)::DownCast(
151 GetReferenceObject( DataTag_Polyline ) );
154 void HYDROData_ImmersibleZone::RemovePolyline()
156 ClearReferenceObjects( DataTag_Polyline );