Salome HOME
Better error handling for parallel mesh
[modules/smesh.git] / src / SMDS / SMDS_LinearEdge.cxx
1 // Copyright (C) 2007-2023  CEA, EDF, 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 void SMDS_LinearEdge::Init(const SMDS_MeshNode * node1,
49                            const SMDS_MeshNode * node2)
50 {
51   myNodes[0] = node1;
52   myNodes[1] = node2;
53 }
54
55 int SMDS_LinearEdge::NbNodes() const
56 {
57   return 2;
58 }
59
60 int SMDS_LinearEdge::NbEdges() const
61 {
62   return 1;
63 }
64
65 int SMDS_LinearEdge::NbFaces() const
66 {
67   return 0;
68 }
69
70 int SMDS_LinearEdge::GetNodeIndex( const SMDS_MeshNode* node ) const
71 {
72   if ( node == myNodes[0] ) return 0;
73   if ( node == myNodes[1] ) return 1;
74   return -1;
75 }
76
77 SMDS_ElemIteratorPtr SMDS_LinearEdge::nodesIterator() const
78 {
79   return boost::make_shared< SMDS_NodeArrayElemIterator >( &myNodes[0], &myNodes[0] + NbNodes() );
80 }
81
82 SMDS_NodeIteratorPtr SMDS_LinearEdge::nodeIterator() const
83 {
84   return boost::make_shared< SMDS_NodeArrayIterator >( &myNodes[0], &myNodes[0] + NbNodes() );
85 }
86
87 /*
88  * \brief Return node by its index
89  * \param ind - node index
90  * \retval const SMDS_MeshNode* - the node
91  */
92 const SMDS_MeshNode* SMDS_LinearEdge::GetNode(const int ind) const
93 {
94   return myNodes[ind];
95 }
96
97 //=======================================================================
98 //function : ChangeNodes
99 //purpose  : 
100 //=======================================================================
101
102 bool SMDS_LinearEdge::ChangeNodes(const SMDS_MeshNode* nodes[], const int nbNodes)
103 {
104   myNodes[0] = nodes[0];
105   myNodes[1] = nodes[1];
106   return nbNodes == 2;
107 }