Salome HOME
Adjust to CVS HEAD modifications
[modules/smesh.git] / src / SMESHDS / SMESHDS_Script.cxx
1 //  SMESH SMESHDS : management of mesh data and SMESH document
2 //
3 //  Copyright (C) 2003  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 //  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS 
5 // 
6 //  This library is free software; you can redistribute it and/or 
7 //  modify it under the terms of the GNU Lesser General Public 
8 //  License as published by the Free Software Foundation; either 
9 //  version 2.1 of the License. 
10 // 
11 //  This library is distributed in the hope that it will be useful, 
12 //  but WITHOUT ANY WARRANTY; without even the implied warranty of 
13 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
14 //  Lesser General Public License for more details. 
15 // 
16 //  You should have received a copy of the GNU Lesser General Public 
17 //  License along with this library; if not, write to the Free Software 
18 //  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA 
19 // 
20 //  See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org 
21 //
22 //
23 //
24 //  File   : SMESH_Script.cxx
25 //  Author : Yves FRICAUD, OCC
26 //  Module : SMESH
27 //  $Header: 
28
29 #include "SMESHDS_Script.hxx"
30
31 using namespace std;
32
33 //=======================================================================
34 //function : getCommand
35 //purpose  : 
36 //=======================================================================
37 SMESHDS_Command* SMESHDS_Script::getCommand(const SMESHDS_CommandType aType)
38 {
39   SMESHDS_Command* com;
40   if (myCommands.empty())
41   {
42     com = new SMESHDS_Command(aType);
43     myCommands.insert(myCommands.end(),com);
44   }
45   else
46   {
47     com = myCommands.back();
48     if (com->GetType() != aType)
49     {
50       com = new SMESHDS_Command(aType);
51       myCommands.insert(myCommands.end(),com);
52     }
53   }
54   return com;
55 }
56
57 //=======================================================================
58 //function : 
59 //purpose  : 
60 //=======================================================================
61 void SMESHDS_Script::AddNode(int NewNodeID, double x, double y, double z)
62 {
63   getCommand(SMESHDS_AddNode)->AddNode(NewNodeID, x, y, z);
64 }
65
66 //=======================================================================
67 //function : 
68 //purpose  : 
69 //=======================================================================
70 void SMESHDS_Script::AddEdge(int NewEdgeID, int idnode1, int idnode2)
71 {
72   getCommand(SMESHDS_AddEdge)->AddEdge(NewEdgeID, idnode1, idnode2);
73 }
74
75 //=======================================================================
76 //function : 
77 //purpose  : 
78 //=======================================================================
79 void SMESHDS_Script::AddFace(int NewFaceID,
80                              int idnode1, int idnode2, int idnode3)
81 {
82   getCommand(SMESHDS_AddTriangle)->AddFace(NewFaceID,
83                                            idnode1, idnode2, idnode3);
84 }
85
86 //=======================================================================
87 //function : 
88 //purpose  : 
89 //=======================================================================
90 void SMESHDS_Script::AddFace(int NewFaceID,
91                              int idnode1, int idnode2,
92                              int idnode3, int idnode4)
93 {
94   getCommand(SMESHDS_AddQuadrangle)->AddFace(NewFaceID,
95                                              idnode1, idnode2,
96                                              idnode3, idnode4);
97 }
98
99 //=======================================================================
100 //function : 
101 //purpose  : 
102 //=======================================================================
103 void SMESHDS_Script::AddVolume(int NewID,
104                                int idnode1, int idnode2,
105                                int idnode3, int idnode4)
106 {
107   getCommand(SMESHDS_AddTetrahedron)->AddVolume(NewID,
108                                                 idnode1, idnode2,
109                                                 idnode3, idnode4);
110 }
111
112 //=======================================================================
113 //function : 
114 //purpose  : 
115 //=======================================================================
116 void SMESHDS_Script::AddVolume(int NewID,
117                                int idnode1, int idnode2,
118                                int idnode3, int idnode4, int idnode5)
119 {
120   getCommand(SMESHDS_AddPyramid)->AddVolume(NewID,
121                                             idnode1, idnode2,
122                                             idnode3, idnode4, idnode5);
123 }
124
125 //=======================================================================
126 //function : 
127 //purpose  : 
128 //=======================================================================
129 void SMESHDS_Script::AddVolume(int NewID,
130                                int idnode1, int idnode2, int idnode3,
131                                int idnode4, int idnode5, int idnode6)
132 {
133   getCommand(SMESHDS_AddPrism)->AddVolume(NewID,
134                                           idnode1, idnode2, idnode3,
135                                           idnode4, idnode5, idnode6);
136 }
137
138 //=======================================================================
139 //function : 
140 //purpose  : 
141 //=======================================================================
142 void SMESHDS_Script::AddVolume(int NewID,
143                                int idnode1, int idnode2, int idnode3, int idnode4,
144                                int idnode5, int idnode6, int idnode7, int idnode8)
145 {
146   getCommand(SMESHDS_AddHexahedron)->AddVolume(NewID,
147                                                idnode1, idnode2, idnode3, idnode4,
148                                                idnode5, idnode6, idnode7, idnode8);
149 }
150
151 //=======================================================================
152 //function : AddPolygonalFace
153 //purpose  : 
154 //=======================================================================
155 void SMESHDS_Script::AddPolygonalFace (int NewFaceID, std::vector<int> nodes_ids)
156 {
157   getCommand(SMESHDS_AddPolygon)->AddPolygonalFace(NewFaceID, nodes_ids);
158 }
159
160 //=======================================================================
161 //function : AddPolyhedralVolume
162 //purpose  : 
163 //=======================================================================
164 void SMESHDS_Script::AddPolyhedralVolume (int NewID,
165                                           std::vector<int> nodes_ids,
166                                           std::vector<int> quantities)
167 {
168   getCommand(SMESHDS_AddPolyhedron)->AddPolyhedralVolume
169     (NewID, nodes_ids, quantities);
170 }
171
172 //=======================================================================
173 //function : 
174 //purpose  : 
175 //=======================================================================
176 void SMESHDS_Script::MoveNode(int NewNodeID, double x, double y, double z)
177 {
178   getCommand(SMESHDS_MoveNode)->MoveNode(NewNodeID, x, y, z);
179 }
180
181 //=======================================================================
182 //function : 
183 //purpose  : 
184 //=======================================================================
185 void SMESHDS_Script::RemoveNode(int ID)
186 {
187   getCommand(SMESHDS_RemoveNode)->RemoveNode(ID);
188 }
189
190 //=======================================================================
191 //function : 
192 //purpose  : 
193 //=======================================================================
194 void SMESHDS_Script::RemoveElement(int ElementID)
195 {
196   getCommand(SMESHDS_RemoveElement)->RemoveElement(ElementID);
197 }
198
199 //=======================================================================
200 //function : ChangeElementNodes
201 //purpose  : 
202 //=======================================================================
203
204 void SMESHDS_Script::ChangeElementNodes(int ElementID, int nodes[], int nbnodes)
205 {
206   getCommand(SMESHDS_ChangeElementNodes)->ChangeElementNodes( ElementID, nodes, nbnodes );
207 }
208
209 //=======================================================================
210 //function : ChangePolyhedronNodes
211 //purpose  : 
212 //=======================================================================
213 void SMESHDS_Script::ChangePolyhedronNodes (const int        ElementID,
214                                             std::vector<int> nodes_ids,
215                                             std::vector<int> quantities)
216 {
217   getCommand(SMESHDS_ChangePolyhedronNodes)->ChangePolyhedronNodes
218     (ElementID, nodes_ids, quantities);
219 }
220
221 //=======================================================================
222 //function : Renumber
223 //purpose  : 
224 //=======================================================================
225
226 void SMESHDS_Script::Renumber (const bool isNodes, const int startID, const int deltaID)
227 {
228   getCommand(SMESHDS_Renumber)->Renumber( isNodes, startID, deltaID );
229 }
230
231 //=======================================================================
232 //function : 
233 //purpose  : 
234 //=======================================================================
235 void SMESHDS_Script::Clear()
236 {
237         myCommands.clear();
238 }
239
240 //=======================================================================
241 //function : 
242 //purpose  : 
243 //=======================================================================
244 const list<SMESHDS_Command*>& SMESHDS_Script::GetCommands()
245 {
246         return myCommands;
247 }