Back to index

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

Class ShHealOper_RemoveFace. More...

#include <ShHealOper_RemoveFace.hxx>

Inheritance diagram for ShHealOper_RemoveFace:
Inheritance graph
[legend]
Collaboration diagram for ShHealOper_RemoveFace:
Collaboration graph
[legend]

List of all members.

Public Member Functions

Standard_EXPORT ShHealOper_RemoveFace ()
Standard_EXPORT ShHealOper_RemoveFace (const TopoDS_Shape &theShape)
virtual Standard_EXPORT void Init (const TopoDS_Shape &theShape)
Standard_EXPORT Standard_Boolean Perform ()
Standard_EXPORT Standard_Boolean Perform (const TopTools_SequenceOfShape &theRemovedFaces)
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 Member Functions

 Handle (ShapeBuild_ReShape) myContext

Protected Attributes

TopoDS_Shape myInitShape
TopoDS_Shape myResultShape
Standard_Boolean myDone
ShHealOper_Error myErrorStatus

Private Member Functions

Standard_Boolean removeFaces (const TopoDS_Shape &theShape, TopoDS_Shape &theNewShape)
Standard_Boolean removeFaces (const TopoDS_Solid &theShape, TopoDS_Shape &theNewShape)
Standard_Boolean removeFaces (const TopoDS_Shell &theShell, TopoDS_Shape &theNewShape)
Standard_Boolean isReplace (const TopoDS_Shape &theOldShape, TopoDS_Shape &theNewShape)
void removePCurve (const TopoDS_Face &theFace)
Standard_Boolean isManifold (const TopoDS_Shell &aShell)

Private Attributes

TopTools_MapOfShape myMapFaces
TopTools_IndexedDataMapOfShapeListOfShape myMapEdgesFace

Detailed Description

Class ShHealOper_RemoveFace.

Definition at line 42 of file ShHealOper_RemoveFace.hxx.


Constructor & Destructor Documentation

Definition at line 56 of file ShHealOper_RemoveFace.cxx.

                                              :
       ShHealOper_Tool()
{
}
ShHealOper_RemoveFace::ShHealOper_RemoveFace ( const TopoDS_Shape &  theShape)

Definition at line 65 of file ShHealOper_RemoveFace.cxx.

{
  Init(theShape);
}

Here is the call graph for this function:


Member Function Documentation

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));
  }
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_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:

ShHealOper_Tool::Handle ( ShapeBuild_ReShape  ) [protected, inherited]
void ShHealOper_RemoveFace::Init ( const TopoDS_Shape &  theShape) [virtual]

Reimplemented from ShHealOper_Tool.

Definition at line 75 of file ShHealOper_RemoveFace.cxx.

{
  //myDone = Standard_False;
  //myInitShape = theShape;
  //myContext->Apply(myInitShape);
  ShHealOper_Tool::Init(theShape);
  myMapEdgesFace.Clear();
  TopExp::MapShapesAndAncestors(theShape,TopAbs_EDGE,TopAbs_FACE,myMapEdgesFace);
}

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_RemoveFace::isManifold ( const TopoDS_Shell &  aShell) [private]

Definition at line 278 of file ShHealOper_RemoveFace.cxx.

{
  Standard_Boolean IsManifold = Standard_True;
  TopExp_Explorer aExp(aShell,TopAbs_EDGE);
  for( ; aExp.More() && IsManifold; aExp.Next()) {
    const TopTools_ListOfShape& als = myMapEdgesFace.FindFromKey(aExp.Current());
    IsManifold = (als.Extent() <=2 ); 
  }
  return IsManifold;
}

Here is the caller graph for this function:

Standard_Boolean ShHealOper_RemoveFace::isReplace ( const TopoDS_Shape &  theOldShape,
TopoDS_Shape &  theNewShape 
) [private]

Definition at line 363 of file ShHealOper_RemoveFace.cxx.

