Salome HOME
yfr : Merge with v1.2
[modules/smesh.git] / src / SMDS / SMDS_MeshNode.cxx
1 using namespace std;
2 // File:        SMDS_MeshNode.cxx
3 // Created:     Wed Jan 23 17:02:11 2002
4 // Author:      Jean-Michel BOULCOURT
5 //              <jmb@coulox.paris1.matra-dtv.fr>
6
7
8 #include "SMDS_MeshNode.ixx"
9 #include "SMDS_ListIteratorOfListOfMeshElement.hxx"
10 #include "SMDS_SpacePosition.hxx"
11
12 static Handle(SMDS_Position)& StaticInstancePosition()
13 {
14   static Handle(SMDS_SpacePosition) staticpos;
15   if (staticpos.IsNull())
16     staticpos = new SMDS_SpacePosition();
17
18   return staticpos;
19 }
20
21 //=======================================================================
22 //function : SMDS_MeshNode
23 //purpose  : 
24 //=======================================================================
25
26 SMDS_MeshNode::SMDS_MeshNode(const Standard_Integer ID,
27                              const Standard_Real x, const Standard_Real y, const Standard_Real z) :
28   SMDS_MeshElement(ID,1,SMDSAbs_Node),myPnt(x,y,z),myPosition(StaticInstancePosition())
29 {
30 }
31
32
33 //=======================================================================
34 //function : RemoveInverseElement
35 //purpose  : 
36 //=======================================================================
37
38 void SMDS_MeshNode::RemoveInverseElement(const Handle(SMDS_MeshElement)& parent)
39 {
40
41   SMDS_ListIteratorOfListOfMeshElement itLstInvCnx(myInverseElements);
42
43   for (;itLstInvCnx.More();itLstInvCnx.Next()) {
44     Handle(SMDS_MeshElement)& ME = itLstInvCnx.Value();
45     if (ME->IsSame(parent))
46       myInverseElements.Remove(itLstInvCnx);
47     if (!itLstInvCnx.More())
48       break;
49   }
50 }
51
52
53 //=======================================================================
54 //function : Print
55 //purpose  : 
56 //=======================================================================
57
58 void SMDS_MeshNode::Print(Standard_OStream& OS) const
59 {
60   OS << "Node <" << myID << "> : X = " << myPnt.X() << " Y = " << myPnt.Y() << " Z = " << myPnt.Z() << endl;
61 }
62
63
64 //=======================================================================
65 //function : SetPosition
66 //purpose  : 
67 //=======================================================================
68
69 void SMDS_MeshNode::SetPosition(const Handle(SMDS_Position)& aPos)
70 {
71   myPosition = aPos;
72 }
73
74 //=======================================================================
75 //function : GetPosition
76 //purpose  : 
77 //=======================================================================
78
79 Handle(SMDS_Position) SMDS_MeshNode::GetPosition() const
80 {
81   return myPosition;
82 }
83