Back to index

salome-geom  6.5.0
Public Member Functions | Protected Attributes | Private Member Functions | Private Attributes
ShHealOper_FillHoles Class Reference

Class ShHealOper_FillHoles. More...

#include <ShHealOper_FillHoles.hxx>

Inheritance diagram for ShHealOper_FillHoles:
Inheritance graph
Collaboration diagram for ShHealOper_FillHoles:
Collaboration graph

List of all members.

Public Member Functions

Standard_EXPORT ShHealOper_FillHoles ()
Standard_EXPORT ShHealOper_FillHoles (const TopoDS_Shape &theShape)
virtual Standard_EXPORT void Init (const TopoDS_Shape &theShape)
Standard_EXPORT void InitParameters (Standard_Integer theDegree=3, Standard_Integer theNbPtsOnCur=5, Standard_Integer theNbIter=12, Standard_Real theTol3d=0.0001, Standard_Real theTol2d=1.e-5, Standard_Real theTolAng=0.01, Standard_Real theTolCrv=0.01, Standard_Integer theMaxDeg=8, Standard_Integer theMaxSeg=9)
Standard_EXPORT Standard_Boolean Fill ()
Standard_EXPORT Standard_Boolean Fill (const TopTools_SequenceOfShape &theFillShapes)
const TopoDS_Shape & GetResultShape () const
Standard_Boolean GetModifiedShape (const TopoDS_Shape &theOldShape, TopoDS_Shape &theNewShape) const
Standard_Boolean IsDone () const
void SetContext (Handle(ShapeBuild_ReShape)&theContext)
 Handle (ShapeBuild_ReShape) Context()
Standard_Integer GetErrorStatus ()

Protected Attributes

TopoDS_Shape myInitShape
TopoDS_Shape myResultShape
Standard_Boolean myDone
ShHealOper_Error myErrorStatus

Private Member Functions

Standard_Boolean prepareWires (const TopTools_SequenceOfShape &theFillShapes, Handle(TopTools_HSequenceOfShape)&theSeqWires)
 Handle (Geom_Surface) buildSurface(const TopoDS_Wire &theWire
 Handle (TColGeom2d_HArray1OfCurve)&theCurves2d
 Handle (TColStd_HArray1OfInteger)&theOrders
 Handle (TColStd_HArray1OfInteger)&theSenses)
Standard_Boolean addFace (const Handle(Geom_Surface)&theSurf, const TopoDS_Wire &theWire, const Handle(TColGeom2d_HArray1OfCurve)&theCurves2d, const Handle(TColStd_HArray1OfInteger)&theOrders, const Handle(TColStd_HArray1OfInteger)&theSenses)
void getResShape (const TopoDS_Shape &theAddShape, const TopTools_IndexedMapOfShape &aMapParent, const Standard_Boolean theHasShell)

Private Attributes

TopTools_IndexedDataMapOfShapeListOfShape myEdgeShells
TopTools_IndexedDataMapOfShapeListOfShape myEdgeComps
TopTools_IndexedDataMapOfShapeListOfShape myEdgeFaces
Standard_Integer myNbPtsOnCur
Standard_Integer myNbIter
Standard_Integer myDegree
Standard_Real myTol2d
Standard_Real myTol3d
Standard_Real myTolAng
Standard_Real myTolCrv
Standard_Integer myMaxDeg
Standard_Integer myMaxSeg

Detailed Description

Class ShHealOper_FillHoles.

Definition at line 45 of file ShHealOper_FillHoles.hxx.

Constructor & Destructor Documentation

Definition at line 71 of file ShHealOper_FillHoles.cxx.

Here is the call graph for this function:

ShHealOper_FillHoles::ShHealOper_FillHoles ( const TopoDS_Shape &  theShape)

Definition at line 80 of file ShHealOper_FillHoles.cxx.


Here is the call graph for this function:

Member Function Documentation

