Back to index

salome-geom  6.5.0
Functions
GEOMAlgo_BuilderSolid.cxx File Reference
#include <GEOMAlgo_BuilderSolid.hxx>
#include <gp_Pnt2d.hxx>
#include <gp_Pln.hxx>
#include <gp_Vec.hxx>
#include <gp_Dir.hxx>
#include <gp_Pnt.hxx>
#include <Geom_Curve.hxx>
#include <Geom_Surface.hxx>
#include <Geom2d_Curve.hxx>
#include <TopAbs.hxx>
#include <TopoDS_Iterator.hxx>
#include <TopoDS_Face.hxx>
#include <TopoDS.hxx>
#include <TopoDS_Shape.hxx>
#include <TopoDS_Shell.hxx>
#include <TopoDS_Edge.hxx>
#include <TopoDS_Solid.hxx>
#include <TopoDS_Vertex.hxx>
#include <TopoDS_Compound.hxx>
#include <BRep_Builder.hxx>
#include <BRep_Tool.hxx>
#include <BRepTools.hxx>
#include <BRepClass3d_SolidClassifier.hxx>
#include <TopExp.hxx>
#include <TopExp_Explorer.hxx>
#include <TopTools_MapOfShape.hxx>
#include <TopTools_MapIteratorOfMapOfShape.hxx>
#include <TopTools_MapOfOrientedShape.hxx>
#include <TopTools_MapIteratorOfMapOfOrientedShape.hxx>
#include <TopTools_ListOfShape.hxx>
#include <TopTools_ListIteratorOfListOfShape.hxx>
#include <TopTools_DataMapOfShapeShape.hxx>
#include <TopTools_IndexedMapOfShape.hxx>
#include <TopTools_IndexedDataMapOfShapeListOfShape.hxx>
#include <TopTools_DataMapOfShapeListOfShape.hxx>
#include <TopTools_DataMapIteratorOfDataMapOfShapeListOfShape.hxx>
#include <IntTools_Context.hxx>
#include <BOPTools_Tools2D.hxx>
#include <BOPTools_Tools3D.hxx>
#include <NMTTools_ListOfCoupleOfShape.hxx>
#include <NMTTools_CoupleOfShape.hxx>
#include <NMTTools_ListIteratorOfListOfCoupleOfShape.hxx>
#include <GEOMAlgo_Tools3D.hxx>
#include <GEOMAlgo_BuilderTools.hxx>

Go to the source code of this file.

Functions

static Standard_Boolean IsGrowthShell (const TopoDS_Shape &, const TopTools_IndexedMapOfShape &)
static Standard_Boolean IsHole (const TopoDS_Shape &, const Handle(IntTools_Context)&)
static Standard_Boolean IsInside (const TopoDS_Shape &, const TopoDS_Shape &, const Handle(IntTools_Context)&)
static void MakeInternalShells (const TopTools_MapOfShape &, TopTools_ListOfShape &)
static Standard_Boolean IsClosedShell (const TopoDS_Shell &)
static Standard_Boolean RefineShell (const TopoDS_Shell &, TopoDS_Shell &)

Function Documentation

Standard_Boolean IsClosedShell ( const TopoDS_Shell &  theShell) [static]

Definition at line 813 of file GEOMAlgo_BuilderSolid.cxx.

{
  Standard_Integer aNbE;
  Standard_Boolean bRet;
  TopoDS_Iterator aIt;
  TopExp_Explorer aExp;
  TopTools_MapOfShape aM;
  //
  bRet=Standard_False;
  aIt.Initialize(theShell);
  for(; aIt.More(); aIt.Next()) {
    const TopoDS_Face& aF=TopoDS::Face(aIt.Value());
    aExp.Init(aF, TopAbs_EDGE);
    for (; aExp.More(); aExp.Next()) {
      const TopoDS_Edge& aE=*((TopoDS_Edge*)(&aExp.Current()));
      if (BRep_Tool::Degenerated(aE)) {
        continue;
      }
      //
      if (aE.Orientation()==TopAbs_INTERNAL) {
        continue;
      }
      //
      if (!aM.Add(aE)) {
        aM.Remove(aE);
      }
    }
  }
  //
  aNbE=aM.Extent();
  if (!aNbE) {
    bRet=!bRet;
  }
  return bRet;
}

Here is the caller graph for this function:

Standard_Boolean IsGrowthShell ( const TopoDS_Shape &  theShell,
const TopTools_IndexedMapOfShape &  theMHF 
) [static]

Definition at line 791 of file GEOMAlgo_BuilderSolid.cxx.

{
  Standard_Boolean bRet;
  TopoDS_Iterator aIt;
  //
  bRet=Standard_False;
  if (theMHF.Extent()) {
    aIt.Initialize(theShell);
    for(; aIt.More(); aIt.Next()) {
      const TopoDS_Shape& aF=aIt.Value();
      if (theMHF.Contains(aF)) {
        return !bRet;
      }
    }
  }
  return bRet;
}

Here is the caller graph for this function:

Standard_Boolean IsHole ( const TopoDS_Shape &  theS2,
const Handle(IntTools_Context)&  theContext 
) [static]

Definition at line 751 of file GEOMAlgo_BuilderSolid.cxx.

{
  TopoDS_Solid *pS2=(TopoDS_Solid *)&theS2;
  BRepClass3d_SolidClassifier& aClsf=theContext->SolidClassifier(*pS2);
  //
  aClsf.PerformInfinitePoint(::RealSmall());
  //
  return (aClsf.State()==TopAbs_IN);
}

Here is the caller graph for this function:

