]> SALOME platform Git repositories - modules/geom.git/commitdiff
Salome HOME
Bug 0020228: [CEA 331] the geompy.RemoveExtraEdges crash with the attached brep shape...
authorjfa <jfa@opencascade.com>
Wed, 13 May 2009 12:03:59 +0000 (12:03 +0000)
committerjfa <jfa@opencascade.com>
Wed, 13 May 2009 12:03:59 +0000 (12:03 +0000)
21 files changed:
doc/salome/gui/GEOM/images/remove_extra_edges.png
doc/salome/gui/GEOM/input/remove_extra_edges_operation.doc
idl/GEOM_Gen.idl
src/GEOMAlgo/BlockFix_BlockFixAPI.cxx
src/GEOMAlgo/BlockFix_BlockFixAPI.hxx
src/GEOMAlgo/BlockFix_BlockFixAPI.lxx
src/GEOMAlgo/BlockFix_CheckTool.cxx
src/GEOMAlgo/BlockFix_UnionFaces.cxx
src/GEOMAlgo/BlockFix_UnionFaces.hxx
src/GEOMAlgo/GEOMAlgo_Tools.cxx
src/GEOMGUI/GEOM_msg_en.po
src/GEOMImpl/GEOMImpl_BlockDriver.cxx
src/GEOMImpl/GEOMImpl_IBlockTrsf.hxx
src/GEOMImpl/GEOMImpl_IBlocksOperations.cxx
src/GEOMImpl/GEOMImpl_IBlocksOperations.hxx
src/GEOM_I/GEOM_IBlocksOperations_i.cc
src/GEOM_I/GEOM_IBlocksOperations_i.hh
src/GEOM_SWIG/GEOM_TestOthers.py
src/GEOM_SWIG/geompyDC.py
src/RepairGUI/RepairGUI_RemoveExtraEdgesDlg.cxx
src/RepairGUI/RepairGUI_RemoveExtraEdgesDlg.h

index bbf6904f6fec1e4a0227c6f28cf9ff56461b0c6e..f5a620b65da3f079785c59a51332eecc176b439a 100644 (file)
Binary files a/doc/salome/gui/GEOM/images/remove_extra_edges.png and b/doc/salome/gui/GEOM/images/remove_extra_edges.png differ
index ad32a93b7a013c5e2f1d95e02d3d068b154ee17c..933c58182c09e34d919cc15ff60094607b6cdd4f 100644 (file)
@@ -7,9 +7,11 @@
 \n This operation removes all seam and degenerated edges from a given
 shape and unites faces and edges, sharing one surface.
 
-\n <b>TUI Command:</b> <em>geompy.RemoveExtraEdges(theShape)</em>,
-there <em>theShape</em> is a compound or a single solid to remove irregular edges from.
-\n <b>Arguments:</b> Name + one shape.
+\n <b>TUI Command:</b> <em>geompy.RemoveExtraEdges(theShape,theOptimumNbFaces)</em>,
+there <em>theShape</em> is a compound or a single solid to remove irregular edges from
+and <em>theOptimumNbFaces</em> is an integer parameter, that regulates,
+whether the faces, sharing common surface, should be united, or not.
+\n <b>Arguments:</b> Name + one shape + a flag.
 \n <b>Advanced option:</b>
    \ref restore_presentation_parameters_page "Set presentation parameters and subshapes from arguments".
 
@@ -23,4 +25,7 @@ there <em>theShape</em> is a compound or a single solid to remove irregular edge
 \image html remove_extra_edges2.png
 <center><em>Improved shape</em></center>
 
+Our <b>TUI Scripts</b> provide you with useful examples of the
+\ref swig_RemoveExtraEdges "Remove Extra Edges" functionality usage.
+
 */
index 4cc2a6c161185259d1e7349a2062f25473551d15..08f580d39c79bb9cbbce852effccda44eea1076f 100644 (file)
@@ -21,7 +21,7 @@
 //
 //  File   : GEOM_Gen.idl
 //  Author : Sergey RUIN
-//
+
 #ifndef __GEOM_GEN__
 #define __GEOM_GEN__
 
@@ -1781,9 +1781,14 @@ module GEOM
      *  Remove all seam and degenerated edges from \a theShape.
      *  Unite faces and edges, sharing one surface.
      *  \param theShape The compound or single solid to remove irregular edges from.
+     *  \param theOptimumNbFaces If more than zero, unite faces only for those solids,
+     *         that have more than theOptimumNbFaces faces. If zero, unite faces always,
+     *         regardsless their quantity in the solid. If negative, do not unite faces at all.
+     *         For blocks repairing recommended value is 6.
      *  \return Improved shape.
      */
