1 // Copyright (C) 2007-2008 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.
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
19 // Partitioning/decimation module for the SALOME v3.2 platform
22 * \file MULTIPR_DecimationFilter.hxx
24 * \brief Interface DecimationFilter: filter used for decimation.
26 * \author Olivier LE ROUX - CS, Virtual Reality Dpt
31 #ifndef MULTIPR_DECIMATION_FILTER_HXX
32 #define MULTIPR_DECIMATION_FILTER_HXX
34 //*****************************************************************************
36 //*****************************************************************************
50 //*****************************************************************************
52 //*****************************************************************************
58 //*****************************************************************************
59 // Interface DecimationFilter and factory to build filters.
60 // Should be derivated to implement new filter.
61 //*****************************************************************************
63 class DecimationFilter
67 * Decimation filter factory. Must be used to build any new filter from its name.
68 * \param pFilterName name of the filter to be instanciated.
69 * \return a new instance of the given filter.
71 static DecimationFilter* create(const char* pFilterName);
76 * Builds an empty DecimationFilter (default constructor).
78 DecimationFilter() { /* do nothing */ }
81 * Destructor. Removes everything.
83 virtual ~DecimationFilter() { /* do nothing */ }
86 * Interface. Creates a new Mesh by decimating the given Mesh with this DecimationFilter.
87 * \param pMesh any mesh to be decimated; must not be NULL.
88 * \param pArgv all the arguments of the filter as a string; must not be NULL.
89 * \param pNameNewMesh name of the decimated mesh; must not be NULL.
90 * \return the decimated mesh.
92 virtual Mesh* apply(Mesh* pMesh, const char* pArgv, const char* pNameNewMesh) = 0;
96 // do not allow copy constructor
97 DecimationFilter(const DecimationFilter&);
100 DecimationFilter& operator=(const DecimationFilter&);
102 // do not allow operator ==
103 bool operator==(const DecimationFilter&);
105 }; // class DecimationFilter
108 //*****************************************************************************
109 // Filter : Average Gradient
110 //*****************************************************************************
112 class DecimationFilterGradAvg : public DecimationFilter
117 * Builds an empty DecimationFilterGradAvg (default constructor).
119 DecimationFilterGradAvg();
122 * Destructor. Removes everything.
124 virtual ~DecimationFilterGradAvg();
127 * Creates a new Mesh by decimating the given Mesh with this DecimationFilter.
130 * Keep this element if all its points (related to a field) have a |gradient| > threshold.
132 * For each point, gradient is computed by considering all the neighbours in a sphere of radius r.
134 * \param pMesh any mesh to be decimated; must not be NULL.
135 * \param pArgv all the arguments of the filter as a string; must not be NULL.
136 * for GradAvg, expected "fieldName fieldIt threshold radius boxing" (5 parameters).
137 * \param pNameNewMesh name of the decimated mesh; must not be NULL.
138 * \return the decimated mesh.
140 virtual Mesh* apply(Mesh* pMesh, const char* pArgv, const char* pNameNewMesh);
143 * Returns information about gradient.
145 void getGradientInfo(
147 const char* pFieldName,
153 double* pOutGradMax);
158 * Returns the norm of the gradient of the field at the given point.
159 * Sub-method used by apply().
160 * \param pPt any point in the field.
161 * \param pNeigbours neighbourhood of pPt.
162 * \return the norm of the gradient of the field in pPt.
164 med_float computeNormGrad(const PointOfField& pPt, const std::vector<PointOfField>& pNeighbours) const;
168 // do not allow copy constructor
169 DecimationFilterGradAvg(const DecimationFilterGradAvg&);
172 DecimationFilterGradAvg& operator=(const DecimationFilterGradAvg&);
174 // do not allow operator ==
175 bool operator==(const DecimationFilterGradAvg&);
177 }; // class DecimationFilterGradAvg
179 //*****************************************************************************
181 //*****************************************************************************
183 class DecimationFilterTreshold : public DecimationFilter
188 * Builds an empty DecimationFilterTreshold (default constructor).
190 DecimationFilterTreshold();
193 * Destructor. Removes everything.
195 virtual ~DecimationFilterTreshold();
198 * Creates a new Mesh by decimating the given Mesh with this DecimationFilter.
201 * Keep this element if all its points (related to a field) have a value > threshold.
203 * \param pMesh any mesh to be decimated; must not be NULL.
204 * \param pArgv all the arguments of the filter as a string; must not be NULL.
205 * for GradAvg, expected "fieldName fieldIt threshold radius boxing" (5 parameters).
206 * \param pNameNewMesh name of the decimated mesh; must not be NULL.
207 * \return the decimated mesh.
209 virtual Mesh* apply(Mesh* pMesh, const char* pArgv, const char* pNameNewMesh);
214 // do not allow copy constructor
215 DecimationFilterTreshold(const DecimationFilterTreshold&);
218 DecimationFilterTreshold& operator=(const DecimationFilterTreshold&);
220 // do not allow operator ==
221 bool operator==(const DecimationFilterTreshold&);
223 }; // class DecimationFilterTreshold
225 } // namespace MULTIPR
228 #endif // MULTIPR_DECIMATION_FILTER_HXX