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
22 #include "DriverUNV_W_SMDS_Mesh.h"
24 #include "SMDS_Mesh.hxx"
26 #include "utilities.h"
28 #include "UNV2411_Structure.hxx"
29 #include "UNV2412_Structure.hxx"
30 #include "UNV_Utilities.hxx"
34 Driver_Mesh::Status DriverUNV_W_SMDS_Mesh::Perform()
36 Status aResult = DRS_OK;
37 std::ofstream out_stream(myFile.c_str());
40 using namespace UNV2411;
41 TDataSet aDataSet2411;
42 // Storing SMDS nodes to the UNV file
43 //-----------------------------------
44 MESSAGE("Perform - myMesh->NbNodes() = "<<myMesh->NbNodes());
45 SMDS_NodeIteratorPtr aNodesIter = myMesh->nodesIterator();
46 for(; aNodesIter->more();){
47 const SMDS_MeshNode* aNode = aNodesIter->next();
49 aRec.coord[0] = aNode->X();
50 aRec.coord[1] = aNode->Y();
51 aRec.coord[2] = aNode->Z();
52 const TNodeLab& aLabel = aNode->GetID();
53 aDataSet2411.insert(TDataSet::value_type(aLabel,aRec));
55 MESSAGE("Perform - aDataSet2411.size() = "<<aDataSet2411.size());
56 UNV2411::Write(out_stream,aDataSet2411);
59 using namespace UNV2412;
60 TDataSet aDataSet2412;
62 MESSAGE("Perform - myMesh->NbEdges() = "<<myMesh->NbEdges());
63 if(myMesh->NbEdges()){
64 SMDS_EdgeIteratorPtr anIter = myMesh->edgesIterator();
65 for(; anIter->more();){
66 const SMDS_MeshEdge* anElem = anIter->next();
67 const TElementLab& aLabel = anElem->GetID();
68 int aNbNodes = anElem->NbNodes();
70 aRec.node_labels.reserve(aNbNodes);
71 SMDS_ElemIteratorPtr aNodesIter = anElem->nodesIterator();
72 for(; aNodesIter->more();){
73 const SMDS_MeshElement* aNode = aNodesIter->next();
74 aRec.node_labels.push_back(aNode->GetID());
76 aRec.fe_descriptor_id = 11;
77 aDataSet2412.insert(TDataSet::value_type(aLabel,aRec));
79 MESSAGE("Perform - aDataSet2412.size() = "<<aDataSet2412.size());
81 MESSAGE("Perform - myMesh->NbFaces() = "<<myMesh->NbFaces());
82 if(myMesh->NbFaces()){
83 SMDS_FaceIteratorPtr anIter = myMesh->facesIterator();
84 for(; anIter->more();){
85 const SMDS_MeshFace* anElem = anIter->next();
86 const TElementLab& aLabel = anElem->GetID();
87 int aNbNodes = anElem->NbNodes();
89 aRec.node_labels.reserve(aNbNodes);
90 SMDS_ElemIteratorPtr aNodesIter = anElem->nodesIterator();
91 for(; aNodesIter->more();){
92 const SMDS_MeshElement* aNode = aNodesIter->next();
93 aRec.node_labels.push_back(aNode->GetID());
97 aRec.fe_descriptor_id = 41;
100 aRec.fe_descriptor_id = 44;
105 aDataSet2412.insert(TDataSet::value_type(aLabel,aRec));
107 MESSAGE("Perform - aDataSet2412.size() = "<<aDataSet2412.size());
109 MESSAGE("Perform - myMesh->NbVolumes() = "<<myMesh->NbVolumes());
110 if(myMesh->NbVolumes()){
111 SMDS_VolumeIteratorPtr anIter = myMesh->volumesIterator();
112 for(; anIter->more();){
113 const SMDS_MeshVolume* anElem = anIter->next();
114 const TElementLab& aLabel = anElem->GetID();
115 int aNbNodes = anElem->NbNodes();
117 aRec.node_labels.reserve(aNbNodes);
118 SMDS_ElemIteratorPtr aNodesIter = anElem->nodesIterator();
119 for(; aNodesIter->more();){
120 const SMDS_MeshElement* aNode = aNodesIter->next();
121 aRec.node_labels.push_back(aNode->GetID());
125 aRec.fe_descriptor_id = 111;
128 aRec.fe_descriptor_id = 112;
129 swap(aRec.node_labels[1],aRec.node_labels[2]);
130 swap(aRec.node_labels[4],aRec.node_labels[5]);
133 aRec.fe_descriptor_id = 115;
138 aDataSet2412.insert(TDataSet::value_type(aLabel,aRec));
140 MESSAGE("Perform - aDataSet2412.size() = "<<aDataSet2412.size());
142 UNV2412::Write(out_stream,aDataSet2412);
144 }catch(const std::exception& exc){
145 INFOS("Follow exception was cought:\n\t"<<exc.what());
147 INFOS("Unknown exception was cought !!!");