1 // Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
25 #include "UNV2412_Structure.hxx"
26 #include "UNV_Utilities.hxx"
30 using namespace UNV2412;
33 static int MYDEBUG = 1;
35 static int MYDEBUG = 0;
38 static string _label_dataset = "2412";
40 UNV2412::TRecord::TRecord():
49 void UNV2412::Read(std::ifstream& in_stream, TDataSet& theDataSet)
52 EXCEPTION(runtime_error,"ERROR: Input file not good.");
55 * adjust the \p istream to our
58 if(!beginning_of_dataset(in_stream,_label_dataset))
59 EXCEPTION(runtime_error,"ERROR: Could not find "<<_label_dataset<<" dataset!");
62 for(; !in_stream.eof();){
65 // end of dataset is reached
71 in_stream>>aRec.fe_descriptor_id;
72 in_stream>>aRec.phys_prop_tab_num;
73 in_stream>>aRec.mat_prop_tab_num;
74 in_stream>>aRec.color;
77 if(IsBeam(aRec.fe_descriptor_id)){
78 in_stream>>aRec.beam_orientation;
79 in_stream>>aRec.beam_fore_end;
80 in_stream>>aRec.beam_aft_end;
83 aRec.node_labels.resize(n_nodes);
84 for(int j=0; j < n_nodes; j++){
86 in_stream>>aRec.node_labels[j];
89 theDataSet.insert(TDataSet::value_type(aLabel,aRec));
95 void UNV2412::Write(std::ofstream& out_stream, const TDataSet& theDataSet)
97 if(!out_stream.good())
98 EXCEPTION(runtime_error,"ERROR: Output file not good.");
101 * Write beginning of dataset
104 out_stream<<" "<<_label_dataset<<"\n";
106 TDataSet::const_iterator anIter = theDataSet.begin();
107 for(; anIter != theDataSet.end(); anIter++){
108 const TElementLab& aLabel = anIter->first;
109 const TRecord& aRec = anIter->second;
110 out_stream<<std::setw(10)<<aLabel; /* element ID */
111 out_stream<<std::setw(10)<<aRec.fe_descriptor_id; /* type of element */
112 out_stream<<std::setw(10)<<aRec.phys_prop_tab_num;
113 out_stream<<std::setw(10)<<aRec.mat_prop_tab_num;
114 out_stream<<std::setw(10)<<aRec.color;
115 out_stream<<std::setw(10)<<aRec.node_labels.size()<<std::endl; /* No. of nodes per element */
117 if(IsBeam(aRec.fe_descriptor_id)){
118 out_stream<<std::setw(10)<<aRec.beam_orientation;
119 out_stream<<std::setw(10)<<aRec.beam_fore_end;
120 out_stream<<std::setw(10)<<aRec.beam_aft_end<<std::endl;
123 int n_nodes = aRec.node_labels.size();
124 int iEnd = (n_nodes-1)/8 + 1;
125 for(int i = 0, k = 0; i < iEnd; i++){
126 int jEnd = n_nodes - 8*(i+1);
131 for(int j = 0; j < jEnd ; k++, j++){
132 out_stream<<std::setw(10)<<aRec.node_labels[k];
134 out_stream<<std::endl;
139 * Write end of dataset
145 bool UNV2412::IsBeam(int theFeDescriptorId){
146 switch (theFeDescriptorId){
147 case 11: // edge with 2 nodes
149 case 22: // edge with 3 nodes
150 case 23: // curved beam
159 bool UNV2412::IsFace(int theFeDescriptorId){
160 switch (theFeDescriptorId){
166 case 41: // Plane Stress Linear Triangle - TRI3
167 case 91: // Thin Shell Linear Triangle - TRI3
169 case 42: // Plane Stress Quadratic Triangle - TRI6
170 case 92: // Thin Shell Quadratic Triangle - TRI6
172 case 43: // Plane Stress Cubic Triangle
174 case 44: // Plane Stress Linear Quadrilateral - QUAD4
175 case 94: // Thin Shell Linear Quadrilateral - QUAD4
177 case 45: // Plane Stress Quadratic Quadrilateral - QUAD8
178 case 95: // Thin Shell Quadratic Quadrilateral - QUAD8
180 case 46: // Plane Stress Cubic Quadrilateral
188 bool UNV2412::IsVolume(int theFeDescriptorId){
189 //if(!IsBeam(theFeDescriptorId) && !IsFace(theFeDescriptorId))
191 switch (theFeDescriptorId){
193 case 111: // Solid Linear Tetrahedron - TET4
194 case 118: // Solid Quadratic Tetrahedron - TET10
196 case 112: // Solid Linear Prism - PRISM6
197 case 113: // Solid Quadratic Prism - PRISM15
199 case 115: // Solid Linear Brick - HEX8
200 case 116: // Solid Quadratic Brick - HEX20
202 case 117: // Solid Cubic Brick
204 case 114: // pyramid of 13 nodes (quadratic)