Code-style consistency improvement:
Apply clang-format-all.sh using the _clang-format file through all the cpp/.h files. make sure not to apply it to certain serialization structures, since some parser expects the * as part of the name, instead of type. This commit contains no other changes aside from adding and applying clang-format-all.sh
This commit is contained in:
@@ -20,110 +20,114 @@
|
||||
|
||||
#define VHACD_DEBUG_MESH
|
||||
|
||||
namespace VHACD {
|
||||
enum AXIS {
|
||||
AXIS_X = 0,
|
||||
AXIS_Y = 1,
|
||||
AXIS_Z = 2
|
||||
namespace VHACD
|
||||
{
|
||||
enum AXIS
|
||||
{
|
||||
AXIS_X = 0,
|
||||
AXIS_Y = 1,
|
||||
AXIS_Z = 2
|
||||
};
|
||||
struct Plane {
|
||||
double m_a;
|
||||
double m_b;
|
||||
double m_c;
|
||||
double m_d;
|
||||
AXIS m_axis;
|
||||
short m_index;
|
||||
struct Plane
|
||||
{
|
||||
double m_a;
|
||||
double m_b;
|
||||
double m_c;
|
||||
double m_d;
|
||||
AXIS m_axis;
|
||||
short m_index;
|
||||
};
|
||||
#ifdef VHACD_DEBUG_MESH
|
||||
struct Material {
|
||||
|
||||
Vec3<double> m_diffuseColor;
|
||||
double m_ambientIntensity;
|
||||
Vec3<double> m_specularColor;
|
||||
Vec3<double> m_emissiveColor;
|
||||
double m_shininess;
|
||||
double m_transparency;
|
||||
Material(void)
|
||||
{
|
||||
m_diffuseColor.X() = 0.5;
|
||||
m_diffuseColor.Y() = 0.5;
|
||||
m_diffuseColor.Z() = 0.5;
|
||||
m_specularColor.X() = 0.5;
|
||||
m_specularColor.Y() = 0.5;
|
||||
m_specularColor.Z() = 0.5;
|
||||
m_ambientIntensity = 0.4;
|
||||
m_emissiveColor.X() = 0.0;
|
||||
m_emissiveColor.Y() = 0.0;
|
||||
m_emissiveColor.Z() = 0.0;
|
||||
m_shininess = 0.4;
|
||||
m_transparency = 0.0;
|
||||
};
|
||||
struct Material
|
||||
{
|
||||
Vec3<double> m_diffuseColor;
|
||||
double m_ambientIntensity;
|
||||
Vec3<double> m_specularColor;
|
||||
Vec3<double> m_emissiveColor;
|
||||
double m_shininess;
|
||||
double m_transparency;
|
||||
Material(void)
|
||||
{
|
||||
m_diffuseColor.X() = 0.5;
|
||||
m_diffuseColor.Y() = 0.5;
|
||||
m_diffuseColor.Z() = 0.5;
|
||||
m_specularColor.X() = 0.5;
|
||||
m_specularColor.Y() = 0.5;
|
||||
m_specularColor.Z() = 0.5;
|
||||
m_ambientIntensity = 0.4;
|
||||
m_emissiveColor.X() = 0.0;
|
||||
m_emissiveColor.Y() = 0.0;
|
||||
m_emissiveColor.Z() = 0.0;
|
||||
m_shininess = 0.4;
|
||||
m_transparency = 0.0;
|
||||
};
|
||||
};
|
||||
#endif // VHACD_DEBUG_MESH
|
||||
#endif // VHACD_DEBUG_MESH
|
||||
|
||||
//! Triangular mesh data structure
|
||||
class Mesh {
|
||||
class Mesh
|
||||
{
|
||||
public:
|
||||
void AddPoint(const Vec3<double>& pt) { m_points.PushBack(pt); };
|
||||
void SetPoint(size_t index, const Vec3<double>& pt) { m_points[index] = pt; };
|
||||
const Vec3<double>& GetPoint(size_t index) const { return m_points[index]; };
|
||||
Vec3<double>& GetPoint(size_t index) { return m_points[index]; };
|
||||
size_t GetNPoints() const { return m_points.Size(); };
|
||||
double* GetPoints() { return (double*)m_points.Data(); } // ugly
|
||||
const double* const GetPoints() const { return (double*)m_points.Data(); } // ugly
|
||||
const Vec3<double>* const GetPointsBuffer() const { return m_points.Data(); } //
|
||||
Vec3<double>* const GetPointsBuffer() { return m_points.Data(); } //
|
||||
void AddTriangle(const Vec3<int>& tri) { m_triangles.PushBack(tri); };
|
||||
void SetTriangle(size_t index, const Vec3<int>& tri) { m_triangles[index] = tri; };
|
||||
const Vec3<int>& GetTriangle(size_t index) const { return m_triangles[index]; };
|
||||
Vec3<int>& GetTriangle(size_t index) { return m_triangles[index]; };
|
||||
size_t GetNTriangles() const { return m_triangles.Size(); };
|
||||
int* GetTriangles() { return (int*)m_triangles.Data(); } // ugly
|
||||
const int* const GetTriangles() const { return (int*)m_triangles.Data(); } // ugly
|
||||
const Vec3<int>* const GetTrianglesBuffer() const { return m_triangles.Data(); }
|
||||
Vec3<int>* const GetTrianglesBuffer() { return m_triangles.Data(); }
|
||||
const Vec3<double>& GetCenter() const { return m_center; }
|
||||
const Vec3<double>& GetMinBB() const { return m_minBB; }
|
||||
const Vec3<double>& GetMaxBB() const { return m_maxBB; }
|
||||
void ClearPoints() { m_points.Clear(); }
|
||||
void ClearTriangles() { m_triangles.Clear(); }
|
||||
void Clear()
|
||||
{
|
||||
ClearPoints();
|
||||
ClearTriangles();
|
||||
}
|
||||
void ResizePoints(size_t nPts) { m_points.Resize(nPts); }
|
||||
void ResizeTriangles(size_t nTri) { m_triangles.Resize(nTri); }
|
||||
void CopyPoints(SArray<Vec3<double> >& points) const { points = m_points; }
|
||||
double GetDiagBB() const { return m_diag; }
|
||||
double ComputeVolume() const;
|
||||
void ComputeConvexHull(const double* const pts,
|
||||
const size_t nPts);
|
||||
void Clip(const Plane& plane,
|
||||
SArray<Vec3<double> >& positivePart,
|
||||
SArray<Vec3<double> >& negativePart) const;
|
||||
bool IsInside(const Vec3<double>& pt) const;
|
||||
double ComputeDiagBB();
|
||||
void AddPoint(const Vec3<double>& pt) { m_points.PushBack(pt); };
|
||||
void SetPoint(size_t index, const Vec3<double>& pt) { m_points[index] = pt; };
|
||||
const Vec3<double>& GetPoint(size_t index) const { return m_points[index]; };
|
||||
Vec3<double>& GetPoint(size_t index) { return m_points[index]; };
|
||||
size_t GetNPoints() const { return m_points.Size(); };
|
||||
double* GetPoints() { return (double*)m_points.Data(); } // ugly
|
||||
const double* const GetPoints() const { return (double*)m_points.Data(); } // ugly
|
||||
const Vec3<double>* const GetPointsBuffer() const { return m_points.Data(); } //
|
||||
Vec3<double>* const GetPointsBuffer() { return m_points.Data(); } //
|
||||
void AddTriangle(const Vec3<int>& tri) { m_triangles.PushBack(tri); };
|
||||
void SetTriangle(size_t index, const Vec3<int>& tri) { m_triangles[index] = tri; };
|
||||
const Vec3<int>& GetTriangle(size_t index) const { return m_triangles[index]; };
|
||||
Vec3<int>& GetTriangle(size_t index) { return m_triangles[index]; };
|
||||
size_t GetNTriangles() const { return m_triangles.Size(); };
|
||||
int* GetTriangles() { return (int*)m_triangles.Data(); } // ugly
|
||||
const int* const GetTriangles() const { return (int*)m_triangles.Data(); } // ugly
|
||||
const Vec3<int>* const GetTrianglesBuffer() const { return m_triangles.Data(); }
|
||||
Vec3<int>* const GetTrianglesBuffer() { return m_triangles.Data(); }
|
||||
const Vec3<double>& GetCenter() const { return m_center; }
|
||||
const Vec3<double>& GetMinBB() const { return m_minBB; }
|
||||
const Vec3<double>& GetMaxBB() const { return m_maxBB; }
|
||||
void ClearPoints() { m_points.Clear(); }
|
||||
void ClearTriangles() { m_triangles.Clear(); }
|
||||
void Clear()
|
||||
{
|
||||
ClearPoints();
|
||||
ClearTriangles();
|
||||
}
|
||||
void ResizePoints(size_t nPts) { m_points.Resize(nPts); }
|
||||
void ResizeTriangles(size_t nTri) { m_triangles.Resize(nTri); }
|
||||
void CopyPoints(SArray<Vec3<double> >& points) const { points = m_points; }
|
||||
double GetDiagBB() const { return m_diag; }
|
||||
double ComputeVolume() const;
|
||||
void ComputeConvexHull(const double* const pts,
|
||||
const size_t nPts);
|
||||
void Clip(const Plane& plane,
|
||||
SArray<Vec3<double> >& positivePart,
|
||||
SArray<Vec3<double> >& negativePart) const;
|
||||
bool IsInside(const Vec3<double>& pt) const;
|
||||
double ComputeDiagBB();
|
||||
|
||||
#ifdef VHACD_DEBUG_MESH
|
||||
bool LoadOFF(const std::string& fileName, bool invert);
|
||||
bool SaveVRML2(const std::string& fileName) const;
|
||||
bool SaveVRML2(std::ofstream& fout, const Material& material) const;
|
||||
bool SaveOFF(const std::string& fileName) const;
|
||||
#endif // VHACD_DEBUG_MESH
|
||||
bool LoadOFF(const std::string& fileName, bool invert);
|
||||
bool SaveVRML2(const std::string& fileName) const;
|
||||
bool SaveVRML2(std::ofstream& fout, const Material& material) const;
|
||||
bool SaveOFF(const std::string& fileName) const;
|
||||
#endif // VHACD_DEBUG_MESH
|
||||
|
||||
//! Constructor.
|
||||
Mesh();
|
||||
//! Destructor.
|
||||
~Mesh(void);
|
||||
//! Constructor.
|
||||
Mesh();
|
||||
//! Destructor.
|
||||
~Mesh(void);
|
||||
|
||||
private:
|
||||
SArray<Vec3<double> > m_points;
|
||||
SArray<Vec3<int> > m_triangles;
|
||||
Vec3<double> m_minBB;
|
||||
Vec3<double> m_maxBB;
|
||||
Vec3<double> m_center;
|
||||
double m_diag;
|
||||
SArray<Vec3<double> > m_points;
|
||||
SArray<Vec3<int> > m_triangles;
|
||||
Vec3<double> m_minBB;
|
||||
Vec3<double> m_maxBB;
|
||||
Vec3<double> m_center;
|
||||
double m_diag;
|
||||
};
|
||||
}
|
||||
} // namespace VHACD
|
||||
#endif
|
||||
Reference in New Issue
Block a user