Back to index

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

#include <GEOMAlgo_FinderShapeOn.hxx>

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

List of all members.

Public Member Functions

Standard_EXPORT GEOMAlgo_FinderShapeOn ()
virtual Standard_EXPORT ~GEOMAlgo_FinderShapeOn ()
virtual Standard_EXPORT void Perform ()
Standard_EXPORT void SetSurface (const Handle(Geom_Surface)&aS)
Standard_EXPORT void SetShapeType (const TopAbs_ShapeEnum aST)
Standard_EXPORT void SetState (const GEOMAlgo_State aSF)
Standard_EXPORT const
Handle_Geom_Surface & 
Surface () const
Standard_EXPORT TopAbs_ShapeEnum ShapeType () const
Standard_EXPORT GEOMAlgo_State State () const
Standard_EXPORT const
TopTools_ListOfShape & 
Shapes () const
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 SetShape (const TopoDS_Shape &aS)
Standard_EXPORT void SetTolerance (const Standard_Real aT)
Standard_EXPORT const
TopoDS_Shape & 
Shape () const
Standard_EXPORT Standard_Real Tolerance () const
Standard_EXPORT const
TopoDS_Shape & 
Result () const
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.

Static Public Member Functions

static Standard_EXPORT void CopySource (const TopoDS_Shape &aS, TopTools_DataMapOfShapeShape &aImages, TopTools_DataMapOfShapeShape &aOriginals, TopoDS_Shape &aSC)
static Standard_EXPORT
Standard_Boolean 
BuildTriangulation (const TopoDS_Shape &aS)

Protected Member Functions

virtual Standard_EXPORT void CheckData ()
Standard_EXPORT void MakeArgument1 ()
Standard_EXPORT void MakeArgument2 ()
Standard_EXPORT void Find ()
Standard_EXPORT void Find (const TopoDS_Shape &aS)
Standard_EXPORT void FindVertices ()
virtual Standard_EXPORT void CheckResult ()

Protected Attributes

Handle_Geom_Surface mySurface
TopAbs_ShapeEnum myShapeType
GEOMAlgo_State myState
TopoDS_Shape myArg1
TopoDS_Shape myArg2
TopTools_ListOfShape myLS
TopTools_DataMapOfShapeShape myImages
GEOMAlgo_IndexedDataMapOfShapeState myMSS
Standard_Boolean myIsAnalytic
TopoDS_Shape myShape
Standard_Real myTolerance
TopoDS_Shape myResult
Handle_IntTools_Context myContext
Standard_Integer myErrorStatus
Standard_Integer myWarningStatus
Standard_Boolean myComputeInternalShapes

Detailed Description

Definition at line 49 of file GEOMAlgo_FinderShapeOn.hxx.


Constructor & Destructor Documentation

Definition at line 81 of file GEOMAlgo_FinderShapeOn.cxx.

:
  GEOMAlgo_ShapeAlgo()
{
  myTolerance=0.0001;
  myShapeType=TopAbs_VERTEX;
  myState=GEOMAlgo_ST_UNKNOWN;
  myIsAnalytic=Standard_True;
}

Definition at line 94 of file GEOMAlgo_FinderShapeOn.cxx.

{
}

Member Function Documentation

Standard_Boolean GEOMAlgo_FinderShapeOn::BuildTriangulation ( const TopoDS_Shape &  aS) [static]

Definition at line 554 of file GEOMAlgo_FinderShapeOn.cxx.

