TopoDS_Shape HYDROData_ImmersibleZone::generateTopShape() const
{
- TopoDS_Shape aResShape = TopoDS_Face();
+ return generateTopShape( GetPolyline() );
+}
+
+TopoDS_Shape HYDROData_ImmersibleZone::generateTopShape( const Handle(HYDROData_PolylineXY)& aPolyline )
+{
+ TopoDS_Face aResultFace = TopoDS_Face();
- Handle(HYDROData_PolylineXY) aPolyline = GetPolyline();
if( !aPolyline.IsNull() )
{
TopoDS_Shape aPolylineShape = aPolyline->GetShape();
}
}
if(aWiresList.IsEmpty())
- return aResShape;
+ return aResultFace;
+
BRepAlgo_FaceRestrictor aFR;
TopoDS_Face aRefFace;
TopoDS_Shape aS = aWiresList.First();
aRefFace = aMakeFace.Face();
}
if(aRefFace.IsNull())
- return aResShape;
+ return aResultFace;
+
aFR.Init(aRefFace,Standard_False, Standard_True);
TopTools_ListIteratorOfListOfShape anIt( aWiresList );
for ( ; anIt.More(); anIt.Next() ) {
}
aFR.Perform();
if (aFR.IsDone()) {
- TopoDS_Compound aResult;
- BRep_Builder aBB;
- aBB.MakeCompound(aResult);
for (; aFR.More(); aFR.Next()) {
- const TopoDS_Face& aFF = aFR.Current();
- aBB.Add(aResult,aFF);
- }
- BRepCheck_Analyzer aChecker(aResult);
- if(aChecker.IsValid())
- aResShape = aResult;
-#ifdef HYDRODATA_IMZONE_DEB
- else {
- aResShape = aResult;
+ aResultFace = aFR.Current();
+ break;
}
-#endif
}
}
}
- return aResShape;
+ BRepCheck_Analyzer anAnalyzer( aResultFace );
+ if( anAnalyzer.IsValid() && aResultFace.ShapeType()==TopAbs_FACE )
+ return aResultFace;
+ else
+ return TopoDS_Face();
}
void HYDROData_ImmersibleZone::createGroupObjects()
*/
HYDRODATA_EXPORT virtual void RemovePolyline();
+ HYDRODATA_EXPORT TopoDS_Shape generateTopShape() const;
+ HYDRODATA_EXPORT static TopoDS_Shape generateTopShape( const Handle(HYDROData_PolylineXY)& );
+
protected:
/**
private:
- /**
- * Generate the zone face.
- */
- TopoDS_Shape generateTopShape() const;
-
/**
* Create all necessary child group objects.
*/
#include <TopoDS_Iterator.hxx>
#include <TopTools_ListIteratorOfListOfShape.hxx>
#include <TopTools_HSequenceOfShape.hxx>
+#include <TopExp_Explorer.hxx>
#include <ShapeAnalysis_FreeBounds.hxx>
#include <TopoDS.hxx>
#include <QColor>
Handle(TopTools_HSequenceOfShape) aSeqWires = new TopTools_HSequenceOfShape;
Handle(TopTools_HSequenceOfShape) aSeqEdges = new TopTools_HSequenceOfShape;
TopTools_ListIteratorOfListOfShape it(aSectionWiresList);
- for(;it.More();it.Next()) {
- TopoDS_Iterator it2(it.Value());
- for(;it2.More();it2.Next())
- aSeqEdges->Append(it2.Value());
+ for(;it.More();it.Next())
+ {
+ TopExp_Explorer it2(it.Value(), TopAbs_EDGE);
+ for(;it2.More();it2.Next())
+ aSeqEdges->Append(it2.Current());
}
BRep_Builder aBB;
TopoDS_Compound aCmp;
+ TopoDS_Shape aResult;
aBB.MakeCompound(aCmp);
- if(aSeqEdges->Length() >1) {
- ShapeAnalysis_FreeBounds::ConnectEdgesToWires(aSeqEdges,Precision::Confusion(),Standard_True,aSeqWires);
- for (Standard_Integer i = 1; i <= aSeqWires->Length();i++) {
- const TopoDS_Shape& aS1 = aSeqWires->Value(i);
- aBB.Add(aCmp, aS1);
+ if(aSeqEdges->Length() >1)
+ {
+ ShapeAnalysis_FreeBounds::ConnectEdgesToWires(aSeqEdges,1E-5,Standard_False,aSeqWires);
+
+ if( aSeqWires->Length()==1 )
+ aResult = aSeqWires->Value( 1 );
+ else
+ {
+ for (Standard_Integer i = 1; i <= aSeqWires->Length();i++)
+ {
+ const TopoDS_Shape& aS1 = aSeqWires->Value(i);
+ aBB.Add(aCmp, aS1);
+ }
+ aResult = aCmp;
+ }
}
- } else if (aSeqEdges->Length() == 1) {
+ else if (aSeqEdges->Length() == 1)
+ {
BRepBuilderAPI_MakeWire mkWire (TopoDS::Edge(aSeqEdges->Value(1)));
- if (mkWire.IsDone())
- aBB.Add(aCmp, mkWire.Wire());
+ if (mkWire.IsDone())
+ aResult = mkWire.Wire();
}
-
-/*
- if ( aMakeWire.IsDone() )
- {
- aShape = aMakeWire.Shape();
- }
- else if ( !aSectionWiresList.IsEmpty() )
- {
- // build compound
- TopoDS_Compound aCompound;
-
- BRep_Builder aBuilder;
- aBuilder.MakeCompound( aCompound );
-
- TopTools_ListIteratorOfListOfShape anIter( aSectionWiresList );
- for ( ; anIter.More(); anIter.Next() )
- {
- aBuilder.Add( aCompound, anIter.Value() );
- }
-
- aShape = aCompound;
- }
-*/
- setPolylineShape( aCmp );
+ setPolylineShape( aResult );
}
/**
{
Handle(HYDROData_PolylineXY) aPolylineObj =
Handle(HYDROData_PolylineXY)::DownCast( anIter.Current() );
- if ( aPolylineObj.IsNull() || !aPolylineObj->IsClosed() )
+ if ( aPolylineObj.IsNull() )//TODO: || !aPolylineObj->IsClosed() )
continue;
QString aPolylineName = aPolylineObj->GetName();
}
}
- Handle(HYDROData_ImmersibleZone) aZoneObj = myIsEdit ? myEditedObject :
- Handle(HYDROData_ImmersibleZone)::DownCast( doc()->CreateObject( KIND_IMMERSIBLE_ZONE ) );
- if ( aZoneObj.IsNull() )
- return false;
-
Handle(HYDROData_PolylineXY) aZonePolyline;
Handle(HYDROData_Bathymetry) aZoneBathymetry;
HYDROGUI_Tool::FindObjectByName( module(), aBathymetryName, KIND_BATHYMETRY ) );
}
+
+ if ( HYDROData_ImmersibleZone::generateTopShape( aZonePolyline ).IsNull() )
+ {
+ theErrorMsg = tr( "ZONE_OBJECT_CANNOT_BE_CREATED" );
+ return false;
+ }
+
+ Handle(HYDROData_ImmersibleZone) aZoneObj = myIsEdit ? myEditedObject :
+ Handle(HYDROData_ImmersibleZone)::DownCast( doc()->CreateObject( KIND_IMMERSIBLE_ZONE ) );
+
aZoneObj->SetName( anObjectName );
if ( !myIsEdit )
if ( !aPanel )
return;
- TopoDS_Wire aWire;
- TopoDS_Shape aShape;
+ TopoDS_Shape aZoneShape;
Handle(HYDROData_PolylineXY) aPolyline = Handle(HYDROData_PolylineXY)::DownCast(
HYDROGUI_Tool::FindObjectByName( module(), thePolylineName, KIND_POLYLINEXY ) );
if ( !aPolyline.IsNull() )
{
- aShape = aPolyline->GetShape();
- if ( aShape.ShapeType() == TopAbs_WIRE ) {
- aWire = TopoDS::Wire( aShape );
- }
+ aZoneShape = HYDROData_ImmersibleZone::generateTopShape( aPolyline );
}
LightApp_Application* anApp = module()->getApp();
myPreviewPrs->setFillingColor( aFillingColor, false, false );
myPreviewPrs->setBorderColor( aBorderColor, false, false );
- if ( !aWire.IsNull() ) {
- myPreviewPrs->setFace( aWire );
- } else if ( !aShape.IsNull() && aShape.ShapeType() == TopAbs_COMPOUND ) {
- TopoDS_Compound aCompound = TopoDS::Compound( aShape );
- if ( !aCompound.IsNull() ) {
- myPreviewPrs->setFaces( aCompound );
- }
- }
+ TopoDS_Face aFace;
+ if( !aZoneShape.IsNull() )
+ aFace = TopoDS::Face( aZoneShape );
+ myPreviewPrs->setFace( aFace );
}
void HYDROGUI_ImmersibleZoneOp::closePreview()
<source>OBJECT_EXISTS_IN_DOCUMENT</source>
<translation>Object with name '%1' already exists in the document.</translation>
</message>
+ <message>
+ <source>ZONE_OBJECT_CANNOT_BE_CREATED</source>
+ <translation>Zone can not be created</translation>
+ </message>
<message>
<source>SAVE_ERROR</source>
<translation>Study could not be saved</translation>