OpenSceneGraph icon indicating copy to clipboard operation
OpenSceneGraph copied to clipboard

Groups that contain more than one geode causing issues when exporting to STL format

Open awiddess-ccdc opened this issue 3 years ago • 2 comments

When there is a group of geodes and you export to STL each geode contains a solid/endsolid When this is processed (using the attached example) you only see a sphere rather than a crystal structure. AABHTZ.zip

Would it be possible to include a boolean to specify whether the geode requires the "solid" to be specified? Or, is there another way of overriding the visitor to allow our own implementation?

awiddess-ccdc avatar Oct 01 '20 07:10 awiddess-ccdc

I'm struggling to figure out what you referring to/have in mind.

Are you talking about needing to extend the STL plugin in some way?

I can't comment on STL plugin specifics without diving into the code - I'm not author of this plugin so am in the same position as yourself w.r.t having to figure out what the codes does, what is appropriate for the file format.

robertosfield avatar Oct 01 '20 07:10 robertosfield

Hi robertosfield, thanks for your comments.

From the specification: `solid

facet normal ni nj nk outer loop vertex v1x v1y v1z vertex v2x v2y v2z vertex v3x v3y v3z endloop endfacet

endsolid `

ReaderWriterSTL.cpp will output the format (above) for each geode within a group. It doesn't necessarily break the specification as the use of "solid" is ambiguous - however, it does beak a couple of 3D printing tools (Microsoft is one).

This is an example (significantly reduced) of what is generated from the ReaderWriterSTL when there is a group of geodes:- solid 0 facet normal 0 -0 0 outer loop vertex -36.7201 7.9413 11.4092 vertex -35.9604 7.9413 11.3428 vertex -36.7201 7.9413 11.4092 endloop endfacet facet normal 0.0172704 0.00304538 0.197401 outer loop vertex -35.9604 7.9413 11.3428 vertex -36.0062 8.20114 11.3428 vertex -36.7201 7.9413 11.4092 endloop endfacet endsolid 0 solid 1 facet normal 0 -0 0 outer loop vertex -61.6544 -38.4334 26.0545 vertex -60.8947 -38.4334 25.988 vertex -61.6544 -38.4334 26.0545 endloop endfacet facet normal 0.0172702 0.00304533 0.197402 outer loop vertex -60.8947 -38.4334 25.988 vertex -60.9406 -38.1736 25.988 vertex -61.6544 -38.4334 26.0545 endloop endfacet facet normal 0 -0 0 outer loop vertex -61.6544 -38.4334 26.0545 vertex -60.9406 -38.1736 25.988 vertex -61.6544 -38.4334 26.0545 endloop endfacet endsolid 1

The boolean, would support wrapping up the output of "solid" and "endsolid" ` if (node.solidRequired) { if (node.getName().empty()) *m_f << "solid " << counter << std::endl; else *m_f << "solid " << node.getName() << std::endl; }

        *m_f << std::fixed << std::setprecision(7);
        for (unsigned int i = 0; i < node.getNumDrawables(); ++i)
        {
            osg::TriangleFunctor<PushPoints> tf;
            tf.m_stream = m_f;
            tf.m_mat = mat;
            tf.m_dontSaveNormals = m_localOptions.dontSaveNormals;
            node.getDrawable(i)->accept(tf);
        }


        if (node.solidRequired)
        {
            if (node.getName().empty())
                *m_f << "endsolid " << counter << std::endl;
            else
                *m_f << "endsolid " << node.getName() << std::endl;
        }

`

awiddess-ccdc avatar Oct 01 '20 08:10 awiddess-ccdc