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 = GetName();
53 aResList << QString( "" );
54 aResList << QString( "%1.Update();" ).arg( aName );
55 aResList << QString( "" );
60 HYDROData_SequenceOfObjects HYDROData_Channel::GetAllReferenceObjects() const
62 HYDROData_SequenceOfObjects aResSeq = HYDROData_ArtificialObject::GetAllReferenceObjects();
64 Handle(HYDROData_Polyline3D) aGuideLine = GetGuideLine();
65 if ( !aGuideLine.IsNull() )
66 aResSeq.Append( aGuideLine );
68 Handle(HYDROData_Profile) aProfile = GetProfile();
69 if ( !aProfile.IsNull() )
70 aResSeq.Append( aProfile );
75 TopoDS_Shape HYDROData_Channel::GetTopShape() const
80 TopoDS_Shape HYDROData_Channel::GetShape3D() const
85 void HYDROData_Channel::Update()
87 HYDROData_ArtificialObject::Update();
89 Handle(HYDROData_Polyline3D) aGuideLine = GetGuideLine();
90 Handle(HYDROData_Profile) aProfile = GetProfile();
91 if ( aGuideLine.IsNull() || aProfile.IsNull() )
95 TopoDS_Wire aPathWire = TopoDS::Wire(aGuideLine->GetShape3D());
96 if(aPathWire.IsNull())
98 TopoDS_Wire aProfileWire = TopoDS::Wire( aProfile->GetShape3D() );
99 if(aProfileWire.IsNull())
102 BRepTools::Write( aPathWire, "guideline.brep" );
103 BRepTools::Write( aProfileWire, "profile.brep" );
105 HYDROData_Canal3dAnd2d aChannelConstructor( aProfileWire, aPathWire );
106 aChannelConstructor.Create3dPresentation();
107 aChannelConstructor.Create2dPresentation();
108 SetShape3D( aChannelConstructor.Get3dPresentation() );
109 SetTopShape( aChannelConstructor.Get2dPresentation() );
111 BRepTools::Write( aChannelConstructor.Get2dPresentation(), "channel2d.brep" );
112 BRepTools::Write( aChannelConstructor.Get3dPresentation(), "channel3d.brep" );
114 TopAbs_ShapeEnum aType = GetTopShape().ShapeType();
116 // Create groups for channel
117 TopoDS_Wire aLeftBank = aChannelConstructor.GetLeftBank();
118 TopoDS_Wire aRightBank = aChannelConstructor.GetRightBank();
119 TopoDS_Wire anInlet = aChannelConstructor.GetInlet();
120 TopoDS_Wire anOutlet = aChannelConstructor.GetOutlet();
122 TopTools_SequenceOfShape aLeftBankEdges;
123 HYDROData_ShapesTool::ExploreShapeToShapes( aLeftBank, TopAbs_EDGE, aLeftBankEdges );
125 TopTools_SequenceOfShape aRightBankEdges;
126 HYDROData_ShapesTool::ExploreShapeToShapes( aRightBank, TopAbs_EDGE, aRightBankEdges );
128 TopTools_SequenceOfShape anInletEdges;
129 HYDROData_ShapesTool::ExploreShapeToShapes( anInlet, TopAbs_EDGE, anInletEdges );
131 TopTools_SequenceOfShape anOutletEdges;
132 HYDROData_ShapesTool::ExploreShapeToShapes( anOutlet, TopAbs_EDGE, anOutletEdges );
134 QString aLeftGroupName = GetName() + "_Left_Bank";
136 Handle(HYDROData_ShapesGroup) aLeftGroup = createGroupObject();
137 aLeftGroup->SetName( aLeftGroupName );
138 aLeftGroup->SetShapes( aLeftBankEdges );
140 QString aRightGroupName = GetName() + "_Right_Bank";
142 Handle(HYDROData_ShapesGroup) aRightGroup = createGroupObject();
143 aRightGroup->SetName( aRightGroupName );
144 aRightGroup->SetShapes( aRightBankEdges );
146 QString anInGroupName = GetName() + "_Inlet";
148 Handle(HYDROData_ShapesGroup) anInGroup = createGroupObject();
149 anInGroup->SetName( anInGroupName );
150 anInGroup->SetShapes( anInletEdges );
152 QString anOutGroupName = GetName() + "_Outlet";
154 Handle(HYDROData_ShapesGroup) anOutGroup = createGroupObject();
155 anOutGroup->SetName( anOutGroupName );
156 anOutGroup->SetShapes( anOutletEdges );
159 QColor HYDROData_Channel::DefaultFillingColor()
161 return QColor( Qt::blue );
164 QColor HYDROData_Channel::DefaultBorderColor()
166 return QColor( Qt::transparent );
169 QColor HYDROData_Channel::getDefaultFillingColor() const
171 return DefaultFillingColor();
174 QColor HYDROData_Channel::getDefaultBorderColor() const
176 return DefaultBorderColor();
179 bool HYDROData_Channel::SetGuideLine( const Handle(HYDROData_Polyline3D)& theGuideLine )
181 Handle(HYDROData_Polyline3D) aPrevGuideLine = GetGuideLine();
183 if ( theGuideLine.IsNull() )
186 return !aPrevGuideLine.IsNull();
189 if ( IsEqual( aPrevGuideLine, theGuideLine ) )
192 TopoDS_Wire aHydraulicWire = TopoDS::Wire( theGuideLine->GetTopShape() );
193 if ( aHydraulicWire.IsNull() )
194 return false; // The polyline must be a single wire
196 SetReferenceObject( theGuideLine, DataTag_GuideLine );
198 // Indicate model of the need to update the chanel presentation
204 Handle(HYDROData_Polyline3D) HYDROData_Channel::GetGuideLine() const
206 return Handle(HYDROData_Polyline3D)::DownCast(
207 GetReferenceObject( DataTag_GuideLine ) );
210 void HYDROData_Channel::RemoveGuideLine()
212 Handle(HYDROData_Polyline3D) aPrevGuideLine = GetGuideLine();
213 if ( aPrevGuideLine.IsNull() )
216 ClearReferenceObjects( DataTag_GuideLine );
218 // Indicate model of the need to update the chanel presentation
222 bool HYDROData_Channel::SetProfile( const Handle(HYDROData_Profile)& theProfile )
224 Handle(HYDROData_Profile) aPrevProfile = GetProfile();
226 if ( theProfile.IsNull() )
229 return !aPrevProfile.IsNull();
232 if ( IsEqual( aPrevProfile, theProfile ) )
235 SetReferenceObject( theProfile, DataTag_Profile );
237 // Indicate model of the need to update the chanel presentation
243 Handle(HYDROData_Profile) HYDROData_Channel::GetProfile() const
245 return Handle(HYDROData_Profile)::DownCast(
246 GetReferenceObject( DataTag_Profile ) );
249 void HYDROData_Channel::RemoveProfile()
251 Handle(HYDROData_Profile) aPrevProfile = GetProfile();
252 if ( aPrevProfile.IsNull() )
255 ClearReferenceObjects( DataTag_Profile );
257 // Indicate model of the need to update the chanel presentation
261 ObjectKind HYDROData_Channel::getAltitudeObjectType() const
263 return KIND_OBSTACLE_ALTITUDE;