1 // Copyright (C) 2021 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
20 #include "MEDCoupling_Wrapper.hxx"
21 #include "MED_TStructures.hxx"
24 using namespace MEDCoupling;
27 PMeshInfo MCTWrapper::CrMeshInfo(TInt theDim,
29 const std::string& theValue,
31 const std::string& theDesc)
33 return PMeshInfo(new TTMeshInfo(theDim, theSpaceDim, theValue, theType, theDesc));
36 void MCTWrapper::SetMeshInfo(const TMeshInfo& theInfo)
38 _mesh_name = theInfo.GetName();
39 _mesh_dim = theInfo.GetDim();
40 _space_dim = theInfo.GetSpaceDim();
44 PNodeInfo MCTWrapper::CrNodeInfo(const PMeshInfo& theMeshInfo,
48 EBooleen theIsElemNum,
49 EBooleen theIsElemNames)
51 return PNodeInfo(new TTNodeInfo
60 void MCTWrapper::SetNodeInfo(const TNodeInfo& theInfo)
62 MED::TNodeInfo& anInfo = const_cast<MED::TNodeInfo&>(theInfo);
63 MED::PNodeCoord aCoord(anInfo.myCoord);
64 MED::TInt aNbElem(anInfo.myNbElem);
65 std::string aCoordNames(anInfo.myCoordNames.data());
66 std::string aCoordUnits(anInfo.myCoordUnits.data());
67 std::vector<std::string> comps( DataArray::SplitStringInChuncks(aCoordNames,MED_SNAME_SIZE) );
68 std::vector<std::string> units( DataArray::SplitStringInChuncks(aCoordUnits,MED_SNAME_SIZE) );
69 std::size_t nbComps( comps.size() );
70 if( nbComps != units.size() )
71 THROW_IK_EXCEPTION("MCTWrapper::SetNodeInfo : mismatch length " << nbComps << " != " << units.size() << " !");
72 std::vector<std::string> compUnits(nbComps);
73 for( std::size_t i = 0 ; i < nbComps ; ++i )
75 compUnits[i] = DataArray::BuildInfoFromVarAndUnit(comps[i],units[i]) ;
77 _coords = DataArrayDouble::New();
78 _coords->alloc(aNbElem,this->_space_dim);
79 std::copy(aCoord->data(),aCoord->data()+aNbElem*this->_space_dim,_coords->getPointer());
80 _coords->setInfoOnComponents(compUnits);
83 void MCTWrapper::GetFamilyInfo(TInt theFamId, TFamilyInfo& theInfo)
85 std::string aFamilyName(theInfo.myName.data());
86 MED::TInt aFamilyId(theInfo.myId);
87 std::string aGroupNames(theInfo.myGroupNames.data());
92 MCTWrapper::CrFamilyInfo(const PMeshInfo& theMeshInfo,
93 const std::string& theValue,
95 const MED::TStringSet& theGroupNames,
96 const MED::TStringVector& theAttrDescs,
97 const MED::TIntVector& theAttrIds,
98 const MED::TIntVector& theAttrVals)
100 return PFamilyInfo(new TTFamilyInfo
112 MCTWrapper::CrPolygoneInfo(const PMeshInfo& theMeshInfo,
113 EEntiteMaillage theEntity,
114 EGeometrieElement theGeom,
117 EConnectivite theConnMode,
118 EBooleen theIsElemNum,
119 EBooleen theIsElemNames)
121 return PPolygoneInfo(new TTPolygoneInfo
135 ::CrPolygoneInfo(const PMeshInfo& theMeshInfo,
136 EEntiteMaillage theEntity,
137 EGeometrieElement theGeom,
138 const TIntVector& theIndexes,
139 const TIntVector& theConnectivities,
140 EConnectivite theConnMode,
141 const TIntVector& theFamilyNums,
142 const TIntVector& theElemNums,
143 const TStringVector& theElemNames)
145 return PPolygoneInfo(new TTPolygoneInfo
160 ::CrPolyedreInfo(const PMeshInfo& theMeshInfo,
161 EEntiteMaillage theEntity,
162 EGeometrieElement theGeom,
166 EConnectivite theConnMode,
167 EBooleen theIsElemNum,
168 EBooleen theIsElemNames)
170 return PPolyedreInfo(new TTPolyedreInfo
185 ::CrBallInfo(const PMeshInfo& theMeshInfo,
187 EBooleen theIsElemNum)
189 return PBallInfo(new TTBallInfo(theMeshInfo, theNbBalls, theIsElemNum));
194 ::CrCellInfo(const PMeshInfo& theMeshInfo,
195 EEntiteMaillage theEntity,
196 EGeometrieElement theGeom,
198 EConnectivite theConnMode,
199 EBooleen theIsElemNum,
200 EBooleen theIsElemNames,
203 return PCellInfo(new TTCellInfo