return 1;
}
-int HYDROData_ShapeFile::WriteObjectPolygon(SHPHandle theShpHandle, const TopoDS_Shape& theInputShape )
+int HYDROData_ShapeFile::WriteObjectPolygon(SHPHandle theShpHandle, const TopoDS_Shape& theInputShape,
+ bool bUseDiscr, double theDefl)
{
if (theInputShape.IsNull())
return 0;
- TopExp_Explorer anEdgeEx(theInputShape, TopAbs_EDGE);
- for (; anEdgeEx.More(); anEdgeEx.Next())
- {
- TopoDS_Edge E = TopoDS::Edge(anEdgeEx.Current());
- double aFP, aLP;
- Handle_Geom_Curve aCur = BRep_Tool::Curve(E, aFP, aLP);
- Handle(Geom_Line) aLine = Handle(Geom_Line)::DownCast(aCur);
- if (aLine.IsNull())
- {
- Handle(Geom_TrimmedCurve) aTC = Handle(Geom_TrimmedCurve)::DownCast(aCur);
- if (!aTC.IsNull())
- {
- Handle(Geom_Line) aLine = Handle(Geom_Line)::DownCast(aTC->BasisCurve());
- if (aLine.IsNull())
- return -1;
- }
- else
- return -1;
- }
- }
+ if (!bUseDiscr && !CheckLinear(theInputShape))
+ return -1;
+
if (theInputShape.ShapeType() == TopAbs_FACE)
{
- ProcessFace(TopoDS::Face(theInputShape), theShpHandle);
+ ProcessFace(TopoDS::Face(theInputShape), theShpHandle, bUseDiscr, theDefl);
}
else if (theInputShape.ShapeType() == TopAbs_COMPOUND)
{
TopoDS_Face aF = TopoDS::Face(Ex.Current());
if (aF.IsNull())
continue;
- ProcessFace(aF, theShpHandle);
+ ProcessFace(aF, theShpHandle, bUseDiscr, theDefl);
}
}
else
for (Standard_Integer i = 1; i <= nbE; i++)
{
TopoDS_Edge E = aSEWD->Edge(i);
- if (bUseDiscr)
+ if (!bUseDiscr)
{
TopoDS_Vertex aV = TopExp::LastVertex(E, 1);
if (aV.IsNull())
DBFClose( hDBF );
return true;
+}
+
+bool HYDROData_ShapeFile::CheckLinear(const TopoDS_Shape& theInpShape)
+{
+ TopExp_Explorer anEdgeEx(theInpShape, TopAbs_EDGE);
+ for (; anEdgeEx.More(); anEdgeEx.Next())
+ {
+ TopoDS_Edge E = TopoDS::Edge(anEdgeEx.Current());
+ double aFP, aLP;
+ Handle_Geom_Curve aCur = BRep_Tool::Curve(E, aFP, aLP);
+ Handle(Geom_Line) aLine = Handle(Geom_Line)::DownCast(aCur);
+ if (aLine.IsNull())
+ {
+ Handle(Geom_TrimmedCurve) aTC = Handle(Geom_TrimmedCurve)::DownCast(aCur);
+ if (!aTC.IsNull())
+ {
+ Handle(Geom_Line) aLine = Handle(Geom_Line)::DownCast(aTC->BasisCurve());
+ if (aLine.IsNull())
+ return false;
+ }
+ else
+ return false;
+ }
+ }
+ return true;
}
\ No newline at end of file
int WriteObjectPoly3D(SHPHandle theShpHandle, Handle_HYDROData_Polyline3D thePoly );
- int WriteObjectPolygon(SHPHandle theShpHandle, const TopoDS_Shape& theInputShape );
+ int WriteObjectPolygon(SHPHandle theShpHandle, const TopoDS_Shape& theInputShape, bool bUseDiscr = false, double theDefl = 0.1 );
//Import
bool Parse(SHPHandle theHandle, ShapeType theType, int& theShapeTypeOfFile);
//Import Landcover
private:
void ProcessFace(const TopoDS_Face& theFace, SHPHandle theShpHandle,
- bool bUseDiscr = false, double theDefl = 0.1);
+ bool bUseDiscr, double theDefl);
+
+ bool CheckLinear(const TopoDS_Shape& theInpShape);
int TryOpenShapeFile(QString theFileName);