3 // Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
29 #include "MED_CoordUtils.hxx"
30 #include "MED_Utilities.hxx"
35 enum ECoordName{eX, eY, eZ, eNone};
37 template<ECoordName TCoordId>
39 GetCoord(const TCCoordSlice& theCoordSlice)
41 return theCoordSlice[TCoordId];
46 GetCoord<eNone>(const TCCoordSlice& theCoordSlice)
102 //---------------------------------------------------------------
104 ::TCoordHelper(TGetCoord* theGetCoord):
105 myGetCoord(theGetCoord)
110 ::GetCoord(TCCoordSlice& theCoordSlice,
113 return (*myGetCoord[theCoordId])(theCoordSlice);
117 //---------------------------------------------------------------
119 GetCoordHelper(PNodeInfo theNodeInfo)
121 PCoordHelper aCoordHelper;
123 PMeshInfo aMeshInfo = theNodeInfo->GetMeshInfo();
124 TInt aMeshDimension = aMeshInfo->GetDim();
125 bool anIsDimPresent[3] = {false, false, false};
126 for(int iDim = 0; iDim < aMeshDimension; iDim++){
127 std::string aName = theNodeInfo->GetCoordName(iDim);
128 if ( aName.size() > 1 ) // PAL12148, aName has size 8 or 16
129 aName = aName.substr(0,1);
130 if(aName == "x" || aName == "X")
131 anIsDimPresent[eX] = true;
132 else if(aName == "y" || aName == "Y")
133 anIsDimPresent[eY] = true;
134 else if(aName == "z" || aName == "Z")
135 anIsDimPresent[eZ] = true;
138 switch(aMeshDimension){
140 aCoordHelper.reset(new TCoordHelper(aXYZGetCoord));
143 if(anIsDimPresent[eY] && anIsDimPresent[eZ])
144 aCoordHelper.reset(new TCoordHelper(aYZGetCoord));
145 else if(anIsDimPresent[eX] && anIsDimPresent[eZ])
146 aCoordHelper.reset(new TCoordHelper(aXZGetCoord));
148 aCoordHelper.reset(new TCoordHelper(aXYGetCoord));
151 if(anIsDimPresent[eY])
152 aCoordHelper.reset(new TCoordHelper(aYGetCoord));
153 else if(anIsDimPresent[eZ])
154 aCoordHelper.reset(new TCoordHelper(aZGetCoord));
156 aCoordHelper.reset(new TCoordHelper(aXGetCoord));