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"
35 typedef std::vector<size_t> TConnect;
37 int GetConnect(const SMDS_ElemIteratorPtr& theNodesIter,
41 for(; theNodesIter->more();){
42 const SMDS_MeshElement* anElem = theNodesIter->next();
43 theConnect.push_back(anElem->GetID());
45 return theConnect.size();
50 Driver_Mesh::Status DriverUNV_W_SMDS_Mesh::Perform()
52 Status aResult = DRS_OK;
53 std::ofstream out_stream(myFile.c_str());
56 using namespace UNV2411;
57 TDataSet aDataSet2411;
58 // Storing SMDS nodes to the UNV file
59 //-----------------------------------
60 MESSAGE("Perform - myMesh->NbNodes() = "<<myMesh->NbNodes());
61 SMDS_NodeIteratorPtr aNodesIter = myMesh->nodesIterator();
62 for(; aNodesIter->more();){
63 const SMDS_MeshNode* aNode = aNodesIter->next();
65 aRec.coord[0] = aNode->X();
66 aRec.coord[1] = aNode->Y();
67 aRec.coord[2] = aNode->Z();
68 const TNodeLab& aLabel = aNode->GetID();
69 aDataSet2411.insert(TDataSet::value_type(aLabel,aRec));
71 MESSAGE("Perform - aDataSet2411.size() = "<<aDataSet2411.size());
72 UNV2411::Write(out_stream,aDataSet2411);
75 using namespace UNV2412;
76 TDataSet aDataSet2412;
80 MESSAGE("Perform - myMesh->NbEdges() = "<<myMesh->NbEdges());
81 if(myMesh->NbEdges()){
82 SMDS_EdgeIteratorPtr anIter = myMesh->edgesIterator();
83 for(; anIter->more();){
84 const SMDS_MeshEdge* anElem = anIter->next();
85 TElementLab aLabel = anElem->GetID();
86 int aNbNodes = anElem->NbNodes();
88 aRec.node_labels.reserve(aNbNodes);
89 SMDS_ElemIteratorPtr aNodesIter = anElem->nodesIterator();
90 for(; aNodesIter->more();){
91 const SMDS_MeshElement* aNode = aNodesIter->next();
92 aRec.node_labels.push_back(aNode->GetID());
94 aRec.fe_descriptor_id = 11;
95 aDataSet2412.insert(TDataSet::value_type(aLabel,aRec));
97 MESSAGE("Perform - aDataSet2412.size() = "<<aDataSet2412.size());
100 MESSAGE("Perform - myMesh->NbFaces() = "<<myMesh->NbFaces());
101 if(myMesh->NbFaces()){
102 SMDS_FaceIteratorPtr anIter = myMesh->facesIterator();
103 for(; anIter->more();){
104 const SMDS_MeshFace* anElem = anIter->next();
105 TElementLab aLabel = anElem->GetID();
106 int aNbNodes = anElem->NbNodes();
108 aRec.node_labels.reserve(aNbNodes);
109 SMDS_ElemIteratorPtr aNodesIter = anElem->nodesIterator();
110 for(; aNodesIter->more();){
111 const SMDS_MeshElement* aNode = aNodesIter->next();
112 aRec.node_labels.push_back(aNode->GetID());
116 aRec.fe_descriptor_id = 41;
119 aRec.fe_descriptor_id = 44;
124 aDataSet2412.insert(TDataSet::value_type(aLabel,aRec));
126 MESSAGE("Perform - aDataSet2412.size() = "<<aDataSet2412.size());
129 MESSAGE("Perform - myMesh->NbVolumes() = "<<myMesh->NbVolumes());
130 if(myMesh->NbVolumes()){
131 SMDS_VolumeIteratorPtr anIter = myMesh->volumesIterator();
132 for(; anIter->more();){
133 const SMDS_MeshVolume* anElem = anIter->next();
134 TElementLab aLabel = anElem->GetID();
136 int aNbNodes = anElem->NbNodes();
137 aConnect.resize(aNbNodes);
139 SMDS_ElemIteratorPtr aNodesIter = anElem->nodesIterator();
140 GetConnect(aNodesIter,aConnect);
146 static int anIds[] = {0,2,1,3};
152 static int anIds[] = {0,2,1,3,5,4};
158 static int anIds[] = {0,3,2,1,4,7,6,5};
168 aRec.fe_descriptor_id = anId;
169 aRec.node_labels.resize(aNbNodes);
170 for(int aNodeId = 0; aNodeId < aNbNodes; aNodeId++){
171 aRec.node_labels[aConn[aNodeId]] = aConnect[aNodeId];
173 aDataSet2412.insert(TDataSet::value_type(aLabel,aRec));
176 MESSAGE("Perform - aDataSet2412.size() = "<<aDataSet2412.size());
178 UNV2412::Write(out_stream,aDataSet2412);
180 }catch(const std::exception& exc){
181 INFOS("Follow exception was cought:\n\t"<<exc.what());
183 INFOS("Unknown exception was cought !!!");