Salome HOME
Merge with version on tag OCC-V2_1_0d
[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 : 
153 //purpose  : 
154 //=======================================================================
155 void SMESHDS_Script::MoveNode(int NewNodeID, double x, double y, double z)
156 {
157   getCommand(SMESHDS_MoveNode)->MoveNode(NewNodeID, x, y, z);
158 }
159
160 //=======================================================================
161 //function : 
162 //purpose  : 
163 //=======================================================================
164 void SMESHDS_Script::RemoveNode(int ID)
165 {
166   getCommand(SMESHDS_RemoveNode)->RemoveNode(ID);
167 }
168
169 //=======================================================================
170 //function : 
171 //purpose  : 
172 //=======================================================================
173 void SMESHDS_Script::RemoveElement(int ElementID)
174 {
175   getCommand(SMESHDS_RemoveElement)->RemoveElement(ElementID);
176 }
177
178 //=======================================================================
179 //function : ChangeElementNodes
180 //purpose  : 
181 //=======================================================================
182
183 void SMESHDS_Script::ChangeElementNodes(int ElementID, int nodes[], int nbnodes)
184 {
185   getCommand(SMESHDS_ChangeElementNodes)->ChangeElementNodes( ElementID, nodes, nbnodes );
186 }
187
188 //=======================================================================
189 //function : Renumber
190 //purpose  : 
191 //=======================================================================
192
193 void SMESHDS_Script::Renumber (const bool isNodes, const int startID, const int deltaID)
194 {
195   getCommand(SMESHDS_Renumber)->Renumber( isNodes, startID, deltaID );
196 }
197
198 //=======================================================================
199 //function : 
200 //purpose  : 
201 //=======================================================================
202 void SMESHDS_Script::Clear()
203 {
204         myCommands.clear();
205 }
206
207 //=======================================================================
208 //function : 
209 //purpose  : 
210 //=======================================================================
211 const list<SMESHDS_Command*>& SMESHDS_Script::GetCommands()
212 {
213         return myCommands;
214 }