00001
00002
00008 #if !defined(__geom_mesh_simplicial_Node_AllIncCells_h__)
00009 #define __geom_mesh_simplicial_Node_AllIncCells_h__
00010
00011 #if defined(DEBUG_geom) && !defined(DEBUG_Node_AllIncCells)
00012 #define DEBUG_Node_AllIncCells
00013 #endif
00014
00015 #ifdef DEBUG_Node_AllIncCells
00016 #ifndef DEBUG_Node_VertSelfId
00017
00018 #define DEBUG_Node_VertSelfId
00019 #endif
00020 #endif
00021
00022 #include "Node_VertSelfId.h"
00023
00024 #include "../../../ads/iterator/IndirectIterator.h"
00025
00026 #include <vector>
00027
00028 BEGIN_NAMESPACE_GEOM
00029
00031
00037 template <class Mesh>
00038 class Node_AllIncCells :
00039 public Node_VertSelfId<Mesh>
00040 {
00041
00042
00043
00044
00045 private:
00046
00047 typedef Node_VertSelfId<Mesh> base_type;
00048
00049
00050
00051
00052
00053 public:
00054
00056 enum { N = base_type::N };
00057
00058
00059
00060
00061
00062 public:
00063
00065 typedef Mesh mesh_type;
00066
00068 typedef typename mesh_type::cell_iterator cell_iterator;
00070 typedef typename mesh_type::cell_const_iterator cell_const_iterator;
00071
00073 typedef typename base_type::node_iterator node_iterator;
00075 typedef typename base_type::node_const_iterator node_const_iterator;
00076
00078 typedef typename base_type::number_type number_type;
00080 typedef typename base_type::vertex_type vertex_type;
00081
00082
00083
00084
00085
00086 private:
00087
00089 typedef std::vector<cell_iterator> cell_iterator_container;
00090
00091
00092
00093
00094
00095 public:
00096
00098 typedef typename cell_iterator_container::iterator cell_iter_iterator;
00100 typedef typename cell_iterator_container::const_iterator
00101 cell_iter_const_iterator;
00102
00104 typedef ads::IndirectIterator<typename cell_iterator_container::iterator>
00105 cell_inc_to_node_iterator;
00107 typedef ads::IndirectIterator<typename
00108 cell_iterator_container::const_iterator>
00109 cell_inc_to_node_const_iterator;
00110
00111
00112
00113
00114
00115 private:
00116
00118 cell_iterator_container _cells;
00119
00120 public:
00121
00122
00125
00127 Node_AllIncCells() :
00128 base_type(),
00129 _cells()
00130 {}
00131
00133 Node_AllIncCells( const vertex_type& vertex, const int identifier = -1 ) :
00134 base_type( vertex, identifier ),
00135 _cells()
00136 {}
00137
00139 void
00140 build( const vertex_type& vertex, const int identifier = -1,
00141 const node_iterator self = 0 )
00142 {
00143 base_type::build( vertex, identifier, self );
00144 _cells.clear();
00145 }
00146
00147 #if 0
00148
00149 Node_AllIncCells( const vertex_type& vertex, const int identifier = -1,
00150 const cell_iterator cell = 0 ) :
00151 base_type( point, identifier ),
00152 _cells()
00153 {
00154 if ( cell != 0 ) {
00155 add_cell( cell );
00156 }
00157 }
00158
00160 void
00161 build( const vertex_type& point, const int identifier = -1,
00162 const cell_iterator cell = 0 )
00163 {
00164 base_type::build( point, identifier );
00165 _cells.clear();
00166 if ( cell != 0 ) {
00167 add_cell( cell );
00168 }
00169 }
00170 #endif
00171
00173 Node_AllIncCells( const Node_AllIncCells& x ) :
00174 base_type( x ),
00175 _cells( x._cells )
00176 {}
00177
00179 ~Node_AllIncCells()
00180 {}
00181
00183
00186
00188 Node_AllIncCells&
00189 operator=( const Node_AllIncCells& x )
00190 {
00191 if ( &x != this ) {
00192 base_type::operator=( x );
00193 _cells = x._cells;
00194 }
00195 return *this;
00196 }
00197
00199
00202
00204 const vertex_type&
00205 vertex() const
00206 {
00207 return base_type::vertex();
00208 }
00209
00211
00215 int
00216 identifier() const
00217 {
00218 return base_type::identifier();
00219 }
00220
00222 node_const_iterator
00223 self() const
00224 {
00225 return base_type::self();
00226 }
00227
00229 cell_const_iterator
00230 cell() const
00231 {
00232
00233 if ( _cells.empty() ) {
00234
00235 return cell_const_iterator( 0 );
00236 }
00237
00238 return _cells.front();
00239 }
00240
00242 int
00243 cells_size() const
00244 {
00245 return int(_cells.size());
00246 }
00247
00249 cell_inc_to_node_const_iterator
00250 cells_begin() const
00251 {
00252 return cell_inc_to_node_const_iterator( _cells.begin() );
00253 }
00254
00256 cell_inc_to_node_const_iterator
00257 cells_end() const
00258 {
00259 return cell_inc_to_node_const_iterator( _cells.end() );
00260 }
00261
00263 cell_iter_const_iterator
00264 cell_iters_begin() const
00265 {
00266 return _cells.begin();
00267 }
00268
00270 cell_iter_const_iterator
00271 cell_iters_end() const
00272 {
00273 return _cells.end();
00274 }
00275
00277
00281 bool
00282 is_on_boundary() const
00283 {
00284
00285 for ( typename cell_iterator_container::const_iterator cii =
00286 _cells.begin();
00287 cii != _cells.end(); ++cii ) {
00288
00289 if ( (*cii)->has_incident_boundary_face( self() ) ) {
00290
00291 return true;
00292 }
00293 }
00294
00295 return false;
00296 }
00297
00298
00300
00303
00305 void
00306 set_vertex( const vertex_type& vertex )
00307 {
00308 base_type::set_vertex( vertex );
00309 }
00310
00312
00316 void
00317 set_identifier( const int identifier ) const
00318 {
00319 base_type::set_identifier( identifier );
00320 }
00321
00323 node_iterator
00324 self()
00325 {
00326 return base_type::self();
00327 }
00328
00330 void
00331 set_self( const node_iterator self )
00332 {
00333 base_type::set_self( self );
00334 }
00335
00337 cell_iterator
00338 cell()
00339 {
00340
00341 if ( _cells.empty() ) {
00342
00343 return cell_iterator( 0 );
00344 }
00345
00346 return _cells.front();
00347 }
00348
00349
00351 void
00352 add_cell( const cell_iterator c )
00353 {
00354
00355 #ifdef DEBUG_Node_AllIncCells
00356 assert( c != 0 );
00357 #endif
00358 _cells.push_back( c );
00359 }
00360
00362 template <typename CellIterInIter>
00363 void
00364 add_cells( CellIterInIter begin, CellIterInIter end )
00365 {
00366 for ( ; begin != end; ++begin ) {
00367 add_cell( *begin );
00368 }
00369 }
00370
00372 void
00373 remove_cell( const cell_iterator c )
00374 {
00375
00376 typename cell_iterator_container::iterator i;
00377 i = std::find( _cells.begin(), _cells.end(), c );
00378
00379 assert( i != _cells.end() );
00380
00381 _cells.erase( i );
00382 }
00383
00385 cell_inc_to_node_iterator
00386 cells_begin()
00387 {
00388 return cell_inc_to_node_iterator( _cells.begin() );
00389 }
00390
00392 cell_inc_to_node_iterator
00393 cells_end()
00394 {
00395 return cell_inc_to_node_iterator( _cells.end() );
00396 }
00397
00399 cell_iter_iterator
00400 cell_iters_begin()
00401 {
00402 return _cells.begin();
00403 }
00404
00406 cell_iter_iterator
00407 cell_iters_end()
00408 {
00409 return _cells.end();
00410 }
00411
00413
00416 void
00417 replace( node_iterator x )
00418 {
00419
00420 int vi;
00421
00422 cell_inc_to_node_iterator i = cells_begin();
00423 cell_inc_to_node_iterator i_end = cells_end();
00424 for ( ; i != i_end; ++i ) {
00425
00426 vi = i->index( self() );
00427
00428 i->set_node( vi, x );
00429 }
00430 }
00431
00433
00436
00438 bool
00439 operator==( const Node_AllIncCells& x ) const
00440 {
00441 return base_type::operator==( x ) && _cells == x._cells;
00442 }
00443
00445 bool
00446 operator!=( const Node_AllIncCells& x ) const
00447 {
00448 return ! operator==( x );
00449 }
00450
00452
00455
00457 void
00458 put( std::ostream& out ) const
00459 {
00460
00461 base_type::put( out );
00462
00463 const int i_end = int(_cells.size());
00464
00465 out << " cells = ";
00466 for ( int i = 0; i != i_end; ++i ) {
00467 out << " " << _cells[i]->identifier();
00468 }
00469 out << "\n";
00470 }
00471
00473 };
00474
00475 END_NAMESPACE_GEOM
00476
00477 #endif