]> SALOME platform Git repositories - modules/hydro.git/commitdiff
Salome HOME
debug of immersible zones creation
authorasl <asl@opencascade.com>
Wed, 18 Dec 2013 09:25:45 +0000 (09:25 +0000)
committerasl <asl@opencascade.com>
Wed, 18 Dec 2013 09:25:45 +0000 (09:25 +0000)
src/HYDROData/HYDROData_ImmersibleZone.cxx
src/HYDROData/HYDROData_ImmersibleZone.h
src/HYDROData/HYDROData_PolylineXY.cxx
src/HYDROGUI/HYDROGUI_ImmersibleZoneOp.cxx
src/HYDROGUI/resources/HYDROGUI_msg_en.ts

index 29bc3a6d34c8f5627b9885830ad99a4e8f5bd98a..cd7e48178cb4e581f8c9e72081e8632ac459b824 100644 (file)
@@ -109,9 +109,13 @@ void HYDROData_ImmersibleZone::Update()
 
 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();
@@ -136,7 +140,8 @@ TopoDS_Shape HYDROData_ImmersibleZone::generateTopShape() const
         }
       }
       if(aWiresList.IsEmpty())
-         return aResShape;
+         return aResultFace;
+
       BRepAlgo_FaceRestrictor aFR;
       TopoDS_Face aRefFace;      
       TopoDS_Shape aS = aWiresList.First();
@@ -146,7 +151,8 @@ TopoDS_Shape HYDROData_ImmersibleZone::generateTopShape() const
         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() ) {
@@ -157,25 +163,18 @@ TopoDS_Shape HYDROData_ImmersibleZone::generateTopShape() const
       }
       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()
index 6370cf45b3d5191bab2a369efdd94b05ae94289a..68ca0e9cd7b165a21fe822f79958d0d8efb953df 100644 (file)
@@ -83,6 +83,9 @@ public:
    */
   HYDRODATA_EXPORT virtual void RemovePolyline();
 
+  HYDRODATA_EXPORT TopoDS_Shape generateTopShape() const;
+  HYDRODATA_EXPORT static TopoDS_Shape generateTopShape( const Handle(HYDROData_PolylineXY)& );
+
 protected:
 
   /**
@@ -97,11 +100,6 @@ protected:
 
 private:
 
-  /**
-   * Generate the zone face.
-   */
-  TopoDS_Shape generateTopShape() const;
-
   /**
    * Create all necessary child group objects.
    */
index eaea172a650df3981ce37149b8c72b573c54743c..5129d6e8568574edd4844e7e860d59fcf8014475 100755 (executable)
@@ -36,6 +36,7 @@
 #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>
@@ -244,50 +245,40 @@ void HYDROData_PolylineXY::Update()
   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 );
 }
 
 /**
index 276d51afcd1a229eac14016021f9e590caf7038c..1dc958e499809d98bb9530fb42c3dc2723d92310 100644 (file)
@@ -99,7 +99,7 @@ void HYDROGUI_ImmersibleZoneOp::startOperation()
   {
     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();
@@ -185,11 +185,6 @@ bool HYDROGUI_ImmersibleZoneOp::processApply( int& theUpdateFlags,
     }
   }
 
-  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;
 
@@ -207,6 +202,16 @@ bool HYDROGUI_ImmersibleZoneOp::processApply( int& theUpdateFlags,
       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 )
@@ -235,17 +240,13 @@ void HYDROGUI_ImmersibleZoneOp::onCreatePreview( const QString& thePolylineName
   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();
@@ -275,14 +276,10 @@ void HYDROGUI_ImmersibleZoneOp::onCreatePreview( const QString& thePolylineName
 
   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()
index e2faf2ecb7b1c3b83c3b3dd21d17afb0c77e07a8..f0f517f5dfa45abe159c1c0c6d364bd8d51f0234 100644 (file)
@@ -136,6 +136,10 @@ does not exist or you have not enough permissions to open it.</translation>
       <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>