You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
179 lines
3.8 KiB
C++
179 lines
3.8 KiB
C++
#pragma once
|
|
#include "MLVector.h"
|
|
|
|
#define MLDPoint MLPoint
|
|
class MLPlNode;
|
|
class MLPoint : public MLVector
|
|
{
|
|
public:
|
|
MLPoint(void);
|
|
MLPoint(double vx, double vy);
|
|
MLPoint(double vx, double vy, double vz);
|
|
MLPoint(double vx, double vy, double vz, double vcz);
|
|
MLPoint(double vx, double vy, double vz, double vcz, double vl);
|
|
MLPoint(double vx, double vy, char* name);
|
|
MLPoint(double vx, double vy, double vz, char* name);
|
|
MLPoint(const MLPoint& dPoint);
|
|
MLPoint(const MLPlNode& node);
|
|
explicit MLPoint(const QPointF& point);
|
|
~MLPoint(void);
|
|
|
|
// 元素数
|
|
__declspec(property(get=getName, put = setName)) char* name;
|
|
__declspec(property(get=getCZ, put = setCZ)) double cz;
|
|
__declspec(property(get=getL, put = setL)) double l;
|
|
__declspec(property(get=getType, put = setType)) int type;
|
|
__declspec(property(get=getIndex, put = setIndex)) int index;
|
|
|
|
public:
|
|
const char* getName() const;
|
|
void setName(const char* name);
|
|
void setName(const QString& name);
|
|
QString getNameQStr();
|
|
|
|
void setCZ(double cz);
|
|
double getCZ() const;
|
|
double& getCZ();
|
|
|
|
double getL() const;
|
|
void setL(double l);
|
|
|
|
int getType() const;
|
|
void setType(int type);
|
|
|
|
int getIndex() const;
|
|
int& getIndex();
|
|
void setIndex(int idx);
|
|
|
|
// 设置点坐标
|
|
void setPoint(double dbx,double dby,double dbz);
|
|
void setPoint(const MLPoint& dPoint);
|
|
void setPoint(const MLPlNode& node);
|
|
void setPoint(const QPointF& point);
|
|
|
|
MLPoint& operator = (const MLPoint& point) throw();
|
|
MLPoint& operator = (const QPoint& point) throw();
|
|
|
|
// 点偏移
|
|
void offset(double offsetx, double offsety);
|
|
|
|
// 相等
|
|
bool Equ(const MLPoint& other, int dot=6);
|
|
|
|
// 转点坐标
|
|
MLPlNode toPlNode() const;
|
|
QPoint toQPoint() const;
|
|
QPointF toQPointF() const;
|
|
|
|
// 读取点数据
|
|
void readPoint(QDataStream& in);
|
|
void readPoint(FILE* fr);
|
|
|
|
// 输出点数据
|
|
void writePoint(QDataStream& out);
|
|
void writePoint(FILE* fw);
|
|
|
|
private:
|
|
char m_name[32];
|
|
double m_cz;
|
|
double m_l; // 长度
|
|
int m_type;
|
|
int m_index; // 索引
|
|
};
|
|
|
|
MLMICROSTRUCTURE_EXPORT QDataStream &operator<<(QDataStream &stream, const MLPoint &point);
|
|
MLMICROSTRUCTURE_EXPORT QDataStream &operator>>(QDataStream &stream, MLPoint &point);
|
|
|
|
//////////////////////////////////////////////////////////////////////////
|
|
|
|
class MLMICROSTRUCTURE_EXPORT MLPointAry
|
|
{
|
|
public:
|
|
MLPointAry();
|
|
~MLPointAry();
|
|
|
|
public:
|
|
// 清空点数组
|
|
void clear();
|
|
|
|
// 个数
|
|
int count() const;
|
|
|
|
// 重设置数组个数
|
|
void resetCount(int count);
|
|
|
|
// 添加点数据
|
|
void append(const MLPoint& dPoint);
|
|
void append(const MLPlNode& node);
|
|
void append(double x, double y, double z=0);
|
|
|
|
const MLPoint& at(int index) const;
|
|
|
|
// 设置点数据
|
|
void setAt(int index, const MLPoint& dPoint);
|
|
const MLPoint& getAt(int index) const;
|
|
|
|
void removeAt(int index);
|
|
|
|
void insertAt(int index, const MLPoint& dPoint);
|
|
|
|
MLPoint* getData();
|
|
const MLPoint* getData() const;
|
|
|
|
MLPoint& operator[]( int index );
|
|
|
|
const MLPoint& operator[]( int index ) const;
|
|
|
|
void operator = (const MLPointAry& point) throw();
|
|
|
|
// 创建数据
|
|
void createPoint(int nNum);
|
|
|
|
// 按长度插入点数据
|
|
void insertPt(double dl, const MLPoint& dPoint);
|
|
|
|
void copy(const MLPointAry& pointAry);
|
|
void append(const MLPointAry& pointAry);
|
|
|
|
void read(QDataStream& in);
|
|
void write(QDataStream& out);
|
|
|
|
// 计算点所在数组长度位置
|
|
void calPointPos();
|
|
|
|
// 使用之前要计算
|
|
double getDistance();
|
|
|
|
// 获得数组最大边框
|
|
void calculateBox();
|
|
|
|
MLBox getBoundingBox() const;
|
|
|
|
// 获得数组X最大值
|
|
double getXMax();
|
|
|
|
// 获得数组X最小值
|
|
double getXMin();
|
|
|
|
// 得到中心点
|
|
MLPoint getCenterPt();
|
|
|
|
// 按 X 排序
|
|
double getYAscX(double x);
|
|
double getYDescX(double x);
|
|
|
|
//MLPline toPline();
|
|
|
|
private:
|
|
// 二分法查找(假设数据已按升序排序)
|
|
void sort(const MLPointAry& pointAry);
|
|
int bs(double dl, const MLPointAry& pointAry);
|
|
|
|
int findIndex(double x);
|
|
|
|
private:
|
|
QVector<MLPoint> m_PointAry;
|
|
bool m_bCalPos; // 是否计算过位置
|
|
};
|
|
|