Salome HOME
Copyright update 2020
[modules/smesh.git] / src / SMDS / SMDS_LinearEdge.cxx
1 // Copyright (C) 2007-2020  CEA/DEN, EDF R&D, OPEN CASCADE
2 //
3 // Copyright (C) 2003-2007  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, or (at your option) any later version.
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.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 //
22 //  File   : SMDS_LinearEdge.cxx
23 //  Author : Jean-Michel BOULCOURT
24 //  Module : SMESH
25 //
26 #ifdef _MSC_VER
27 #pragma warning(disable:4786)
28 #endif
29
30 #include "SMDS_LinearEdge.hxx"
31 #include "SMDS_MeshNode.hxx"
32 #include "SMDS_SetIterator.hxx"
33
34 #include <boost/make_shared.hpp>
35
36 //=======================================================================
37 //function : SMDS_LinearEdge
38 //purpose  : 
39 //=======================================================================
40
41 SMDS_LinearEdge::SMDS_LinearEdge(const SMDS_MeshNode * node1,
42                                  const SMDS_MeshNode * node2)
43 {
44   myNodes[0] = node1;
45   myNodes[1] = node2;
46 }
47
48 int SMDS_LinearEdge::NbNodes() const
49 {
50   return 2;
51 }
52
53 int SMDS_LinearEdge::NbEdges() const
54 {
55   return 1;
56 }
57
58 int SMDS_LinearEdge::NbFaces() const
59 {
60   return 0;
61 }
62
63 int SMDS_LinearEdge::GetNodeIndex( const SMDS_MeshNode* node ) const
64 {
65   if ( node == myNodes[0] ) return 0;
66   if ( node == myNodes[1] ) return 1;
67   return -1;
68 }
69
70 SMDS_ElemIteratorPtr SMDS_LinearEdge::nodesIterator() const
71 {
72   return boost::make_shared< SMDS_NodeArrayElemIterator >( &myNodes[0], &myNodes[0] + NbNodes() );
73 }
74
75 SMDS_NodeIteratorPtr SMDS_LinearEdge::nodeIterator() const
76 {
77   return boost::make_shared< SMDS_NodeArrayIterator >( &myNodes[0], &myNodes[0] + NbNodes() );
78 }
79
80 /*
81  * \brief Return node by its index
82  * \param ind - node index
83  * \retval const SMDS_MeshNode* - the node
84  */
85 const SMDS_MeshNode* SMDS_LinearEdge::GetNode(const int ind) const
86 {
87   return myNodes[ind];
88 }
89
90 //=======================================================================
91 //function : ChangeNodes
92 //purpose  : 
93 //=======================================================================
94
95 bool SMDS_LinearEdge::ChangeNodes(const SMDS_MeshNode* nodes[], const int nbNodes)
96 {
97   myNodes[0] = nodes[0];
98   myNodes[1] = nodes[1];
99   return nbNodes == 2;
100 }