-    GEOM_Object RemoveExtraEdges (in GEOM_Object theShape);
+    GEOM_Object RemoveExtraEdges (in GEOM_Object theShape,
+                                  in long        theOptimumNbFaces);
 
     /*!
      *  Check, if the given shape is a blocks compound.
index 62e33fd4ed737cd0e51979d9c0366a469ae19557..674a9867e3ff5ef424e015e6a16b3bcba20c26d6 100644 (file)
 //
 //  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
 //
-// File:       BlockFix_BlockFixAPI.cxx
-// Created:    Tue Dec  7 11:59:05 2004
-// Author:     Pavel DURANDIN
-//
+//  File:    BlockFix_BlockFixAPI.cxx
+//  Created: Tue Dec  7 11:59:05 2004
+//  Author:  Pavel DURANDIN
+
 #include <BlockFix_BlockFixAPI.ixx>
 #include <BlockFix.hxx>
 #include <BlockFix_UnionFaces.hxx>
 
 //=======================================================================
 //function : ShapeConvert_CanonicAPI
-//purpose  : 
+//purpose  :
 //=======================================================================
 
 BlockFix_BlockFixAPI::BlockFix_BlockFixAPI()
 {
   myTolerance = Precision::Confusion();
+  myOptimumNbFaces = 6;
 }
 
 //=======================================================================
 //function : Perform
-//purpose  : 
+//purpose  :
 //=======================================================================
 
-void BlockFix_BlockFixAPI::Perform() 
+void BlockFix_BlockFixAPI::Perform()
 {
-
   // processing spheres with degenerativities
   TopoDS_Shape aShape = Shape();
   myShape = BlockFix::RotateSphereSpace(aShape,myTolerance);
-  
+
   // faces unification
   BlockFix_UnionFaces aFaceUnifier;
   aFaceUnifier.GetTolerance() = myTolerance;
-  TopoDS_Shape aResult;
-  aResult = aFaceUnifier.Perform(myShape);
-  
-  
+  aFaceUnifier.GetOptimumNbFaces() = myOptimumNbFaces;
+  TopoDS_Shape aResult = aFaceUnifier.Perform(myShape);
+
   BlockFix_UnionEdges anEdgeUnifier;
   myShape = anEdgeUnifier.Perform(aResult,myTolerance);
-  
+
   TopoDS_Shape aRes = BlockFix::FixRanges(myShape,myTolerance);
   myShape = aRes;
-  
 }
index 9bece72c49aefc45d0ef3f44ac8c7f314c972f0e..d2511898af5e6920532e393c0e161142a7b4582b 100644 (file)
@@ -18,7 +18,7 @@
 //  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
 //
 //  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
+
 #ifndef _BlockFix_BlockFixAPI_HeaderFile
 #define _BlockFix_BlockFixAPI_HeaderFile
 
 #ifndef _MMgt_TShared_HeaderFile
 #include <MMgt_TShared.hxx>
 #endif
+
 class ShapeBuild_ReShape;
 class TopoDS_Shape;
 
 
-class BlockFix_BlockFixAPI : public MMgt_TShared {
-
+class BlockFix_BlockFixAPI : public MMgt_TShared
+{
 public:
-
-    void* operator new(size_t,void* anAddress) 
-      {
-        return anAddress;
-      }
-    void* operator new(size_t size) 
-      { 
-        return Standard::Allocate(size); 
-      }
-    void  operator delete(void *anAddress) 
-      { 
-        if (anAddress) Standard::Free((Standard_Address&)anAddress); 
-      }
- // Methods PUBLIC
- // 
-Standard_EXPORT BlockFix_BlockFixAPI();
-  void SetShape(const TopoDS_Shape& Shape) ;
-Standard_EXPORT   void Perform() ;
+  void* operator new(size_t,void* anAddress) 
+  {
+    return anAddress;
+  }
+  void* operator new(size_t size) 
+  { 
+    return Standard::Allocate(size); 
+  }
+  void  operator delete(void *anAddress) 
+  { 
+    if (anAddress) Standard::Free((Standard_Address&)anAddress); 
+  }
+
 // Methods PUBLIC
 // 
+  Standard_EXPORT BlockFix_BlockFixAPI();
+  void SetShape(const TopoDS_Shape& Shape);
+  Standard_EXPORT   void Perform();
   TopoDS_Shape Shape() const;
-  Handle_ShapeBuild_ReShape& Context() ;
-  Standard_Real& Tolerance() ;
-Standard_EXPORT ~BlockFix_BlockFixAPI();
-
-
-
-
- // Type management
- //
- Standard_EXPORT friend Handle_Standard_Type& BlockFix_BlockFixAPI_Type_();
- Standard_EXPORT const Handle(Standard_Type)& DynamicType() const;
- Standard_EXPORT Standard_Boolean             IsKind(const Handle(Standard_Type)&) const;
-
-protected:
-
- // Methods PROTECTED
- // 
-
-
- // Fields PROTECTED
- //
+  Handle_ShapeBuild_ReShape& Context();
+  Standard_Real& Tolerance();
+  Standard_Integer& OptimumNbFaces();
+  Standard_EXPORT ~BlockFix_BlockFixAPI();
 
+  // Type management
+  //
+  Standard_EXPORT friend Handle_Standard_Type& BlockFix_BlockFixAPI_Type_();
+  Standard_EXPORT const Handle(Standard_Type)& DynamicType() const;
+  Standard_EXPORT Standard_Boolean            IsKind(const Handle(Standard_Type)&) const;
 
 private: 
-
- // Methods PRIVATE
- // 
-
-
- // Fields PRIVATE
- //
-Handle_ShapeBuild_ReShape myContext;
-TopoDS_Shape myShape;
-Standard_Real myTolerance;
-
-
+  // Fields PRIVATE
+  //
+  Handle_ShapeBuild_ReShape myContext;
+  TopoDS_Shape myShape;
+  Standard_Real myTolerance;
+  Standard_Integer myOptimumNbFaces;
 };
 
-
 #include <BlockFix_BlockFixAPI.lxx>
 
-
-
-// other Inline functions and methods (like "C++: function call" methods)
-//
-
-
 #endif
index 883e4fec61f0ea397267dccf427d811db4b33f72..e66051950a3bd97fba0b4d55d8e69e8664deedc1 100644 (file)
 //  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
 //
 //  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
+
 #include <BlockFix_BlockFixAPI.hxx>
 
 //=======================================================================
-//function : Shape
+//function : SetShape
 //purpose  : 
 //=======================================================================
 
@@ -40,7 +40,7 @@ inline TopoDS_Shape BlockFix_BlockFixAPI::Shape() const
 {
   return myShape;
 }
-  
+
 //=======================================================================
 //function : Context
 //purpose  : 
@@ -50,7 +50,7 @@ inline Handle(ShapeBuild_ReShape)& BlockFix_BlockFixAPI::Context()
 {
   return myContext;
 }
-  
+
 //=======================================================================
 //function : Tolerance
 //purpose  : 
@@ -60,4 +60,13 @@ inline Standard_Real& BlockFix_BlockFixAPI::Tolerance()
 {
   return myTolerance;
 }
-  
+
+//=======================================================================
+//function : OptimumNbFaces
+//purpose  : 
+//=======================================================================
+
+inline Standard_Integer& BlockFix_BlockFixAPI::OptimumNbFaces()
+{
+  return myOptimumNbFaces;
+}
index a5d8252559d816fc607f574a6625d94e294f81b4..51532d02ca5bcd359a452d74a262971907b72f3f 100644 (file)
 //
 //  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
 //
-// File:      BlockFix_CheckTool.cxx
-// Created:   17.12.04 11:15:25
-// Author:    Sergey KUUL
-//
+//  File:      BlockFix_CheckTool.cxx
+//  Created:   17.12.04 11:15:25
+//  Author:    Sergey KUUL
+
 #include <BlockFix_CheckTool.ixx>
 
+//#include <BlockFix_UnionEdges.hxx>
+//#include <BlockFix_UnionFaces.hxx>
+
 #include <BRep_Tool.hxx>
-#include <BlockFix_UnionEdges.hxx>
-#include <BlockFix_UnionFaces.hxx>
+
 #include <TopExp.hxx>
 #include <TopExp_Explorer.hxx>
 #include <TopoDS.hxx>
@@ -78,33 +80,43 @@ void BlockFix_CheckTool::Perform()
   myNbUF=0;
   myNbUE=0;
   myNbUFUE=0;
-  TopExp_Explorer exps;
-  for(exps.Init(myShape, TopAbs_SOLID); exps.More(); exps.Next()) {
+
+  TopExp_Explorer exps (myShape, TopAbs_SOLID);
+  TopTools_MapOfShape mapS;
+  for (; exps.More(); exps.Next()) {
     TopoDS_Solid aSolid = TopoDS::Solid(exps.Current());
+    if (!mapS.Add(aSolid)) continue;
     myNbSolids++;
     Standard_Boolean IsBlock=Standard_True;
     Standard_Boolean MayBeUF=Standard_False;
     Standard_Boolean MayBeUE=Standard_False;
     Standard_Integer nf=0;
-    TopExp_Explorer expf;
-    for(expf.Init(aSolid, TopAbs_FACE); expf.More(); expf.Next()) nf++;
+    TopExp_Explorer expf (aSolid, TopAbs_FACE);
+    TopTools_MapOfShape mapF;
+    for (; expf.More(); expf.Next()) {
+      if (mapF.Add(expf.Current()))
+        nf++;
+    }
 
-    if(nf<6) {
-      IsBlock=Standard_False;
+    if (nf < 6) {
+      IsBlock = Standard_False;
     }
-    else if(nf>6) {
-      IsBlock=Standard_False;
+    else if (nf > 6) {
+      IsBlock = Standard_False;
       // check faces unification
       TopTools_SequenceOfShape faces;
-      for( expf.Init(aSolid, TopAbs_FACE); expf.More(); expf.Next()) {
-        TopoDS_Face aFace = TopoDS::Face(expf.Current());
-        faces.Append(aFace);
+      mapF.Clear();
+      for (expf.Init(aSolid, TopAbs_FACE); expf.More(); expf.Next()) {
+        if (mapF.Add(expf.Current())) {
+          TopoDS_Face aFace = TopoDS::Face(expf.Current());
+          faces.Append(aFace);
+        }
       }
       Standard_Boolean HasFacesForUnification = Standard_False;
-      for(Standard_Integer i=1; i<faces.Length() && !HasFacesForUnification; i++) {
+      for (Standard_Integer i=1; i<faces.Length() && !HasFacesForUnification; i++) {
         TopoDS_Face F1 = TopoDS::Face(faces.Value(i));
         TopTools_MapOfShape Edges;
-        for(TopExp_Explorer expe(F1,TopAbs_EDGE); expe.More(); expe.Next())
+        for (TopExp_Explorer expe(F1,TopAbs_EDGE); expe.More(); expe.Next())
           Edges.Add(expe.Current().Oriented(TopAbs_FORWARD));
         TopLoc_Location L1;
         Handle(Geom_Surface) S1 = BRep_Tool::Surface(F1,L1);
@@ -124,51 +136,57 @@ void BlockFix_CheckTool::Perform()
           }
         }
       }
-      if(HasFacesForUnification) {
+      if (HasFacesForUnification) {
         MayBeUF=Standard_True;
       }
     }
 
     Standard_Integer nbe=0;
     TopTools_MapOfShape DegenEdges;
-    TopExp_Explorer expe;
-    for(expe.Init(aSolid, TopAbs_EDGE); expe.More(); expe.Next()) {
+    TopExp_Explorer expe (aSolid, TopAbs_EDGE);
+    TopTools_MapOfShape mapE;
+    for (; expe.More(); expe.Next()) {
       TopoDS_Edge E = TopoDS::Edge(expe.Current());
-      if(BRep_Tool::Degenerated(E)) {
-        if(!DegenEdges.Contains(E)) {
-          DegenEdges.Add(E);
-        }
+      if (!mapE.Add(E)) continue;
+      if (BRep_Tool::Degenerated(E)) {
+        DegenEdges.Add(E);
       }
       else {
         nbe++;
       }
     }
-    if( nbe==24 && DegenEdges.Extent()>0 ) {
-      IsBlock=Standard_False;
+    if (nbe == 12 && DegenEdges.Extent() > 0) {
+      IsBlock = Standard_False;
       myNbDegen++;
       myPossibleBlocks.Append(aSolid);
       continue;
     }
-    if(nbe<24)
-      IsBlock=Standard_False;
-    if(nbe>24) {
-      IsBlock=Standard_False;
+    if (nbe < 12)
+      IsBlock = Standard_False;
+    if (nbe > 12) {
+      IsBlock = Standard_False;
       // check edges unification
       // creating map of edge faces
       TopTools_IndexedDataMapOfShapeListOfShape aMapEdgeFaces;
       TopExp::MapShapesAndAncestors(aSolid, TopAbs_EDGE, TopAbs_FACE, aMapEdgeFaces);
-      for(expf.Init(aSolid, TopAbs_FACE); expf.More(); expf.Next()) {
+
+      mapF.Clear();
+      for (expf.Init(aSolid, TopAbs_FACE); expf.More(); expf.Next()) {
         TopoDS_Face aFace = TopoDS::Face(expf.Current());
+        if (!mapF.Add(aFace)) continue;
         TopTools_IndexedDataMapOfShapeListOfShape aMapFacesEdges;
-        for(expe.Init(aFace,TopAbs_EDGE); expe.More(); expe.Next()) {
+
+        TopTools_MapOfShape mapEe;
+        for (expe.Init(aFace, TopAbs_EDGE); expe.More(); expe.Next()) {
           TopoDS_Edge edge = TopoDS::Edge(expe.Current());
-          if(!aMapEdgeFaces.Contains(edge)) continue;
+          if (!mapEe.Add(edge)) continue;
+          if (!aMapEdgeFaces.Contains(edge)) continue;
           const TopTools_ListOfShape& aList = aMapEdgeFaces.FindFromKey(edge);
-          TopTools_ListIteratorOfListOfShape anIter(aList);
-          for; anIter.More(); anIter.Next()) {
+          TopTools_ListIteratorOfListOfShape anIter (aList);
+          for (; anIter.More(); anIter.Next()) {
             TopoDS_Face face = TopoDS::Face(anIter.Value());
-            if(face.IsSame(aFace)) continue;
-            if(aMapFacesEdges.Contains(face)) {
+            if (face.IsSame(aFace)) continue;
+            if (aMapFacesEdges.Contains(face)) {
               aMapFacesEdges.ChangeFromKey(face).Append(edge);
             }
             else {
@@ -178,34 +196,33 @@ void BlockFix_CheckTool::Perform()
             }
           }
         }
-        Standard_Integer i=1;
-        for(; i<=aMapFacesEdges.Extent(); i++) {
+        Standard_Integer i = 1;
+        for (; i <= aMapFacesEdges.Extent(); i++) {
           const TopTools_ListOfShape& ListEdges = aMapFacesEdges.FindFromIndex(i);
-          if(ListEdges.Extent()>1) break;
+          if (ListEdges.Extent() > 1) break;
         }
-        if(i<=aMapFacesEdges.Extent()) {
-          MayBeUE=Standard_True;
+        if (i <= aMapFacesEdges.Extent()) {
+          MayBeUE = Standard_True;
           break;
         }
       }
     }
 
-    if(IsBlock) 
+    if (IsBlock) 
       myNbBlocks++;
     else {
-      if(MayBeUF) {
+      if (MayBeUF) {
         myPossibleBlocks.Append(aSolid);
-        if(MayBeUE)
+        if (MayBeUE)
           myNbUFUE++;
         else
           myNbUF++;
       }
-      else if(MayBeUE) {
+      else if (MayBeUE) {
         myNbUE++;
         myPossibleBlocks.Append(aSolid);
       }
     }
-
   }
 
   myHasCheck = Standard_True;
index e513cbe59dfadf8f2515e8bcd04e85ef61021ffa..d63b5aaac2862ae16e014859768331a3bab4f768 100644 (file)
 //
 //  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
 //
-// File:       BlockFix_UnionFaces.cxx
-// Created:    Tue Dec  7 17:15:42 2004
-// Author:     Pavel DURANDIN
-//
+//  File:    BlockFix_UnionFaces.cxx
+//  Created: Tue Dec  7 17:15:42 2004
+//  Author:  Pavel DURANDIN
 
 #include <BlockFix_UnionFaces.ixx>
 
@@ -59,7 +58,7 @@
 #include <TopoDS.hxx>
 #include <TopoDS_Edge.hxx>
 #include <TopoDS_Wire.hxx>
-#include <TopoDS_Face.hxx>  
+#include <TopoDS_Face.hxx>
 #include <TopoDS_Solid.hxx>
 #include <TopoDS_Vertex.hxx>
 #include <TopoDS_Shell.hxx>
 
 #include <gp_XY.hxx>
 #include <gp_Pnt2d.hxx>
-  
+
 //=======================================================================
 //function : BlockFix_UnionFaces
-//purpose  : 
+//purpose  :
 //=======================================================================
 
 BlockFix_UnionFaces::BlockFix_UnionFaces()
-     : myTolerance(Precision::Confusion())
+  : myTolerance(Precision::Confusion()),
+    myOptimumNbFaces(6)
 {
 }
 
 
 //=======================================================================
-//function : GetTolearnce
-//purpose  : 
+//function : GetTolerance
+//purpose  :
 //=======================================================================
 
 Standard_Real& BlockFix_UnionFaces::GetTolerance()
@@ -102,6 +102,17 @@ Standard_Real& BlockFix_UnionFaces::GetTolerance()
 }
 
 
+//=======================================================================
+//function : GetOptimumNbFaces
+//purpose  :
+//=======================================================================
+
+Standard_Integer& BlockFix_UnionFaces::GetOptimumNbFaces()
+{
+  return myOptimumNbFaces;
+}
+
+
 //=======================================================================
 //function : AddOrdinaryEdges
 //purpose  : auxilary
@@ -129,22 +140,22 @@ static Standard_Boolean AddOrdinaryEdges(TopTools_SequenceOfShape& edges,
   for(Standard_Integer i = 1; i <= edges.Length(); i++) {
     TopoDS_Shape current = edges(i);
     if(aNewEdges.Contains(current)) {
-               
+
       aNewEdges.Remove(current);
       edges.Remove(i);
       i--;
-      
+
       if(!isDropped) {
         isDropped = Standard_True;
         anIndex = i;
       }
     }
   }
-          
+
   //add edges to the sequemce
   for(TopTools_MapIteratorOfMapOfShape anIter(aNewEdges); anIter.More(); anIter.Next())
     edges.Append(anIter.Key());
-  
+
   return isDropped;
 }
 
@@ -156,7 +167,7 @@ static Standard_Boolean AddOrdinaryEdges(TopTools_SequenceOfShape& edges,
 static Handle(Geom_Surface) ClearRts(const Handle(Geom_Surface)& aSurface)
 {
   if(aSurface->IsKind(STANDARD_TYPE(Geom_RectangularTrimmedSurface))) {
-    Handle(Geom_RectangularTrimmedSurface) rts = 
+    Handle(Geom_RectangularTrimmedSurface) rts =
       Handle(Geom_RectangularTrimmedSurface)::DownCast(aSurface);
     return rts->BasisSurface();
   }
@@ -166,7 +177,7 @@ static Handle(Geom_Surface) ClearRts(const Handle(Geom_Surface)& aSurface)
 
 //=======================================================================
 //function : Perform
-//purpose  : 
+//purpose  :
 //=======================================================================
 
 TopoDS_Shape BlockFix_UnionFaces::Perform(const TopoDS_Shape& Shape)
@@ -176,7 +187,7 @@ TopoDS_Shape BlockFix_UnionFaces::Perform(const TopoDS_Shape& Shape)
 
   // processing each solid
   TopExp_Explorer exps;
-  for(exps.Init(Shape, TopAbs_SOLID); exps.More(); exps.Next()) {
+  for (exps.Init(Shape, TopAbs_SOLID); exps.More(); exps.Next()) {
     TopoDS_Solid aSolid = TopoDS::Solid(exps.Current());
 
     // creating map of edge faces
@@ -185,28 +196,40 @@ TopoDS_Shape BlockFix_UnionFaces::Perform(const TopoDS_Shape& Shape)
 
     // map of processed shapes
     TopTools_MapOfShape aProcessed;
-  
+
     Handle(ShapeBuild_ReShape) aContext = new ShapeBuild_ReShape;
 
-    Standard_Integer NbModif=0;
+    Standard_Integer NbModif = 0;
     Standard_Boolean hasFailed = Standard_False;
-    Standard_Real tol = Min(Max(Precision::Confusion(), myTolerance/10.),0.1);
-    // processing each face
+    Standard_Real tol = Min(Max(Precision::Confusion(), myTolerance/10.), 0.1);
+
+    // count faces
+    int nbf = 0;
     TopExp_Explorer exp;
-    //for( exp.Init(Shape, TopAbs_FACE); exp.More(); exp.Next()) {
-    for( exp.Init(aSolid, TopAbs_FACE); exp.More(); exp.Next()) {
+    TopTools_MapOfShape mapF;
+    for (exp.Init(aSolid, TopAbs_FACE); exp.More(); exp.Next()) {
+      if (mapF.Add(exp.Current()))
+        nbf++;
+    }
+
+    bool doUnion = ((myOptimumNbFaces == 0) ||
+                    ((myOptimumNbFaces > 0) && (nbf > myOptimumNbFaces)));
+
+    // processing each face
+    mapF.Clear();
+    for (exp.Init(aSolid, TopAbs_FACE); exp.More() && doUnion; exp.Next()) {
       TopoDS_Face aFace = TopoDS::Face(exp.Current().Oriented(TopAbs_FORWARD));
-      
-      if(aProcessed.Contains(aFace))
+
+      if (aProcessed.Contains(aFace))
         continue;
-    
+
       Standard_Integer dummy;
       TopTools_SequenceOfShape edges;
       AddOrdinaryEdges(edges,aFace,dummy);
-    
+
       TopTools_SequenceOfShape faces;
       faces.Append(aFace);
-    
+
       //surface and location to construct result
       TopLoc_Location aBaseLocation;
       Handle(Geom_Surface) aBaseSurface = BRep_Tool::Surface(aFace,aBaseLocation);
@@ -214,73 +237,73 @@ TopoDS_Shape BlockFix_UnionFaces::Perform(const TopoDS_Shape& Shape)
 
       // find adjacent faces to union
       Standard_Integer i;
-      fori = 1; i <= edges.Length(); i++) {
+      for (i = 1; i <= edges.Length(); i++) {
         TopoDS_Edge edge = TopoDS::Edge(edges(i));
-        if(BRep_Tool::Degenerated(edge))
+        if (BRep_Tool::Degenerated(edge))
           continue;
-      
+
         const TopTools_ListOfShape& aList = aMapEdgeFaces.FindFromKey(edge);
         TopTools_ListIteratorOfListOfShape anIter(aList);
-        for; anIter.More(); anIter.Next()) {
+        for (; anIter.More(); anIter.Next()) {
           TopoDS_Face anCheckedFace = TopoDS::Face(anIter.Value().Oriented(TopAbs_FORWARD));
-          if(anCheckedFace.IsSame(aFace))
+          if (anCheckedFace.IsSame(aFace))
             continue;
-        
-          if(aProcessed.Contains(anCheckedFace))
+
+          if (aProcessed.Contains(anCheckedFace))
             continue;
-        
-          if(IsSameDomain(aFace,anCheckedFace)) {
-          
-            if(aList.Extent() != 2) {
+
+          if (IsSameDomain(aFace,anCheckedFace)) {
+
+            if (aList.Extent() != 2) {
               // non mainfold case is not processed
               continue;
             }
-          
+
             // replacing pcurves
             TopoDS_Face aMockUpFace;
             BRep_Builder B;
             B.MakeFace(aMockUpFace,aBaseSurface,aBaseLocation,0.);
             MovePCurves(aMockUpFace,anCheckedFace);
-            
-            if(AddOrdinaryEdges(edges,aMockUpFace,dummy)) {
+
+            if (AddOrdinaryEdges(edges,aMockUpFace,dummy)) {
               // sequence edges is modified
               i = dummy;
             }
-            
+
             faces.Append(anCheckedFace);
             aProcessed.Add(anCheckedFace);
             break;
           }
         }
       }
-    
+
       // all faces collected in the sequence. Perform union of faces
-      if(faces.Length() > 1) {
+      if (faces.Length() > 1) {
         NbModif++;
         TopoDS_Face aResult;
         BRep_Builder B;
         B.MakeFace(aResult,aBaseSurface,aBaseLocation,0);
         Standard_Integer nbWires = 0;
-      
+
         // connecting wires
-        while(edges.Length()>0) {
-        
+        while (edges.Length()>0) {
+
           Standard_Boolean isEdge3d = Standard_False;
           nbWires++;
           TopTools_MapOfShape aVertices;
           TopoDS_Wire aWire;
           B.MakeWire(aWire);
-        
+
           TopoDS_Edge anEdge = TopoDS::Edge(edges(1));
           edges.Remove(1);
-        
+
           isEdge3d |= !BRep_Tool::Degenerated(anEdge);
           B.Add(aWire,anEdge);
           TopoDS_Vertex V1,V2;
           TopExp::Vertices(anEdge,V1,V2);
           aVertices.Add(V1);
           aVertices.Add(V2);
-        
+
           Standard_Boolean isNewFound = Standard_False;
           do {
             isNewFound = Standard_False;
@@ -298,10 +321,10 @@ TopoDS_Shape BlockFix_UnionFaces::Perform(const TopoDS_Shape& Shape)
               }
             }
           } while (isNewFound);
-        
+
           // sorting any type of edges
           aWire = TopoDS::Wire(aContext->Apply(aWire));
-                
+
           TopoDS_Face tmpF = TopoDS::Face(aContext->Apply(faces(1).Oriented(TopAbs_FORWARD)));
           Handle(ShapeFix_Wire) sfw = new ShapeFix_Wire(aWire,tmpF,Precision::Confusion());
           sfw->FixReorder();
@@ -348,7 +371,7 @@ TopoDS_Shape BlockFix_UnionFaces::Perform(const TopoDS_Shape& Shape)
               sawo.Add(c2d->Value(f).XY(),c2d->Value(l).XY());
             }
             sawo.Perform();
-            
+
             // constructind one degenerative edge
             gp_XY aStart, anEnd, tmp;
             Standard_Integer nbFirst = sawo.Ordered(1);
@@ -358,7 +381,7 @@ TopoDS_Shape BlockFix_UnionFaces::Perform(const TopoDS_Shape& Shape)
             TopoDS_Edge E = sbe.CopyReplaceVertices(anOrigE,aDummyV,aDummyV);
             sawo.XY(nbFirst,aStart,tmp);
             sawo.XY(sawo.Ordered(aLastEdge),tmp,anEnd);
-          
+
             gp_XY aVec = anEnd-aStart;
             Handle(Geom2d_Line) aLine = new Geom2d_Line(aStart,gp_Dir2d(anEnd-aStart));
 
@@ -372,13 +395,11 @@ TopoDS_Shape BlockFix_UnionFaces::Perform(const TopoDS_Shape& Shape)
             B.Add(aW,E);
             B.Add(aResult,aW);
           }
-        
         }
-      
+
         // perform substitution of face
         aContext->Replace(aContext->Apply(aFace),aResult);
-      
-      
+
         ShapeFix_Face sff (aResult);
         //Intializing by tolerances
         sff.SetPrecision(myTolerance);
@@ -390,74 +411,72 @@ TopoDS_Shape BlockFix_UnionFaces::Perform(const TopoDS_Shape& Shape)
         sff.SetContext(aContext);
         // Applying the fixes
         sff.Perform();
-        if(sff.Status(ShapeExtend_FAIL)) 
+        if(sff.Status(ShapeExtend_FAIL))
         hasFailed = Standard_True;
-      
+
         // breaking down to several faces
         TopoDS_Shape theResult = aContext->Apply(aResult);
-        for(TopExp_Explorer aFaceExp(theResult,TopAbs_FACE);aFaceExp.More();aFaceExp.Next()) {
+        for (TopExp_Explorer aFaceExp (theResult,TopAbs_FACE); aFaceExp.More(); aFaceExp.Next()) {
           TopoDS_Face aCurrent = TopoDS::Face(aFaceExp.Current().Oriented(TopAbs_FORWARD));
           Handle(TColGeom_HArray2OfSurface) grid = new TColGeom_HArray2OfSurface ( 1, 1, 1, 1 );
           grid->SetValue ( 1, 1, aBaseSurface );
           Handle(ShapeExtend_CompositeSurface) G = new ShapeExtend_CompositeSurface ( grid );
           ShapeFix_ComposeShell CompShell;
-          CompShell.Init ( G, aBaseLocation, aCurrent, ::Precision::Confusion() );//myPrecision 
+          CompShell.Init ( G, aBaseLocation, aCurrent, ::Precision::Confusion() );//myPrecision
           CompShell.SetContext( aContext );
-          
+
           TopTools_SequenceOfShape parts;
           ShapeFix_SequenceOfWireSegment wires;
           for(TopExp_Explorer W_Exp(aCurrent,TopAbs_WIRE);W_Exp.More();W_Exp.Next()) {
-            Handle(ShapeExtend_WireData) sbwd = 
+            Handle(ShapeExtend_WireData) sbwd =
               new ShapeExtend_WireData ( TopoDS::Wire(W_Exp.Current() ));
             ShapeFix_WireSegment seg ( sbwd, TopAbs_REVERSED );
             wires.Append(seg);
           }
-                
+
           CompShell.DispatchWires ( parts,wires );
           for (Standard_Integer j=1; j <= parts.Length(); j++ ) {
             ShapeFix_Face aFixOrient(TopoDS::Face(parts(j)));
             aFixOrient.SetContext(aContext);
             aFixOrient.FixOrientation();
           }
-        
+
           TopoDS_Shape CompRes;
           if ( faces.Length() !=1 ) {
             TopoDS_Shell S;
             B.MakeShell ( S );
-            for ( i=1; i <= parts.Length(); i++ ) 
+            for ( i=1; i <= parts.Length(); i++ )
               B.Add ( S, parts(i) );
             CompRes = S;
           }
           else CompRes = parts(1);
-          
+
           aContext->Replace(aCurrent,CompRes);
         }
-      
+
         // remove the remaining faces
         for(i = 2; i <= faces.Length(); i++)
           aContext->Remove(faces(i));
       }
-    }
-  
+    } // end processing each face
+
     //TopoDS_Shape aResult = Shape;
-    if(NbModif>0) {
-      TopoDS_Shape aResult = aSolid;
-      if(!hasFailed) {
-        aResult = aContext->Apply(aSolid);
-    
-        ShapeFix_Edge sfe;
-        for(exp.Init(aResult,TopAbs_EDGE); exp.More(); exp.Next()) {
-          TopoDS_Edge E = TopoDS::Edge(exp.Current());
-          sfe.FixVertexTolerance (E);
-          // ptv add fix same parameter
-          sfe.FixSameParameter(E, myTolerance);
-        }
-        
-        myContext->Replace(aSolid,aResult);
+    if (NbModif > 0 && !hasFailed) {
+      TopoDS_Shape aResult = aContext->Apply(aSolid);
+
+      ShapeFix_Edge sfe;
+      for (exp.Init(aResult,TopAbs_EDGE); exp.More(); exp.Next()) {
+        TopoDS_Edge E = TopoDS::Edge(exp.Current());
+        sfe.FixVertexTolerance (E);
+        // ptv add fix same parameter
+        sfe.FixSameParameter(E, myTolerance);
       }
+
+      myContext->Replace(aSolid, aResult);
     }
-//    else {
-      for( exp.Init(aSolid, TopAbs_FACE); exp.More(); exp.Next()) {
+    //else
+    {
+      for (exp.Init(aSolid, TopAbs_FACE); exp.More(); exp.Next()) {
         TopoDS_Face aFace = TopoDS::Face(exp.Current().Oriented(TopAbs_FORWARD));
         Handle(ShapeFix_Wire) sfw = new ShapeFix_Wire;
         sfw->SetContext(myContext);
@@ -465,15 +484,14 @@ TopoDS_Shape BlockFix_UnionFaces::Perform(const TopoDS_Shape& Shape)
         sfw->SetMinTolerance(myTolerance);
         sfw->SetMaxTolerance(Max(1.,myTolerance*1000.));
         sfw->SetFace(aFace);
-        for ( TopoDS_Iterator iter(aFace,Standard_False); iter.More(); iter.Next()) { 
-          TopoDS_Wire wire = TopoDS::Wire ( iter.Value() );
+        for (TopoDS_Iterator iter (aFace,Standard_False); iter.More(); iter.Next()) {
+          TopoDS_Wire wire = TopoDS::Wire(iter.Value());
           sfw->Load(wire);
           sfw->FixReorder();
           sfw->FixShifted();
         }
       }
-//    }
-
+    }
   } // end processing each solid
 
   aResShape = myContext->Apply(Shape);
@@ -483,7 +501,7 @@ TopoDS_Shape BlockFix_UnionFaces::Perform(const TopoDS_Shape& Shape)
 
 //=======================================================================
 //function : IsSameDomain
-//purpose  : 
+//purpose  :
 //=======================================================================
 
 Standard_Boolean BlockFix_UnionFaces::IsSameDomain(const TopoDS_Face& aFace,
@@ -492,10 +510,10 @@ Standard_Boolean BlockFix_UnionFaces::IsSameDomain(const TopoDS_Face& aFace,
   //checking the same handless
   TopLoc_Location L1, L2;
   Handle(Geom_Surface) S1, S2;
-  
+
   S1 = BRep_Tool::Surface(aFace,L1);
   S2 = BRep_Tool::Surface(aCheckedFace,L2);
-  
+
   if (S1 == S2 && L1 == L2)
     return true;
 
@@ -586,7 +604,7 @@ Standard_Boolean BlockFix_UnionFaces::IsSameDomain(const TopoDS_Face& aFace,
 
 //=======================================================================
 //function : MovePCurves
-//purpose  : 
+//purpose  :
 //=======================================================================
 
 void BlockFix_UnionFaces::MovePCurves(TopoDS_Face& aTarget,
@@ -594,17 +612,17 @@ void BlockFix_UnionFaces::MovePCurves(TopoDS_Face& aTarget,
 {
   BRep_Builder B;
   for(TopExp_Explorer wexp(aSource,TopAbs_WIRE);wexp.More();wexp.Next()) {
-    Handle(ShapeFix_Wire) sfw = new ShapeFix_Wire(TopoDS::Wire(wexp.Current()), 
+    Handle(ShapeFix_Wire) sfw = new ShapeFix_Wire(TopoDS::Wire(wexp.Current()),
                                                   aTarget, Precision::Confusion());
     sfw->FixReorder();
     Standard_Boolean isReoredFailed = sfw->StatusReorder ( ShapeExtend_FAIL );
     sfw->FixEdgeCurves();
     if(isReoredFailed)
       continue;
-    
+
     sfw->FixShifted();
     sfw->FixDegenerated();
-    
+
     // remove degenerated edges from not degenerated points
     ShapeAnalysis_Edge sae;
     Handle(ShapeExtend_WireData) sewd = sfw->WireData();
@@ -615,7 +633,7 @@ void BlockFix_UnionFaces::MovePCurves(TopoDS_Face& aTarget,
         i--;
       }
     }
-    
+
     TopoDS_Wire ResWire = sfw->Wire();
     B.Add(aTarget,ResWire);
   }
index 9cf0578d8f420329bc556f4ae7bfea04a67ce70a..afe00c1733c7f1acf71536610a6830025a18286f 100644 (file)
@@ -18,7 +18,7 @@
 //  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
 //
 //  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
+
 #ifndef _BlockFix_UnionFaces_HeaderFile
 #define _BlockFix_UnionFaces_HeaderFile
 
 #ifndef _Standard_Boolean_HeaderFile
 #include <Standard_Boolean.hxx>
 #endif
-class TopoDS_Shape;
-class TopoDS_Face;
-
-
 #ifndef _Standard_HeaderFile
 #include <Standard.hxx>
 #endif
@@ -39,63 +35,55 @@ class TopoDS_Face;
 #include <Standard_Macro.hxx>
 #endif
 
-class BlockFix_UnionFaces  {
+class TopoDS_Shape;
+class TopoDS_Face;
 
+class BlockFix_UnionFaces
+{
 public:
-
-    void* operator new(size_t,void* anAddress) 
-      {
-        return anAddress;
-      }
-    void* operator new(size_t size) 
-      { 
-        return Standard::Allocate(size); 
-      }
-    void  operator delete(void *anAddress) 
-      { 
-        if (anAddress) Standard::Free((Standard_Address&)anAddress); 
-      }
- // Methods PUBLIC
- // 
-Standard_EXPORT BlockFix_UnionFaces();
-Standard_EXPORT   Standard_Real& GetTolerance() ;
-Standard_EXPORT   TopoDS_Shape Perform(const TopoDS_Shape& Shape) ;
-Standard_EXPORT virtual  Standard_Boolean IsSameDomain(const TopoDS_Face& aFace,const TopoDS_Face& aChekedFace) const;
-Standard_EXPORT virtual  void MovePCurves(TopoDS_Face& aTarget,const TopoDS_Face& aSource) const;
-
-
-
-
-
-protected:
-
- // Methods PROTECTED
- // 
-
-
- // Fields PROTECTED
- //
-
+  void* operator new(size_t,void* anAddress) 
+  {
+    return anAddress;
+  }
+  void* operator new(size_t size) 
+  { 
+    return Standard::Allocate(size); 
+  }
+  void  operator delete(void *anAddress) 
+  { 
+    if (anAddress) Standard::Free((Standard_Address&)anAddress); 
+  }
+
+  // Methods PUBLIC
+  // 
+  Standard_EXPORT BlockFix_UnionFaces();
+
+  Standard_EXPORT   Standard_Real& GetTolerance();
+
+  /* \brief To get/set the OptimumNbFaces parameter
+   *
+   * If a being processed solid has less than OptimumNbFaces
+   *    faces, no union will be performed.
+   * By default this parameter is set to 6 (to correctly
+   *    process blocks - hexahedral solids)
+   * Special values: 0 - do all possible unions, regardless the faces quantity,
+   *                 negative - do not perform any unions, regardless the faces quantity.
+   *
+   */
+  Standard_EXPORT   Standard_Integer& GetOptimumNbFaces();
+
+  Standard_EXPORT   TopoDS_Shape Perform(const TopoDS_Shape& Shape);
+
+  Standard_EXPORT virtual  Standard_Boolean IsSameDomain(const TopoDS_Face& aFace,
+                                                         const TopoDS_Face& aChekedFace) const;
+  Standard_EXPORT virtual  void MovePCurves(TopoDS_Face& aTarget,
+                                            const TopoDS_Face& aSource) const;
 
 private: 
