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"
23 #include "utilities.h"
25 #include "UNV2411_Structure.hxx"
26 #include "UNV2412_Structure.hxx"
27 #include "UNV_Utilities.hxx"
33 static int MYDEBUG = 0;
35 static int MYDEBUG = 0;
39 Driver_Mesh::Status DriverUNV_R_SMDS_Mesh::Perform()
41 Status aResult = DRS_OK;
42 std::ifstream in_stream(myFile.c_str());
45 using namespace UNV2411;
46 TDataSet aDataSet2411;
47 UNV2411::Read(in_stream,aDataSet2411);
48 if(MYDEBUG) MESSAGE("Perform - aDataSet2411.size() = "<<aDataSet2411.size());
49 TDataSet::const_iterator anIter = aDataSet2411.begin();
50 for(; anIter != aDataSet2411.end(); anIter++){
51 const TNodeLab& aLabel = anIter->first;
52 const TRecord& aRec = anIter->second;
53 myMesh->AddNodeWithID(aRec.coord[0],aRec.coord[1],aRec.coord[2],aLabel);
57 using namespace UNV2412;
59 TDataSet aDataSet2412;
60 UNV2412::Read(in_stream,aDataSet2412);
61 TDataSet::const_iterator anIter = aDataSet2412.begin();
62 if(MYDEBUG) MESSAGE("Perform - aDataSet2412.size() = "<<aDataSet2412.size());
63 for(; anIter != aDataSet2412.end(); anIter++){
64 SMDS_MeshElement* anElement = NULL;
65 const TElementLab& aLabel = anIter->first;
66 const TRecord& aRec = anIter->second;
67 if(IsBeam(aRec.fe_descriptor_id)){
68 anElement = myMesh->AddEdgeWithID(aRec.node_labels[0],
71 }else if(IsFace(aRec.fe_descriptor_id)){
72 switch(aRec.fe_descriptor_id){
77 case 41: // Plane Stress Linear Triangle - TRI3
78 case 91: // Thin Shell Linear Triangle - TRI3
80 case 42: // Plane Stress Quadratic Triangle - TRI6
81 case 92: // Thin Shell Quadratic Triangle - TRI6
83 anElement = myMesh->AddFaceWithID(aRec.node_labels[0],
89 case 44: // Plane Stress Linear Quadrilateral - QUAD4
90 case 94: // Thin Shell Linear Quadrilateral - QUAD4
92 case 45: // Plane Stress Quadratic Quadrilateral - QUAD8
93 case 95: // Thin Shell Quadratic Quadrilateral - QUAD8
94 anElement = myMesh->AddFaceWithID(aRec.node_labels[0],
101 }else if(IsVolume(aRec.fe_descriptor_id)){
102 switch(aRec.fe_descriptor_id){
104 case 111: // Solid Linear Tetrahedron - TET4
105 case 118: // Solid Quadratic Tetrahedron - TET10
107 anElement = myMesh->AddVolumeWithID(aRec.node_labels[0],
114 case 112: // Solid Linear Prism - PRISM6
116 anElement = myMesh->AddVolumeWithID(aRec.node_labels[0],
125 case 113: // Solid Quadratic Prism - PRISM15
127 anElement = myMesh->AddVolumeWithID(aRec.node_labels[0],
131 aRec.node_labels[13],
132 aRec.node_labels[11],
136 case 115: // Solid Linear Brick - HEX8
137 anElement = myMesh->AddVolumeWithID(aRec.node_labels[0],
148 case 116: // Solid Quadratic Brick - HEX20
150 anElement = myMesh->AddVolumeWithID(aRec.node_labels[0],
154 aRec.node_labels[12],
155 aRec.node_labels[18],
156 aRec.node_labels[16],
157 aRec.node_labels[14],
163 MESSAGE("DriverUNV_R_SMDS_Mesh::Perform - can not add element with ID = "<<aLabel<<" and type = "<<aRec.fe_descriptor_id);
166 }catch(const std::exception& exc){
167 INFOS("Follow exception was cought:\n\t"<<exc.what());
169 INFOS("Unknown exception was cought !!!");