From: vbd Date: Mon, 10 Sep 2007 10:20:59 +0000 (+0000) Subject: staffan : X-Git-Tag: trio_trio_coupling~56 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=7133f6cb1fd256d244583df04576406d82b6102b;p=tools%2Fmedcoupling.git staffan : * doc updates --- diff --git a/src/INTERP_KERNEL/BoundingBox.cxx b/src/INTERP_KERNEL/BoundingBox.cxx index d5f3feabb..accae0c1f 100644 --- a/src/INTERP_KERNEL/BoundingBox.cxx +++ b/src/INTERP_KERNEL/BoundingBox.cxx @@ -21,8 +21,7 @@ namespace INTERP_UTILS { using namespace std; assert(_coords != 0); - assert(numPts > 1); - + assert(numPts > 1); // initialize with first two points const double* pt1 = pts[0]; @@ -38,11 +37,12 @@ namespace INTERP_UTILS { updateWithPoint(pts[i]); } + assert(isValid()); } /** - * Constructor creating box from union of two boxes, resulting in a box that enclose both of them + * Constructor creating box from union of two boxes, resulting in a box that encloses both of them * * @param box1 the first box * @param box2 the second box @@ -58,6 +58,7 @@ namespace INTERP_UTILS _coords[c] = min(box1._coords[c], box2._coords[c]); _coords[c + 3] = max(box1._coords[c + 3], box2._coords[c + 3]); } + assert(isValid()); } @@ -86,11 +87,11 @@ namespace INTERP_UTILS // boxes are disjoint if there exists a direction in which the // minimum coordinate of one is greater than the maximum coordinate of the other - //? more stable version - /*const double tol = 1.0e-2*_coords[c]; - if(_coords[c] > otherMaxCoord + tol - || _coords[c + 3] < otherMinCoord - tol) - */ + // more stable version ? + // const double tol = 1.0e-2*_coords[c]; + // if(_coords[c] > otherMaxCoord + tol + // || _coords[c + 3] < otherMinCoord - tol) + if(_coords[c] > otherMaxCoord || _coords[c + 3] < otherMinCoord) @@ -103,29 +104,7 @@ namespace INTERP_UTILS return false; } - /** - * Sets a coordinate of the box to a given value. - * - * @param coord coordinate to set - * @param value new value for coordinate - * - */ - void BoundingBox::setCoordinate(const BoxCoord coord, double value) - { - _coords[coord] = value; - } - - /** - * Gets a coordinate of the box - * - * @param coord coordinate to set - * @return value of coordinate - * - */ - double BoundingBox::getCoordinate(const BoxCoord coord) const - { - return _coords[coord]; - } + /** * Updates the bounding box to include a given point @@ -147,20 +126,8 @@ namespace INTERP_UTILS } } - - /* - * Prints the coordinates of the box to std::cout - * - */ - void BoundingBox::dumpCoords() const - { - std::cout << "[xmin, xmax] = [" << _coords[XMIN] << ", " << _coords[XMAX] << "]" << " | "; - std::cout << "[ymin, ymax] = [" << _coords[YMIN] << ", " << _coords[YMAX] << "]" << " | "; - std::cout << "[zmin, zmax] = [" << _coords[ZMIN] << ", " << _coords[ZMAX] << "]"; - std::cout << std::endl; - } - - /* + + /** * Checks if the box is valid, which it is if its minimum coordinates are * smaller than its maximum coordinates in all directions. * diff --git a/src/INTERP_KERNEL/BoundingBox.hxx b/src/INTERP_KERNEL/BoundingBox.hxx index 4abe00d0a..60e361f75 100644 --- a/src/INTERP_KERNEL/BoundingBox.hxx +++ b/src/INTERP_KERNEL/BoundingBox.hxx @@ -1,6 +1,8 @@ #ifndef __BOUNDING_BOX_HXX__ #define __BOUNDING_BOX_HXX__ +#include + namespace INTERP_UTILS { @@ -11,6 +13,8 @@ namespace INTERP_UTILS class BoundingBox { public: + + /// Enumeration representing the six coordinates that define the bounding box enum BoxCoord { XMIN = 0, YMIN = 1, ZMIN = 2, XMAX = 3, YMAX = 4, ZMAX = 5 }; BoundingBox(const double** pts, const int numPts); @@ -21,24 +25,66 @@ namespace INTERP_UTILS bool isDisjointWith(const BoundingBox& box) const; - void setCoordinate(const BoxCoord coord, double value); + inline void setCoordinate(const BoxCoord coord, double value); - double getCoordinate(const BoxCoord coord) const; + inline double getCoordinate(const BoxCoord coord) const; void updateWithPoint(const double* pt); - void dumpCoords() const; + inline void dumpCoords() const; private: bool isValid() const; + + /// disallow copying + BoundingBox(const BoundingBox& box); - /// vector containing the coordinates of the box + /// disallow assignment + BoundingBox& operator=(const BoundingBox& box); + + /// Vector containing the coordinates of the box /// interlaced in the order XMIN, YMIN, ZMIN, XMAX, YMAX, ZMAX double* _coords; }; + /** + * Sets a coordinate of the box to a given value. + * + * @param coord coordinate to set + * @param value new value for coordinate + * + */ + inline void BoundingBox::setCoordinate(const BoxCoord coord, double value) + { + _coords[coord] = value; + } + + /** + * Gets a coordinate of the box + * + * @param coord coordinate to get + * @return value of coordinate + * + */ + inline double BoundingBox::getCoordinate(const BoxCoord coord) const + { + return _coords[coord]; + } + + /** + * Prints the coordinates of the box to std::cout + * + */ + inline void BoundingBox::dumpCoords() const + { + std::cout << "[xmin, xmax] = [" << _coords[XMIN] << ", " << _coords[XMAX] << "]" << " | "; + std::cout << "[ymin, ymax] = [" << _coords[YMIN] << ", " << _coords[YMAX] << "]" << " | "; + std::cout << "[zmin, zmax] = [" << _coords[ZMIN] << ", " << _coords[ZMAX] << "]"; + std::cout << std::endl; + } + }; #endif diff --git a/src/INTERP_KERNEL/MeshElement.cxx b/src/INTERP_KERNEL/MeshElement.cxx index a12c5365d..89d4bb7ca 100644 --- a/src/INTERP_KERNEL/MeshElement.cxx +++ b/src/INTERP_KERNEL/MeshElement.cxx @@ -17,11 +17,11 @@ namespace INTERP_UTILS * @param mesh mesh that the element belongs to * @param type geometric type of the element */ - MeshElement::MeshElement(const int index, const MED_EN::medGeometryElement type, const MEDMEM::MESH& mesh) - : _index(index), _box(0), _type(type) + MeshElement::MeshElement(const int index, const MEDMEM::MESH& mesh) + : _index(index), _box(0), _type(mesh.getElementType(MED_EN::MED_CELL, index)) { // get coordinates of vertices - const int numNodes = getNumberOfNodesForType(type); + const int numNodes = getNumberOfNodesForType(_type); assert(numNodes >= 3); @@ -49,40 +49,12 @@ namespace INTERP_UTILS } } - /* - * Accessor to global number - * - * @return global number of the element - */ - int MeshElement::getIndex() const - { - return _index; - } - /* - * Accessor to bounding box - * - * @return pointer to bounding box of the element - */ - const BoundingBox* MeshElement::getBoundingBox() const - { - return _box; - } - - /* - * Accessor to the type of the element - * - * @return type of the element - */ - MED_EN::medGeometryElement MeshElement::getType() const - { - return _type; - } ///////////////////////////////////////////////////////////////////// /// ElementBBoxOrder ///////////// ///////////////////////////////////////////////////////////////////// - /* + /** * Constructor * * @param coord BoundingBox coordinate (XMIN, XMAX, etc) on which to base the ordering @@ -92,7 +64,7 @@ namespace INTERP_UTILS { } - /* + /** * Comparison operator based on the bounding boxes of the elements * * @return true if the coordinate _coord of the bounding box of elem1 is diff --git a/src/INTERP_KERNEL/MeshElement.hxx b/src/INTERP_KERNEL/MeshElement.hxx index 56f3fce53..e91359a39 100644 --- a/src/INTERP_KERNEL/MeshElement.hxx +++ b/src/INTERP_KERNEL/MeshElement.hxx @@ -17,7 +17,7 @@ namespace INTERP_UTILS /** * Class representing a single element of a mesh together with its bounding box. - * It permits access to the element's global number, type and bounding box and allows + * It gives access to the element's global number, type and bounding box and allows * easy bounding box intersection tests between MeshElements and collections of MeshElement (MeshRegions) */ class MeshElement @@ -25,24 +25,65 @@ namespace INTERP_UTILS public: - MeshElement(const int index, const MED_EN::medGeometryElement type, const MEDMEM::MESH& mesh); + MeshElement(const int index, const MEDMEM::MESH& mesh); ~MeshElement(); - int getIndex() const; + inline int getIndex() const; - const BoundingBox* getBoundingBox() const; + inline const BoundingBox* getBoundingBox() const; - MED_EN::medGeometryElement getType() const; + inline MED_EN::medGeometryElement getType() const; private: - const int _index; /// global number of the element - BoundingBox* _box; /// bounding box of the element - does not change after having been initialised - MED_EN::medGeometryElement _type;/// type of the element + /// disallow copying + MeshElement(const MeshElement& elem); + + /// disallow assignment + MeshElement& operator=(const MeshElement& elem); + + /// global number of the element + const int _index; + + /// bounding box of the element - does not change after having been initialised + BoundingBox* _box; + + /// type of the element + MED_EN::medGeometryElement _type; }; + /** + * Accessor to global number + * + * @return global number of the element + */ + inline int MeshElement::getIndex() const + { + return _index; + } + + /** + * Accessor to bounding box + * + * @return pointer to bounding box of the element + */ + inline const BoundingBox* MeshElement::getBoundingBox() const + { + return _box; + } - /* + /** + * Accessor to the type of the element + * + * @return type of the element + */ + inline MED_EN::medGeometryElement MeshElement::getType() const + { + return _type; + } + + + /** * Class defining an order for MeshElements based on their bounding boxes. * The order defined between two elements is that between a given coordinate of * their bounding boxes. For instance, if the order is based on YMIN, an element whose boxes @@ -58,7 +99,8 @@ namespace INTERP_UTILS bool operator()(MeshElement* elem1, MeshElement* elem2); private : - BoundingBox::BoxCoord _coord; /// BoundingBox coordinate (XMIN, XMAX, etc) on which to base the ordering + /// BoundingBox coordinate (XMIN, XMAX, etc) on which to base the ordering + BoundingBox::BoxCoord _coord; }; }; diff --git a/src/INTERP_KERNEL/MeshRegion.hxx b/src/INTERP_KERNEL/MeshRegion.hxx index a3dd2a2f4..e00936981 100644 --- a/src/INTERP_KERNEL/MeshRegion.hxx +++ b/src/INTERP_KERNEL/MeshRegion.hxx @@ -36,6 +36,13 @@ namespace INTERP_UTILS inline int getNumberOfElements() const; private: + + /// disallow copying + MeshRegion(const MeshRegion& m); + + /// disallow assignment + MeshRegion& operator=(const MeshRegion& m); + /// Vector of pointers to contained MeshElements. /// NB : these pointers are not owned by the region object, and are thus /// neither allocated or liberated in this class. The elements must therefore be allocated and liberated outside the class.