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"
25 #include "SMESHDS_GroupBase.hxx"
26 #include "SMESH_Group.hxx"
27 #include "SMDS_QuadraticEdge.hxx"
28 #include "SMDS_QuadraticFaceOfNodes.hxx"
30 #include "utilities.h"
32 #include "UNV2411_Structure.hxx"
33 #include "UNV2412_Structure.hxx"
34 #include "UNV2417_Structure.hxx"
35 #include "UNV_Utilities.hxx"
40 typedef std::vector<size_t> TConnect;
42 int GetConnect(const SMDS_ElemIteratorPtr& theNodesIter,
46 for(; theNodesIter->more();){
47 const SMDS_MeshElement* anElem = theNodesIter->next();
48 theConnect.push_back(anElem->GetID());
50 return theConnect.size();
55 Driver_Mesh::Status DriverUNV_W_SMDS_Mesh::Perform()
57 Status aResult = DRS_OK;
58 std::ofstream out_stream(myFile.c_str());
61 using namespace UNV2411;
62 TDataSet aDataSet2411;
63 // Storing SMDS nodes to the UNV file
64 //-----------------------------------
65 MESSAGE("Perform - myMesh->NbNodes() = "<<myMesh->NbNodes());
66 SMDS_NodeIteratorPtr aNodesIter = myMesh->nodesIterator();
67 for(; aNodesIter->more();){
68 const SMDS_MeshNode* aNode = aNodesIter->next();
70 aRec.coord[0] = aNode->X();
71 aRec.coord[1] = aNode->Y();
72 aRec.coord[2] = aNode->Z();
73 const TNodeLab& aLabel = aNode->GetID();
74 aDataSet2411.insert(TDataSet::value_type(aLabel,aRec));
76 MESSAGE("Perform - aDataSet2411.size() = "<<aDataSet2411.size());
77 UNV2411::Write(out_stream,aDataSet2411);
80 using namespace UNV2412;
81 TDataSet aDataSet2412;
85 MESSAGE("Perform - myMesh->NbEdges() = "<<myMesh->NbEdges());
86 if(myMesh->NbEdges()){
87 SMDS_EdgeIteratorPtr anIter = myMesh->edgesIterator();
88 for(; anIter->more();){
89 const SMDS_MeshEdge* anElem = anIter->next();
90 TElementLab aLabel = anElem->GetID();
91 int aNbNodes = anElem->NbNodes();
93 aRec.node_labels.reserve(aNbNodes);
94 SMDS_ElemIteratorPtr aNodesIter;
95 if( anElem->IsQuadratic() ) {
96 aNodesIter = static_cast<const SMDS_QuadraticEdge* >
97 ( anElem )->interlacedNodesElemIterator();
98 aRec.fe_descriptor_id = 22;
100 aNodesIter = anElem->nodesIterator();
101 aRec.fe_descriptor_id = 11;
103 for(; aNodesIter->more();){
104 const SMDS_MeshElement* aNode = aNodesIter->next();
105 aRec.node_labels.push_back(aNode->GetID());
107 aDataSet2412.insert(TDataSet::value_type(aLabel,aRec));
109 MESSAGE("Perform - aDataSet2412.size() = "<<aDataSet2412.size());
112 MESSAGE("Perform - myMesh->NbFaces() = "<<myMesh->NbFaces());
113 if(myMesh->NbFaces()){
114 SMDS_FaceIteratorPtr anIter = myMesh->facesIterator();
115 for(; anIter->more();){
116 const SMDS_MeshFace* anElem = anIter->next();
117 TElementLab aLabel = anElem->GetID();
118 int aNbNodes = anElem->NbNodes();
120 aRec.node_labels.reserve(aNbNodes);
121 SMDS_ElemIteratorPtr aNodesIter;
122 if( anElem->IsQuadratic() )
123 aNodesIter = static_cast<const SMDS_QuadraticFaceOfNodes* >
124 ( anElem )->interlacedNodesElemIterator();
126 aNodesIter = anElem->nodesIterator();
127 for(; aNodesIter->more();){
128 const SMDS_MeshElement* aNode = aNodesIter->next();
129 aRec.node_labels.push_back(aNode->GetID());
133 aRec.fe_descriptor_id = 41;
136 aRec.fe_descriptor_id = 44;
139 aRec.fe_descriptor_id = 42;
142 aRec.fe_descriptor_id = 45;
147 aDataSet2412.insert(TDataSet::value_type(aLabel,aRec));
149 MESSAGE("Perform - aDataSet2412.size() = "<<aDataSet2412.size());
152 MESSAGE("Perform - myMesh->NbVolumes() = "<<myMesh->NbVolumes());
153 if(myMesh->NbVolumes()){
154 SMDS_VolumeIteratorPtr anIter = myMesh->volumesIterator();
155 for(; anIter->more();){
156 const SMDS_MeshVolume* anElem = anIter->next();
157 TElementLab aLabel = anElem->GetID();
159 int aNbNodes = anElem->NbNodes();
160 aConnect.resize(aNbNodes);
162 SMDS_ElemIteratorPtr aNodesIter = anElem->nodesIterator();
163 GetConnect(aNodesIter,aConnect);
169 static int anIds[] = {0,2,1,3};
175 static int anIds[] = {0,2,1,3,5,4};
181 static int anIds[] = {0,3,2,1,4,7,6,5};
187 static int anIds[] = {0,4,2,9,5,3, 1,6,8, 7};
193 static int anIds[] = {0,6,4,2,7,5,3,1,8,11,10,9,12};
199 static int anIds[] = {0,4,2,9,13,11,5,3,1,14,12,10,6,8,7};
205 static int anIds[] = {0,6, 4,2, 12,18,16,14,7, 5, 3, 1, 19,17,15,13,8, 11,10,9};
215 aRec.fe_descriptor_id = anId;
216 aRec.node_labels.resize(aNbNodes);
217 for(int aNodeId = 0; aNodeId < aNbNodes; aNodeId++){
218 aRec.node_labels[aConn[aNodeId]] = aConnect[aNodeId];
220 aDataSet2412.insert(TDataSet::value_type(aLabel,aRec));
223 MESSAGE("Perform - aDataSet2412.size() = "<<aDataSet2412.size());
225 UNV2412::Write(out_stream,aDataSet2412);
228 using namespace UNV2417;
229 TDataSet aDataSet2417;
230 for ( TGroupsMap::iterator it = myGroupsMap.begin(); it != myGroupsMap.end(); it++ ) {
231 SMESH_Group* aGroup = it->second;
232 SMESHDS_GroupBase* aGroupDS = aGroup->GetGroupDS();
235 aRec.GroupName = aGroup->GetName();
237 SMDS_ElemIteratorPtr aIter = aGroupDS->GetElements();
238 if (aGroupDS->GetType() == SMDSAbs_Node) {
239 aRec.NodeList.resize(aGroupDS->Extent());
241 while (aIter->more()) {
242 const SMDS_MeshElement* aElem = aIter->next();
243 aRec.NodeList[i] = aElem->GetID();
247 aRec.ElementList.resize(aGroupDS->Extent());
249 while (aIter->more()) {
250 const SMDS_MeshElement* aElem = aIter->next();
251 aRec.ElementList[i] = aElem->GetID();
255 aDataSet2417.insert(TDataSet::value_type(aGroupDS->GetID(), aRec));
258 UNV2417::Write(out_stream,aDataSet2417);
261 catch(const std::exception& exc){
262 INFOS("Follow exception was cought:\n\t"<<exc.what());
265 INFOS("Unknown exception was cought !!!");