//-------------------------------------------------------------------------------------------------- #endregion #region Export public bool Export(string fileName, IExchanger exchanger) { if (!IsValid) { Messages.Error("The etching mask data could not be generated."); return(false); } var exporter = exchanger as IVectorExporter; if (exporter == null) { return(false); } VectorExportLayer[] exportLayers = new VectorExportLayer[_Layers.Length]; for (var layer = 0; layer < _Layers.Length; layer++) { exportLayers[layer] = new VectorExportLayer(VectorExportLayerType.FilledOutline, $"Layer{layer}", _Layers[layer].BRep); } return(exporter.DoExport(fileName, VectorExportTemplate.Contours, exportLayers)); }
//-------------------------------------------------------------------------------------------------- void _ExportLayer(VectorExportLayer layer) { _Document.Layers.Add(new DxfDomLayer(layer.Name, _Lineweights[layer.Type], layer.Type.ToString())); _CurrentLayer = layer.Name; foreach (var edge in layer.BRep.Edges()) { var tedge = edge.TShape() as BRep_TEdge; if (tedge == null) { return; } var curves = tedge.CurvesList(); foreach (var curve in curves) { Geom2d_Curve geomCurve; double first = 0; double last = 0; BRep_CurveOnSurface curveOnSurface = curve as BRep_CurveOnSurface; if (curveOnSurface != null) { geomCurve = curveOnSurface.PCurve(); first = curveOnSurface.First(); last = curveOnSurface.Last(); } else { geomCurve = BRep_Tool.CurveOnSurface(edge, new Geom_Plane(Ax3.XOY), new TopLoc_Location(), ref first, ref last); } if (geomCurve != null) { _AddCurve(geomCurve, first, last); } } } }
//-------------------------------------------------------------------------------------------------- SvgGroupElement _ExportLayer(VectorExportLayer layer) { if (_Styles == null || !_Styles.TryGetValue(layer.Type, out var lineStyle)) { return(null); } CurrentGroup = new SvgGroupElement { ID = layer.Name, Style = lineStyle }; if (layer.BRep == null) { return(null); } if (_Template == VectorExportTemplate.Contours) { CurrentGroup.IsLayer = true; } CurrentPath = null; if (_Template == VectorExportTemplate.Drawing) { // Drawings do only contain lines CombineToPath = false; _ExportEdges(layer.BRep.Edges(), null); } else { CombineToPath = layer.Type.HasFlag(VectorExportLayerType.Filled); var faces = layer.BRep.Faces(); foreach (var face in faces) { var outerWire = BRepTools.OuterWire(face); if (outerWire == null) { continue; } _ExportEdges(outerWire.Edges(), face); var wires = face.Wires(); foreach (var wire in wires) { if (wire.IsEqual(outerWire)) { continue; } _ExportEdges(wire.Edges(), face); } FinalizePath(); } } if (CurrentGroup.Children.Any()) { return(CurrentGroup); } return(null); }