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>
20 #include <TopoDS_Wire.hxx>
21 #include <TopoDS_Vertex.hxx>
22 #include <TopoDS_Face.hxx>
24 //#define DEB_CHANNEL 1
26 #include <BRepTools.hxx>
30 #include <QStringList>
32 IMPLEMENT_STANDARD_HANDLE(HYDROData_Channel,HYDROData_ArtificialObject)
33 IMPLEMENT_STANDARD_RTTIEXT(HYDROData_Channel,HYDROData_ArtificialObject)
36 HYDROData_Channel::HYDROData_Channel()
37 : HYDROData_ArtificialObject()
41 HYDROData_Channel::~HYDROData_Channel()
45 QStringList HYDROData_Channel::DumpToPython( MapOfTreatedObjects& theTreatedObjects ) const
47 QStringList aResList = dumpObjectCreation( theTreatedObjects );
48 QString aName = GetObjPyName();
50 Handle(HYDROData_Polyline3D) aRefGideLine = GetGuideLine();
51 setPythonReferenceObject( theTreatedObjects, aResList, aRefGideLine, "SetGuideLine" );
53 Handle(HYDROData_Profile) aRefProfile = GetProfile();
54 setPythonReferenceObject( theTreatedObjects, aResList, aRefProfile, "SetProfile" );
56 aResList << QString( "" );
57 aResList << QString( "%1.Update();" ).arg( aName );
58 aResList << QString( "" );
63 HYDROData_SequenceOfObjects HYDROData_Channel::GetAllReferenceObjects() const
65 HYDROData_SequenceOfObjects aResSeq = HYDROData_ArtificialObject::GetAllReferenceObjects();
67 Handle(HYDROData_Polyline3D) aGuideLine = GetGuideLine();
68 if ( !aGuideLine.IsNull() )
69 aResSeq.Append( aGuideLine );
71 Handle(HYDROData_Profile) aProfile = GetProfile();
72 if ( !aProfile.IsNull() )
73 aResSeq.Append( aProfile );
78 TopoDS_Shape HYDROData_Channel::GetTopShape() const
83 TopoDS_Shape HYDROData_Channel::GetShape3D() const
88 void HYDROData_Channel::Update()
90 HYDROData_ArtificialObject::Update();
92 Handle(HYDROData_Polyline3D) aGuideLine = GetGuideLine();
93 Handle(HYDROData_Profile) aProfile = GetProfile();
94 if ( aGuideLine.IsNull() || aProfile.IsNull() )
98 TopoDS_Wire aPathWire = TopoDS::Wire(aGuideLine->GetShape3D());
99 if(aPathWire.IsNull())
101 TopoDS_Wire aProfileWire = TopoDS::Wire( aProfile->GetShape3D() );
102 if(aProfileWire.IsNull())
106 BRepTools::Write( aPathWire, "guideline.brep" );
107 BRepTools::Write( aProfileWire, "profile.brep" );
110 HYDROData_Canal3dAnd2d aChannelConstructor( aProfileWire, aPathWire );
111 if( aChannelConstructor.GetStatus() != 0 )
114 aChannelConstructor.Create3dPresentation();
115 aChannelConstructor.Create2dPresentation();
116 SetShape3D( aChannelConstructor.Get3dPresentation() );
117 SetTopShape( aChannelConstructor.Get2dPresentation() );
120 BRepTools::Write( aChannelConstructor.Get2dPresentation(), "channel2d.brep" );
121 BRepTools::Write( aChannelConstructor.Get3dPresentation(), "channel3d.brep" );
124 TopAbs_ShapeEnum aType = GetTopShape().ShapeType();
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();
133 HYDROData_ShapesTool::DumpShapeSubShapes( std::cout, "Top shape edges:", GetTopShape(), TopAbs_EDGE );
134 HYDROData_ShapesTool::DumpShapeSubShapes( std::cout, "Left bank edges:", aLeftBank, TopAbs_EDGE );
135 HYDROData_ShapesTool::DumpShapeSubShapes( std::cout, "Right bank edges:", aRightBank, TopAbs_EDGE );
136 HYDROData_ShapesTool::DumpShapeSubShapes( std::cout, "Inlet edges:", anInlet, TopAbs_EDGE );
137 HYDROData_ShapesTool::DumpShapeSubShapes( std::cout, "Outlet edges:", anOutlet, TopAbs_EDGE );
140 TopTools_SequenceOfShape aLeftBankEdges;
141 HYDROData_ShapesTool::ExploreShapeToShapes( aLeftBank, TopAbs_EDGE, aLeftBankEdges );
143 TopTools_SequenceOfShape aRightBankEdges;
144 HYDROData_ShapesTool::ExploreShapeToShapes( aRightBank, TopAbs_EDGE, aRightBankEdges );
146 TopTools_SequenceOfShape anInletEdges;
147 HYDROData_ShapesTool::ExploreShapeToShapes( anInlet, TopAbs_EDGE, anInletEdges );
149 TopTools_SequenceOfShape anOutletEdges;
150 HYDROData_ShapesTool::ExploreShapeToShapes( anOutlet, TopAbs_EDGE, anOutletEdges );
152 QString aLeftGroupName = GetName() + "_Left_Bank";
154 Handle(HYDROData_ShapesGroup) aLeftGroup = createGroupObject();
155 aLeftGroup->SetName( aLeftGroupName );
156 aLeftGroup->SetShapes( aLeftBankEdges );
158 QString aRightGroupName = GetName() + "_Right_Bank";
160 Handle(HYDROData_ShapesGroup) aRightGroup = createGroupObject();
161 aRightGroup->SetName( aRightGroupName );
162 aRightGroup->SetShapes( aRightBankEdges );
164 QString anInGroupName = GetName() + "_Inlet";
166 Handle(HYDROData_ShapesGroup) anInGroup = createGroupObject();
167 anInGroup->SetName( anInGroupName );
168 anInGroup->SetShapes( anInletEdges );
170 QString anOutGroupName = GetName() + "_Outlet";
172 Handle(HYDROData_ShapesGroup) anOutGroup = createGroupObject();
173 anOutGroup->SetName( anOutGroupName );
174 anOutGroup->SetShapes( anOutletEdges );
177 bool HYDROData_Channel::IsHas2dPrs() const
182 QColor HYDROData_Channel::DefaultFillingColor()
184 return QColor( Qt::blue );
187 QColor HYDROData_Channel::DefaultBorderColor()
189 return QColor( Qt::transparent );
192 QColor HYDROData_Channel::getDefaultFillingColor() const
194 return DefaultFillingColor();
197 QColor HYDROData_Channel::getDefaultBorderColor() const
199 return DefaultBorderColor();
202 bool HYDROData_Channel::SetGuideLine( const Handle(HYDROData_Polyline3D)& theGuideLine )
204 Handle(HYDROData_Polyline3D) aPrevGuideLine = GetGuideLine();
206 if ( theGuideLine.IsNull() )
209 return !aPrevGuideLine.IsNull();
212 if ( IsEqual( aPrevGuideLine, theGuideLine ) )
215 TopoDS_Wire aHydraulicWire = TopoDS::Wire( theGuideLine->GetTopShape() );
216 if ( aHydraulicWire.IsNull() )
217 return false; // The polyline must be a single wire
219 SetReferenceObject( theGuideLine, DataTag_GuideLine );
221 // Indicate model of the need to update the chanel presentation
227 Handle(HYDROData_Polyline3D) HYDROData_Channel::GetGuideLine() const
229 return Handle(HYDROData_Polyline3D)::DownCast(
230 GetReferenceObject( DataTag_GuideLine ) );
233 void HYDROData_Channel::RemoveGuideLine()
235 Handle(HYDROData_Polyline3D) aPrevGuideLine = GetGuideLine();
236 if ( aPrevGuideLine.IsNull() )
239 ClearReferenceObjects( DataTag_GuideLine );
241 // Indicate model of the need to update the chanel presentation
245 bool HYDROData_Channel::SetProfile( const Handle(HYDROData_Profile)& theProfile )
247 Handle(HYDROData_Profile) aPrevProfile = GetProfile();
249 if ( theProfile.IsNull() )
252 return !aPrevProfile.IsNull();
255 if ( IsEqual( aPrevProfile, theProfile ) )
258 SetReferenceObject( theProfile, DataTag_Profile );
260 // Indicate model of the need to update the chanel presentation
266 Handle(HYDROData_Profile) HYDROData_Channel::GetProfile() const
268 return Handle(HYDROData_Profile)::DownCast(
269 GetReferenceObject( DataTag_Profile ) );
272 void HYDROData_Channel::RemoveProfile()
274 Handle(HYDROData_Profile) aPrevProfile = GetProfile();
275 if ( aPrevProfile.IsNull() )
278 ClearReferenceObjects( DataTag_Profile );
280 // Indicate model of the need to update the chanel presentation
284 ObjectKind HYDROData_Channel::getAltitudeObjectType() const
286 return KIND_OBSTACLE_ALTITUDE;