Add some utility variant API functions
This commit is contained in:
parent
a0fa9bb206
commit
e7757fcbda
@ -24,6 +24,12 @@ void gmio_stream_set_null(gmio_stream_t* stream)
|
||||
memset(stream, 0, sizeof(gmio_stream_t));
|
||||
}
|
||||
|
||||
gmio_stream_t gmio_stream_null()
|
||||
{
|
||||
gmio_stream_t null_stream = { 0 };
|
||||
return null_stream;
|
||||
}
|
||||
|
||||
static gmio_bool_t gmio_stream_stdio_at_end(void* cookie)
|
||||
{
|
||||
return feof((FILE*) cookie);
|
||||
@ -54,3 +60,10 @@ void gmio_stream_set_stdio(gmio_stream_t* stream, FILE* file)
|
||||
stream->read_func = gmio_stream_stdio_read;
|
||||
stream->write_func = gmio_stream_stdio_write;
|
||||
}
|
||||
|
||||
gmio_stream_t gmio_stream_stdio(FILE* file)
|
||||
{
|
||||
gmio_stream_t stdio_stream = { 0 };
|
||||
gmio_stream_set_stdio(&stdio_stream, file);
|
||||
return stdio_stream;
|
||||
}
|
||||
|
@ -98,9 +98,15 @@ GMIO_C_LINKAGE_BEGIN
|
||||
/*! Installs a null stream */
|
||||
GMIO_LIB_EXPORT void gmio_stream_set_null(gmio_stream_t* stream);
|
||||
|
||||
/*! Returns a null stream */
|
||||
GMIO_LIB_EXPORT gmio_stream_t gmio_stream_null();
|
||||
|
||||
/*! Configures \p stream for standard FILE* (cookie will hold \p file) */
|
||||
GMIO_LIB_EXPORT void gmio_stream_set_stdio(gmio_stream_t* stream, FILE* file);
|
||||
|
||||
/*! Returns a stream for standard FILE* (cookie will hold \p file) */
|
||||
GMIO_LIB_EXPORT gmio_stream_t gmio_stream_stdio(FILE* file);
|
||||
|
||||
GMIO_C_LINKAGE_END
|
||||
|
||||
#endif /* GMIO_STREAM_H */
|
||||
|
@ -15,9 +15,6 @@
|
||||
|
||||
#include <gmio_support/occ_libstl.h>
|
||||
|
||||
#include <gmio_stl/stl_mesh.h>
|
||||
#include <gmio_stl/stl_mesh_creator.h>
|
||||
|
||||
#include <cstring>
|
||||
#include <StlMesh_Mesh.hxx>
|
||||
#include <StlMesh_MeshTriangle.hxx>
|
||||
@ -86,7 +83,7 @@ static void occmesh_get_triangle(const void* cookie,
|
||||
|
||||
} // namespace internal
|
||||
|
||||
void gmio_stl_occmesh(gmio_stl_mesh_t *mesh, const gmio_OccStlMeshDomain &meshCookie)
|
||||
void gmio_stl_set_occmesh(gmio_stl_mesh_t *mesh, const gmio_OccStlMeshDomain &meshCookie)
|
||||
{
|
||||
std::memset(mesh, 0, sizeof(gmio_stl_mesh_t));
|
||||
mesh->cookie = &meshCookie;
|
||||
@ -94,13 +91,27 @@ void gmio_stl_occmesh(gmio_stl_mesh_t *mesh, const gmio_OccStlMeshDomain &meshCo
|
||||
mesh->get_triangle_func = internal::occmesh_get_triangle;
|
||||
}
|
||||
|
||||
void gmio_stl_occmesh_creator(gmio_stl_mesh_creator_t *creator, const Handle_StlMesh_Mesh &mesh)
|
||||
gmio_stl_mesh gmio_stl_occmesh(const gmio_OccStlMeshDomain &meshCookie)
|
||||
{
|
||||
gmio_stl_mesh occmesh = { 0 };
|
||||
gmio_stl_set_occmesh(&occmesh, meshCookie);
|
||||
return occmesh;
|
||||
}
|
||||
|
||||
void gmio_stl_set_occmesh_creator(gmio_stl_mesh_creator_t *creator, const Handle_StlMesh_Mesh &mesh)
|
||||
{
|
||||
std::memset(creator, 0, sizeof(gmio_stl_mesh_creator_t));
|
||||
creator->cookie = internal::occMeshPtr(mesh);
|
||||
creator->add_triangle_func = internal::occmesh_add_triangle;
|
||||
}
|
||||
|
||||
gmio_stl_mesh_creator gmio_stl_occmesh_creator(const Handle_StlMesh_Mesh &mesh)
|
||||
{
|
||||
gmio_stl_mesh_creator occ_creator = { 0 };
|
||||
gmio_stl_set_occmesh_creator(&occ_creator, mesh);
|
||||
return occ_creator;
|
||||
}
|
||||
|
||||
gmio_OccStlMeshDomain::gmio_OccStlMeshDomain(const Handle_StlMesh_Mesh &stlMesh, int domId)
|
||||
: m_mesh(stlMesh),
|
||||
m_domainId(domId)
|
||||
|
@ -21,6 +21,9 @@
|
||||
#define GMIO_SUPPORT_OCC_LIBSTL_H
|
||||
|
||||
#include "support_global.h"
|
||||
#include "../gmio_stl/stl_mesh.h"
|
||||
#include "../gmio_stl/stl_mesh_creator.h"
|
||||
|
||||
#include <Handle_StlMesh_Mesh.hxx>
|
||||
struct gmio_stl_mesh;
|
||||
struct gmio_stl_mesh_creator;
|
||||
@ -50,13 +53,32 @@ private:
|
||||
* \c mesh->cookie will point to \p meshCookie
|
||||
*/
|
||||
GMIO_LIBSUPPORT_EXPORT
|
||||
void gmio_stl_occmesh(gmio_stl_mesh* mesh, const gmio_OccStlMeshDomain& meshCookie);
|
||||
void gmio_stl_set_occmesh(
|
||||
gmio_stl_mesh* mesh, const gmio_OccStlMeshDomain& meshCookie);
|
||||
|
||||
/*! Returns a gmio_stl_mesh mapped to domain in StlMesh_Mesh
|
||||
*
|
||||
* The mesh's cookie will point to \p meshCookie
|
||||
*/
|
||||
GMIO_LIBSUPPORT_EXPORT
|
||||
gmio_stl_mesh gmio_stl_occmesh(const gmio_OccStlMeshDomain& meshCookie);
|
||||
|
||||
/*! Initializes \p creator to build a new domain in a StlMesh_Mesh object
|
||||
*
|
||||
* \c creator->cookie will point to the internal data(ie. StlMesh_Mesh*) of handle \p mesh
|
||||
* \c creator->cookie will point to the internal data(ie StlMesh_Mesh*) of
|
||||
* handle \p mesh
|
||||
*/
|
||||
GMIO_LIBSUPPORT_EXPORT
|
||||
void gmio_stl_occmesh_creator(gmio_stl_mesh_creator* creator, const Handle_StlMesh_Mesh& mesh);
|
||||
void gmio_stl_set_occmesh_creator(
|
||||
gmio_stl_mesh_creator* creator, const Handle_StlMesh_Mesh& mesh);
|
||||
|
||||
/*! Returns a gmio_stl_mesh_creator that will build a new domain in a
|
||||
* StlMesh_Mesh object
|
||||
*
|
||||
* The creator's cookie will point to the internal data(ie StlMesh_Mesh*) of
|
||||
* handle \p mesh
|
||||
*/
|
||||
GMIO_LIBSUPPORT_EXPORT
|
||||
gmio_stl_mesh_creator gmio_stl_occmesh_creator(const Handle_StlMesh_Mesh& mesh);
|
||||
|
||||
#endif /* GMIO_SUPPORT_OCC_LIBSTL_H */
|
||||
|
@ -15,8 +15,6 @@
|
||||
|
||||
#include <gmio_support/qt_stream.h>
|
||||
|
||||
#include <gmio_core/stream.h>
|
||||
|
||||
#include <QtCore/QFile>
|
||||
#include <QtCore/QIODevice>
|
||||
|
||||
@ -69,3 +67,10 @@ void gmio_stream_set_qiodevice(gmio_stream_t* stream, QIODevice* device)
|
||||
stream->read_func = gmio_stream_qiodevice_read;
|
||||
stream->write_func = gmio_stream_qiodevice_write;
|
||||
}
|
||||
|
||||
gmio_stream_t gmio_stream_qiodevice(QIODevice* device)
|
||||
{
|
||||
gmio_stream_t qtstream = { 0 };
|
||||
gmio_stream_set_qiodevice(&qtstream, device);
|
||||
return qtstream;
|
||||
}
|
||||
|
@ -21,9 +21,9 @@
|
||||
#define GMIO_SUPPORT_QT_STREAM_H
|
||||
|
||||
#include "support_global.h"
|
||||
#include "../gmio_core/stream.h"
|
||||
#include <QtCore/QtGlobal>
|
||||
|
||||
struct gmio_stream;
|
||||
QT_BEGIN_NAMESPACE
|
||||
class QIODevice;
|
||||
QT_END_NAMESPACE
|
||||
@ -31,6 +31,10 @@ QT_END_NAMESPACE
|
||||
/*! Configures \p stream for \c QIODevice* (cookie will hold \p device) */
|
||||
GMIO_LIBSUPPORT_EXPORT
|
||||
void gmio_stream_set_qiodevice(
|
||||
struct gmio_stream* stream, QT_PREPEND_NAMESPACE(QIODevice)* device);
|
||||
gmio_stream_t* stream, QT_PREPEND_NAMESPACE(QIODevice)* device);
|
||||
|
||||
/*! Returns a gmio_stream for \c QIODevice* (cookie will hold \p device) */
|
||||
GMIO_LIBSUPPORT_EXPORT
|
||||
gmio_stream_t gmio_stream_qiodevice(QT_PREPEND_NAMESPACE(QIODevice)* device);
|
||||
|
||||
#endif /* GMIO_SUPPORT_QT_STREAM_H */
|
||||
|
Loading…
Reference in New Issue
Block a user