Files
envi-code/SourceCode/Code2026/inc/geometryUtility/geometryUtility.h
T
gjm 164968b62e chore
把非utf8-bom编码的cpp/h文件改为 utf8 bom 编码, msvc识别utf8编码时,如果不是bom格式的,会使用当前cp_oem来解码.
2026-10-04 00:04:20 +08:00

132 lines
3.2 KiB
C++

#pragma once
#include "gepnt3d.h"
#include "gepnt2d.h"
#include "gept2dar.h"
#include "gept3dar.h"
#include <vector>
#include <map>
#include <set>
#include <functional>
#ifdef GEO_EXPORT
#define GEODLLIMPEXP __declspec(dllexport)
#else
#define GEODLLIMPEXP __declspec(dllimport)
#endif
#pragma warning(disable:4503)
namespace Geometry
{
#if defined(_UNICODE) || defined(UNICODE)
typedef std::wstring string;
#else
typedef std::string string;
#endif
typedef std::vector<AcGePoint3d> GePoint3dArray;
typedef std::vector<AcGePoint2d> GePoint2dArray;
typedef std::vector<GePoint2dArray> GePolyArray2d;
typedef std::vector<GePoint3dArray> GePolyArray3d;
// 多边形
struct GePolygon2d
{
GePoint2dArray vertexs;
};
typedef std::vector<GePolygon2d> GePolygon2dList;
// 多边形带泂 polygon with holes
struct GePwh2d
{
GePolygon2d outer_boundary;
GePolygon2dList inner_holes;
};
typedef std::vector<GePwh2d> GePwh2dList;
enum Bounded_side
{
eOutside = -1,
eIsPoint,
eOnside,
eInside,
SIDE_ERROR,
};
}
namespace Geometry
{
GEODLLIMPEXP bool less_xy(const AcGePoint2d &pt1, const AcGePoint2d &pt2);
GEODLLIMPEXP bool less_xyz(const AcGePoint3d &pt1, const AcGePoint3d &pt2);
struct com_point3d_xy
{
bool operator() (const AcGePoint3d &v1 , const AcGePoint3d &v2) const
{
return less_xy(AcGePoint2d(v1.x, v1.y), AcGePoint2d(v2.x, v2.y));
}
};
typedef std::set<AcGePoint3d, com_point3d_xy> Point3dSet_xy;
// 对pts做delaunary三角化,并保存成GePolyFaceMesh结构
GEODLLIMPEXP void delaunayTriangulationMesh(const GePoint3dArray &arPts
, AcGePoint3dArray &vertexArray
, AcArray<Adesk::Int32> &faceArray);
GEODLLIMPEXP void delaunayTriangulationMeshWithHolds(const Geometry::GePoint3dArray &arPts
, const GePolyArray3d &holds
, AcGePoint3dArray &vertexArray
, AcArray<Adesk::Int32> &faceArray);
// 计算一堆点的凸包曲线
// 传出是一个point数组,按顺序组成一条polygon
GEODLLIMPEXP void calcConvexHull2D(const GePoint2dArray &arPts, GePoint2dArray &poly);
GEODLLIMPEXP void calcConvexHull2D(const GePoint3dArray &arPts, GePoint2dArray &poly);
GEODLLIMPEXP void calcConvexHull2D(const GePoint3dArray &arPts, GePoint3dArray &poly);
#pragma region polygon boolean oper
GEODLLIMPEXP Bounded_side boundary_check(const AcGePoint2d &pt, GePwh2d &gepoly);
GEODLLIMPEXP bool is_vaild_polygon(const GePwh2d &P);
GEODLLIMPEXP bool is_vaild_polygon(const GePolygon2d &P);
GEODLLIMPEXP bool is_counterclockwise(const GePwh2d &P);
GEODLLIMPEXP bool is_counterclockwise(const AcGePoint2d &ptS
, const AcGePoint2d &ptM
, const AcGePoint2d &ptE );
GEODLLIMPEXP bool is_intersect(const GePwh2d &p1, const GePwh2d &p2);
GEODLLIMPEXP void intersect(const GePwh2d &P
, const GePwh2d &Q
, GePwh2dList &gepwhlst);
GEODLLIMPEXP bool join(const GePwh2d &P
, const GePwh2d &Q
, GePwh2d &gepwh);
GEODLLIMPEXP void difference( const GePwh2d &P
, const GePwh2d &Q
, GePwh2dList &gepwhlst);
GEODLLIMPEXP void symmetric_difference( const GePwh2d &P
, const GePwh2d &Q
, GePwh2dList &gepwhlst);
GEODLLIMPEXP void sort_xy(GePolygon2d &ge);
GEODLLIMPEXP void sort_yx(GePolygon2d &ge);
GEODLLIMPEXP void convexHull2d(const AcGePoint2dArray &input, AcGePoint2dArray &output);
#pragma endregion
}