Back to index

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

The algorithm to build faces from set of edges
More...

#include <GEOMAlgo_BuilderFace.hxx>

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

List of all members.

Public Member Functions

Standard_EXPORT GEOMAlgo_BuilderFace ()
 Empty constructor

virtual Standard_EXPORT ~GEOMAlgo_BuilderFace ()
Standard_EXPORT void SetFace (const TopoDS_Face &theFace)
 Sets the face generatix

Standard_EXPORT const TopoDS_Face & Face () const
 Returns the face generatix

virtual Standard_EXPORT void Perform ()
 Performs the algorithm

Standard_EXPORT void SetContext (const Handle(IntTools_Context)&theContext)
 Sets cashed geometrical tools

Standard_EXPORT const
Handle_IntTools_Context & 
Context () const
 Returns cashed geometrical tools

Standard_EXPORT void SetShapes (const TopTools_ListOfShape &theLS)
 Sets edges/faces to process

Standard_EXPORT const
TopTools_ListOfShape & 
Shapes () const
 Returns edges/faces to process

Standard_EXPORT const
TopTools_ListOfShape & 
Loops () const
 Returns wires/shells that have been built

Standard_EXPORT const
TopTools_ListOfShape & 
Areas () const
 Returns faces/solids that have been built

Standard_EXPORT Standard_Integer ErrorStatus () const
Standard_EXPORT Standard_Integer WarningStatus () const
Standard_EXPORT void ComputeInternalShapes (const Standard_Boolean theFlag)
 Allows to omit of creation of internal shapes (manifold topology).
Needed for the SALOME/TRIPOLI module.

Protected Member Functions

virtual Standard_EXPORT void PerformShapesToAvoid ()
 Collect the edges that
a) are internal
b) are the same and have different orientation

virtual Standard_EXPORT void PerformLoops ()
 Build draft wires
a)myLoops - draft wires that consist of
boundary edges
b)myLoopsInternal - draft wires that contains
inner edges

virtual Standard_EXPORT void PerformAreas ()
 Build draft faces that contains boundary edges

virtual Standard_EXPORT void PerformInternalShapes ()
 Build finalized faces with internals

virtual Standard_EXPORT void CheckData ()
virtual Standard_EXPORT void CheckResult ()

Protected Attributes

TopoDS_Face myFace
TopTools_ListOfShape myShapes
TopTools_ListOfShape myLoops
TopTools_ListOfShape myLoopsInternal
TopTools_MapOfOrientedShape myShapesToAvoid
TopTools_ListOfShape myAreas
Handle_IntTools_Context myContext
Standard_Integer myErrorStatus
Standard_Integer myWarningStatus
Standard_Boolean myComputeInternalShapes

Detailed Description

The algorithm to build faces from set of edges

Definition at line 41 of file GEOMAlgo_BuilderFace.hxx.


Constructor & Destructor Documentation

Empty constructor

Definition at line 101 of file GEOMAlgo_BuilderFace.cxx.

Definition at line 110 of file GEOMAlgo_BuilderFace.cxx.

{
}

Member Function Documentation

const TopTools_ListOfShape & GEOMAlgo_BuilderArea::Areas ( ) const [inherited]

Returns faces/solids that have been built

Definition at line 110 of file GEOMAlgo_BuilderArea.cxx.

{
  return myAreas;
}

Here is the caller graph for this function:

void GEOMAlgo_Algo::CheckData ( ) [protected, virtual, inherited]
void GEOMAlgo_Algo::CheckResult ( ) [protected, virtual, inherited]

Reimplemented in GEOMAlgo_Gluer.

Definition at line 59 of file GEOMAlgo_Algo.cxx.

void GEOMAlgo_Algo::ComputeInternalShapes ( const Standard_Boolean  theFlag) [inherited]

Allows to omit of creation of internal shapes (manifold topology).
Needed for the SALOME/TRIPOLI module.

Definition at line 87 of file GEOMAlgo_Algo.cxx.

{
  myComputeInternalShapes = theFlag;
}

Here is the caller graph for this function:

