Back to index

salome-geom  6.5.0
Functions
GEOMAlgo_GetInPlace_1.cxx File Reference
#include <GEOMAlgo_GetInPlace.hxx>
#include <math.h>
#include <gp_Pnt.hxx>
#include <gp_Vec.hxx>
#include <gp_Pnt2d.hxx>
#include <gp_Dir2d.hxx>
#include <Geom_Surface.hxx>
#include <Geom2d_Curve.hxx>
#include <Geom2d_Line.hxx>
#include <Geom2d_TrimmedCurve.hxx>
#include <Geom2dAdaptor_Curve.hxx>
#include <Geom2dHatch_Hatcher.hxx>
#include <Geom2dHatch_Intersector.hxx>
#include <HatchGen_Domain.hxx>
#include <GeomAPI_ProjectPointOnCurve.hxx>
#include <TopAbs_State.hxx>
#include <TopAbs_ShapeEnum.hxx>
#include <TopAbs_Orientation.hxx>
#include <TopoDS_Vertex.hxx>
#include <TopoDS_Edge.hxx>
#include <TopoDS_Solid.hxx>
#include <TopoDS_Face.hxx>
#include <BRep_Tool.hxx>
#include <TopExp_Explorer.hxx>
#include <BRepTools.hxx>
#include <BRepClass3d_SolidClassifier.hxx>
#include <IntTools_Tools.hxx>
#include <BOPTools_Tools3D.hxx>
#include <BOPTools_Tools2D.hxx>

Go to the source code of this file.

Functions

static Standard_Integer PntInEdge (const TopoDS_Edge &aF, gp_Pnt &aP)
static Standard_Integer PntInEdge (const TopoDS_Edge &aF, gp_Pnt &aP, Standard_Real &aT)
static Standard_Integer PntInFace (const TopoDS_Face &aF, gp_Pnt &aP)
static Standard_Integer PntInFace (const TopoDS_Face &aF, gp_Pnt &aP, gp_Pnt2d &theP2D)
static Standard_Integer PntInSolid (const TopoDS_Solid &aZ, const Standard_Real aTol, gp_Pnt &aP)

Function Documentation

Standard_Integer PntInEdge ( const TopoDS_Edge &  aF,
gp_Pnt &  aP 
) [static]

Definition at line 199 of file GEOMAlgo_GetInPlace_1.cxx.

{
  Standard_Integer iErr;
  Standard_Real aT;
  //
  iErr=PntInEdge(aE, aP, aT);
  //
  return iErr;
}

Here is the caller graph for this function:

Standard_Integer PntInEdge ( const TopoDS_Edge &  aF,
gp_Pnt &  aP,
Standard_Real &  aT 
) [static]

Definition at line 214 of file GEOMAlgo_GetInPlace_1.cxx.

{
  Standard_Integer iErr;
  Standard_Real aT1, aT2;
  Handle(Geom_Curve) aC3D;
  //
  iErr=0;
  //
  aC3D=BRep_Tool::Curve(aE, aT1, aT2);
  aT=IntTools_Tools::IntermediatePoint(aT1, aT2);
  aC3D->D0(aT, aP);
  //
  return iErr;
}

Here is the call graph for this function:

Standard_Integer PntInFace ( const TopoDS_Face &  aF,
gp_Pnt &  aP 
) [static]

Definition at line 273 of file GEOMAlgo_GetInPlace_1.cxx.

{
  Standard_Integer iErr;
  //
  gp_Pnt2d aP2Dx;
  //
  iErr=PntInFace(aF, aP, aP2Dx);
  //
  return iErr;
}

Here is the caller graph for this function:

Standard_Integer PntInFace ( const TopoDS_Face &  aF,
gp_Pnt &  aP,
gp_Pnt2d &  theP2D 
) [static]

Definition at line 288 of file GEOMAlgo_GetInPlace_1.cxx.

