@@ -48,19 +48,92 @@ namespace geode
4848 {
4949 set_grid_dimensions (
5050 std::move ( cells_number ), std::move ( cells_length ) );
51+ const auto nb_u = grid_.nb_cells_in_direction ( 0 );
52+ const auto nb_v = grid_.nb_cells_in_direction ( 1 );
53+ const auto nb_w = grid_.nb_cells_in_direction ( 2 );
5154 grid_.vertex_attribute_manager ().resize (
52- grid_.nb_vertices_in_direction ( 0 )
53- * grid_.nb_vertices_in_direction ( 1 )
54- * grid_.nb_vertices_in_direction ( 2 ) );
55+ ( nb_u + 1 ) * ( nb_v + 1 ) * ( nb_w + 1 ) );
5556 grid_.polyhedron_attribute_manager ().resize ( grid_.nb_cells () );
56- for ( const auto p : Range{ grid_. nb_polyhedra () } )
57+ for ( const auto w : Range{ nb_w } )
5758 {
58- for ( const auto v : LRange{ 8 } )
59+ for ( const auto v : Range{ nb_v } )
5960 {
60- associate_polyhedron_vertex_to_vertex (
61- { p, v }, grid_.polyhedron_vertex ( { p, v } ) );
61+ for ( const auto u : Range{ nb_u } )
62+ {
63+ const auto cell = u + v * nb_u + w * nb_u * nb_v;
64+ const auto vertex =
65+ u + v * ( nb_u + 1 ) + w * ( nb_u + 1 ) * ( nb_v + 1 );
66+ associate_polyhedron_vertex_to_vertex (
67+ { cell, 0 }, vertex );
68+ }
6269 }
6370 }
71+ // Last Face U
72+ for ( const auto w : Range{ nb_w } )
73+ {
74+ for ( const auto v : Range{ nb_v } )
75+ {
76+ const auto cell = ( nb_u - 1 ) + v * nb_u + w * nb_u * nb_v;
77+ const auto vertex =
78+ nb_u + v * ( nb_u + 1 ) + w * ( nb_u + 1 ) * ( nb_v + 1 );
79+ associate_polyhedron_vertex_to_vertex ( { cell, 1 }, vertex );
80+ }
81+ }
82+ // Last Face V
83+ for ( const auto w : Range{ nb_w } )
84+ {
85+ for ( const auto u : Range{ nb_u } )
86+ {
87+ const auto cell = u + ( nb_v - 1 ) * nb_u + w * nb_u * nb_v;
88+ const auto vertex =
89+ u + nb_v * ( nb_u + 1 ) + w * ( nb_u + 1 ) * ( nb_v + 1 );
90+ associate_polyhedron_vertex_to_vertex ( { cell, 2 }, vertex );
91+ }
92+ }
93+ // Last Face W
94+ for ( const auto v : Range{ nb_v } )
95+ {
96+ for ( const auto u : Range{ nb_u } )
97+ {
98+ const auto cell = u + v * nb_u + ( nb_w - 1 ) * nb_u * nb_v;
99+ const auto vertex =
100+ u + v * ( nb_u + 1 ) + nb_w * ( nb_u + 1 ) * ( nb_v + 1 );
101+ associate_polyhedron_vertex_to_vertex ( { cell, 4 }, vertex );
102+ }
103+ }
104+ // Last Line U-V
105+ for ( const auto w : Range{ nb_w } )
106+ {
107+ const auto cell =
108+ ( nb_u - 1 ) + ( nb_v - 1 ) * nb_u + w * nb_u * nb_v;
109+ const auto vertex =
110+ nb_u + nb_v * ( nb_u + 1 ) + w * ( nb_u + 1 ) * ( nb_v + 1 );
111+ associate_polyhedron_vertex_to_vertex ( { cell, 3 }, vertex );
112+ }
113+ // Last Line U-W
114+ for ( const auto v : Range{ nb_v } )
115+ {
116+ const auto cell =
117+ ( nb_u - 1 ) + v * nb_u + ( nb_w - 1 ) * nb_u * nb_v;
118+ const auto vertex =
119+ nb_u + v * ( nb_u + 1 ) + nb_w * ( nb_u + 1 ) * ( nb_v + 1 );
120+ associate_polyhedron_vertex_to_vertex ( { cell, 5 }, vertex );
121+ }
122+ // Last Line V-W
123+ for ( const auto u : Range{ nb_u } )
124+ {
125+ const auto cell =
126+ u + ( nb_v - 1 ) * nb_u + ( nb_w - 1 ) * nb_u * nb_v;
127+ const auto vertex =
128+ u + nb_v * ( nb_u + 1 ) + nb_w * ( nb_u + 1 ) * ( nb_v + 1 );
129+ associate_polyhedron_vertex_to_vertex ( { cell, 6 }, vertex );
130+ }
131+ // Last Corner U-V-W
132+ const auto cell =
133+ ( nb_u - 1 ) + ( nb_v - 1 ) * nb_u + ( nb_w - 1 ) * nb_u * nb_v;
134+ const auto vertex =
135+ nb_u + nb_v * ( nb_u + 1 ) + nb_w * ( nb_u + 1 ) * ( nb_v + 1 );
136+ associate_polyhedron_vertex_to_vertex ( { cell, 7 }, vertex );
64137 update_origin ( origin );
65138 }
66139
0 commit comments