X-Git-Url: http://git.salome-platform.org/gitweb/?p=modules%2Fsmesh.git;a=blobdiff_plain;f=src%2FDriverUNV%2FUNV2412_Structure.cxx;fp=src%2FDriverUNV%2FUNV2412_Structure.cxx;h=0160d7b68ab3f112fc03d403f54a47a45915d112;hp=0000000000000000000000000000000000000000;hb=e4737e85f0da6d3f90fd08f6be1c2825195fe16f;hpb=51569f091c2d18be76ea9bd3e68ca0247cc731c3 diff --git a/src/DriverUNV/UNV2412_Structure.cxx b/src/DriverUNV/UNV2412_Structure.cxx new file mode 100644 index 000000000..0160d7b68 --- /dev/null +++ b/src/DriverUNV/UNV2412_Structure.cxx @@ -0,0 +1,203 @@ +// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org + +#include +#include + +#include "UNV2412_Structure.hxx" +#include "UNV_Utilities.hxx" + +using namespace std; +using namespace UNV; +using namespace UNV2412; + +#ifdef _DEBUG_ +static int MYDEBUG = 1; +#else +static int MYDEBUG = 0; +#endif + +static string _label_dataset = "2412"; + +UNV2412::TRecord::TRecord(): + phys_prop_tab_num(2), + mat_prop_tab_num(1), + color(7), + beam_orientation(0), + beam_fore_end(0), + beam_aft_end(0) +{} + +void UNV2412::Read(std::ifstream& in_stream, TDataSet& theDataSet) +{ + if(!in_stream.good()) + EXCEPTION(runtime_error,"ERROR: Input file not good."); + + /* + * adjust the \p istream to our + * position + */ + if(!beginning_of_dataset(in_stream,_label_dataset)) + EXCEPTION(runtime_error,"ERROR: Could not find "<<_label_dataset<<" dataset!"); + + TElementLab aLabel; + for(; !in_stream.eof();){ + in_stream >> aLabel ; + if(aLabel == -1){ + // end of dataset is reached + break; + } + + int n_nodes; + TRecord aRec; + in_stream>>aRec.fe_descriptor_id; + in_stream>>aRec.phys_prop_tab_num; + in_stream>>aRec.mat_prop_tab_num; + in_stream>>aRec.color; + in_stream>>n_nodes; + + if(IsBeam(aRec.fe_descriptor_id)){ + in_stream>>aRec.beam_orientation; + in_stream>>aRec.beam_fore_end; + in_stream>>aRec.beam_aft_end; + } + + aRec.node_labels.resize(n_nodes); + for(int j=0; j < n_nodes; j++){ + // read node labels + in_stream>>aRec.node_labels[j]; + } + + theDataSet.insert(TDataSet::value_type(aLabel,aRec)); + } + +} + + +void UNV2412::Write(std::ofstream& out_stream, const TDataSet& theDataSet) +{ + if(!out_stream.good()) + EXCEPTION(runtime_error,"ERROR: Output file not good."); + + /* + * Write beginning of dataset + */ + out_stream<<" -1\n"; + out_stream<<" "<<_label_dataset<<"\n"; + + TDataSet::const_iterator anIter = theDataSet.begin(); + for(; anIter != theDataSet.end(); anIter++){ + const TElementLab& aLabel = anIter->first; + const TRecord& aRec = anIter->second; + out_stream<