]> SALOME platform Git repositories - plugins/blsurfplugin.git/blob - src/BLSURFPlugin/BLSURFPlugin_Attractor.hxx
Salome HOME
rnc: Small modification to ensure that objects used in setClassAttractorGeom have...
[plugins/blsurfplugin.git] / src / BLSURFPlugin / BLSURFPlugin_Attractor.hxx
1 //  Copyright (C) 2007-2010  CEA/DEN, EDF R&D
2 //
3 //  This library is free software; you can redistribute it and/or
4 //  modify it under the terms of the GNU Lesser General Public
5 //  License as published by the Free Software Foundation; either
6 //  version 2.1 of the License.
7 //
8 //  This library is distributed in the hope that it will be useful,
9 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
10 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11 //  Lesser General Public License for more details.
12 //
13 //  You should have received a copy of the GNU Lesser General Public
14 //  License along with this library; if not, write to the Free Software
15 //  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
16 //
17 //  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 //
19
20 // ---
21 // File    : BLSURFPlugin_Attractor.hxx
22 // Authors : Renaud Nédélec (OCC)
23 // ---
24 // 
25 // The idea of the algorithm used to calculate the distance on a 
26 // non-euclidian parametric surface has been found in the ref. below:
27 //
28 // Ref:"Accurate Anisotropic Fast Marching for Diffusion-Based Geodesic Tractography"
29 // S. Jbabdi, P. Bellec, R. Toro, Daunizeau, M. Pélégrini-Issac, and H. Benali1
30 //
31
32 #ifndef _BLSURFPlugin_Attractor_HXX_
33 #define _BLSURFPlugin_Attractor_HXX_
34
35 #include <vector>
36 #include <map>
37 #include <set>
38 #include <stdexcept>
39 #include <string>
40 #include <limits>
41 #include <utilities.h>
42
43 // OPENCASCADE includes
44 #include <BRep_Tool.hxx>
45 #include <TopExp.hxx>
46 #include <TopExp_Explorer.hxx>
47 #include <TopoDS.hxx>
48 #include <NCollection_Map.hxx>
49
50 #include <Geom_Surface.hxx>
51 #include <Handle_Geom_Surface.hxx>
52 #include <Geom2d_Curve.hxx>
53 #include <Handle_Geom2d_Curve.hxx>
54 #include <Geom_Curve.hxx>
55 #include <Handle_Geom_Curve.hxx>
56 #include <Handle_AIS_InteractiveObject.hxx>
57 #include <TopoDS_Vertex.hxx>
58 #include <TopoDS_Edge.hxx>
59 #include <TopoDS_Wire.hxx>
60 #include <TopoDS_Face.hxx>
61
62 #include <gp_Pnt2d.hxx>
63 #include <TopTools_IndexedMapOfShape.hxx>
64 #include <TopoDS_Shape.hxx>
65 #include <BRep_Builder.hxx>
66 #include <BRepTools.hxx>
67
68 #include <TopTools_DataMapOfShapeInteger.hxx>
69 #include <GProp_GProps.hxx>
70 #include <BRepGProp.hxx>
71
72 #ifndef WNT
73 #include <fenv.h>
74 #endif
75
76 #include <Standard_ErrorHandler.hxx>
77 #include <GeomAPI_ProjectPointOnCurve.hxx>
78 #include <GeomAPI_ProjectPointOnSurf.hxx>
79 #include <gp_XY.hxx>
80 #include <gp_XYZ.hxx>
81 #include <TopTools_MapOfShape.hxx>
82
83 #define TYPE_EXP 0
84 #define TYPE_LIN 1
85
86 class BLSURFPlugin_Attractor {
87   
88   public:
89     
90     BLSURFPlugin_Attractor ();
91     BLSURFPlugin_Attractor (const TopoDS_Face& Face, const TopoDS_Shape& Attractor, const std::string& attEntry); //, double Step = 0.015);
92     bool init();                                                // Calculates the discrete points correponding to attractor 
93                                                                 // and intialises the map of distances
94     void edgeInit(Handle(Geom_Surface) aSurf, const TopoDS_Edge& anEdge);
95     
96     double              GetSize (double u, double v);
97     TopoDS_Face         GetFace()           const { return _face; }
98     TopoDS_Shape        GetAttractorShape() const { return _attractorShape; }
99     std::string         GetAttractorEntry() const { return _attEntry; }
100 //     double              GetStep()           const { return _step; }
101     std::vector<double> GetParameters()     const 
102     { 
103       double tab_params[] = {_startSize, _endSize, _actionRadius, _constantRadius}; 
104       std::vector<double> params (tab_params, tab_params + sizeof(tab_params) / sizeof(double) );
105       return params;
106     }
107     
108     void SetParameters(double Start_Size, double End_Size, double Action_Radius, double Constant_Radius);
109     void SetType(int type){ _type = type; }
110     
111     void BuildMap();                                            // Builds the map of distances between source point and any point P(u,v)
112     bool IsMapBuilt() const { return _isMapBuilt; }             // Controls if the map has been built
113     bool Empty()      const { return _isEmpty; }
114   
115     typedef std::vector<double> TDiscreteParam;
116     typedef std::vector< std::vector<double> > TDistMap;
117     typedef std::vector< std::vector<bool> > TPointSet;
118     typedef std::set< std::vector<double> > TTrialSet;
119     typedef std::vector<double> Trial_Pnt;
120     typedef std::vector<int> IJ_Pnt;
121           
122   private:
123     
124     TopoDS_Face       _face;
125     TopoDS_Shape      _attractorShape;
126     std::string       _attEntry;
127     TDiscreteParam    _vectU;
128     TDiscreteParam    _vectV;
129     TDistMap          _DMap;
130     TPointSet         _known;
131     TTrialSet         _trial;
132     int               _type;                                    // Type of function used to calculate the size from the distance (unused for now)
133 //     double            _step;                                    // Step between two values of the discretized parametric space in U or V direction
134     int               _gridU;                                   // Number of grid points in U direction
135     int               _gridV;                                   // Number of grid points in V direction
136     double            _u1, _u2, _v1, _v2;                       // Bounds of the parametric space of the face 
137     double            _startSize, _endSize;                     // User parameters
138     double            _actionRadius, _constantRadius;           //
139     
140     bool              _isMapBuilt;
141     bool              _isEmpty;
142     
143     double            _distance(double u, double v);
144 };    
145
146 #endif