SheafSystem  0.0.0.0
unary_index_space.cc
1 
2 //
3 // Copyright (c) 2014 Limit Point Systems, Inc.
4 //
5 // Licensed under the Apache License, Version 2.0 (the "License");
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
8 //
9 // http://www.apache.org/licenses/LICENSE-2.0
10 //
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an "AS IS" BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
16 //
17 
18 // Implementation for class unary_index_space
19 
20 #include "SheafSystem/unary_index_space.h"
21 #include "SheafSystem/assert_contract.h"
22 
23 using namespace fiber_bundle; // Workaround for MS C++ bug.
24 
25 // ===========================================================
26 // UNARY_INDEX_SPACE FACET
27 // ===========================================================
28 
33 {
34  // Preconditions:
35 
36  // Body:
37 
38  // Create the block neighborhoods.
39 
40  unary_index lblock_id, lnbr_id;
42 
43  for(lblock_id=0; lblock_id<i_size; lblock_id++)
44  {
45  // Make a list of the members in the neighborhood of
46  // the current member, including the current member itself.
47 
48  unary_index ldelta;
49  for(ldelta=-1; ldelta<2; ldelta++)
50  {
51  lnbr_id = lblock_id + ldelta;
52  if(contains(lnbr_id))
53  {
54  result->push_back(lnbr_id);
55  }
56  }
57 
58  if(result->row_ct() < size)
59  {
60  // Move the the next row.
61 
62  result->new_back_row();
63  }
64  }
65 
66  // Postconditions:
67 
68  ensure(result != 0);
69  ensure(result->row_ct() == size);
70 
71  // Exit:
72 
73  return result;
74 }
75 
76 
77 // ===========================================================
78 // NON-MEMBER FUNCTIONS
79 // ===========================================================
80 
81 std::ostream&
83 operator<<(std::ostream& os, const fiber_bundle::unary_index_space& xbis)
84 {
85  os << "i_size: " << xbis.i_size
86  << " size: " << xbis.size;
87  return os;
88 }
89 
90 
ragged_array< unary_index > * neighbor_list() const
Create a ragged array containing the row major offsets of the neighbors of each index in the index sp...
unary_index i_size
Upper bound for the i index.
void push_back(const T &xvalue)
Add a value to the back of the back row.
index_type row_ct() const
The number of rows.
A bounded domain for unary_index objects.
unary_index size
Number in the space.
void new_back_row()
Creates a new last row.
A two index array with variable length rows.
Namespace for the fiber_bundles component of the sheaf system.
SHEAF_DLL_SPEC std::ostream & operator<<(std::ostream &os, const binary_index &xbi)
Insert binary_index& xbi into ostream& os.
Definition: binary_index.cc:35