mirror of
https://github.com/QIDITECH/QIDISlicer.git
synced 2026-02-02 00:48:43 +03:00
update src
This commit is contained in:
@@ -19,7 +19,7 @@ include(GenerateExportHeader)
|
||||
|
||||
generate_export_header(OCCTWrapper)
|
||||
|
||||
find_package(OpenCASCADE 7.6.2 REQUIRED)
|
||||
find_package(OpenCASCADE 7.6.1 REQUIRED)
|
||||
|
||||
set(OCCT_LIBS
|
||||
TKXDESTEP
|
||||
@@ -55,6 +55,7 @@ slic3r_remap_configs("${OCCT_LIBS}" RelWithDebInfo Release)
|
||||
target_include_directories(OCCTWrapper PRIVATE ${CMAKE_CURRENT_BINARY_DIR})
|
||||
target_include_directories(OCCTWrapper PUBLIC ${OpenCASCADE_INCLUDE_DIR})
|
||||
target_link_libraries(OCCTWrapper ${OCCT_LIBS})
|
||||
target_link_libraries(OCCTWrapper libslic3r admesh)
|
||||
|
||||
include(GNUInstallDirs)
|
||||
|
||||
|
||||
@@ -21,6 +21,8 @@
|
||||
#include "BRepBuilderAPI_Transform.hxx"
|
||||
#include "TopExp_Explorer.hxx"
|
||||
#include "BRep_Tool.hxx"
|
||||
#include "admesh/stl.h"
|
||||
#include "libslic3r/Point.hpp"
|
||||
|
||||
const double STEP_TRANS_CHORD_ERROR = 0.005;
|
||||
const double STEP_TRANS_ANGLE_RES = 1;
|
||||
@@ -126,24 +128,13 @@ try {
|
||||
std::string obj_name((last_slash == nullptr) ? path : last_slash + 1);
|
||||
res->object_name = obj_name;
|
||||
|
||||
for (size_t i = 0; i < namedSolids.size(); ++i) {
|
||||
//BBS:if (proFn) {
|
||||
// proFn(LOAD_STEP_STAGE_GET_MESH, i, namedSolids.size(), cb_cancel);
|
||||
// if (cb_cancel) {
|
||||
// model->delete_object(new_object);
|
||||
// shapeTool.reset(nullptr);
|
||||
// application->Close(document);
|
||||
// return false;
|
||||
// }
|
||||
//}
|
||||
|
||||
for (const NamedSolid &namedSolid : namedSolids) {
|
||||
BRepMesh_IncrementalMesh mesh(namedSolid.solid, STEP_TRANS_CHORD_ERROR, false, STEP_TRANS_ANGLE_RES, true);
|
||||
res->volumes.emplace_back();
|
||||
auto& vertices = res->volumes.back().vertices;
|
||||
auto& indices = res->volumes.back().indices;
|
||||
|
||||
BRepMesh_IncrementalMesh mesh(namedSolids[i].solid, STEP_TRANS_CHORD_ERROR, false, STEP_TRANS_ANGLE_RES, true);
|
||||
|
||||
for (TopExp_Explorer anExpSF(namedSolids[i].solid, TopAbs_FACE); anExpSF.More(); anExpSF.Next()) {
|
||||
std::vector<Vec3f> vertices;
|
||||
std::vector<stl_facet> &facets = res->volumes.back().facets;
|
||||
for (TopExp_Explorer anExpSF(namedSolid.solid, TopAbs_FACE); anExpSF.More(); anExpSF.Next()) {
|
||||
const int aNodeOffset = int(vertices.size());
|
||||
const TopoDS_Shape& aFace = anExpSF.Current();
|
||||
TopLoc_Location aLoc;
|
||||
@@ -156,27 +147,33 @@ try {
|
||||
for (Standard_Integer aNodeIter = 1; aNodeIter <= aTriangulation->NbNodes(); ++aNodeIter) {
|
||||
gp_Pnt aPnt = aTriangulation->Node(aNodeIter);
|
||||
aPnt.Transform(aTrsf);
|
||||
vertices.push_back({float(aPnt.X()), float(aPnt.Y()), float(aPnt.Z())});
|
||||
vertices.emplace_back(std::move(Vec3f(float(aPnt.X()), float(aPnt.Y()), float(aPnt.Z()))));
|
||||
}
|
||||
// Now the indices.
|
||||
|
||||
// Now copy the facets.
|
||||
const TopAbs_Orientation anOrientation = anExpSF.Current().Orientation();
|
||||
for (Standard_Integer aTriIter = 1; aTriIter <= aTriangulation->NbTriangles(); ++aTriIter) {
|
||||
const int aTriangleOffet = int(facets.size());
|
||||
Poly_Triangle aTri = aTriangulation->Triangle(aTriIter);
|
||||
|
||||
Standard_Integer anId[3];
|
||||
aTri.Get(anId[0], anId[1], anId[2]);
|
||||
if (anOrientation == TopAbs_REVERSED)
|
||||
if (anOrientation == TopAbs_REVERSED) {
|
||||
std::swap(anId[1], anId[2]);
|
||||
}
|
||||
|
||||
// Account for the vertices we already have from previous faces.
|
||||
// anId is 1-based index !
|
||||
indices.push_back({anId[0] - 1 + aNodeOffset,
|
||||
anId[1] - 1 + aNodeOffset,
|
||||
anId[2] - 1 + aNodeOffset});
|
||||
stl_facet facet;
|
||||
facet.vertex[0] = vertices[anId[0] + aNodeOffset - 1];
|
||||
facet.vertex[1] = vertices[anId[1] + aNodeOffset - 1];
|
||||
facet.vertex[2] = vertices[anId[2] + aNodeOffset - 1];
|
||||
facet.normal = (facet.vertex[1] - facet.vertex[0]).cross(facet.vertex[2] - facet.vertex[1]).normalized();
|
||||
facet.extra[0] = 0;
|
||||
facet.extra[1] = 0;
|
||||
facets.emplace_back(std::move(facet));
|
||||
}
|
||||
}
|
||||
|
||||
res->volumes.back().volume_name = namedSolids[i].name;
|
||||
res->volumes.back().volume_name = namedSolid.name;
|
||||
|
||||
if (vertices.empty())
|
||||
res->volumes.pop_back();
|
||||
|
||||
@@ -6,12 +6,13 @@
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
struct stl_facet;
|
||||
|
||||
namespace Slic3r {
|
||||
|
||||
struct OCCTVolume {
|
||||
std::string volume_name;
|
||||
std::vector<std::array<float, 3>> vertices;
|
||||
std::vector<std::array<int, 3>> indices;
|
||||
std::string volume_name;
|
||||
std::vector<stl_facet> facets;
|
||||
};
|
||||
|
||||
struct OCCTResult {
|
||||
|
||||
Reference in New Issue
Block a user