Standard_EXPORT const Handle_IntTools_Context& GEOMAlgo_BuilderArea::Context ( ) const [inherited]

Returns cashed geometrical tools

Standard_Integer GEOMAlgo_Algo::ErrorStatus ( ) const [inherited]

Definition at line 67 of file GEOMAlgo_Algo.cxx.

{
  return myErrorStatus;
}

Here is the caller graph for this function:

const TopoDS_Face & GEOMAlgo_BuilderFace::Face ( ) const

Returns the face generatix

Definition at line 125 of file GEOMAlgo_BuilderFace.cxx.

{
  return myFace;
}

Here is the caller graph for this function:

const TopTools_ListOfShape & GEOMAlgo_BuilderArea::Loops ( ) const [inherited]

Returns wires/shells that have been built

Definition at line 102 of file GEOMAlgo_BuilderArea.cxx.

{
  return myLoops;
}
void GEOMAlgo_BuilderFace::Perform ( ) [virtual]

Performs the algorithm

Reimplemented from GEOMAlgo_BuilderArea.

Definition at line 133 of file GEOMAlgo_BuilderFace.cxx.

{
  myErrorStatus=0;
  //
  if (myFace.IsNull()) {
    myErrorStatus=12;// Null face generix
    return;
  }
  // Initialize the context
  GEOMAlgo_BuilderArea::Perform();
  //
  PerformShapesToAvoid();
  if (myErrorStatus) {
    return;
  }
  //
  PerformLoops();
  if (myErrorStatus) {
    return;
  }
  //
  PerformAreas();
  if (myErrorStatus) {
    return;
  }
  //
  PerformInternalShapes();
  if (myErrorStatus) {
    return;
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void GEOMAlgo_BuilderFace::PerformAreas ( ) [protected, virtual]

Build draft faces that contains boundary edges

Reimplemented from GEOMAlgo_BuilderArea.

Definition at line 364 of file GEOMAlgo_BuilderFace.cxx.

{
  myErrorStatus=0;
  //
  Standard_Boolean bIsGrowth, bIsHole;
  Standard_Real aTol;
  TopTools_ListOfShape aNewFaces, aHoleWires;
  TopoDS_Shape anInfinitePointShape;
  TopTools_DataMapOfShapeShape aInOutMap;
  TopTools_DataMapOfShapeListOfShape aMSH;
  TopTools_DataMapIteratorOfDataMapOfShapeListOfShape aItMSH;
  TopTools_ListIteratorOfListOfShape aIt1, aIt2;
  TopTools_IndexedMapOfShape aMHE;
  BRep_Builder aBB;
  Handle(Geom_Surface) aS;
  TopLoc_Location aLoc;
  //
  aTol=BRep_Tool::Tolerance(myFace);
  aS=BRep_Tool::Surface(myFace, aLoc);
  //
  myAreas.Clear();
  //
  //  Draft faces [aNewFaces]
  aIt1.Initialize(myLoops);
  for ( ; aIt1.More(); aIt1.Next()) {
    const TopoDS_Shape& aWire=aIt1.Value();
    //
    bIsGrowth=IsGrowthWire(aWire, aMHE);
    if (bIsGrowth) {
      // make a growth face from a wire
      TopoDS_Face aFace;
      aBB.MakeFace(aFace, aS, aLoc, aTol);
      aBB.Add (aFace, aWire);
      //
      aNewFaces.Append (aFace);
    }
    else{
      // check if a wire is a hole
      //XX
      //bIsHole=IsHole(aWire, myFace, myContext);
      bIsHole=GEOMAlgo_BuilderTools::IsHole(aWire, myFace);
      //XX
      if (bIsHole) {
        aHoleWires.Append(aWire);
        TopExp::MapShapes(aWire, TopAbs_EDGE, aMHE);
      }
      else {
        // make a growth face from a wire
        TopoDS_Face aFace;
        aBB.MakeFace(aFace, aS, aLoc, aTol);
        aBB.Add (aFace, aWire);
        //
        aNewFaces.Append (aFace);
      }
    }
  }
  //
  // 2. Find outer growth shell that is most close to each hole shell
  aIt2.Initialize(aHoleWires);
  for (; aIt2.More(); aIt2.Next()) {
    const TopoDS_Shape& aHole = aIt2.Value();
    //
    aIt1.Initialize(aNewFaces);
    for ( ; aIt1.More(); aIt1.Next()) {
      const TopoDS_Shape& aF=aIt1.Value();
      //
      if (!IsInside(aHole, aF, myContext)){
        continue;
      }
      //
      if ( aInOutMap.IsBound (aHole)){
        const TopoDS_Shape& aF2=aInOutMap(aHole);
        if (IsInside(aF, aF2, myContext)) {
          aInOutMap.UnBind(aHole);
          aInOutMap.Bind (aHole, aF);
        }
      }
      else{
        aInOutMap.Bind (aHole, aF);
      }
    }
    //
    // Add aHole to a map Face/ListOfHoles [aMSH]
    if (aInOutMap.IsBound(aHole)){
      const TopoDS_Shape& aF=aInOutMap(aHole);
      if (aMSH.IsBound(aF)) {
        TopTools_ListOfShape& aLH=aMSH.ChangeFind(aF);
        aLH.Append(aHole);
      }
      else {
        TopTools_ListOfShape aLH;
        aLH.Append(aHole);
        aMSH.Bind(aF, aLH);
      }
    }
  }// for (; aIt2.More(); aIt2.Next())
  //
  // 3. Add aHoles to Faces
  aItMSH.Initialize(aMSH);
  for (; aItMSH.More(); aItMSH.Next()) {
    TopoDS_Face aF=TopoDS::Face(aItMSH.Key());
    //
    const TopTools_ListOfShape& aLH=aItMSH.Value();
    aIt2.Initialize(aLH);
    for (; aIt2.More(); aIt2.Next()) {
      const TopoDS_Shape& aHole = aIt2.Value();
      aBB.Add (aF, aHole);
    }
    //
    // update classifier
    aTol=BRep_Tool::Tolerance(aF);
    IntTools_FClass2d& aClsf=myContext->FClass2d(aF);
    aClsf.Init(aF, aTol);
  }
  //
  // These aNewFaces are draft faces that
  // do not contain any internal shapes
  //
  myAreas.Append(aNewFaces);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void GEOMAlgo_BuilderFace::PerformInternalShapes ( ) [protected, virtual]

Build finalized faces with internals

Reimplemented from GEOMAlgo_BuilderArea.

Definition at line 488 of file GEOMAlgo_BuilderFace.cxx.

{
  myErrorStatus=0;
  //
  Standard_Integer aNbWI=myLoopsInternal.Extent();
  if (!aNbWI) {// nothing to do
    return;
  }
  //
  //Standard_Real aTol;
  BRep_Builder aBB;
  TopTools_ListIteratorOfListOfShape aIt1, aIt2;
  TopoDS_Iterator aIt;
  TopTools_MapOfShape aME, aMEP;
  TopTools_MapIteratorOfMapOfShape aItME;
  TopTools_IndexedDataMapOfShapeListOfShape aMVE;
  TopTools_ListOfShape aLSI;
  //
  // 1. All internal edges
  aIt1.Initialize(myLoopsInternal);
  for (; aIt1.More(); aIt1.Next()) {
    const TopoDS_Shape& aWire=aIt1.Value();
    aIt.Initialize(aWire);
    for (; aIt.More(); aIt.Next()) {
      const TopoDS_Shape& aE=aIt.Value();
      aME.Add(aE);
    }
  }
  aNbWI=aME.Extent();
  //
  // 2 Process faces
  aIt2.Initialize(myAreas);
  for ( ; aIt2.More(); aIt2.Next()) {
    TopoDS_Face& aF=TopoDS::Face(aIt2.Value());
    //
    aMVE.Clear();
    TopExp::MapShapesAndAncestors(aF, TopAbs_VERTEX, TopAbs_EDGE, aMVE);
    //
    // 2.1 Separate faces to process aMEP
    aMEP.Clear();
    aItME.Initialize(aME);
    for (; aItME.More(); aItME.Next()) {
      const TopoDS_Edge& aE=TopoDS::Edge(aItME.Key());
      if (IsInside(aE, aF, myContext)) {
        aMEP.Add(aE);
      }
    }
    //
    // 2.2 Make Internal Wires
    aLSI.Clear();
    MakeInternalWires(aMEP, aLSI);
    //
    // 2.3 Add them to aF
    aIt1.Initialize(aLSI);
    for (; aIt1.More(); aIt1.Next()) {
      const TopoDS_Shape& aSI=aIt1.Value();
      aBB.Add (aF, aSI);
    }
    //
    // 2.4 Remove faces aMFP from aMF
    aItME.Initialize(aMEP);
    for (; aItME.More(); aItME.Next()) {
      const TopoDS_Shape& aE=aItME.Key();
      aME.Remove(aE);
    }
    //
    aNbWI=aME.Extent();
    if (!aNbWI) {
      break;
    }
  } //for ( ; aIt2.More(); aIt2.Next()) {
}

Here is the call graph for this function:

Here is the caller graph for this function:

void GEOMAlgo_BuilderFace::PerformLoops ( ) [protected, virtual]

Build draft wires
a)myLoops - draft wires that consist of
boundary edges
b)myLoopsInternal - draft wires that contains
inner edges

Reimplemented from GEOMAlgo_BuilderArea.

Definition at line 244 of file GEOMAlgo_BuilderFace.cxx.

{
  myErrorStatus=0;
  //
  Standard_Boolean bFlag;
  Standard_Integer aNbEA;
  TopTools_ListIteratorOfListOfShape aIt;
  TopTools_MapIteratorOfMapOfOrientedShape aItM;
  TopTools_IndexedDataMapOfShapeListOfShape aVEMap;
  TopTools_MapOfOrientedShape aMAdded;
  TopoDS_Iterator aItW;
  BRep_Builder aBB;
  GEOMAlgo_WireEdgeSet aWES;
  GEOMAlgo_WESCorrector aWESCor;
  //
  // 1. Usual Wires
  myLoops.Clear();
  aWES.SetFace(myFace);
  //
  aIt.Initialize (myShapes);
  for (; aIt.More(); aIt.Next()) {
    const TopoDS_Shape& aE=aIt.Value();
    if (!myShapesToAvoid.Contains(aE)) {
      aWES.AddStartElement(aE);
    }
  }
  //
  aWESCor.SetWES(aWES);
  aWESCor.Perform();
  //
  GEOMAlgo_WireEdgeSet& aWESN=aWESCor.NewWES();
  const TopTools_ListOfShape& aLW=aWESN.Shapes();
  //
  aIt.Initialize (aLW);
  for (; aIt.More(); aIt.Next()) {
    const TopoDS_Shape& aW=aIt.Value();
    myLoops.Append(aW);
  }
  //modified by NIZNHY-PKV Tue Aug  5 15:09:29 2008f
  // Post Treatment
  TopTools_MapOfOrientedShape aMEP;
  //
  // a. collect all edges that are in loops
  aIt.Initialize (myLoops);
  for (; aIt.More(); aIt.Next()) {
    const TopoDS_Shape& aW=aIt.Value();
    aItW.Initialize(aW);
    for (; aItW.More(); aItW.Next()) {
      const TopoDS_Shape& aE=aItW.Value();
      aMEP.Add(aE);
    }
  }
  //
  // b. collect all edges that are to avoid
  aItM.Initialize(myShapesToAvoid);
  for (; aItM.More(); aItM.Next()) {
    const TopoDS_Shape& aE=aItM.Key();
    aMEP.Add(aE);
  }
  //
  // c. add all edges that are not processed to myShapesToAvoid
  aIt.Initialize (myShapes);
  for (; aIt.More(); aIt.Next()) {
    const TopoDS_Shape& aE=aIt.Value();
    if (!aMEP.Contains(aE)) {
      myShapesToAvoid.Add(aE);
    }
  }
  //modified by NIZNHY-PKV Tue Aug  5 15:09:35 2008t
  //
  // 2. Internal Wires
  myLoopsInternal.Clear();
  //
  aNbEA=myShapesToAvoid.Extent();
  aItM.Initialize(myShapesToAvoid);
  for (; aItM.More(); aItM.Next()) {
    const TopoDS_Shape& aEE=aItM.Key();
    TopExp::MapShapesAndAncestors(aEE, TopAbs_VERTEX, TopAbs_EDGE, aVEMap);
  }
  //
  bFlag=Standard_True;
  aItM.Initialize(myShapesToAvoid);
  for (; aItM.More()&&bFlag; aItM.Next()) {
    const TopoDS_Shape& aEE=aItM.Key();
    if (!aMAdded.Add(aEE)) {
      continue;
    }
    //
    // make new wire
    TopoDS_Wire aW;
    aBB.MakeWire(aW);
    aBB.Add(aW, aEE);
    //
    aItW.Initialize(aW);
    for (; aItW.More()&&bFlag; aItW.Next()) {
      const TopoDS_Edge& aE=TopoDS::Edge(aItW.Value());
      //
      TopoDS_Iterator aItE(aE);
      for (; aItE.More()&&bFlag; aItE.Next()) {
        const TopoDS_Vertex& aV = TopoDS::Vertex(aItE.Value());
        const TopTools_ListOfShape& aLE=aVEMap.FindFromKey(aV);
        aIt.Initialize(aLE);
        for (; aIt.More()&&bFlag; aIt.Next()) {
          const TopoDS_Shape& aEx=aIt.Value();
          if (aMAdded.Add(aEx)) {
            aBB.Add(aW, aEx);
            if(aMAdded.Extent()==aNbEA) {
              bFlag=!bFlag;
            }
          }
        }//for (; aIt.More(); aIt.Next()) {
      }//for (; aItE.More(); aItE.Next()) {
    }//for (; aItW.More(); aItW.Next()) {
    myLoopsInternal.Append(aW);
  }//for (; aItM.More(); aItM.Next()) {
}

Here is the call graph for this function:

Here is the caller graph for this function:

void GEOMAlgo_BuilderFace::PerformShapesToAvoid ( ) [protected, virtual]

Collect the edges that
a) are internal
b) are the same and have different orientation

