303 lines
8.6 KiB
C++
303 lines
8.6 KiB
C++
#pragma once
|
|
#include "aecdbentitybase.h"
|
|
#include "AecDbObjXDataMap.h"
|
|
#include "define_class_xdata_key.h"
|
|
|
|
#ifdef EARTHWORM_EXPORT
|
|
#define DLLIMPEXP __declspec(dllexport)
|
|
#else
|
|
#define DLLIMPEXP __declspec(dllimport)
|
|
#endif
|
|
|
|
class DLLIMPEXP AecDbXCamera : public AecDbEntityBase
|
|
{
|
|
public:
|
|
typedef AcArray<AcDbEntity*> AcDbEntityArray;
|
|
typedef std::map<AcDbObjectId, AcDbEntityArray> IDMapEntities;
|
|
typedef std::map<AcDbEntity*, AcDbEntityArray> EntMapEntities;
|
|
public:
|
|
ACRX_DECLARE_MEMBERS(AecDbXCamera);
|
|
|
|
enum USAGE_MODE
|
|
{
|
|
// 可以通过修改夹点来改变选择集
|
|
// 绘制剖切符号和结果范围框
|
|
eVerti = 0,
|
|
eHoriz,
|
|
|
|
// 选择集通过外部传入,不会修改
|
|
// 不绘制剖切符号,只绘制结果范围框
|
|
eStatic,
|
|
eNone,
|
|
};
|
|
|
|
enum HlrControl
|
|
{
|
|
//----- Should the curves be projected to a plane?
|
|
kProject = 0x0001,
|
|
|
|
//----- Should all curves be returned, or just visible ones?
|
|
kShowAll = 0x0002,
|
|
|
|
//----- Is it required to return the entity which caused a particular curve to be created?
|
|
kEntity = 0x0004,
|
|
|
|
//----- Are the objectIds for the generating entities required, including those of the nested blocks?
|
|
kBlock = 0x0008,
|
|
|
|
//----- Should the subenty information be returned for solids or graphic primitives?
|
|
kSubentity = 0x0010,
|
|
|
|
//----- Should tangent edges be suppressed?
|
|
kHideTangents = 0x0020,
|
|
|
|
//----- Should stored data be cleaned after use?
|
|
kCleanup = 0x0040,
|
|
|
|
//----- Should isolines be shown (same as would be seen in AutoCAD)?
|
|
kIsolines = 0x0080,
|
|
|
|
//----- Should the entities be united before hidden lines? Will be much slower, but more accurate for intersecting entities.
|
|
kUnite = 0x0100,
|
|
|
|
//----- Should the algorithm use the data which were created previously?
|
|
kReuse = 0x0200,
|
|
|
|
//----- Should the progress & abort callbacks be called?
|
|
kProgress = 0x0400,
|
|
|
|
//----- Should we show single points (requires bit more processing)?
|
|
kHandlePoints = 0x0800,
|
|
|
|
//----- Process all entities without looking at their layer state on which they lie on.
|
|
kProcessAll = 0x1000,
|
|
|
|
/*----- Should we process internal edges' visibility
|
|
(i.e. AcDbPolyFaceMesh / ACIS internal common edge / custom entity mesh/shell promitives)
|
|
Will be much slower, but more accurate for internal edges' visibility processing.*/
|
|
kHonorInternals = 0x2000,
|
|
|
|
//----- Should we generate silhouettes for AcDbPolyFaceMesh
|
|
kMeshSilhouettes = 0x4000,
|
|
|
|
//----- The HLR object cache is uniq for all viewports
|
|
kSingleCacheVp = 0x8000
|
|
};
|
|
|
|
enum Visibility
|
|
{
|
|
//----- Not hidden by anything
|
|
kVisible,
|
|
|
|
//----- Hidden by a face
|
|
kHidden,
|
|
|
|
//----- Hidden by another edge
|
|
kOccluded,
|
|
|
|
//----- Hidden because of entity internal visibility of a edge
|
|
kInternallyHidden,
|
|
|
|
//----- (i.e. AcDbPolyFaceMesh / ACIS internal common edge) Visibility not yet defined
|
|
kUndefined
|
|
};
|
|
|
|
struct GripData
|
|
{
|
|
GripData(): m_idx(-1)
|
|
, m_subIdx(-1)
|
|
, m_bDrawResultFrame(false)
|
|
, m_mode(AecDbXCamera::eNone)
|
|
, m_pt(AcGePoint3d::kOrigin)
|
|
, m_arSelectFrame(0)
|
|
, m_arResultFrame(0)
|
|
{}
|
|
int m_idx; // 索引 joggedCamera中代表是那个折线, Camera中代表是那个夹点
|
|
int m_subIdx; // 子索引 joggedCamera 使用,代表是那个夹点, Camera中没有意义
|
|
AcGePoint3d m_pt;
|
|
AcGePoint3dArray m_arSelectFrame , m_arResultFrame;
|
|
AecDbXCamera::USAGE_MODE m_mode;
|
|
bool m_bDrawResultFrame; // 是否绘制结果范围
|
|
};
|
|
|
|
protected:
|
|
static Adesk::UInt32 kCurrentVersionNumber;
|
|
|
|
public:
|
|
AecDbXCamera(void);
|
|
~AecDbXCamera(void);
|
|
|
|
void refresh(const bool &bRefreshEntity);
|
|
|
|
static void collectEnities(resbuf *selType, resbuf *selArea, AcDbObjectIdArray &arIds);
|
|
static AcDbEntity* cloneObject(AcDbObjectId &id);
|
|
static AcDbEntity* cloneObject(AcDbEntity *pEnt);
|
|
static void cloneObjects(AcDbObjectIdArray &arids, AcDbEntityArray &ents);
|
|
|
|
static void collectEnvelope(const AcDbObjectIdArray &arids
|
|
, AcDbObjectIdArray &arOther
|
|
, AcDbObjectIdArray &arEnve);
|
|
|
|
void updateSelecttionSet(const AcDbObjectIdArray &ids);
|
|
|
|
static struct resbuf* getSelectTypeResbuf();
|
|
|
|
static void eraseEnt(AcDbObjectId &id, Adesk::Boolean erasing = Adesk::kTrue);
|
|
static void eraseEnts(AcDbObjectIdArray &ids, Adesk::Boolean erasing = Adesk::kTrue);
|
|
|
|
|
|
void calcRangeOfElev(double &dMax, double &dMin);
|
|
|
|
/*
|
|
transfromHorResult函数 AecDbJoggedCamera 和 AecDbXCamera 都会使用
|
|
ptEye 是剖切面原点
|
|
X,Y,Z就是剖切面坐标轴,水平剖切是AcGeVecotr3d::kXAxis,垂直剖切需要取一下方向
|
|
*/
|
|
static void transfromHlrResult(const AcGePoint3d &ptEye // 剖切点
|
|
, const AcGeVector3d &vtEy // 剖切方向
|
|
, const AcGeVector3d &vtX // 剖切线方向,水平剖切永远AcGeVector3d::kXAxis
|
|
, const AcGePoint3d &ptOutput // 结果对齐点
|
|
, IDMapEntities &result // 传入的需要转换位置hlr计算结果
|
|
, EntMapEntities &result2 // 传入的需要转换位置hlr计算结果
|
|
, AcDbEntity *pSection); // 剖切面,用来切割结果
|
|
|
|
static void hlrCalc(AcDbObjectIdArray &arids // 用来计算的实体集合
|
|
, const AcGePoint3d &ptEye
|
|
, const AcGeVector3d &vtEye
|
|
, const AcGeVector3d &vtX
|
|
, const AcGePoint3d &ptOutput
|
|
, AcDbPolyline *pSection // 以上参数同transfromHlrResult
|
|
, IDMapEntities &outputWithID // 有图形id关联的剖其结果指针
|
|
, AcDbEntityArray &outputWithoutID // 没有图形id关联的剖其结果指针
|
|
, AcDbEntityArray &arAxisPtrs ); // 收集到的轴网实体指针(本函数内部释放)
|
|
|
|
|
|
private:
|
|
void getGripPoints(AcGePoint3dArray &ar) const;
|
|
|
|
void collectEnities(AcDbObjectIdArray &arIds) const;
|
|
|
|
void transfromHlrResult(IDMapEntities &result, EntMapEntities &result2, AcDbEntity *pSection) const;
|
|
|
|
AcDbExtents getResultExtent() const;
|
|
|
|
bool getResultBox(AcGePoint3d &ptLT
|
|
, AcGePoint3d &ptRT
|
|
, AcGePoint3d &ptRB
|
|
, AcGePoint3d &ptLB)const;
|
|
|
|
void moveOutput(const AcGeVector3d &vtOffset);
|
|
|
|
struct resbuf* getCollectArea() const;
|
|
|
|
void collectAxisObject(AcDbObjectIdArray &arids) const;
|
|
|
|
void collectEnvelope(AcDbObjectIdArray &arids) const;
|
|
|
|
AcDbPolyline* getSectionPolygon();
|
|
|
|
public:
|
|
virtual Acad::ErrorStatus subErase(Adesk::Boolean erasing);
|
|
|
|
virtual Acad::ErrorStatus copyFrom(const AcRxObject *pSrc);
|
|
|
|
virtual void subList() const;
|
|
virtual Acad::ErrorStatus subTransformBy(const AcGeMatrix3d &xform);
|
|
|
|
virtual Acad::ErrorStatus subGetGripPoints(AcDbGripDataPtrArray &grips,
|
|
const double curViewUnitSize,
|
|
const int gripSize,
|
|
const AcGeVector3d &curViewDir,
|
|
const int bitflags) const;
|
|
|
|
virtual Acad::ErrorStatus subMoveGripPointsAt(const AcDbVoidPtrArray &appData, const AcGeVector3d &offset, const int bitflags);
|
|
|
|
virtual Acad::ErrorStatus dwgInFields(AcDbDwgFiler *pFiler);
|
|
virtual Acad::ErrorStatus dwgOutFields(AcDbDwgFiler *pFiler) const;
|
|
|
|
Acad::ErrorStatus subGetOsnapPoints(AcDb::OsnapMode osnapMode,
|
|
INT_PTR gsSelectionMark,
|
|
const AcGePoint3d &pickPoint,
|
|
const AcGePoint3d &lastPoint,
|
|
const AcGeMatrix3d &viewXform,
|
|
AcGePoint3dArray &snapPoints,
|
|
AcDbIntArray &geomIds) const;
|
|
|
|
public:
|
|
|
|
virtual Acad::ErrorStatus Draw2d(AcGiDraw &dc) const;
|
|
virtual Acad::ErrorStatus Draw3d(AcGiDraw &dc) const;
|
|
|
|
virtual AecDbObjXDataMap *GetSpecialtyData(AcDb::OpenMode bMode = AcDb::kForWrite);
|
|
virtual const AecDbObjXDataMap *GetSpecialtyData() const;
|
|
|
|
public:
|
|
|
|
DEF_XDATA_KEY_FUN(EyePoint, AcGePoint3d, _ptEye_);
|
|
DEF_XDATA_KEY_FUN(EyeDirect, AcGeVector3d, _vtEye_);
|
|
DEF_XDATA_KEY_FUN(Width, double, _width_);
|
|
DEF_XDATA_KEY_FUN(Height, double, _height_);
|
|
DEF_XDATA_KEY_FUN(OutputPoint, AcGePoint3d, _ptOutput_);
|
|
DEF_XDATA_KEY_FUN(HorizTop, double, _horiztop_);
|
|
DEF_XDATA_KEY_FUN(HorizBottom, double, _horizbottom_);
|
|
DEF_XDATA_KEY_FUN(UsageMode, int, _usagemode_);
|
|
|
|
public:
|
|
virtual bool GetProperties(SimpleProperty::PropertySetByIndex &properties) const;
|
|
virtual bool SetProperties(SimpleProperty::PropertySetByName &properties);
|
|
|
|
private:
|
|
|
|
AecDbObjXDataMap m_mapSpecXData;
|
|
AcDbObjectIdArray m_arResults;
|
|
|
|
// 静态模式下,保存被剖切实体的id
|
|
AcDbObjectIdArray m_arSelectionSet;
|
|
mutable AcArray<GripData*> m_GripDatas;
|
|
};
|
|
|
|
class DLLIMPEXP XCameraJig_V: public AcEdJig
|
|
{
|
|
public:
|
|
XCameraJig_V(void);
|
|
virtual ~XCameraJig_V(void);
|
|
AcEdJig::DragStatus DoIt();
|
|
|
|
public:
|
|
|
|
virtual AcEdJig::DragStatus sampler();
|
|
|
|
virtual AcDbEntity *entity() const;
|
|
|
|
virtual Adesk::Boolean update();
|
|
|
|
public:
|
|
AcGePoint3d m_ptStart, m_ptEnd, m_ptDir, m_ptOutput, m_ptEye;
|
|
AcGeVector3d m_vtEye;
|
|
AcDbPolyline *m_pPolyline;
|
|
int m_nStep; // 0-剖切符号第二点 1-剖切方向点 2-结果位置
|
|
};
|
|
|
|
class DLLIMPEXP XCameraJig_H: public AcEdJig
|
|
{
|
|
public:
|
|
XCameraJig_H(void);
|
|
virtual ~XCameraJig_H(void);
|
|
AcEdJig::DragStatus DoIt();
|
|
|
|
public:
|
|
|
|
virtual AcEdJig::DragStatus sampler();
|
|
|
|
virtual AcDbEntity *entity() const;
|
|
|
|
virtual Adesk::Boolean update();
|
|
|
|
public:
|
|
AcGePoint3d m_ptLT, m_ptRB, m_ptLB, m_ptRT
|
|
, m_ptDir, m_ptOutput, m_ptEye;
|
|
AcGeVector3d m_vtEye;
|
|
AcDbPolyline *m_pPolyline;
|
|
int m_nStep; // 0-截面范围第二点 1-结果位置
|
|
};
|