From: eap Date: Wed, 14 Jan 2009 10:30:28 +0000 (+0000) Subject: MEDMEM Industrialization 2008 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=4fbb0cd3cd82a42b848f27967965168786f05a62;p=tools%2Fmedcoupling.git MEDMEM Industrialization 2008 - ~UnitTetraIntersectionBary() { clearPolygons(/*andFaces=*/true ); } + virtual ~UnitTetraIntersectionBary(); --- diff --git a/src/INTERP_KERNEL/UnitTetraIntersectionBary.cxx b/src/INTERP_KERNEL/UnitTetraIntersectionBary.cxx index ac7482eb4..69283b62f 100644 --- a/src/INTERP_KERNEL/UnitTetraIntersectionBary.cxx +++ b/src/INTERP_KERNEL/UnitTetraIntersectionBary.cxx @@ -51,9 +51,10 @@ namespace INTERP_KERNEL */ //================================================================================ -UnitTetraIntersectionBary::UnitTetraIntersectionBary() +UnitTetraIntersectionBary::UnitTetraIntersectionBary():TransformedTriangle() { - init(); + _intVolume = 0; + //init(); } //================================================================================ /*! @@ -63,7 +64,7 @@ UnitTetraIntersectionBary::UnitTetraIntersectionBary() void UnitTetraIntersectionBary::init() { - _volume = 0; + _intVolume = 0; _faces.clear(); } @@ -76,7 +77,7 @@ void UnitTetraIntersectionBary::init() void UnitTetraIntersectionBary::addSide(const TransformedTriangle& triangle) { - _volume += triangle.getVolume(); + _intVolume += triangle.getVolume(); double triNormal[3], polyNormal[3]; crossprod<3>( triangle.getCorner(P),triangle.getCorner(Q),triangle.getCorner(R), triNormal); @@ -99,10 +100,9 @@ void UnitTetraIntersectionBary::addSide(const TransformedTriangle& triangle) sortIntersectionPolygon(A, _barycenterA); pPolygonA = & _polygonA; } - const vector& polygonA = *pPolygonA; // check if polygon orientation is same as the one of triangle - vector::const_iterator p = polygonA.begin(), pEnd = polygonA.end(); + vector::const_iterator p = pPolygonA->begin(), pEnd = pPolygonA->end(); double* p1 = *p++; double* p2 = *p; while ( samePoint( p1, p2 ) && ++p != pEnd ) @@ -118,20 +118,20 @@ void UnitTetraIntersectionBary::addSide(const TransformedTriangle& triangle) // store polygon _faces.push_back( vector< double* > () ); vector< double* >& faceCorner = _faces.back(); - faceCorner.resize( polygonA.size()/* + 1*/ ); + faceCorner.resize( pPolygonA->size()/* + 1*/ ); int i = 0; if ( reverse ) { - vector::const_reverse_iterator polyF = polygonA.rbegin(), polyEnd; - for ( polyEnd = polygonA.rend(); polyF != polyEnd; ++i, ++polyF ) + vector::const_reverse_iterator polyF = pPolygonA->rbegin(), polyEnd; + for ( polyEnd = pPolygonA->rend(); polyF != polyEnd; ++i, ++polyF ) if ( i==0 || !samePoint( *polyF, faceCorner[i-1] )) copyVector3( *polyF, faceCorner[i] = new double[3] ); else --i; } else { - vector::const_iterator polyF = polygonA.begin(), polyEnd; - for ( polyEnd = polygonA.end(); polyF != polyEnd; ++i, ++polyF ) + vector::const_iterator polyF = pPolygonA->begin(), polyEnd; + for ( polyEnd = pPolygonA->end(); polyF != polyEnd; ++i, ++polyF ) if ( i==0 || !samePoint( *polyF, faceCorner[i-1] )) copyVector3( *polyF, faceCorner[i] = new double[3] ); else @@ -143,7 +143,7 @@ void UnitTetraIntersectionBary::addSide(const TransformedTriangle& triangle) _faces.pop_back(); } else { - if ( i < polygonA.size() ) + if ( i < pPolygonA->size() ) faceCorner.resize( i ); } @@ -168,10 +168,10 @@ bool UnitTetraIntersectionBary::getBary(double* baryCenter) baryCenter[0] = baryCenter[1] = baryCenter[2] = -1.0; if ( addSideFaces() < NB_TETRA_SIDES ) { // tetra is not intersected - if ( _volume != 0.0 ) { + if ( _intVolume != 0.0 ) { // tetra is fully inside the other cell baryCenter[0] = baryCenter[1] = baryCenter[2] = 0.25; - _volume = 0.166667; + _intVolume = 0.166667; return true; } return false; @@ -231,10 +231,10 @@ bool UnitTetraIntersectionBary::getBary(double* baryCenter) baryCenter[1] += ( bary[1] * 0.75 + P[1] * 0.25 ) * vol; baryCenter[2] += ( bary[2] * 0.75 + P[2] * 0.25 ) * vol; } - if ( _volume < 0. ) _volume = -_volume; - baryCenter[0] /= _volume; - baryCenter[1] /= _volume; - baryCenter[2] /= _volume; + if ( _intVolume < 0. ) _intVolume = -_intVolume; + baryCenter[0] /= _intVolume; + baryCenter[1] /= _intVolume; + baryCenter[2] /= _intVolume; return true; } @@ -323,7 +323,8 @@ int UnitTetraIntersectionBary::addSideFaces() } } // check if the segment p1-p2 is on the inclined side - if ( epsilonEqual( p1[_X] + p1[_Y] + p1[_Z], 1.0 ) && + if ( sideFaces[3] && + epsilonEqual( p1[_X] + p1[_Y] + p1[_Z], 1.0 ) && epsilonEqual( p2[_X] + p2[_Y] + p2[_Z], 1.0 )) { sideFaces[3]->push_back( new double[3] ); @@ -597,23 +598,34 @@ void UnitTetraIntersectionBary::setTriangleOnSide(int iSide) void UnitTetraIntersectionBary::clearPolygons(bool andFaces) { for(vector::iterator it = _polygonA.begin() ; it != _polygonA.end() ; ++it) - delete[] *it; + { delete[] *it; *it = 0; } for(vector::iterator it = _polygonB.begin() ; it != _polygonB.end() ; ++it) - delete[] *it; + { delete[] *it; *it = 0; } _polygonA.clear(); _polygonB.clear(); if ( andFaces ) { - list< vector< double* > >::iterator f = _faces.begin(), fEnd = _faces.end(); + list< vector< double* > >::iterator f = this->_faces.begin(), fEnd = this->_faces.end(); for ( ; f != fEnd; ++f ) { vector< double* >& polygon = *f; for(vector::iterator it = polygon.begin() ; it != polygon.end() ; ++it) - delete[] *it; + { delete[] *it; *it = 0; } } - _faces.clear(); + this->_faces.clear(); } } +//================================================================================ +/*! + * \brief Destructor clears coordinates of faces + */ +//================================================================================ + +UnitTetraIntersectionBary::~UnitTetraIntersectionBary() +{ + clearPolygons(/*andFaces=*/true ); +} + } diff --git a/src/INTERP_KERNEL/UnitTetraIntersectionBary.hxx b/src/INTERP_KERNEL/UnitTetraIntersectionBary.hxx index 1f4574830..d24ce7d1d 100644 --- a/src/INTERP_KERNEL/UnitTetraIntersectionBary.hxx +++ b/src/INTERP_KERNEL/UnitTetraIntersectionBary.hxx @@ -53,9 +53,9 @@ namespace INTERP_KERNEL * \brief Returns volume of intersection * \retval double - */ - inline double getVolume() const; + inline double getVolume() const { return _intVolume; } - ~UnitTetraIntersectionBary() { clearPolygons(/*andFaces=*/true ); } + virtual ~UnitTetraIntersectionBary(); private: @@ -66,18 +66,12 @@ namespace INTERP_KERNEL void clearPolygons(bool andFaces=false); /// volume of intersection - double _volume; + double _intVolume; /// faces of intersection polyhedron std::list< std::vector< double* > > _faces; }; - - inline double UnitTetraIntersectionBary::getVolume() const - { - return _volume; - } - } #endif