Reimplemented from GEOMAlgo_BuilderArea.

Definition at line 168 of file GEOMAlgo_BuilderFace.cxx.

{
  Standard_Boolean bFound;
  Standard_Integer i, iCnt, aNbV, aNbE;
  TopTools_IndexedDataMapOfShapeListOfShape aMVE;
  TopTools_ListIteratorOfListOfShape aIt;
  //
  myShapesToAvoid.Clear();
  //
  iCnt=0;
  while (1) {
    ++iCnt;
    bFound=Standard_False;
    //
    // 1. MEF
    aMVE.Clear();
    aIt.Initialize (myShapes);
    for (; aIt.More(); aIt.Next()) {
      const TopoDS_Shape& aE=aIt.Value();
      if (!myShapesToAvoid.Contains(aE)) {
        TopExp::MapShapesAndAncestors(aE, TopAbs_VERTEX, TopAbs_EDGE, aMVE);
      }
//       else {
//         int a=0;
//       }
    }
    aNbV=aMVE.Extent();
    //
    // 2. myEdgesToAvoid
    for (i=1; i<=aNbV; ++i) {
      const TopoDS_Vertex& aV=TopoDS::Vertex(aMVE.FindKey(i));
      //
      TopTools_ListOfShape& aLE=aMVE.ChangeFromKey(aV);
      aNbE=aLE.Extent();
      if (!aNbE) {
        continue;
      }
      //
      const TopoDS_Edge& aE1=TopoDS::Edge(aLE.First());
      if (aNbE==1) {
        if (BRep_Tool::Degenerated(aE1)) {
          continue;
        }
        if (aV.Orientation()==TopAbs_INTERNAL) {
          continue;
        }
        bFound=Standard_True;
        myShapesToAvoid.Add(aE1);
      }
      else if (aNbE==2) {
        const TopoDS_Edge& aE2=TopoDS::Edge(aLE.Last());
        if (aE2.IsSame(aE1)) {
          TopoDS_Vertex aV1x, aV2x;
          //
          TopExp::Vertices(aE1, aV1x, aV2x);
          if (aV1x.IsSame(aV2x)) {
            continue;
          }
          bFound=Standard_True;
          myShapesToAvoid.Add(aE1);
          myShapesToAvoid.Add(aE2);
        }
      }
    }// for (i=1; i<=aNbE; ++i) {
    //
    if (!bFound) {
      break;
    }
    //
  }//while (1)
  //printf(" EdgesToAvoid=%d, iCnt=%d\n", EdgesToAvoid.Extent(), iCnt);
}