Standard_Boolean ShHealOper_FillHoles::addFace ( const Handle(Geom_Surface)&  theSurf,
const TopoDS_Wire &  theWire,
const Handle(TColGeom2d_HArray1OfCurve)&  theCurves2d,
const Handle(TColStd_HArray1OfInteger)&  theOrders,
const Handle(TColStd_HArray1OfInteger)&  theSenses 
) [private]

Definition at line 333 of file ShHealOper_FillHoles.cxx.

#if OCC_VERSION_LARGE > 0x06050100 // for OCC-6.5.2 and higher version
  BRepBuilderAPI_MakeFace aMakeFace (theSurf, Precision::Confusion());
  BRepBuilderAPI_MakeFace aMakeFace (theSurf);
  TopoDS_Face aFace = aMakeFace.Face();

  TopoDS_Wire aWire;
  BRep_Builder aB;

  TopTools_IndexedMapOfShape aMapParent;
  Standard_Integer aInd = 1;
  Standard_Boolean hasShell = Standard_False;
  TopoDS_Iterator aIter(theWire);
  for ( ; aIter.More(); aIter.Next(), aInd++) {
    TopoDS_Edge anEdge = TopoDS::Edge (aIter.Value());
    Standard_Real aF, aL;
    BRep_Tool::Range (anEdge, aF, aL);
    TopLoc_Location aLoc;
    aB.UpdateEdge (anEdge, theCurves2d->Value (aInd),aFace, 0.);

    aB.Range (anEdge, aFace, aF, aL);

    // Set orientation of the edge: orientation should be changed
    // if its orientation does not make sence with curve orientation
    // recommended by GeomPlate
    if ((anEdge.Orientation() == TopAbs_FORWARD) ==
        (theSenses->Value (theOrders->Value (aInd)) == 1)) {
    aB.Add (aWire, anEdge);
    TopoDS_Shape aParent;

    if(myEdgeFaces.FindFromKey(anEdge).Extent() >1)

    if(myEdgeShells.Contains(anEdge)) {
      if(myEdgeShells.FindFromKey(anEdge).Extent()) {
       aParent = myEdgeShells.FindFromKey(anEdge).First();
       hasShell = Standard_True;
    else if(myEdgeComps.Contains(anEdge)) {
      if(myEdgeComps.FindFromKey(anEdge).Extent()) {
        aParent = myEdgeComps.FindFromKey(anEdge).First();

  Handle(ShapeFix_Face) aSff = new ShapeFix_Face(aFace);
  if(aSff->Status(ShapeExtend_FAIL)) {
    myErrorStatus = ShHealOper_ErrorExecution;
    return Standard_False;
  //theFace = aSff->Face();
  TopoDS_Shape aResShape = aSff->Result();
  return Standard_True;

Here is the call graph for this function:

Here is the caller graph for this function:

Standard_Boolean ShHealOper_FillHoles::Fill ( )

Definition at line 127 of file ShHealOper_FillHoles.cxx.

  ShapeAnalysis_FreeBounds sab(myInitShape);
  TopoDS_Compound aCompClosed = sab.GetClosedWires();
  TopoDS_Compound aCompOpen = sab.GetOpenWires();
  TopTools_SequenceOfShape aFillWires;
  if(!aCompClosed.IsNull()) {
    TopoDS_Iterator aIt(aCompClosed);

    for( ; aIt.More(); aIt.Next())
  if(!aCompOpen.IsNull()) {
    TopoDS_Iterator aIt(aCompOpen);
    for(  ; aIt.More(); aIt.Next())

  TopExp_Explorer aExp(myInitShape,TopAbs_EDGE,TopAbs_FACE);

  for( ; aExp.More(); aExp.Next())

  return Fill(aFillWires);

Here is the caller graph for this function:

Standard_Boolean ShHealOper_FillHoles::Fill ( const TopTools_SequenceOfShape &  theFillShapes)

Definition at line 157 of file ShHealOper_FillHoles.cxx.

  myDone = Standard_False;
  myErrorStatus = ShHealOper_NotError;
  if(myInitShape.IsNull()) {
    myErrorStatus = ShHealOper_InvalidParameters;
    return myDone;
  if(!theFillShapes.Length()) {
    return myDone;

  Handle(TopTools_HSequenceOfShape) aSeqWires = new TopTools_HSequenceOfShape;
  if(!prepareWires(theFillShapes,aSeqWires)) {
    myErrorStatus = ShHealOper_InvalidParameters;
    return myDone;

  myResultShape = myInitShape;
  Standard_Integer i =1;
  for( ; i <= aSeqWires->Length(); i++) {
    TopoDS_Wire aWire = TopoDS::Wire(aSeqWires->Value(i));
    Handle(TColGeom2d_HArray1OfCurve) aCurves2d;
    Handle(TColStd_HArray1OfInteger) aOrders;
    Handle(TColStd_HArray1OfInteger) aSenses;
    Handle(Geom_Surface) aSurf = buildSurface(aWire,aCurves2d,aOrders,aSenses);
      myErrorStatus = ShHealOper_ErrorExecution;
      myDone = (addFace(aSurf,aWire,aCurves2d,aOrders,aSenses) || myDone);
    myResultShape = myContext->Apply(myResultShape);
  return myDone;

Here is the call graph for this function:

Standard_Integer ShHealOper_Tool::GetErrorStatus ( ) [inline, inherited]

Definition at line 90 of file ShHealOper_Tool.hxx.

    return myErrorStatus;

Here is the caller graph for this function:

Standard_Boolean ShHealOper_Tool::GetModifiedShape ( const TopoDS_Shape &  theOldShape,
TopoDS_Shape &  theNewShape 
) const [inline, inherited]

Definition at line 64 of file ShHealOper_Tool.hxx.

    theNewShape = myContext->Apply(theOldShape);
    return (!theNewShape.IsSame(theOldShape));
void ShHealOper_FillHoles::getResShape ( const TopoDS_Shape &  theAddShape,
const TopTools_IndexedMapOfShape &  aMapParent,
const Standard_Boolean  theHasShell 
) [private]

Definition at line 415 of file ShHealOper_FillHoles.cxx.

  BRep_Builder aB;

  if(!aMapParent.Extent()) {
    TopoDS_Compound aComp;
    TopoDS_Shape aresShape = myContext->Apply(myResultShape);
    myResultShape = aComp;
    return ;
  Standard_Boolean anhasShell = theHasShell;
  TopoDS_Shell aTmpShell;
  TopTools_SequenceOfShape aseqShells;
  if(anhasShell) {
    Standard_Integer i =1;
    for( ; i <= aMapParent.Extent(); i++) {
      TopoDS_Shape aParShape = myContext->Apply(aMapParent.FindKey(i));
      if(aParShape.ShapeType() == TopAbs_SHELL) {
        TopExp_Explorer aexp(aParShape,TopAbs_FACE);
        for( ; aexp.More(); aexp.Next())
    anhasShell = aseqShells.Length();
  if(anhasShell) {
    Handle(ShapeFix_Shell) asfs = new ShapeFix_Shell;
    TopoDS_Shape anshape = asfs->Shape();
    Standard_Integer i =2;
    for( ; i<= aseqShells.Length(); i++)
  else {
    TopoDS_Compound aComp;
    TopoDS_Shape oldshape = myContext->Apply(aMapParent.FindKey(1));
    TopoDS_Iterator aIt(oldshape);
    for( ; aIt.More(); aIt.Next())
    myContext->Replace( oldshape,aComp);

Here is the call graph for this function:

Here is the caller graph for this function:

const TopoDS_Shape& ShHealOper_Tool::GetResultShape ( ) const [inline, inherited]

Definition at line 57 of file ShHealOper_Tool.hxx.

    return myResultShape;


Here is the caller graph for this function:

ShHealOper_FillHoles::Handle ( Geom_Surface  ) const [private]

Here is the caller graph for this function:

ShHealOper_FillHoles::Handle ( TColGeom2d_HArray1OfCurve  ) [private]
ShHealOper_FillHoles::Handle ( TColStd_HArray1OfInteger  ) [private]
ShHealOper_FillHoles::Handle ( TColStd_HArray1OfInteger  ) [private]
ShHealOper_Tool::Handle ( ShapeBuild_ReShape  ) [inline, inherited]

Definition at line 84 of file ShHealOper_Tool.hxx.

    return myContext;

Here is the caller graph for this function:

void ShHealOper_FillHoles::Init ( const TopoDS_Shape &  theShape) [virtual]

Reimplemented from ShHealOper_Tool.

Definition at line 90 of file ShHealOper_FillHoles.cxx.

  TopExp::MapShapesAndAncestors( myInitShape, TopAbs_EDGE,TopAbs_SHELL   , myEdgeShells);
  TopExp::MapShapesAndAncestors ( myInitShape, TopAbs_EDGE,TopAbs_COMPOUND, myEdgeComps );

  TopExp::MapShapesAndAncestors ( myInitShape, TopAbs_EDGE,TopAbs_FACE, myEdgeFaces );

Here is the caller graph for this function:

void ShHealOper_FillHoles::InitParameters ( Standard_Integer  theDegree = 3,
Standard_Integer  theNbPtsOnCur = 5,
Standard_Integer  theNbIter = 12,
Standard_Real  theTol3d = 0.0001,
Standard_Real  theTol2d = 1.e-5,
Standard_Real  theTolAng = 0.01,
Standard_Real  theTolCrv = 0.01,
Standard_Integer  theMaxDeg = 8,
Standard_Integer  theMaxSeg = 9 

Definition at line 103 of file ShHealOper_FillHoles.cxx.

  myNbPtsOnCur = theNbPtsOnCur;
  myNbIter = theNbIter;
  myDegree =theDegree;
  myTol2d = theTol2d;
  myTol3d = theTol3d;
  myTolAng = theTolAng;
  myTolCrv = theTolCrv;
  myMaxDeg = theMaxDeg;
  myMaxSeg =theMaxSeg;

Here is the caller graph for this function:

Standard_Boolean ShHealOper_Tool::IsDone ( ) const [inline, inherited]

Definition at line 72 of file ShHealOper_Tool.hxx.

    return myDone;
Standard_Boolean ShHealOper_FillHoles::prepareWires ( const TopTools_SequenceOfShape &  theFillShapes,
Handle(TopTools_HSequenceOfShape)&  theSeqWires 
) [private]

Definition at line 211 of file ShHealOper_FillHoles.cxx.

  Handle(TopTools_HSequenceOfShape) aSeqEdges = new TopTools_HSequenceOfShape;
  Standard_Integer i =1;
  for( ; i <= theFillShapes.Length(); i++) {
    TopExp_Explorer aExp;
    for (aExp.Init (theFillShapes.Value(i),TopAbs_WIRE); aExp.More(); aExp.Next()) {
      TopoDS_Iterator aIt(aExp.Current());
      Standard_Boolean isAdd = Standard_True;
      for( ; aIt.More() && isAdd; aIt.Next()) {
          isAdd =  (myEdgeFaces.FindFromKey(aIt.Value()).Extent() <2);
    for (aExp.Init (theFillShapes.Value(i),TopAbs_EDGE, TopAbs_WIRE); aExp.More(); aExp.Next()) {
      if (!BRep_Tool::Degenerated (TopoDS::Edge (aExp.Current())))
        if(myEdgeFaces.Contains(aExp.Current()) && myEdgeFaces.FindFromKey(aExp.Current()).Extent() >1)

    Standard_Real aTol = 0.;
    Standard_Boolean aShared = Standard_True;
    Handle(TopTools_HSequenceOfShape) aTmpWires = new TopTools_HSequenceOfShape;
    ShapeAnalysis_FreeBounds::ConnectEdgesToWires(aSeqEdges, aTol, aShared, aTmpWires);
    Handle(TopTools_HSequenceOfShape) anWiresClosed = new TopTools_HSequenceOfShape,
    anWiresOpen   = new TopTools_HSequenceOfShape;
    ShapeAnalysis_FreeBounds::SplitWires(aTmpWires, aTol, aShared, anWiresClosed, anWiresOpen);

    for (i = 1; i <= anWiresClosed->Length(); i++)
      theSeqWires->Append (anWiresClosed->Value (i));
    for (i = 1; i <= anWiresOpen->Length(); i++)
      theSeqWires->Append (anWiresOpen->Value (i));

  for( i =1; i <= theSeqWires->Length(); i++) {
    TopoDS_Wire aWire = TopoDS::Wire(theSeqWires->Value(i));

    TopoDS_Iterator aIt(aWire);
    Standard_Integer ne =0;
    TopoDS_Edge ae;
    for( ; aIt.More(); aIt.Next(), ne++)
      ae = TopoDS::Edge(aIt.Value());
    if((ne == 1) && ( !isCircle(ae))) {
  return (theSeqWires->Length());

Here is the call graph for this function:

Here is the caller graph for this function:

void ShHealOper_Tool::SetContext ( Handle(ShapeBuild_ReShape)&  theContext) [inline, inherited]

Definition at line 78 of file ShHealOper_Tool.hxx.

    myContext = theContext;

Member Data Documentation

Standard_Integer ShHealOper_FillHoles::myDegree [private]

Definition at line 105 of file ShHealOper_FillHoles.hxx.

Standard_Boolean ShHealOper_Tool::myDone [protected, inherited]

Definition at line 100 of file ShHealOper_Tool.hxx.

TopTools_IndexedDataMapOfShapeListOfShape ShHealOper_FillHoles::myEdgeComps [private]

Definition at line 101 of file ShHealOper_FillHoles.hxx.

TopTools_IndexedDataMapOfShapeListOfShape ShHealOper_FillHoles::myEdgeFaces [private]

Definition at line 102 of file ShHealOper_FillHoles.hxx.

TopTools_IndexedDataMapOfShapeListOfShape ShHealOper_FillHoles::myEdgeShells [private]

Definition at line 99 of file ShHealOper_FillHoles.hxx.

Definition at line 101 of file ShHealOper_Tool.hxx.

TopoDS_Shape ShHealOper_Tool::myInitShape [protected, inherited]

Definition at line 98 of file ShHealOper_Tool.hxx.

Standard_Integer ShHealOper_FillHoles::myMaxDeg [private]

Definition at line 110 of file ShHealOper_FillHoles.hxx.

Standard_Integer ShHealOper_FillHoles::myMaxSeg [private]

Definition at line 111 of file ShHealOper_FillHoles.hxx.

Standard_Integer ShHealOper_FillHoles::myNbIter [private]

Definition at line 104 of file ShHealOper_FillHoles.hxx.

Standard_Integer ShHealOper_FillHoles::myNbPtsOnCur [private]

Definition at line 103 of file ShHealOper_FillHoles.hxx.

TopoDS_Shape ShHealOper_Tool::myResultShape [protected, inherited]

Definition at line 99 of file ShHealOper_Tool.hxx.

Standard_Real ShHealOper_FillHoles::myTol2d [private]

Definition at line 106 of file ShHealOper_FillHoles.hxx.

Standard_Real ShHealOper_FillHoles::myTol3d [private]

Definition at line 107 of file ShHealOper_FillHoles.hxx.

Standard_Real ShHealOper_FillHoles::myTolAng [private]

Definition at line 108 of file ShHealOper_FillHoles.hxx.

Standard_Real ShHealOper_FillHoles::myTolCrv [private]

Definition at line 109 of file ShHealOper_FillHoles.hxx.

The documentation for this class was generated from the following files: