#include <BRepBuilderAPI_MakePolygon.hxx>
#include <BRepBuilderAPI_MakeFace.hxx>
#include <BRepOffsetAPI_NormalProjection.hxx>
+#include <BRepAdaptor_Curve.hxx>
#ifndef LIGHT_MODE
#include <GEOMBase.h>
#include <Geom_BSplineCurve.hxx>
#include <GCPnts_AbscissaPoint.hxx>
+#include <GCPnts_QuasiUniformDeflection.hxx>
#include <ImageComposer_MetaTypes.h>
#include <TColStd_ListIteratorOfListOfReal.hxx>
#include <TColStd_Array1OfReal.hxx>
+#include <TColgp_Array1OfPnt.hxx>
#include <TDataStd_AsciiString.hxx>
#include <TDataStd_BooleanList.hxx>
IMPLEMENT_STANDARD_RTTIEXT(HYDROData_PolylineXY, HYDROData_IPolyline)
HYDROData_PolylineXY::HYDROData_PolylineXY()
-: HYDROData_IPolyline()
+: HYDROData_IPolyline(),
+ myIsInCustomFlag( false )
{
}
{
}
-QStringList HYDROData_PolylineXY::DumpToPython( MapOfTreatedObjects& theTreatedObjects ) const
+QStringList HYDROData_PolylineXY::DumpToPython( const QString& thePyScriptPath,
+ MapOfTreatedObjects& theTreatedObjects ) const
{
QStringList aResList = dumpObjectCreation( theTreatedObjects );
QString aPolylineName = GetObjPyName();
NCollection_Sequence<HYDROData_PolylineXY::SectionType>& theSectTypes,
NCollection_Sequence<bool>& theSectClosures,
NCollection_Sequence<HYDROData_PolylineXY::PointsList>& theSectPoints,
- const bool theIsCanBeClosed )
+ bool IsCanBeClosed,
+ bool IsInterpolationAllowed,
+ double theDeflection )
{
Standard_Real aFirst = 0.0, aLast = 0.0;
Handle(Geom_Curve) anEdgeGeomCurve = BRep_Tool::Curve( theEdge, aFirst, aLast );
HYDROData_PolylineXY::SectionType aSectionType = HYDROData_PolylineXY::SECTION_POLYLINE;
HYDROData_PolylineXY::PointsList aPointsList;
- if ( anEdgeGeomCurve->IsKind( STANDARD_TYPE(Geom_Line) ) )
+ if( anEdgeGeomCurve->IsKind( STANDARD_TYPE(Geom_Line) ) )
{
Handle(Geom_Line) aGeomLine = Handle(Geom_Line)::DownCast( anEdgeGeomCurve );
HYDROData_PolylineXY::Point aSectLastPoint( aLastPoint.X(), aLastPoint.Y() );
aPointsList.Append( aSectLastPoint );
}
- else if ( anEdgeGeomCurve->IsKind( STANDARD_TYPE(Geom_BSplineCurve) ) )
+ else if ( anEdgeGeomCurve->IsKind( STANDARD_TYPE(Geom_BSplineCurve) ) || IsInterpolationAllowed )
{
aSectionType = HYDROData_PolylineXY::SECTION_SPLINE;
- Handle(Geom_BSplineCurve) aGeomSpline =
- Handle(Geom_BSplineCurve)::DownCast( anEdgeGeomCurve );
+ BRepAdaptor_Curve anAdaptorCurve( theEdge );
+ GCPnts_QuasiUniformDeflection aDiscrete( anAdaptorCurve, theDeflection );
- int aNbKnots = aGeomSpline->NbKnots();
+ int aNbPoints = aDiscrete.NbPoints();
- TColStd_Array1OfReal aSplineKnots( 1, aNbKnots );
- aGeomSpline->Knots( aSplineKnots );
+ // Decrease the number of imported poles because of last one
+ // pole is the closing point which are the start point
+ if ( anIsEdgeClosed ) aNbPoints--;
- // Decrease the number of imported knots because of last one
- // knot is the closing point which are the start point
- if ( anIsEdgeClosed ) aNbKnots--;
-
- for ( int i = 1; i <= aNbKnots; ++i )
+ for ( int i = 1; i <= aNbPoints; ++i )
{
- const Standard_Real& aKnot = aSplineKnots.Value( i );
-
- gp_Pnt aPoint;
- aGeomSpline->D0( aKnot, aPoint );
+ const gp_Pnt& aPoint = aDiscrete.Value( i );
HYDROData_PolylineXY::Point aSectPoint( aPoint.X(), aPoint.Y() );
aPointsList.Append( aSectPoint );
return true;
}
-bool HYDROData_PolylineXY::ImportShape( const TopoDS_Shape& theShape )
+bool HYDROData_PolylineXY::ImportShape( const TopoDS_Shape& theShape,
+ bool IsInterpolationAllowed,
+ double theDeviation )
{
if ( theShape.IsNull() )
return false;
if ( theShape.ShapeType() == TopAbs_EDGE )
{
TopoDS_Edge anEdge = TopoDS::Edge( theShape );
- anIsCanBeImported = convertEdgeToSection( anEdge, aSectNames, aSectTypes, aSectClosures, aSectPoints, true );
+ anIsCanBeImported = convertEdgeToSection( anEdge, aSectNames, aSectTypes,
+ aSectClosures, aSectPoints, true, IsInterpolationAllowed, theDeviation );
}
else if ( theShape.ShapeType() == TopAbs_WIRE )
{
for ( int i = 1, n = anEdges.Length(); i <= n && anIsCanBeImported; ++i )
{
TopoDS_Edge aWireEdge = TopoDS::Edge( anEdges.Value( i ) );
- anIsCanBeImported = convertEdgeToSection( aWireEdge, aSectNames, aSectTypes, aSectClosures, aSectPoints, false );
+ anIsCanBeImported = convertEdgeToSection( aWireEdge, aSectNames, aSectTypes,
+ aSectClosures, aSectPoints, false, IsInterpolationAllowed, theDeviation );
}
}
aBB.MakeCompound(aCmp);
if(aSeqEdges->Length() >1)
{
- ShapeAnalysis_FreeBounds::ConnectEdgesToWires(aSeqEdges,1E-5,Standard_False,aSeqWires);
+ ShapeAnalysis_FreeBounds::ConnectEdgesToWires( aSeqEdges, 1E-5, Standard_True, aSeqWires );
if( aSeqWires->Length()==1 )
aResult = aSeqWires->Value( 1 );
theSectTypes.Clear();
theSectClosures.Clear();
+ if( IsCustom() )
+ {
+ const_cast<HYDROData_PolylineXY*>( this )->Interpolate();
+ }
+
Handle(TDataStd_ExtStringList) aNamesList;
Handle(TDataStd_IntegerList) aTypesList;
Handle(TDataStd_BooleanList) aClosuresList;
if( IsCustom() )
{
- //TODO: make interpolation to fill the list
+ const_cast<HYDROData_PolylineXY*>( this )->Interpolate();
}
Handle(TDataStd_RealList) aListX, aListY;
bool HYDROData_PolylineXY::IsCustom() const
{
+ if( myIsInCustomFlag )
+ return false;
+
bool isNull = GetShape().IsNull();
int aNbPoints = 0;
- //TODO: to check if there is no points
- //for( int i=0, n=NbSections(); i<n; i++ )
- // aNbPoints += NbPoints( i );
+ HYDROData_PolylineXY* aThat = const_cast<HYDROData_PolylineXY*>( this );
+ aThat->myIsInCustomFlag = true;
+ for( int i=0, n=NbSections(); i<n; i++ )
+ aNbPoints += NbPoints( i );
+ aThat->myIsInCustomFlag = false;
return !isNull && aNbPoints == 0;
}
+
+void HYDROData_PolylineXY::Interpolate()
+{
+ ImportShape( GetShape(), true );
+}