-
- // Methods PRIVATE
- // 
-
-
- // Fields PRIVATE
- //
-Standard_Real myTolerance;
-
-
+  // Fields PRIVATE
+  //
+  Standard_Real myTolerance;
+  Standard_Integer myOptimumNbFaces;
 };
 
-
-
-
-
-// other Inline functions and methods (like "C++: function call" methods)
-//
-
-
 #endif
index bad8a3c150eadb738057b169b476a66ee853bb45..2556e13316ec222897ef5322bf9a9a01ff245cbf 100644 (file)
@@ -286,41 +286,58 @@ Standard_Boolean GEOMAlgo_Tools::ProjectPointOnShape(const gp_Pnt& aP1,
                                                     gp_Pnt& aP2,
                                                     IntTools_Context& aCtx)
 {
-  Standard_Boolean bIsDone=Standard_False;
+  Standard_Boolean bIsDone = Standard_False;
   Standard_Real aT2;
   TopAbs_ShapeEnum aType;
   //
-  aType=aS.ShapeType();
-  switch(aType) {
-    case TopAbs_EDGE: {
-      const TopoDS_Edge& aE2=TopoDS::Edge(aS);
-      //
-      bIsDone=aCtx.ProjectPointOnEdge(aP1, aE2, aT2);
-      if (!bIsDone) {
-       return bIsDone;
+  aType = aS.ShapeType();
+  switch (aType)
+    {
+    case TopAbs_EDGE:
+      {
+        cout << "$$$ case TopAbs_EDGE" << endl;
+        const TopoDS_Edge& aE2 = TopoDS::Edge(aS);
+        //
+        if (BRep_Tool::Degenerated(aE2)) { // jfa
+          cout << "$$$ Degenerated" << endl;
+          return Standard_True;
+        }
+        else {
+          Standard_Real f, l;
+          Handle(Geom_Curve) aC3D = BRep_Tool::Curve (aE2, f, l);
+          if (aC3D.IsNull()) {
+            cout << "$$$ aC3D.IsNull()" << endl;
+            return Standard_True;
+          }
+          bIsDone = aCtx.ProjectPointOnEdge(aP1, aE2, aT2);
+        }
+        if (!bIsDone) {
+          cout << "$$$ !bIsDone" << endl;
+          return bIsDone;
+        }
+        //
+        GEOMAlgo_Tools::PointOnEdge(aE2, aT2, aP2);
       }
-      //
-      GEOMAlgo_Tools::PointOnEdge(aE2, aT2, aP2);
-    }
       break;
       //
-    case TopAbs_FACE: {
-      const TopoDS_Face& aF2=TopoDS::Face(aS);
-      GeomAPI_ProjectPointOnSurf& aProj=aCtx.ProjPS(aF2);
-      //
-      aProj.Perform(aP1);
-      bIsDone=aProj.IsDone();
-      if (!bIsDone) {
-       return bIsDone;
+    case TopAbs_FACE:
+      {
+        const TopoDS_Face& aF2 = TopoDS::Face(aS);
+        GeomAPI_ProjectPointOnSurf& aProj = aCtx.ProjPS(aF2);
+        //
+        aProj.Perform(aP1);
+        bIsDone = aProj.IsDone();
+        if (!bIsDone) {
+          return bIsDone;
+        }
+        //
+        aP2 = aProj.NearestPoint(); 
       }
-      //
-      aP2=aProj.NearestPoint(); 
-    }
       break;
       //  
     default:
       break; // Err
-  }
+    }
   return bIsDone;
 }
 //=======================================================================
index df66b8bae19640924815a0ce0ad856089d64a7c3..345d34fae70696e727077464583089976af99960 100644 (file)
@@ -2254,6 +2254,9 @@ msgstr "SupressFaces"
 msgid "CHANGE_ORIENTATION_NEW_OBJ_NAME"
 msgstr "Invert"
 
+msgid "GEOM_RMEE_UNION_FACES"
+msgstr "Union faces, laying on common surface"
+
 msgid "REMOVE_EXTRA_EDGES_NEW_OBJ_NAME"
 msgstr "NoExtraEdges"
 
index 7a98359acd338276298775bdaaf736fb64e78a4e..880661f70c3b4b93f6da7792390354a8c29313a4 100644 (file)
@@ -18,7 +18,7 @@
 //  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
 //
 //  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
+
 #include <Standard_Stream.hxx>
 
 #include <BRepOffsetAPI_MakeFilling.hxx>
@@ -506,6 +506,7 @@ Standard_Integer GEOMImpl_BlockDriver::Execute(TFunction_Logbook& log) const
       // 1. Improve solids with seam and/or degenerated edges
       BlockFix_BlockFixAPI aTool;
       //aTool.Tolerance() = toler;
+      aTool.OptimumNbFaces() = aCI.GetOptimumNbFaces();
       aTool.SetShape(aBlockOrComp);
       aTool.Perform();
 
index b6827133d114c111c0a48449ea0b32727854d4a3..f618a269593e3334c52443ebee167f1ce3638842 100644 (file)
@@ -19,8 +19,8 @@
 //
 //  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
 //
-//NOTE: This is an interface to a function for the Blocks Multi-Transformations.
-//
+//NOTE: This is an interface to a functions for the Blocks Multi-Transformations and repairing
+
 #include "GEOM_Function.hxx"
 
 #define TRSF_ORIGIN  1
@@ -32,6 +32,8 @@
 #define TRSF_FACE_2_V  6
 #define TRSF_NBITER_V  7
 
+#define TRSF_NB_FACES  8
+
 class GEOMImpl_IBlockTrsf
 {
  public:
@@ -49,6 +51,8 @@ class GEOMImpl_IBlockTrsf
   void SetNbIterU (int theNbIter) { _func->SetInteger(TRSF_NBITER_U, theNbIter); }
   void SetNbIterV (int theNbIter) { _func->SetInteger(TRSF_NBITER_V, theNbIter); }
 
+  void SetOptimumNbFaces (int theNbFaces) { _func->SetInteger(TRSF_NB_FACES, theNbFaces); }
+
   int GetFace1U () { return _func->GetInteger(TRSF_FACE_1_U); }
   int GetFace2U () { return _func->GetInteger(TRSF_FACE_2_U); }
   int GetFace1V () { return _func->GetInteger(TRSF_FACE_1_V); }
@@ -56,6 +60,8 @@ class GEOMImpl_IBlockTrsf
   int GetNbIterU() { return _func->GetInteger(TRSF_NBITER_U); }
   int GetNbIterV() { return _func->GetInteger(TRSF_NBITER_V); }
 
+  int GetOptimumNbFaces() { return _func->GetInteger(TRSF_NB_FACES); }
+
  private:
 
   Handle(GEOM_Function) _func;
index 9c461c12398d039cd67c78af2bbfa3660055f782..6f7e86cd0a3b95cf5f42a85a2e171c3a313273c8 100644 (file)
@@ -18,7 +18,7 @@
 //  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
 //
 //  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
+
 #ifdef WNT
 #pragma warning( disable:4786 )
 #endif
@@ -2311,7 +2311,8 @@ Standard_Boolean GEOMImpl_IBlocksOperations::CheckCompoundOfBlocks
  */
 //=============================================================================
 Handle(GEOM_Object) GEOMImpl_IBlocksOperations::RemoveExtraEdges
-                                             (Handle(GEOM_Object) theObject)
+                                     (Handle(GEOM_Object) theObject,
+                                      const Standard_Integer theOptimumNbFaces)
 {
   SetErrorCode(KO);
 
@@ -2332,6 +2333,7 @@ Handle(GEOM_Object) GEOMImpl_IBlocksOperations::RemoveExtraEdges
 
   GEOMImpl_IBlockTrsf aTI (aFunction);
   aTI.SetOriginal(aLastFunction);
+  aTI.SetOptimumNbFaces(theOptimumNbFaces);
 
   //Compute the fixed shape
   try {
@@ -2351,7 +2353,8 @@ Handle(GEOM_Object) GEOMImpl_IBlocksOperations::RemoveExtraEdges
 
   //Make a Python command
   GEOM::TPythonDump(aFunction) << aCopy
-    << " = geompy.RemoveExtraEdges(" << theObject << ")";
+                               << " = geompy.RemoveExtraEdges(" << theObject
+                               << ", " << theOptimumNbFaces << ")";
 
   SetErrorCode(OK);
   return aCopy;
@@ -2384,6 +2387,7 @@ Handle(GEOM_Object) GEOMImpl_IBlocksOperations::CheckAndImprove
 
   GEOMImpl_IBlockTrsf aTI (aFunction);
   aTI.SetOriginal(aLastFunction);
+  aTI.SetOptimumNbFaces(6);
 
   //Compute the fixed shape
   try {
index 449c36f510261548a82189f8be197536a3a2f3b2..491a606130447dfe2a49da58bbca897be6b3b6da 100644 (file)
@@ -18,7 +18,7 @@
 //  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
 //
 //  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
+
 #ifndef _GEOMImpl_IBlocksOperations_HXX_
 #define _GEOMImpl_IBlocksOperations_HXX_
 
@@ -125,7 +125,8 @@ class GEOMImpl_IBlocksOperations : public GEOM_IOperations {
   Standard_EXPORT TCollection_AsciiString PrintBCErrors (Handle(GEOM_Object)  theCompound,
                                          const std::list<BCError>& theErrors);
 
-  Standard_EXPORT Handle(GEOM_Object) RemoveExtraEdges (Handle(GEOM_Object) theShape);
+  Standard_EXPORT Handle(GEOM_Object) RemoveExtraEdges (Handle(GEOM_Object) theShape,
+                                                        const Standard_Integer theOptimumNbFaces = 6);
 
   Standard_EXPORT Handle(GEOM_Object) CheckAndImprove (Handle(GEOM_Object) theCompound);
 
index 4763ba016c64425e36d84616f33c22bf945595f1..9eb087de45a3ec0ed725ad97e32688819ee79e26 100644 (file)
@@ -689,7 +689,9 @@ char* GEOM_IBlocksOperations_i::PrintBCErrors
  *  RemoveExtraEdges
  */
 //=============================================================================
-GEOM::GEOM_Object_ptr GEOM_IBlocksOperations_i::RemoveExtraEdges (GEOM::GEOM_Object_ptr theShape)
+GEOM::GEOM_Object_ptr GEOM_IBlocksOperations_i::RemoveExtraEdges
+                                      (GEOM::GEOM_Object_ptr theShape,
+                                       CORBA::Long           theOptimumNbFaces)
 {
   GEOM::GEOM_Object_var aGEOMObject;
 
@@ -701,8 +703,7 @@ GEOM::GEOM_Object_ptr GEOM_IBlocksOperations_i::RemoveExtraEdges (GEOM::GEOM_Obj
   if (aShape.IsNull()) return aGEOMObject._retn();
 
   //Get the result
-  Handle(GEOM_Object) anObject =
-    GetOperations()->RemoveExtraEdges(aShape);
+  Handle(GEOM_Object) anObject = GetOperations()->RemoveExtraEdges(aShape, theOptimumNbFaces);
   if (!GetOperations()->IsDone() || anObject.IsNull())
     return aGEOMObject._retn();
 
index ff6480f8b55f650534ac54e8c3e3298515d82e33..49e326ea155ed58b8aa5ee28e54973b65e57b948 100644 (file)
@@ -18,7 +18,7 @@
 //  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
 //
 //  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
+
 #ifndef _GEOM_IBlocksOperations_i_HeaderFile
 #define _GEOM_IBlocksOperations_i_HeaderFile
 
@@ -112,7 +112,8 @@ class GEOM_I_EXPORT GEOM_IBlocksOperations_i :
   char* PrintBCErrors (GEOM::GEOM_Object_ptr theCompound,
                       const GEOM::GEOM_IBlocksOperations::BCErrors& theErrors);
 
-  GEOM::GEOM_Object_ptr RemoveExtraEdges (GEOM::GEOM_Object_ptr theShape);
+  GEOM::GEOM_Object_ptr RemoveExtraEdges (GEOM::GEOM_Object_ptr theShape,
+                                          CORBA::Long           theOptimumNbFaces);
 
   GEOM::GEOM_Object_ptr CheckAndImprove (GEOM::GEOM_Object_ptr theCompound);
 
index 76d4e2811e3df5bed2a1a60cea39a91f7e6691c2..f1da607014c25c0e4e0a1dfcb862658faafcc661 100644 (file)
@@ -104,6 +104,8 @@ def TestOtherOperations (geompy, math):
   vy = geompy.MakeVectorDXDYDZ( 0,  1,  0)
   vz = geompy.MakeVectorDXDYDZ( 0,  0,  1)
 
+  v_y = geompy.MakeVectorDXDYDZ( 0, -1,  0)
+
   p11 = geompy.MakeVertex( 0,  0, 0)
   p12 = geompy.MakeVertex(30,  0, 0)
   p13 = geompy.MakeVertex(30, 30, 0)
@@ -320,18 +322,17 @@ def TestOtherOperations (geompy, math):
 
   v_0pp = geompy.MakeVectorDXDYDZ( 0,  1,  1)
   #v_0np = geompy.MakeVectorDXDYDZ( 0, -1,  1)
-  #v_p0p = geompy.MakeVectorDXDYDZ( 1,  0,  1)
-  #v_n0p = geompy.MakeVectorDXDYDZ(-1,  0,  1)
-  #v_pp0 = geompy.MakeVectorDXDYDZ( 1,  1,  0)
-  #v_np0 = geompy.MakeVectorDXDYDZ(-1,  1,  0)
-  v_0n0 = geompy.MakeVectorDXDYDZ( 0, -1,  0)
+  v_p0p = geompy.MakeVectorDXDYDZ( 1,  0,  1)
+  v_p0n = geompy.MakeVectorDXDYDZ(1,  0,  -1)
+  v_pp0 = geompy.MakeVectorDXDYDZ( 1,  1,  0)
+  v_pn0 = geompy.MakeVectorDXDYDZ(1,  -1,  0)
 
   #pln_0pp = geompy.MakePlane(p0, v_0pp, 300)
   #pln_0np = geompy.MakePlane(p0, v_0np, 300)
-  #pln_p0p = geompy.MakePlane(p0, v_p0p, 300)
-  #pln_n0p = geompy.MakePlane(p0, v_n0p, 300)
-  #pln_pp0 = geompy.MakePlane(p0, v_pp0, 300)
-  #pln_np0 = geompy.MakePlane(p0, v_np0, 300)
+  pln_p0p = geompy.MakePlane(p0, v_p0p, 300)
+  pln_p0n = geompy.MakePlane(p0, v_p0n, 300)
+  pln_pp0 = geompy.MakePlane(p0, v_pp0, 300)
+  pln_pn0 = geompy.MakePlane(p0, v_pn0, 300)
   #
   #part_objs = [b0, pln_0pp, pln_0np, pln_p0p, pln_n0p, pln_pp0, pln_np0]
   #part_tool_1 = geompy.MakePartition(part_objs, [], [], [b0])
@@ -410,6 +411,49 @@ def TestOtherOperations (geompy, math):
 
   geompy.addToStudy(freeFaces, "freeFaces")
 
+  # RemoveExtraEdges with union of all faces, sharing common surfaces
+  tools = [pln_pp0, pln_pn0, pln_p0p, pln_p0n]
+
+  Partition_1 = geompy.MakePartition([Sphere], tools, [], [], geompy.ShapeType["SOLID"], 0, [])
+  geompy.addToStudy(Partition_1, "Partition_1")
+
+  faces = geompy.SubShapeAllSorted(Partition_1, geompy.ShapeType["FACE"])
+
+  Face_1 = faces[0]
+  Face_2 = faces[39]
+  Face_3 = faces[40]
+
+  geompy.addToStudyInFather(Partition_1, Face_1, "Face_1")
+  geompy.addToStudyInFather(Partition_1, Face_2, "Face_2")
+  geompy.addToStudyInFather(Partition_1, Face_3, "Face_3")
+
+  Vector_5 = geompy.MakeVectorDXDYDZ(0, 20, 0)
+  geompy.addToStudy(Vector_5, "Vector_5")
+
+  Rotation_1 = geompy.MakeRotation(Face_1, Vector_5, 90*math.pi/180.0)
+  Rotation_2 = geompy.MakeRotation(Face_1, Vector_5, 180*math.pi/180.0)
+  Rotation_3 = geompy.MakeRotation(Face_1, Vector_5, 270*math.pi/180.0)
+
+  geompy.addToStudy(Rotation_1, "Rotation_1")
+  geompy.addToStudy(Rotation_2, "Rotation_2")
+  geompy.addToStudy(Rotation_3, "Rotation_3")
+
+  Vector_6 = geompy.MakeVectorDXDYDZ(0, 0, 20)
+  geompy.addToStudy(Vector_6, "Vector_6")
+
+  Rotation_4 = geompy.MakeRotation(Face_1, Vector_6, 90*math.pi/180.0)
+  Rotation_5 = geompy.MakeRotation(Face_1, Vector_6, -90*math.pi/180.0)
+  geompy.addToStudy(Rotation_4, "Rotation_4")
+  geompy.addToStudy(Rotation_5, "Rotation_5")
+
+  Shell_1 = geompy.MakeShell([Face_1, Rotation_1, Rotation_2, Rotation_3, Rotation_4, Rotation_5])
+  Solid_1 = geompy.MakeSolid([Shell_1])
+  NoExtraEdges_1 = geompy.RemoveExtraEdges(Solid_1, 0)
+
+  geompy.addToStudy(Shell_1, "Shell_1")
+  geompy.addToStudy(Solid_1, "Solid_1")
+  geompy.addToStudy(NoExtraEdges_1, "NoExtraEdges_1")
+
   # RemoveExtraEdges
   freeFacesWithoutExtra = geompy.RemoveExtraEdges(freeFaces)
 
@@ -474,13 +518,13 @@ def TestOtherOperations (geompy, math):
   # GetShapesOnPlaneWithLocation
   Loc = geompy.MakeVertex(0, -50, 0)
   edges_on_pln = geompy.GetShapesOnPlaneWithLocation(blocksComp, geompy.ShapeType["EDGE"],
-                                                     v_0n0, Loc, geompy.GEOM.ST_ON)
+                                                     v_y, Loc, geompy.GEOM.ST_ON)
   for edge_i in edges_on_pln:
     geompy.addToStudy(edge_i, "Edge on Plane (N = (0, -1, 0) & Location = (0, -50, 0)")
     
   # GetShapesOnPlaneWithLocationIDs
   edges_on_pln_ids = geompy.GetShapesOnPlaneWithLocationIDs(
-           blocksComp, geompy.ShapeType["EDGE"], v_0n0, Loc, geompy.GEOM.ST_ON)
+           blocksComp, geompy.ShapeType["EDGE"], v_y, Loc, geompy.GEOM.ST_ON)
   group_edges_on_pln = geompy.CreateGroup(blocksComp, geompy.ShapeType["EDGE"])
   geompy.UnionIDs(group_edges_on_pln, edges_on_pln_ids)
   grname = "Group of edges on Plane (N = (0, -1, 0) & Location = (0, -50, 0))"
index 889d0b69e7be0e44f9b5e06cedc0587e232139cd..76bdb024ae036744b2bf7f6f5b3e5d4372f5012b 100644 (file)
@@ -2990,12 +2990,16 @@ class geompyDC(GEOM._objref_GEOM_Gen):
         #  Unite faces and edges, sharing one surface. It means that
         #  this faces must have references to one C++ surface object (handle).
         #  @param theShape The compound or single solid to remove irregular edges from.
+        #  @param theOptimumNbFaces If more than zero, unite faces only for those solids,
+        #         that have more than theOptimumNbFaces faces. If zero, unite faces always,
+        #         regardsless their quantity in the solid. If negative (the default value),
+        #         do not unite faces at all. For blocks repairing recommended value is 6.
         #  @return Improved shape.
         #
         #  @ref swig_RemoveExtraEdges "Example"
-        def RemoveExtraEdges(self,theShape):
+        def RemoveExtraEdges(self,theShape,theOptimumNbFaces=-1):
             # Example: see GEOM_TestOthers.py
-            anObj = self.BlocksOp.RemoveExtraEdges(theShape)
+            anObj = self.BlocksOp.RemoveExtraEdges(theShape,theOptimumNbFaces)
             RaiseIfFailed("RemoveExtraEdges", self.BlocksOp)
             return anObj
 
index 9a7cc55dd922d824e1d2d2381a9e7ec8fe7cd11e..9eb3e1ba6638263868a07ba5a4abcc38f75d89d7 100644 (file)
 //  Author : Michael Zorin
 //  Module : GEOM
 //  $Header$
-//
+
 #include "RepairGUI_RemoveExtraEdgesDlg.h"
 
 #include "SalomeApp_Application.h"
 #include "LightApp_SelectionMgr.h"
 #include "SUIT_Session.h"
 
+#include "DlgRef_1Sel1Check_QTD.h"
+
 #include "GEOMImpl_Types.hxx"
 
 #include <TColStd_MapOfInteger.hxx>
@@ -62,12 +64,14 @@ RepairGUI_RemoveExtraEdgesDlg::RepairGUI_RemoveExtraEdgesDlg(GeometryGUI* theGeo
   RadioButton2->close(TRUE);
   RadioButton3->close(TRUE);
 
-  GroupPoints = new DlgRef_1Sel_QTD(this, "GroupPoints");
+  GroupPoints = new DlgRef_1Sel1Check_QTD(this, "GroupPoints");
   GroupPoints->GroupBox1->setTitle(tr("GEOM_REMOVE_EXTRA_EDGES"));
   GroupPoints->TextLabel1->setText(tr("GEOM_SELECTED_SHAPE"));
   GroupPoints->PushButton1->setPixmap(image1);
   GroupPoints->LineEdit1->setReadOnly( true );
 
+  GroupPoints->CheckButton1->setText(tr("GEOM_RMEE_UNION_FACES"));
+
   Layout1->addWidget(GroupPoints, 2, 0);
   /***************************************************************/
 
@@ -97,6 +101,8 @@ void RepairGUI_RemoveExtraEdgesDlg::Init()
 
   myOkObject = false;
 
+  GroupPoints->CheckButton1->setChecked( false );
+
   activateSelection();
 
   GroupBoxPublish->show();
@@ -282,10 +288,14 @@ bool RepairGUI_RemoveExtraEdgesDlg::execute( ObjectList& objects )
 {
   GEOM::GEOM_Object_var anObj;
 
-  anObj = GEOM::GEOM_IBlocksOperations::_narrow(getOperation())->RemoveExtraEdges(myObject);
+  int nbFacesOptimum = -1; // -1 means do not union faces
+  if (GroupPoints->CheckButton1->isChecked())
+    nbFacesOptimum = 0; // 0 means union all faces, that possible
+  anObj = GEOM::GEOM_IBlocksOperations::_narrow(getOperation())->RemoveExtraEdges
+    (myObject, nbFacesOptimum);
 
-  if ( !anObj->_is_nil() )
-    objects.push_back( anObj._retn() );
+  if (!anObj->_is_nil())
+    objects.push_back(anObj._retn());
 
   return true;
 }
index 3eabb54bf746f7678d5d0f1dc64e5f68b86c0cbf..8172867d775f0d05526b4afeac63ee8efb91597a 100644 (file)
 //  File   : RepairGUI_RemoveExtraEdgesDlg.h
 //  Author : Michael ZORIN
 //  Module : GEOM
-//
+
 #ifndef DIALOGBOX_REMOVEEXTRAEDGES_H
 #define DIALOGBOX_REMOVEEXTRAEDGES_H
 
 #include "GEOMBase_Skeleton.h"
-#include "DlgRef_1Sel_QTD.h"
+//#include "DlgRef_1Sel_QTD.h"
+
+class DlgRef_1Sel1Check_QTD;
 
 //=================================================================================
 // class    : RepairGUI_RemoveExtraEdgesDlg
@@ -60,8 +62,9 @@ private :
     GEOM::GEOM_Object_var myObject;
     bool myOkObject;
 
-    DlgRef_1Sel_QTD* GroupPoints;
-
+    //DlgRef_1Sel_QTD* GroupPoints;
+    //DlgRef_1Sel1Check* GroupPoints;
+    DlgRef_1Sel1Check_QTD* GroupPoints;
 
 private slots:
     void ClickOnOk();