1 // Copyright (C) 2005 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
2 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
4 // This library is free software; you can redistribute it and/or
5 // modify it under the terms of the GNU Lesser General Public
6 // License as published by the Free Software Foundation; either
7 // version 2.1 of the License.
9 // This library is distributed in the hope that it will be useful
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 // Lesser General Public License for more details.
14 // You should have received a copy of the GNU Lesser General Public
15 // License along with this library; if not, write to the Free Software
16 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 // See http://www.salome-platform.org/
20 #include "DriverUNV_R_SMDS_Mesh.h"
21 #include "SMDS_Mesh.hxx"
22 #include "SMDS_MeshGroup.hxx"
24 #include "utilities.h"
26 #include "UNV2411_Structure.hxx"
27 #include "UNV2412_Structure.hxx"
28 #include "UNV2417_Structure.hxx"
29 #include "UNV_Utilities.hxx"
35 static int MYDEBUG = 0;
37 static int MYDEBUG = 0;
41 DriverUNV_R_SMDS_Mesh::~DriverUNV_R_SMDS_Mesh()
48 Driver_Mesh::Status DriverUNV_R_SMDS_Mesh::Perform()
50 Status aResult = DRS_OK;
51 std::ifstream in_stream(myFile.c_str());
54 using namespace UNV2411;
55 TDataSet aDataSet2411;
56 UNV2411::Read(in_stream,aDataSet2411);
57 if(MYDEBUG) MESSAGE("Perform - aDataSet2411.size() = "<<aDataSet2411.size());
58 TDataSet::const_iterator anIter = aDataSet2411.begin();
59 for(; anIter != aDataSet2411.end(); anIter++){
60 const TNodeLab& aLabel = anIter->first;
61 const TRecord& aRec = anIter->second;
62 myMesh->AddNodeWithID(aRec.coord[0],aRec.coord[1],aRec.coord[2],aLabel);
66 using namespace UNV2412;
68 TDataSet aDataSet2412;
69 UNV2412::Read(in_stream,aDataSet2412);
70 TDataSet::const_iterator anIter = aDataSet2412.begin();
71 if(MYDEBUG) MESSAGE("Perform - aDataSet2412.size() = "<<aDataSet2412.size());
72 for(; anIter != aDataSet2412.end(); anIter++){
73 SMDS_MeshElement* anElement = NULL;
74 const TElementLab& aLabel = anIter->first;
75 const TRecord& aRec = anIter->second;
76 if(IsBeam(aRec.fe_descriptor_id)) {
77 if((aRec.fe_descriptor_id == 11) || (aRec.fe_descriptor_id == 21)) {
78 // edge with two nodes
79 anElement = myMesh->AddEdgeWithID(aRec.node_labels[0],
84 // quadratic edge (with 3 nodes)
85 anElement = myMesh->AddEdgeWithID(aRec.node_labels[0],
91 else if(IsFace(aRec.fe_descriptor_id)) {
92 switch(aRec.fe_descriptor_id){
97 case 41: // Plane Stress Linear Triangle - TRI3
98 case 91: // Thin Shell Linear Triangle - TRI3
99 anElement = myMesh->AddFaceWithID(aRec.node_labels[0],
105 case 42: // Plane Stress Quadratic Triangle - TRI6
106 case 92: // Thin Shell Quadratic Triangle - TRI6
107 anElement = myMesh->AddFaceWithID(aRec.node_labels[0],
116 case 44: // Plane Stress Linear Quadrilateral - QUAD4
117 case 94: // Thin Shell Linear Quadrilateral - QUAD4
118 anElement = myMesh->AddFaceWithID(aRec.node_labels[0],
125 case 45: // Plane Stress Quadratic Quadrilateral - QUAD8
126 case 95: // Thin Shell Quadratic Quadrilateral - QUAD8
127 anElement = myMesh->AddFaceWithID(aRec.node_labels[0],
139 else if(IsVolume(aRec.fe_descriptor_id)){
140 switch(aRec.fe_descriptor_id){
142 case 111: // Solid Linear Tetrahedron - TET4
143 anElement = myMesh->AddVolumeWithID(aRec.node_labels[0],
150 case 118: // Solid Quadratic Tetrahedron - TET10
151 anElement = myMesh->AddVolumeWithID(aRec.node_labels[0],
164 case 112: // Solid Linear Prism - PRISM6
165 anElement = myMesh->AddVolumeWithID(aRec.node_labels[0],
174 case 113: // Solid Quadratic Prism - PRISM15
175 anElement = myMesh->AddVolumeWithID(aRec.node_labels[0],
184 aRec.node_labels[11],
185 aRec.node_labels[10],
187 aRec.node_labels[12],
188 aRec.node_labels[14],
189 aRec.node_labels[13],
193 case 115: // Solid Linear Brick - HEX8
194 anElement = myMesh->AddVolumeWithID(aRec.node_labels[0],
205 case 116: // Solid Quadratic Brick - HEX20
206 anElement = myMesh->AddVolumeWithID(aRec.node_labels[0],
211 aRec.node_labels[12],
212 aRec.node_labels[18],
213 aRec.node_labels[16],
214 aRec.node_labels[14],
221 aRec.node_labels[19],
222 aRec.node_labels[17],
223 aRec.node_labels[15],
224 aRec.node_labels[13],
227 aRec.node_labels[11],
228 aRec.node_labels[10],
233 case 114: // pyramid of 13 nodes (quadratic) - PIRA13
234 anElement = myMesh->AddVolumeWithID(aRec.node_labels[0],
244 aRec.node_labels[12],
245 aRec.node_labels[11],
246 aRec.node_labels[10],
253 // MESSAGE("DriverUNV_R_SMDS_Mesh::Perform - can not add element with ID = "<<aLabel<<" and type = "<<aRec.fe_descriptor_id);
257 using namespace UNV2417;
259 TDataSet aDataSet2417;
260 UNV2417::Read(in_stream,aDataSet2417);
261 if(MYDEBUG) MESSAGE("Perform - aDataSet2417.size() = "<<aDataSet2417.size());
262 if (aDataSet2417.size() > 0) {
263 myGroup = new SMDS_MeshGroup(myMesh);
264 TDataSet::const_iterator anIter = aDataSet2417.begin();
265 for(; anIter != aDataSet2417.end(); anIter++){
266 const TGroupId& aLabel = anIter->first;
267 const TRecord& aRec = anIter->second;
268 //SMDS_MeshGroup* aNewGroup = (SMDS_MeshGroup*) myGroup->AddSubGroup(SMDSAbs_Edge);
269 //myGroupNames.insert(TGroupNamesMap::value_type(aNewGroup, aRec.GroupName));
270 //myGroupId.insert(TGroupIdMap::value_type(aNewGroup, aLabel));
272 int aNodesNb = aRec.NodeList.size();
275 SMDS_MeshGroup* aNodesGroup = (SMDS_MeshGroup*) myGroup->AddSubGroup(SMDSAbs_Node);
276 std::string aGrName = aRec.GroupName + "_Nodes";
277 myGroupNames.insert(TGroupNamesMap::value_type(aNodesGroup, aGrName));
278 myGroupId.insert(TGroupIdMap::value_type(aNodesGroup, aLabel));
280 for (i = 0; i < aNodesNb; i++) {
281 const SMDS_MeshNode* aNode = myMesh->FindNode(aRec.NodeList[i]);
283 aNodesGroup->Add(aNode);
286 int aElementsNb = aRec.ElementList.size();
287 if (aElementsNb > 0){
288 SMDS_MeshGroup* aEdgesGroup = 0;
289 SMDS_MeshGroup* aFacesGroup = 0;
291 for (i = 0; i < aElementsNb; i++) {
292 const SMDS_MeshElement* aElement = myMesh->FindElement(aRec.ElementList[i]);
294 switch (aElement->GetType()) {
297 aEdgesGroup = (SMDS_MeshGroup*) myGroup->AddSubGroup(SMDSAbs_Edge);
298 std::string aEdgesGrName = aRec.GroupName + "_Edges";
299 myGroupNames.insert(TGroupNamesMap::value_type(aEdgesGroup, aEdgesGrName));
300 myGroupId.insert(TGroupIdMap::value_type(aEdgesGroup, aLabel));
302 aEdgesGroup->Add(aElement);
306 aFacesGroup = (SMDS_MeshGroup*) myGroup->AddSubGroup(SMDSAbs_Face);
307 std::string aFacesGrName = aRec.GroupName + "_Faces";
308 myGroupNames.insert(TGroupNamesMap::value_type(aFacesGroup, aFacesGrName));
309 myGroupId.insert(TGroupIdMap::value_type(aFacesGroup, aLabel));
311 aFacesGroup->Add(aElement);
321 catch(const std::exception& exc){
322 INFOS("Follow exception was cought:\n\t"<<exc.what());
325 INFOS("Unknown exception was cought !!!");