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 IMPLEMENT_STANDARD_HANDLE(HYDROData_Channel,HYDROData_ArtificialObject)
34 IMPLEMENT_STANDARD_RTTIEXT(HYDROData_Channel,HYDROData_ArtificialObject)
37 HYDROData_Channel::HYDROData_Channel()
38 : HYDROData_ArtificialObject()
42 HYDROData_Channel::~HYDROData_Channel()
46 QStringList HYDROData_Channel::DumpToPython( MapOfTreatedObjects& theTreatedObjects ) const
48 QStringList aResList = dumpObjectCreation( theTreatedObjects );
49 QString aName = GetObjPyName();
51 Handle(HYDROData_Polyline3D) aRefGideLine = GetGuideLine();
52 setPythonReferenceObject( theTreatedObjects, aResList, aRefGideLine, "SetGuideLine" );
54 Handle(HYDROData_Profile) aRefProfile = GetProfile();
55 setPythonReferenceObject( theTreatedObjects, aResList, aRefProfile, "SetProfile" );
57 aResList << QString( "" );
58 aResList << QString( "%1.Update();" ).arg( aName );
59 aResList << QString( "" );
64 HYDROData_SequenceOfObjects HYDROData_Channel::GetAllReferenceObjects() const
66 HYDROData_SequenceOfObjects aResSeq = HYDROData_ArtificialObject::GetAllReferenceObjects();
68 Handle(HYDROData_Polyline3D) aGuideLine = GetGuideLine();
69 if ( !aGuideLine.IsNull() )
70 aResSeq.Append( aGuideLine );
72 Handle(HYDROData_Profile) aProfile = GetProfile();
73 if ( !aProfile.IsNull() )
74 aResSeq.Append( aProfile );
79 TopoDS_Shape HYDROData_Channel::GetTopShape() const
84 TopoDS_Shape HYDROData_Channel::GetShape3D() const
89 void HYDROData_Channel::Update()
91 HYDROData_ArtificialObject::Update();
93 Handle(HYDROData_Polyline3D) aGuideLine = GetGuideLine();
94 Handle(HYDROData_Profile) aProfile = GetProfile();
95 if ( aGuideLine.IsNull() || aProfile.IsNull() )
99 TopoDS_Wire aPathWire = TopoDS::Wire(aGuideLine->GetShape3D());
100 if(aPathWire.IsNull())
102 TopoDS_Wire aProfileWire = TopoDS::Wire( aProfile->GetShape3D() );
103 if(aProfileWire.IsNull())
106 BRepTools::Write( aPathWire, "guideline.brep" );
107 BRepTools::Write( aProfileWire, "profile.brep" );
109 HYDROData_Canal3dAnd2d aChannelConstructor( aProfileWire, aPathWire );
110 aChannelConstructor.Create3dPresentation();
111 aChannelConstructor.Create2dPresentation();
112 SetShape3D( aChannelConstructor.Get3dPresentation() );
113 SetTopShape( aChannelConstructor.Get2dPresentation() );
115 BRepTools::Write( aChannelConstructor.Get2dPresentation(), "channel2d.brep" );
116 BRepTools::Write( aChannelConstructor.Get3dPresentation(), "channel3d.brep" );
118 TopAbs_ShapeEnum aType = GetTopShape().ShapeType();
120 // Create groups for channel
121 TopoDS_Wire aLeftBank = aChannelConstructor.GetLeftBank();
122 TopoDS_Wire aRightBank = aChannelConstructor.GetRightBank();
123 TopoDS_Wire anInlet = aChannelConstructor.GetInlet();
124 TopoDS_Wire anOutlet = aChannelConstructor.GetOutlet();
126 TopTools_SequenceOfShape aLeftBankEdges;
127 HYDROData_ShapesTool::ExploreShapeToShapes( aLeftBank, TopAbs_EDGE, aLeftBankEdges );
129 TopTools_SequenceOfShape aRightBankEdges;
130 HYDROData_ShapesTool::ExploreShapeToShapes( aRightBank, TopAbs_EDGE, aRightBankEdges );
132 TopTools_SequenceOfShape anInletEdges;
133 HYDROData_ShapesTool::ExploreShapeToShapes( anInlet, TopAbs_EDGE, anInletEdges );
135 TopTools_SequenceOfShape anOutletEdges;
136 HYDROData_ShapesTool::ExploreShapeToShapes( anOutlet, TopAbs_EDGE, anOutletEdges );
138 QString aLeftGroupName = GetName() + "_Left_Bank";
140 Handle(HYDROData_ShapesGroup) aLeftGroup = createGroupObject();
141 aLeftGroup->SetName( aLeftGroupName );
142 aLeftGroup->SetShapes( aLeftBankEdges );
144 QString aRightGroupName = GetName() + "_Right_Bank";
146 Handle(HYDROData_ShapesGroup) aRightGroup = createGroupObject();
147 aRightGroup->SetName( aRightGroupName );
148 aRightGroup->SetShapes( aRightBankEdges );
150 QString anInGroupName = GetName() + "_Inlet";
152 Handle(HYDROData_ShapesGroup) anInGroup = createGroupObject();
153 anInGroup->SetName( anInGroupName );
154 anInGroup->SetShapes( anInletEdges );
156 QString anOutGroupName = GetName() + "_Outlet";
158 Handle(HYDROData_ShapesGroup) anOutGroup = createGroupObject();
159 anOutGroup->SetName( anOutGroupName );
160 anOutGroup->SetShapes( anOutletEdges );
163 QColor HYDROData_Channel::DefaultFillingColor()
165 return QColor( Qt::blue );
168 QColor HYDROData_Channel::DefaultBorderColor()
170 return QColor( Qt::transparent );
173 QColor HYDROData_Channel::getDefaultFillingColor() const
175 return DefaultFillingColor();
178 QColor HYDROData_Channel::getDefaultBorderColor() const
180 return DefaultBorderColor();
183 bool HYDROData_Channel::SetGuideLine( const Handle(HYDROData_Polyline3D)& theGuideLine )
185 Handle(HYDROData_Polyline3D) aPrevGuideLine = GetGuideLine();
187 if ( theGuideLine.IsNull() )
190 return !aPrevGuideLine.IsNull();
193 if ( IsEqual( aPrevGuideLine, theGuideLine ) )
196 TopoDS_Wire aHydraulicWire = TopoDS::Wire( theGuideLine->GetTopShape() );
197 if ( aHydraulicWire.IsNull() )
198 return false; // The polyline must be a single wire
200 SetReferenceObject( theGuideLine, DataTag_GuideLine );
202 // Indicate model of the need to update the chanel presentation
208 Handle(HYDROData_Polyline3D) HYDROData_Channel::GetGuideLine() const
210 return Handle(HYDROData_Polyline3D)::DownCast(
211 GetReferenceObject( DataTag_GuideLine ) );
214 void HYDROData_Channel::RemoveGuideLine()
216 Handle(HYDROData_Polyline3D) aPrevGuideLine = GetGuideLine();
217 if ( aPrevGuideLine.IsNull() )
220 ClearReferenceObjects( DataTag_GuideLine );
222 // Indicate model of the need to update the chanel presentation
226 bool HYDROData_Channel::SetProfile( const Handle(HYDROData_Profile)& theProfile )
228 Handle(HYDROData_Profile) aPrevProfile = GetProfile();
230 if ( theProfile.IsNull() )
233 return !aPrevProfile.IsNull();
236 if ( IsEqual( aPrevProfile, theProfile ) )
239 SetReferenceObject( theProfile, DataTag_Profile );
241 // Indicate model of the need to update the chanel presentation
247 Handle(HYDROData_Profile) HYDROData_Channel::GetProfile() const
249 return Handle(HYDROData_Profile)::DownCast(
250 GetReferenceObject( DataTag_Profile ) );
253 void HYDROData_Channel::RemoveProfile()
255 Handle(HYDROData_Profile) aPrevProfile = GetProfile();
256 if ( aPrevProfile.IsNull() )
259 ClearReferenceObjects( DataTag_Profile );
261 // Indicate model of the need to update the chanel presentation
265 ObjectKind HYDROData_Channel::getAltitudeObjectType() const
267 return KIND_OBSTACLE_ALTITUDE;