{
  
  Standard_Boolean isChange = Standard_False;
  TopTools_SequenceOfShape aSeqShapes;
  if(theShape.ShapeType() == TopAbs_COMPOUND || theShape.ShapeType() == TopAbs_COMPSOLID ||
     theShape.ShapeType() == TopAbs_SOLID) {
    TopoDS_Iterator aEs(theShape);
    for( ; aEs.More(); aEs.Next()) {
      TopoDS_Shape aNewShell = aEs.Value();
      if(aNewShell.ShapeType()!= TopAbs_SHELL) {
        aSeqShapes.Append(aNewShell);
        continue;
      }
      TopoDS_Shape as = getResultShell(TopoDS::Shell(aNewShell));
      isChange = (as.IsNull() || (as.ShapeType() == TopAbs_FACE));
      if(!as.IsNull()) {
        aSeqShapes.Append(as);
      }
    }
  }
  else if(theShape.ShapeType() == TopAbs_SHELL) {
    TopoDS_Shape aSh = getResultShell(TopoDS::Shell(theShape));
    isChange = (aSh.IsNull() || (aSh.ShapeType() == TopAbs_FACE));
    if(!aSh.IsNull())
      aSeqShapes.Append(aSh);
  }
  else aSeqShapes.Append(theShape);

  if(aSeqShapes.IsEmpty())
    return Standard_True;

  if(isChange) {
    if(aSeqShapes.Length() == 1)
      theNewShape = aSeqShapes.Value(1);
    else if (aSeqShapes.Length() > 1) {
      TopoDS_Compound aComp1;
      BRep_Builder aBB;
      aBB.MakeCompound(aComp1);
      Standard_Integer kk =1;
      for( ; kk <=  aSeqShapes.Length(); kk++)
        aBB.Add(aComp1,aSeqShapes.Value(kk));
      if(aSeqShapes.Length())
        theNewShape = aComp1;
    }
  }
  else
    theNewShape = theShape;
  return isChange;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Standard_Boolean ShHealOper_RemoveFace::Perform ( )

Definition at line 89 of file ShHealOper_RemoveFace.cxx.

{
  myDone = Standard_False;
  myErrorStatus = ShHealOper_NotError;
  if(myInitShape.IsNull()) {
    myErrorStatus = ShHealOper_InvalidParameters;
    return myDone;
  }
  TopExp_Explorer aExp(myInitShape,TopAbs_FACE);
  for( ; aExp.More(); aExp.Next()) {
    removePCurve(TopoDS::Face(aExp.Current()));
    myContext->Remove(aExp.Current());
    myDone = Standard_True;
  }
  if(myDone) {
    TopoDS_Shape aNewShape = myContext->Apply(myInitShape);
    isReplace(aNewShape,myResultShape);
    myContext->Replace(aNewShape,myResultShape);
  }
  return myDone;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Standard_Boolean ShHealOper_RemoveFace::Perform ( const TopTools_SequenceOfShape &  theRemovedFaces)

Definition at line 115 of file ShHealOper_RemoveFace.cxx.

{
  myDone = Standard_False;
  myErrorStatus = ShHealOper_NotError;
  if(myInitShape.IsNull()) {
    myErrorStatus = ShHealOper_InvalidParameters;
    return myDone;
  }
  if(theRemoveFaces.IsEmpty())
    return Standard_False;
  myMapFaces.Clear();
  
  Standard_Integer i=1; 
  for( ; i <= theRemoveFaces.Length(); i++)
    myMapFaces.Add(theRemoveFaces.Value(i));
  
  myDone = removeFaces(myInitShape,myResultShape);
  return myDone;
}

Here is the call graph for this function:

Standard_Boolean ShHealOper_RemoveFace::removeFaces ( const TopoDS_Shape &  theShape,
TopoDS_Shape &  theNewShape 
) [private]

Definition at line 140 of file ShHealOper_RemoveFace.cxx.

{
  Standard_Boolean isDone = Standard_False;
  
  TopAbs_ShapeEnum aType = theShape.ShapeType();
  theNewShape = theShape;
  if(!myMapFaces.Extent())
    return isDone;
  if( aType == TopAbs_WIRE || aType == TopAbs_EDGE || aType == TopAbs_VERTEX)
      return isDone;
  if(aType == TopAbs_FACE && myMapFaces.Contains(theShape)) {
    removePCurve(TopoDS::Face(theShape));
    
    myContext->Remove(theShape);
    myMapFaces.Remove(theShape);
    //theNewShape = TopoDS_Shape();
    theNewShape.Nullify();
    isDone = Standard_True;
  }
  else if(aType == TopAbs_SHELL) {
    isDone = removeFaces(TopoDS::Shell(theShape),theNewShape);
    return isDone;
  }
  else if(aType == TopAbs_SOLID) {
    isDone = removeFaces(TopoDS::Solid(theShape),theNewShape);
    myContext->Replace(theShape,theNewShape);
  }
  else if(aType == TopAbs_COMPSOLID) {

    //in the case of compsolid method for removing faces for solid
    //will be used.

    TopExp_Explorer aExpShell(theShape,TopAbs_SHELL);
    TopoDS_Solid aSol;
    BRep_Builder aB;
    aB.MakeSolid(aSol);
    for( ; aExpShell.More(); aExpShell.Next()) {
      aB.Add(aSol,aExpShell.Current());
    }
    TopoDS_Shape aNewShape;
    isDone =  removeFaces(aSol,aNewShape);
    if(isDone)
       myContext->Replace(theShape,theNewShape);
    
  }
  else if(aType == TopAbs_COMPOUND) {
    //in the case of compounf faces will be removed from each part of compound separately

    TopoDS_Compound aComp;
    TopoDS_Iterator aItShape(theShape,Standard_False);
    BRep_Builder aB;
    aB.MakeCompound(aComp);
    Standard_Integer nbs =0;
    for( ; aItShape.More() ; aItShape.Next()) {

      TopoDS_Shape aNShape;
      if( removeFaces(aItShape.Value(),aNShape)) {
        isDone = Standard_True;
        myContext->Replace(aItShape.Value(),aNShape);
      }
      if(!aNShape.IsNull()) {
        aB.Add(aComp,aNShape);
        nbs++;
      }
    }
    if(isDone) {
      if(nbs) 
        theNewShape = aComp;
      else
        theNewShape =TopoDS_Shape();
      myContext->Replace(theShape,theNewShape);
    }
   
  }
  return isDone;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Standard_Boolean ShHealOper_RemoveFace::removeFaces ( const TopoDS_Solid &  theShape,
TopoDS_Shape &  theNewShape 
) [private]

Definition at line 222 of file ShHealOper_RemoveFace.cxx.

{
  Standard_Boolean isDone = Standard_False;
  TopoDS_Solid aSol;
  BRep_Builder aB;
  aB.MakeSolid(aSol);
  TopoDS_Compound aComp;
  aB.MakeCompound(aComp);
  Standard_Boolean isAddSol = Standard_False, isAddComp = Standard_False;

  //firslty faces will be deleted from each shell.
  TopoDS_Iterator aItSol(theShape,Standard_False);
  for( ; aItSol.More(); aItSol.Next()) {
    TopoDS_Shape aSh = aItSol.Value();
    TopoDS_Shape aNewShape;
    if(removeFaces(aSh,aNewShape)) 
      isDone = Standard_True;
    
    if(aNewShape.IsNull())
      continue;
    else if(aNewShape.ShapeType() == TopAbs_SHELL ) {
      aB.Add(aSol,aNewShape);
      isAddSol = Standard_True;
    }
    else {
      aB.Add(aComp,aNewShape);
      isAddComp = Standard_True;
    }
    
  }
  if(isDone) {
    //for getting correct solids class ShapeFix_Solid will be used.
    if(isAddSol) {
      Handle(ShapeFix_Solid) aSfSol = new ShapeFix_Solid(aSol);
      aSfSol->FixShellMode()= Standard_False;
      aSfSol->Perform();
      TopoDS_Shape aresSol = aSfSol->Shape();
      if(!isAddComp) 
        theNewShape = aresSol;
      else 
        aB.Add(aComp,aresSol);
    }
    else if(isAddComp)
        theNewShape = aComp;
    else
      theNewShape.Nullify();
  }
  else
    theNewShape = theShape; 
  return isDone;
}

Here is the call graph for this function:

Standard_Boolean ShHealOper_RemoveFace::removeFaces ( const TopoDS_Shell &  theShell,
TopoDS_Shape &  theNewShape 
) [private]

Definition at line 313 of file ShHealOper_RemoveFace.cxx.

{
  
  Standard_Boolean aIsRemove = Standard_False;
  //TopoDS_Shape aShape = myReShape->Apply(theShape);
  //removing faces from shell.
  TopoDS_Iterator aIterFaces(theShell,Standard_False);
  for(; aIterFaces.More() && myMapFaces.Extent(); aIterFaces.Next()) {

    if(!myMapFaces.Contains(aIterFaces.Value()))
      continue;
    TopoDS_Face aFace = TopoDS::Face( aIterFaces.Value());
    removePCurve(aFace);
    aIsRemove  = Standard_True;
    myContext->Remove(aFace);
    myMapFaces.Remove(aFace);
  }
  if(aIsRemove) {
    TopoDS_Shape aNewShape = myContext->Apply(theShell);
    //avoiding empty shell and shell containing one face.
    TopoDS_Shape aresShape = getResultShell(aNewShape);
    if(aresShape.IsNull()) {
      myContext->Remove(aNewShape);
      theNewShape.Nullify();
    }
    else if(aresShape.ShapeType() == TopAbs_FACE) {
      myContext->Replace(aNewShape,aresShape);
      theNewShape = aresShape;
    }
    else if(aresShape.ShapeType() == TopAbs_SHELL) {
      //obtaining correct shell or compound with help class ShapeFix_Shell.
      Standard_Boolean isManifShell = isManifold(theShell);
      Handle(ShapeFix_Shell) aFixShell = new ShapeFix_Shell;
      aFixShell->FixFaceOrientation(TopoDS::Shell(aresShape),Standard_True,!isManifShell);
      TopoDS_Shape aFixShape = aFixShell->Shape();
      TopoDS_Shape areplShape;
      isReplace(aFixShape,areplShape);
      myContext->Replace(aNewShape,areplShape);
      theNewShape = areplShape;
    }
  }
  else theNewShape = theShell;
  return aIsRemove;
}

Here is the call graph for this function:

void ShHealOper_RemoveFace::removePCurve ( const TopoDS_Face &  theFace) [private]

Definition at line 419 of file ShHealOper_RemoveFace.cxx.

{
  //removing pcurves belonging removed face.
  Handle(Geom_Surface) aSurfDel = BRep_Tool::Surface(theFace);
  for(TopExp_Explorer aExpEdges(theFace,TopAbs_EDGE);  aExpEdges.More();  aExpEdges.Next()) {
    const TopTools_ListOfShape& alFaces = myMapEdgesFace.FindFromKey(aExpEdges.Current());
    Standard_Boolean aIsDeleted = Standard_True;
    
    //pcurve will be removed if containing this edge faces have different surfaces.
    TopTools_ListIteratorOfListOfShape aIterOtherFace(alFaces);
    for(; aIterOtherFace.More() && aIsDeleted ; aIterOtherFace.Next()) {
      if(aIterOtherFace.Value().IsSame(theFace))
         continue;
         TopoDS_Face aFaceOther = TopoDS::Face(aIterOtherFace.Value());
         Handle(Geom_Surface) aSurf = BRep_Tool::Surface( aFaceOther);
         aIsDeleted = (aSurf != aSurfDel);
    }
    
    TopoDS_Edge aEdge = TopoDS::Edge(myContext->Apply(aExpEdges.Current()));
    ShapeBuild_Edge aSbe;
    TopoDS_Edge aNewEdge = aSbe.Copy(aEdge,Standard_False);
    if(aIsDeleted) {
      aSbe.RemovePCurve(aNewEdge,aSurfDel);
      myContext->Replace(aEdge,aNewEdge);
      
    }
    
  }
}

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_Boolean ShHealOper_Tool::myDone [protected, inherited]

Definition at line 100 of file ShHealOper_Tool.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.

TopTools_IndexedDataMapOfShapeListOfShape ShHealOper_RemoveFace::myMapEdgesFace [private]

Definition at line 78 of file ShHealOper_RemoveFace.hxx.

TopTools_MapOfShape ShHealOper_RemoveFace::myMapFaces [private]

Definition at line 77 of file ShHealOper_RemoveFace.hxx.

TopoDS_Shape ShHealOper_Tool::myResultShape [protected, inherited]

Definition at line 99 of file ShHealOper_Tool.hxx.


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