1 // Copyright (C) 2003 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
23 #include "UNV2412_Structure.hxx"
24 #include "UNV_Utilities.hxx"
28 using namespace UNV2412;
31 static int MYDEBUG = 1;
33 static int MYDEBUG = 0;
36 static string _label_dataset = "2412";
38 UNV2412::TRecord::TRecord():
47 void UNV2412::Read(std::ifstream& in_stream, TDataSet& theDataSet)
50 EXCEPTION(runtime_error,"ERROR: Input file not good.");
53 * adjust the \p istream to our
56 if(!beginning_of_dataset(in_stream,_label_dataset))
57 EXCEPTION(runtime_error,"ERROR: Could not find "<<_label_dataset<<" dataset!");
60 for(; !in_stream.eof();){
63 // end of dataset is reached
69 in_stream>>aRec.fe_descriptor_id;
70 in_stream>>aRec.phys_prop_tab_num;
71 in_stream>>aRec.mat_prop_tab_num;
72 in_stream>>aRec.color;
75 if(IsBeam(aRec.fe_descriptor_id)){
76 in_stream>>aRec.beam_orientation;
77 in_stream>>aRec.beam_fore_end;
78 in_stream>>aRec.beam_aft_end;
81 aRec.node_labels.resize(n_nodes);
82 for(int j=0; j < n_nodes; j++){
84 in_stream>>aRec.node_labels[j];
87 theDataSet.insert(TDataSet::value_type(aLabel,aRec));
93 void UNV2412::Write(std::ofstream& out_stream, const TDataSet& theDataSet)
95 if(!out_stream.good())
96 EXCEPTION(runtime_error,"ERROR: Output file not good.");
99 * Write beginning of dataset
102 out_stream<<" "<<_label_dataset<<"\n";
104 TDataSet::const_iterator anIter = theDataSet.begin();
105 for(; anIter != theDataSet.end(); anIter++){
106 const TElementLab& aLabel = anIter->first;
107 const TRecord& aRec = anIter->second;
108 out_stream<<std::setw(10)<<aLabel; /* element ID */
109 out_stream<<std::setw(10)<<aRec.fe_descriptor_id; /* type of element */
110 out_stream<<std::setw(10)<<aRec.phys_prop_tab_num;
111 out_stream<<std::setw(10)<<aRec.mat_prop_tab_num;
112 out_stream<<std::setw(10)<<aRec.color;
113 out_stream<<std::setw(10)<<aRec.node_labels.size()<<std::endl; /* No. of nodes per element */
115 if(IsBeam(aRec.fe_descriptor_id)){
116 out_stream<<std::setw(10)<<aRec.beam_orientation;
117 out_stream<<std::setw(10)<<aRec.beam_fore_end;
118 out_stream<<std::setw(10)<<aRec.beam_aft_end<<std::endl;
121 int n_nodes = aRec.node_labels.size();
122 int iEnd = (n_nodes-1)/8 + 1;
123 for(int i = 0, k = 0; i < iEnd; i++){
124 int jEnd = n_nodes - 8*(i+1);
129 for(int j = 0; j < jEnd ; k++, j++){
130 out_stream<<std::setw(10)<<aRec.node_labels[k];
132 out_stream<<std::endl;
137 * Write end of dataset
143 bool UNV2412::IsBeam(int theFeDescriptorId){
144 switch (theFeDescriptorId){
145 case 11: // edge with 2 nodes
147 case 22: // edge with 3 nodes
148 case 23: // curved beam
157 bool UNV2412::IsFace(int theFeDescriptorId){
158 switch (theFeDescriptorId){
164 case 41: // Plane Stress Linear Triangle - TRI3
165 case 91: // Thin Shell Linear Triangle - TRI3
167 case 42: // Plane Stress Quadratic Triangle - TRI6
168 case 92: // Thin Shell Quadratic Triangle - TRI6
170 case 43: // Plane Stress Cubic Triangle
172 case 44: // Plane Stress Linear Quadrilateral - QUAD4
173 case 94: // Thin Shell Linear Quadrilateral - QUAD4
175 case 45: // Plane Stress Quadratic Quadrilateral - QUAD8
176 case 95: // Thin Shell Quadratic Quadrilateral - QUAD8
178 case 46: // Plane Stress Cubic Quadrilateral
186 bool UNV2412::IsVolume(int theFeDescriptorId){
187 //if(!IsBeam(theFeDescriptorId) && !IsFace(theFeDescriptorId))
189 switch (theFeDescriptorId){
191 case 111: // Solid Linear Tetrahedron - TET4
192 case 118: // Solid Quadratic Tetrahedron - TET10
194 case 112: // Solid Linear Prism - PRISM6
195 case 113: // Solid Quadratic Prism - PRISM15
197 case 115: // Solid Linear Brick - HEX8
198 case 116: // Solid Quadratic Brick - HEX20
200 case 117: // Solid Cubic Brick
202 case 114: // pyramid of 13 nodes (quadratic)