1 // Copyright (C) 2007-2022 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, or (at your option) any later version.
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 #ifndef __MESHELEMENT_TXX__
20 #define __MESHELEMENT_TXX__
22 #include "MeshElement.hxx"
24 #include "TetraAffineTransform.hxx"
25 #include "TransformedTriangle.hxx"
26 #include "MeshUtils.hxx"
27 #include "BoundingBox.hxx"
29 #include <type_traits>
33 namespace INTERP_KERNEL
39 * @param index global number of element in the mesh in C mode.
40 * @param mesh mesh that the element belongs to
42 template<class ConnType>
43 template<class MyMeshType>
44 MeshElement<ConnType>::MeshElement(const ConnType index, const MyMeshType& mesh): _number( 0 )
46 this->assign(index,mesh);
49 template<class ConnType>
50 template<class MyMeshType>
51 void MeshElement<ConnType>::assign(const ConnType index, const MyMeshType& mesh)
53 auto numberCore = mesh.getNumberOfNodesOfElement(OTT<typename MyMeshType::MyConnType,MyMeshType::My_numPol>::indFC(index));
54 if(numberCore < std::numeric_limits<nbnodesincelltype>::max())
56 _number = static_cast< nbnodesincelltype >(numberCore);
57 std::unique_ptr<const double*[]> vertices( new const double*[_number] );
58 for( nbnodesincelltype i = 0 ; i < _number ; ++i)
59 vertices[i] = getCoordsOfNode(i , OTT<typename MyMeshType::MyConnType,MyMeshType::My_numPol>::indFC(index), mesh);
60 // create bounding box
61 _box.initializeWith(vertices.get(),_number);
65 THROW_IK_EXCEPTION("ERROR at index " << index << " : exceeding capacity !");
69 /////////////////////////////////////////////////////////////////////
70 /// ElementBBoxOrder /////////////
71 /////////////////////////////////////////////////////////////////////
74 * Comparison operator based on the bounding boxes of the elements
76 * @return true if the coordinate _coord of the bounding box of elem1 is
77 * strictly smaller than that of the bounding box of elem2
79 template<class ConnType>
80 bool ElementBBoxOrder::operator()( MeshElement<ConnType>* elem1, MeshElement<ConnType>* elem2)
82 const BoundingBox* box1 = elem1->getBoundingBox();
83 const BoundingBox* box2 = elem2->getBoundingBox();
90 const double coord1 = box1->getCoordinate(_coord);
91 const double coord2 = box2->getCoordinate(_coord);
93 return coord1 < coord2;