00001
00002
00008 #if !defined(__geom_mesh_simplicial_Node_VertSelf_h__)
00009 #define __geom_mesh_simplicial_Node_VertSelf_h__
00010
00011 #if defined(DEBUG_geom) && !defined(DEBUG_Node_VertSelf)
00012 #define DEBUG_Node_VertSelf
00013 #endif
00014
00015 #include "../../defs.h"
00016
00017 #include "../../../ads/array/FixedArray.h"
00018
00019 BEGIN_NAMESPACE_GEOM
00020
00022
00026 template <class Mesh>
00027 class Node_VertSelf
00028 {
00029
00030
00031
00032
00033 public:
00034
00036 enum { N = Mesh::N };
00037
00038
00039
00040
00041
00042 public:
00043
00045 typedef Mesh mesh_type;
00046
00048 typedef typename mesh_type::node_iterator node_iterator;
00050 typedef typename mesh_type::node_const_iterator node_const_iterator;
00051
00053 typedef typename mesh_type::number_type number_type;
00055 typedef ads::FixedArray<N,number_type> vertex_type;
00056
00057
00058
00059
00060
00061 private:
00062
00064 vertex_type _vertex;
00066 node_iterator _self;
00067
00068 public:
00069
00070
00073
00075 Node_VertSelf() :
00076 _vertex(),
00077 _self( 0 )
00078 {}
00079
00081 Node_VertSelf( const vertex_type& vertex, const node_iterator self = 0 ) :
00082 _vertex( vertex ),
00083 _self( self )
00084 {}
00085
00087 void
00088 build( const vertex_type& vertex, const node_iterator self = 0 )
00089 {
00090 _vertex = vertex;
00091 _self = self;
00092 }
00093
00095 Node_VertSelf( const Node_VertSelf& x ) :
00096 _vertex( x._vertex ),
00097 _self( x._self )
00098 {}
00099
00101 ~Node_VertSelf()
00102 {}
00103
00105
00108
00110 Node_VertSelf&
00111 operator=( const Node_VertSelf& x )
00112 {
00113 if ( &x != this ) {
00114 _vertex = x._vertex;
00115 _self = x._self;
00116 }
00117 return *this;
00118 }
00119
00121
00124
00126 const vertex_type&
00127 vertex() const
00128 {
00129 return _vertex;
00130 }
00131
00133 node_const_iterator
00134 self() const
00135 {
00136 return _self;
00137 }
00138
00140
00148 int
00149 identifier( const node_const_iterator nodes_begin ) const
00150 {
00151 if ( _self == 0 ) {
00152 return -1;
00153 }
00154 return std::distance( nodes_begin, node_const_iterator( _self ) );
00155 }
00156
00158
00161
00163 node_iterator
00164 self()
00165 {
00166 return _self;
00167 }
00168
00170 void
00171 set_vertex( const vertex_type& vertex )
00172 {
00173 _vertex = vertex;
00174 }
00175
00177 void
00178 set_self( const node_iterator self )
00179 {
00180 _self = self;
00181 }
00182
00184
00187
00189 bool
00190 operator==( const Node_VertSelf& x ) const
00191 {
00192 return _self == x._self && _vertex == x._vertex;
00193 }
00194
00196 bool
00197 operator!=( const Node_VertSelf& x ) const
00198 {
00199 return ! operator==( x );
00200 }
00201
00203
00206
00208
00212 void
00213 put( std::ostream& out, const node_const_iterator nodes_begin ) const
00214 {
00215 out << _vertex << " " << identifier( nodes_begin );
00216 }
00217
00219 };
00220
00221 END_NAMESPACE_GEOM
00222
00223 #endif