COMPASSi/trunk/code/inc/ReadDXF/block_obj.h

254 lines
4.4 KiB
C++
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#pragma once
#include <vector>//包含头文件
using namespace std;
//块对象类存放DXF的块对线包括世界坐标、缩放比例、线、圆等对象
//线对象
class Point2D32f
{
public:
float x;
float y;
Point2D32f()
{
x=0.0;
y=0.0;
}
Point2D32f(float fx,float fy)
{
x=fx;
y=fy;
}
};
class Point3D32f
{
public:
float x;
float y;
float z;
Point3D32f()
{
x = 0.0;
y = 0.0;
z = 0.0;
}
Point3D32f(float fx,float fy,float fz)
{
x=fx;
y=fy;
z =fz;
}
};
class Point3DW32f
{
public:
float x;
float y;
float z;
float w;
Point3DW32f()
{
x = 0.0;
y = 0.0;
z = 0.0;
w =0.0;
}
Point3DW32f(float fx,float fy,float fz,float fw)
{
x=fx;
y=fy;
z =fz;
w =fw;
}
};
class DXFText
{
public:
/*! X Coordinate of insertion point. */
double ipx;
/*! Y Coordinate of insertion point. */
double ipy;
/*! Z Coordinate of insertion point. */
double ipz;
/*! X Coordinate of alignment point. */
double apx;
/*! Y Coordinate of alignment point. */
double apy;
/*! Z Coordinate of alignment point. */
double apz;
/*! Text height */
double height;
/*! Relative X scale factor. */
double xScaleFactor;
/*! 0 = default, 2 = Backwards, 4 = Upside down */
int textGenerationFlags;
/**
* Horizontal justification.
*
* 0 = Left (default), 1 = Center, 2 = Right,
* 3 = Aligned, 4 = Middle, 5 = Fit
* For 3, 4, 5 the vertical alignment has to be 0.
*/
int hJustification;
/**
* Vertical justification.
*
* 0 = Baseline (default), 1 = Bottom, 2 = Middle, 3= Top
*/
int vJustification;
/*! Text string. */
std::string text;
/*! Style (font). */
std::string style;
/*! Rotation angle of dimension text away from default orientation. */
double angle;
};
class DXFMText
{
public:
/*! X Coordinate of insertion point. */
double ipx;
/*! Y Coordinate of insertion point. */
double ipy;
/*! Z Coordinate of insertion point. */
double ipz;
/*! X Coordinate of X direction vector. */
double dirx;
/*! Y Coordinate of X direction vector. */
double diry;
/*! Z Coordinate of X direction vector. */
double dirz;
/*! Text height */
double height;
/*! Width of the text box. */
double width;
/**
* Attachment point.
*
* 1 = Top left, 2 = Top center, 3 = Top right,
* 4 = Middle left, 5 = Middle center, 6 = Middle right,
* 7 = Bottom left, 8 = Bottom center, 9 = Bottom right
*/
int attachmentPoint;
/**
* Drawing direction.
*
* 1 = left to right, 3 = top to bottom, 5 = by style
*/
int drawingDirection;
/**
* Line spacing style.
*
* 1 = at least, 2 = exact
*/
int lineSpacingStyle;
/**
* Line spacing factor. 0.25 .. 4.0
*/
double lineSpacingFactor;
/*! Text string. */
std::string text;
/*! Style string. */
std::string style;
/*! Rotation angle. */
double angle;
};
class DXFLine
{
public:
Point2D32f beginpoint;
Point2D32f endpoint;
};
//圆对象
class DXFCircle
{
public:
Point2D32f centerpoint;
double radius;
};
//多线实体对象
class DXFPolyLineEntities
{
public:
vector<Point2D32f> vertex;//顶点
bool isclose;//闭合标志位
};
//圆弧对象对象
class DXFArc
{
public:
Point2D32f centerpoint;
double radius;
double bangle;//起点角度
double eangle;//终点角度
};
class Spline
{
public:
unsigned int degree;
/*! Number of knots. */
unsigned int nKnots;
/*! Number of control points. */
unsigned int nControl;
/*! Number of fit points. */
unsigned int nFit;
/*! Flags */
int flags;
double tangentStartX;
double tangentStartY;
double tangentStartZ;
double tangentEndX;
double tangentEndY;
double tangentEndZ;
vector<double> knotLst;
vector<Point3D32f> fitPntLst;
vector<Point3DW32f> ctrPntLst;
};
class BlockObj
{
public:
BlockObj()
{
sx = 1;
sy = 1;
sz = 1;
ipx = 0;
ipy = 0;
ipz = 0;
line.clear();
}
~BlockObj(){}
//块名称
string name;
//缩放比例
double sx;
double sy;
double sz;
//用户坐标系相在世界坐标系中的位置
double ipx;
double ipy;
double ipz;
vector<DXFLine> line;
vector<DXFCircle> circle;
vector<DXFPolyLineEntities> polylineentities;
vector<DXFArc> arc;
vector<Spline> splineLst;
vector<DXFText> textLst;
vector<DXFMText> mtextLst;
bool drawflag;
};