/// <summary> /// This is the method that actually does the work. /// </summary> /// <param name="DA">The DA object is used to retrieve from inputs and store in outputs.</param> protected override void SolveInstance(IGH_DataAccess DA) { ModelCls mymodel = new ModelCls(); //新建模型对象,存储建立的模型 string path0 = null; //路径 int typeFile = 1; //文件类型,1为midas mgt,2为abaqus inp bool cmd = false; //文件输出指令,True为输出 DA.GetData(3, ref cmd); if (DA.GetData(0, ref mymodel) && DA.GetData(1, ref path0) && DA.GetData(2, ref typeFile) && cmd) { ExportModel myExport = null; switch (typeFile) { case 1: myExport = new ExportGen(mymodel, path0); break; case 2: myExport = new ExportAbaqus(mymodel, path0); break; } Process process = Process.Start(myExport.Pathfile);//打开输出的文件,便于直接复制 process.Dispose(); } }
public ExportModel(ModelCls model, string path0, string type) { Model = model; string path = string.Concat(path0, type); Pathfile = Path.Combine(@"", path); Sw = new StreamWriter(new FileStream(Pathfile, FileMode.Create, FileAccess.Write)); }
public async void CheckNumberIsPrime_Success() { Service service = new Service(); ModelCls modelCls = new ModelCls(); modelCls.Number = 2; bool result = service.isPrime(modelCls); Assert.True(result); }
public async void CheckNumberIsPrime_Fail() { Service service = new Service(); ModelCls modelCls = new ModelCls(); modelCls.Number = 4; bool result = service.isPrime(modelCls); Assert.False(result); }
/// <summary> /// This is the method that actually does the work. /// </summary> /// <param name="DA">The DA object is used to retrieve from inputs and store in outputs.</param> protected override void SolveInstance(IGH_DataAccess DA) { List <Point3d> PointsCloud_3D = new List <Point3d>(); List <int> PointsIndex_2D = new List <int>(); List <Point3d> PointsCoords_2D = new List <Point3d>(); List <Line> Lines_2D = new List <Line>(); List <Line> Lines_3D = new List <Line>(); double err = 20; RTree PointsCoords_2DRtree = new RTree(); bool bool1 = DA.GetDataList(0, PointsCloud_3D); bool bool2 = DA.GetDataList(1, PointsIndex_2D); bool bool3 = DA.GetDataList(2, PointsCoords_2D); bool bool4 = DA.GetDataList(3, Lines_2D); bool bool5 = DA.GetData(4, ref err); ModelCls model = new ModelCls(); if (bool1) { model.Nodes = PointsCloud_3D; } if (bool2 && bool3) { for (int i = 0; i < PointsCoords_2D.Count; i++) { PointsCoords_2DRtree.Insert(PointsCoords_2D[i], i); } } if (bool1 && bool2 && bool3 && bool4) { List <BeamElementCls> BeamElements = new List <BeamElementCls>(); Lines_2D.ForEach(x => BeamElements.Add(new BeamElementCls(x, 1, 1))); int num = BeamElements.Count; for (int i = 0; i < num; i++) { List <int> verticesIndex = new List <int>(); for (int j = 0; j < 2; j++) { Point3d chkPt = BeamElements[i].Line.PointAt((double)j); FunctionClass.RtreeSearch(PointsCoords_2DRtree, PointsIndex_2D, chkPt, err, verticesIndex); } if (verticesIndex.Count == 2) { BeamElements[i].Nodes_no = verticesIndex; BeamElements[i].Line = new Line(PointsCloud_3D[verticesIndex[0] - 1], PointsCloud_3D[verticesIndex[1] - 1]); } } model.BeamElements = BeamElements; BeamElements.ForEach(x => Lines_3D.Add(x.Line)); DA.SetDataList(0, Lines_3D); DA.SetData(2, model); } }
/// <summary> /// Step1:提取线和网格的节点然后根据误差去重,建立起单元-节点的对应关系 /// Step2:设置梁单元荷载对应的单元编号属性,建立起荷载-单元编号索引关系 /// Step3:给模型对象附加各种信息:节点、单元、荷载、边界、组等 /// </summary> /// <param name="DA">用来获取输入端的参数和设置输出端的结果</param> protected override void SolveInstance(IGH_DataAccess DA) { //建立局部变量存储输入参数 List <BeamElementCls> BeamList = new List <BeamElementCls>(); List <ShellElementCls> ShellList = new List <ShellElementCls>(); List <BeamLoadCls> BeamLoadList = new List <BeamLoadCls>(); List <ShellLoadCls> ShellLoadList = new List <ShellLoadCls>(); List <SupportCls> SupportList = new List <SupportCls>(); //获取输入参数传给局部变量,并返回是否成功或取数据 bool bool1 = DA.GetDataList(0, BeamList); bool bool2 = DA.GetDataList(1, ShellList); bool boolBL = DA.GetDataList(2, BeamLoadList); double err = 0.01; DA.GetData(5, ref err); BeamLoadList.RemoveAll(j => { return(j == null); }); bool boolSL = DA.GetDataList(3, ShellLoadList); bool boolSPT = DA.GetDataList(4, SupportList); ModelCls model = new ModelCls(); List <Point3d> pointsOrigin = new List <Point3d>(); List <Point3d> pointsAfter = new List <Point3d>(); //将去重后的点存入Rtree,由列表转变为树形结构数据,以便高效的进行空间点的搜索,建立线段端点索引 RTree pointsAfterRt = new RTree(); RTree beamMidPts = new RTree(); //Step1-1:对线和网格节点合并然后去重,得到去重后的节点列表pointsAfter if (bool1)//如果有梁单元输入的话 { //ElementsList.AddRange(BeamList); for (int k = 0; k < BeamList.Count; k++) { BeamList[k].Ele_no = k + 1;//对线单元赋予单元编号 } //建立所有线段端点组成的列表 pointsOrigin = FunctionClass.getPoints(BeamList); if (bool2)//如果有壳单元输入的话 { //ElementsList.AddRange(ShellList); for (int m = 0; m < ShellList.Count; m++) { ShellList[m].Ele_no = BeamList.Count + 1 + m;//对面单元赋予单元编号 } //获得所有面单元对象的顶点列表 List <Point3d> pointsMesh = FunctionClass.getPoints(ShellList); pointsOrigin.AddRange(pointsMesh); } //1.利用kangaroo中的节点去重功能进行去重,效率比自己判断节点距离高 //2.注意:如果err大于某些线的长度,会造成线段数据丢失,导出的模型没有这部分线段 pointsAfter = Util.RemoveDupPts2(pointsOrigin, err);//测距离方法:x,y,z方向差同时小于err的点。而不是真实距离,真实距离可能大于err,但是速度比算真实距离快。 //List<Point3d> pointsAfter = FunctionClass.deleteDuplicatPts(pointsOrigin, err); //Step1-2:节点列表转为节点树 for (int j = 0; j < pointsAfter.Count; j++) { pointsAfterRt.Insert(pointsAfter[j], j); } for (int k = 0; k < BeamList.Count; k++) { beamMidPts.Insert(BeamList[k].Line.PointAt(0.5), k); } //Step1-3:对所梁单元和壳单元的节点赋予编号,建立单元-节点编号的索引关系 SetLineVerInd(pointsAfterRt, BeamList, err);//对线单元赋予节点索引***核心功能** if (bool2) { SetMeshVerInd(pointsAfterRt, ShellList, err);//对面单元赋予节点索引***核心功能** } } //Step2:设置梁单元荷载对象中的单元编号属性,建立起荷载-单元编号索引关系 if (boolBL) { for (int i = 0; i < BeamLoadList.Count; i++) { BeamLoadCls bloadi = BeamLoadList[i]; if (bloadi != null) { SetBeamLoadEleNo(beamMidPts, bloadi, err);//此属性在单元未合并之前,并不知道每个单元的编号,因此只能放在创建模型中实现 } } } //Step3:给模型对象附加各种信息:节点、单元、荷载、边界、组等 //给模型添加节点信息、梁单元信息、壳单元信息 model.Nodes = pointsAfter; model.BeamElements = BeamList; model.ShellElements = ShellList; model.BeamLoads = BeamLoadList; model.ShellLoads = ShellLoadList; model.Supports = SupportList; DA.SetData(0, model); //输出模型数据对象 DA.SetDataList(1, model.ModelInfo); //输出模型信息 }
public ExportGen(ModelCls model, string path0) : base(model, path0, ".mgt") { OutPutFile(); }
public ExportAbaqus(ModelCls model, string path0) : base(model, path0, ".inp") { OutPutFile(); }