gmio_support: split stl_occ.h+cpp into stl_occ_mesh and stl_occ_meshvs
This commit is contained in:
parent
6c2b784323
commit
ac6d242f9a
@ -38,7 +38,7 @@ endfunction()
|
||||
add_executable(
|
||||
benchmark_opencascade
|
||||
main.cpp
|
||||
${CMAKE_SOURCE_DIR}/src/gmio_support/stl_occ.cpp
|
||||
${CMAKE_SOURCE_DIR}/src/gmio_support/stl_occ_mesh.cpp
|
||||
${COMMONS_FILES})
|
||||
|
||||
if(GMIO_TARGET_ARCH_BIT_SIZE EQUAL 64)
|
||||
|
@ -22,7 +22,7 @@
|
||||
#include <gmio_core/version.h>
|
||||
#include <gmio_stl/stl_io.h>
|
||||
#include <gmio_stl/stl_io_options.h>
|
||||
#include <gmio_support/stl_occ.h>
|
||||
#include <gmio_support/stl_occ_mesh.h>
|
||||
|
||||
#include "../commons/benchmark_tools.h"
|
||||
|
||||
|
@ -66,8 +66,11 @@ install(FILES gmio_support/stream_qt.h DESTINATION include/gmio_support)
|
||||
install(FILES gmio_support/stream_qt.cpp DESTINATION src/gmio_support)
|
||||
|
||||
# OpenCASCADE support
|
||||
install(FILES gmio_support/stl_occ.h DESTINATION include/gmio_support)
|
||||
install(FILES gmio_support/stl_occ.cpp DESTINATION src/gmio_support)
|
||||
install(FILES gmio_support/stl_occ_mesh.h DESTINATION include/gmio_support)
|
||||
install(FILES gmio_support/stl_occ_meshvs.h DESTINATION include/gmio_support)
|
||||
install(FILES gmio_support/stl_occ_mesh.cpp DESTINATION src/gmio_support)
|
||||
install(FILES gmio_support/stl_occ_meshvs.cpp DESTINATION src/gmio_support)
|
||||
install(FILES gmio_support/stl_occ_utils.h DESTINATION src/gmio_support)
|
||||
|
||||
# Installs for target
|
||||
if(GMIO_BUILD_SHARED_LIBS)
|
||||
|
@ -13,7 +13,9 @@
|
||||
** "http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html".
|
||||
****************************************************************************/
|
||||
|
||||
#include <gmio_support/stl_occ.h>
|
||||
#include <gmio_support/stl_occ_mesh.h>
|
||||
|
||||
#include "stl_occ_utils.h"
|
||||
|
||||
#include <cstring>
|
||||
#include <StlMesh_Mesh.hxx>
|
||||
@ -21,11 +23,6 @@
|
||||
#include <StlMesh_SequenceOfMeshTriangle.hxx>
|
||||
#include <TColgp_SequenceOfXYZ.hxx>
|
||||
|
||||
#ifndef GMIO_SUPPORT_STL_OCC_NO_MESHVS_DATASOURCE
|
||||
# include <MeshVS_DataSource.hxx>
|
||||
# include <TColStd_PackedMapOfInteger.hxx>
|
||||
#endif // !GMIO_SUPPORT_STL_OCC_NO_MESHVS_DATASOURCE
|
||||
|
||||
namespace internal {
|
||||
|
||||
/* Common */
|
||||
@ -51,20 +48,6 @@ static void occmesh_add_triangle(
|
||||
n.x, n.y, n.z);
|
||||
}
|
||||
|
||||
static inline void gmio_stl_occ_copy_xyz(
|
||||
gmio_vec3f* vec, double x, double y, double z)
|
||||
{
|
||||
vec->x = static_cast<float>(x);
|
||||
vec->y = static_cast<float>(y);
|
||||
vec->z = static_cast<float>(z);
|
||||
}
|
||||
|
||||
static inline void gmio_stl_occ_copy_xyz(
|
||||
gmio_vec3f* vec, const gp_XYZ& coords)
|
||||
{
|
||||
gmio_stl_occ_copy_xyz(vec, coords.X(), coords.Y(), coords.Z());
|
||||
}
|
||||
|
||||
static void occmesh_get_triangle(
|
||||
const void* cookie, uint32_t tri_id, gmio_stl_triangle* tri)
|
||||
{
|
||||
@ -86,39 +69,6 @@ static void occmesh_get_triangle(
|
||||
}
|
||||
}
|
||||
|
||||
#ifndef GMIO_SUPPORT_STL_OCC_NO_MESHVS_DATASOURCE
|
||||
static void occmesh_datasource_get_triangle(
|
||||
const void* cookie, uint32_t /*tri_id*/, gmio_stl_triangle* tri)
|
||||
{
|
||||
void* wcookie = const_cast<void*>(cookie);
|
||||
gmio_stl_occmesh_datasource_iterator* it =
|
||||
static_cast<gmio_stl_occmesh_datasource_iterator*>(wcookie);
|
||||
const MeshVS_DataSource* data_src = it->data_src();
|
||||
|
||||
int node_count;
|
||||
MeshVS_EntityType entity_type;
|
||||
const Standard_Boolean get_geom_ok =
|
||||
data_src->GetGeom(
|
||||
it->current_element_key(),
|
||||
Standard_True, // Is element
|
||||
it->cached_element_coords(),
|
||||
node_count,
|
||||
entity_type);
|
||||
if (get_geom_ok && node_count == 3) {
|
||||
// Copy vertex coords
|
||||
const TColStd_Array1OfReal& in_coords_array = it->cached_element_coords();
|
||||
float* out_coords_ptr = &tri->v1.x;
|
||||
for (int i = 0; i < 9; ++i)
|
||||
out_coords_ptr[i] = static_cast<float>(in_coords_array.Value(i + 1));
|
||||
// Copy normal coords
|
||||
double nx, ny, nz;
|
||||
data_src->GetNormal(it->current_element_key(), 3, nx, ny, nz);
|
||||
gmio_stl_occ_copy_xyz(&tri->n, nx, ny, nz);
|
||||
}
|
||||
it->move_to_next_tri();
|
||||
}
|
||||
#endif // !GMIO_SUPPORT_STL_OCC_NO_MESHVS_DATASOURCE
|
||||
|
||||
} // namespace internal
|
||||
|
||||
gmio_stl_mesh gmio_stl_occmesh(const gmio_stl_occmesh_iterator& it)
|
||||
@ -132,19 +82,6 @@ gmio_stl_mesh gmio_stl_occmesh(const gmio_stl_occmesh_iterator& it)
|
||||
return mesh;
|
||||
}
|
||||
|
||||
#ifndef GMIO_SUPPORT_STL_OCC_NO_MESHVS_DATASOURCE
|
||||
gmio_stl_mesh gmio_stl_occmesh(const gmio_stl_occmesh_datasource_iterator& it)
|
||||
{
|
||||
gmio_stl_mesh mesh = {};
|
||||
mesh.cookie = ⁢
|
||||
mesh.triangle_count =
|
||||
it.data_src() != NULL ?
|
||||
it.data_src()->GetAllElements().Extent() : 0;
|
||||
mesh.func_get_triangle = internal::occmesh_datasource_get_triangle;
|
||||
return mesh;
|
||||
}
|
||||
#endif // !GMIO_SUPPORT_STL_OCC_NO_MESHVS_DATASOURCE
|
||||
|
||||
gmio_stl_mesh_creator gmio_stl_occmesh_creator(StlMesh_Mesh* mesh)
|
||||
{
|
||||
gmio_stl_mesh_creator creator = {};
|
||||
@ -210,28 +147,3 @@ bool gmio_stl_occmesh_iterator::move_to_next_tri(uint32_t tri_id)
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
#ifndef GMIO_SUPPORT_STL_OCC_NO_MESHVS_DATASOURCE
|
||||
gmio_stl_occmesh_datasource_iterator::gmio_stl_occmesh_datasource_iterator()
|
||||
: m_data_src(NULL),
|
||||
m_element_coords(1, 1)
|
||||
{ }
|
||||
|
||||
gmio_stl_occmesh_datasource_iterator::gmio_stl_occmesh_datasource_iterator(
|
||||
const MeshVS_DataSource *data_src)
|
||||
: m_data_src(data_src),
|
||||
m_element_coords(1, 9)
|
||||
{
|
||||
if (m_data_src != NULL)
|
||||
m_element_it.Initialize(m_data_src->GetAllElements());
|
||||
}
|
||||
|
||||
gmio_stl_occmesh_datasource_iterator::gmio_stl_occmesh_datasource_iterator(
|
||||
const Handle_MeshVS_DataSource &hnd)
|
||||
: m_data_src(hnd.operator->()),
|
||||
m_element_coords(1, 9)
|
||||
{
|
||||
if (m_data_src != NULL)
|
||||
m_element_it.Initialize(m_data_src->GetAllElements());
|
||||
}
|
||||
#endif /* GMIO_SUPPORT_STL_OCC_NO_MESHVS_DATASOURCE */
|
@ -13,7 +13,7 @@
|
||||
** "http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html".
|
||||
****************************************************************************/
|
||||
|
||||
/*! \file stl_occ.h
|
||||
/*! \file stl_occ_mesh.h
|
||||
* Support of OpenCascade's StlMesh_Mesh
|
||||
*
|
||||
* \addtogroup gmio_support
|
||||
@ -24,8 +24,8 @@
|
||||
# error C++ compiler required
|
||||
#endif
|
||||
|
||||
#ifndef GMIO_SUPPORT_STL_OCC_H
|
||||
#define GMIO_SUPPORT_STL_OCC_H
|
||||
#ifndef GMIO_SUPPORT_STL_OCC_MESH_H
|
||||
#define GMIO_SUPPORT_STL_OCC_MESH_H
|
||||
|
||||
#include "support_global.h"
|
||||
#include "../gmio_stl/stl_mesh.h"
|
||||
@ -36,11 +36,37 @@
|
||||
#include <StlMesh_SequenceOfMeshTriangle.hxx>
|
||||
#include <TColgp_SequenceOfXYZ.hxx>
|
||||
|
||||
#ifndef GMIO_SUPPORT_STL_OCC_NO_MESHVS_DATASOURCE
|
||||
# include <MeshVS_DataSource.hxx>
|
||||
# include <TColStd_Array1OfReal.hxx>
|
||||
# include <TColStd_MapIteratorOfPackedMapOfInteger.hxx>
|
||||
#endif // !GMIO_SUPPORT_STL_OCC_NO_MESHVS_DATASOURCE
|
||||
struct gmio_stl_occmesh_iterator;
|
||||
|
||||
/*! Returns a gmio_stl_mesh mapped to the OpenCascade mesh in iterator \p it
|
||||
*
|
||||
* The mesh's cookie will point to \c &it so the lifescope of the corresponding
|
||||
* object must be at least as longer as the returned gmio_stl_mesh.
|
||||
*
|
||||
* Example of use:
|
||||
* \code{.cpp}
|
||||
* Handle_StlMesh_Mesh occmesh = ...;
|
||||
* const gmio_stl_occmesh_iterator it(occmesh);
|
||||
* const gmio_stl_mesh mesh = gmio_stl_occmesh(it);
|
||||
* gmio_stl_write_file(stl_format, filepath, &mesh, &options);
|
||||
* \endcode
|
||||
*/
|
||||
gmio_stl_mesh gmio_stl_occmesh(const gmio_stl_occmesh_iterator& it);
|
||||
|
||||
/*! Returns a gmio_stl_mesh_creator that will build a new domain in a
|
||||
* StlMesh_Mesh object
|
||||
*
|
||||
* The creator's cookie will point \p mesh
|
||||
*/
|
||||
gmio_stl_mesh_creator gmio_stl_occmesh_creator(StlMesh_Mesh* mesh);
|
||||
|
||||
/*! Same as gmio_stl_occmesh_creator(StlMesh_Mesh*) but takes a handle
|
||||
*
|
||||
* The creator's cookie will point to the internal data(ie StlMesh_Mesh*) of
|
||||
* handle \p hnd
|
||||
*/
|
||||
gmio_stl_mesh_creator gmio_stl_occmesh_creator(const Handle_StlMesh_Mesh& hnd);
|
||||
|
||||
|
||||
/*! Forward iterator over the triangles of OpenCascade's StlMesh_Mesh
|
||||
*
|
||||
@ -73,80 +99,6 @@ private:
|
||||
uint32_t m_domain_last_tri_id;
|
||||
};
|
||||
|
||||
/*! Returns a gmio_stl_mesh mapped to the OpenCascade mesh in iterator \p it
|
||||
*
|
||||
* The mesh's cookie will point to \c &it so the lifescope of the corresponding
|
||||
* object must be at least as longer as the returned gmio_stl_mesh.
|
||||
*
|
||||
* Example of use:
|
||||
* \code{.cpp}
|
||||
* Handle_StlMesh_Mesh occmesh = ...;
|
||||
* const gmio_stl_occmesh_iterator it(occmesh);
|
||||
* const gmio_stl_mesh mesh = gmio_stl_occmesh(it);
|
||||
* gmio_stl_write_file(stl_format, filepath, &mesh, &options);
|
||||
* \endcode
|
||||
*/
|
||||
gmio_stl_mesh gmio_stl_occmesh(const gmio_stl_occmesh_iterator& it);
|
||||
|
||||
#ifndef GMIO_SUPPORT_STL_OCC_NO_MESHVS_DATASOURCE
|
||||
/*! Forward iterator over the triangles of OpenCascade's MeshVS_DataSource
|
||||
*
|
||||
* It is used to iterate efficiently over the elements of a MeshVS_DataSource
|
||||
* object.\n
|
||||
* Each element should be of type MeshVS_ET_Face and made of 3 nodes.
|
||||
*
|
||||
* Don't use API of this class, it's intended to gmio_stl_mesh()
|
||||
*/
|
||||
struct gmio_stl_occmesh_datasource_iterator
|
||||
{
|
||||
gmio_stl_occmesh_datasource_iterator();
|
||||
gmio_stl_occmesh_datasource_iterator(const MeshVS_DataSource* data_src);
|
||||
gmio_stl_occmesh_datasource_iterator(const Handle_MeshVS_DataSource& hnd);
|
||||
|
||||
inline void move_to_next_tri();
|
||||
inline int current_element_key() const;
|
||||
inline TColStd_Array1OfReal& cached_element_coords();
|
||||
inline const MeshVS_DataSource* data_src() const;
|
||||
|
||||
private:
|
||||
const MeshVS_DataSource* m_data_src;
|
||||
TColStd_MapIteratorOfPackedMapOfInteger m_element_it;
|
||||
TColStd_Array1OfReal m_element_coords;
|
||||
};
|
||||
|
||||
/*! Returns a gmio_stl_mesh mapped to the OpenCascade mesh data-source in
|
||||
* iterator \p it
|
||||
*
|
||||
* The mesh's cookie will point to \c &it so the lifescope of the corresponding
|
||||
* object must be at least as longer as the returned gmio_stl_mesh.
|
||||
*
|
||||
* Example of use:
|
||||
* \code{.cpp}
|
||||
* Handle_MeshVS_Mesh mesh = ...;
|
||||
* const gmio_stl_occmesh_datasource_iterator it(mesh->GetDataSource());
|
||||
* const gmio_stl_mesh mesh = gmio_stl_occmesh(it);
|
||||
* gmio_stl_write_file(stl_format, filepath, &mesh, &options);
|
||||
* \endcode
|
||||
*/
|
||||
gmio_stl_mesh gmio_stl_occmesh(const gmio_stl_occmesh_datasource_iterator& it);
|
||||
#endif // !GMIO_SUPPORT_STL_OCC_NO_MESHVS_DATASOURCE
|
||||
|
||||
/*! Returns a gmio_stl_mesh_creator that will build a new domain in a
|
||||
* StlMesh_Mesh object
|
||||
*
|
||||
* The creator's cookie will point \p mesh
|
||||
*/
|
||||
gmio_stl_mesh_creator gmio_stl_occmesh_creator(StlMesh_Mesh* mesh);
|
||||
|
||||
/*! Same as gmio_stl_occmesh_creator(StlMesh_Mesh*) but takes a handle
|
||||
*
|
||||
* The creator's cookie will point to the internal data(ie StlMesh_Mesh*) of
|
||||
* handle \p hnd
|
||||
*/
|
||||
gmio_stl_mesh_creator gmio_stl_occmesh_creator(const Handle_StlMesh_Mesh& hnd);
|
||||
|
||||
|
||||
|
||||
#ifndef DOXYGEN
|
||||
|
||||
/*
|
||||
@ -166,21 +118,7 @@ const TColgp_SequenceOfXYZ &gmio_stl_occmesh_iterator::domain_vertices() const
|
||||
const StlMesh_Mesh *gmio_stl_occmesh_iterator::mesh() const
|
||||
{ return m_mesh; }
|
||||
|
||||
#ifndef GMIO_SUPPORT_STL_OCC_NO_MESHVS_DATASOURCE
|
||||
void gmio_stl_occmesh_datasource_iterator::move_to_next_tri()
|
||||
{ m_element_it.Next(); }
|
||||
|
||||
int gmio_stl_occmesh_datasource_iterator::current_element_key() const
|
||||
{ return m_element_it.Key(); }
|
||||
|
||||
TColStd_Array1OfReal& gmio_stl_occmesh_datasource_iterator::cached_element_coords()
|
||||
{ return m_element_coords; }
|
||||
|
||||
const MeshVS_DataSource* gmio_stl_occmesh_datasource_iterator::data_src() const
|
||||
{ return m_data_src; }
|
||||
#endif /* GMIO_SUPPORT_STL_OCC_NO_MESHVS_DATASOURCE */
|
||||
|
||||
#endif /* !DOXYGEN */
|
||||
|
||||
#endif /* GMIO_SUPPORT_STL_OCC_H */
|
||||
#endif /* GMIO_SUPPORT_STL_OCC_MESH_H */
|
||||
/*! @} */
|
90
src/gmio_support/stl_occ_meshvs.cpp
Normal file
90
src/gmio_support/stl_occ_meshvs.cpp
Normal file
@ -0,0 +1,90 @@
|
||||
/****************************************************************************
|
||||
** gmio
|
||||
** Copyright Fougue (2 Mar. 2015)
|
||||
** contact@fougue.pro
|
||||
**
|
||||
** This software is a reusable library whose purpose is to provide complete
|
||||
** I/O support for various CAD file formats (eg. STL)
|
||||
**
|
||||
** This software is governed by the CeCILL-B license under French law and
|
||||
** abiding by the rules of distribution of free software. You can use,
|
||||
** modify and/ or redistribute the software under the terms of the CeCILL-B
|
||||
** license as circulated by CEA, CNRS and INRIA at the following URL
|
||||
** "http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html".
|
||||
****************************************************************************/
|
||||
|
||||
#include <gmio_support/stl_occ_meshvs.h>
|
||||
|
||||
#include "stl_occ_utils.h"
|
||||
|
||||
#include <MeshVS_DataSource.hxx>
|
||||
#include <TColStd_PackedMapOfInteger.hxx>
|
||||
|
||||
namespace internal {
|
||||
|
||||
static void occmesh_datasource_get_triangle(
|
||||
const void* cookie, uint32_t /*tri_id*/, gmio_stl_triangle* tri)
|
||||
{
|
||||
void* wcookie = const_cast<void*>(cookie);
|
||||
gmio_stl_occmesh_datasource_iterator* it =
|
||||
static_cast<gmio_stl_occmesh_datasource_iterator*>(wcookie);
|
||||
const MeshVS_DataSource* data_src = it->data_src();
|
||||
|
||||
int node_count;
|
||||
MeshVS_EntityType entity_type;
|
||||
const Standard_Boolean get_geom_ok =
|
||||
data_src->GetGeom(
|
||||
it->current_element_key(),
|
||||
Standard_True, // Is element
|
||||
it->cached_element_coords(),
|
||||
node_count,
|
||||
entity_type);
|
||||
if (get_geom_ok && node_count == 3) {
|
||||
// Copy vertex coords
|
||||
const TColStd_Array1OfReal& in_coords_array = it->cached_element_coords();
|
||||
float* out_coords_ptr = &tri->v1.x;
|
||||
for (int i = 0; i < 9; ++i)
|
||||
out_coords_ptr[i] = static_cast<float>(in_coords_array.Value(i + 1));
|
||||
// Copy normal coords
|
||||
double nx, ny, nz;
|
||||
data_src->GetNormal(it->current_element_key(), 3, nx, ny, nz);
|
||||
gmio_stl_occ_copy_xyz(&tri->n, nx, ny, nz);
|
||||
}
|
||||
it->move_to_next_tri();
|
||||
}
|
||||
|
||||
} // namespace internal
|
||||
|
||||
gmio_stl_mesh gmio_stl_occmesh(const gmio_stl_occmesh_datasource_iterator& it)
|
||||
{
|
||||
gmio_stl_mesh mesh = {};
|
||||
mesh.cookie = ⁢
|
||||
mesh.triangle_count =
|
||||
it.data_src() != NULL ?
|
||||
it.data_src()->GetAllElements().Extent() : 0;
|
||||
mesh.func_get_triangle = internal::occmesh_datasource_get_triangle;
|
||||
return mesh;
|
||||
}
|
||||
|
||||
gmio_stl_occmesh_datasource_iterator::gmio_stl_occmesh_datasource_iterator()
|
||||
: m_data_src(NULL),
|
||||
m_element_coords(1, 1)
|
||||
{ }
|
||||
|
||||
gmio_stl_occmesh_datasource_iterator::gmio_stl_occmesh_datasource_iterator(
|
||||
const MeshVS_DataSource *data_src)
|
||||
: m_data_src(data_src),
|
||||
m_element_coords(1, 9)
|
||||
{
|
||||
if (m_data_src != NULL)
|
||||
m_element_it.Initialize(m_data_src->GetAllElements());
|
||||
}
|
||||
|
||||
gmio_stl_occmesh_datasource_iterator::gmio_stl_occmesh_datasource_iterator(
|
||||
const Handle_MeshVS_DataSource &hnd)
|
||||
: m_data_src(hnd.operator->()),
|
||||
m_element_coords(1, 9)
|
||||
{
|
||||
if (m_data_src != NULL)
|
||||
m_element_it.Initialize(m_data_src->GetAllElements());
|
||||
}
|
102
src/gmio_support/stl_occ_meshvs.h
Normal file
102
src/gmio_support/stl_occ_meshvs.h
Normal file
@ -0,0 +1,102 @@
|
||||
/****************************************************************************
|
||||
** gmio
|
||||
** Copyright Fougue (2 Mar. 2015)
|
||||
** contact@fougue.pro
|
||||
**
|
||||
** This software is a reusable library whose purpose is to provide complete
|
||||
** I/O support for various CAD file formats (eg. STL)
|
||||
**
|
||||
** This software is governed by the CeCILL-B license under French law and
|
||||
** abiding by the rules of distribution of free software. You can use,
|
||||
** modify and/ or redistribute the software under the terms of the CeCILL-B
|
||||
** license as circulated by CEA, CNRS and INRIA at the following URL
|
||||
** "http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html".
|
||||
****************************************************************************/
|
||||
|
||||
/*! \file stl_occ.h
|
||||
* Support of OpenCascade's MeshVS_DataSource
|
||||
*
|
||||
* \addtogroup gmio_support
|
||||
* @{
|
||||
*/
|
||||
|
||||
#ifndef __cplusplus
|
||||
# error C++ compiler required
|
||||
#endif
|
||||
|
||||
#ifndef GMIO_SUPPORT_STL_OCC_MESHVS_H
|
||||
#define GMIO_SUPPORT_STL_OCC_MESHVS_H
|
||||
|
||||
#include "support_global.h"
|
||||
#include "../gmio_stl/stl_mesh.h"
|
||||
#include "../gmio_stl/stl_mesh_creator.h"
|
||||
|
||||
#include <MeshVS_DataSource.hxx>
|
||||
#include <TColStd_Array1OfReal.hxx>
|
||||
#include <TColStd_MapIteratorOfPackedMapOfInteger.hxx>
|
||||
|
||||
struct gmio_stl_occmesh_datasource_iterator;
|
||||
|
||||
/*! Returns a gmio_stl_mesh mapped to the OpenCascade mesh data-source in
|
||||
* iterator \p it
|
||||
*
|
||||
* The mesh's cookie will point to \c &it so the lifescope of the corresponding
|
||||
* object must be at least as longer as the returned gmio_stl_mesh.
|
||||
*
|
||||
* Example of use:
|
||||
* \code{.cpp}
|
||||
* Handle_MeshVS_Mesh mesh = ...;
|
||||
* const gmio_stl_occmesh_datasource_iterator it(mesh->GetDataSource());
|
||||
* const gmio_stl_mesh mesh = gmio_stl_occmesh(it);
|
||||
* gmio_stl_write_file(stl_format, filepath, &mesh, &options);
|
||||
* \endcode
|
||||
*/
|
||||
gmio_stl_mesh gmio_stl_occmesh(const gmio_stl_occmesh_datasource_iterator& it);
|
||||
|
||||
/*! Forward iterator over the triangles of OpenCascade's MeshVS_DataSource
|
||||
*
|
||||
* It is used to iterate efficiently over the elements of a MeshVS_DataSource
|
||||
* object.\n
|
||||
* Each element should be of type MeshVS_ET_Face and made of 3 nodes.
|
||||
*
|
||||
* Don't use API of this class, it's intended to gmio_stl_mesh()
|
||||
*/
|
||||
struct gmio_stl_occmesh_datasource_iterator
|
||||
{
|
||||
gmio_stl_occmesh_datasource_iterator();
|
||||
explicit gmio_stl_occmesh_datasource_iterator(const MeshVS_DataSource* data_src);
|
||||
explicit gmio_stl_occmesh_datasource_iterator(const Handle_MeshVS_DataSource& hnd);
|
||||
|
||||
inline void move_to_next_tri();
|
||||
inline int current_element_key() const;
|
||||
inline TColStd_Array1OfReal& cached_element_coords();
|
||||
inline const MeshVS_DataSource* data_src() const;
|
||||
|
||||
private:
|
||||
const MeshVS_DataSource* m_data_src;
|
||||
TColStd_MapIteratorOfPackedMapOfInteger m_element_it;
|
||||
TColStd_Array1OfReal m_element_coords;
|
||||
};
|
||||
|
||||
#ifndef DOXYGEN
|
||||
|
||||
/*
|
||||
* Implementation
|
||||
*/
|
||||
|
||||
void gmio_stl_occmesh_datasource_iterator::move_to_next_tri()
|
||||
{ m_element_it.Next(); }
|
||||
|
||||
int gmio_stl_occmesh_datasource_iterator::current_element_key() const
|
||||
{ return m_element_it.Key(); }
|
||||
|
||||
TColStd_Array1OfReal& gmio_stl_occmesh_datasource_iterator::cached_element_coords()
|
||||
{ return m_element_coords; }
|
||||
|
||||
const MeshVS_DataSource* gmio_stl_occmesh_datasource_iterator::data_src() const
|
||||
{ return m_data_src; }
|
||||
|
||||
#endif /* !DOXYGEN */
|
||||
|
||||
#endif /* GMIO_SUPPORT_STL_OCC_MESHVS_H */
|
||||
/*! @} */
|
46
src/gmio_support/stl_occ_utils.h
Normal file
46
src/gmio_support/stl_occ_utils.h
Normal file
@ -0,0 +1,46 @@
|
||||
/****************************************************************************
|
||||
** gmio
|
||||
** Copyright Fougue (2 Mar. 2015)
|
||||
** contact@fougue.pro
|
||||
**
|
||||
** This software is a reusable library whose purpose is to provide complete
|
||||
** I/O support for various CAD file formats (eg. STL)
|
||||
**
|
||||
** This software is governed by the CeCILL-B license under French law and
|
||||
** abiding by the rules of distribution of free software. You can use,
|
||||
** modify and/ or redistribute the software under the terms of the CeCILL-B
|
||||
** license as circulated by CEA, CNRS and INRIA at the following URL
|
||||
** "http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html".
|
||||
****************************************************************************/
|
||||
|
||||
/*! \file stl_occ_utils.h
|
||||
* Utility functions for interfacing OpenCascade in gmio
|
||||
*
|
||||
* \addtogroup gmio_support
|
||||
* @{
|
||||
*/
|
||||
|
||||
#ifndef GMIO_SUPPORT_STL_OCC_UTILS_H
|
||||
#define GMIO_SUPPORT_STL_OCC_UTILS_H
|
||||
|
||||
#include <gmio_support/support_global.h>
|
||||
|
||||
#include <gmio_core/vecgeom.h>
|
||||
#include <gp_XYZ.hxx>
|
||||
|
||||
GMIO_INLINE void gmio_stl_occ_copy_xyz(
|
||||
gmio_vec3f* vec, double x, double y, double z)
|
||||
{
|
||||
vec->x = static_cast<float>(x);
|
||||
vec->y = static_cast<float>(y);
|
||||
vec->z = static_cast<float>(z);
|
||||
}
|
||||
|
||||
GMIO_INLINE void gmio_stl_occ_copy_xyz(
|
||||
gmio_vec3f* vec, const gp_XYZ& coords)
|
||||
{
|
||||
gmio_stl_occ_copy_xyz(vec, coords.X(), coords.Y(), coords.Z());
|
||||
}
|
||||
|
||||
#endif /* GMIO_SUPPORT_STL_OCC_UTILS_H */
|
||||
/*! @} */
|
@ -34,7 +34,8 @@ add_executable(
|
||||
qt/QtCore/QIODevice
|
||||
qt/QtCore/QString
|
||||
qt/QtCore/QtGlobal
|
||||
../../src/gmio_support/stl_occ.cpp
|
||||
../../src/gmio_support/stl_occ_mesh.cpp
|
||||
../../src/gmio_support/stl_occ_meshvs.cpp
|
||||
../../src/gmio_support/stream_qt.cpp)
|
||||
target_link_libraries(fake_support gmio)
|
||||
include_directories(
|
||||
|
@ -1,5 +1,5 @@
|
||||
#include "../../src/gmio_stl/stl_io.h"
|
||||
#include "../../src/gmio_support/stl_occ.h"
|
||||
#include "../../src/gmio_support/stl_occ_mesh.h"
|
||||
#include "../../src/gmio_support/stream_qt.h"
|
||||
#include "../../src/gmio_support/stream_cpp.h"
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user