Bug 0020228: [CEA 331] the geompy.RemoveExtraEdges crash with the attached brep shape file. Added a new parameter theOptimumNbFaces to the RemoveExtraEdges functionality. In GUI it is a boolean flag.

This commit is contained in:
jfa 2009-04-21 13:28:59 +00:00
parent a6c9711ba9
commit 8fc906ac5a
18 changed files with 278 additions and 239 deletions

View File

@ -21,7 +21,7 @@
// //
// File : GEOM_Gen.idl // File : GEOM_Gen.idl
// Author : Sergey RUIN // Author : Sergey RUIN
//
#ifndef __GEOM_GEN__ #ifndef __GEOM_GEN__
#define __GEOM_GEN__ #define __GEOM_GEN__
@ -1869,9 +1869,14 @@ module GEOM
* Remove all seam and degenerated edges from \a theShape. * Remove all seam and degenerated edges from \a theShape.
* Unite faces and edges, sharing one surface. * Unite faces and edges, sharing one surface.
* \param theShape The compound or single solid to remove irregular edges from. * \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. * \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. * Check, if the given shape is a blocks compound.

View File

@ -19,10 +19,10 @@
// //
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
// //
// File: BlockFix_BlockFixAPI.cxx // File: BlockFix_BlockFixAPI.cxx
// Created: Tue Dec 7 11:59:05 2004 // Created: Tue Dec 7 11:59:05 2004
// Author: Pavel DURANDIN // Author: Pavel DURANDIN
//
#include <BlockFix_BlockFixAPI.ixx> #include <BlockFix_BlockFixAPI.ixx>
#include <BlockFix.hxx> #include <BlockFix.hxx>
#include <BlockFix_UnionFaces.hxx> #include <BlockFix_UnionFaces.hxx>
@ -31,37 +31,35 @@
//======================================================================= //=======================================================================
//function : ShapeConvert_CanonicAPI //function : ShapeConvert_CanonicAPI
//purpose : //purpose :
//======================================================================= //=======================================================================
BlockFix_BlockFixAPI::BlockFix_BlockFixAPI() BlockFix_BlockFixAPI::BlockFix_BlockFixAPI()
{ {
myTolerance = Precision::Confusion(); myTolerance = Precision::Confusion();
myOptimumNbFaces = 6;
} }
//======================================================================= //=======================================================================
//function : Perform //function : Perform
//purpose : //purpose :
//======================================================================= //=======================================================================
void BlockFix_BlockFixAPI::Perform() void BlockFix_BlockFixAPI::Perform()
{ {
// processing spheres with degenerativities // processing spheres with degenerativities
TopoDS_Shape aShape = Shape(); TopoDS_Shape aShape = Shape();
myShape = BlockFix::RotateSphereSpace(aShape,myTolerance); myShape = BlockFix::RotateSphereSpace(aShape,myTolerance);
// faces unification // faces unification
BlockFix_UnionFaces aFaceUnifier; BlockFix_UnionFaces aFaceUnifier;
aFaceUnifier.GetTolerance() = myTolerance; aFaceUnifier.GetTolerance() = myTolerance;
TopoDS_Shape aResult; aFaceUnifier.GetOptimumNbFaces() = myOptimumNbFaces;
aResult = aFaceUnifier.Perform(myShape); TopoDS_Shape aResult = aFaceUnifier.Perform(myShape);
BlockFix_UnionEdges anEdgeUnifier; BlockFix_UnionEdges anEdgeUnifier;
myShape = anEdgeUnifier.Perform(aResult,myTolerance); myShape = anEdgeUnifier.Perform(aResult,myTolerance);
TopoDS_Shape aRes = BlockFix::FixRanges(myShape,myTolerance); TopoDS_Shape aRes = BlockFix::FixRanges(myShape,myTolerance);
myShape = aRes; myShape = aRes;
} }

View File

@ -18,7 +18,7 @@
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
// //
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
#ifndef _BlockFix_BlockFixAPI_HeaderFile #ifndef _BlockFix_BlockFixAPI_HeaderFile
#define _BlockFix_BlockFixAPI_HeaderFile #define _BlockFix_BlockFixAPI_HeaderFile
@ -41,77 +41,53 @@
#ifndef _MMgt_TShared_HeaderFile #ifndef _MMgt_TShared_HeaderFile
#include <MMgt_TShared.hxx> #include <MMgt_TShared.hxx>
#endif #endif
class ShapeBuild_ReShape; class ShapeBuild_ReShape;
class TopoDS_Shape; class TopoDS_Shape;
class BlockFix_BlockFixAPI : public MMgt_TShared { class BlockFix_BlockFixAPI : public MMgt_TShared
{
public: 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);
}
void* operator new(size_t,void* anAddress) // Methods PUBLIC
{ //
return anAddress; Standard_EXPORT BlockFix_BlockFixAPI();
} void SetShape(const TopoDS_Shape& Shape);
void* operator new(size_t size) Standard_EXPORT void Perform();
{
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; TopoDS_Shape Shape() const;
Handle_ShapeBuild_ReShape& Context() ; Handle_ShapeBuild_ReShape& Context();
Standard_Real& Tolerance() ; Standard_Real& Tolerance();
Standard_EXPORT ~BlockFix_BlockFixAPI(); 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;
protected:
// Methods PROTECTED
//
// Fields PROTECTED
//
// 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: private:
// Fields PRIVATE
// Methods PRIVATE //
// Handle_ShapeBuild_ReShape myContext;
TopoDS_Shape myShape;
Standard_Real myTolerance;
// Fields PRIVATE Standard_Integer myOptimumNbFaces;
//
Handle_ShapeBuild_ReShape myContext;
TopoDS_Shape myShape;
Standard_Real myTolerance;
}; };
#include <BlockFix_BlockFixAPI.lxx> #include <BlockFix_BlockFixAPI.lxx>
// other Inline functions and methods (like "C++: function call" methods)
//
#endif #endif

View File

@ -18,11 +18,11 @@
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
// //
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
#include <BlockFix_BlockFixAPI.hxx> #include <BlockFix_BlockFixAPI.hxx>
//======================================================================= //=======================================================================
//function : Shape //function : SetShape
//purpose : //purpose :
//======================================================================= //=======================================================================
@ -40,7 +40,7 @@ inline TopoDS_Shape BlockFix_BlockFixAPI::Shape() const
{ {
return myShape; return myShape;
} }
//======================================================================= //=======================================================================
//function : Context //function : Context
//purpose : //purpose :
@ -50,7 +50,7 @@ inline Handle(ShapeBuild_ReShape)& BlockFix_BlockFixAPI::Context()
{ {
return myContext; return myContext;
} }
//======================================================================= //=======================================================================
//function : Tolerance //function : Tolerance
//purpose : //purpose :
@ -60,4 +60,13 @@ inline Standard_Real& BlockFix_BlockFixAPI::Tolerance()
{ {
return myTolerance; return myTolerance;
} }
//=======================================================================
//function : OptimumNbFaces
//purpose :
//=======================================================================
inline Standard_Integer& BlockFix_BlockFixAPI::OptimumNbFaces()
{
return myOptimumNbFaces;
}

View File

@ -25,9 +25,11 @@
#include <BlockFix_CheckTool.ixx> #include <BlockFix_CheckTool.ixx>
//#include <BlockFix_UnionEdges.hxx>
//#include <BlockFix_UnionFaces.hxx>
#include <BRep_Tool.hxx> #include <BRep_Tool.hxx>
#include <BlockFix_UnionEdges.hxx>
#include <BlockFix_UnionFaces.hxx>
#include <TopExp.hxx> #include <TopExp.hxx>
#include <TopExp_Explorer.hxx> #include <TopExp_Explorer.hxx>
#include <TopoDS.hxx> #include <TopoDS.hxx>

View File

@ -19,10 +19,9 @@
// //
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
// //
// File: BlockFix_UnionFaces.cxx // File: BlockFix_UnionFaces.cxx
// Created: Tue Dec 7 17:15:42 2004 // Created: Tue Dec 7 17:15:42 2004
// Author: Pavel DURANDIN // Author: Pavel DURANDIN
//
#include <BlockFix_UnionFaces.ixx> #include <BlockFix_UnionFaces.ixx>
@ -59,7 +58,7 @@
#include <TopoDS.hxx> #include <TopoDS.hxx>
#include <TopoDS_Edge.hxx> #include <TopoDS_Edge.hxx>
#include <TopoDS_Wire.hxx> #include <TopoDS_Wire.hxx>
#include <TopoDS_Face.hxx> #include <TopoDS_Face.hxx>
#include <TopoDS_Solid.hxx> #include <TopoDS_Solid.hxx>
#include <TopoDS_Vertex.hxx> #include <TopoDS_Vertex.hxx>
#include <TopoDS_Shell.hxx> #include <TopoDS_Shell.hxx>
@ -79,21 +78,22 @@
#include <gp_XY.hxx> #include <gp_XY.hxx>
#include <gp_Pnt2d.hxx> #include <gp_Pnt2d.hxx>
//======================================================================= //=======================================================================
//function : BlockFix_UnionFaces //function : BlockFix_UnionFaces
//purpose : //purpose :
//======================================================================= //=======================================================================
BlockFix_UnionFaces::BlockFix_UnionFaces() BlockFix_UnionFaces::BlockFix_UnionFaces()
: myTolerance(Precision::Confusion()) : myTolerance(Precision::Confusion()),
myOptimumNbFaces(6)
{ {
} }
//======================================================================= //=======================================================================
//function : GetTolearnce //function : GetTolerance
//purpose : //purpose :
//======================================================================= //=======================================================================
Standard_Real& BlockFix_UnionFaces::GetTolerance() 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 //function : AddOrdinaryEdges
//purpose : auxilary //purpose : auxilary
@ -129,22 +140,22 @@ static Standard_Boolean AddOrdinaryEdges(TopTools_SequenceOfShape& edges,
for(Standard_Integer i = 1; i <= edges.Length(); i++) { for(Standard_Integer i = 1; i <= edges.Length(); i++) {
TopoDS_Shape current = edges(i); TopoDS_Shape current = edges(i);
if(aNewEdges.Contains(current)) { if(aNewEdges.Contains(current)) {
aNewEdges.Remove(current); aNewEdges.Remove(current);
edges.Remove(i); edges.Remove(i);
i--; i--;
if(!isDropped) { if(!isDropped) {
isDropped = Standard_True; isDropped = Standard_True;
anIndex = i; anIndex = i;
} }
} }
} }
//add edges to the sequemce //add edges to the sequemce
for(TopTools_MapIteratorOfMapOfShape anIter(aNewEdges); anIter.More(); anIter.Next()) for(TopTools_MapIteratorOfMapOfShape anIter(aNewEdges); anIter.More(); anIter.Next())
edges.Append(anIter.Key()); edges.Append(anIter.Key());
return isDropped; return isDropped;
} }
@ -156,7 +167,7 @@ static Standard_Boolean AddOrdinaryEdges(TopTools_SequenceOfShape& edges,
static Handle(Geom_Surface) ClearRts(const Handle(Geom_Surface)& aSurface) static Handle(Geom_Surface) ClearRts(const Handle(Geom_Surface)& aSurface)
{ {
if(aSurface->IsKind(STANDARD_TYPE(Geom_RectangularTrimmedSurface))) { if(aSurface->IsKind(STANDARD_TYPE(Geom_RectangularTrimmedSurface))) {
Handle(Geom_RectangularTrimmedSurface) rts = Handle(Geom_RectangularTrimmedSurface) rts =
Handle(Geom_RectangularTrimmedSurface)::DownCast(aSurface); Handle(Geom_RectangularTrimmedSurface)::DownCast(aSurface);
return rts->BasisSurface(); return rts->BasisSurface();
} }
@ -166,7 +177,7 @@ static Handle(Geom_Surface) ClearRts(const Handle(Geom_Surface)& aSurface)
//======================================================================= //=======================================================================
//function : Perform //function : Perform
//purpose : //purpose :
//======================================================================= //=======================================================================
TopoDS_Shape BlockFix_UnionFaces::Perform(const TopoDS_Shape& Shape) TopoDS_Shape BlockFix_UnionFaces::Perform(const TopoDS_Shape& Shape)
@ -201,9 +212,12 @@ TopoDS_Shape BlockFix_UnionFaces::Perform(const TopoDS_Shape& Shape)
nbf++; nbf++;
} }
bool doUnion = ((myOptimumNbFaces == 0) ||
((myOptimumNbFaces > 0) && (nbf > myOptimumNbFaces)));
// processing each face // processing each face
mapF.Clear(); mapF.Clear();
for (exp.Init(aSolid, TopAbs_FACE); exp.More() && nbf > 6; exp.Next()) { for (exp.Init(aSolid, TopAbs_FACE); exp.More() && doUnion; exp.Next()) {
TopoDS_Face aFace = TopoDS::Face(exp.Current().Oriented(TopAbs_FORWARD)); TopoDS_Face aFace = TopoDS::Face(exp.Current().Oriented(TopAbs_FORWARD));
if (aProcessed.Contains(aFace)) if (aProcessed.Contains(aFace))
@ -227,42 +241,42 @@ TopoDS_Shape BlockFix_UnionFaces::Perform(const TopoDS_Shape& Shape)
TopoDS_Edge edge = TopoDS::Edge(edges(i)); TopoDS_Edge edge = TopoDS::Edge(edges(i));
if (BRep_Tool::Degenerated(edge)) if (BRep_Tool::Degenerated(edge))
continue; continue;
const TopTools_ListOfShape& aList = aMapEdgeFaces.FindFromKey(edge); const TopTools_ListOfShape& aList = aMapEdgeFaces.FindFromKey(edge);
TopTools_ListIteratorOfListOfShape anIter(aList); TopTools_ListIteratorOfListOfShape anIter(aList);
for (; anIter.More(); anIter.Next()) { for (; anIter.More(); anIter.Next()) {
TopoDS_Face anCheckedFace = TopoDS::Face(anIter.Value().Oriented(TopAbs_FORWARD)); TopoDS_Face anCheckedFace = TopoDS::Face(anIter.Value().Oriented(TopAbs_FORWARD));
if (anCheckedFace.IsSame(aFace)) if (anCheckedFace.IsSame(aFace))
continue; continue;
if (aProcessed.Contains(anCheckedFace)) if (aProcessed.Contains(anCheckedFace))
continue; continue;
if (IsSameDomain(aFace,anCheckedFace)) { if (IsSameDomain(aFace,anCheckedFace)) {
if (aList.Extent() != 2) { if (aList.Extent() != 2) {
// non mainfold case is not processed // non mainfold case is not processed
continue; continue;
} }
// replacing pcurves // replacing pcurves
TopoDS_Face aMockUpFace; TopoDS_Face aMockUpFace;
BRep_Builder B; BRep_Builder B;
B.MakeFace(aMockUpFace,aBaseSurface,aBaseLocation,0.); B.MakeFace(aMockUpFace,aBaseSurface,aBaseLocation,0.);
MovePCurves(aMockUpFace,anCheckedFace); MovePCurves(aMockUpFace,anCheckedFace);
if (AddOrdinaryEdges(edges,aMockUpFace,dummy)) { if (AddOrdinaryEdges(edges,aMockUpFace,dummy)) {
// sequence edges is modified // sequence edges is modified
i = dummy; i = dummy;
} }
faces.Append(anCheckedFace); faces.Append(anCheckedFace);
aProcessed.Add(anCheckedFace); aProcessed.Add(anCheckedFace);
break; break;
} }
} }
} }
// all faces collected in the sequence. Perform union of faces // all faces collected in the sequence. Perform union of faces
if (faces.Length() > 1) { if (faces.Length() > 1) {
NbModif++; NbModif++;
@ -270,26 +284,26 @@ TopoDS_Shape BlockFix_UnionFaces::Perform(const TopoDS_Shape& Shape)
BRep_Builder B; BRep_Builder B;
B.MakeFace(aResult,aBaseSurface,aBaseLocation,0); B.MakeFace(aResult,aBaseSurface,aBaseLocation,0);
Standard_Integer nbWires = 0; Standard_Integer nbWires = 0;
// connecting wires // connecting wires
while (edges.Length()>0) { while (edges.Length()>0) {
Standard_Boolean isEdge3d = Standard_False; Standard_Boolean isEdge3d = Standard_False;
nbWires++; nbWires++;
TopTools_MapOfShape aVertices; TopTools_MapOfShape aVertices;
TopoDS_Wire aWire; TopoDS_Wire aWire;
B.MakeWire(aWire); B.MakeWire(aWire);
TopoDS_Edge anEdge = TopoDS::Edge(edges(1)); TopoDS_Edge anEdge = TopoDS::Edge(edges(1));
edges.Remove(1); edges.Remove(1);
isEdge3d |= !BRep_Tool::Degenerated(anEdge); isEdge3d |= !BRep_Tool::Degenerated(anEdge);
B.Add(aWire,anEdge); B.Add(aWire,anEdge);
TopoDS_Vertex V1,V2; TopoDS_Vertex V1,V2;
TopExp::Vertices(anEdge,V1,V2); TopExp::Vertices(anEdge,V1,V2);
aVertices.Add(V1); aVertices.Add(V1);
aVertices.Add(V2); aVertices.Add(V2);
Standard_Boolean isNewFound = Standard_False; Standard_Boolean isNewFound = Standard_False;
do { do {
isNewFound = Standard_False; isNewFound = Standard_False;
@ -307,10 +321,10 @@ TopoDS_Shape BlockFix_UnionFaces::Perform(const TopoDS_Shape& Shape)
} }
} }
} while (isNewFound); } while (isNewFound);
// sorting any type of edges // sorting any type of edges
aWire = TopoDS::Wire(aContext->Apply(aWire)); aWire = TopoDS::Wire(aContext->Apply(aWire));
TopoDS_Face tmpF = TopoDS::Face(aContext->Apply(faces(1).Oriented(TopAbs_FORWARD))); TopoDS_Face tmpF = TopoDS::Face(aContext->Apply(faces(1).Oriented(TopAbs_FORWARD)));
Handle(ShapeFix_Wire) sfw = new ShapeFix_Wire(aWire,tmpF,Precision::Confusion()); Handle(ShapeFix_Wire) sfw = new ShapeFix_Wire(aWire,tmpF,Precision::Confusion());
sfw->FixReorder(); sfw->FixReorder();
@ -357,7 +371,7 @@ TopoDS_Shape BlockFix_UnionFaces::Perform(const TopoDS_Shape& Shape)
sawo.Add(c2d->Value(f).XY(),c2d->Value(l).XY()); sawo.Add(c2d->Value(f).XY(),c2d->Value(l).XY());
} }
sawo.Perform(); sawo.Perform();
// constructind one degenerative edge // constructind one degenerative edge
gp_XY aStart, anEnd, tmp; gp_XY aStart, anEnd, tmp;
Standard_Integer nbFirst = sawo.Ordered(1); Standard_Integer nbFirst = sawo.Ordered(1);
@ -367,7 +381,7 @@ TopoDS_Shape BlockFix_UnionFaces::Perform(const TopoDS_Shape& Shape)
TopoDS_Edge E = sbe.CopyReplaceVertices(anOrigE,aDummyV,aDummyV); TopoDS_Edge E = sbe.CopyReplaceVertices(anOrigE,aDummyV,aDummyV);
sawo.XY(nbFirst,aStart,tmp); sawo.XY(nbFirst,aStart,tmp);
sawo.XY(sawo.Ordered(aLastEdge),tmp,anEnd); sawo.XY(sawo.Ordered(aLastEdge),tmp,anEnd);
gp_XY aVec = anEnd-aStart; gp_XY aVec = anEnd-aStart;
Handle(Geom2d_Line) aLine = new Geom2d_Line(aStart,gp_Dir2d(anEnd-aStart)); Handle(Geom2d_Line) aLine = new Geom2d_Line(aStart,gp_Dir2d(anEnd-aStart));
@ -397,9 +411,9 @@ TopoDS_Shape BlockFix_UnionFaces::Perform(const TopoDS_Shape& Shape)
sff.SetContext(aContext); sff.SetContext(aContext);
// Applying the fixes // Applying the fixes
sff.Perform(); sff.Perform();
if(sff.Status(ShapeExtend_FAIL)) if(sff.Status(ShapeExtend_FAIL))
hasFailed = Standard_True; hasFailed = Standard_True;
// breaking down to several faces // breaking down to several faces
TopoDS_Shape theResult = aContext->Apply(aResult); 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()) {
@ -408,38 +422,38 @@ TopoDS_Shape BlockFix_UnionFaces::Perform(const TopoDS_Shape& Shape)
grid->SetValue ( 1, 1, aBaseSurface ); grid->SetValue ( 1, 1, aBaseSurface );
Handle(ShapeExtend_CompositeSurface) G = new ShapeExtend_CompositeSurface ( grid ); Handle(ShapeExtend_CompositeSurface) G = new ShapeExtend_CompositeSurface ( grid );
ShapeFix_ComposeShell CompShell; ShapeFix_ComposeShell CompShell;
CompShell.Init ( G, aBaseLocation, aCurrent, ::Precision::Confusion() );//myPrecision CompShell.Init ( G, aBaseLocation, aCurrent, ::Precision::Confusion() );//myPrecision
CompShell.SetContext( aContext ); CompShell.SetContext( aContext );
TopTools_SequenceOfShape parts; TopTools_SequenceOfShape parts;
ShapeFix_SequenceOfWireSegment wires; ShapeFix_SequenceOfWireSegment wires;
for(TopExp_Explorer W_Exp(aCurrent,TopAbs_WIRE);W_Exp.More();W_Exp.Next()) { 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() )); new ShapeExtend_WireData ( TopoDS::Wire(W_Exp.Current() ));
ShapeFix_WireSegment seg ( sbwd, TopAbs_REVERSED ); ShapeFix_WireSegment seg ( sbwd, TopAbs_REVERSED );
wires.Append(seg); wires.Append(seg);
} }
CompShell.DispatchWires ( parts,wires ); CompShell.DispatchWires ( parts,wires );
for (Standard_Integer j=1; j <= parts.Length(); j++ ) { for (Standard_Integer j=1; j <= parts.Length(); j++ ) {
ShapeFix_Face aFixOrient(TopoDS::Face(parts(j))); ShapeFix_Face aFixOrient(TopoDS::Face(parts(j)));
aFixOrient.SetContext(aContext); aFixOrient.SetContext(aContext);
aFixOrient.FixOrientation(); aFixOrient.FixOrientation();
} }
TopoDS_Shape CompRes; TopoDS_Shape CompRes;
if ( faces.Length() !=1 ) { if ( faces.Length() !=1 ) {
TopoDS_Shell S; TopoDS_Shell S;
B.MakeShell ( S ); B.MakeShell ( S );
for ( i=1; i <= parts.Length(); i++ ) for ( i=1; i <= parts.Length(); i++ )
B.Add ( S, parts(i) ); B.Add ( S, parts(i) );
CompRes = S; CompRes = S;
} }
else CompRes = parts(1); else CompRes = parts(1);
aContext->Replace(aCurrent,CompRes); aContext->Replace(aCurrent,CompRes);
} }
// remove the remaining faces // remove the remaining faces
for(i = 2; i <= faces.Length(); i++) for(i = 2; i <= faces.Length(); i++)
aContext->Remove(faces(i)); aContext->Remove(faces(i));
@ -470,7 +484,7 @@ TopoDS_Shape BlockFix_UnionFaces::Perform(const TopoDS_Shape& Shape)
sfw->SetMinTolerance(myTolerance); sfw->SetMinTolerance(myTolerance);
sfw->SetMaxTolerance(Max(1.,myTolerance*1000.)); sfw->SetMaxTolerance(Max(1.,myTolerance*1000.));
sfw->SetFace(aFace); sfw->SetFace(aFace);
for (TopoDS_Iterator iter (aFace,Standard_False); iter.More(); iter.Next()) { for (TopoDS_Iterator iter (aFace,Standard_False); iter.More(); iter.Next()) {
TopoDS_Wire wire = TopoDS::Wire(iter.Value()); TopoDS_Wire wire = TopoDS::Wire(iter.Value());
sfw->Load(wire); sfw->Load(wire);
sfw->FixReorder(); sfw->FixReorder();
@ -487,7 +501,7 @@ TopoDS_Shape BlockFix_UnionFaces::Perform(const TopoDS_Shape& Shape)
//======================================================================= //=======================================================================
//function : IsSameDomain //function : IsSameDomain
//purpose : //purpose :
//======================================================================= //=======================================================================
Standard_Boolean BlockFix_UnionFaces::IsSameDomain(const TopoDS_Face& aFace, Standard_Boolean BlockFix_UnionFaces::IsSameDomain(const TopoDS_Face& aFace,
@ -496,10 +510,10 @@ Standard_Boolean BlockFix_UnionFaces::IsSameDomain(const TopoDS_Face& aFace,
//checking the same handless //checking the same handless
TopLoc_Location L1, L2; TopLoc_Location L1, L2;
Handle(Geom_Surface) S1, S2; Handle(Geom_Surface) S1, S2;
S1 = BRep_Tool::Surface(aFace,L1); S1 = BRep_Tool::Surface(aFace,L1);
S2 = BRep_Tool::Surface(aCheckedFace,L2); S2 = BRep_Tool::Surface(aCheckedFace,L2);
if (S1 == S2 && L1 == L2) if (S1 == S2 && L1 == L2)
return true; return true;
@ -590,7 +604,7 @@ Standard_Boolean BlockFix_UnionFaces::IsSameDomain(const TopoDS_Face& aFace,
//======================================================================= //=======================================================================
//function : MovePCurves //function : MovePCurves
//purpose : //purpose :
//======================================================================= //=======================================================================
void BlockFix_UnionFaces::MovePCurves(TopoDS_Face& aTarget, void BlockFix_UnionFaces::MovePCurves(TopoDS_Face& aTarget,
@ -598,17 +612,17 @@ void BlockFix_UnionFaces::MovePCurves(TopoDS_Face& aTarget,
{ {
BRep_Builder B; BRep_Builder B;
for(TopExp_Explorer wexp(aSource,TopAbs_WIRE);wexp.More();wexp.Next()) { 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()); aTarget, Precision::Confusion());
sfw->FixReorder(); sfw->FixReorder();
Standard_Boolean isReoredFailed = sfw->StatusReorder ( ShapeExtend_FAIL ); Standard_Boolean isReoredFailed = sfw->StatusReorder ( ShapeExtend_FAIL );
sfw->FixEdgeCurves(); sfw->FixEdgeCurves();
if(isReoredFailed) if(isReoredFailed)
continue; continue;
sfw->FixShifted(); sfw->FixShifted();
sfw->FixDegenerated(); sfw->FixDegenerated();
// remove degenerated edges from not degenerated points // remove degenerated edges from not degenerated points
ShapeAnalysis_Edge sae; ShapeAnalysis_Edge sae;
Handle(ShapeExtend_WireData) sewd = sfw->WireData(); Handle(ShapeExtend_WireData) sewd = sfw->WireData();
@ -619,7 +633,7 @@ void BlockFix_UnionFaces::MovePCurves(TopoDS_Face& aTarget,
i--; i--;
} }
} }
TopoDS_Wire ResWire = sfw->Wire(); TopoDS_Wire ResWire = sfw->Wire();
B.Add(aTarget,ResWire); B.Add(aTarget,ResWire);
} }

View File

@ -18,7 +18,7 @@
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
// //
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
#ifndef _BlockFix_UnionFaces_HeaderFile #ifndef _BlockFix_UnionFaces_HeaderFile
#define _BlockFix_UnionFaces_HeaderFile #define _BlockFix_UnionFaces_HeaderFile
@ -28,10 +28,6 @@
#ifndef _Standard_Boolean_HeaderFile #ifndef _Standard_Boolean_HeaderFile
#include <Standard_Boolean.hxx> #include <Standard_Boolean.hxx>
#endif #endif
class TopoDS_Shape;
class TopoDS_Face;
#ifndef _Standard_HeaderFile #ifndef _Standard_HeaderFile
#include <Standard.hxx> #include <Standard.hxx>
#endif #endif
@ -39,63 +35,55 @@ class TopoDS_Face;
#include <Standard_Macro.hxx> #include <Standard_Macro.hxx>
#endif #endif
class BlockFix_UnionFaces { class TopoDS_Shape;
class TopoDS_Face;
class BlockFix_UnionFaces
{
public: 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);
}
void* operator new(size_t,void* anAddress) // Methods PUBLIC
{ //
return anAddress; Standard_EXPORT BlockFix_UnionFaces();
}
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;
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,
protected: const TopoDS_Face& aChekedFace) const;
Standard_EXPORT virtual void MovePCurves(TopoDS_Face& aTarget,
// Methods PROTECTED const TopoDS_Face& aSource) const;
//
// Fields PROTECTED
//
private: private:
// Fields PRIVATE
// Methods PRIVATE //
// Standard_Real myTolerance;
Standard_Integer myOptimumNbFaces;
// Fields PRIVATE
//
Standard_Real myTolerance;
}; };
// other Inline functions and methods (like "C++: function call" methods)
//
#endif #endif

View File

@ -286,41 +286,58 @@ Standard_Boolean GEOMAlgo_Tools::ProjectPointOnShape(const gp_Pnt& aP1,
gp_Pnt& aP2, gp_Pnt& aP2,
IntTools_Context& aCtx) IntTools_Context& aCtx)
{ {
Standard_Boolean bIsDone=Standard_False; Standard_Boolean bIsDone = Standard_False;
Standard_Real aT2; Standard_Real aT2;
TopAbs_ShapeEnum aType; TopAbs_ShapeEnum aType;
// //
aType=aS.ShapeType(); aType = aS.ShapeType();
switch(aType) { switch (aType)
case TopAbs_EDGE: { {
const TopoDS_Edge& aE2=TopoDS::Edge(aS); case TopAbs_EDGE:
// {
bIsDone=aCtx.ProjectPointOnEdge(aP1, aE2, aT2); cout << "$$$ case TopAbs_EDGE" << endl;
if (!bIsDone) { const TopoDS_Edge& aE2 = TopoDS::Edge(aS);
return bIsDone; //
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; break;
// //
case TopAbs_FACE: { case TopAbs_FACE:
const TopoDS_Face& aF2=TopoDS::Face(aS); {
GeomAPI_ProjectPointOnSurf& aProj=aCtx.ProjPS(aF2); const TopoDS_Face& aF2 = TopoDS::Face(aS);
// GeomAPI_ProjectPointOnSurf& aProj = aCtx.ProjPS(aF2);
aProj.Perform(aP1); //
bIsDone=aProj.IsDone(); aProj.Perform(aP1);
if (!bIsDone) { bIsDone = aProj.IsDone();
return bIsDone; if (!bIsDone) {
return bIsDone;
}
//
aP2 = aProj.NearestPoint();
} }
//
aP2=aProj.NearestPoint();
}
break; break;
// //
default: default:
break; // Err break; // Err
} }
return bIsDone; return bIsDone;
} }
//======================================================================= //=======================================================================

View File

@ -3527,6 +3527,10 @@ Please, select face, shell or solid and try again</translation>
<source>GEOM_REMOVE_EXTRA_EDGES</source> <source>GEOM_REMOVE_EXTRA_EDGES</source>
<translation>Object to remove extra edges</translation> <translation>Object to remove extra edges</translation>
</message> </message>
<message>
<source>GEOM_RMEE_UNION_FACES</source>
<translation>Union faces, laying on common surface</translation>
</message>
<message> <message>
<source>REMOVE_EXTRA_EDGES_NEW_OBJ_NAME</source> <source>REMOVE_EXTRA_EDGES_NEW_OBJ_NAME</source>
<translation>NoExtraEdges</translation> <translation>NoExtraEdges</translation>

View File

@ -18,7 +18,7 @@
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
// //
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
#include <Standard_Stream.hxx> #include <Standard_Stream.hxx>
#include <BRepOffsetAPI_MakeFilling.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 // 1. Improve solids with seam and/or degenerated edges
BlockFix_BlockFixAPI aTool; BlockFix_BlockFixAPI aTool;
//aTool.Tolerance() = toler; //aTool.Tolerance() = toler;
aTool.OptimumNbFaces() = aCI.GetOptimumNbFaces();
aTool.SetShape(aBlockOrComp); aTool.SetShape(aBlockOrComp);
aTool.Perform(); aTool.Perform();

View File

@ -19,8 +19,8 @@
// //
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // 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" #include "GEOM_Function.hxx"
#define TRSF_ORIGIN 1 #define TRSF_ORIGIN 1
@ -32,6 +32,8 @@
#define TRSF_FACE_2_V 6 #define TRSF_FACE_2_V 6
#define TRSF_NBITER_V 7 #define TRSF_NBITER_V 7
#define TRSF_NB_FACES 8
class GEOMImpl_IBlockTrsf class GEOMImpl_IBlockTrsf
{ {
public: public:
@ -49,6 +51,8 @@ class GEOMImpl_IBlockTrsf
void SetNbIterU (int theNbIter) { _func->SetInteger(TRSF_NBITER_U, theNbIter); } void SetNbIterU (int theNbIter) { _func->SetInteger(TRSF_NBITER_U, theNbIter); }
void SetNbIterV (int theNbIter) { _func->SetInteger(TRSF_NBITER_V, 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 GetFace1U () { return _func->GetInteger(TRSF_FACE_1_U); }
int GetFace2U () { return _func->GetInteger(TRSF_FACE_2_U); } int GetFace2U () { return _func->GetInteger(TRSF_FACE_2_U); }
int GetFace1V () { return _func->GetInteger(TRSF_FACE_1_V); } 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 GetNbIterU() { return _func->GetInteger(TRSF_NBITER_U); }
int GetNbIterV() { return _func->GetInteger(TRSF_NBITER_V); } int GetNbIterV() { return _func->GetInteger(TRSF_NBITER_V); }
int GetOptimumNbFaces() { return _func->GetInteger(TRSF_NB_FACES); }
private: private:
Handle(GEOM_Function) _func; Handle(GEOM_Function) _func;

View File

@ -18,7 +18,7 @@
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
// //
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
#ifdef WNT #ifdef WNT
#pragma warning( disable:4786 ) #pragma warning( disable:4786 )
#endif #endif
@ -2309,7 +2309,8 @@ Standard_Boolean GEOMImpl_IBlocksOperations::CheckCompoundOfBlocks
*/ */
//============================================================================= //=============================================================================
Handle(GEOM_Object) GEOMImpl_IBlocksOperations::RemoveExtraEdges Handle(GEOM_Object) GEOMImpl_IBlocksOperations::RemoveExtraEdges
(Handle(GEOM_Object) theObject) (Handle(GEOM_Object) theObject,
const Standard_Integer theOptimumNbFaces)
{ {
SetErrorCode(KO); SetErrorCode(KO);
@ -2330,6 +2331,7 @@ Handle(GEOM_Object) GEOMImpl_IBlocksOperations::RemoveExtraEdges
GEOMImpl_IBlockTrsf aTI (aFunction); GEOMImpl_IBlockTrsf aTI (aFunction);
aTI.SetOriginal(aLastFunction); aTI.SetOriginal(aLastFunction);
aTI.SetOptimumNbFaces(theOptimumNbFaces);
//Compute the fixed shape //Compute the fixed shape
try { try {
@ -2382,6 +2384,7 @@ Handle(GEOM_Object) GEOMImpl_IBlocksOperations::CheckAndImprove
GEOMImpl_IBlockTrsf aTI (aFunction); GEOMImpl_IBlockTrsf aTI (aFunction);
aTI.SetOriginal(aLastFunction); aTI.SetOriginal(aLastFunction);
aTI.SetOptimumNbFaces(6);
//Compute the fixed shape //Compute the fixed shape
try { try {

View File

@ -18,7 +18,7 @@
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
// //
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
#ifndef _GEOMImpl_IBlocksOperations_HXX_ #ifndef _GEOMImpl_IBlocksOperations_HXX_
#define _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, Standard_EXPORT TCollection_AsciiString PrintBCErrors (Handle(GEOM_Object) theCompound,
const std::list<BCError>& theErrors); 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); Standard_EXPORT Handle(GEOM_Object) CheckAndImprove (Handle(GEOM_Object) theCompound);

View File

@ -687,7 +687,9 @@ char* GEOM_IBlocksOperations_i::PrintBCErrors
* RemoveExtraEdges * 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; GEOM::GEOM_Object_var aGEOMObject;
@ -699,8 +701,7 @@ GEOM::GEOM_Object_ptr GEOM_IBlocksOperations_i::RemoveExtraEdges (GEOM::GEOM_Obj
if (aShape.IsNull()) return aGEOMObject._retn(); if (aShape.IsNull()) return aGEOMObject._retn();
//Get the result //Get the result
Handle(GEOM_Object) anObject = Handle(GEOM_Object) anObject = GetOperations()->RemoveExtraEdges(aShape, theOptimumNbFaces);
GetOperations()->RemoveExtraEdges(aShape);
if (!GetOperations()->IsDone() || anObject.IsNull()) if (!GetOperations()->IsDone() || anObject.IsNull())
return aGEOMObject._retn(); return aGEOMObject._retn();

View File

@ -18,7 +18,7 @@
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
// //
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
#ifndef _GEOM_IBlocksOperations_i_HeaderFile #ifndef _GEOM_IBlocksOperations_i_HeaderFile
#define _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, char* PrintBCErrors (GEOM::GEOM_Object_ptr theCompound,
const GEOM::GEOM_IBlocksOperations::BCErrors& theErrors); 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); GEOM::GEOM_Object_ptr CheckAndImprove (GEOM::GEOM_Object_ptr theCompound);

View File

@ -3407,12 +3407,16 @@ class geompyDC(GEOM._objref_GEOM_Gen):
# Unite faces and edges, sharing one surface. It means that # Unite faces and edges, sharing one surface. It means that
# this faces must have references to one C++ surface object (handle). # this faces must have references to one C++ surface object (handle).
# @param theShape The compound or single solid to remove irregular edges from. # @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. # @return Improved shape.
# #
# @ref swig_RemoveExtraEdges "Example" # @ref swig_RemoveExtraEdges "Example"
def RemoveExtraEdges(self,theShape): def RemoveExtraEdges(self,theShape,theOptimumNbFaces=-1):
# Example: see GEOM_TestOthers.py # Example: see GEOM_TestOthers.py
anObj = self.BlocksOp.RemoveExtraEdges(theShape) anObj = self.BlocksOp.RemoveExtraEdges(theShape,theOptimumNbFaces)
RaiseIfFailed("RemoveExtraEdges", self.BlocksOp) RaiseIfFailed("RemoveExtraEdges", self.BlocksOp)
return anObj return anObj

View File

@ -22,7 +22,7 @@
// GEOM RepairGUI : GUI for Geometry component // GEOM RepairGUI : GUI for Geometry component
// File : RepairGUI_RemoveExtraEdgesDlg.cxx // File : RepairGUI_RemoveExtraEdgesDlg.cxx
// Author : Michael Zorin, Open CASCADE S.A.S. // Author : Michael Zorin, Open CASCADE S.A.S.
//
#include "RepairGUI_RemoveExtraEdgesDlg.h" #include "RepairGUI_RemoveExtraEdgesDlg.h"
#include <DlgRef.h> #include <DlgRef.h>
@ -63,12 +63,15 @@ RepairGUI_RemoveExtraEdgesDlg::RepairGUI_RemoveExtraEdgesDlg( GeometryGUI* theGe
mainFrame()->RadioButton3->setAttribute( Qt::WA_DeleteOnClose ); mainFrame()->RadioButton3->setAttribute( Qt::WA_DeleteOnClose );
mainFrame()->RadioButton3->close(); mainFrame()->RadioButton3->close();
GroupPoints = new DlgRef_1Sel( centralWidget() ); GroupPoints = new DlgRef_1Sel1Check( centralWidget() );
GroupPoints->GroupBox1->setTitle( tr( "GEOM_REMOVE_EXTRA_EDGES" ) ); GroupPoints->GroupBox1->setTitle( tr( "GEOM_REMOVE_EXTRA_EDGES" ) );
GroupPoints->TextLabel1->setText( tr( "GEOM_SELECTED_SHAPE" ) ); GroupPoints->TextLabel1->setText( tr( "GEOM_SELECTED_SHAPE" ) );
GroupPoints->PushButton1->setIcon( image1 ); GroupPoints->PushButton1->setIcon( image1 );
GroupPoints->LineEdit1->setReadOnly( true ); GroupPoints->LineEdit1->setReadOnly( true );
GroupPoints->CheckButton1->setText( tr( "GEOM_RMEE_UNION_FACES" ) );
QVBoxLayout* layout = new QVBoxLayout( centralWidget() ); QVBoxLayout* layout = new QVBoxLayout( centralWidget() );
layout->setMargin( 0 ); layout->setSpacing( 6 ); layout->setMargin( 0 ); layout->setSpacing( 6 );
layout->addWidget( GroupPoints ); layout->addWidget( GroupPoints );
@ -101,6 +104,8 @@ void RepairGUI_RemoveExtraEdgesDlg::Init()
myOkObject = false; myOkObject = false;
GroupPoints->CheckButton1->setChecked( false );
activateSelection(); activateSelection();
mainFrame()->GroupBoxPublish->show(); mainFrame()->GroupBoxPublish->show();
@ -278,11 +283,15 @@ bool RepairGUI_RemoveExtraEdgesDlg::isValid( QString& msg )
bool RepairGUI_RemoveExtraEdgesDlg::execute( ObjectList& objects ) bool RepairGUI_RemoveExtraEdgesDlg::execute( ObjectList& objects )
{ {
GEOM::GEOM_Object_var anObj; 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())
if ( !anObj->_is_nil() ) nbFacesOptimum = 0; // 0 means union all faces, that possible
objects.push_back( anObj._retn() ); anObj = GEOM::GEOM_IBlocksOperations::_narrow(getOperation())->RemoveExtraEdges
(myObject, nbFacesOptimum);
if (!anObj->_is_nil())
objects.push_back(anObj._retn());
return true; return true;
} }

View File

@ -19,16 +19,16 @@
// //
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
// //
// GEOM GEOMGUI : GUI for Geometry component // GEOM GEOMGUI : GUI for Geometry component
// File : RepairGUI_RemoveExtraEdgesDlg.h // File : RepairGUI_RemoveExtraEdgesDlg.h
// Author : Michael ZORIN, Open CASCADE S.A.S. // Author : Michael ZORIN, Open CASCADE S.A.S.
//
#ifndef REPAIRGUI_REMOVEEXTRAEDGESDLG_H #ifndef REPAIRGUI_REMOVEEXTRAEDGESDLG_H
#define REPAIRGUI_REMOVEEXTRAEDGESDLG_H #define REPAIRGUI_REMOVEEXTRAEDGESDLG_H
#include <GEOMBase_Skeleton.h> #include <GEOMBase_Skeleton.h>
class DlgRef_1Sel; class DlgRef_1Sel1Check;
//================================================================================= //=================================================================================
// class : RepairGUI_RemoveExtraEdgesDlg // class : RepairGUI_RemoveExtraEdgesDlg
@ -58,7 +58,7 @@ private:
GEOM::GEOM_Object_var myObject; GEOM::GEOM_Object_var myObject;
bool myOkObject; bool myOkObject;
DlgRef_1Sel* GroupPoints; DlgRef_1Sel1Check* GroupPoints;
private slots: private slots:
void ClickOnOk(); void ClickOnOk();