#pragma once #include "InterpreterBase.h" #include #include #include #include #include #include #include #include "Geometry_M.h" #include "Hull_M.h" #include "DataManagerGlobal.h" class DATAMANAGER_DLL_API_EXPORTS ObjectInterpreter : public InterpreterBase { protected: int id2DelOrReplace = 0; bool genNewID = false; public: ObjectInterpreter(); void ExecuteCommand(std::vector &commandLines) override; // // 解析布尔运算符与名称 // // 返回:0="+"并,1="-"差,2="*"交 // protected: int ParseBoolSymbolFromName(std::string &objName); // /// // /// 返回false表示重复命名,但不能被替换 // /// bool ParseName(IModel& o, std::string &objName, const std::string &commandLine); // /// // /// 返回false表示重复命名,但不能被替换 // /// 根据输入名称返回可用名称 // /// bool ParseInputName(IModel &o, std::string &objName, const std::string &inputName); // 20171201 added byczb bool ValidSyntaxOfName(const std::string &objName); // /// // /// 返回false表示重复命名,但不能被替换 // /// 根据输入名称返回可用名称,不能为空 // /// bool ParseInputName(std::string &objName, const std::string &inputName); // 20180201 added by czb // std::string ParseNameMirror(std::shared_ptr o); // // 20161228 by czb,新增,根据命令行第一行,获得镜像图元的名称;当未指定名称时自动生成;当已指定名称时,根据系统配置"询问"或"自动更新" std::string ParseNameMirror(IModel *o, const std::string &commandLine); // /// // /// 根据前缀生成名称,直到无重名 // /// // /// // /// std::string ParseNameByPre(const std::string &preName); // 20170901 新增 by czb // /// // /// 根据前缀和指定基数生成名称,直到无重名 // /// std::string ParseNameByPre(const std::string &preName, int &baseNum); // 20171201 新增 by czb std::string ParseNameHull(); std::string ParseNameSuffix(IModel *o, const std::string &sSuffix); // /// // /// 三维坐标点解析 // /// 20170308 修改 by czb // /// // /// 返回的坐标点 // /// 坐标表达式 // /// false,解析时不保存引用关系;true,解析式保存引用关系 // /// bool ParsePointLoc(Point3D_M &o, const std::string &loc, bool withRef = false); // /// // /// 解析平面坐标点 // /// 不生成对应的对象 // /// // /// 坐标点对象 // /// 坐标表达式 // /// 位置面方向 // /// 位置面坐标分量 void ParsePointLoc2D(Point3D_M &o, const std::string &loc, const std::string &cutdir, double cutoff); // /// // /// 根据点及方向,创建临时曲线长度[-10000,10000] // /// // /// 点 // /// 曲线方向 // private: // std::shared_ptr CreateTempCurve(std::shared_ptr p, const std::string &cutdir); // /// // /// 解析空间坐标点,通过指定平面点,平面法向,该点所在的空间曲线 // /// 不生成对应的对象 // /// // /// 坐标点对象 // /// 平面坐标点 // /// 平面坐标点法向 // /// 空间曲线ID // protected: // void ParsePointLoc(std::shared_ptr &o, std::shared_ptr p, const std::string &cutdir, int baseCurve); // /// // /// 解析坐标点类型 // /// ResType约束类型:0等于,1小于,2大于,3接近.仅Type=1或2时使用. // /// // /// 被解析的坐标点 // /// 类型标识:n=?,x>?,y~?,z=? // private: void ParseRes(Point3D_M &o, const std::string &res); // /// // /// 添加到模型或互操作序列,一般用于无名称的对象 // /// 如为IModel3D,则添加进互操作序列不修改ModelData数据 // /// 否则,直接添加到模型修改ModelData数据(CSX数据文件对应的数据) // /// // protected: // void Add2ModelOrInteract(std::shared_ptr o); // /// // /// 添加到模型或互操作序列,用于有名称的对象 // /// 如为IModel3D,则添加进互操作序列不修改ModelData数据 // /// 否则,直接添加到模型修改ModelData数据(CSX数据文件对应的数据) // /// bSetCommand=true时,修改o.Command // /// void Add2ModelOrInteractWithIdtf(IModel *o, bool bSetCommand = true); // // protected void OnOutput(string text) //20170106 by czb // //{ // // Global.FireEvent(EventTopicNames.SystemOutput, this, new EventArgs(text)); // // } // /// // /// 生成新图元ID // /// ID前缀如下 // /// 0-Point3D, 1-Curve, 2-Surface,3-Solid // /// 10-MainDeckSurf,11-ShellSurf,12-DeckSurf,13-BoundSurf,14-SubdivSurf,15-OpencargoResion // /// 16-Space,17-Appendage,18-Hull // /// // /// // /// int GenerateObjectID(IModel *o); // /// // /// 初始化某类型的ID序号 // /// // /// // /// // void InitialObjectID(std::type_info t); // /// // /// 根据默认规则生成新图元名称 (不包含流水号 by yangchen) // /// // /// // /// std::string GenerateObjectName(IModel &o); // /// // /// 根据默认规则生成新图元名称(节点/板元/梁元) // /// // /// // /// // /// // std::string GenerateObjectNameSec(std::shared_ptr o, int secid); // /// // /// 查找同名并且可被删除(替换)的图元ID // /// // /// // /// -1:无同名图元.-2:同名图元类型不同(不可被删除). int FindIDByName(const std::string& name, bool replace = false, const char* typeName = nullptr, bool throwEx = true); // /// // /// 从互操作缓存中查找 // /// // /// // /// // /// // /// // /// int FindIDByNameFromInteract(const std::string &name, bool replace = false, const char* typeName = nullptr, bool throwEx = true); // /// // /// 拷贝一个图元,将新图元置入数据集,并返回其ID // /// // /// // /// // std::shared_ptr CopyObjectWithSrc(int id, bool add2Model = true, bool mirror = false, double dx = 0, double dy = 0, double dz = 0, double kx = 1, double ky = 1, double kz = 1, std::unordered_map &dicCopyed = std::unordered_map()); // /// // /// 带依赖复制对象 // /// // /// 已复制对象字典,源对象依赖id,新对象依赖id // /// 源对象id // /// 是否添加到模型数据中 // /// 是否镜像 // /// 偏移值 // /// // /// // /// // /// // /// // /// // private: // std::shared_ptr CopyObjectWithSrcPriv(std::unordered_map &dicCopyed, int id, bool add2Model, bool mirror, double dx, double dy, double dz, double kx, double ky, double kz); /// /// 解析X坐标,支持浮点(五位小数),肋位坐标,站位坐标 /// protected: double GetX(const std::string &str); Point3D_M ParseLoc(std::vector &linePara1b, const std::string &cutdir, double &offset); // /// // /// 解析双向投影面上的坐标 // /// // /// 解析后得到的点 // /// 坐标表达式 // /// 位置面 // /// 位置面的坐标分量 // /// 第1投影面内线形成的直纹面 // void ParsePointLoc2D(std::shared_ptr &o, const std::string &loc, const std::string &cutdir, double cutoff, std::shared_ptr sur); // /// // /// 解析单向投影位置面 // /// 返回引用点,如没有时返回null // /// // /// // /// 位置面 "X","Y","Z" // /// 坐标分量 // std::shared_ptr ParseLoc(std::vector &linePara1b, const std::string &cutdir, double &offset); // protected: // std::shared_ptr shared_from_this() // { // return std::static_pointer_cast(InterpreterBase::shared_from_this()); // } };