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 );
55 HYDROData_SequenceOfObjects HYDROData_Channel::GetAllReferenceObjects() const
57 HYDROData_SequenceOfObjects aResSeq = HYDROData_ArtificialObject::GetAllReferenceObjects();
59 Handle(HYDROData_Polyline3D) aGuideLine = GetGuideLine();
60 if ( !aGuideLine.IsNull() )
61 aResSeq.Append( aGuideLine );
63 Handle(HYDROData_Profile) aProfile = GetProfile();
64 if ( !aProfile.IsNull() )
65 aResSeq.Append( aProfile );
70 TopoDS_Shape HYDROData_Channel::GetTopShape() const
75 TopoDS_Shape HYDROData_Channel::GetShape3D() const
80 void HYDROData_Channel::Update()
82 HYDROData_ArtificialObject::Update();
84 Handle(HYDROData_Polyline3D) aGuideLine = GetGuideLine();
85 Handle(HYDROData_Profile) aProfile = GetProfile();
86 if ( aGuideLine.IsNull() || aProfile.IsNull() )
90 TopoDS_Wire aPathWire = TopoDS::Wire(aGuideLine->GetShape3D());
91 if(aPathWire.IsNull())
93 TopoDS_Wire aProfileWire = TopoDS::Wire( aProfile->GetShape3D() );
94 if(aProfileWire.IsNull())
97 BRepTools::Write( aPathWire, "guideline.brep" );
98 BRepTools::Write( aProfileWire, "profile.brep" );
100 HYDROData_Canal3dAnd2d aChannelConstructor( aProfileWire, aPathWire );
101 aChannelConstructor.Create3dPresentation();
102 aChannelConstructor.Create2dPresentation();
103 SetShape3D( aChannelConstructor.Get3dPresentation() );
104 SetTopShape( aChannelConstructor.Get2dPresentation() );
106 BRepTools::Write( aChannelConstructor.Get2dPresentation(), "channel2d.brep" );
107 BRepTools::Write( aChannelConstructor.Get3dPresentation(), "channel3d.brep" );
109 TopAbs_ShapeEnum aType = GetTopShape().ShapeType();
111 // Create groups for channel
112 TopoDS_Wire aLeftBank = aChannelConstructor.GetLeftBank();
113 TopoDS_Wire aRightBank = aChannelConstructor.GetRightBank();
114 TopoDS_Wire anInlet = aChannelConstructor.GetInlet();
115 TopoDS_Wire anOutlet = aChannelConstructor.GetOutlet();
117 TopTools_SequenceOfShape aLeftBankEdges;
118 HYDROData_ShapesTool::ExploreShapeToShapes( aLeftBank, TopAbs_EDGE, aLeftBankEdges );
120 TopTools_SequenceOfShape aRightBankEdges;
121 HYDROData_ShapesTool::ExploreShapeToShapes( aRightBank, TopAbs_EDGE, aRightBankEdges );
123 TopTools_SequenceOfShape anInletEdges;
124 HYDROData_ShapesTool::ExploreShapeToShapes( anInlet, TopAbs_EDGE, anInletEdges );
126 TopTools_SequenceOfShape anOutletEdges;
127 HYDROData_ShapesTool::ExploreShapeToShapes( anOutlet, TopAbs_EDGE, anOutletEdges );
129 QString aLeftGroupName = GetName() + "_Left_Bank";
131 Handle(HYDROData_ShapesGroup) aLeftGroup = createGroupObject();
132 aLeftGroup->SetName( aLeftGroupName );
133 aLeftGroup->SetShapes( aLeftBankEdges );
135 QString aRightGroupName = GetName() + "_Right_Bank";
137 Handle(HYDROData_ShapesGroup) aRightGroup = createGroupObject();
138 aRightGroup->SetName( aRightGroupName );
139 aRightGroup->SetShapes( aRightBankEdges );
141 QString anInGroupName = GetName() + "_Inlet";
143 Handle(HYDROData_ShapesGroup) anInGroup = createGroupObject();
144 anInGroup->SetName( anInGroupName );
145 anInGroup->SetShapes( anInletEdges );
147 QString anOutGroupName = GetName() + "_Outlet";
149 Handle(HYDROData_ShapesGroup) anOutGroup = createGroupObject();
150 anOutGroup->SetName( anOutGroupName );
151 anOutGroup->SetShapes( anOutletEdges );
154 QColor HYDROData_Channel::DefaultFillingColor()
156 return QColor( Qt::blue );
159 QColor HYDROData_Channel::DefaultBorderColor()
161 return QColor( Qt::transparent );
164 QColor HYDROData_Channel::getDefaultFillingColor() const
166 return DefaultFillingColor();
169 QColor HYDROData_Channel::getDefaultBorderColor() const
171 return DefaultBorderColor();
174 bool HYDROData_Channel::SetGuideLine( const Handle(HYDROData_Polyline3D)& theGuideLine )
176 Handle(HYDROData_Polyline3D) aPrevGuideLine = GetGuideLine();
178 if ( theGuideLine.IsNull() )
181 return !aPrevGuideLine.IsNull();
184 if ( IsEqual( aPrevGuideLine, theGuideLine ) )
187 TopoDS_Wire aHydraulicWire = TopoDS::Wire( theGuideLine->GetTopShape() );
188 if ( aHydraulicWire.IsNull() )
189 return false; // The polyline must be a single wire
191 SetReferenceObject( theGuideLine, DataTag_GuideLine );
193 // Indicate model of the need to update the chanel presentation
199 Handle(HYDROData_Polyline3D) HYDROData_Channel::GetGuideLine() const
201 return Handle(HYDROData_Polyline3D)::DownCast(
202 GetReferenceObject( DataTag_GuideLine ) );
205 void HYDROData_Channel::RemoveGuideLine()
207 Handle(HYDROData_Polyline3D) aPrevGuideLine = GetGuideLine();
208 if ( aPrevGuideLine.IsNull() )
211 ClearReferenceObjects( DataTag_GuideLine );
213 // Indicate model of the need to update the chanel presentation
217 bool HYDROData_Channel::SetProfile( const Handle(HYDROData_Profile)& theProfile )
219 Handle(HYDROData_Profile) aPrevProfile = GetProfile();
221 if ( theProfile.IsNull() )
224 return !aPrevProfile.IsNull();
227 if ( IsEqual( aPrevProfile, theProfile ) )
230 SetReferenceObject( theProfile, DataTag_Profile );
232 // Indicate model of the need to update the chanel presentation
238 Handle(HYDROData_Profile) HYDROData_Channel::GetProfile() const
240 return Handle(HYDROData_Profile)::DownCast(
241 GetReferenceObject( DataTag_Profile ) );
244 void HYDROData_Channel::RemoveProfile()
246 Handle(HYDROData_Profile) aPrevProfile = GetProfile();
247 if ( aPrevProfile.IsNull() )
250 ClearReferenceObjects( DataTag_Profile );
252 // Indicate model of the need to update the chanel presentation
256 ObjectKind HYDROData_Channel::getAltitudeObjectType() const
258 return KIND_OBSTACLE_ALTITUDE;