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