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 if(aRec.fe_descriptor_id == 11) {
69 // edge with two nodes
70 anElement = myMesh->AddEdgeWithID(aRec.node_labels[0],
75 // quadratic edge (with 3 nodes)
76 anElement = myMesh->AddEdgeWithID(aRec.node_labels[0],
82 else if(IsFace(aRec.fe_descriptor_id)) {
83 switch(aRec.fe_descriptor_id){
88 case 41: // Plane Stress Linear Triangle - TRI3
89 case 91: // Thin Shell Linear Triangle - TRI3
90 anElement = myMesh->AddFaceWithID(aRec.node_labels[0],
96 case 42: // Plane Stress Quadratic Triangle - TRI6
97 case 92: // Thin Shell Quadratic Triangle - TRI6
98 anElement = myMesh->AddFaceWithID(aRec.node_labels[0],
107 case 44: // Plane Stress Linear Quadrilateral - QUAD4
108 case 94: // Thin Shell Linear Quadrilateral - QUAD4
109 anElement = myMesh->AddFaceWithID(aRec.node_labels[0],
116 case 45: // Plane Stress Quadratic Quadrilateral - QUAD8
117 case 95: // Thin Shell Quadratic Quadrilateral - QUAD8
118 anElement = myMesh->AddFaceWithID(aRec.node_labels[0],
130 else if(IsVolume(aRec.fe_descriptor_id)){
131 switch(aRec.fe_descriptor_id){
133 case 111: // Solid Linear Tetrahedron - TET4
134 anElement = myMesh->AddVolumeWithID(aRec.node_labels[0],
141 case 118: // Solid Quadratic Tetrahedron - TET10
142 anElement = myMesh->AddVolumeWithID(aRec.node_labels[0],
155 case 112: // Solid Linear Prism - PRISM6
156 anElement = myMesh->AddVolumeWithID(aRec.node_labels[0],
165 case 113: // Solid Quadratic Prism - PRISM15
166 anElement = myMesh->AddVolumeWithID(aRec.node_labels[0],
175 aRec.node_labels[11],
176 aRec.node_labels[10],
178 aRec.node_labels[12],
179 aRec.node_labels[14],
180 aRec.node_labels[13],
184 case 115: // Solid Linear Brick - HEX8
185 anElement = myMesh->AddVolumeWithID(aRec.node_labels[0],
196 case 116: // Solid Quadratic Brick - HEX20
197 anElement = myMesh->AddVolumeWithID(aRec.node_labels[0],
205 aRec.node_labels[11],
206 aRec.node_labels[10],
209 aRec.node_labels[15],
210 aRec.node_labels[14],
211 aRec.node_labels[13],
212 aRec.node_labels[12],
213 aRec.node_labels[16],
214 aRec.node_labels[19],
215 aRec.node_labels[18],
216 aRec.node_labels[17],
220 case 114: // pyramid of 13 nodes (quadratic) - PIRA13
221 anElement = myMesh->AddVolumeWithID(aRec.node_labels[0],
231 aRec.node_labels[12],
232 aRec.node_labels[11],
233 aRec.node_labels[10],
240 MESSAGE("DriverUNV_R_SMDS_Mesh::Perform - can not add element with ID = "<<aLabel<<" and type = "<<aRec.fe_descriptor_id);
244 catch(const std::exception& exc){
245 INFOS("Follow exception was cought:\n\t"<<exc.what());
248 INFOS("Unknown exception was cought !!!");