{"record":{"id":"d2fbd84246fd9361","repo":"Yalantis/uCrop","slug":"load-off-failed-to-read-primitive-u-u-u-ver","errorCode":null,"errorMessage":"load_off(): Failed to read primitive %u/%u (%u vertices) from file '%s'.","messagePattern":"load_off\\(\\): Failed to read primitive %u/%u \\(%u vertices\\) from file '(.+?)'\\.","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"ucrop/src/main/jni/CImg.h","lineNumber":59413,"sourceCode":"              CImg<tf>::vector(i0,i5,i4,i3).move_to(primitives);\n              CImg<tf>::vector(i0,i7,i6,i5).move_to(primitives);\n              colors.insert(3,CImg<tc>::vector((tc)(c0*255),(tc)(c1*255),(tc)(c2*255)));\n              ++(++nb_primitives);\n            }\n          } break;\n          default :\n            cimg::warn(_cimg_instance\n                       \"load_off(): Failed to read primitive %u/%u (%u vertices) from file '%s'.\",\n                       cimg_instance,\n                       nb_read,nb_primitives,prim,filename?filename:\"(FILE*)\");\n\n            err = std::fscanf(nfile,\"%*[^\\n] \");\n          }\n        }\n      }\n      if (!file) cimg::fclose(nfile);\n      if (primitives._width!=nb_primitives)\n        cimg::warn(_cimg_instance\n                   \"load_off(): Only %u/%u primitives read from file '%s'.\",\n                   cimg_instance,\n                   primitives._width,nb_primitives,filename?filename:\"(FILE*)\");\n      return *this;\n    }\n\n    //! Load image sequence from a video file, using OpenCV library.\n    /**\n      \\param filename Filename, as a C-string.\n      \\param first_frame Index of the first frame to read.\n      \\param last_frame Index of the last frame to read.\n      \\param step_frame Step value for frame reading.\n      \\param axis Alignment axis.\n      \\param align Appending alignment.\n    **/\n    CImg<T>& load_video(const char *const filename,\n                        const unsigned int first_frame=0, const unsigned int last_frame=~0U,\n                        const unsigned int step_frame=1,","sourceCodeStart":59395,"sourceCodeEnd":59431,"githubUrl":"https://github.com/Yalantis/uCrop/blob/f788b534b48c144edf786c8cddbf0e029e637804/ucrop/src/main/jni/CImg.h#L59395-L59431","documentation":"After load_off() finishes parsing an OFF mesh, the primitives list has fewer entries than the count declared in the file header, meaning one or more primitives failed to read (see the per-primitive warning). The mesh is returned incomplete rather than failing, so downstream geometry is silently missing faces.","triggerScenarios":"CImg::load_off() on an OFF file where primitives._width < nb_primitives after the parse loop: unreadable face lines, unexpected polygon sizes, or premature EOF before all declared faces are present.","commonSituations":"Truncated downloads/exports; face count in header larger than the actual number of face lines; parser limitations with big polygons; files with comments or blank lines inside the face section.","solutions":["Open the OFF file and compare the declared face count with the number of face lines; repair the header or the missing lines.","Triangulate/normalize the file with an external tool (MeshLab, trimesh) before loading.","Validate the OFF with a linter/assimp and re-export; then verify the loaded mesh's primitives size equals the declared count in your code.","Treat the warning as fatal in your pipeline: after load_off(), check primitives size vs header and reject inconsistent meshes."],"exampleFix":"// after\nCImgList<unsigned int> prims;\nprims_mesh.load_off(\"model.off\", colors, prims);\n// after: guard against truncated parse\nif (prims.size() != declared_nb_faces) throw std::runtime_error(\"model.off truncated: expected \" + std::to_string(declared_nb_faces) + \" faces\");","handlingStrategy":"validation","validationCode":"mesh.load_off(path, colors, prims);\nif (prims.size() != declaredNbFaces) reject(path, \"truncated/malformed OFF\");","typeGuard":null,"tryCatchPattern":"try { mesh.load_off(path); } catch (...) { mesh = loadViaExternalConverter(path); }","preventionTips":["Compare declared face count with actual face lines before loading.","Re-export suspect OFF files through a mesh tool.","Detect CImg warnings and escalate them to errors in asset pipelines."],"tags":["off","mesh","truncated-file","parsing"],"backgroundTag":"file-read-failed","analyzedSha":"f788b534b48c144edf786c8cddbf0e029e637804","analyzedAt":"2026-09-08T08:36:04.887Z","contentChangedAt":"2026-09-08T08:36:04.887Z","schemaVersion":2},"datasetVersion":"2026-09-17T15:17:12.973Z"}