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 "UNV2417_Structure.hxx"
28 #include "UNV_Utilities.hxx"
34 static int MYDEBUG = 0;
36 static int MYDEBUG = 0;
40 Driver_Mesh::Status DriverUNV_R_SMDS_Mesh::Perform()
42 Status aResult = DRS_OK;
43 std::ifstream in_stream(myFile.c_str());
46 using namespace UNV2411;
47 TDataSet aDataSet2411;
48 UNV2411::Read(in_stream,aDataSet2411);
49 if(MYDEBUG) MESSAGE("Perform - aDataSet2411.size() = "<<aDataSet2411.size());
50 TDataSet::const_iterator anIter = aDataSet2411.begin();
51 for(; anIter != aDataSet2411.end(); anIter++){
52 const TNodeLab& aLabel = anIter->first;
53 const TRecord& aRec = anIter->second;
54 myMesh->AddNodeWithID(aRec.coord[0],aRec.coord[1],aRec.coord[2],aLabel);
58 using namespace UNV2412;
60 TDataSet aDataSet2412;
61 UNV2412::Read(in_stream,aDataSet2412);
62 TDataSet::const_iterator anIter = aDataSet2412.begin();
63 if(MYDEBUG) MESSAGE("Perform - aDataSet2412.size() = "<<aDataSet2412.size());
64 for(; anIter != aDataSet2412.end(); anIter++){
65 SMDS_MeshElement* anElement = NULL;
66 const TElementLab& aLabel = anIter->first;
67 const TRecord& aRec = anIter->second;
68 if(IsBeam(aRec.fe_descriptor_id)) {
69 if((aRec.fe_descriptor_id == 11) || (aRec.fe_descriptor_id == 21)) {
70 // edge with two nodes
71 anElement = myMesh->AddEdgeWithID(aRec.node_labels[0],
76 cout<<"### Id of element = "<<aRec.fe_descriptor_id<<endl;
77 // quadratic edge (with 3 nodes)
78 anElement = myMesh->AddEdgeWithID(aRec.node_labels[0],
84 else if(IsFace(aRec.fe_descriptor_id)) {
85 switch(aRec.fe_descriptor_id){
90 case 41: // Plane Stress Linear Triangle - TRI3
91 case 91: // Thin Shell Linear Triangle - TRI3
92 anElement = myMesh->AddFaceWithID(aRec.node_labels[0],
98 case 42: // Plane Stress Quadratic Triangle - TRI6
99 case 92: // Thin Shell Quadratic Triangle - TRI6
100 anElement = myMesh->AddFaceWithID(aRec.node_labels[0],
109 case 44: // Plane Stress Linear Quadrilateral - QUAD4
110 case 94: // Thin Shell Linear Quadrilateral - QUAD4
111 anElement = myMesh->AddFaceWithID(aRec.node_labels[0],
118 case 45: // Plane Stress Quadratic Quadrilateral - QUAD8
119 case 95: // Thin Shell Quadratic Quadrilateral - QUAD8
120 anElement = myMesh->AddFaceWithID(aRec.node_labels[0],
132 else if(IsVolume(aRec.fe_descriptor_id)){
133 switch(aRec.fe_descriptor_id){
135 case 111: // Solid Linear Tetrahedron - TET4
136 anElement = myMesh->AddVolumeWithID(aRec.node_labels[0],
143 case 118: // Solid Quadratic Tetrahedron - TET10
144 anElement = myMesh->AddVolumeWithID(aRec.node_labels[0],
157 case 112: // Solid Linear Prism - PRISM6
158 anElement = myMesh->AddVolumeWithID(aRec.node_labels[0],
167 case 113: // Solid Quadratic Prism - PRISM15
168 anElement = myMesh->AddVolumeWithID(aRec.node_labels[0],
177 aRec.node_labels[11],
178 aRec.node_labels[10],
180 aRec.node_labels[12],
181 aRec.node_labels[14],
182 aRec.node_labels[13],
186 case 115: // Solid Linear Brick - HEX8
187 anElement = myMesh->AddVolumeWithID(aRec.node_labels[0],
198 case 116: // Solid Quadratic Brick - HEX20
199 anElement = myMesh->AddVolumeWithID(aRec.node_labels[0],
204 aRec.node_labels[12],
205 aRec.node_labels[18],
206 aRec.node_labels[16],
207 aRec.node_labels[14],
214 aRec.node_labels[19],
215 aRec.node_labels[17],
216 aRec.node_labels[15],
217 aRec.node_labels[13],
220 aRec.node_labels[11],
221 aRec.node_labels[10],
226 case 114: // pyramid of 13 nodes (quadratic) - PIRA13
227 anElement = myMesh->AddVolumeWithID(aRec.node_labels[0],
237 aRec.node_labels[12],
238 aRec.node_labels[11],
239 aRec.node_labels[10],
246 // MESSAGE("DriverUNV_R_SMDS_Mesh::Perform - can not add element with ID = "<<aLabel<<" and type = "<<aRec.fe_descriptor_id);
250 using namespace UNV2417;
251 TDataSet aDataSet2417;
252 UNV2417::Read(in_stream,aDataSet2417);
255 catch(const std::exception& exc){
256 INFOS("Follow exception was cought:\n\t"<<exc.what());
259 INFOS("Unknown exception was cought !!!");