/// <summary> /// Used to access the rectangle vertexes. The array passed as parameter is filled with the vertexes. /// </summary> /// <param name="vertexArray"></param> public void GetVertexes(OCGraphic2d_Array1OfVertex vertexArray) { if (_array1OfVertex.Length() == vertexArray.Length()) { //TODO: the loop condition is not <= !? for (int i = 1; i < _array1OfVertex.Length(); i++) { vertexArray.SetValue(i, new OCGraphic2d_Vertex(_array1OfVertex.Value(i).X(), _array1OfVertex.Value(i).Y())); } } }
/// <summary> /// Adds a Line2D to the OCAF tree /// </summary> /// <param name="line"></param> /// <param name="ax2"></param> /// <returns></returns> private int AddToOcaf(Line2D line, OCgp_Ax2 ax2) { OCGraphic2d_Array1OfVertex vertexArray = new OCGraphic2d_Array1OfVertex(1, 2); line.GetVertexes(vertexArray); Node mainLabel = _document.Root; _label = mainLabel.AddNewChild(); return(UpdateLinePosition(_label, ax2, vertexArray)); }
/// <summary> /// Used to retrieve the vertexes of the line. /// </summary> /// <param name="vertexArray"></param> public void GetVertexes(OCGraphic2d_Array1OfVertex vertexArray) { int arrLen = _array1OfVertex.Length(); int vertexLen = vertexArray.Length(); if (arrLen == vertexLen) { for (int i = 1; i <= arrLen; i++) { vertexArray.SetValue(i, new OCGraphic2d_Vertex(_array1OfVertex.Value(i).X(), _array1OfVertex.Value(i).Y())); } } }
int UpdateLinePosition(Node L, OCgp_Ax2 ax2, OCGraphic2d_Array1OfVertex vertexArray) { L.Update <StringInterpreter>().Value = DisplayedShapeNames.Line; var lineDriver = L.Update <FunctionInterpreter>(); lineDriver.Name = "Line"; lineDriver.BeginUpdate(); // Create the data structure : Set the dimensions, position and name attributes OCgp_Pnt point1 = GeomUtils.VertexToPnt(vertexArray.Value(1), ax2); lineDriver.Dependency.Child(1).Geometry = point1; OCgp_Pnt point2 = GeomUtils.VertexToPnt(vertexArray.Value(2), ax2); lineDriver.Dependency.Child(2).Geometry = point2; if (lineDriver.Execute() != 0) { // TODO: Handle the error } return(0); }