1 // Copyright (C) 2007-2010 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
26 #include "UNV2412_Structure.hxx"
27 #include "UNV_Utilities.hxx"
31 using namespace UNV2412;
34 static int MYDEBUG = 1;
36 static int MYDEBUG = 0;
39 static string _label_dataset = "2412";
41 UNV2412::TRecord::TRecord():
50 void UNV2412::Read(std::ifstream& in_stream, TDataSet& theDataSet)
53 EXCEPTION(runtime_error,"ERROR: Input file not good.");
56 * adjust the \p istream to our
59 if(!beginning_of_dataset(in_stream,_label_dataset))
60 EXCEPTION(runtime_error,"ERROR: Could not find "<<_label_dataset<<" dataset!");
63 for(; !in_stream.eof();){
66 // end of dataset is reached
72 in_stream>>aRec.fe_descriptor_id;
73 in_stream>>aRec.phys_prop_tab_num;
74 in_stream>>aRec.mat_prop_tab_num;
75 in_stream>>aRec.color;
78 if(IsBeam(aRec.fe_descriptor_id)){
79 in_stream>>aRec.beam_orientation;
80 in_stream>>aRec.beam_fore_end;
81 in_stream>>aRec.beam_aft_end;
84 aRec.node_labels.resize(n_nodes);
85 for(int j=0; j < n_nodes; j++){
87 in_stream>>aRec.node_labels[j];
90 theDataSet.insert(TDataSet::value_type(aLabel,aRec));
96 void UNV2412::Write(std::ofstream& out_stream, const TDataSet& theDataSet)
98 if(!out_stream.good())
99 EXCEPTION(runtime_error,"ERROR: Output file not good.");
102 * Write beginning of dataset
105 out_stream<<" "<<_label_dataset<<"\n";
107 TDataSet::const_iterator anIter = theDataSet.begin();
108 for(; anIter != theDataSet.end(); anIter++){
109 const TElementLab& aLabel = anIter->first;
110 const TRecord& aRec = anIter->second;
111 out_stream<<std::setw(10)<<aLabel; /* element ID */
112 out_stream<<std::setw(10)<<aRec.fe_descriptor_id; /* type of element */
113 out_stream<<std::setw(10)<<aRec.phys_prop_tab_num;
114 out_stream<<std::setw(10)<<aRec.mat_prop_tab_num;
115 out_stream<<std::setw(10)<<aRec.color;
116 out_stream<<std::setw(10)<<aRec.node_labels.size()<<std::endl; /* No. of nodes per element */
118 if(IsBeam(aRec.fe_descriptor_id)){
119 out_stream<<std::setw(10)<<aRec.beam_orientation;
120 out_stream<<std::setw(10)<<aRec.beam_fore_end;
121 out_stream<<std::setw(10)<<aRec.beam_aft_end<<std::endl;
124 int n_nodes = aRec.node_labels.size();
125 int iEnd = (n_nodes-1)/8 + 1;
126 for(int i = 0, k = 0; i < iEnd; i++){
127 int jEnd = n_nodes - 8*(i+1);
132 for(int j = 0; j < jEnd ; k++, j++){
133 out_stream<<std::setw(10)<<aRec.node_labels[k];
135 out_stream<<std::endl;
140 * Write end of dataset
146 bool UNV2412::IsBeam(int theFeDescriptorId){
147 switch (theFeDescriptorId){
148 case 11: // edge with 2 nodes
150 case 22: // edge with 3 nodes
151 case 23: // curved beam
160 bool UNV2412::IsFace(int theFeDescriptorId){
161 switch (theFeDescriptorId){
167 case 41: // Plane Stress Linear Triangle - TRI3
168 case 91: // Thin Shell Linear Triangle - TRI3
170 case 42: // Plane Stress Quadratic Triangle - TRI6
171 case 92: // Thin Shell Quadratic Triangle - TRI6
173 case 43: // Plane Stress Cubic Triangle
175 case 44: // Plane Stress Linear Quadrilateral - QUAD4
176 case 94: // Thin Shell Linear Quadrilateral - QUAD4
178 case 45: // Plane Stress Quadratic Quadrilateral - QUAD8
179 case 95: // Thin Shell Quadratic Quadrilateral - QUAD8
181 case 46: // Plane Stress Cubic Quadrilateral
189 bool UNV2412::IsVolume(int theFeDescriptorId){
190 //if(!IsBeam(theFeDescriptorId) && !IsFace(theFeDescriptorId))
192 switch (theFeDescriptorId){
194 case 111: // Solid Linear Tetrahedron - TET4
195 case 118: // Solid Quadratic Tetrahedron - TET10
197 case 112: // Solid Linear Prism - PRISM6
198 case 113: // Solid Quadratic Prism - PRISM15
200 case 115: // Solid Linear Brick - HEX8
201 case 116: // Solid Quadratic Brick - HEX20
203 case 117: // Solid Cubic Brick
205 case 114: // pyramid of 13 nodes (quadratic)