Here is the caller graph for this function:

void GEOMAlgo_BuilderArea::SetContext ( const Handle(IntTools_Context)&  theContext) [inherited]

Sets cashed geometrical tools

Definition at line 53 of file GEOMAlgo_BuilderArea.cxx.

{
  myContext=theContext;
}

Here is the caller graph for this function:

void GEOMAlgo_BuilderFace::SetFace ( const TopoDS_Face &  theFace)

Sets the face generatix

Definition at line 117 of file GEOMAlgo_BuilderFace.cxx.

{
  myFace=theFace;
}

Here is the caller graph for this function:

void GEOMAlgo_BuilderArea::SetShapes ( const TopTools_ListOfShape &  theLS) [inherited]

Sets edges/faces to process

Definition at line 79 of file GEOMAlgo_BuilderArea.cxx.

{
  TopTools_ListIteratorOfListOfShape aIt;
  //
  myShapes.Clear();
  aIt.Initialize(theLF);
  for(; aIt.More(); aIt.Next()) {
    const TopoDS_Shape& aF=aIt.Value();
    myShapes.Append(aF);
  }
}

Here is the caller graph for this function:

const TopTools_ListOfShape & GEOMAlgo_BuilderArea::Shapes ( ) const [inherited]

Returns edges/faces to process

