1 // Copyright (C) 2007-2016 CEA/DEN, EDF R&D
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, or (at your option) any later version.
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.
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
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 // File : BLSURFPlugin_Attractor.hxx
22 // Authors : Renaud Nédélec (OCC)
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:
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
32 #ifndef _BLSURFPlugin_Attractor_HXX_
33 #define _BLSURFPlugin_Attractor_HXX_
41 #include <utilities.h>
43 // OPENCASCADE includes
44 #include <BRep_Tool.hxx>
46 #include <TopExp_Explorer.hxx>
48 #include <NCollection_Map.hxx>
50 #include <Geom_Surface.hxx>
51 #include <Geom2d_Curve.hxx>
52 #include <Geom_Curve.hxx>
53 #include <TopoDS_Vertex.hxx>
54 #include <TopoDS_Edge.hxx>
55 #include <TopoDS_Wire.hxx>
56 #include <TopoDS_Face.hxx>
58 #include <gp_Pnt2d.hxx>
59 #include <TopTools_IndexedMapOfShape.hxx>
60 #include <TopoDS_Shape.hxx>
61 #include <BRep_Builder.hxx>
62 #include <BRepTools.hxx>
64 #include <TopTools_DataMapOfShapeInteger.hxx>
65 #include <GProp_GProps.hxx>
66 #include <BRepGProp.hxx>
72 #include <Standard_ErrorHandler.hxx>
73 #include <GeomAPI_ProjectPointOnCurve.hxx>
74 #include <GeomAPI_ProjectPointOnSurf.hxx>
77 #include <TopTools_MapOfShape.hxx>
82 class BLSURFPlugin_Attractor {
86 BLSURFPlugin_Attractor ();
87 BLSURFPlugin_Attractor (const TopoDS_Face& Face, const TopoDS_Shape& Attractor, const std::string& attEntry);
89 bool init(); // Calculates the discrete points correponding to attractor
90 // and intialises the map of distances
91 void edgeInit(Handle(Geom_Surface) aSurf, const TopoDS_Edge& anEdge);
93 double GetSize (double u, double v);
94 TopoDS_Face GetFace() const { return _face; }
95 TopoDS_Shape GetAttractorShape() const { return _attractorShape; }
96 std::string GetAttractorEntry() const { return _attEntry; }
97 std::vector<double> GetParameters() const
99 double tab_params[] = {_startSize, _endSize, _actionRadius, _constantRadius};
100 std::vector<double> params (tab_params, tab_params + sizeof(tab_params) / sizeof(double) );
104 void SetParameters(double Start_Size, double End_Size, double Action_Radius, double Constant_Radius);
105 void SetType(int type){ _type = type; }
107 void BuildMap(); // Builds the map of distances between source point and any point P(u,v)
108 bool IsMapBuilt() const { return _isMapBuilt; } // Controls if the map has been built
109 bool Empty() const { return _isEmpty; }
111 typedef std::vector<double> TDiscreteParam;
112 typedef std::vector< std::vector<double> > TDistMap;
113 typedef std::vector< std::vector<bool> > TPointSet;
114 typedef std::set< std::vector<double> > TTrialSet;
115 typedef std::vector<double> Trial_Pnt;
116 typedef std::vector<int> IJ_Pnt;
121 TopoDS_Shape _attractorShape;
122 std::string _attEntry;
123 TDiscreteParam _vectU;
124 TDiscreteParam _vectV;
128 int _type; // Type of function used to calculate the size from the distance (unused for now)
129 int _gridU; // Number of grid points in U direction
130 int _gridV; // Number of grid points in V direction
131 double _u1, _u2, _v1, _v2; // Bounds of the parametric space of the face
132 double _startSize, _endSize; // User parameters
133 double _actionRadius, _constantRadius; //
138 // data of a specific case: a point attractor on a plane
139 Handle(Geom_Surface) _plane;
140 gp_Pnt _attractorPnt;
142 double (BLSURFPlugin_Attractor::*_distance)(double u, double v); // Retrieve the value of the distance map at point (u,v) of the parametric space of _face
143 double _distanceFromMap(double u, double v);
144 double _distanceFromPoint(double u, double v);