cmlibs / zinc

Source code repository for OpenCMISS-Zinc
Mozilla Public License 2.0
15 stars 18 forks source link

Export STL crashes with empty glpyh set #277

Closed rchristie closed 8 months ago

rchristie commented 8 months ago

NULL glyph_set is being dereferenced in draw_glyph_set_stl().

Test case:

TEST(cmzn_scene, stl_export_empty_points_crash)
{
    ZincTestSetupCpp zinc;

    Field coordinates = zinc.fm.createFieldFiniteElement(3);
    EXPECT_TRUE(coordinates.isValid());

    GraphicsPoints points = zinc.scene.createGraphicsPoints();
    EXPECT_TRUE(points.isValid());
    EXPECT_EQ(CMZN_OK, points.setFieldDomainType(Field::DOMAIN_TYPE_NODES));
    EXPECT_EQ(CMZN_OK, points.setCoordinateField(coordinates));

    StreaminformationScene si = zinc.scene.createStreaminformationScene();
    EXPECT_TRUE(si.isValid());
    EXPECT_EQ(CMZN_OK, si.setIOFormat(si.IO_FORMAT_ASCII_STL));
    StreamresourceMemory srm = si.createStreamresourceMemory();
    EXPECT_EQ(CMZN_OK, zinc.scene.write(si));
}