{
  // calculate deflection
  Standard_Real aDeviationCoefficient = 0.001;

  Bnd_Box B;
  BRepBndLib::Add(theShape, B);
  Standard_Real aXmin, aYmin, aZmin, aXmax, aYmax, aZmax;
  B.Get(aXmin, aYmin, aZmin, aXmax, aYmax, aZmax);

  Standard_Real dx = aXmax - aXmin, dy = aYmax - aYmin, dz = aZmax - aZmin;
  Standard_Real aDeflection = Max(Max(dx, dy), dz) * aDeviationCoefficient * 4;
  Standard_Real aHLRAngle = 0.349066;

  // build triangulation
  BRepMesh_IncrementalMesh Inc (theShape, aDeflection, Standard_False, aHLRAngle);

  // check triangulation
  bool isTriangulation = true;

  TopExp_Explorer exp (theShape, TopAbs_FACE);
  if (exp.More())
  {
    TopLoc_Location aTopLoc;
    Handle(Poly_Triangulation) aTRF;
    aTRF = BRep_Tool::Triangulation(TopoDS::Face(exp.Current()), aTopLoc);
    if (aTRF.IsNull()) {
      isTriangulation = false;
    }
  }
  else // no faces, try edges
  {
    TopExp_Explorer expe (theShape, TopAbs_EDGE);
    if (!expe.More()) {
      isTriangulation = false;
    }
    else {
      TopLoc_Location aLoc;
      Handle(Poly_Polygon3D) aPE = BRep_Tool::Polygon3D(TopoDS::Edge(expe.Current()), aLoc);
      if (aPE.IsNull()) {
        isTriangulation = false;
      }
    }
  }

  return isTriangulation;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void GEOMAlgo_FinderShapeOn::CheckData ( ) [protected, virtual]

Reimplemented from GEOMAlgo_Algo.

Definition at line 469 of file GEOMAlgo_FinderShapeOn.cxx.

{
  myErrorStatus=0;
  //
  if(mySurface.IsNull()) {
    myErrorStatus=10; // mySurface=NULL
    return;
  }
  //
  if (myShape.IsNull()) {
    myErrorStatus=11; // myShape=NULL
    return;
  }
  //
  if (!(myShapeType==TopAbs_VERTEX ||
        myShapeType==TopAbs_EDGE ||
        myShapeType==TopAbs_FACE ||
        myShapeType==TopAbs_SOLID)) {
    myErrorStatus=12; // unallowed sub-shape type
    return;
  }
  //
  if (myState==GEOMAlgo_ST_UNKNOWN ||
      myState==GEOMAlgo_ST_INOUT) {
    myErrorStatus=13; // unallowed state type
    return;
  }
}

Here is the caller graph for this function:

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_ShapeAlgo::Context ( ) const [inherited]

Returns cashed geometrical tools

void GEOMAlgo_FinderShapeOn::CopySource ( const TopoDS_Shape &  aS,
TopTools_DataMapOfShapeShape &  aImages,
TopTools_DataMapOfShapeShape &  aOriginals,
TopoDS_Shape &  aSC 
) [static]

Definition at line 502 of file GEOMAlgo_FinderShapeOn.cxx.

{
  Standard_Boolean bFree;
  TopAbs_ShapeEnum aType;
  Standard_Integer aR;
  BRep_Builder BB;
  TopoDS_Iterator aIt;
  //
  aType=aE.ShapeType();
  //
  if (aOriginals.IsBound(aE)) {
    aEx=aOriginals.ChangeFind(aE);
    return;
  }
  else {
    aEx=aE.EmptyCopied();
    aOriginals.Bind(aE, aEx);
    aImages.Bind(aEx, aE);
  }
  //
  aR=(Standard_Integer)aType+1;
  if (aR>TopAbs_VERTEX) {
    return;
  }
  //
  bFree=aEx.Free();
  aEx.Free(Standard_True);
  //
  aType=(TopAbs_ShapeEnum) aR;
  //
  aIt.Initialize(aE);//, Standard_False);
  for (; aIt.More();  aIt.Next()) {
    const TopoDS_Shape& aV=aIt.Value();
    TopoDS_Shape aVx;
    //
    CopySource (aV, aImages, aOriginals, aVx);
    //
    aVx.Orientation(aV.Orientation());
    BB.Add(aEx, aVx);
  }
  //
  aEx.Free(bFree);
}

Here is the caller graph for this function:

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:

void GEOMAlgo_FinderShapeOn::Find ( ) [protected]

Definition at line 256 of file GEOMAlgo_FinderShapeOn.cxx.

{
  Standard_Integer i, aNb;
  Standard_Boolean bICS;
  TopTools_IndexedMapOfShape aM;
  //
  TopExp::MapShapes(myArg2, myShapeType, aM);
  //
  aNb=aM.Extent();
  if (!aNb) {
    myWarningStatus=10; // No found sub-shapes of type myShapeType
    return;
  }
  //
  bICS=GEOMAlgo_Tools::IsCompositeShape(myArg2);
  if (!bICS || myIsAnalytic) {
    TopoDS_Compound aCmp;
    BRep_Builder aBB;
    //
    aBB.MakeCompound(aCmp);
    for (i=1; i<=aNb; ++i) {
      const TopoDS_Shape& aSi=aM(i);
      aBB.Add(aCmp, aSi);
    }
    //
    aM.Clear();
    aM.Add(aCmp);
    aNb=1;
  }
  //
  for (i=1; i<=aNb; ++i) {
    const TopoDS_Shape& aS=aM(i);
    Find(aS);
    if (myErrorStatus) {
      return;
    }
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void GEOMAlgo_FinderShapeOn::Find ( const TopoDS_Shape &  aS) [protected]

Definition at line 298 of file GEOMAlgo_FinderShapeOn.cxx.

{
  myErrorStatus=0;
  //
  Standard_Boolean bIsDone;
  Standard_Integer i, iErr;
  TopAbs_State aSts[]={TopAbs_IN, TopAbs_OUT, TopAbs_ON};
  TopTools_ListIteratorOfListOfShape aIt;
  BOPTools_DSFiller aDF;
  //
  // 1. Prepare DSFiller
  aDF.SetShapes (myArg1, aS);
  bIsDone=aDF.IsDone();
  if (!bIsDone) {
    myErrorStatus=30; // wrong args are used for DSFiller
    return;
  }
  aDF.Perform();
  bIsDone=aDF.IsDone();
  if (!bIsDone) {
    myErrorStatus=31; // DSFiller failed
    return;
  }
  //
  // 2. Find shapes
  GEOMAlgo_ShapeSolid* pSS;
  GEOMAlgo_VertexSolid aVXS;
  GEOMAlgo_WireSolid aWRS;
  GEOMAlgo_ShellSolid aSHS;
  GEOMAlgo_SolidSolid aSLS;
  //
  pSS=NULL;
  //
  switch (myShapeType) {
    case TopAbs_VERTEX:
      pSS=&aVXS;
      break;
    case TopAbs_EDGE:
      pSS=&aWRS;
      break;
    case TopAbs_FACE:
      pSS=&aSHS;
      break;
    case TopAbs_SOLID:
      aSLS.SetShape2(myArg2);
      pSS=&aSLS;
      break;
    default:
      myErrorStatus=12; // unallowed sub-shape type
      return;
  }
  //
  pSS->SetFiller(aDF);
  pSS->Perform();
  iErr=pSS->ErrorStatus();
  if (iErr) {
    myErrorStatus=32; // builder ShapeSolid failed
    return;
  }
  //
  for (i=0; i<3; ++i) {
    const TopTools_ListOfShape& aLS=pSS->Shapes(aSts[i]);
    aIt.Initialize(aLS);
    for (; aIt.More(); aIt.Next()) {
      const TopoDS_Shape& aSImage=aIt.Value();
      if (myImages.IsBound(aSImage)) {
        const TopoDS_Shape& aSx=myImages.Find(aSImage);
        myMSS.Add(aSx, aSts[i]);
      }
      else {
        myErrorStatus=33;// can not find original shape
        return;
      }
    }
  }
}

Here is the call graph for this function:

Definition at line 221 of file GEOMAlgo_FinderShapeOn.cxx.

{
  Standard_Integer i, aNb, iErr;
  TopAbs_State aSt;
  TopAbs_Orientation aOr;
  gp_Pnt aP;
  TopTools_IndexedMapOfShape aM;
  //
  TopExp::MapShapes(myArg1, TopAbs_FACE, aM);
  const TopoDS_Face& aF=TopoDS::Face(aM(1));
  aOr=aF.Orientation();
  //
  aM.Clear();
  TopExp::MapShapes(myShape, myShapeType, aM);
  aNb=aM.Extent();
  if (!aNb) {
    myWarningStatus=10; // No found sub-shapes of type myShapeType
    return;
  }
  //
  for (i=1; i<=aNb; ++i) {
    const TopoDS_Shape& aS=aM(i);
    const TopoDS_Vertex& aV=TopoDS::Vertex(aS);
    aP=BRep_Tool::Pnt(aV);
    iErr=GEOMAlgo_SurfaceTools::GetState(aP, mySurface, myTolerance, aSt);
    if (aOr==TopAbs_REVERSED) {
      aSt=GEOMAlgo_SurfaceTools::ReverseState(aSt);
    }
    myMSS.Add(aS, aSt);
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 378 of file GEOMAlgo_FinderShapeOn.cxx.

{
  myErrorStatus=0;
  //
  Standard_Integer i, aNb;
  TopAbs_ShapeEnum aType;
  BRepLib_FaceError aFErr;
  BRepLib_MakeFace aMF;
  TopTools_IndexedMapOfShape aM;
  BRep_Builder aBB;
  TopoDS_Face aFace;
  TopoDS_Shell aSh;
  TopoDS_Solid aSd;
  //
  // Argument 1
  if (!myIsAnalytic) {
#if OCC_VERSION_LARGE > 0x06050100 // for OCC-6.5.2 and higher version
    aMF.Init(mySurface, Standard_True, Precision::Confusion());
#else
    aMF.Init(mySurface, Standard_True);
#endif
    aFErr=aMF.Error();
    if (aFErr!=BRepLib_FaceDone) {
      myErrorStatus=20; // can not build the face
      return;
    }
    //
    const TopoDS_Shape& aF=aMF.Shape();
    aFace=TopoDS::Face(aF);
    //
    // update tolerances
    aM.Add(aF);
    TopExp::MapShapes(aF, TopAbs_VERTEX, aM);
    TopExp::MapShapes(aF, TopAbs_EDGE, aM);
    aNb=aM.Extent();
    for (i=1; i<=aNb; ++i) {
      const TopoDS_Shape& aS=aM(i);
      aType=aS.ShapeType();
      switch (aType) {
      case TopAbs_VERTEX: {
        const TopoDS_Vertex& aVx=TopoDS::Vertex(aS);
        aBB.UpdateVertex(aVx, myTolerance);
      }
        break;
      case TopAbs_EDGE: {
        const TopoDS_Edge& aEx=TopoDS::Edge(aS);
        aBB.UpdateEdge(aEx, myTolerance);
      }
        break;
      case TopAbs_FACE: {
        const TopoDS_Face& aFx=TopoDS::Face(aS);
        aBB.UpdateFace(aFx, myTolerance);
      }
        break;
      default:
        break;
      }
    }
  } //
  else {
    aBB.MakeFace(aFace, mySurface, myTolerance);
  }
  //
  // make solid
  aBB.MakeShell(aSh);
  aBB.Add(aSh, aFace);
  aBB.MakeSolid(aSd);
  aBB.Add(aSd, aSh);
  myArg1=aSd;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 452 of file GEOMAlgo_FinderShapeOn.cxx.

{
  myErrorStatus=0;
  //
  TopoDS_Shape aSC;
  TopTools_DataMapOfShapeShape aOriginals;
  //
  myImages.Clear();
  //
  GEOMAlgo_FinderShapeOn::CopySource(myShape, myImages, aOriginals, aSC);
  //
  myArg2=aSC;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void GEOMAlgo_FinderShapeOn::Perform ( ) [virtual]

Reimplemented from GEOMAlgo_ShapeAlgo.

Definition at line 175 of file GEOMAlgo_FinderShapeOn.cxx.

{
  myErrorStatus=0;
  myWarningStatus=0;
  myLS.Clear();
  myMSS.Clear();
  //
  if (!myResult.IsNull()){
    myResult.Nullify();
  }
  //
  CheckData();
  if(myErrorStatus) {
    return;
  }
  //
  // Initialize the context
  GEOMAlgo_ShapeAlgo::Perform();
  //
  myIsAnalytic=GEOMAlgo_SurfaceTools::IsAnalytic(mySurface);
  //
  MakeArgument1();
  if(myErrorStatus) {
    return;
  }
  //
  if (myIsAnalytic && myShapeType==TopAbs_VERTEX) {
    FindVertices();
    return;
  }
  //
  MakeArgument2();
  if(myErrorStatus) {
    return;
  }
  //
  Find();
  if(myErrorStatus || myWarningStatus) {
    return;
  }
  //
}

Here is the call graph for this function:

const TopoDS_Shape & GEOMAlgo_ShapeAlgo::Result ( ) const [inherited]

Definition at line 101 of file GEOMAlgo_ShapeAlgo.cxx.

{
  return myResult;
}
void GEOMAlgo_ShapeAlgo::SetContext ( const Handle(IntTools_Context)&  theContext) [inherited]

Sets cashed geometrical tools

Definition at line 53 of file GEOMAlgo_ShapeAlgo.cxx.

{
  myContext=theContext;
}
void GEOMAlgo_ShapeAlgo::SetShape ( const TopoDS_Shape &  aS) [inherited]

Definition at line 69 of file GEOMAlgo_ShapeAlgo.cxx.

{
  myShape=aS;
}

Here is the caller graph for this function:

void GEOMAlgo_FinderShapeOn::SetShapeType ( const TopAbs_ShapeEnum  aST)

Definition at line 117 of file GEOMAlgo_FinderShapeOn.cxx.

{
  myShapeType=aType;
}

Definition at line 133 of file GEOMAlgo_FinderShapeOn.cxx.

{
  myState=aState;
}
void GEOMAlgo_FinderShapeOn::SetSurface ( const Handle(Geom_Surface)&  aS)

Definition at line 101 of file GEOMAlgo_FinderShapeOn.cxx.

{
  mySurface=aS;
}
void GEOMAlgo_ShapeAlgo::SetTolerance ( const Standard_Real  aT) [inherited]

Definition at line 85 of file GEOMAlgo_ShapeAlgo.cxx.

{
  myTolerance=aT;
}

Here is the caller graph for this function:

const TopoDS_Shape & GEOMAlgo_ShapeAlgo::Shape ( ) const [inherited]

Definition at line 77 of file GEOMAlgo_ShapeAlgo.cxx.

{
  return myShape;
}
const TopTools_ListOfShape & GEOMAlgo_FinderShapeOn::Shapes ( ) const

Definition at line 149 of file GEOMAlgo_FinderShapeOn.cxx.

{
  Standard_Boolean bIsConformState;
  Standard_Integer i, aNb;
  TopAbs_State aSt;
  TopTools_ListOfShape* pL;
  //
  pL=(TopTools_ListOfShape*) &myLS;
  pL->Clear();
  //
  aNb=myMSS.Extent();
  for (i=1; i<=aNb; ++i) {
    const TopoDS_Shape& aS=myMSS.FindKey(i);
    aSt=myMSS.FindFromIndex(i);
    //
    bIsConformState=GEOMAlgo_SurfaceTools::IsConformState(aSt, myState);
    if (bIsConformState) {
      pL->Append(aS);
    }
  }
  return myLS;
}

Here is the call graph for this function:

TopAbs_ShapeEnum GEOMAlgo_FinderShapeOn::ShapeType ( ) const

Definition at line 125 of file GEOMAlgo_FinderShapeOn.cxx.

{
  return myShapeType;
}

Definition at line 141 of file GEOMAlgo_FinderShapeOn.cxx.

{
  return myState;
}
Standard_EXPORT const Handle_Geom_Surface& GEOMAlgo_FinderShapeOn::Surface ( ) const
Standard_Real GEOMAlgo_ShapeAlgo::Tolerance ( ) const [inherited]

Definition at line 93 of file GEOMAlgo_ShapeAlgo.cxx.

{
  return myTolerance;
}

Here is the caller graph for this function:

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

TopoDS_Shape GEOMAlgo_FinderShapeOn::myArg1 [protected]

Definition at line 114 of file GEOMAlgo_FinderShapeOn.hxx.

TopoDS_Shape GEOMAlgo_FinderShapeOn::myArg2 [protected]

Definition at line 115 of file GEOMAlgo_FinderShapeOn.hxx.

Standard_Boolean GEOMAlgo_Algo::myComputeInternalShapes [protected, inherited]

Definition at line 73 of file GEOMAlgo_Algo.hxx.

Handle_IntTools_Context GEOMAlgo_ShapeAlgo::myContext [protected, inherited]

Definition at line 83 of file GEOMAlgo_ShapeAlgo.hxx.

Standard_Integer GEOMAlgo_Algo::myErrorStatus [protected, inherited]

Definition at line 71 of file GEOMAlgo_Algo.hxx.

TopTools_DataMapOfShapeShape GEOMAlgo_FinderShapeOn::myImages [protected]

Definition at line 117 of file GEOMAlgo_FinderShapeOn.hxx.

Standard_Boolean GEOMAlgo_FinderShapeOn::myIsAnalytic [protected]

Definition at line 119 of file GEOMAlgo_FinderShapeOn.hxx.

TopTools_ListOfShape GEOMAlgo_FinderShapeOn::myLS [protected]

Definition at line 116 of file GEOMAlgo_FinderShapeOn.hxx.

Definition at line 118 of file GEOMAlgo_FinderShapeOn.hxx.

TopoDS_Shape GEOMAlgo_ShapeAlgo::myResult [protected, inherited]

Definition at line 82 of file GEOMAlgo_ShapeAlgo.hxx.

TopoDS_Shape GEOMAlgo_ShapeAlgo::myShape [protected, inherited]

Definition at line 80 of file GEOMAlgo_ShapeAlgo.hxx.

TopAbs_ShapeEnum GEOMAlgo_FinderShapeOn::myShapeType [protected]

Definition at line 112 of file GEOMAlgo_FinderShapeOn.hxx.

Definition at line 113 of file GEOMAlgo_FinderShapeOn.hxx.

Handle_Geom_Surface GEOMAlgo_FinderShapeOn::mySurface [protected]

Definition at line 111 of file GEOMAlgo_FinderShapeOn.hxx.

Standard_Real GEOMAlgo_ShapeAlgo::myTolerance [protected, inherited]

Definition at line 81 of file GEOMAlgo_ShapeAlgo.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: