#include <NCollection_List.hxx>
#include <GC_MakeSegment.hxx>
#include <BRep_Builder.hxx>
+#include <BRepAdaptor_Curve.hxx>
+#include <GCPnts_QuasiUniformDeflection.hxx>
#ifdef WIN32
#pragma warning( disable: 4996 )
}
-void HYDROData_ShapeFile::ProcessFace(TopoDS_Face theFace, SHPHandle theShpHandle)
+void HYDROData_ShapeFile::ProcessFace(const TopoDS_Face& theFace, SHPHandle theShpHandle,
+ bool bUseDiscr, double theDefl )
{
if (theFace.ShapeType() != TopAbs_FACE)
return;
aWires.Append(aW);
}
- //TopExp_Explorer Ex(theFace, TopAbs_WIRE);
int NbWires = 0;
for (int k = 1; k <= aWires.Length(); k++)
{
for (Standard_Integer i = 1; i <= nbE; i++)
{
TopoDS_Edge E = aSEWD->Edge(i);
- TopoDS_Vertex aV = TopExp::LastVertex(E, 1);
- if (aV.IsNull())
- continue;
- gp_Pnt P = BRep_Tool::Pnt(aV);
- aPnts.Append(gp_Pnt2d(P.X(), P.Y()));
+ if (bUseDiscr)
+ {
+ TopoDS_Vertex aV = TopExp::LastVertex(E, 1);
+ if (aV.IsNull())
+ continue;
+ gp_Pnt P = BRep_Tool::Pnt(aV);
+ aPnts.Append(gp_Pnt2d(P.X(), P.Y()));
+ }
+ else
+ {
+ BRepAdaptor_Curve Cur( E );
+ GCPnts_QuasiUniformDeflection Discr( Cur, theDefl );
+ if( !Discr.IsDone() )
+ continue; //skip all edge?
+ for( int i = 1; i <= Discr.NbPoints(); i++ )
+ {
+ gp_Pnt P = Discr.Value( i );
+ aPnts.Append(gp_Pnt2d(P.X(), P.Y()));
+ }
+ }
}
NCollection_Sequence<gp_Pnt2d> aNPnts;
aNPnts.Append(aPnts.First());
aNPnts.Append(aPnts(j + 1));
}
- //assume that the orientation of extrenal wire & internal wires is correct
+ //assume that the orientation of external wire & internal wires is correct
//so just write all points "as-is"
//External wire will be written in clockwise direction
//any other wires (holes) - in anticlockwise direction
x.push_back( aNPnts(j).X());
y.push_back( aNPnts(j).Y());
}
+ //first point is same as the last one => closed polygon
x.push_back( aNPnts(1).X());
y.push_back( aNPnts(1).Y());
+
}
aSHPObj = SHPCreateObject( SHPT_POLYGON, -1, NbWires, &anPartStart[0], NULL, x.size(), &x[0], &y[0], NULL, NULL );
BRepBuilderAPI_MakeFace aDB(pln, W);
TopoDS_Face aDummyFace = TopoDS::Face(aDB.Shape());
BRepTopAdaptor_FClass2d FClass(aDummyFace, Precision::PConfusion());
- if ( i == 0 && FClass.PerformInfinitePoint() == TopAbs_OUT)
+ if ( i == 0 && FClass.PerformInfinitePoint() != TopAbs_OUT)
W.Reverse();
if ( i > 0 && FClass.PerformInfinitePoint() != TopAbs_IN)
W.Reverse();