Back to index

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

#include <BlockFix_CheckTool.hxx>

List of all members.

Public Member Functions

void * operator new (size_t, void *anAddress)
void * operator new (size_t size)
void operator delete (void *anAddress)
Standard_EXPORT BlockFix_CheckTool ()
Standard_EXPORT void SetShape (const TopoDS_Shape &aShape)
Standard_EXPORT void Perform ()
Standard_EXPORT Standard_Integer NbPossibleBlocks () const
Standard_EXPORT TopoDS_Shape PossibleBlock (const Standard_Integer num) const
Standard_EXPORT void DumpCheckResult (Standard_OStream &S) const

Private Attributes

TopoDS_Shape myShape
Standard_Boolean myHasCheck
Standard_Integer myNbSolids
Standard_Integer myNbBlocks
TopTools_SequenceOfShape myPossibleBlocks
Standard_Integer myNbDegen
Standard_Integer myNbUF
Standard_Integer myNbUE
Standard_Integer myNbUFUE
Standard_Integer myBadRanges

Detailed Description

Definition at line 51 of file BlockFix_CheckTool.hxx.


Constructor & Destructor Documentation

Definition at line 51 of file BlockFix_CheckTool.cxx.

{
  myHasCheck = Standard_False;
  myPossibleBlocks.Clear();
}

Member Function Documentation

void BlockFix_CheckTool::DumpCheckResult ( Standard_OStream &  S) const

Definition at line 263 of file BlockFix_CheckTool.cxx.

{
  if(!myHasCheck)
    S<<"Check not performed!"<<endl;
  else {
    S<<"dump results of check:"<<endl;
    S<<"  total number of solids = "<<myNbSolids<<endl;
    S<<"  including: number of good blocks = "<<myNbBlocks<<endl;
    S<<"             number of possible blocks = "<<NbPossibleBlocks()<<endl;
    S<<"             including: need remove degenerative = "<<myNbDegen<<endl;
    S<<"                        need unionfaces = "<<myNbUF<<endl;
    S<<"                        need unionedges = "<<myNbUE<<endl;
    S<<"                        need both unionfaces and unionedges = "<<myNbUFUE<<endl;
    Standard_Integer nbtmp = myNbSolids - myNbBlocks - NbPossibleBlocks();
    S<<"             number of impossible blocks = "<<nbtmp<<endl;
  }
}

Here is the call graph for this function:

Standard_Integer BlockFix_CheckTool::NbPossibleBlocks ( ) const

Definition at line 238 of file BlockFix_CheckTool.cxx.

{
  return myPossibleBlocks.Length();
}

Here is the caller graph for this function:

void BlockFix_CheckTool::operator delete ( void *  anAddress) [inline]

Definition at line 63 of file BlockFix_CheckTool.hxx.

      {
        if (anAddress) Standard::Free((Standard_Address&)anAddress);
      }
void* BlockFix_CheckTool::operator new ( size_t  ,
void *  anAddress 
) [inline]

Definition at line 55 of file BlockFix_CheckTool.hxx.

      {
        return anAddress;
      }
void* BlockFix_CheckTool::operator new ( size_t  size) [inline]

Definition at line 59 of file BlockFix_CheckTool.hxx.

      {
        return Standard::Allocate(size);
      }

Definition at line 76 of file BlockFix_CheckTool.cxx.

