Failed to get data from BaseContainer
-
Hi,
I use the plugin to store some data to the Base Container, but it always crashes when I read it again from the Base Container.return ...ge_container.h(293): CRITICAL: Stop
Thanks for any help!
this is code
//function ToBc static maxon::Result<void> ToBC(BaseContainer& bc_local_pos,maxon::BaseArray<maxon::BaseArray<maxon::BaseArray<Vector>>>& local_pos) { //Convert a 3 dimensions BaseArray to a 3 dimensions BaseContainer Int32 all_cnt = local_pos.GetCount(), i,x = 0,x_id ; for (i = 0;i < all_cnt;++i) { BaseContainer per_bc_local_pos; Int32 per_local_cnt = local_pos[i].GetCount(), l; for (l = 0;l < per_local_cnt;++l) { BaseContainer per_per_bc_local_pos; Int32 per_per_local_cnt = local_pos[i][l].GetCount(), p_l; for (p_l = 0;p_l < per_per_local_cnt;++p_l) { per_per_bc_local_pos.SetVector(p_l, local_pos[i][l][p_l]); } per_bc_local_pos.SetContainer(l, per_per_bc_local_pos); //test BaseContainer test = per_bc_local_pos.GetContainer(l); x = 0; while (true) { x_id = test.GetIndexId(x++); if (x_id == NOTOK) break; else { Vector vec = test.GetVector(x_id); DiagnosticOutput("Vector:@", vec); } } } bc_local_pos.SetContainer(i, per_bc_local_pos); } return maxon::OK; } //function ToArr static maxon::Result<void> ToArr(BaseContainer& bc_local_pos, maxon::BaseArray<maxon::BaseArray<maxon::BaseArray<Vector>>>& local_pos) { //convert 3 dimensions BaseContainer to 3 dimensions BaseArray iferr_scope; Int32 x = 0, y = 0, z = 0; x = 0; while (true) { const Int32 x_id = bc_local_pos.GetIndexId(x++); if (x_id == NOTOK) break; else { BaseContainer per_bc_local_pos = bc_local_pos.GetContainer(x_id); maxon::BaseArray<maxon::BaseArray<Vector>> per_local_pos; y = 0; while (true) { const Int32 y_id = per_bc_local_pos.GetIndexId(y++); if (y_id == NOTOK) break; else { BaseContainer per_per_bc_local_pos = per_bc_local_pos.GetContainer(y_id); z = 0; maxon::BaseArray<Vector> per_per_local_pos; while (true) { const Int32 z_id = per_per_bc_local_pos.GetIndexId(z++); if (z_id == NOTOK) break; else { per_per_local_pos.Append(per_per_bc_local_pos.GetVector(z_id)) iferr_return; } } per_local_pos.Append(per_per_local_pos) iferr_return; } } local_pos.Append(per_local_pos) iferr_return; } } return maxon::OK; } // local_pos, new_local_pos ----> 3 dimension BaseArray<Vector> // test_bc ----> BaseContainer ToBC(test_bc, local_pos) ToArr(test_bc,new_local_pos)
-
Hi chuanzhen, thanks for reaching out us.
With regard to the issue reported, I'm not able to hit the Critical Stop mentioned in the initial post.
I've tested your code usingmaxon::BaseArray<maxon::BaseArray<maxon::BaseArray<maxon::Vector>>> ba_3d, ba_3d2; ba_3d.Resize(2) iferr_return; ba_3d[0].Resize(2) iferr_return; ba_3d[1].Resize(2) iferr_return; ba_3d[0][0].Resize(2) iferr_return; ba_3d[0][1].Resize(2) iferr_return; ba_3d[1][0].Resize(2) iferr_return; ba_3d[1][1].Resize(2) iferr_return; ba_3d[0][0][0] = maxon::Vector(0, 0, 0); ba_3d[0][0][1] = maxon::Vector(0, 0, 1); ba_3d[0][1][0] = maxon::Vector(0, 1, 0); ba_3d[0][1][1] = maxon::Vector(0, 1, 1); ba_3d[1][0][0] = maxon::Vector(1, 0, 0); ba_3d[1][0][1] = maxon::Vector(1, 0, 1); ba_3d[1][1][0] = maxon::Vector(1, 1, 0); ba_3d[1][1][1] = maxon::Vector(1, 1, 1); BaseContainer bc_3d; ToBC(bc_3d, ba_3d) iferr_return; ToArr(bc_3d, ba_3d2) iferr_return; for (int i = 0; i < 2; i++) for (int j = 0; j < 2; j++) for (int k = 0; k < 2; k++) DiagnosticOutput("[@][@][@]: ba_3d -> @\nba_3d2 -> @", i, j, k, ba_3d[i][j][k], ba_3d2[i][j][k]); return maxon::OK;
and this was the output reported in the console - the lines starting with "Vector:" were from your code -
Vector:(0.000,0.000,0.000) Vector:(0.000,0.000,1.000) Vector:(0.000,1.000,0.000) Vector:(0.000,1.000,1.000) Vector:(1.000,0.000,0.000) Vector:(1.000,0.000,1.000) Vector:(1.000,1.000,0.000) Vector:(1.000,1.000,1.000) [0][0][0]: ba_3d -> (0.000,0.000,0.000) ba_3d2 -> (0.000,0.000,0.000) [0][0][1]: ba_3d -> (0.000,0.000,1.000) ba_3d2 -> (0.000,0.000,1.000) [0][1][0]: ba_3d -> (0.000,1.000,0.000) ba_3d2 -> (0.000,1.000,0.000) [0][1][1]: ba_3d -> (0.000,1.000,1.000) ba_3d2 -> (0.000,1.000,1.000) [1][0][0]: ba_3d -> (1.000,0.000,0.000) ba_3d2 -> (1.000,0.000,0.000) [1][0][1]: ba_3d -> (1.000,0.000,1.000) ba_3d2 -> (1.000,0.000,1.000) [1][1][0]: ba_3d -> (1.000,1.000,0.000) ba_3d2 -> (1.000,1.000,0.000) [1][1][1]: ba_3d -> (1.000,1.000,1.000) ba_3d2 -> (1.000,1.000,1.000)
Two things to mention:
- the Critical Stop you hit is caused by the fact that the
BaseContainer::GetContainer()
method is attempted to run on an entry which is actually not containing a BaseContainer. - if you need to simply transfer the content of a BaseArray to a BaseContainer you can consider to use
BaseContainer::SetMemory()
as shown in in the BaseContainer Manual. - finally I recommend rewriting your method signatures ordering the parameters and taking advantage of the
const
qualifier as:
static maxon::Result<void> ToBC(const maxon::BaseArray<maxon::BaseArray<maxon::BaseArray<Vector>>>& local_pos, BaseContainer& bc_local_pos) {} static maxon::Result<void> ToArr(const BaseContainer& bc_local_pos, maxon::BaseArray<maxon::BaseArray<maxon::BaseArray<Vector>>>& local_pos)
Best, Riccardo
- the Critical Stop you hit is caused by the fact that the
-
Hi, @r_gigante
Thank you for your reply. With your help, I finally traced the source of the problem. As you said, the reason for the error(Critical Stop) is that there is no Container at all. Because of a very hidden error in somewhere, I wrote the wrong data type to BaseContainer.