--- /dev/null
+// Copyright (C) 2007-2008 CEA/DEN, EDF R&D
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+// File : IntersectionResult.hxx
+// Created : Mon Nov 24 12:22:18 2008
+// Author : Edward AGAPOV (eap)
+
+#ifndef IntersectionResult_HeaderFile
+#define IntersectionResult_HeaderFile
+
+#include <vector>
+#include <map>
+
+namespace INTERP_KERNEL
+{
+
+ /*!
+ * \brief Container of cell intersection results
+ *
+ * For each source cell it stores id of target cell, volume of intersection
+ * and optionally barycentre of intersection
+ */
+ class INTERPKERNEL_EXPORT IntersectionResult: public std::vector< std::map< int,double> >
+ {
+ typedef std::map< int,double> _SurfMapType;
+ typedef std::map< int,double*> _BaryMapType;
+ bool _need_baryCentres;
+ int _dim;
+ std::vector< _BaryMapType > _baryCentres;
+ public:
+ IntersectionResult(int spaceDim): _dim(spaceDim), _need_baryCentres(false) {}
+
+ void resize(size_t n)
+ {
+ std::vector< _SurfMapType >::resize( n );
+ if ( _need_baryCentres )
+ _baryCentres.resize( n );
+ }
+
+ void setNeedBaryCentres(bool need)
+ {
+ _need_baryCentres = need;
+ if ( _need_baryCentres )
+ _baryCentres.resize( size() );
+ else
+ _baryCentres.clear();
+ }
+
+ bool getNeedBaryCentres() const
+ {
+ return _need_baryCentres;
+ }
+
+ double* getBaryCentre(int iSize, int j) //!< 0 <= iSize <= size()
+ {
+ double* res = 0;
+ if ( _need_baryCentres ) {
+ res = new double[ _dim ];
+ _baryCentres[ iSize ].insert( make_pair( j, res ));
+ }
+ return res;
+ }
+
+ int getNumberOfIntersections() const
+ {
+ int nb = 0;
+ std::vector< _SurfMapType >::const_iterator res = begin(), resEnd = end();
+ for ( ; res != resEnd; ++res )
+ nb += res->size();
+ return nb;
+ }
+
+ ~IntersectionResult()
+ {
+ std::vector<_BaryMapType>::iterator bm = _baryCentres.begin(), bmEnd = _baryCentres.end();
+ for ( ; bm != bmEnd; ++bm ) {
+ _BaryMapType::iterator i_bc = bm->begin(), bcEnd = bm->end();
+ for ( ; i_bc != bcEnd; ++i_bc )
+ delete [] i_bc->second;
+ }
+ }
+ };
+}
+
+#endif