Salome HOME
Remove Opencascade dependencies
[modules/smesh.git] / src / SMDS / SMDS_MeshNode.cxx
1 //  SMESH SMDS : implementaion of Salome mesh data structure
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   : SMDS_MeshNode.cxx
25 //  Author : Jean-Michel BOULCOURT
26 //  Module : SMESH
27
28 using namespace std;
29 #include "SMDS_MeshNode.ixx"
30 #include "SMDS_ListIteratorOfListOfMeshElement.hxx"
31 #include "SMDS_SpacePosition.hxx"
32
33 static Handle(SMDS_Position)& StaticInstancePosition()
34 {
35   static Handle(SMDS_SpacePosition) staticpos;
36   if (staticpos.IsNull())
37     staticpos = new SMDS_SpacePosition();
38
39   return staticpos;
40 }
41
42 //=======================================================================
43 //function : SMDS_MeshNode
44 //purpose  : 
45 //=======================================================================
46
47 SMDS_MeshNode::SMDS_MeshNode(const Standard_Integer ID,
48                              const Standard_Real x, const Standard_Real y, const Standard_Real z) :
49   SMDS_MeshElement(ID,1,SMDSAbs_Node),myPnt(x,y,z),myPosition(StaticInstancePosition())
50 {
51 }
52
53
54 //=======================================================================
55 //function : RemoveInverseElement
56 //purpose  : 
57 //=======================================================================
58
59 void SMDS_MeshNode::RemoveInverseElement(const Handle(SMDS_MeshElement)& parent)
60 {
61
62   SMDS_ListIteratorOfListOfMeshElement itLstInvCnx(myInverseElements);
63
64   for (;itLstInvCnx.More();itLstInvCnx.Next()) {
65     Handle(SMDS_MeshElement)& ME = itLstInvCnx.Value();
66     if (ME->IsSame(parent))
67       myInverseElements.Remove(itLstInvCnx);
68     if (!itLstInvCnx.More())
69       break;
70   }
71 }
72
73
74 //=======================================================================
75 //function : Print
76 //purpose  : 
77 //=======================================================================
78
79 void SMDS_MeshNode::Print(Standard_OStream& OS) const
80 {
81   OS << "Node <" << myID << "> : X = " << myPnt.X() << " Y = " << myPnt.Y() << " Z = " << myPnt.Z() << endl;
82 }
83
84
85 //=======================================================================
86 //function : SetPosition
87 //purpose  : 
88 //=======================================================================
89
90 void SMDS_MeshNode::SetPosition(const Handle(SMDS_Position)& aPos)
91 {
92   myPosition = aPos;
93 }
94
95 //=======================================================================
96 //function : GetPosition
97 //purpose  : 
98 //=======================================================================
99
100 Handle(SMDS_Position) SMDS_MeshNode::GetPosition() const
101 {
102   return myPosition;
103 }
104