{"record":{"id":"2e6396c2b59747c2","repo":"Yalantis/uCrop","slug":"atnxyz-empty-instance","errorCode":null,"errorMessage":"atNXYZ(): Empty instance.","messagePattern":"atNXYZ\\(\\): Empty instance\\.","errorType":"exception","errorClass":"CImgInstanceException","httpStatus":null,"severity":"error","filePath":"ucrop/src/main/jni/CImg.h","lineNumber":65067,"sourceCode":"    }\n\n    //! Access pixel value with Dirichlet boundary conditions for the 3 coordinates (\\c pos, \\c x,\\c y,\\c z) \\const.\n    T atNXYZ(const int pos, const int x, const int y, const int z, const int c, const T& out_value) const {\n      return (pos<0 || pos>=width())?out_value:_data[pos].atXYZ(x,y,z,c,out_value);\n    }\n\n    //! Access to pixel value with Neumann boundary conditions for the 4 coordinates (\\c pos, \\c x,\\c y,\\c z).\n    /**\n       \\param pos Index of the image element to access.\n       \\param x X-coordinate of the pixel value.\n       \\param y Y-coordinate of the pixel value.\n       \\param z Z-coordinate of the pixel value.\n       \\param c C-coordinate of the pixel value.\n       \\note <tt>list.atNXYZ(p,x,y,z,c);</tt> is equivalent to <tt>list[p].atXYZ(x,y,z,c);</tt>.\n    **/\n   T& atNXYZ(const int pos, const int x, const int y, const int z, const int c=0) {\n      if (is_empty())\n        throw CImgInstanceException(_cimglist_instance\n                                    \"atNXYZ(): Empty instance.\",\n                                    cimglist_instance);\n\n      return _atNXYZ(pos,x,y,z,c);\n    }\n\n    //! Access to pixel value with Neumann boundary conditions for the 4 coordinates (\\c pos, \\c x,\\c y,\\c z) \\const.\n    T atNXYZ(const int pos, const int x, const int y, const int z, const int c=0) const {\n      if (is_empty())\n        throw CImgInstanceException(_cimglist_instance\n                                    \"atNXYZ(): Empty instance.\",\n                                    cimglist_instance);\n\n      return _atNXYZ(pos,x,y,z,c);\n    }\n\n    T& _atNXYZ(const int pos, const int x, const int y, const int z, const int c=0) {\n      return _data[cimg::cut(pos,0,width() - 1)].atXYZ(x,y,z,c);","sourceCodeStart":65049,"sourceCodeEnd":65085,"githubUrl":"https://github.com/Yalantis/uCrop/blob/f788b534b48c144edf786c8cddbf0e029e637804/ucrop/src/main/jni/CImg.h#L65049-L65085","documentation":"Non-const CImgList<T>::atNXYZ(pos,x,y,z,c=0) accesses a pixel with Neumann boundary conditions on the 4 coordinates (pos,x,y,z) (c defaults to 0). It throws CImgInstanceException when the list instance is empty.","triggerScenarios":"Calling list.atNXYZ(p,x,y,z) on an empty CImgList (is_empty()==true), typically one that was never filled or was cleared.","commonSituations":"3D volume sampling helpers operating on lists loaded from files that failed to load; loops over multiple images where all images were removed; APIs that return an empty list on error and are then sampled.","solutions":["Check list.is_empty() (or size()>0) before sampling.","Verify list population succeeded before the sampling loop.","Prefer iterating with cimglist_for which naturally skips empty lists.","Catch CImgInstanceException where empty input is acceptable."],"exampleFix":"// before\nCImgList<T> lst;\ndouble s = lst.atNXYZ(0, x, y, z);\n// after\nCImgList<T> lst;\nif (!lst.is_empty()) {\n  double s = lst.atNXYZ(0, x, y, z);\n}","handlingStrategy":"validation","validationCode":"// C++\nif (!list.is_empty()) { /* call atNXYZ safely */ }","typeGuard":"template <typename T>\nbool nonEmpty(const CImgList<T>& l) { return l.size() > 0; }","tryCatchPattern":"// C++\ntry {\n  T v = list.atNXYZ(p, x, y, z);\n} catch (CImgInstanceException& e) {\n  // handle empty list\n}","preventionTips":["Check is_empty() before sampling loops.","Verify lists produced by earlier processing stages are non-empty.","Use cimglist_for instead of manual indexing where possible.","Log list.size() when a sampling helper fails to aid diagnosis."],"tags":["cimg","cpp","empty-list","pixel-access"],"backgroundTag":"empty-result-set","analyzedSha":"f788b534b48c144edf786c8cddbf0e029e637804","analyzedAt":"2026-09-08T08:36:04.887Z","contentChangedAt":"2026-09-08T08:36:04.887Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}