2 #include "HYDROData_Channel.h"
4 #include "HYDROData_Document.h"
5 #include "HYDROData_Polyline3D.h"
6 #include "HYDROData_Profile.h"
7 #include "HYDROData_PolylineXY.h"
8 #include "HYDROData_Projection.h"
9 #include "HYDROData_ShapesGroup.h"
10 #include "HYDROData_ShapesTool.h"
11 #include "HYDROData_Pipes.h"
13 #include <BRepOffsetAPI_MakePipeShell.hxx>
14 #include <BRepOffsetAPI_MakePipe.hxx>
15 #include <BRepCheck_Analyzer.hxx>
16 #include <BRepTools.hxx>
21 #include <TopoDS_Wire.hxx>
22 #include <TopoDS_Vertex.hxx>
23 #include <TopoDS_Face.hxx>
25 //#define DEB_CHANNEL 1
27 #include <BRepTools.hxx>
31 #include <QStringList>
33 #define PYTHON_CHANNEL_ID "KIND_CHANNEL"
35 IMPLEMENT_STANDARD_HANDLE(HYDROData_Channel,HYDROData_ArtificialObject)
36 IMPLEMENT_STANDARD_RTTIEXT(HYDROData_Channel,HYDROData_ArtificialObject)
39 HYDROData_Channel::HYDROData_Channel()
40 : HYDROData_ArtificialObject()
44 HYDROData_Channel::~HYDROData_Channel()
48 QStringList HYDROData_Channel::DumpToPython( MapOfTreatedObjects& theTreatedObjects ) const
52 Handle(HYDROData_Document) aDocument = HYDROData_Document::Document( myLab );
53 if ( aDocument.IsNull() )
56 QString aDocName = aDocument->GetDocPyName();
57 QString aChannelName = GetName();
59 aResList << QString( "%1 = %2.CreateObject( %3 );" )
60 .arg( aChannelName ).arg( aDocName ).arg( PYTHON_CHANNEL_ID );
61 aResList << QString( "%1.SetName( \"%2\" );" )
62 .arg( aChannelName ).arg( aChannelName );
63 aResList << QString( "" );
70 HYDROData_SequenceOfObjects HYDROData_Channel::GetAllReferenceObjects() const
72 HYDROData_SequenceOfObjects aResSeq = HYDROData_ArtificialObject::GetAllReferenceObjects();
74 Handle(HYDROData_Polyline3D) aGuideLine = GetGuideLine();
75 if ( !aGuideLine.IsNull() )
76 aResSeq.Append( aGuideLine );
78 Handle(HYDROData_Profile) aProfile = GetProfile();
79 if ( !aProfile.IsNull() )
80 aResSeq.Append( aProfile );
85 TopoDS_Shape HYDROData_Channel::GetTopShape() const
90 TopoDS_Shape HYDROData_Channel::GetShape3D() const
95 void HYDROData_Channel::Update()
97 HYDROData_ArtificialObject::Update();
99 Handle(HYDROData_Polyline3D) aGuideLine = GetGuideLine();
100 Handle(HYDROData_Profile) aProfile = GetProfile();
101 if ( aGuideLine.IsNull() || aProfile.IsNull() )
105 TopoDS_Wire aPathWire = TopoDS::Wire(aGuideLine->GetShape3D());
106 if(aPathWire.IsNull())
108 TopoDS_Wire aProfileWire = TopoDS::Wire( aProfile->GetShape3D() );
109 if(aProfileWire.IsNull())
112 //BRepTools::Write( aPathWire, "guideline.brep" );
113 //BRepTools::Write( aProfileWire, "profile.brep" );
115 HYDROData_Canal3dAnd2d aChannelConstructor( aProfileWire, aPathWire );
116 aChannelConstructor.Create3dPresentation();
117 aChannelConstructor.Create2dPresentation();
118 SetShape3D( aChannelConstructor.Get3dPresentation() );
119 SetTopShape( aChannelConstructor.Get2dPresentation() );
121 //BRepTools::Write( aPathWire, "guideline.brep" );
122 //BRepTools::Write( aProfileWire, "profile.brep" );
123 //BRepTools::Write( aChannelConstructor.Get2dPresentation(), "channel2d.brep" );
124 //BRepTools::Write( aChannelConstructor.Get3dPresentation(), "channel3d.brep" );
126 // Create groups for channel
127 TopoDS_Wire aLeftBank = aChannelConstructor.GetLeftBank();
128 TopoDS_Wire aRightBank = aChannelConstructor.GetRightBank();
129 TopoDS_Wire anInlet = aChannelConstructor.GetInlet();
130 TopoDS_Wire anOutlet = aChannelConstructor.GetOutlet();
132 TopTools_SequenceOfShape aLeftBankEdges;
133 HYDROData_ShapesTool::ExploreShapeToShapes( aLeftBank, TopAbs_EDGE, aLeftBankEdges );
135 TopTools_SequenceOfShape aRightBankEdges;
136 HYDROData_ShapesTool::ExploreShapeToShapes( aRightBank, TopAbs_EDGE, aRightBankEdges );
138 TopTools_SequenceOfShape anInletEdges;
139 HYDROData_ShapesTool::ExploreShapeToShapes( anInlet, TopAbs_EDGE, anInletEdges );
141 TopTools_SequenceOfShape anOutletEdges;
142 HYDROData_ShapesTool::ExploreShapeToShapes( anOutlet, TopAbs_EDGE, anOutletEdges );
144 QString aLeftGroupName = GetName() + "_Left_Bank";
146 Handle(HYDROData_ShapesGroup) aLeftGroup = createGroupObject();
147 aLeftGroup->SetName( aLeftGroupName );
148 aLeftGroup->SetShapes( aLeftBankEdges );
150 QString aRightGroupName = GetName() + "_Right_Bank";
152 Handle(HYDROData_ShapesGroup) aRightGroup = createGroupObject();
153 aRightGroup->SetName( aRightGroupName );
154 aRightGroup->SetShapes( aRightBankEdges );
156 QString anInGroupName = GetName() + "_Inlet";
158 Handle(HYDROData_ShapesGroup) anInGroup = createGroupObject();
159 anInGroup->SetName( anInGroupName );
160 anInGroup->SetShapes( anInletEdges );
162 QString anOutGroupName = GetName() + "_Outlet";
164 Handle(HYDROData_ShapesGroup) anOutGroup = createGroupObject();
165 anOutGroup->SetName( anOutGroupName );
166 anOutGroup->SetShapes( anOutletEdges );
169 QColor HYDROData_Channel::DefaultFillingColor()
171 return QColor( Qt::blue );
174 QColor HYDROData_Channel::DefaultBorderColor()
176 return QColor( Qt::transparent );
179 QColor HYDROData_Channel::getDefaultFillingColor() const
181 return DefaultFillingColor();
184 QColor HYDROData_Channel::getDefaultBorderColor() const
186 return DefaultBorderColor();
189 bool HYDROData_Channel::SetGuideLine( const Handle(HYDROData_Polyline3D)& theGuideLine )
191 Handle(HYDROData_Polyline3D) aPrevGuideLine = GetGuideLine();
193 if ( theGuideLine.IsNull() )
196 return !aPrevGuideLine.IsNull();
199 if ( IsEqual( aPrevGuideLine, theGuideLine ) )
202 TopoDS_Wire aHydraulicWire = TopoDS::Wire( theGuideLine->GetTopShape() );
203 if ( aHydraulicWire.IsNull() )
204 return false; // The polyline must be a single wire
206 SetReferenceObject( theGuideLine, DataTag_GuideLine );
208 // Indicate model of the need to update the chanel presentation
214 Handle(HYDROData_Polyline3D) HYDROData_Channel::GetGuideLine() const
216 return Handle(HYDROData_Polyline3D)::DownCast(
217 GetReferenceObject( DataTag_GuideLine ) );
220 void HYDROData_Channel::RemoveGuideLine()
222 Handle(HYDROData_Polyline3D) aPrevGuideLine = GetGuideLine();
223 if ( aPrevGuideLine.IsNull() )
226 ClearReferenceObjects( DataTag_GuideLine );
228 // Indicate model of the need to update the chanel presentation
232 bool HYDROData_Channel::SetProfile( const Handle(HYDROData_Profile)& theProfile )
234 Handle(HYDROData_Profile) aPrevProfile = GetProfile();
236 if ( theProfile.IsNull() )
239 return !aPrevProfile.IsNull();
242 if ( IsEqual( aPrevProfile, theProfile ) )
245 SetReferenceObject( theProfile, DataTag_Profile );
247 // Indicate model of the need to update the chanel presentation
253 Handle(HYDROData_Profile) HYDROData_Channel::GetProfile() const
255 return Handle(HYDROData_Profile)::DownCast(
256 GetReferenceObject( DataTag_Profile ) );
259 void HYDROData_Channel::RemoveProfile()
261 Handle(HYDROData_Profile) aPrevProfile = GetProfile();
262 if ( aPrevProfile.IsNull() )
265 ClearReferenceObjects( DataTag_Profile );
267 // Indicate model of the need to update the chanel presentation
271 ObjectKind HYDROData_Channel::getAltitudeObjectType() const
273 return KIND_OBSTACLE_ALTITUDE;