#include "HYDROData_PolylineXY.h"
+#include <BRep_Builder.hxx>
#include <BRepBuilderAPI_MakeFace.hxx>
+#include <BRepBuilderAPI_MakeWire.hxx>
#include <TDataStd_AsciiString.hxx>
#include <TNaming_Builder.hxx>
#include <TNaming_NamedShape.hxx>
{
TopoDS_Shape aResShape;
+ BRepBuilderAPI_MakeWire aMakeWire;
+
+ TopTools_ListOfShape aClosedWires;
+
+ HYDROData_SequenceOfObjects aRefPolylines = GetPolylines();
+ for ( int i = 1, n = aRefPolylines.Length(); i <= n; ++i ) {
+ Handle(HYDROData_PolylineXY) aPolyline =
+ Handle(HYDROData_PolylineXY)::DownCast( aRefPolylines.Value( i ) );
+
+ if ( aPolyline.IsNull() ) {
+ continue;
+ }
+
+ TopoDS_Shape aPolyShape = aPolyline->GetShape();
+ if ( aPolyShape.IsNull() || aPolyShape.ShapeType() != TopAbs_WIRE ) {
+ continue;
+ }
+
+ const TopoDS_Wire& aPolylineWire = TopoDS::Wire( aPolyShape );
+ if ( aPolylineWire.IsNull() ) {
+ continue;
+ }
+
+ if ( aPolylineWire.Closed() ) {
+ aClosedWires.Append( aPolylineWire );
+ } else {
+ aMakeWire.Add( aPolylineWire );
+ aMakeWire.Build();
+ if ( aMakeWire.IsDone() ) {
+ if ( aMakeWire.Wire().Closed() ) {
+ aClosedWires.Append( aMakeWire.Wire() );
+ aMakeWire = BRepBuilderAPI_MakeWire();
+ }
+ }
+ }
+ }
+
+ if ( aClosedWires.Extent() == 1 ) {
+ // make face
+ BRepBuilderAPI_MakeFace aMakeFace( TopoDS::Wire( aClosedWires.First() ) );
+ aMakeFace.Build();
+ if( aMakeFace.IsDone() ) {
+ aResShape = aMakeFace.Face();
+ }
+ } else if ( aClosedWires.Extent() > 1 ) {
+ // make compound
+ BRep_Builder aBuilder;
+ TopoDS_Compound aCompound;
+ aBuilder.MakeCompound( aCompound );
+
+ TopTools_ListIteratorOfListOfShape aWiresIter( aClosedWires );
+ for ( ; aWiresIter.More(); aWiresIter.Next() ) {
+ BRepBuilderAPI_MakeFace aMakeFace( TopoDS::Wire( aWiresIter.Value() ) );
+ aMakeFace.Build();
+ if( aMakeFace.IsDone() ) {
+ aBuilder.Add( aCompound, aMakeFace.Face() );
+ }
+ }
+
+ aResShape = aCompound;
+ }
+
///< \TODO to be reimplemented
+ /*
TopoDS_Shape anArgShape;
TopTools_ListOfShape aToolShapes;
aResShape = aBOP.Shape();
}
}
+ */
return aResShape;
}
\ No newline at end of file