{
  myNbSolids=0;
  myNbBlocks=0;
  myNbDegen=0;
  myNbUF=0;
  myNbUE=0;
  myNbUFUE=0;

  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 (aSolid, TopAbs_FACE);
    TopTools_MapOfShape mapF;
    for (; expf.More(); expf.Next()) {
      if (mapF.Add(expf.Current()))
        nf++;
    }

    if (nf < 6) {
      IsBlock = Standard_False;
    }
    else if (nf > 6) {
      IsBlock = Standard_False;
      // check faces unification
      TopTools_SequenceOfShape faces;
      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++) {
        TopoDS_Face F1 = TopoDS::Face(faces.Value(i));
        TopTools_MapOfShape Edges;
        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);
        for(Standard_Integer j=i+1; j<=faces.Length() && !HasFacesForUnification; j++) {
          TopoDS_Face F2 = TopoDS::Face(faces.Value(j));
          TopLoc_Location L2;
          Handle(Geom_Surface) S2 = BRep_Tool::Surface(F2,L2);
          if( S1==S2 && L1==L2 ) {
            // faces have equal based surface
            // now check common edge
            for(TopExp_Explorer expe2(F2,TopAbs_EDGE); expe2.More(); expe2.Next()) {
              if(Edges.Contains(expe2.Current().Oriented(TopAbs_FORWARD))) {
                HasFacesForUnification = Standard_True;
                break;
              }
            }
          }
        }
      }
      if (HasFacesForUnification) {
        MayBeUF=Standard_True;
      }
    }

    Standard_Integer nbe=0;
    TopTools_MapOfShape DegenEdges;
    TopExp_Explorer expe (aSolid, TopAbs_EDGE);
    TopTools_MapOfShape mapE;
    for (; expe.More(); expe.Next()) {
      TopoDS_Edge E = TopoDS::Edge(expe.Current());
      if (!mapE.Add(E)) continue;
      if (BRep_Tool::Degenerated(E)) {
        DegenEdges.Add(E);
      }
      else {
        nbe++;
      }
    }
    if (nbe == 12 && DegenEdges.Extent() > 0) {
      IsBlock = Standard_False;
      myNbDegen++;
      myPossibleBlocks.Append(aSolid);
      continue;
    }
    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);

      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;

        TopTools_MapOfShape mapEe;
        for (expe.Init(aFace, TopAbs_EDGE); expe.More(); expe.Next()) {
          TopoDS_Edge edge = TopoDS::Edge(expe.Current());
          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()) {
            TopoDS_Face face = TopoDS::Face(anIter.Value());
            if (face.IsSame(aFace)) continue;
            if (aMapFacesEdges.Contains(face)) {
              aMapFacesEdges.ChangeFromKey(face).Append(edge);
            }
            else {
              TopTools_ListOfShape ListEdges;
              ListEdges.Append(edge);
              aMapFacesEdges.Add(face,ListEdges);
            }
          }
        }
        Standard_Integer i = 1;
        for (; i <= aMapFacesEdges.Extent(); i++) {
          const TopTools_ListOfShape& ListEdges = aMapFacesEdges.FindFromIndex(i);
          if (ListEdges.Extent() > 1) break;
        }
        if (i <= aMapFacesEdges.Extent()) {
          MayBeUE = Standard_True;
          break;
        }
      }
    }

    if (IsBlock)
      myNbBlocks++;
    else {
      if (MayBeUF) {
        myPossibleBlocks.Append(aSolid);
        if (MayBeUE)
          myNbUFUE++;
        else
          myNbUF++;
      }
      else if (MayBeUE) {
        myNbUE++;
        myPossibleBlocks.Append(aSolid);
      }
    }
  }

  myHasCheck = Standard_True;
}

Here is the call graph for this function:

Here is the caller graph for this function:

TopoDS_Shape BlockFix_CheckTool::PossibleBlock ( const Standard_Integer  num) const

Definition at line 249 of file BlockFix_CheckTool.cxx.

{
  TopoDS_Shape res;
  if( num>0 && num<=myPossibleBlocks.Length() )
    res = myPossibleBlocks.Value(num);
  return res;
}
void BlockFix_CheckTool::SetShape ( const TopoDS_Shape &  aShape)

Definition at line 63 of file BlockFix_CheckTool.cxx.

{
  myHasCheck = Standard_False;
  myShape = aShape;
  myPossibleBlocks.Clear();
}

Here is the caller graph for this function:


Member Data Documentation

Standard_Integer BlockFix_CheckTool::myBadRanges [private]

Definition at line 107 of file BlockFix_CheckTool.hxx.

Standard_Boolean BlockFix_CheckTool::myHasCheck [private]

Definition at line 99 of file BlockFix_CheckTool.hxx.

Standard_Integer BlockFix_CheckTool::myNbBlocks [private]

Definition at line 101 of file BlockFix_CheckTool.hxx.

Standard_Integer BlockFix_CheckTool::myNbDegen [private]

Definition at line 103 of file BlockFix_CheckTool.hxx.

Standard_Integer BlockFix_CheckTool::myNbSolids [private]

Definition at line 100 of file BlockFix_CheckTool.hxx.

Standard_Integer BlockFix_CheckTool::myNbUE [private]

Definition at line 105 of file BlockFix_CheckTool.hxx.

Standard_Integer BlockFix_CheckTool::myNbUF [private]

Definition at line 104 of file BlockFix_CheckTool.hxx.

Standard_Integer BlockFix_CheckTool::myNbUFUE [private]

Definition at line 106 of file BlockFix_CheckTool.hxx.

TopTools_SequenceOfShape BlockFix_CheckTool::myPossibleBlocks [private]

Definition at line 102 of file BlockFix_CheckTool.hxx.

TopoDS_Shape BlockFix_CheckTool::myShape [private]

Definition at line 98 of file BlockFix_CheckTool.hxx.


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