Salome HOME
Remove OCC_LIBS from LDFLAGS
[modules/smesh.git] / src / SMDS / SMDSEdit_Transform.cxx
1 //  SMESH SMDS : implementaion of Salome mesh data structure
2 //
3 //  Copyright (C) 2003  OPEN CASCADE
4 // 
5 //  This library is free software; you can redistribute it and/or 
6 //  modify it under the terms of the GNU Lesser General Public 
7 //  License as published by the Free Software Foundation; either 
8 //  version 2.1 of the License. 
9 // 
10 //  This library is distributed in the hope that it will be useful, 
11 //  but WITHOUT ANY WARRANTY; without even the implied warranty of 
12 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
13 //  Lesser General Public License for more details. 
14 // 
15 //  You should have received a copy of the GNU Lesser General Public 
16 //  License along with this library; if not, write to the Free Software 
17 //  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA 
18 // 
19 //  See http://www.opencascade.org or email : webmaster@opencascade.org 
20 //
21 //
22 //
23 //  File   : SMDSEdit_Transform.cxx
24 //  Author : Jean-Michel BOULCOURT
25 //  Module : SMESH
26
27 using namespace std;
28 #include "SMDSEdit_Transform.ixx"
29 #include "SMDS_MeshNode.hxx"
30 #include "SMDS_MeshElement.hxx"
31 #include "SMDS_MeshNodesIterator.hxx"
32 #include "SMDS_ListIteratorOfListOfMeshElement.hxx"
33 #include "TColStd_MapOfInteger.hxx"
34
35
36 //=======================================================================
37 //function : SMDSEdit_Transform
38 //purpose  : 
39 //=======================================================================
40
41 SMDSEdit_Transform::SMDSEdit_Transform(const Handle(SMDS_Mesh)& aMesh,const gp_Trsf& aTrsf)
42   :myMesh(aMesh),myTrsf(aTrsf)
43 {
44 }
45
46 //=======================================================================
47 //function : SMDSEdit_Transform
48 //purpose  : 
49 //=======================================================================
50
51 SMDSEdit_Transform::SMDSEdit_Transform(const Handle(SMDS_Mesh)& aMesh,
52                                        const SMDS_ListOfMeshElement& aListOfME,
53                                        const gp_Trsf& aTrsf)
54   :myMesh(aMesh),myTrsf(aTrsf)
55 {
56   myListOfME = aListOfME;
57 }
58
59 //=======================================================================
60 //function : SetTrsf
61 //purpose  : 
62 //=======================================================================
63
64 void SMDSEdit_Transform::SetTrsf(const gp_Trsf& aTrsf)
65 {
66   myTrsf = aTrsf;
67 }
68
69 //=======================================================================
70 //function : GetTrsf
71 //purpose  : 
72 //=======================================================================
73
74 gp_Trsf SMDSEdit_Transform::GetTrsf() const
75 {
76   return myTrsf;
77 }
78
79 //=======================================================================
80 //function : Perform
81 //purpose  : 
82 //=======================================================================
83
84 void SMDSEdit_Transform::Perform()
85 {
86   if (myListOfME.IsEmpty()) { 
87     // transform the whole mesh
88     SMDS_MeshNodesIterator itNodes(myMesh);
89     
90     for (;itNodes.More();itNodes.Next()) {
91       const Handle(SMDS_MeshElement)& elem = itNodes.Value();
92       Handle(SMDS_MeshNode) node = *((Handle(SMDS_MeshNode)*)&elem);
93       
94       gp_Pnt P = node->Pnt();
95       P.Transform(myTrsf);
96       node->SetPnt(P);
97     }
98     
99   } else {
100     TColStd_MapOfInteger mapnode;
101     Standard_Integer nbnodes,inode;
102
103     SMDS_ListIteratorOfListOfMeshElement itME(myListOfME);
104     for (;itME.More();itME.Next()) {
105       const Handle(SMDS_MeshElement)& elem = itME.Value();
106       nbnodes = elem->NbNodes();
107
108       for (inode = 1; inode <= nbnodes; ++inode) {
109         const Handle(SMDS_MeshNode)& node = myMesh->GetNode(inode,elem);
110         if (mapnode.Add(node->GetID())) {
111           gp_Pnt P = node->Pnt();
112           P.Transform(myTrsf);
113           node->SetPnt(P);
114         }
115       }
116       
117     }
118   }
119 }
120