1 // Project MULTIPR, IOLS WP1.2.1 - EDF/CS
2 // Partitioning/decimation module for the SALOME v3.2 platform
5 * \file MULTIPR_DecimationAccel.hxx
7 * \brief Interface DecimationAccel: acceleration structure used for decimation.
9 * \author Olivier LE ROUX - CS, Virtual Reality Dpt
14 #ifndef MULTIPR_DECIMATION_ACCEL_HXX
15 #define MULTIPR_DECIMATION_ACCEL_HXX
17 //*****************************************************************************
19 //*****************************************************************************
33 //*****************************************************************************
35 //*****************************************************************************
40 //*****************************************************************************
41 // Interface DecimationAccel
42 //*****************************************************************************
49 * Builds an empty DecimationAccel (default constructor).
51 DecimationAccel() { /* do nothing */ }
54 * Destructor. Removes everything.
56 virtual ~DecimationAccel() { /* do nothing */ }
58 //---------------------------------------------------------------------
60 //---------------------------------------------------------------------
63 * Interface. Configures this acceleration structure. String is used for genericity.
64 * \param pArgv all the configuration parameters in a string.
66 virtual void configure(const char* pArgv) = 0;
69 * Interface. Creates a new acceleration structure and fills it with the given list of points.
70 * \param pPts list of points to be inserted in the acceleration structure.
72 virtual void create(const std::vector<PointOfField>& pPts) = 0;
75 * Interface. Finds all the points in a sphere defined by its center (x,y,z) and its radius.
76 * \param pCenterX x-coordinates of the center of the sphere.
77 * \param pCenterY y-coordinates of the center of the sphere.
78 * \param pCenterZ z-coordinates of the center of the sphere.
79 * \param pRadius radius of the sphere.
80 * \return all the points in a sphere defined by its center (x,y,z) and its radius.
82 virtual std::vector<PointOfField> findNeighbours(
86 med_float pRadius) const = 0;
88 //---------------------------------------------------------------------
90 //---------------------------------------------------------------------
93 * Sets the flag which control the stream operator <<.
94 * \param pFlag new flag value.
96 void setPrintAll(bool pFlag) { mFlagPrintAll = pFlag; }
99 * Dumps any GaussLoc to the given output stream.
100 * \param pOs any output stream.
101 * \param pA any DecimationAccel.
102 * \return the output stream pOs.
104 friend std::ostream& operator<<(std::ostream& pOs, DecimationAccel& pA);
108 bool mFlagPrintAll; /** Flag to control the behaviour of the stream operator <<. */
112 // do not allow copy constructor
113 DecimationAccel(const DecimationAccel&);
116 DecimationAccel& operator=(const DecimationAccel&);
118 // do not allow operator ==
119 bool operator==(const DecimationAccel&);
121 }; // class DecimationAccel
124 //*****************************************************************************
125 // Interface DecimationFilter and factory to build filters.
126 //*****************************************************************************
128 class DecimationAccelGrid : public DecimationAccel
133 * Builds an empty DecimationAccelGrid (default constructor).
135 DecimationAccelGrid();
138 * Destructor. Removes everything.
140 virtual ~DecimationAccelGrid();
143 * Resets this object in its state by default (empty). Cleans memory.
147 //---------------------------------------------------------------------
149 //---------------------------------------------------------------------
152 * Configures this acceleration structure. String is used for genericity.
153 * \param pArgv assumes "size_x size_y size_z": number of cells along each axis.
155 virtual void configure(const char* pArgv);
158 * Creates a new acceleration structure and fills it with the given list of points.
159 * setSize() must have been called before.
160 * \param pPts list of points to be inserted in the acceleration structure.
161 * \throw IllegalStateException if setSize() has not been called before.
163 virtual void create(const std::vector<PointOfField>& pPts);
166 * Finds all the points in a sphere defined by its center (x,y,z) and its radius.
167 * \param pCenterX x-coordinates of the center of the sphere.
168 * \param pCenterY y-coordinates of the center of the sphere.
169 * \param pCenterZ z-coordinates of the center of the sphere.
170 * \param pRadius radius of the sphere.
171 * \return all the points in a sphere defined by its center (x,y,z) and its radius.
173 virtual std::vector<PointOfField> findNeighbours(
177 med_float pRadius) const;
180 * Returns the coordinates of the cell which contain the point (x,y,z).
181 * Clamping is performed on (pIx, pIy, pIz) to avoid out of bounds.
182 * \param pX (in) X-coordinates of the point.
183 * \param pY (in) Y-coordinates of the point.
184 * \param pZ (in) Z-coordinates of the point.
185 * \param pIx (out) X-index of the cell which contain the point (x,y,z).
186 * \param pIy (out) Y-index.
187 * \param pIz (out) Z-index.
190 med_float pX, med_float pY, med_float pZ,
191 int* pIx, int* pIy, int* pIz) const;
194 * Returns the index of the cell whose coordinates are (i, j, k).
198 * \return the index of the cell (i, j, k).
200 int getCellIndex(int pI, int pJ, int pK) const;
203 * Returns the list of points contained in the cell of pPt.
204 * \param pPt any point which coordinates are in the bbox of this acceleration structure.
205 * \return the list of points contained in the cell of pPt.
207 std::vector<PointOfField>& getCell(const PointOfField& pPt);
209 //---------------------------------------------------------------------
211 //---------------------------------------------------------------------
214 * Dumps any GaussLoc to the given output stream.
215 * \param pOs any output stream.
216 * \param pG any DecimationAccelGrid.
217 * \return the output stream pOs.
219 friend std::ostream& operator<<(std::ostream& pOs, DecimationAccelGrid& pG);
224 * Computes the axis-aligned bounding box of a set of points.
225 * Sets the fields mMin/mMax.
226 * \param pPts list of points.
228 void computeBBox(const std::vector<PointOfField>& pPts);
232 int mNum; /**< Number of points in the grid. */
233 med_float mMin[3]; /**< Bounding box, min corner. */
234 med_float mMax[3]; /**< Bounding box, max corner. */
235 med_float mInvLen[3]; /**< 1/length of cells, along each dimension. */
236 med_int mSize[3]; /**< Number of cells along each dimension. */
237 std::vector<PointOfField>* mGrid; /**< Flatten grid structure; each cell is a vector of PointOfField. */
241 // do not allow copy constructor
242 DecimationAccelGrid(const DecimationAccelGrid&);
245 DecimationAccelGrid& operator=(const DecimationAccelGrid&);
247 // do not allow operator ==
248 bool operator==(const DecimationAccelGrid&);
250 }; // class DecimationAccelGrid
253 } // namespace MULTIPR
256 #endif // MULTIPR_DECIMATION_ACCEL_HXX