Definition at line 94 of file GEOMAlgo_BuilderArea.cxx.

{
  return myShapes;
}
Standard_Integer GEOMAlgo_Algo::WarningStatus ( ) const [inherited]

Definition at line 75 of file GEOMAlgo_Algo.cxx.

{
  return myWarningStatus;
}

Here is the caller graph for this function:


Member Data Documentation

TopTools_ListOfShape GEOMAlgo_BuilderArea::myAreas [protected, inherited]

Definition at line 109 of file GEOMAlgo_BuilderArea.hxx.

Standard_Boolean GEOMAlgo_Algo::myComputeInternalShapes [protected, inherited]

Definition at line 73 of file GEOMAlgo_Algo.hxx.

Handle_IntTools_Context GEOMAlgo_BuilderArea::myContext [protected, inherited]

Definition at line 110 of file GEOMAlgo_BuilderArea.hxx.

Standard_Integer GEOMAlgo_Algo::myErrorStatus [protected, inherited]

Definition at line 71 of file GEOMAlgo_Algo.hxx.

TopoDS_Face GEOMAlgo_BuilderFace::myFace [protected]

Definition at line 88 of file GEOMAlgo_BuilderFace.hxx.

TopTools_ListOfShape GEOMAlgo_BuilderArea::myLoops [protected, inherited]

Definition at line 106 of file GEOMAlgo_BuilderArea.hxx.

TopTools_ListOfShape GEOMAlgo_BuilderArea::myLoopsInternal [protected, inherited]

Definition at line 107 of file GEOMAlgo_BuilderArea.hxx.

TopTools_ListOfShape GEOMAlgo_BuilderArea::myShapes [protected, inherited]

Definition at line 105 of file GEOMAlgo_BuilderArea.hxx.

TopTools_MapOfOrientedShape GEOMAlgo_BuilderArea::myShapesToAvoid [protected, inherited]

Definition at line 108 of file GEOMAlgo_BuilderArea.hxx.

Standard_Integer GEOMAlgo_Algo::myWarningStatus [protected, inherited]

Definition at line 72 of file GEOMAlgo_Algo.hxx.


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