{
  Standard_Boolean bIsDone, bHasFirstPoint, bHasSecondPoint;
  Standard_Integer iErr, aIx, aNbDomains, i;
  Standard_Real aUMin, aUMax, aVMin, aVMax;
  Standard_Real aVx, aUx, aV1, aV2, aU1, aU2, aEpsT;
  Standard_Real aTotArcIntr, aTolTangfIntr, aTolHatch2D, aTolHatch3D;
  gp_Dir2d aD2D (0., 1.);
  gp_Pnt2d aP2D;
  gp_Pnt aPx;
  Handle(Geom2d_Curve) aC2D;
  Handle(Geom2d_TrimmedCurve) aCT2D;
  Handle(Geom2d_Line) aL2D;
  Handle(Geom_Surface) aS;
  TopAbs_Orientation aOrE;
  TopoDS_Face aFF;
  TopExp_Explorer aExp;
  //
  aTolHatch2D=1.e-8;
  aTolHatch3D=1.e-8;
  aTotArcIntr=1.e-10;
  aTolTangfIntr=1.e-10;
  //
  Geom2dHatch_Intersector aIntr(aTotArcIntr, aTolTangfIntr);
  Geom2dHatch_Hatcher aHatcher(aIntr,
                            aTolHatch2D, aTolHatch3D,
                            Standard_True, Standard_False);
  //
  iErr=0;
  aEpsT=1.e-12;
  //
  aFF=aF;
  aFF.Orientation (TopAbs_FORWARD);
  //
  aS=BRep_Tool::Surface(aFF);
  BRepTools::UVBounds(aFF, aUMin, aUMax, aVMin, aVMax);
  //
  // 1
  aExp.Init (aFF, TopAbs_EDGE);
  for (; aExp.More() ; aExp.Next()) {
    const TopoDS_Edge& aE=*((TopoDS_Edge*)&aExp.Current());
    aOrE=aE.Orientation();
    //
    aC2D=BRep_Tool::CurveOnSurface (aE, aFF, aU1, aU2);
    if (aC2D.IsNull() ) {
      iErr=1;
      return iErr;
    }
    if (fabs(aU1-aU2) < aEpsT) {
      iErr=2;
      return iErr;
    }
    //
    aCT2D=new Geom2d_TrimmedCurve(aC2D, aU1, aU2);
    aHatcher.AddElement(aCT2D, aOrE);
  }// for (; aExp.More() ; aExp.Next()) {
  //
  // 2
  aUx=IntTools_Tools::IntermediatePoint(aUMin, aUMax);
  aP2D.SetCoord(aUx, 0.);
  aL2D=new Geom2d_Line (aP2D, aD2D);
  Geom2dAdaptor_Curve aHCur(aL2D);
  //
  aIx=aHatcher.AddHatching(aHCur) ;
  //
  // 3.
  aHatcher.Trim();
  bIsDone=aHatcher.TrimDone(aIx);
  if (!bIsDone) {
    iErr=3;
    return iErr;
  }
  //
  aHatcher.ComputeDomains(aIx);
  bIsDone=aHatcher.IsDone(aIx);
  if (!bIsDone) {
    iErr=4;
    return iErr;
  }
  //
  // 4.
  aNbDomains=aHatcher.NbDomains(aIx);
  for (i=1; i<=aNbDomains; ++i) {
    const HatchGen_Domain& aDomain=aHatcher.Domain (aIx, i) ;
    bHasFirstPoint=aDomain.HasFirstPoint();
    if (!bHasFirstPoint) {
      iErr=5;
      return iErr;
    }
    //
    aV1=aDomain.FirstPoint().Parameter();
    //
    bHasSecondPoint=aDomain.HasSecondPoint();
    if (!bHasSecondPoint) {
      iErr=6;
      return iErr;
    }
    //
    aV2=aDomain.SecondPoint().Parameter();
    //
    aVx=IntTools_Tools::IntermediatePoint(aV1, aV2);
    //
    break;
  }
  //
  aS->D0(aUx, aVx, aPx);
  //
  theP2D.SetCoord(aUx, aVx);
  theP=aPx;
  //
  return iErr;
}

Here is the call graph for this function:

Standard_Integer PntInSolid ( const TopoDS_Solid &  aZ,
const Standard_Real  aTol,
gp_Pnt &  aP 
) [static]

Definition at line 234 of file GEOMAlgo_GetInPlace_1.cxx.

{
  Standard_Integer iErr;
  Standard_Real aUx, aVx, aCoef;
  gp_Pnt aPx;
  gp_Pnt2d aP2Dx;
  gp_Vec aDNx;

  TopoDS_Face aF;
  TopExp_Explorer aExp;
  //
  iErr=0;
  aCoef=10.;
  //
  aExp.Init (aZ, TopAbs_FACE);
  for (; aExp.More() ; aExp.Next()) {
    aF=*((TopoDS_Face*)&aExp.Current());
    break;
  }
  //
  iErr=PntInFace(aF, aPx, aP2Dx);
  if (iErr) {
    return iErr;
  }
  //
  aP2Dx.Coord(aUx, aVx);
  BOPTools_Tools2D::FaceNormal(aF, aUx, aVx, aDNx);
  aDNx.Reverse();
  //
  aP.SetXYZ(aPx.XYZ()+aCoef*aTol*aDNx.XYZ());
  //
  return iErr;
}

Here is the call graph for this function:

Here is the caller graph for this function: