#include <Draw_Interpretor.hxx>
#include <DBRep.hxx>
#include <DrawTrSurf.hxx>
+#include <Draw_Viewer.hxx>
#include <string.h>
#include <stdio.h>
#include <Geom_Line.hxx>
#include <IntCurvesFace_Intersector.hxx>
+#include <IntCurvesFace_ShapeIntersector.hxx>
#include <TopAbs.hxx>
#include <TopAbs_Orientation.hxx>
static Standard_Integer emptyshape(Draw_Interpretor&, Standard_Integer, const char** );
static Standard_Integer subshape (Draw_Interpretor&, Standard_Integer, const char** );
static Standard_Integer brepintcs (Draw_Interpretor&, Standard_Integer, const char** );
+static Standard_Integer intcshape (Draw_Interpretor&, Standard_Integer, const char** );
static Standard_Integer MakeBoss (Draw_Interpretor&, Standard_Integer, const char** );
static Standard_Integer MakeShell (Draw_Interpretor&, Standard_Integer, const char** );
static Standard_Integer xbounds (Draw_Interpretor&, Standard_Integer, const char** );
"Calcul d'intersection entre face et curve : BRepIntCS curve1 [curve2 ...] shape [res] [tol]"
,__FILE__,brepintcs,g);
+ theCommands.Add("intcshape", "command for testing algorithm IntCurvesFace_ShapeIntersector",
+ __FILE__, intcshape, g);
theCommands.Add("makeboss", "create a boss on the shape myS", __FILE__, MakeBoss, g);
theCommands.Add("mksh", "create a shell on Shape", __FILE__, MakeShell, g);
theCommands.Add("xbounds", "xbounds face", __FILE__, xbounds, g);
return 0;
}
//=======================================================================
+//function : intcshape
+//purpose :
+//=======================================================================
+Standard_Integer intcshape(Draw_Interpretor& theDI,
+ Standard_Integer theArgNb,
+ const char** theArgVec)
+{
+ if (theArgNb < 2) {
+ theDI << " use intcshape Shape [Line] [Pmin] [Pmax]\n";
+ return 1;
+ }
+ TopoDS_Shape aS = DBRep::Get(theArgVec[1]);
+ if (aS.IsNull()) {
+ theDI << " Null Shape is not allowed here\n";
+ return 1;
+ }
+
+ IntCurvesFace_ShapeIntersector anInter;
+ anInter.Load(aS, 1e-7);
+
+ if (theArgNb > 2)
+ {
+ Handle(Geom_Curve) anObj = DrawTrSurf::GetCurve(theArgVec[2]);
+ if (anObj.IsNull())
+ {
+ theDI << " Null curve is not allowed here\n";
+ return 1;
+ }
+ Handle(Geom_Line) aL = Handle(Geom_Line)::DownCast(anObj);
+ Standard_Real aPMin = (theArgNb > 3) ?
+ Draw::Atof(theArgVec[3]) : (-RealLast());
+ Standard_Real aPMax = (theArgNb > 4) ?
+ Draw::Atof(theArgVec[4]) : (RealLast());
+
+ anInter.Perform(aL->Lin(), aPMin, aPMax);
+ }
+ else
+ {
+ Draw_Viewer aDout;
+ theDI << "Pick positions with button \n";
+ Standard_Integer anId, aX, aY, aB;
+ gp_Trsf aT;
+ gp_Pnt aP1, aP2;
+ aDout.Select(anId, aX, aY, aB);
+
+ aDout.GetTrsf(anId, aT);
+ aT.Invert();
+ Standard_Real aZ = aDout.Zoom(anId);
+ aP2.SetCoord((Standard_Real)aX / aZ, (Standard_Real)aY / aZ, 0.0);
+ aP2.Transform(aT);
+ aP1.SetCoord((Standard_Real)aX / aZ, (Standard_Real)aY / aZ, -1.0);
+ aP1.Transform(aT);
+
+ gp_Ax1 anAxe(aP1, gp_Vec(aP1, aP2));
+ anInter.Perform(anAxe, -RealLast(), RealLast());
+ }
+
+ Standard_Integer aNBPoints = 0;
+ for (Standard_Integer anI = 1; anI <= anInter.NbPnt(); anI++)
+ {
+ gp_Pnt aCurP = anInter.Pnt(anI);
+ IntCurveSurface_TransitionOnCurve aTransition = anInter.Transition(anI);
+ theDI << "(" << aCurP.X() << ", " << aCurP.Y() << ", " << aCurP.Z() << ") : ";
+ switch (aTransition) {
+ case IntCurveSurface_Tangent:
+ theDI << "Tangent\n";
+ break;
+ case IntCurveSurface_In:
+ theDI << "In\n";
+ break;
+ case IntCurveSurface_Out:
+ theDI << "Out\n";
+ break;
+ default:
+ break;
+ }
+ aNBPoints++;
+ }
+ if (aNBPoints == 0)
+ {
+ theDI << "Points of intersections are not found\n";
+ }
+ return 0;
+}
+//=======================================================================
//function : MakeBoss
//purpose :
//=======================================================================