Skip to content

File is too small to be a valid STL file. error #36

@foulde

Description

@foulde

Hi ! i am having an issue with a stl file of a 2d square plate of 72 triangles and 216 vertices i am trying to use the c++ header only as mentioned in the c++ example but i get the following error :

terminate called after throwing an instance of 'std::runtime_error'
what(): File is too small to be a valid STL file.
Aborted (core dumped)

i am using the following code :

`#include
#include // std::ifstream
#include<string.h>
#include "../lib/stl.h"

// char filename[] = "square_plate.stl";

// char filename[] = "plat100x100.stl";
char filename[] = "square_plate.stl";

int main(){

std::ifstream file(filename, std::ios::binary);
if(!file.is_open()){
    std::cerr << "Error: Unable to open file '" << filename << "'" << std::endl;
}

// Deserialize the triangles in either binary or ASCII format
std::cout << "\n\nthis is the code \n\n"; 
std::vector<openstl::Triangle> triangles = openstl::deserializeStl(file);
file.close();

const auto& [vertices, faces] = convertToVerticesAndFaces(triangles);

return 0; 

}
`

Best regards

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions