From 46a4fc674e1b80398d142b39ac8395d997065cc7 Mon Sep 17 00:00:00 2001 From: gka Date: Mon, 15 May 2006 13:50:06 +0000 Subject: [PATCH] Added tangent plane for thru sections --- src/GEOMImpl/GEOMImpl_PlaneDriver.cxx | 44 ++++++++++++++++++++++++++- 1 file changed, 43 insertions(+), 1 deletion(-) diff --git a/src/GEOMImpl/GEOMImpl_PlaneDriver.cxx b/src/GEOMImpl/GEOMImpl_PlaneDriver.cxx index 8941ba280..dd09d2941 100644 --- a/src/GEOMImpl/GEOMImpl_PlaneDriver.cxx +++ b/src/GEOMImpl/GEOMImpl_PlaneDriver.cxx @@ -27,6 +27,8 @@ #include #include +#include +#include #include #include @@ -42,6 +44,8 @@ #include #include #include +#include +#include #include #include @@ -126,7 +130,45 @@ Standard_Integer GEOMImpl_PlaneDriver::Execute(TFunction_Logbook& log) const Standard_TypeMismatch::Raise("Plane creation aborted: non-planar face given as argument"); } aShape = BRepBuilderAPI_MakeFace(aGS, -aSize, +aSize, -aSize, +aSize).Shape(); - } else { + } + else if (aType == PLANE_TANGENT_FACE) + { + Handle(GEOM_Function) aRefFace = aPI.GetFace(); + TopoDS_Shape aShape1 = aRefFace->GetValue(); + if(aShape1.IsNull()) + Standard_TypeMismatch::Raise("Plane was not created.Basis face was not specified"); + TopoDS_Face aFace = TopoDS::Face(aShape1); + + Standard_Real aKoefU = aPI.GetParameterU(); + Standard_Real aKoefV = aPI.GetParameterV(); + Standard_Real aUmin,aUmax,aVmin,aVmax; + ShapeAnalysis::GetFaceUVBounds(aFace,aUmin,aUmax,aVmin,aVmax); + Standard_Real aDeltaU = aUmax - aUmin; + Standard_Real aDeltaV = aVmax - aVmin; + Standard_Real aParamU = aUmin + aDeltaU*aKoefU; + Standard_Real aParamV = aVmin + aDeltaV*aKoefV; + Handle(Geom_Surface) aSurf = BRep_Tool::Surface(aFace); + if(aSurf.IsNull()) + Standard_TypeMismatch::Raise("Plane was not created.Base surface is absent"); + gp_Vec aVecU,aVecV; + gp_Pnt aPLoc; + aSurf->D1(aParamU,aParamV,aPLoc,aVecU,aVecV); + BRepTopAdaptor_FClass2d clas(aFace,Precision::PConfusion()); + + TopAbs_State stOut= clas.PerformInfinitePoint(); + gp_Pnt2d aP2d(aParamU,aParamV); + TopAbs_State st= clas.Perform(aP2d); + if(st == stOut) + Standard_TypeMismatch::Raise("Plane was not created.Point lies outside the face"); + gp_Vec aNorm = aVecU^aVecV; + gp_Ax3 anAxis(aPLoc,gp_Dir(aNorm),gp_Dir(aVecU)); + gp_Pln aPlane(anAxis); + BRepBuilderAPI_MakeFace aTool(aPlane, -aSize, +aSize, -aSize, +aSize); + if(aTool.IsDone()) + aShape = aTool.Shape(); + } + + else { } if (aShape.IsNull()) return 0; -- 2.39.2