feat(core): SnapshotService — рендер 3D-модели в PNG (S4, "зрение агента")
- RasterImageFormat (PNG/JPG/BMP/...) + MIME-типы + парсинг - SnapshotService: ksDocument3D.SaveAsToRasterFormat -> временный файл -> байты (resultArrayBytes при заданном имени файла не заполняется; рендер в файл надёжен) - tests: снимок активной детали возвращает валидный PNG (визуально проверено) - docs/OPEN_QUESTIONS.md: зафиксирован нюанс resultArrayBytes Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,38 @@
|
||||
namespace Kompas.Mcp.Core.Vision;
|
||||
|
||||
/// <summary>Формат растра для снимка модели (значения ksRasterFormatEnum / ksRasterFormatParam.format).</summary>
|
||||
public enum RasterImageFormat : short
|
||||
{
|
||||
Bmp = 0,
|
||||
Gif = 1,
|
||||
Jpg = 2,
|
||||
Png = 3,
|
||||
Tif = 4,
|
||||
Tga = 5,
|
||||
}
|
||||
|
||||
public static class RasterImageFormats
|
||||
{
|
||||
/// <summary>MIME-тип для image-контента MCP.</summary>
|
||||
public static string MimeType(this RasterImageFormat format) => format switch
|
||||
{
|
||||
RasterImageFormat.Png => "image/png",
|
||||
RasterImageFormat.Jpg => "image/jpeg",
|
||||
RasterImageFormat.Bmp => "image/bmp",
|
||||
RasterImageFormat.Gif => "image/gif",
|
||||
RasterImageFormat.Tif => "image/tiff",
|
||||
RasterImageFormat.Tga => "image/x-tga",
|
||||
_ => "application/octet-stream",
|
||||
};
|
||||
|
||||
public static RasterImageFormat Parse(string value) => value.Trim().ToLowerInvariant() switch
|
||||
{
|
||||
"png" => RasterImageFormat.Png,
|
||||
"jpg" or "jpeg" => RasterImageFormat.Jpg,
|
||||
"bmp" => RasterImageFormat.Bmp,
|
||||
"gif" => RasterImageFormat.Gif,
|
||||
"tif" or "tiff" => RasterImageFormat.Tif,
|
||||
"tga" => RasterImageFormat.Tga,
|
||||
_ => throw new ArgumentException($"Неизвестный формат растра '{value}'.", nameof(value)),
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user