{"record":{"id":"8f0b974a53a56b4b","repo":"Yalantis/uCrop","slug":"load-off-only-u-u-primitives-read-from-file","errorCode":null,"errorMessage":"load_off(): Only %u/%u primitives read from file '%s'.","messagePattern":"load_off\\(\\): Only %u/%u primitives read from file '(.+?)'\\.","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"ucrop/src/main/jni/CImg.h","lineNumber":59402,"sourceCode":"          case 8 : {\n            if ((err = std::fscanf(nfile,\"%u%u%u%u%u%u%u%u%255[^\\n] \",&i0,&i1,&i2,&i3,&i4,&i5,&i6,&i7,line._data))<7) {\n              cimg::warn(_cimg_instance\n                         \"load_off(): Failed to read primitive %u/%u from file '%s'.\",\n                         cimg_instance,\n                         nb_read,nb_primitives,filename?filename:\"(FILE*)\");\n\n              err = std::fscanf(nfile,\"%*[^\\n] \");\n            } else {\n              err = cimg_sscanf(line,\"%f%f%f\",&c0,&c1,&c2);\n              CImg<tf>::vector(i0,i3,i2,i1).move_to(primitives);\n              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.","sourceCodeStart":59384,"sourceCodeEnd":59420,"githubUrl":"https://github.com/Yalantis/uCrop/blob/f788b534b48c144edf786c8cddbf0e029e637804/ucrop/src/main/jni/CImg.h#L59384-L59420","documentation":"load_off() failed to parse one primitive (face/polygon) while reading an OFF mesh file: the vertex count for that primitive was unexpected or the line could not be parsed. It warns with cimg::warn, skips the line (%[^\\n] scan) and continues, so the mesh loads with one fewer primitive than declared.","triggerScenarios":"Loading a malformed OFF file whose face lines do not match 'N v1 v2 ... vN' with a supported N (CImg's parser handles triangles and quads specially; larger polygons or malformed counts hit the default branch of the parse switch).","commonSituations":"OFF files with polygons of more vertices than the parser handles; files with negative or out-of-range vertex indices; non-integer tokens on face lines; hand-edited or tool-exported OFF with trailing garbage on face lines.","solutions":["Pre-process the OFF file to triangulate faces (e.g. with MeshLab or a script) so every face line has exactly 3 vertex indices.","Fix malformed face lines (ensure each face starts with a valid count N followed by N integer indices in range).","Validate the OFF structure (counts vs actual lines) before loading; reject or repair non-conforming files.","If the source mesh is fine but CImg's parser is too limited, convert to another format (e.g. via meshlab/assimp) and use the corresponding loader."],"exampleFix":"# repair step: triangulate the OFF before loading\nmeshlabserver -i model.off -o model_tri.off -m wt\n# then\nmesh.load_off(\"model_tri.off\");","handlingStrategy":"validation","validationCode":"// validate OFF face lines parse as 'N i0 ... i{N-1}' before loading\nfor (auto& line : faceLines) if (!isValidFaceLine(line)) repairOrReject(line);","typeGuard":null,"tryCatchPattern":"try { mesh.load_off(path, colors, prims); } catch (CImgIOException& e) { /* re-export mesh */ }","preventionTips":["Triangulate meshes before loading OFF files.","Validate OFF structure with an independent parser (assimp, trimesh).","Check loaded primitive count against the file header."],"tags":["off","mesh","parsing","format"],"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"}