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())
107 BRepTools::Write( aPathWire, "guideline.brep" );
108 BRepTools::Write( aProfileWire, "profile.brep" );
111 HYDROData_Canal3dAnd2d aChannelConstructor( aProfileWire, aPathWire );
112 aChannelConstructor.Create3dPresentation();
113 aChannelConstructor.Create2dPresentation();
114 SetShape3D( aChannelConstructor.Get3dPresentation() );
115 SetTopShape( aChannelConstructor.Get2dPresentation() );
117 BRepTools::Write( aChannelConstructor.Get2dPresentation(), "channel2d.brep" );
118 BRepTools::Write( aChannelConstructor.Get3dPresentation(), "channel3d.brep" );
120 TopAbs_ShapeEnum aType = GetTopShape().ShapeType();
122 // Create groups for channel
123 TopoDS_Wire aLeftBank = aChannelConstructor.GetLeftBank();
124 TopoDS_Wire aRightBank = aChannelConstructor.GetRightBank();
125 TopoDS_Wire anInlet = aChannelConstructor.GetInlet();
126 TopoDS_Wire anOutlet = aChannelConstructor.GetOutlet();
129 HYDROData_ShapesTool::DumpShapeSubShapes( std::cout, "Top shape edges:", GetTopShape(), TopAbs_EDGE );
130 HYDROData_ShapesTool::DumpShapeSubShapes( std::cout, "Left bank edges:", aLeftBank, TopAbs_EDGE );
131 HYDROData_ShapesTool::DumpShapeSubShapes( std::cout, "Right bank edges:", aRightBank, TopAbs_EDGE );
132 HYDROData_ShapesTool::DumpShapeSubShapes( std::cout, "Inlet edges:", anInlet, TopAbs_EDGE );
133 HYDROData_ShapesTool::DumpShapeSubShapes( std::cout, "Outlet edges:", anOutlet, TopAbs_EDGE );
136 TopTools_SequenceOfShape aLeftBankEdges;
137 HYDROData_ShapesTool::ExploreShapeToShapes( aLeftBank, TopAbs_EDGE, aLeftBankEdges );
139 TopTools_SequenceOfShape aRightBankEdges;
140 HYDROData_ShapesTool::ExploreShapeToShapes( aRightBank, TopAbs_EDGE, aRightBankEdges );
142 TopTools_SequenceOfShape anInletEdges;
143 HYDROData_ShapesTool::ExploreShapeToShapes( anInlet, TopAbs_EDGE, anInletEdges );
145 TopTools_SequenceOfShape anOutletEdges;
146 HYDROData_ShapesTool::ExploreShapeToShapes( anOutlet, TopAbs_EDGE, anOutletEdges );
148 QString aLeftGroupName = GetName() + "_Left_Bank";
150 Handle(HYDROData_ShapesGroup) aLeftGroup = createGroupObject();
151 aLeftGroup->SetName( aLeftGroupName );
152 aLeftGroup->SetShapes( aLeftBankEdges );
154 QString aRightGroupName = GetName() + "_Right_Bank";
156 Handle(HYDROData_ShapesGroup) aRightGroup = createGroupObject();
157 aRightGroup->SetName( aRightGroupName );
158 aRightGroup->SetShapes( aRightBankEdges );
160 QString anInGroupName = GetName() + "_Inlet";
162 Handle(HYDROData_ShapesGroup) anInGroup = createGroupObject();
163 anInGroup->SetName( anInGroupName );
164 anInGroup->SetShapes( anInletEdges );
166 QString anOutGroupName = GetName() + "_Outlet";
168 Handle(HYDROData_ShapesGroup) anOutGroup = createGroupObject();
169 anOutGroup->SetName( anOutGroupName );
170 anOutGroup->SetShapes( anOutletEdges );
173 QColor HYDROData_Channel::DefaultFillingColor()
175 return QColor( Qt::blue );
178 QColor HYDROData_Channel::DefaultBorderColor()
180 return QColor( Qt::transparent );
183 QColor HYDROData_Channel::getDefaultFillingColor() const
185 return DefaultFillingColor();
188 QColor HYDROData_Channel::getDefaultBorderColor() const
190 return DefaultBorderColor();
193 bool HYDROData_Channel::SetGuideLine( const Handle(HYDROData_Polyline3D)& theGuideLine )
195 Handle(HYDROData_Polyline3D) aPrevGuideLine = GetGuideLine();
197 if ( theGuideLine.IsNull() )
200 return !aPrevGuideLine.IsNull();
203 if ( IsEqual( aPrevGuideLine, theGuideLine ) )
206 TopoDS_Wire aHydraulicWire = TopoDS::Wire( theGuideLine->GetTopShape() );
207 if ( aHydraulicWire.IsNull() )
208 return false; // The polyline must be a single wire
210 SetReferenceObject( theGuideLine, DataTag_GuideLine );
212 // Indicate model of the need to update the chanel presentation
218 Handle(HYDROData_Polyline3D) HYDROData_Channel::GetGuideLine() const
220 return Handle(HYDROData_Polyline3D)::DownCast(
221 GetReferenceObject( DataTag_GuideLine ) );
224 void HYDROData_Channel::RemoveGuideLine()
226 Handle(HYDROData_Polyline3D) aPrevGuideLine = GetGuideLine();
227 if ( aPrevGuideLine.IsNull() )
230 ClearReferenceObjects( DataTag_GuideLine );
232 // Indicate model of the need to update the chanel presentation
236 bool HYDROData_Channel::SetProfile( const Handle(HYDROData_Profile)& theProfile )
238 Handle(HYDROData_Profile) aPrevProfile = GetProfile();
240 if ( theProfile.IsNull() )
243 return !aPrevProfile.IsNull();
246 if ( IsEqual( aPrevProfile, theProfile ) )
249 SetReferenceObject( theProfile, DataTag_Profile );
251 // Indicate model of the need to update the chanel presentation
257 Handle(HYDROData_Profile) HYDROData_Channel::GetProfile() const
259 return Handle(HYDROData_Profile)::DownCast(
260 GetReferenceObject( DataTag_Profile ) );
263 void HYDROData_Channel::RemoveProfile()
265 Handle(HYDROData_Profile) aPrevProfile = GetProfile();
266 if ( aPrevProfile.IsNull() )
269 ClearReferenceObjects( DataTag_Profile );
271 // Indicate model of the need to update the chanel presentation
275 ObjectKind HYDROData_Channel::getAltitudeObjectType() const
277 return KIND_OBSTACLE_ALTITUDE;