mirror of
https://github.com/OrcaSlicer/OrcaSlicer.git
synced 2026-10-07 15:51:08 +00:00
* Add Missing Includes Across src/libslic3r Every libslic3r source and header now directly includes the headers declaring what it uses, rather than relying on the precompiled header or transitive includes. Generated with clang-tidy misc-include-cleaner, with libslic3r headers spelled libslic3r/... so they resolve outside the library's private include paths. MultiMaterialSegmentation.hpp, Support/SupportParameters.hpp and Format/STEP.hpp are made self-contained by hand. * Make the libslic3r Headers Compile on Their Own Each now includes, or forward-declares, what it uses instead of relying on what its includers happened to include first. Left out: I18N.hpp, which errors on purpose when included from GUI code, and VoxelizeCSGMesh.hpp and SLA/bicubic.h, which nothing includes and which no longer compile at all. * Add the Includes Missing From the Hand-Fixed libslic3r Headers clang-tidy would not edit these headers while they failed to compile on their own, so the first pass skipped them. With the headers now self-contained, a second pass adds the rest. * Keep Windows Setup Ahead of the Added libslic3r Includes Print.cpp and Thread.cpp open with a _WIN32 block that has to come first; without the precompiled header, Print.cpp otherwise reaches windows.h through OCCT with NONLS defined and boost/regex fails. OpenVDBUtils.cpp and SLA/SupportTreeBuilder.cpp had includes inside #ifndef NOMINMAX, which libslic3r defines on Windows, so those were skipped there. .clang-tidy also ignores the MSVC STL and UCRT internals, Boost.Multiprecision's fwd.hpp and CPython's Windows include directory. * Re-Add libslic3r Includes After the Clipper2 2.0.1 Migration Rebasing onto main took main's version of the files the Clipper2 migration rewrote, so their added includes are restored here, along with includes for main's new code. Clipper2's individual headers are now ignored by clang-tidy: they only build the Z variant through clipper2_z.hpp, which defines USINGZ first, so including clipper.core.h and the like directly broke ClipperZUtils.cpp.
144 lines
3.6 KiB
C++
144 lines
3.6 KiB
C++
#ifndef slic3r_Format_objparser_hpp_
|
|
#define slic3r_Format_objparser_hpp_
|
|
|
|
#include <string>
|
|
#include <vector>
|
|
#include <array>
|
|
#include <unordered_map>
|
|
#include <istream>
|
|
#include <memory>
|
|
|
|
namespace ObjParser {
|
|
|
|
struct ObjVertex
|
|
{
|
|
int coordIdx;
|
|
int textureCoordIdx;
|
|
int normalIdx;
|
|
};
|
|
|
|
inline bool operator==(const ObjVertex &v1, const ObjVertex &v2)
|
|
{
|
|
return v1.coordIdx == v2.coordIdx &&
|
|
v1.textureCoordIdx == v2.textureCoordIdx &&
|
|
v1.normalIdx == v2.normalIdx;
|
|
}
|
|
|
|
struct ObjUseMtl
|
|
{
|
|
int vertexIdxFirst;
|
|
int vertexIdxEnd{-1};
|
|
int face_start;
|
|
int face_end{-1};
|
|
std::string name;
|
|
};
|
|
|
|
struct ObjNewMtl
|
|
{
|
|
std::string name;
|
|
float Ns;
|
|
float Ni;
|
|
float d;
|
|
float illum;
|
|
float Tr{1.0f}; // Transmission
|
|
std::array<float, 3> Tf;
|
|
std::array<float, 3> Ka;
|
|
std::array<float, 3> Kd;
|
|
std::array<float, 3> Ks;
|
|
std::array<float, 3> Ke;
|
|
std::string map_Kd;//defalut png
|
|
};
|
|
|
|
inline bool operator==(const ObjUseMtl &v1, const ObjUseMtl &v2)
|
|
{
|
|
return v1.vertexIdxFirst == v2.vertexIdxFirst &&
|
|
v1.name.compare(v2.name) == 0;
|
|
}
|
|
|
|
struct ObjObject
|
|
{
|
|
int vertexIdxFirst;
|
|
std::string name;
|
|
};
|
|
|
|
inline bool operator==(const ObjObject &v1, const ObjObject &v2)
|
|
{
|
|
return
|
|
v1.vertexIdxFirst == v2.vertexIdxFirst &&
|
|
v1.name.compare(v2.name) == 0;
|
|
}
|
|
|
|
struct ObjGroup
|
|
{
|
|
int vertexIdxFirst;
|
|
std::string name;
|
|
};
|
|
|
|
inline bool operator==(const ObjGroup &v1, const ObjGroup &v2)
|
|
{
|
|
return v1.vertexIdxFirst == v2.vertexIdxFirst &&
|
|
v1.name.compare(v2.name) == 0;
|
|
}
|
|
|
|
struct ObjSmoothingGroup
|
|
{
|
|
int vertexIdxFirst;
|
|
int smoothingGroupID;
|
|
};
|
|
|
|
inline bool operator==(const ObjSmoothingGroup &v1, const ObjSmoothingGroup &v2)
|
|
{
|
|
return v1.vertexIdxFirst == v2.vertexIdxFirst &&
|
|
v1.smoothingGroupID == v2.smoothingGroupID;
|
|
}
|
|
#define OBJ_VERTEX_COLOR_ALPHA 6
|
|
#define OBJ_VERTEX_LENGTH 7 // x, y, z, color_x,color_y,color_z,color_w
|
|
#define OBJ_TEXCOORD_LENGTH 2 // u, v
|
|
#define ONE_FACE_SIZE 4//ONE_FACE format: f 8/4/6 7/3/6 6/2/6 -1/-1/-1
|
|
struct ObjData {
|
|
// Version of the data structure for load / store in the private binary format.
|
|
int version;
|
|
|
|
// x, y, z, color_x,color_y,color_z,color_w
|
|
std::vector<float> coordinates;
|
|
bool has_vertex_color{false};
|
|
// u, v
|
|
std::vector<float> textureCoordinates;
|
|
// x, y, z
|
|
std::vector<float> normals;
|
|
// u, v, w
|
|
std::vector<float> parameters;
|
|
|
|
std::vector<std::string> mtllibs;
|
|
std::vector<ObjUseMtl> usemtls;
|
|
std::vector<ObjObject> objects;
|
|
std::vector<ObjGroup> groups;
|
|
std::vector<ObjSmoothingGroup> smoothingGroups;
|
|
|
|
// List of faces, delimited by an ObjVertex with all members set to -1.
|
|
std::vector<ObjVertex> vertices;
|
|
};
|
|
|
|
struct MtlData
|
|
{
|
|
// Version of the data structure for load / store in the private binary format.
|
|
int version;
|
|
std::unordered_map<std::string, std::shared_ptr<ObjNewMtl>> new_mtl_unmap;
|
|
// Material names in declaration order. new_mtl_unmap is unordered, but OBJ material
|
|
// indices are positional, so texture import needs the original order.
|
|
std::vector<std::string> mtl_orders;
|
|
};
|
|
extern bool objparse(const char *path, ObjData &data);
|
|
extern bool mtlparse(const char *path, MtlData &data);
|
|
extern bool objparse(std::istream &stream, ObjData &data);
|
|
|
|
extern bool objbinsave(const char *path, const ObjData &data);
|
|
|
|
extern bool objbinload(const char *path, ObjData &data);
|
|
|
|
extern bool objequal(const ObjData &data1, const ObjData &data2);
|
|
|
|
} // namespace ObjParser
|
|
|
|
#endif /* slic3r_Format_objparser_hpp_ */
|