]> SALOME platform Git repositories - modules/multipr.git/blob - src/MULTIPR/MULTIPR_DecimationFilter.hxx
Salome HOME
*** empty log message ***
[modules/multipr.git] / src / MULTIPR / MULTIPR_DecimationFilter.hxx
1 // Project MULTIPR, IOLS WP1.2.1 - EDF/CS
2 // Partitioning/decimation module for the SALOME v3.2 platform
3
4 /**
5  * \file    MULTIPR_DecimationFilter.hxx
6  *
7  * \brief   Interface DecimationFilter: filter used for decimation.
8  *
9  * \author  Olivier LE ROUX - CS, Virtual Reality Dpt
10  * 
11  * \date    01/2007
12  */
13
14 #ifndef MULTIPR_DECIMATION_FILTER_HXX
15 #define MULTIPR_DECIMATION_FILTER_HXX
16
17 //*****************************************************************************
18 // Includes section
19 //*****************************************************************************
20
21 extern "C"
22 {
23     #include "med.h"
24 }
25
26 #include <iostream>
27 #include <vector>
28
29
30 namespace multipr
31 {
32
33 //*****************************************************************************
34 // Predeclaration
35 //*****************************************************************************
36
37 class Mesh;
38 class PointOfField;
39
40
41 //*****************************************************************************
42 // Interface DecimationFilter and factory to build filters.
43 // Should be derivated to implement new filter.
44 //*****************************************************************************
45
46 class DecimationFilter
47 {
48 public:
49     /**
50      * Decimation filter factory. Must be used to build any new filter from its name.
51      * \param  pFilterName name of the filter to be instanciated.
52      * \return a new instance of the given filter. 
53      */
54     static DecimationFilter* create(const char* pFilterName);
55     
56 public:
57     
58     /** 
59      * Builds an empty DecimationFilter (default constructor).
60      */
61     DecimationFilter() { /* do nothing */ }
62     
63     /**
64      * Destructor. Removes everything.
65      */
66     virtual ~DecimationFilter() { /* do nothing */ } 
67     
68     /**
69      * Interface. Creates a new Mesh by decimating the given Mesh with this DecimationFilter.
70      * \param  pMesh        any mesh to be decimated; must not be NULL.
71      * \param  pArgv        all the arguments of the filter as a string; must not be NULL.
72      * \param  pNameNewMesh name of the decimated mesh; must not be NULL.
73      * \return the decimated mesh.
74      */
75     virtual Mesh* apply(Mesh* pMesh, const char* pArgv, const char* pNameNewMesh) = 0;
76     
77 private:
78     
79     // do not allow copy constructor
80     DecimationFilter(const DecimationFilter&);
81     
82     // do not allow copy
83     DecimationFilter& operator=(const DecimationFilter&);
84     
85     // do not allow operator ==
86     bool operator==(const DecimationFilter&); 
87
88 }; // class DecimationFilter
89
90
91 //*****************************************************************************
92 // Filter : Average Gradient
93 //*****************************************************************************
94
95 class DecimationFilterGradAvg : public DecimationFilter
96 {
97 public:
98
99     /**
100      * Builds an empty DecimationFilterGradAvg (default constructor).
101      */
102     DecimationFilterGradAvg();
103     
104     /**
105      * Destructor. Removes everything.
106      */
107     virtual ~DecimationFilterGradAvg();
108     
109     /**
110      * Creates a new Mesh by decimating the given Mesh with this DecimationFilter.
111      * 
112      * For each element
113      *     Keep this element if all its points (related to a field) have a |gradient| > threshold.
114      *
115      * For each point, gradient is computed by considering all the neighbours in a sphere of radius r.
116      *
117      * \param  pMesh        any mesh to be decimated; must not be NULL.
118      * \param  pArgv        all the arguments of the filter as a string; must not be NULL.
119      *                      for GradAvg, expected "fieldName fieldIt threshold radius boxing" (5 parameters).
120      * \param  pNameNewMesh name of the decimated mesh; must not be NULL.
121      * \return the decimated mesh.
122      */
123     virtual Mesh* apply(Mesh* pMesh, const char* pArgv, const char* pNameNewMesh);
124     
125     /**
126      * Returns information about gradient.
127      */
128     void getGradientInfo(
129         Mesh*       pMesh, 
130         const char* pFieldName, 
131         int         pFieldIt, 
132         double      pRadius,
133         int         pBoxing,
134         double*     pOutGradMin,
135         double*     pOutGradAvg,
136         double*     pOutGradMax);
137     
138 private:
139
140     /**
141      * Returns the norm of the gradient of the field at the given point.
142      * Sub-method used by apply().
143      * \param  pPt        any point in the field.
144      * \param  pNeigbours neighbourhood of pPt.
145      * \return the norm of the gradient of the field in pPt.
146      */
147     med_float computeNormGrad(const PointOfField& pPt, const std::vector<PointOfField>& pNeighbours) const;
148     
149 private:
150     
151     // do not allow copy constructor
152     DecimationFilterGradAvg(const DecimationFilterGradAvg&);
153     
154     // do not allow copy
155     DecimationFilterGradAvg& operator=(const DecimationFilterGradAvg&);
156     
157     // do not allow operator ==
158     bool operator==(const DecimationFilterGradAvg&); 
159     
160 }; // class DecimationFilterGradAvg
161
162
163 } // namespace MULTIPR
164
165
166 #endif // MULTIPR_DECIMATION_FILTER_HXX
167
168 // EOF