Standard_Boolean IsInside ( const TopoDS_Shape &  theS1,
const TopoDS_Shape &  theS2,
const Handle(IntTools_Context)&  theContext 
) [static]

Definition at line 765 of file GEOMAlgo_BuilderSolid.cxx.

{
  TopExp_Explorer aExp;
  TopAbs_State aState;
  //
  TopoDS_Solid *pS2=(TopoDS_Solid *)&theS2;
  //
  aExp.Init(theS1, TopAbs_FACE);
  if (!aExp.More()){
    BRepClass3d_SolidClassifier& aClsf=theContext->SolidClassifier(*pS2);
    aClsf.PerformInfinitePoint(::RealSmall());
    aState=aClsf.State();
  }
  else {
    TopTools_IndexedMapOfShape aBounds;
    const TopoDS_Face& aF = TopoDS::Face(aExp.Current());
    aState=GEOMAlgo_Tools3D::ComputeState(aF, *pS2, 1.e-14, aBounds, theContext);
  }
  return (aState==TopAbs_IN);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void MakeInternalShells ( const TopTools_MapOfShape &  theMF,
TopTools_ListOfShape &  theShells 
) [static]

Definition at line 698 of file GEOMAlgo_BuilderSolid.cxx.

{
  TopTools_MapIteratorOfMapOfShape aItM;
  TopTools_MapOfShape aAddedFacesMap;
  TopTools_ListIteratorOfListOfShape aItF;
  TopTools_IndexedDataMapOfShapeListOfShape aMEF;
  BRep_Builder aBB;
  //
  aItM.Initialize(theMF);
  for (; aItM.More(); aItM.Next()) {
    const TopoDS_Shape& aF=aItM.Key();
    TopExp::MapShapesAndAncestors(aF, TopAbs_EDGE, TopAbs_FACE, aMEF);
  }
  //
  aItM.Initialize(theMF);
  for (; aItM.More(); aItM.Next()) {
    TopoDS_Shape aFF=aItM.Key();
    if (!aAddedFacesMap.Add(aFF)) {
      continue;
    }
    //
    // make a new shell
    TopoDS_Shell aShell;
    aBB.MakeShell(aShell);
    aFF.Orientation(TopAbs_INTERNAL);
    aBB.Add(aShell, aFF);
    //
    TopoDS_Iterator aItAddedF (aShell);
    for (; aItAddedF.More(); aItAddedF.Next()) {
      const TopoDS_Shape& aF =aItAddedF.Value();
      //
      TopExp_Explorer aEdgeExp(aF, TopAbs_EDGE);
      for (; aEdgeExp.More(); aEdgeExp.Next()) {
        const TopoDS_Shape& aE =aEdgeExp.Current();
        const TopTools_ListOfShape& aLF=aMEF.FindFromKey(aE);
        aItF.Initialize(aLF);
        for (; aItF.More(); aItF.Next()) {
          TopoDS_Shape aFL=aItF.Value();
          if (aAddedFacesMap.Add(aFL)){
            aFL.Orientation(TopAbs_INTERNAL);
            aBB.Add(aShell, aFL);
          }
        }
      }
    }
    theShells.Append(aShell);
  }
}

Here is the caller graph for this function:

Standard_Boolean RefineShell ( const TopoDS_Shell &  aShell,
TopoDS_Shell &  aShx 
) [static]

Definition at line 852 of file GEOMAlgo_BuilderSolid.cxx.

{
  Standard_Boolean bRet;
  Standard_Integer i, aNbE, aNbF;
  TopAbs_Orientation aOrE;
  TopTools_IndexedDataMapOfShapeListOfShape aMEF;
  TopTools_MapOfOrientedShape aMFx;
  //
  bRet=Standard_False;
  //
  TopExp::MapShapesAndAncestors(aShell, TopAbs_EDGE, TopAbs_FACE, aMEF);
  aNbE=aMEF.Extent();
  for (i=1; i<=aNbE; ++i) {
    const TopoDS_Edge &aE=*((TopoDS_Edge*)(&aMEF.FindKey(i)));
    //
    if (BRep_Tool::Degenerated(aE)) {
      continue;
    }
    //
    aOrE=aE.Orientation();
    //
    const TopTools_ListOfShape& aLF=aMEF(i);
    aNbF=aLF.Extent();
    if (!aNbF) {
      continue;
    }
    //
    const TopoDS_Face& aF1=*((TopoDS_Face*)(&aLF.First()));
    if (aNbF==1) {
      if (aOrE==TopAbs_INTERNAL) {
       continue;
      }
      aMFx.Add(aF1);
    }
    //
    else if (aNbF==2) {
      const TopoDS_Face& aF2=*((TopoDS_Face*)(&aLF.Last()));
      if (aF2.IsSame(aF1)) {
       if (BRep_Tool::IsClosed(aE, aF1)) {
         continue;
       }
       if (aOrE==TopAbs_INTERNAL) {
         continue;
       }
       aMFx.Add(aF1);
       aMFx.Add(aF2);
      }
    }
  }
  //
  aNbF=aMFx.Extent();
  if (!aNbF) {
    return bRet;
  }
  //
  BRep_Builder aBB;
  TopoDS_Iterator aIt;
  //
  aNbF=0;
  aBB.MakeShell(aShx);
  aIt.Initialize(aShell);
  for (; aIt.More(); aIt.Next()) {
    const TopoDS_Shape& aF=aIt.Value();
    if (!aMFx.Contains(aF)) {
      aBB.Add(aShx, aF);
      ++aNbF;
    }
  }
  //
  if (aNbF) {
    bRet=IsClosedShell(aShx);
  }
  //
  return bRet;
}

Here is the call graph for this function:

Here is the caller graph for this function: