/**
* Returns true if polyline is closed
*/
-bool HYDROData_PolylineXY::IsClosed( const bool theIsSimpleCheck ) const
+bool HYDROData_PolylineXY::IsClosed(const bool theIsSimpleCheck) const
{
+ //DEBTRACE("IsClosed " << theIsSimpleCheck << " " << GetName());
bool anIsClosed = false;
TopoDS_Shape aShape = GetShape();
- if ( aShape.IsNull() )
+ if (aShape.IsNull())
return anIsClosed;
TopTools_SequenceOfShape aWires;
- HYDROData_ShapesTool::ExploreShapeToShapes( aShape, TopAbs_WIRE, aWires );
+ HYDROData_ShapesTool::ExploreShapeToShapes(aShape, TopAbs_WIRE, aWires);
int aNbWires = aWires.Length();
- if ( theIsSimpleCheck )
- {
- anIsClosed = aNbWires > 0;
- for ( int i = 1; i <= aNbWires && anIsClosed; ++i )
+ if (theIsSimpleCheck)
{
- const TopoDS_Shape& aWire = aWires.Value( i );
- anIsClosed = BRep_Tool::IsClosed( aWire );
+ anIsClosed = aNbWires > 0;
+ for (int i = 1; i <= aNbWires && anIsClosed; ++i)
+ {
+ const TopoDS_Shape& aWire = aWires.Value(i);
+ anIsClosed = BRep_Tool::IsClosed(aWire);
+ }
}
- }
else
- {
- anIsClosed = aNbWires == 1 && BRep_Tool::IsClosed( aWires.First() );
- }
+ {
+ if (aNbWires == 1)
+ anIsClosed = BRep_Tool::IsClosed(aWires.First());
+ else
+ {
+ //DEBTRACE("aNbWires " << aNbWires);
+ Handle(TopTools_HSequenceOfShape) aSeqWires = new TopTools_HSequenceOfShape;
+ Handle(TopTools_HSequenceOfShape) aSeqEdges = new TopTools_HSequenceOfShape;
+ for (int i = 1; i <= aNbWires; ++i)
+ {
+ const TopoDS_Shape& aWire = aWires.Value(i);
+ TopExp_Explorer it2(aWire, TopAbs_EDGE);
+ for (; it2.More(); it2.Next())
+ aSeqEdges->Append(it2.Current());
+ }
+ if (aSeqEdges->Length() > 1)
+ {
+ //DEBTRACE(aSeqEdges->Length());
+ ShapeAnalysis_FreeBounds::ConnectEdgesToWires(aSeqEdges, 1E-5, Standard_False, aSeqWires);
+ if (aSeqWires->Length() == 1)
+ {
+ //DEBTRACE(aSeqWires->Length());
+ const TopoDS_Wire& aPolylineWire = TopoDS::Wire(aSeqWires->Value(1));
+ anIsClosed = BRep_Tool::IsClosed(aPolylineWire);
+ }
+ }
+ }
+ }
return anIsClosed;
}
+int HYDROData_PolylineXY::GetNbConnectedWires(Handle(TopTools_HSequenceOfShape)& aConnectedWires) const
+{
+ TopoDS_Shape aShape = GetShape();
+ if (aShape.IsNull())
+ return 0;
+ int aNbconnectedWires = 0;
+ TopTools_SequenceOfShape aWires;
+ HYDROData_ShapesTool::ExploreShapeToShapes(aShape, TopAbs_WIRE, aWires);
+ int aNbWires = aWires.Length();
+ if (aNbWires == 1)
+ {
+ aNbconnectedWires = aNbWires;
+ aConnectedWires->Append(aWires.First());
+ }
+ else
+ {
+ //DEBTRACE("aNbWires " << aNbWires);
+ Handle(TopTools_HSequenceOfShape) aSeqWires = new TopTools_HSequenceOfShape;
+ Handle(TopTools_HSequenceOfShape) aSeqEdges = new TopTools_HSequenceOfShape;
+ for (int i = 1; i <= aNbWires; ++i)
+ {
+ const TopoDS_Shape& aWire = aWires.Value(i);
+ TopExp_Explorer it2(aWire, TopAbs_EDGE);
+ for (; it2.More(); it2.Next())
+ aSeqEdges->Append(it2.Current());
+ }
+ if (aSeqEdges->Length() > 1)
+ {
+ //DEBTRACE(aSeqEdges->Length());
+ ShapeAnalysis_FreeBounds::ConnectEdgesToWires(aSeqEdges, 1E-5, Standard_False, aSeqWires);
+ }
+ aConnectedWires = aSeqWires;
+ aNbconnectedWires = aConnectedWires->Length();
+ DEBTRACE("aNbconnectedWires " << aNbconnectedWires);
+ }
+return aNbconnectedWires;
+}
+
double HYDROData_PolylineXY::GetDistance( const int theSectionIndex,
const int thePointIndex ) const
{
Standard_Boolean hasLimits(Standard_False);
QString aBndName;
HYDROData_MapOfShape aBndView;
- if (! thePolyline.IsNull()) {
- const TopoDS_Wire aBndWire = TopoDS::Wire(thePolyline->GetShape());
+ if (! thePolyline.IsNull()) {
+ Handle(TopTools_HSequenceOfShape) aConnectedWires = new TopTools_HSequenceOfShape;
+ int nbWires = thePolyline->GetNbConnectedWires(aConnectedWires);
+ const TopoDS_Wire aBndWire = TopoDS::Wire(aConnectedWires->Value(1));
if(!aBndWire.IsNull()) {
TopoDS_Face limFace;
if(buildLimFace(aBndWire, limFace)) {
Handle(HYDROData_PolylineXY) aPolyline;
return Split( theObjectList, aGeomGroups, aPolyline );
-}
\ No newline at end of file
+}
{
aPolylineObj = Handle(HYDROData_PolylineXY)::DownCast( anIter.Current() );
- if ( !aPolylineObj.IsNull() && aPolylineObj->IsClosed() )
+ if ( !aPolylineObj.IsNull() && aPolylineObj->IsClosed(false) )
{
- // Check the polyline shape
- TopoDS_Shape aPolylineShape = aPolylineObj->GetShape();
- if ( !aPolylineShape.IsNull() && aPolylineShape.ShapeType() == TopAbs_WIRE ) {
+// // Check the polyline shape
+// TopoDS_Shape aPolylineShape = aPolylineObj->GetShape();
+// if ( !aPolylineShape.IsNull() && aPolylineShape.ShapeType() == TopAbs_WIRE ) {
aPolylineName = aPolylineObj->GetName();
if ( !aPolylineName.isEmpty() )
{
aList.append( aPolylineName );
anEntryList.append( HYDROGUI_DataObject::dataObjectEntry( aPolylineObj ) );
}
- }
+// }
}
}
aPanel->setPolylineNames( aList, anEntryList );