Merge branch 'hotfix-0.3.1'
This commit is contained in:
commit
2347c9d706
@ -39,7 +39,7 @@ include(CMakeDependentOption)
|
||||
project(gmio)
|
||||
set(GMIO_VERSION_MAJOR 0)
|
||||
set(GMIO_VERSION_MINOR 3)
|
||||
set(GMIO_VERSION_PATCH 0)
|
||||
set(GMIO_VERSION_PATCH 1)
|
||||
set(GMIO_VERSION
|
||||
${GMIO_VERSION_MAJOR}.${GMIO_VERSION_MINOR}.${GMIO_VERSION_PATCH})
|
||||
|
||||
|
@ -9,7 +9,7 @@
|
||||
</a>
|
||||
[](https://coveralls.io/github/fougue/gmio?branch=master)
|
||||
[](https://github.com/fougue/gmio/blob/master/LICENSE.txt)
|
||||
[](https://github.com/fougue/gmio/releases)
|
||||
[](https://github.com/fougue/gmio/releases)
|
||||
|
||||
|
||||
C library for geometry input/output
|
||||
|
@ -156,22 +156,34 @@ static void RWStl_WriteBinary(const void* filepath)
|
||||
|
||||
static void StlAPI_WriteAscii(const void* filepath)
|
||||
{
|
||||
StlAPI_Writer writer;
|
||||
writer.ASCIIMode() = Standard_True;
|
||||
const char* cfilepath = static_cast<const char*>(filepath);
|
||||
const StlAPI_ErrorStatus err = writer.Write(BmkBRep::inputShape, cfilepath);
|
||||
if (err != StlAPI_StatusOK)
|
||||
std::cerr << "StlAPI_Writer::Write() error: " << err << std::endl;
|
||||
if (!BmkBRep::inputShape.IsNull()) {
|
||||
StlAPI_Writer writer;
|
||||
writer.ASCIIMode() = Standard_True;
|
||||
const char* cfilepath = static_cast<const char*>(filepath);
|
||||
#if OCC_VERSION_HEX >= 0x060900
|
||||
const StlAPI_ErrorStatus err = writer.Write(BmkBRep::inputShape, cfilepath);
|
||||
if (err != StlAPI_StatusOK)
|
||||
std::cerr << "StlAPI_Writer::Write() error: " << err << std::endl;
|
||||
#else
|
||||
writer.Write(BmkBRep::inputShape, cfilepath);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
static void StlAPI_WriteBinary(const void* filepath)
|
||||
{
|
||||
StlAPI_Writer writer;
|
||||
writer.ASCIIMode() = Standard_False;
|
||||
const char* cfilepath = static_cast<const char*>(filepath);
|
||||
const StlAPI_ErrorStatus err = writer.Write(BmkBRep::inputShape, cfilepath);
|
||||
if (err != StlAPI_StatusOK)
|
||||
std::cerr << "StlAPI_Writer::Write() error: " << err << std::endl;
|
||||
if (!BmkBRep::inputShape.IsNull()) {
|
||||
StlAPI_Writer writer;
|
||||
writer.ASCIIMode() = Standard_False;
|
||||
const char* cfilepath = static_cast<const char*>(filepath);
|
||||
#if OCC_VERSION_HEX >= 0x060900
|
||||
const StlAPI_ErrorStatus err = writer.Write(BmkBRep::inputShape, cfilepath);
|
||||
if (err != StlAPI_StatusOK)
|
||||
std::cerr << "StlAPI_Writer::Write() error: " << err << std::endl;
|
||||
#else
|
||||
writer.Write(BmkBRep::inputShape, cfilepath);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace BmkOcc
|
||||
|
@ -45,13 +45,6 @@ add_executable(occstl_write_file
|
||||
occstl_write_file.cpp ${SUPPORT_STL_OCC_FILES})
|
||||
add_executable(occstl_redefine_mesh_creator
|
||||
occstl_redefine_mesh_creator.cpp ${SUPPORT_STL_OCC_FILES})
|
||||
if(CMAKE_COMPILER_IS_GNUCC)
|
||||
set_target_properties(
|
||||
occstl_read_file
|
||||
occstl_write_file
|
||||
occstl_redefine_mesh_creator
|
||||
PROPERTIES COMPILE_FLAGS "-std=c++0x")
|
||||
endif()
|
||||
|
||||
# gmio STL
|
||||
add_executable(stl_get_infos stl_get_infos.c)
|
||||
|
@ -31,6 +31,7 @@
|
||||
|
||||
#include "../../gmio_core/error.h"
|
||||
#include "../../gmio_core/internal/byte_swap.h"
|
||||
#include "../../gmio_core/internal/helper_stream.h"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
|
@ -38,13 +38,9 @@
|
||||
#define GMIO_STL_INFOS_H
|
||||
|
||||
#include "stl_global.h"
|
||||
|
||||
#include "../gmio_core/internal/helper_stream.h"
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
#include "stl_format.h"
|
||||
#include "stlb_header.h"
|
||||
#include <stddef.h>
|
||||
|
||||
/*! Informations retrieved by gmio_stl_infos_get() */
|
||||
struct gmio_stl_infos
|
||||
|
@ -61,32 +61,34 @@ gmio_stl_mesh_occshape::gmio_stl_mesh_occshape(const TopoDS_Shape& shape)
|
||||
}
|
||||
|
||||
// Fill face and triangle datas
|
||||
m_vec_face_data.reserve(face_count);
|
||||
m_vec_triangle_data.reserve(this->triangle_count);
|
||||
std::size_t vec_face_id = 0;
|
||||
std::size_t vec_tri_id = 0;
|
||||
m_vec_face_data.resize(face_count);
|
||||
m_vec_triangle_data.resize(this->triangle_count);
|
||||
for (TopExp_Explorer expl(shape, TopAbs_FACE); expl.More(); expl.Next()) {
|
||||
const TopoDS_Face& topoface = TopoDS::Face(expl.Current());
|
||||
TopLoc_Location loc;
|
||||
const Handle_Poly_Triangulation& hnd_face_poly =
|
||||
BRep_Tool::Triangulation(topoface, loc);
|
||||
if (!hnd_face_poly.IsNull()) {
|
||||
{ // Add next face_data
|
||||
struct face_data facedata;
|
||||
facedata.trsf = loc.Transformation();
|
||||
facedata.is_reversed = (topoface.Orientation() == TopAbs_REVERSED);
|
||||
if (facedata.trsf.IsNegative())
|
||||
facedata.is_reversed = !facedata.is_reversed;
|
||||
facedata.ptr_nodes = &hnd_face_poly->Nodes();
|
||||
m_vec_face_data.push_back(std::move(facedata));
|
||||
}
|
||||
const struct face_data& last_facedata = m_vec_face_data.back();
|
||||
// Add triangle_datas
|
||||
// Copy next face_data
|
||||
struct face_data& facedata = m_vec_face_data.at(vec_face_id);
|
||||
facedata.trsf = loc.Transformation();
|
||||
facedata.is_reversed = (topoface.Orientation() == TopAbs_REVERSED);
|
||||
if (facedata.trsf.IsNegative())
|
||||
facedata.is_reversed = !facedata.is_reversed;
|
||||
facedata.ptr_nodes = &hnd_face_poly->Nodes();
|
||||
|
||||
// Copy triangle_datas
|
||||
const Poly_Array1OfTriangle& vec_face_tri = hnd_face_poly->Triangles();
|
||||
for (int i = vec_face_tri.Lower(); i <= vec_face_tri.Upper(); ++i) {
|
||||
struct triangle_data tridata;
|
||||
struct triangle_data& tridata = m_vec_triangle_data.at(vec_tri_id);
|
||||
tridata.ptr_triangle = &vec_face_tri.Value(i);
|
||||
tridata.ptr_face_data = &last_facedata;
|
||||
m_vec_triangle_data.push_back(std::move(tridata));
|
||||
tridata.ptr_face_data = &facedata;
|
||||
++vec_tri_id;
|
||||
}
|
||||
|
||||
++vec_face_id;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -95,18 +95,24 @@ void gmio_stl_mesh_occmesh::init_cache()
|
||||
this->triangle_count += m_mesh->NbTriangles(dom_id);
|
||||
|
||||
// Fill vector of triangle data
|
||||
m_vec_triangle_data.reserve(this->triangle_count);
|
||||
m_vec_domain_data.resize(domain_count);
|
||||
m_vec_triangle_data.resize(this->triangle_count);
|
||||
std::size_t vec_tri_id = 0;
|
||||
for (int dom_id = 1; dom_id <= domain_count; ++dom_id) {
|
||||
// Cache vertex indexes
|
||||
// TColgp_SequenceOfXYZ::Value(int) is slow(linear search)
|
||||
const TColgp_SequenceOfXYZ& seq_vertices = m_mesh->Vertices(dom_id);
|
||||
struct domain_data domdata;
|
||||
domdata.vec_coords.reserve(seq_vertices.Size());
|
||||
struct domain_data& domdata = m_vec_domain_data.at(dom_id - 1);
|
||||
domdata.vec_coords.reserve(seq_vertices.Length());
|
||||
#if OCC_VERSION_HEX >= 0x070000
|
||||
typedef TColgp_SequenceOfXYZ::const_iterator ConstIterSeqXYZ;
|
||||
const ConstIterSeqXYZ seq_end = seq_vertices.cend();
|
||||
for (ConstIterSeqXYZ it = seq_vertices.cbegin(); it != seq_end; ++it)
|
||||
domdata.vec_coords.push_back(&(*it));
|
||||
m_vec_domain_data.push_back(std::move(domdata));
|
||||
#else
|
||||
for (int i = 1; i <= seq_vertices.Length(); ++i)
|
||||
domdata.vec_coords.push_back(&seq_vertices.Value(i));
|
||||
#endif
|
||||
|
||||
// Cache triangles
|
||||
const StlMesh_SequenceOfMeshTriangle& seq_triangles =
|
||||
@ -114,10 +120,10 @@ void gmio_stl_mesh_occmesh::init_cache()
|
||||
for (int tri_id = 1; tri_id <= seq_triangles.Length(); ++tri_id) {
|
||||
const Handle_StlMesh_MeshTriangle& hnd_occtri =
|
||||
seq_triangles.Value(tri_id);
|
||||
struct triangle_data tridata;
|
||||
struct triangle_data& tridata = m_vec_triangle_data.at(vec_tri_id);
|
||||
tridata.ptr_triangle = hnd_occtri.operator->();
|
||||
tridata.ptr_domain = &m_vec_domain_data.back();
|
||||
m_vec_triangle_data.push_back(std::move(tridata));
|
||||
tridata.ptr_domain = &domdata;
|
||||
++vec_tri_id;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -99,7 +99,7 @@ static int gmio_stream_qiodevice_set_pos(
|
||||
|
||||
struct gmio_stream gmio_stream_qiodevice(QIODevice* device)
|
||||
{
|
||||
struct gmio_stream stream = {0};
|
||||
struct gmio_stream stream = {};
|
||||
stream.cookie = device;
|
||||
stream.func_at_end = gmio_stream_qiodevice_at_end;
|
||||
stream.func_error = gmio_stream_qiodevice_error;
|
||||
|
@ -48,9 +48,3 @@ include_directories(
|
||||
${CMAKE_SOURCE_DIR}/src
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/opencascade
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/qt)
|
||||
|
||||
if(CMAKE_COMPILER_IS_GNUCC)
|
||||
set_target_properties(
|
||||
fake_support
|
||||
PROPERTIES COMPILE_FLAGS "-std=c++0x")
|
||||
endif()
|
||||
|
@ -21,6 +21,7 @@ public:
|
||||
};
|
||||
|
||||
int Size() const { return 0; }
|
||||
int Length() const { return this->Size(); }
|
||||
|
||||
const gp_XYZ& Value(const int /*Index*/) const
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user