public override ISurface GetCanonicalForm(double precision, BoundingRect?bounds) { ICurve testWith = basisCurve; if (basisCurve is BSpline bsp) { if (bsp.GetSimpleCurve(precision, out ICurve simpleCurve)) { testWith = simpleCurve; } } if (testWith is Ellipse elli && elli.IsCircle) { double r = (elli).Radius; if (Precision.SameDirection(elli.Plane.Normal, this.direction, false)) { CylindricalSurface cs = new CylindricalSurface(elli.Center, elli.MajorAxis, elli.MinorAxis, elli.Plane.Normal); GeoVector n1 = this.GetNormal(this.PositionOf(elli.StartPoint)); GeoVector n2 = cs.GetNormal(cs.PositionOf(elli.StartPoint)); if (n1 * n2 < 0) { cs.ReverseOrientation(); } return(cs); } }
public static dynamic GetTSObject(CylindricalSurface dynObject) { if (dynObject is null) { return(null); } return(dynObject.teklaObject); }
/// <summary> /// 幾何 -> 固體 -> 表面 -> 邊 /// Geomerty -> Solid -> surface -> edges /// </summary> /// <param name="famulyOfColumns"></param> private CurveLoop GetFaceEdgelines(FamilyInstance famulyOfColumns) { CurveLoop curveLoop = new CurveLoop(); Options opt = new Options(); opt.ComputeReferences = true; opt.DetailLevel = ViewDetailLevel.Fine; GeometryElement geomElem = famulyOfColumns.get_Geometry(opt); if (geomElem != null) { /// GeometryElement 包含三個枚舉(GeometryInstance, Solid, Solid) foreach (var item in geomElem) { /// 取得Type為Solid的枚舉 if (item.GetType().Name == "Solid") { /// 轉換至Solid型態 Solid solid = item as Solid; /// 若無面,略過 if (solid.Faces.Size == 0) { continue; } /// 列舉Solid所有面 foreach (Face face in solid.Faces) { /// 轉換至Surface型態 Surface surface = face.GetSurface(); /// 若為平面 else 圓柱面 if (face.GetType().Name == "PlanarFace") { Plane plane = surface as Plane; /// 取得基準面 if (Math.Round(plane.Normal.X, 2) == 0 && Math.Round(plane.Normal.Y, 2) == 0 && Math.Round(plane.Normal.Z, 2) == -1) { curveLoop = face.GetEdgesAsCurveLoops()[0]; } } else if (face.GetType().Name == "CylindricalFace") { CylindricalSurface csf = surface as CylindricalSurface; } } } } } return(curveLoop); }
public static Surface GetSurface(this Face face) { switch (face) { case PlanarFace planarFace: return(Plane.CreateByOriginAndBasis(planarFace.Origin, planarFace.XVector, planarFace.YVector)); case ConicalFace conicalFace: { var basisX = conicalFace.get_Radius(0).Normalize(); var basisY = conicalFace.get_Radius(1).Normalize(); var basisZ = conicalFace.Axis.Normalize(); return(ConicalSurface.Create(new Frame(conicalFace.Origin, basisX, basisY, basisZ), conicalFace.HalfAngle)); } case CylindricalFace cylindricalFace: { double radius = cylindricalFace.get_Radius(0).GetLength(); var basisX = cylindricalFace.get_Radius(0).Normalize(); var basisY = cylindricalFace.get_Radius(1).Normalize(); var basisZ = cylindricalFace.Axis.Normalize(); return(CylindricalSurface.Create(new Frame(cylindricalFace.Origin, basisX, basisY, basisZ), radius)); } case RevolvedFace revolvedFace: { var ECStoWCS = new Transform(Transform.Identity) { Origin = revolvedFace.Origin, BasisX = revolvedFace.get_Radius(0).Normalize(), BasisY = revolvedFace.get_Radius(1).Normalize(), BasisZ = revolvedFace.Axis.Normalize() }; var profileInWCS = revolvedFace.Curve.CreateTransformed(ECStoWCS); return(RevolvedSurface.Create(new Frame(ECStoWCS.Origin, ECStoWCS.BasisX, ECStoWCS.BasisY, ECStoWCS.BasisZ), profileInWCS)); } case RuledFace ruledFace: { var profileCurve0 = ruledFace.get_Curve(0); var profileCurve1 = ruledFace.get_Curve(1); return(RuledSurface.Create(profileCurve0, profileCurve1)); } } return(null); }
private void ModifyCylindricalSide_Click(object sender, EventArgs e) { ModifyCylindricalSide.Enabled = false; var geometryEnumerator = bentPlate.Geometry.GetGeometryEnumerator(); CylindricalSurfaceNode cylindricalSection = null; while (geometryEnumerator.MoveNext()) { if (geometryEnumerator.Current.GeometryNode is CylindricalSurfaceNode) { cylindricalSection = geometryEnumerator.Current.GeometryNode as CylindricalSurfaceNode; break; } } if (cylindricalSection != null) { try { Vector endFaceNormal1 = cylindricalSection.Surface.EndFaceNormal1; Vector endFaceNormal2 = cylindricalSection.Surface.EndFaceNormal2; LineSegment sideBoundary1 = new LineSegment(new Point(500.0, 4500.0, 0), new Point(2500.0, 4500.0, 0)); LineSegment sideBoundary2 = new LineSegment(new Point(500.0, 6000.0, 1500.0), new Point(2500.0, 6000.0, 1500.0)); CylindricalSurface newCylindricalSurface = new CylindricalSurface(endFaceNormal1, endFaceNormal2, sideBoundary1, sideBoundary2); BentPlateGeometrySolver solver = new BentPlateGeometrySolver(); var changedGeometry = solver.ModifyCylindricalSurface(bentPlate.Geometry, geometryEnumerator.Current, newCylindricalSurface); bentPlate.Geometry = changedGeometry; bentPlate.Modify(); model.CommitChanges(); } catch (Exception Ex) { Console.WriteLine("Exception : ", Ex.ToString()); } } }
/// <summary> /// Create a cylinder to subtract from the cube. /// </summary> public BRepBuilder CreateBrepVoid() { // Naming convention for faces and edges: we // assume that x is to the left and pointing down, // y is horizontal and pointing to the right, // z is up. BRepBuilder b = new BRepBuilder(BRepType.Solid); // The surfaces of the four faces. Frame basis = new Frame(new XYZ(50, 0, 0), new XYZ(0, 1, 0), new XYZ(-1, 0, 0), new XYZ(0, 0, 1)); CylindricalSurface cylSurf = CylindricalSurface.Create(basis, 40); Plane top1 = Plane.CreateByNormalAndOrigin(new XYZ(0, 0, 1), new XYZ(0, 0, 100)); // normal points outside the cylinder Plane bottom1 = Plane.CreateByNormalAndOrigin(new XYZ(0, 0, 1), new XYZ(0, 0, 0)); // normal points inside the cylinder // Add the four faces BRepBuilderGeometryId frontCylFaceId = b.AddFace(BRepBuilderSurfaceGeometry.Create(cylSurf, null), false); BRepBuilderGeometryId backCylFaceId = b.AddFace(BRepBuilderSurfaceGeometry.Create(cylSurf, null), false); BRepBuilderGeometryId topFaceId = b.AddFace(BRepBuilderSurfaceGeometry.Create(top1, null), false); BRepBuilderGeometryId bottomFaceId = b.AddFace(BRepBuilderSurfaceGeometry.Create(bottom1, null), true); // Geometry for the four semi-circular edges and two vertical linear edges BRepBuilderEdgeGeometry frontEdgeBottom = BRepBuilderEdgeGeometry.Create(Arc.Create(new XYZ(10, 0, 0), new XYZ(90, 0, 0), new XYZ(50, 40, 0))); BRepBuilderEdgeGeometry backEdgeBottom = BRepBuilderEdgeGeometry.Create(Arc.Create(new XYZ(90, 0, 0), new XYZ(10, 0, 0), new XYZ(50, -40, 0))); BRepBuilderEdgeGeometry frontEdgeTop = BRepBuilderEdgeGeometry.Create(Arc.Create(new XYZ(10, 0, 100), new XYZ(90, 0, 100), new XYZ(50, 40, 100))); BRepBuilderEdgeGeometry backEdgeTop = BRepBuilderEdgeGeometry.Create(Arc.Create(new XYZ(10, 0, 100), new XYZ(90, 0, 100), new XYZ(50, -40, 100))); BRepBuilderEdgeGeometry linearEdgeFront = BRepBuilderEdgeGeometry.Create(new XYZ(90, 0, 0), new XYZ(90, 0, 100)); BRepBuilderEdgeGeometry linearEdgeBack = BRepBuilderEdgeGeometry.Create(new XYZ(10, 0, 0), new XYZ(10, 0, 100)); // Add the six edges BRepBuilderGeometryId frontEdgeBottomId = b.AddEdge(frontEdgeBottom); BRepBuilderGeometryId frontEdgeTopId = b.AddEdge(frontEdgeTop); BRepBuilderGeometryId linearEdgeFrontId = b.AddEdge(linearEdgeFront); BRepBuilderGeometryId linearEdgeBackId = b.AddEdge(linearEdgeBack); BRepBuilderGeometryId backEdgeBottomId = b.AddEdge(backEdgeBottom); BRepBuilderGeometryId backEdgeTopId = b.AddEdge(backEdgeTop); // Loops of the four faces BRepBuilderGeometryId loopId_Top = b.AddLoop(topFaceId); BRepBuilderGeometryId loopId_Bottom = b.AddLoop(bottomFaceId); BRepBuilderGeometryId loopId_Front = b.AddLoop(frontCylFaceId); BRepBuilderGeometryId loopId_Back = b.AddLoop(backCylFaceId); // Add coedges for the loop of the front face b.AddCoEdge(loopId_Front, linearEdgeBackId, false); b.AddCoEdge(loopId_Front, frontEdgeTopId, false); b.AddCoEdge(loopId_Front, linearEdgeFrontId, true); b.AddCoEdge(loopId_Front, frontEdgeBottomId, true); b.FinishLoop(loopId_Front); b.FinishFace(frontCylFaceId); // Add coedges for the loop of the back face b.AddCoEdge(loopId_Back, linearEdgeBackId, true); b.AddCoEdge(loopId_Back, backEdgeBottomId, true); b.AddCoEdge(loopId_Back, linearEdgeFrontId, false); b.AddCoEdge(loopId_Back, backEdgeTopId, true); b.FinishLoop(loopId_Back); b.FinishFace(backCylFaceId); // Add coedges for the loop of the top face b.AddCoEdge(loopId_Top, backEdgeTopId, false); b.AddCoEdge(loopId_Top, frontEdgeTopId, true); b.FinishLoop(loopId_Top); b.FinishFace(topFaceId); // Add coedges for the loop of the bottom face b.AddCoEdge(loopId_Bottom, frontEdgeBottomId, false); b.AddCoEdge(loopId_Bottom, backEdgeBottomId, false); b.FinishLoop(loopId_Bottom); b.FinishFace(bottomFaceId); b.Finish(); return(b); }
protected IFCCylindricalSurface(IFCAnyHandle ifcCylindricalSurface) { Process(ifcCylindricalSurface); m_CylindricalSurface = CylindricalSurface.Create(new Frame(Position.Origin, Position.BasisX, Position.BasisY, Position.BasisZ), Radius); }
/// <summary> /// 创建圆柱 /// </summary> public static void CreateCylinder(Document doc, Material mat) { // Naming convention for faces and edges: we assume that x is to the left and pointing down, y is horizontal and pointing to the right, z is up BRepBuilder brepBuilder = new BRepBuilder(BRepType.Solid); // The surfaces of the four faces. Frame basis = new Frame(new XYZ(5, -10, 0), new XYZ(0, 1, 0), new XYZ(-1, 0, 0), new XYZ(0, 0, 1)); // Note that we do not have to create two identical surfaces here. The same surface can be used for multiple faces, // since BRepBuilderSurfaceGeometry::Create() copies the input surface. // Thus, potentially we could have only one surface here, // but we must create at least two faces below to account for periodicity. CylindricalSurface frontCylSurf = CylindricalSurface.Create(basis, 5); CylindricalSurface backCylSurf = CylindricalSurface.Create(basis, 5); Plane top = Plane.CreateByNormalAndOrigin(new XYZ(0, 0, 1), new XYZ(0, 0, 100)); // normal points outside the cylinder Plane bottom = Plane.CreateByNormalAndOrigin(new XYZ(0, 0, 1), new XYZ(0, 0, 0)); // normal points inside the cylinder // Note that the alternating of "inside/outside" matches the alternating of "true/false" in the next block that defines faces. // There must be a correspondence to ensure that all faces are correctly oriented to point out of the solid. // Add the four faces BRepBuilderGeometryId frontCylFaceId = brepBuilder.AddFace(BRepBuilderSurfaceGeometry.Create(frontCylSurf, null), false); BRepBuilderGeometryId backCylFaceId = brepBuilder.AddFace(BRepBuilderSurfaceGeometry.Create(backCylSurf, null), false); BRepBuilderGeometryId topFaceId = brepBuilder.AddFace(BRepBuilderSurfaceGeometry.Create(top, null), false); BRepBuilderGeometryId bottomFaceId = brepBuilder.AddFace(BRepBuilderSurfaceGeometry.Create(bottom, null), true); brepBuilder.SetFaceMaterialId(frontCylFaceId, mat.Id); brepBuilder.SetFaceMaterialId(backCylFaceId, mat.Id); // Geometry for the four semi-circular edges and two vertical linear edges BRepBuilderEdgeGeometry frontEdgeBottom = BRepBuilderEdgeGeometry.Create(Arc.Create(new XYZ(0, -10, 0), new XYZ(10, -10, 0), new XYZ(5, -5, 0))); BRepBuilderEdgeGeometry backEdgeBottom = BRepBuilderEdgeGeometry.Create(Arc.Create(new XYZ(10, -10, 0), new XYZ(0, -10, 0), new XYZ(5, -15, 0))); BRepBuilderEdgeGeometry frontEdgeTop = BRepBuilderEdgeGeometry.Create(Arc.Create(new XYZ(0, -10, 100), new XYZ(10, -10, 100), new XYZ(5, -5, 100))); BRepBuilderEdgeGeometry backEdgeTop = BRepBuilderEdgeGeometry.Create(Arc.Create(new XYZ(0, -10, 100), new XYZ(10, -10, 100), new XYZ(5, -15, 100))); BRepBuilderEdgeGeometry linearEdgeFront = BRepBuilderEdgeGeometry.Create(new XYZ(10, -10, 0), new XYZ(10, -10, 100)); BRepBuilderEdgeGeometry linearEdgeBack = BRepBuilderEdgeGeometry.Create(new XYZ(0, -10, 0), new XYZ(0, -10, 100)); // Add the six edges BRepBuilderGeometryId frontEdgeBottomId = brepBuilder.AddEdge(frontEdgeBottom); BRepBuilderGeometryId frontEdgeTopId = brepBuilder.AddEdge(frontEdgeTop); BRepBuilderGeometryId linearEdgeFrontId = brepBuilder.AddEdge(linearEdgeFront); BRepBuilderGeometryId linearEdgeBackId = brepBuilder.AddEdge(linearEdgeBack); BRepBuilderGeometryId backEdgeBottomId = brepBuilder.AddEdge(backEdgeBottom); BRepBuilderGeometryId backEdgeTopId = brepBuilder.AddEdge(backEdgeTop); // Loops of the four faces BRepBuilderGeometryId loopId_Top = brepBuilder.AddLoop(topFaceId); BRepBuilderGeometryId loopId_Bottom = brepBuilder.AddLoop(bottomFaceId); BRepBuilderGeometryId loopId_Front = brepBuilder.AddLoop(frontCylFaceId); BRepBuilderGeometryId loopId_Back = brepBuilder.AddLoop(backCylFaceId); // Add coedges for the loop of the front face brepBuilder.AddCoEdge(loopId_Front, linearEdgeBackId, false); brepBuilder.AddCoEdge(loopId_Front, frontEdgeTopId, false); brepBuilder.AddCoEdge(loopId_Front, linearEdgeFrontId, true); brepBuilder.AddCoEdge(loopId_Front, frontEdgeBottomId, true); brepBuilder.FinishLoop(loopId_Front); brepBuilder.FinishFace(frontCylFaceId); // Add coedges for the loop of the back face brepBuilder.AddCoEdge(loopId_Back, linearEdgeBackId, true); brepBuilder.AddCoEdge(loopId_Back, backEdgeBottomId, true); brepBuilder.AddCoEdge(loopId_Back, linearEdgeFrontId, false); brepBuilder.AddCoEdge(loopId_Back, backEdgeTopId, true); brepBuilder.FinishLoop(loopId_Back); brepBuilder.FinishFace(backCylFaceId); // Add coedges for the loop of the top face brepBuilder.AddCoEdge(loopId_Top, backEdgeTopId, false); brepBuilder.AddCoEdge(loopId_Top, frontEdgeTopId, true); brepBuilder.FinishLoop(loopId_Top); brepBuilder.FinishFace(topFaceId); // Add coedges for the loop of the bottom face brepBuilder.AddCoEdge(loopId_Bottom, frontEdgeBottomId, false); brepBuilder.AddCoEdge(loopId_Bottom, backEdgeBottomId, false); brepBuilder.FinishLoop(loopId_Bottom); brepBuilder.FinishFace(bottomFaceId); brepBuilder.Finish(); createDirectShapeElementFromBrepBuilderObject(brepBuilder, "Full cylinder", doc); }
public CylindricalSurfaceConvertable(Surface surface, IStpModel model) { _surface = (CylindricalSurface)surface; _model = model; Init(); }
public NonPeriodicCylindricalSurface(CylindricalSurface toSubstitute, double vmin, double vmax) : base(toSubstitute) { // vmin wird so bestimmt, dass es sicher kleiner ist als der zu erwartende v-Bereich this.vmin = vmin - (vmax - vmin) / 2.0; }
/// <summary> /// Инициализация всех дочерних сущности для заданной сущности. Используется рекурсивно для каждого вложенного параметра. /// </summary> /// <param name="itemParam">Родительский параметр, для которого необходимо инициализировать параметры</param> /// <param name="entitiesDictionary">Словарь всех сущностей, полученных из STEP файла. Ключем должен быть номер сущности.</param> /// <param name="parentNode">Родительский узел дерева TreeView. Инициализация происходит параллельно.</param> /// <returns>Метод возвращает проинициализированную сущность до самого нижнего уровня.</returns> private IEntityModel parseItemParam(EntityParam itemParam, Dictionary <int, BaseEntity> entitiesDictionary, TreeNode parentNode) { if (mCallback != null) { currentProgress += progressStep; mCallback.extractionStep(currentProgress < 99 ? currentProgress : 99); } //Инициализируемый параметр IEntityModel newParam = null; //Инициализируемый дочерний узел дерева TreeNode childNode = null; //Номер сущности, хранящийся в параметре int itemNumber; if (itemParam.value.StartsWith("#") && int.TryParse(itemParam.value.Substring(1), out itemNumber)) { //Сущность из словаря, получаемая по номеру BaseEntity nextEntity; if (entitiesDictionary.TryGetValue(itemNumber, out nextEntity)) { //Подбор необходимого алгоритма инициализации по имени сущности из STEP файла switch (nextEntity.Name) { //Комментарии для одного алгоритма, далее по аналогии. case Axis2Placement3D.NAME: //Создание объекта для соответствующего имени сущности Axis2Placement3D tempParamA2P3D = new Axis2Placement3D(); //Создания нового узла дерева (узлы деревьев формируются параллельно инициализации сущностей) childNode = new TreeNode(tempParamA2P3D.StepName); //Присвоение имени (title) объекту сущности из параметров, полученных парсером из STEP файла tempParamA2P3D.Name = nextEntity.ParsedParams[0][0].value; //Добавление соотвествующего узла дерева childNode.Nodes.Add("Label: " + tempParamA2P3D.Name); //Рекурсивный вызов метода для инициализации остальных внутренних параметров tempParamA2P3D.Location = (CartesianPoint)parseItemParam(nextEntity.ParsedParams[1][0], entitiesDictionary, childNode); tempParamA2P3D.Axis = (Direction)parseItemParam(nextEntity.ParsedParams[2][0], entitiesDictionary, childNode); tempParamA2P3D.RefDirection = (Direction)parseItemParam(nextEntity.ParsedParams[3][0], entitiesDictionary, childNode); //Присвоение абстрактной переменной текущей сущности newParam = tempParamA2P3D; break; case ManifoldSolidBrep.NAME: ManifoldSolidBrep tempParamMSB = new ManifoldSolidBrep(); childNode = new TreeNode(tempParamMSB.StepName); tempParamMSB.Name = nextEntity.ParsedParams[0][0].value; childNode.Nodes.Add("Label: " + tempParamMSB.Name); tempParamMSB.Outer = (ClosedShell)parseItemParam(nextEntity.ParsedParams[1][0], entitiesDictionary, childNode); newParam = tempParamMSB; break; case ClosedShell.NAME: ClosedShell tempParamCS = new ClosedShell(); childNode = new TreeNode(tempParamCS.StepName); tempParamCS.Name = nextEntity.ParsedParams[0][0].value; childNode.Nodes.Add("Label: " + tempParamCS.Name); tempParamCS.CfsFaces = new List <Face>(nextEntity.ParsedParams[1].Count); TreeNode childParamNode = new TreeNode("Cfs faces"); childNode.Nodes.Add(childParamNode); foreach (var itemParamCS in nextEntity.ParsedParams[1]) { IEntityModel param = parseItemParam(itemParamCS, entitiesDictionary, childParamNode); tempParamCS.CfsFaces.Add((Face)param); } newParam = tempParamCS; break; case AdvancedFace.NAME: AdvancedFace tempParamAF = new AdvancedFace(); childNode = new TreeNode(tempParamAF.StepName); tempParamAF.Name = nextEntity.ParsedParams[0][0].value; childNode.Nodes.Add("Label: " + tempParamAF.Name); tempParamAF.Bounds = new List <FaceBound>(nextEntity.ParsedParams[1].Count); TreeNode childParamNodeAF = new TreeNode("Bounds"); childNode.Nodes.Add(childParamNodeAF); foreach (var itemParamAFB in nextEntity.ParsedParams[1]) { IEntityModel param = parseItemParam(itemParamAFB, entitiesDictionary, childParamNodeAF); tempParamAF.Bounds.Add((FaceBound)param); } tempParamAF.FaceGeometry = (Surface)parseItemParam(nextEntity.ParsedParams[2][0], entitiesDictionary, childNode); tempParamAF.SameSense = nextEntity.ParsedParams[3][0].value; childNode.Nodes.Add("Same sense: " + tempParamAF.SameSense); newParam = tempParamAF; break; case FaceBound.NAME: FaceBound tempParamFB = new FaceBound(); childNode = new TreeNode(tempParamFB.StepName); tempParamFB.Name = nextEntity.ParsedParams[0][0].value; childNode.Nodes.Add("Label: " + tempParamFB.Name); tempParamFB.Bound = (Loop)parseItemParam(nextEntity.ParsedParams[1][0], entitiesDictionary, childNode); tempParamFB.Orientation = nextEntity.ParsedParams[2][0].value; childNode.Nodes.Add("Orientation: " + tempParamFB.Orientation); newParam = tempParamFB; break; case FaceOuterBound.NAME: FaceOuterBound tempParamFOB = new FaceOuterBound(); childNode = new TreeNode(tempParamFOB.StepName); tempParamFOB.Name = nextEntity.ParsedParams[0][0].value; childNode.Nodes.Add("Label: " + tempParamFOB.Name); tempParamFOB.Bound = (Loop)parseItemParam(nextEntity.ParsedParams[1][0], entitiesDictionary, childNode); tempParamFOB.Orientation = nextEntity.ParsedParams[2][0].value; childNode.Nodes.Add("Orientation: " + tempParamFOB.Orientation); newParam = tempParamFOB; break; case ConicalSurface.NAME: ConicalSurface tempParamCoSu = new ConicalSurface(); childNode = new TreeNode(tempParamCoSu.StepName); tempParamCoSu.Name = nextEntity.ParsedParams[0][0].value; childNode.Nodes.Add("Label: " + tempParamCoSu.Name); tempParamCoSu.Position = (Axis2Placement3D)parseItemParam(nextEntity.ParsedParams[1][0], entitiesDictionary, childNode); tempParamCoSu.Radius = (double)doubleConverter.ConvertFromInvariantString(nextEntity.ParsedParams[2][0].value); childNode.Nodes.Add("Radius: " + tempParamCoSu.Radius); tempParamCoSu.SemiAngle = (double)doubleConverter.ConvertFromInvariantString(nextEntity.ParsedParams[3][0].value); childNode.Nodes.Add("Semi angle: " + tempParamCoSu.SemiAngle); newParam = tempParamCoSu; break; case CylindricalSurface.NAME: CylindricalSurface tempParamCySu = new CylindricalSurface(); childNode = new TreeNode(tempParamCySu.StepName); tempParamCySu.Name = nextEntity.ParsedParams[0][0].value; childNode.Nodes.Add("Label: " + tempParamCySu.Name); tempParamCySu.Position = (Axis2Placement3D)parseItemParam(nextEntity.ParsedParams[1][0], entitiesDictionary, childNode); tempParamCySu.Radius = (double)doubleConverter.ConvertFromInvariantString(nextEntity.ParsedParams[2][0].value); childNode.Nodes.Add("Radius: " + tempParamCySu.Radius); newParam = tempParamCySu; break; case EdgeLoop.NAME: EdgeLoop tempParamEL = new EdgeLoop(); childNode = new TreeNode(tempParamEL.StepName); tempParamEL.Name = nextEntity.ParsedParams[0][0].value; childNode.Nodes.Add("Label: " + tempParamEL.Name); tempParamEL.EdgeList = new List <OrientedEdge>(nextEntity.ParsedParams[1].Count); TreeNode childParamNodeEL = new TreeNode("Edge list"); childNode.Nodes.Add(childParamNodeEL); foreach (var itemParamEL in nextEntity.ParsedParams[1]) { IEntityModel param = parseItemParam(itemParamEL, entitiesDictionary, childParamNodeEL); tempParamEL.EdgeList.Add((OrientedEdge)param); } newParam = tempParamEL; break; case OrientedEdge.NAME: OrientedEdge tempParamOE = new OrientedEdge(); childNode = new TreeNode(tempParamOE.StepName); tempParamOE.Name = nextEntity.ParsedParams[0][0].value; childNode.Nodes.Add("Label: " + tempParamOE.Name); tempParamOE.EdgeStart = (Vertex)parseItemParam(nextEntity.ParsedParams[1][0], entitiesDictionary, childNode); tempParamOE.EdgeEnd = (Vertex)parseItemParam(nextEntity.ParsedParams[2][0], entitiesDictionary, childNode); tempParamOE.EdgeElement = (Edge)parseItemParam(nextEntity.ParsedParams[3][0], entitiesDictionary, childNode); tempParamOE.Orientation = nextEntity.ParsedParams[4][0].value; childNode.Nodes.Add("Orientation: " + tempParamOE.Orientation); newParam = tempParamOE; break; case Edge.NAME: Edge tempParamE = new Edge(); childNode = new TreeNode(tempParamE.StepName); tempParamE.Name = nextEntity.ParsedParams[0][0].value; childNode.Nodes.Add("Label: " + tempParamE.Name); tempParamE.EdgeStart = (Vertex)parseItemParam(nextEntity.ParsedParams[1][0], entitiesDictionary, childNode); tempParamE.EdgeEnd = (Vertex)parseItemParam(nextEntity.ParsedParams[2][0], entitiesDictionary, childNode); newParam = tempParamE; break; case VertexPoint.NAME: VertexPoint tempParamVP = new VertexPoint(); childNode = new TreeNode(tempParamVP.StepName); tempParamVP.Name = nextEntity.ParsedParams[0][0].value; childNode.Nodes.Add("Label: " + tempParamVP.Name); tempParamVP.VertexGeometry = (CartesianPoint)parseItemParam(nextEntity.ParsedParams[1][0], entitiesDictionary, childNode); newParam = tempParamVP; break; case CartesianPoint.NAME: CartesianPoint tempParamCP = new CartesianPoint(); childNode = new TreeNode(tempParamCP.StepName); tempParamCP.Name = nextEntity.ParsedParams[0][0].value; childNode.Nodes.Add("Label: " + tempParamCP.Name); tempParamCP.X = (double)doubleConverter.ConvertFromInvariantString(nextEntity.ParsedParams[1][0].value); childNode.Nodes.Add("X: " + tempParamCP.X); tempParamCP.Y = (double)doubleConverter.ConvertFromInvariantString(nextEntity.ParsedParams[1][1].value); childNode.Nodes.Add("Y: " + tempParamCP.Y); tempParamCP.Z = (double)doubleConverter.ConvertFromInvariantString(nextEntity.ParsedParams[1][2].value); childNode.Nodes.Add("Z: " + tempParamCP.Z); newParam = tempParamCP; break; case EdgeCurve.NAME: EdgeCurve tempParamEC = new EdgeCurve(); childNode = new TreeNode(tempParamEC.StepName); tempParamEC.Name = nextEntity.ParsedParams[0][0].value; childNode.Nodes.Add("Label: " + tempParamEC.Name); tempParamEC.EdgeStart = (Vertex)parseItemParam(nextEntity.ParsedParams[1][0], entitiesDictionary, childNode); tempParamEC.EdgeEnd = (Vertex)parseItemParam(nextEntity.ParsedParams[2][0], entitiesDictionary, childNode); tempParamEC.EdgeGeometry = (Curve)parseItemParam(nextEntity.ParsedParams[3][0], entitiesDictionary, childNode); tempParamEC.SameSense = nextEntity.ParsedParams[4][0].value; childNode.Nodes.Add("Same sense: " + tempParamEC.SameSense); newParam = tempParamEC; break; case Circle.NAME: Circle tempParamCi = new Circle(); childNode = new TreeNode(tempParamCi.StepName); tempParamCi.Name = nextEntity.ParsedParams[0][0].value; childNode.Nodes.Add("Label: " + tempParamCi.Name); tempParamCi.Position = (Axis2Placement3D)parseItemParam(nextEntity.ParsedParams[1][0], entitiesDictionary, childNode); tempParamCi.Radius = (double)doubleConverter.ConvertFromInvariantString(nextEntity.ParsedParams[2][0].value); childNode.Nodes.Add("Radius: " + tempParamCi.Radius); newParam = tempParamCi; break; case Direction.NAME: Direction tempParamDi = new Direction(); childNode = new TreeNode(tempParamDi.StepName); tempParamDi.Name = nextEntity.ParsedParams[0][0].value; childNode.Nodes.Add("Label: " + tempParamDi.Name); TreeNode childParamNodeDi = new TreeNode("Direction ratios"); childNode.Nodes.Add(childParamNodeDi); tempParamDi.DirectionRatios = new List <double>(3); tempParamDi.DirectionRatios.Add((double)doubleConverter.ConvertFromInvariantString(nextEntity.ParsedParams[1][0].value)); tempParamDi.DirectionRatios.Add((double)doubleConverter.ConvertFromInvariantString(nextEntity.ParsedParams[1][1].value)); tempParamDi.DirectionRatios.Add((double)doubleConverter.ConvertFromInvariantString(nextEntity.ParsedParams[1][2].value)); childParamNodeDi.Nodes.Add(tempParamDi.DirectionRatios[0].ToString()); childParamNodeDi.Nodes.Add(tempParamDi.DirectionRatios[1].ToString()); childParamNodeDi.Nodes.Add(tempParamDi.DirectionRatios[2].ToString()); newParam = tempParamDi; break; case Line.NAME: Line tempParamL = new Line(); childNode = new TreeNode(tempParamL.StepName); tempParamL.Name = nextEntity.ParsedParams[0][0].value; childNode.Nodes.Add("Label: " + tempParamL.Name); tempParamL.Pnt = (CartesianPoint)parseItemParam(nextEntity.ParsedParams[1][0], entitiesDictionary, childNode); tempParamL.Dir = (Vector)parseItemParam(nextEntity.ParsedParams[2][0], entitiesDictionary, childNode); newParam = tempParamL; break; case Vector.NAME: Vector tempParamV = new Vector(); childNode = new TreeNode(tempParamV.StepName); tempParamV.Name = nextEntity.ParsedParams[0][0].value; childNode.Nodes.Add("Label: " + tempParamV.Name); tempParamV.Orientation = (Direction)parseItemParam(nextEntity.ParsedParams[1][0], entitiesDictionary, childNode); tempParamV.Magnitude = (double)doubleConverter.ConvertFromInvariantString(nextEntity.ParsedParams[2][0].value); childNode.Nodes.Add("Magnitude: " + tempParamV.Magnitude); newParam = tempParamV; break; case Plane.NAME: Plane tempParamPl = new Plane(); childNode = new TreeNode(tempParamPl.StepName); tempParamPl.Name = nextEntity.ParsedParams[0][0].value; childNode.Nodes.Add("Label: " + tempParamPl.Name); tempParamPl.Position = (Axis2Placement3D)parseItemParam(nextEntity.ParsedParams[1][0], entitiesDictionary, childNode); newParam = tempParamPl; break; case ToroidalSurface.NAME: ToroidalSurface tempParamTorSu = new ToroidalSurface(); childNode = new TreeNode(tempParamTorSu.StepName); tempParamTorSu.Name = nextEntity.ParsedParams[0][0].value; childNode.Nodes.Add("Label: " + tempParamTorSu.Name); tempParamTorSu.Position = (Axis2Placement3D)parseItemParam(nextEntity.ParsedParams[1][0], entitiesDictionary, childNode); tempParamTorSu.MajorRadius = (double)doubleConverter.ConvertFromInvariantString(nextEntity.ParsedParams[2][0].value); childNode.Nodes.Add("MajorRadius: " + tempParamTorSu.MajorRadius); tempParamTorSu.MinorRadius = (double)doubleConverter.ConvertFromInvariantString(nextEntity.ParsedParams[3][0].value); childNode.Nodes.Add("MinorRadius: " + tempParamTorSu.MinorRadius); newParam = tempParamTorSu; break; case BoundedSurface.NAME: BoundedSurface tempParamBoundSu = new BoundedSurface(); childNode = new TreeNode(tempParamBoundSu.StepName); //tempParamBoundSu.Name = nextEntity.ParsedParams[0][0].value; childNode.Nodes.Add(/*"Label: " + tempParamBoundSu.Name + */ "[Not implemented]"); newParam = tempParamBoundSu; break; default: //Ошибка генерируется в том случае, если сущность не определена ни одним из алгоритмов => нужно создать новый класс сущности и прописать соответствующей ей алгоритм инициализации. throw new InvalidDataException("Not found entity: " + nextEntity.Name); } //Добавление в родительский узел TreeView нового дочернего узла, проинициализированного в алгоритмах выше. parentNode.Nodes.Add(childNode); } } return(newParam); }