Salome HOME
23507: Nodes can't be projected to a CAD
[modules/homard.git] / src / FrontTrack / FrontTrack_Projector.hxx
1 // File      : FrontTrack_Projector.hxx
2 // Created   : Wed Apr 26 20:12:13 2017
3 // Author    : Edward AGAPOV (eap)
4
5 #ifndef __FrontTrack_Projector_HXX__
6 #define __FrontTrack_Projector_HXX__
7
8 #include <TopoDS_Shape.hxx>
9 #include <Bnd_Box.hxx>
10
11 struct FT_RealProjector;
12
13 /*!
14  * \brief Projector of a point to a boundary shape. Wrapper of a real projection algo
15  */
16 class FT_Projector
17 {
18 public:
19
20   FT_Projector(const TopoDS_Shape& shape = TopoDS_Shape());
21   FT_Projector(const FT_Projector& other);
22   ~FT_Projector();
23
24   // initialize with a boundary shape, compute the bounding box
25   void setBoundaryShape(const TopoDS_Shape& shape);
26
27   // return the boundary shape
28   const TopoDS_Shape& getShape() const { return _shape; }
29
30   // return the bounding box
31   const Bnd_Box getBoundingBox() const { return _bndBox; }
32
33
34   // create a real projector
35   void prepareForProjection();
36
37   // return true if a previously found solution can be used to speed up the projection
38   bool canUsePrevSolution() const;
39
40   // return true if projection is not needed
41   bool isPlanarBoundary() const;
42
43
44   // switch a mode of usage of prevSolution.
45   // If projection fails, to try to project without usage of prevSolution.
46   // By default this mode is off
47   void tryWithoutPrevSolution( bool toTry ) { _tryWOPrevSolution = toTry; }
48
49   // project a point to the boundary shape
50   bool project( const gp_Pnt& point,
51                 const double  maxDist2,
52                 gp_Pnt&       projection,
53                 double*       newSolution,
54                 const double* prevSolution = 0);
55
56   // project a point to the boundary shape and check if the projection is within the shape boundary
57   bool projectAndClassify( const gp_Pnt& point,
58                            const double  maxDist2,
59                            gp_Pnt&       projection,
60                            double*       newSolution,
61                            const double* prevSolution = 0);
62
63   // check if a point lies on the boundary shape
64   bool isOnShape( const gp_Pnt& point,
65                   const double  tol2,
66                   double*       newSolution,
67                   const double* prevSolution = 0);
68
69 private:
70
71   FT_RealProjector* _realProjector;
72   Bnd_Box           _bndBox;
73   TopoDS_Shape      _shape;
74   bool              _tryWOPrevSolution;
75 };
76
77 #endif