//
#include <HYDROData_PolylineOperator.h>
+#include <HYDROData_Document.h>
#include <BRepBuilderAPI_MakeEdge2d.hxx>
+#include <BRepBuilderAPI_MakeWire.hxx>
#include <TopoDS_Edge.hxx>
+#include <TopoDS_Wire.hxx>
template<class T> void append( std::vector<T>& theList, const std::vector<T>& theList2 )
{
}
-bool HYDROData_PolylineOperator::Split( const Handle( HYDROData_PolylineXY )& thePolyline,
+bool HYDROData_PolylineOperator::Split( const Handle( HYDROData_Document )& theDoc,
+ const TCollection_AsciiString& theNamePrefix,
+ const Handle( HYDROData_PolylineXY )& thePolyline,
const gp_Pnt2d& thePoint ) const
{
std::vector<gp_Pnt2d> aPointsList( 1 );
for( int i=0, n=aCurves.size(); i<n; i++ )
{
std::vector<Handle( Geom2d_Curve )> aCurvesList = Split( aCurves[i], aPointsList );
- bool isLocalOK = CreatePolylines( aCurvesList );
+ bool isLocalOK = CreatePolylines( theDoc, theNamePrefix, aCurvesList );
isOK = isOK && isLocalOK;
}
return isOK;
}
-bool HYDROData_PolylineOperator::Split( const Handle( HYDROData_PolylineXY )& thePolyline,
+bool HYDROData_PolylineOperator::Split( const Handle( HYDROData_Document )& theDoc,
+ const TCollection_AsciiString& theNamePrefix,
+ const Handle( HYDROData_PolylineXY )& thePolyline,
const Handle( HYDROData_PolylineXY )& theTool ) const
{
std::vector<Handle( Geom2d_Curve )> aCurves = GetCurves( thePolyline );
{
std::vector<gp_Pnt2d> aPointsList = Intersection( aCurves[i], aToolCurves[j] );
std::vector<Handle( Geom2d_Curve )> aCurvesList = Split( aCurves[i], aPointsList );
- bool isLocalOK = CreatePolylines( aCurvesList );
+ bool isLocalOK = CreatePolylines( theDoc, theNamePrefix, aCurvesList );
isOK = isOK && isLocalOK;
}
return isOK;
}
-bool HYDROData_PolylineOperator::Split( const HYDROData_SequenceOfObjects& thePolylines )
+bool HYDROData_PolylineOperator::Split( const Handle( HYDROData_Document )& theDoc,
+ const TCollection_AsciiString& theNamePrefix,
+ const HYDROData_SequenceOfObjects& thePolylines )
{
int f = thePolylines.Lower(), l = thePolylines.Upper();
bool isOK = true;
append( aCompletePointsList, aPointsList );
}
std::vector<Handle( Geom2d_Curve )> aCurvesList = Split( anAllCurves[i], aCompletePointsList );
- bool isLocalOK = CreatePolylines( aCurvesList );
+ bool isLocalOK = CreatePolylines( theDoc, theNamePrefix, aCurvesList );
isOK = isOK && isLocalOK;
}
return isOK;
}
-bool HYDROData_PolylineOperator::Merge( const HYDROData_SequenceOfObjects& thePolylines )
+bool HYDROData_PolylineOperator::Merge( const Handle( HYDROData_Document )& theDoc,
+ const TCollection_AsciiString& theName,
+ const HYDROData_SequenceOfObjects& thePolylines )
{
//TODO
return true;
return aResult;
}
-bool HYDROData_PolylineOperator::CreatePolylines( const std::vector<Handle( Geom2d_Curve )>& theCurves )
+bool HYDROData_PolylineOperator::CreatePolylines( const Handle( HYDROData_Document )& theDoc,
+ const TCollection_AsciiString& theNamePrefix,
+ const std::vector<Handle( Geom2d_Curve )>& theCurves )
{
+ if( theDoc.IsNull() )
+ return false;
+
int n = theCurves.size();
for( int i=0; i<n; i++ )
{
TopoDS_Edge anEdge = BRepBuilderAPI_MakeEdge2d( theCurves[i] ).Edge();
- //TODO
+ BRepBuilderAPI_MakeWire aMakeWire;
+ aMakeWire.Add( anEdge );
+
+ Handle( HYDROData_PolylineXY ) aPolyline =
+ Handle( HYDROData_PolylineXY )::DownCast( theDoc->CreateObject( KIND_POLYLINEXY ) );
+ if( aPolyline.IsNull() )
+ return false;
+
+ aPolyline->SetShape( aMakeWire.Wire() );
+ //TODO: set name
}
return true;
}