| 120 | } |
| 121 | |
| 122 | void test_gradient_grid3D() |
| 123 | { |
| 124 | auto grid = geode::RegularGrid< 3 >::create(); |
| 125 | auto builder = geode::RegularGridBuilder< 3 >::create( *grid ); |
| 126 | builder->initialize_grid( geode::Point3D{ { 0, 0, 0 } }, { 2, 2, 2 }, |
| 127 | { geode::Vector3D{ { 1, 0, 0 } }, geode::Vector3D{ { 0, 1, 0 } }, |
| 128 | geode::Vector3D{ { 0, 0, 1 } } } ); |
| 129 | const auto scalar_function_name = "scalar_function"; |
| 130 | auto attribute = |
| 131 | grid->vertex_attribute_manager() |
| 132 | .find_or_create_attribute< geode::VariableAttribute, double >( |
| 133 | scalar_function_name, 0 ); |
| 134 | attribute->set_value( 4, 1 ); |
| 135 | attribute->set_value( 10, 1 ); |
| 136 | attribute->set_value( 12, 1 ); |
| 137 | attribute->set_value( 14, 1 ); |
| 138 | attribute->set_value( 16, 1 ); |
| 139 | attribute->set_value( 22, 1 ); |
| 140 | attribute->set_value( 1, 2 ); |
| 141 | attribute->set_value( 3, 2 ); |
| 142 | attribute->set_value( 5, 2 ); |
| 143 | attribute->set_value( 7, 2 ); |
| 144 | attribute->set_value( 9, 2 ); |
| 145 | attribute->set_value( 11, 2 ); |
| 146 | attribute->set_value( 15, 2 ); |
| 147 | attribute->set_value( 17, 2 ); |
| 148 | attribute->set_value( 19, 2 ); |
| 149 | attribute->set_value( 21, 2 ); |
| 150 | attribute->set_value( 23, 2 ); |
| 151 | attribute->set_value( 25, 2 ); |
| 152 | attribute->set_value( 0, 3 ); |
| 153 | attribute->set_value( 2, 3 ); |
| 154 | attribute->set_value( 6, 3 ); |
| 155 | attribute->set_value( 8, 3 ); |
| 156 | attribute->set_value( 18, 3 ); |
| 157 | attribute->set_value( 20, 3 ); |
| 158 | attribute->set_value( 24, 3 ); |
| 159 | attribute->set_value( 26, 3 ); |
| 160 | const auto gradient_name = geode::compute_solid_scalar_function_gradient( |
| 161 | *grid, scalar_function_name ); |
| 162 | geode::Logger::info( "Gradient attribute name: ", gradient_name ); |
| 163 | const auto [gradient_name_2, vertices_with_no_value] = |
| 164 | geode::internal::compute_solid_scalar_function_gradient( |
| 165 | *grid, scalar_function_name, { 0, 1 } ); |
| 166 | geode::Logger::info( "Gradient attribute name 2: ", gradient_name_2 ); |
| 167 | geode::OpenGeodeMeshException::test( vertices_with_no_value.size() == 7, |
| 168 | "Wrong number of vertices without value for gradient " |
| 169 | "computation, ", |
| 170 | vertices_with_no_value.size(), " instead of 7" ); |
| 171 | geode::save_regular_grid< 3 >( *grid, "grid_with_gradient.og_rgd3d" ); |
| 172 | } |
| 173 | |
| 174 | void test() |
| 175 | { |
no test coverage detected