1 // Copyright (C) 2009-2012 OPEN CASCADE
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.
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 // File : IntersectorCU.txx
20 // Created : Thu Dec 17 12:30:17 2009
21 // Author : Edward AGAPOV (eap)
23 #ifndef __IntersectorCU_TXX__
24 #define __IntersectorCU_TXX__
26 #include "IntersectorCU.hxx"
28 // convert index "From Mesh Index"
29 #define _FMIU(i) OTT<typename MyUMeshType::MyConnType,MyUMeshType::My_numPol>::ind2C((i))
30 #define _FMIC(i) OTT<typename MyCMeshType::MyConnType,MyCMeshType::My_numPol>::ind2C((i))
31 // convert index "To Mesh Index"
32 #define _TMIU(i) OTT<typename MyUMeshType::MyConnType,MyUMeshType::My_numPol>::indFC((i))
33 #define _TMIC(i) OTT<typename MyCMeshType::MyConnType,MyCMeshType::My_numPol>::indFC((i))
34 // convert coord "From Mesh Coord"
35 #define _FMCOO(i) OTT<typename MyUMeshType::MyConnType,MyUMeshType::My_numPol>::coo2C((i))
36 // convert connectivity "From Mesh Connectivity"
37 #define _FMCON(i) OTT<typename MyUMeshType::MyConnType,MyUMeshType::My_numPol>::conn2C((i))
40 #define _CU_TEMPLATE \
41 template<class MyCMeshType, class MyUMeshType, class MyMatrix, class ConcreteIntersector>
42 #define _INTERSECTOR_CU_ \
43 IntersectorCU<MyCMeshType, MyUMeshType, MyMatrix, ConcreteIntersector>
45 namespace INTERP_KERNEL
47 //================================================================================
51 //================================================================================
54 _INTERSECTOR_CU_::IntersectorCU(const MyCMeshType& meshS, const MyUMeshType& meshT):
55 _meshU(meshT), _meshC(meshS)
57 _connectU =meshT.getConnectivityPtr();
58 _connIndexU=meshT.getConnectivityIndexPtr();
59 _coordsU =meshT.getCoordinatesPtr();
61 for ( int j = 0; j < SPACEDIM; ++j )
63 _coordsC [ j ] = _meshC.getCoordsAlongAxis( _TMIC( j ));
64 _nbCellsC[ j ] = _meshC.nbCellsAlongAxis ( _TMIC( j ));
68 //================================================================================
72 //================================================================================
75 _INTERSECTOR_CU_::~IntersectorCU()
79 //================================================================================
81 * \brief Return bounding box of an unstructured element
83 //================================================================================
86 void _INTERSECTOR_CU_::getUElemBB(double* bb, UConnType icell)
88 //initializing bounding box limits
89 for(int idim=0; idim<SPACEDIM; idim++)
91 bb[2*idim ] = std::numeric_limits<double>::max();
92 bb[2*idim+1] = -std::numeric_limits<double>::max();
95 UConnType nb_nodes = _connIndexU[icell+1] - _connIndexU[icell];
96 for (UConnType i=0; i<nb_nodes; i++)
98 //const double* coord_node=_coordsU+SPACEDIM*(OTT<ConnType,numPol>::coo2C(conn[OTT<ConnType,numPol>::conn2C(conn_index[OTT<ConnType,numPol>::ind2C(iP)]+i)]));
99 const double* coord_node=_coordsU+SPACEDIM*(_FMCOO( _connectU[_FMCON (_connIndexU[_FMIU(icell)]+i)]));
100 for(int idim=0; idim<SPACEDIM; idim++)
102 double x = *(coord_node+idim);
103 bb[2*idim ] = (x<bb[2*idim ])?x:bb[2*idim ];
104 bb[2*idim+1] = (x>bb[2*idim+1])?x:bb[2*idim+1];
109 //================================================================================
111 * \brief Return coordinates of nodes of an unstructured element
113 //================================================================================
116 void _INTERSECTOR_CU_::getUCoordinates(UConnType icell, std::vector<double>& coords)
118 UConnType nb_nodes = _connIndexU[icell+1] - _connIndexU[icell];
119 coords.resize( SPACEDIM * nb_nodes );
120 for (UConnType i=0; i<nb_nodes; i++)
121 for(int j=0; j<SPACEDIM; j++)
122 coords[SPACEDIM*i+j]=_coordsU[SPACEDIM*_FMCOO( _connectU[_FMCON (_connIndexU[_FMIU(icell)]+i)])+j];
126 int _INTERSECTOR_CU_::getNumberOfRowsOfResMatrix() const
128 return _meshU.getNumberOfElements();
131 int _INTERSECTOR_CU_::getNumberOfColsOfResMatrix() const
133 return _meshC.getNumberOfElements();
136 //================================================================================
138 * \brief Intersects unstructured target cell with structured source cell given by
140 * \param icellU - index of an unstructured element
141 * \param icellC - i,j,k of a structured element
142 * \param res - matrix to fill in
144 //================================================================================
147 void _INTERSECTOR_CU_::intersectCells(CConnType icellU,
148 const std::vector<CConnType>& icellC,
151 double v = intersectGeometry(icellU, icellC);
153 CConnType iC = icellC[0], area = _nbCellsC[0];
154 for ( int j = 1; j < SPACEDIM; ++j )
156 iC += icellC[j] * area;
157 area *= _nbCellsC[j];
159 res[ icellU ][ iC ] = v;