1 // SMESH SMESHDS : management of mesh data and SMESH document
3 // Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
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.
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.
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
20 // See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
24 // File : SMESH_Script.cxx
25 // Author : Yves FRICAUD, OCC
29 #include "SMESHDS_Script.hxx"
33 //=======================================================================
34 //function : getCommand
36 //=======================================================================
37 SMESHDS_Command* SMESHDS_Script::getCommand(const SMESHDS_CommandType aType)
40 if (myCommands.empty())
42 com = new SMESHDS_Command(aType);
43 myCommands.insert(myCommands.end(),com);
47 com = myCommands.back();
48 if (com->GetType() != aType)
50 com = new SMESHDS_Command(aType);
51 myCommands.insert(myCommands.end(),com);
57 //=======================================================================
60 //=======================================================================
61 void SMESHDS_Script::AddNode(int NewNodeID, double x, double y, double z)
63 getCommand(SMESHDS_AddNode)->AddNode(NewNodeID, x, y, z);
66 //=======================================================================
69 //=======================================================================
70 void SMESHDS_Script::AddEdge(int NewEdgeID, int idnode1, int idnode2)
72 getCommand(SMESHDS_AddEdge)->AddEdge(NewEdgeID, idnode1, idnode2);
75 //=======================================================================
78 //=======================================================================
79 void SMESHDS_Script::AddFace(int NewFaceID,
80 int idnode1, int idnode2, int idnode3)
82 getCommand(SMESHDS_AddTriangle)->AddFace(NewFaceID,
83 idnode1, idnode2, idnode3);
86 //=======================================================================
89 //=======================================================================
90 void SMESHDS_Script::AddFace(int NewFaceID,
91 int idnode1, int idnode2,
92 int idnode3, int idnode4)
94 getCommand(SMESHDS_AddQuadrangle)->AddFace(NewFaceID,
99 //=======================================================================
102 //=======================================================================
103 void SMESHDS_Script::AddVolume(int NewID,
104 int idnode1, int idnode2,
105 int idnode3, int idnode4)
107 getCommand(SMESHDS_AddTetrahedron)->AddVolume(NewID,
112 //=======================================================================
115 //=======================================================================
116 void SMESHDS_Script::AddVolume(int NewID,
117 int idnode1, int idnode2,
118 int idnode3, int idnode4, int idnode5)
120 getCommand(SMESHDS_AddPyramid)->AddVolume(NewID,
122 idnode3, idnode4, idnode5);
125 //=======================================================================
128 //=======================================================================
129 void SMESHDS_Script::AddVolume(int NewID,
130 int idnode1, int idnode2, int idnode3,
131 int idnode4, int idnode5, int idnode6)
133 getCommand(SMESHDS_AddPrism)->AddVolume(NewID,
134 idnode1, idnode2, idnode3,
135 idnode4, idnode5, idnode6);
138 //=======================================================================
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)
146 getCommand(SMESHDS_AddHexahedron)->AddVolume(NewID,
147 idnode1, idnode2, idnode3, idnode4,
148 idnode5, idnode6, idnode7, idnode8);
151 //=======================================================================
152 //function : AddPolygonalFace
154 //=======================================================================
155 void SMESHDS_Script::AddPolygonalFace (int NewFaceID, std::vector<int> nodes_ids)
157 getCommand(SMESHDS_AddPolygon)->AddPolygonalFace(NewFaceID, nodes_ids);
160 //=======================================================================
161 //function : AddPolyhedralVolume
163 //=======================================================================
164 void SMESHDS_Script::AddPolyhedralVolume (int NewID,
165 std::vector<int> nodes_ids,
166 std::vector<int> quantities)
168 getCommand(SMESHDS_AddPolyhedron)->AddPolyhedralVolume
169 (NewID, nodes_ids, quantities);
172 //=======================================================================
175 //=======================================================================
176 void SMESHDS_Script::MoveNode(int NewNodeID, double x, double y, double z)
178 getCommand(SMESHDS_MoveNode)->MoveNode(NewNodeID, x, y, z);
181 //=======================================================================
184 //=======================================================================
185 void SMESHDS_Script::RemoveNode(int ID)
187 getCommand(SMESHDS_RemoveNode)->RemoveNode(ID);
190 //=======================================================================
193 //=======================================================================
194 void SMESHDS_Script::RemoveElement(int ElementID)
196 getCommand(SMESHDS_RemoveElement)->RemoveElement(ElementID);
199 //=======================================================================
200 //function : ChangeElementNodes
202 //=======================================================================
204 void SMESHDS_Script::ChangeElementNodes(int ElementID, int nodes[], int nbnodes)
206 getCommand(SMESHDS_ChangeElementNodes)->ChangeElementNodes( ElementID, nodes, nbnodes );
209 //=======================================================================
210 //function : ChangePolyhedronNodes
212 //=======================================================================
213 void SMESHDS_Script::ChangePolyhedronNodes (const int ElementID,
214 std::vector<int> nodes_ids,
215 std::vector<int> quantities)
217 getCommand(SMESHDS_ChangePolyhedronNodes)->ChangePolyhedronNodes
218 (ElementID, nodes_ids, quantities);
221 //=======================================================================
222 //function : Renumber
224 //=======================================================================
226 void SMESHDS_Script::Renumber (const bool isNodes, const int startID, const int deltaID)
228 getCommand(SMESHDS_Renumber)->Renumber( isNodes, startID, deltaID );
231 //=======================================================================
234 //=======================================================================
235 void SMESHDS_Script::Clear()
240 //=======================================================================
243 //=======================================================================
244 const list<SMESHDS_Command*>& SMESHDS_Script::GetCommands()