From 3c40edd12a7b023ca9c2e778c25f91cff3ace5be Mon Sep 17 00:00:00 2001 From: "C.Vengels" <6281096+cvengels@users.noreply.github.com> Date: Fri, 30 Oct 2026 13:25:18 +0000 Subject: [PATCH] Print face: Send to Slicer lays a body on its marked face (#8429) (#8433) * claim: #8429 Co-Authored-By: Claude Opus 5.5 * Print face: Send to Slicer lays a body on its marked face (#8429) A body can have one flat print face (Document::print_faces, held by the certified target a sketch on a face holds). body.print_face {body, point?} marks or clears it. Send to Slicer, Save Mesh with a slicer and EasyPrint turn and move the exported copy so the face lies on the bed at Z = 0 with the centre of mass over the origin; a face that can't be found is a warning and that body is exported as it lies. Move/Copy and Mirror give a copy its source's print face. One pending format file; the command has its own icon (print_face). Co-Authored-By: Claude Opus 5.5 * Print face: Ctrl+B, the face menu and the Send to Slicer row (#8429) Ctrl+B and the face context menu mark the selected flat face as its body's print face, or clear it. Send to Slicer shows the print face of the one body being sent in a Print face input, takes a flat face picked in the viewport and clears it when emptied. Co-Authored-By: Claude Opus 5.5 * Print face: a light tint in the viewport and its strength in Preferences (#8429) Each visible body's print face is tinted towards the theme's section colour and outlined, at the strength set under Preferences > General > Slicer (print_face_highlight, 0 to 1, 20 % by default; 0 hides it). The user guide describes the print face, and the known limitation after a shell of a shelled body is listed. Co-Authored-By: Claude Opus 5.5 --------- Co-authored-by: Claude Opus 5.5 --- assets/icons/ui/design/requested_icons.txt | 1 + .../icons/ui/design/svg/model/print_face.svg | 19 + assets/locales/pending/print-face.json | 332 ++++++++++++++ attribution/pending/print-face-icon.md | 1 + crates/doc/src/document.rs | 10 +- crates/doc/src/face_anchor.rs | 55 +-- crates/doc/src/format/pending/print-faces.rs | 5 + crates/doc/src/lib.rs | 2 + crates/doc/src/placement_reuse.rs | 2 + crates/doc/src/print_face.rs | 105 +++++ crates/engine/src/cmd/features.rs | 8 +- crates/engine/src/cmd/file.rs | 21 + crates/engine/src/cmd/file_easyprint.rs | 17 +- crates/engine/src/cmd/file_send.rs | 10 +- crates/engine/src/cmd/mod.rs | 2 + crates/engine/src/cmd/print_face.rs | 417 ++++++++++++++++++ crates/engine/src/lib.rs | 2 + crates/engine/src/schema/mod.rs | 1 + crates/engine/src/schema/print_face.rs | 74 ++++ crates/ui-egui/src/context_menu.rs | 3 + crates/ui-egui/src/dialogs_save_mesh.rs | 57 ++- crates/ui-egui/src/lib.rs | 6 + crates/ui-egui/src/prefs.rs | 6 + crates/ui-egui/src/prefs/general.rs | 11 + crates/ui-egui/src/print_face_ui.rs | 104 +++++ crates/ui-egui/src/viewport.rs | 28 ++ .../tests/scenarios/print_face_ctrl_b.json | 16 + docs/book/src/guide/files.md | 11 + docs/book/src/reference/glossary.md | 13 + docs/control-protocol.md | 1 + docs/roadmap-detail.md | 4 + 31 files changed, 1301 insertions(+), 43 deletions(-) create mode 100644 assets/icons/ui/design/svg/model/print_face.svg create mode 100644 assets/locales/pending/print-face.json create mode 100644 attribution/pending/print-face-icon.md create mode 100644 crates/doc/src/format/pending/print-faces.rs create mode 100644 crates/doc/src/print_face.rs create mode 100644 crates/engine/src/cmd/print_face.rs create mode 100644 crates/engine/src/schema/print_face.rs create mode 100644 crates/ui-egui/src/print_face_ui.rs create mode 100644 crates/ui-egui/tests/scenarios/print_face_ctrl_b.json diff --git a/assets/icons/ui/design/requested_icons.txt b/assets/icons/ui/design/requested_icons.txt index fe784a97f..e102eb58e 100644 --- a/assets/icons/ui/design/requested_icons.txt +++ b/assets/icons/ui/design/requested_icons.txt @@ -201,6 +201,7 @@ polygon false polygon_circumscribed false polygon_edge false presspull false +print_face false project false project_surface false rack_pinion false diff --git a/assets/icons/ui/design/svg/model/print_face.svg b/assets/icons/ui/design/svg/model/print_face.svg new file mode 100644 index 000000000..107dc1256 --- /dev/null +++ b/assets/icons/ui/design/svg/model/print_face.svg @@ -0,0 +1,19 @@ + + Print Face + + + + + + + + + + + + + + + + + diff --git a/assets/locales/pending/print-face.json b/assets/locales/pending/print-face.json new file mode 100644 index 000000000..91bcd9384 --- /dev/null +++ b/assets/locales/pending/print-face.json @@ -0,0 +1,332 @@ +{ + "en": { + "cmd.body.print_face": "Print Face", + "ui.clear_print_face": "Clear Print Face", + "ui.print_face_cleared": "{body}: print face cleared", + "ui.print_face_input": "Print face", + "ui.print_face_one_body": "A print face is picked for one body: send that body on its own to change it", + "ui.print_face_pick": "Select one flat face of a solid body to make it the print face", + "ui.print_face_set": "{body}: print face set; Send to Slicer lays the body on it", + "prefs.print_face_highlight": "Print face highlight", + "prefs.print_face_highlight_tip": "How strongly the print face of a body is tinted and outlined in the view. 0 % shows no highlight." + }, + "de": { + "cmd.body.print_face": "Auflagefläche", + "ui.clear_print_face": "Auflagefläche entfernen", + "ui.print_face_cleared": "{body}: Auflagefläche entfernt", + "ui.print_face_input": "Auflagefläche", + "ui.print_face_one_body": "Eine Auflagefläche gehört zu einem Körper: Sende diesen Körper allein, um sie zu ändern", + "ui.print_face_pick": "Eine plane Fläche eines Volumenkörpers auswählen, um sie zur Auflagefläche zu machen", + "ui.print_face_set": "{body}: Auflagefläche gesetzt; An Slicer senden legt den Körper darauf", + "prefs.print_face_highlight": "Hervorhebung der Auflagefläche", + "prefs.print_face_highlight_tip": "Wie stark die Auflagefläche eines Körpers in der Ansicht eingefärbt und umrandet wird. 0 % zeigt keine Hervorhebung." + }, + "ja": { + "cmd.body.print_face": "造形面", + "ui.clear_print_face": "造形面を解除", + "ui.print_face_cleared": "{body}: 造形面を解除しました", + "ui.print_face_input": "造形面", + "ui.print_face_one_body": "造形面はボディごとに選びます。変更するにはそのボディだけを送信してください", + "ui.print_face_pick": "ソリッドボディの平面を1つ選択すると造形面になります", + "ui.print_face_set": "{body}: 造形面を設定しました。スライサーへ送るとこの面を下にして置きます", + "prefs.print_face_highlight": "造形面の強調", + "prefs.print_face_highlight_tip": "ビューでボディの造形面を色付けし輪郭を描く強さ。0 % で強調しません。" + }, + "zh": { + "cmd.body.print_face": "打印底面", + "ui.clear_print_face": "清除打印底面", + "ui.print_face_cleared": "{body}:已清除打印底面", + "ui.print_face_input": "打印底面", + "ui.print_face_one_body": "打印底面属于单个实体:请单独发送该实体以更改它", + "ui.print_face_pick": "选择实体的一个平面,将其设为打印底面", + "ui.print_face_set": "{body}:已设置打印底面;发送到切片软件时实体将放在此面上", + "prefs.print_face_highlight": "打印底面高亮", + "prefs.print_face_highlight_tip": "视图中实体打印底面的着色和轮廓强度。0 % 不显示高亮。" + }, + "ko": { + "cmd.body.print_face": "출력 바닥면", + "ui.clear_print_face": "출력 바닥면 해제", + "ui.print_face_cleared": "{body}: 출력 바닥면을 해제했습니다", + "ui.print_face_input": "출력 바닥면", + "ui.print_face_one_body": "출력 바닥면은 바디마다 하나입니다. 변경하려면 그 바디만 보내십시오", + "ui.print_face_pick": "솔리드 바디의 평면 하나를 선택하면 출력 바닥면이 됩니다", + "ui.print_face_set": "{body}: 출력 바닥면을 설정했습니다. 슬라이서로 보내면 이 면이 아래로 놓입니다", + "prefs.print_face_highlight": "출력 바닥면 강조", + "prefs.print_face_highlight_tip": "뷰에서 바디의 출력 바닥면을 색칠하고 윤곽을 그리는 강도입니다. 0 %이면 강조하지 않습니다." + }, + "ar": { + "cmd.body.print_face": "وجه الطباعة", + "ui.clear_print_face": "مسح وجه الطباعة", + "ui.print_face_cleared": "{body}: تم مسح وجه الطباعة", + "ui.print_face_input": "وجه الطباعة", + "ui.print_face_one_body": "يُختار وجه الطباعة لجسم واحد: أرسل ذلك الجسم وحده لتغييره", + "ui.print_face_pick": "اختر وجهًا مستويًا واحدًا لجسم صلب لجعله وجه الطباعة", + "ui.print_face_set": "{body}: تم تعيين وجه الطباعة؛ الإرسال إلى برنامج التقطيع يضع الجسم عليه", + "prefs.print_face_highlight": "إبراز وجه الطباعة", + "prefs.print_face_highlight_tip": "مدى قوة تلوين وجه الطباعة للجسم وتحديده في العرض. ‏0 % لا يُظهر أي إبراز." + }, + "he": { + "cmd.body.print_face": "פאת הדפסה", + "ui.clear_print_face": "נקה פאת הדפסה", + "ui.print_face_cleared": "{body}: פאת ההדפסה נוקתה", + "ui.print_face_input": "פאת הדפסה", + "ui.print_face_one_body": "פאת הדפסה נבחרת לגוף אחד: שלח את הגוף הזה לבדו כדי לשנות אותה", + "ui.print_face_pick": "בחר פאה שטוחה אחת של גוף מוצק כדי להפוך אותה לפאת ההדפסה", + "ui.print_face_set": "{body}: פאת ההדפסה הוגדרה; שליחה לסלייסר מניחה את הגוף עליה", + "prefs.print_face_highlight": "הדגשת פאת ההדפסה", + "prefs.print_face_highlight_tip": "עד כמה חזק צובעים ומקיפים את פאת ההדפסה של גוף בתצוגה. ‏0 % אינו מציג הדגשה." + }, + "vi": { + "cmd.body.print_face": "Mặt in", + "ui.clear_print_face": "Xóa mặt in", + "ui.print_face_cleared": "{body}: đã xóa mặt in", + "ui.print_face_input": "Mặt in", + "ui.print_face_one_body": "Mặt in được chọn cho một thân: hãy gửi riêng thân đó để thay đổi", + "ui.print_face_pick": "Chọn một mặt phẳng của thân đặc để đặt làm mặt in", + "ui.print_face_set": "{body}: đã đặt mặt in; Gửi đến Slicer sẽ đặt thân lên mặt này", + "prefs.print_face_highlight": "Tô sáng mặt in", + "prefs.print_face_highlight_tip": "Mức tô màu và viền mặt in của thân trong khung nhìn. 0 % không tô sáng." + }, + "bs": { + "cmd.body.print_face": "Površina za štampu", + "ui.clear_print_face": "Ukloni površinu za štampu", + "ui.print_face_cleared": "{body}: površina za štampu uklonjena", + "ui.print_face_input": "Površina za štampu", + "ui.print_face_one_body": "Površina za štampu pripada jednom tijelu: pošaljite to tijelo samo da biste je promijenili", + "ui.print_face_pick": "Odaberite ravnu površinu punog tijela da postane površina za štampu", + "ui.print_face_set": "{body}: površina za štampu postavljena; Pošalji u slajser polaže tijelo na nju", + "prefs.print_face_highlight": "Isticanje površine za štampu", + "prefs.print_face_highlight_tip": "Koliko se jako površina za štampu tijela boji i obrubljuje u prikazu. 0 % ne prikazuje isticanje." + }, + "cs": { + "cmd.body.print_face": "Tisková plocha", + "ui.clear_print_face": "Zrušit tiskovou plochu", + "ui.print_face_cleared": "{body}: tisková plocha zrušena", + "ui.print_face_input": "Tisková plocha", + "ui.print_face_one_body": "Tisková plocha patří jednomu tělesu: odešlete toto těleso samostatně, abyste ji změnili", + "ui.print_face_pick": "Vyberte rovinnou plochu objemového tělesa, aby se stala tiskovou plochou", + "ui.print_face_set": "{body}: tisková plocha nastavena; Odeslat do sliceru položí těleso na ni", + "prefs.print_face_highlight": "Zvýraznění tiskové plochy", + "prefs.print_face_highlight_tip": "Jak výrazně se tisková plocha tělesa v pohledu obarví a obtáhne. 0 % nezobrazí žádné zvýraznění." + }, + "da": { + "cmd.body.print_face": "Printflade", + "ui.clear_print_face": "Ryd printflade", + "ui.print_face_cleared": "{body}: printflade ryddet", + "ui.print_face_input": "Printflade", + "ui.print_face_one_body": "En printflade hører til ét legeme: send det legeme alene for at ændre den", + "ui.print_face_pick": "Vælg en plan flade på et massivt legeme for at gøre den til printfladen", + "ui.print_face_set": "{body}: printflade sat; Send til slicer lægger legemet på den", + "prefs.print_face_highlight": "Fremhævning af printflade", + "prefs.print_face_highlight_tip": "Hvor kraftigt et legemes printflade farves og omrids i visningen. 0 % viser ingen fremhævning." + }, + "es": { + "cmd.body.print_face": "Cara de impresión", + "ui.clear_print_face": "Quitar cara de impresión", + "ui.print_face_cleared": "{body}: cara de impresión quitada", + "ui.print_face_input": "Cara de impresión", + "ui.print_face_one_body": "Una cara de impresión pertenece a un solo cuerpo: envía ese cuerpo solo para cambiarla", + "ui.print_face_pick": "Selecciona una cara plana de un cuerpo sólido para convertirla en la cara de impresión", + "ui.print_face_set": "{body}: cara de impresión definida; Enviar al laminador apoya el cuerpo sobre ella", + "prefs.print_face_highlight": "Resaltado de la cara de impresión", + "prefs.print_face_highlight_tip": "Intensidad del tinte y del contorno de la cara de impresión de un cuerpo en la vista. 0 % no muestra resaltado." + }, + "fr": { + "cmd.body.print_face": "Face d’impression", + "ui.clear_print_face": "Effacer la face d’impression", + "ui.print_face_cleared": "{body} : face d’impression effacée", + "ui.print_face_input": "Face d’impression", + "ui.print_face_one_body": "Une face d’impression appartient à un seul corps : envoyez ce corps seul pour la modifier", + "ui.print_face_pick": "Sélectionnez une face plane d’un corps solide pour en faire la face d’impression", + "ui.print_face_set": "{body} : face d’impression définie ; Envoyer au slicer pose le corps sur cette face", + "prefs.print_face_highlight": "Mise en évidence de la face d’impression", + "prefs.print_face_highlight_tip": "Intensité de la teinte et du contour de la face d’impression d’un corps dans la vue. 0 % n’affiche aucune mise en évidence." + }, + "gl": { + "cmd.body.print_face": "Cara de impresión", + "ui.clear_print_face": "Quitar cara de impresión", + "ui.print_face_cleared": "{body}: cara de impresión quitada", + "ui.print_face_input": "Cara de impresión", + "ui.print_face_one_body": "Unha cara de impresión pertence a un só corpo: envía ese corpo só para cambiala", + "ui.print_face_pick": "Selecciona unha cara plana dun corpo sólido para facela a cara de impresión", + "ui.print_face_set": "{body}: cara de impresión definida; Enviar ao laminador apoia o corpo sobre ela", + "prefs.print_face_highlight": "Resaltado da cara de impresión", + "prefs.print_face_highlight_tip": "Intensidade da tinguidura e do contorno da cara de impresión dun corpo na vista. 0 % non mostra resaltado." + }, + "hr": { + "cmd.body.print_face": "Ploha ispisa", + "ui.clear_print_face": "Ukloni plohu ispisa", + "ui.print_face_cleared": "{body}: ploha ispisa uklonjena", + "ui.print_face_input": "Ploha ispisa", + "ui.print_face_one_body": "Ploha ispisa pripada jednom tijelu: pošaljite to tijelo samo da biste je promijenili", + "ui.print_face_pick": "Odaberite ravnu plohu punog tijela da postane ploha ispisa", + "ui.print_face_set": "{body}: ploha ispisa postavljena; Pošalji u slicer polaže tijelo na nju", + "prefs.print_face_highlight": "Isticanje plohe ispisa", + "prefs.print_face_highlight_tip": "Koliko se jako ploha ispisa tijela boji i obrubljuje u prikazu. 0 % ne prikazuje isticanje." + }, + "hu": { + "cmd.body.print_face": "Nyomtatási lap", + "ui.clear_print_face": "Nyomtatási lap törlése", + "ui.print_face_cleared": "{body}: nyomtatási lap törölve", + "ui.print_face_input": "Nyomtatási lap", + "ui.print_face_one_body": "A nyomtatási lap egy testhez tartozik: a módosításhoz küldd el azt a testet egyedül", + "ui.print_face_pick": "Válassz ki egy tömör test egy sík lapját, hogy az legyen a nyomtatási lap", + "ui.print_face_set": "{body}: nyomtatási lap beállítva; a Küldés szeletelőnek erre a lapra fekteti a testet", + "prefs.print_face_highlight": "Nyomtatási lap kiemelése", + "prefs.print_face_highlight_tip": "Milyen erősen színezi és körvonalazza a nézet a test nyomtatási lapját. 0 % esetén nincs kiemelés." + }, + "id": { + "cmd.body.print_face": "Permukaan cetak", + "ui.clear_print_face": "Hapus permukaan cetak", + "ui.print_face_cleared": "{body}: permukaan cetak dihapus", + "ui.print_face_input": "Permukaan cetak", + "ui.print_face_one_body": "Permukaan cetak milik satu bodi: kirim bodi itu sendiri untuk mengubahnya", + "ui.print_face_pick": "Pilih satu permukaan datar dari bodi padat untuk dijadikan permukaan cetak", + "ui.print_face_set": "{body}: permukaan cetak diatur; Kirim ke slicer meletakkan bodi di atasnya", + "prefs.print_face_highlight": "Sorotan permukaan cetak", + "prefs.print_face_highlight_tip": "Seberapa kuat permukaan cetak sebuah bodi diwarnai dan diberi garis tepi di tampilan. 0 % tidak menampilkan sorotan." + }, + "it": { + "cmd.body.print_face": "Faccia di stampa", + "ui.clear_print_face": "Rimuovi faccia di stampa", + "ui.print_face_cleared": "{body}: faccia di stampa rimossa", + "ui.print_face_input": "Faccia di stampa", + "ui.print_face_one_body": "Una faccia di stampa appartiene a un solo corpo: invia quel corpo da solo per cambiarla", + "ui.print_face_pick": "Seleziona una faccia piana di un corpo solido per renderla la faccia di stampa", + "ui.print_face_set": "{body}: faccia di stampa impostata; Invia allo slicer appoggia il corpo su di essa", + "prefs.print_face_highlight": "Evidenziazione della faccia di stampa", + "prefs.print_face_highlight_tip": "Intensità della tinta e del contorno della faccia di stampa di un corpo nella vista. 0 % non mostra evidenziazione." + }, + "ms": { + "cmd.body.print_face": "Muka cetakan", + "ui.clear_print_face": "Kosongkan muka cetakan", + "ui.print_face_cleared": "{body}: muka cetakan dikosongkan", + "ui.print_face_input": "Muka cetakan", + "ui.print_face_one_body": "Muka cetakan dimiliki oleh satu jasad: hantar jasad itu sahaja untuk menukarnya", + "ui.print_face_pick": "Pilih satu muka rata pada jasad pepejal untuk menjadikannya muka cetakan", + "ui.print_face_set": "{body}: muka cetakan ditetapkan; Hantar ke penghiris meletakkan jasad di atasnya", + "prefs.print_face_highlight": "Serlahan muka cetakan", + "prefs.print_face_highlight_tip": "Sejauh mana muka cetakan sesuatu jasad diwarnakan dan digaris dalam paparan. 0 % tidak menunjukkan serlahan." + }, + "nb": { + "cmd.body.print_face": "Utskriftsflate", + "ui.clear_print_face": "Fjern utskriftsflate", + "ui.print_face_cleared": "{body}: utskriftsflate fjernet", + "ui.print_face_input": "Utskriftsflate", + "ui.print_face_one_body": "En utskriftsflate hører til ett legeme: send det legemet alene for å endre den", + "ui.print_face_pick": "Velg en plan flate på et massivt legeme for å gjøre den til utskriftsflaten", + "ui.print_face_set": "{body}: utskriftsflate satt; Send til slicer legger legemet på den", + "prefs.print_face_highlight": "Utheving av utskriftsflate", + "prefs.print_face_highlight_tip": "Hvor sterkt et legemes utskriftsflate fargelegges og omrisses i visningen. 0 % viser ingen utheving." + }, + "nl": { + "cmd.body.print_face": "Printvlak", + "ui.clear_print_face": "Printvlak wissen", + "ui.print_face_cleared": "{body}: printvlak gewist", + "ui.print_face_input": "Printvlak", + "ui.print_face_one_body": "Een printvlak hoort bij één lichaam: stuur dat lichaam alleen om het te wijzigen", + "ui.print_face_pick": "Selecteer één vlak van een massief lichaam om het het printvlak te maken", + "ui.print_face_set": "{body}: printvlak ingesteld; Naar slicer sturen legt het lichaam erop", + "prefs.print_face_highlight": "Markering van het printvlak", + "prefs.print_face_highlight_tip": "Hoe sterk het printvlak van een lichaam in de weergave wordt gekleurd en omlijnd. 0 % toont geen markering." + }, + "pl": { + "cmd.body.print_face": "Powierzchnia druku", + "ui.clear_print_face": "Usuń powierzchnię druku", + "ui.print_face_cleared": "{body}: usunięto powierzchnię druku", + "ui.print_face_input": "Powierzchnia druku", + "ui.print_face_one_body": "Powierzchnia druku należy do jednej bryły: wyślij tę bryłę osobno, aby ją zmienić", + "ui.print_face_pick": "Wybierz płaską powierzchnię bryły, aby ustawić ją jako powierzchnię druku", + "ui.print_face_set": "{body}: ustawiono powierzchnię druku; Wyślij do slicera kładzie bryłę na niej", + "prefs.print_face_highlight": "Wyróżnienie powierzchni druku", + "prefs.print_face_highlight_tip": "Jak mocno powierzchnia druku bryły jest barwiona i obrysowywana w widoku. 0 % nie pokazuje wyróżnienia." + }, + "pt-BR": { + "cmd.body.print_face": "Face de impressão", + "ui.clear_print_face": "Limpar face de impressão", + "ui.print_face_cleared": "{body}: face de impressão removida", + "ui.print_face_input": "Face de impressão", + "ui.print_face_one_body": "Uma face de impressão pertence a um único corpo: envie esse corpo sozinho para alterá-la", + "ui.print_face_pick": "Selecione uma face plana de um corpo sólido para torná-la a face de impressão", + "ui.print_face_set": "{body}: face de impressão definida; Enviar ao fatiador apoia o corpo sobre ela", + "prefs.print_face_highlight": "Destaque da face de impressão", + "prefs.print_face_highlight_tip": "Intensidade da cor e do contorno da face de impressão de um corpo na vista. 0 % não mostra destaque." + }, + "ro": { + "cmd.body.print_face": "Față de imprimare", + "ui.clear_print_face": "Șterge fața de imprimare", + "ui.print_face_cleared": "{body}: fața de imprimare a fost ștearsă", + "ui.print_face_input": "Față de imprimare", + "ui.print_face_one_body": "O față de imprimare aparține unui singur corp: trimiteți acel corp singur pentru a o schimba", + "ui.print_face_pick": "Selectați o față plană a unui corp solid pentru a o face fața de imprimare", + "ui.print_face_set": "{body}: fața de imprimare a fost setată; Trimite la slicer așază corpul pe ea", + "prefs.print_face_highlight": "Evidențierea feței de imprimare", + "prefs.print_face_highlight_tip": "Cât de puternic este colorată și conturată fața de imprimare a unui corp în vizualizare. 0 % nu afișează evidențiere." + }, + "ru": { + "cmd.body.print_face": "Грань печати", + "ui.clear_print_face": "Сбросить грань печати", + "ui.print_face_cleared": "{body}: грань печати сброшена", + "ui.print_face_input": "Грань печати", + "ui.print_face_one_body": "Грань печати относится к одному телу: отправьте это тело отдельно, чтобы изменить её", + "ui.print_face_pick": "Выберите плоскую грань твёрдого тела, чтобы сделать её гранью печати", + "ui.print_face_set": "{body}: грань печати задана; «Отправить в слайсер» кладёт тело на неё", + "prefs.print_face_highlight": "Подсветка грани печати", + "prefs.print_face_highlight_tip": "Насколько сильно грань печати тела окрашивается и обводится в виде. 0 % — без подсветки." + }, + "sr": { + "cmd.body.print_face": "Површина за штампу", + "ui.clear_print_face": "Уклони површину за штампу", + "ui.print_face_cleared": "{body}: површина за штампу уклоњена", + "ui.print_face_input": "Површина за штампу", + "ui.print_face_one_body": "Површина за штампу припада једном телу: пошаљите то тело само да бисте је променили", + "ui.print_face_pick": "Изаберите равну површину пуног тела да постане површина за штампу", + "ui.print_face_set": "{body}: површина за штампу постављена; Пошаљи у слајсер полаже тело на њу", + "prefs.print_face_highlight": "Истицање површине за штампу", + "prefs.print_face_highlight_tip": "Колико се јако површина за штампу тела боји и обрубљује у приказу. 0 % не приказује истицање." + }, + "sv": { + "cmd.body.print_face": "Utskriftsyta", + "ui.clear_print_face": "Rensa utskriftsyta", + "ui.print_face_cleared": "{body}: utskriftsyta rensad", + "ui.print_face_input": "Utskriftsyta", + "ui.print_face_one_body": "En utskriftsyta hör till en kropp: skicka den kroppen ensam för att ändra den", + "ui.print_face_pick": "Välj en plan yta på en solid kropp för att göra den till utskriftsytan", + "ui.print_face_set": "{body}: utskriftsyta angiven; Skicka till slicer lägger kroppen på den", + "prefs.print_face_highlight": "Markering av utskriftsyta", + "prefs.print_face_highlight_tip": "Hur starkt en kropps utskriftsyta färgas och konturmarkeras i vyn. 0 % visar ingen markering." + }, + "tr": { + "cmd.body.print_face": "Baskı yüzeyi", + "ui.clear_print_face": "Baskı yüzeyini temizle", + "ui.print_face_cleared": "{body}: baskı yüzeyi temizlendi", + "ui.print_face_input": "Baskı yüzeyi", + "ui.print_face_one_body": "Baskı yüzeyi tek bir gövdeye aittir: değiştirmek için o gövdeyi tek başına gönderin", + "ui.print_face_pick": "Baskı yüzeyi yapmak için katı bir gövdenin düz bir yüzeyini seçin", + "ui.print_face_set": "{body}: baskı yüzeyi ayarlandı; Dilimleyiciye gönder gövdeyi bu yüzeyin üzerine koyar", + "prefs.print_face_highlight": "Baskı yüzeyi vurgusu", + "prefs.print_face_highlight_tip": "Bir gövdenin baskı yüzeyinin görünümde ne kadar güçlü renklendirilip çerçeveleneceği. %0 vurgu göstermez." + }, + "uk": { + "cmd.body.print_face": "Грань друку", + "ui.clear_print_face": "Скинути грань друку", + "ui.print_face_cleared": "{body}: грань друку скинуто", + "ui.print_face_input": "Грань друку", + "ui.print_face_one_body": "Грань друку належить одному тілу: надішліть це тіло окремо, щоб змінити її", + "ui.print_face_pick": "Виберіть плоску грань твердого тіла, щоб зробити її гранню друку", + "ui.print_face_set": "{body}: грань друку задано; «Надіслати в слайсер» кладе тіло на неї", + "prefs.print_face_highlight": "Підсвічування грані друку", + "prefs.print_face_highlight_tip": "Наскільки сильно грань друку тіла зафарбовується й обводиться у вигляді. 0 % — без підсвічування." + }, + "zh-TW": { + "cmd.body.print_face": "列印底面", + "ui.clear_print_face": "清除列印底面", + "ui.print_face_cleared": "{body}:已清除列印底面", + "ui.print_face_input": "列印底面", + "ui.print_face_one_body": "列印底面屬於單一實體:請單獨傳送該實體以變更它", + "ui.print_face_pick": "選取實體的一個平面,將其設為列印底面", + "ui.print_face_set": "{body}:已設定列印底面;傳送到切片軟體時實體會放在此面上", + "prefs.print_face_highlight": "列印底面醒目提示", + "prefs.print_face_highlight_tip": "在檢視中為實體的列印底面著色及描邊的強度。0 % 不顯示醒目提示。" + } +} diff --git a/attribution/pending/print-face-icon.md b/attribution/pending/print-face-icon.md new file mode 100644 index 000000000..7fdd65977 --- /dev/null +++ b/attribution/pending/print-face-icon.md @@ -0,0 +1 @@ +| assets/icons/ui/design/svg/model/print_face.svg | SolidCraft contributors | two-tone modelling icon master (64 grid), original SolidCraft artwork | MIT OR Apache-2.0 | diff --git a/crates/doc/src/document.rs b/crates/doc/src/document.rs index 8373cdbc5..3c53b5e6d 100644 --- a/crates/doc/src/document.rs +++ b/crates/doc/src/document.rs @@ -2736,6 +2736,9 @@ pub struct Document { /// Physical material per body (by body name); others use the default. #[serde(default, skip_serializing_if = "std::collections::BTreeMap::is_empty")] pub materials: std::collections::BTreeMap, + /// The flat face per body (by body name) that a slicer export lays on the print bed. + #[serde(default, skip_serializing_if = "std::collections::BTreeMap::is_empty")] + pub print_faces: std::collections::BTreeMap, /// Physical materials defined in this design (`material.create`), next to the built-in ones. #[serde(default, skip_serializing_if = "Vec::is_empty")] pub user_materials: Vec, @@ -2982,6 +2985,7 @@ impl Document { body_components: Default::default(), body_offsets: Default::default(), materials: Default::default(), + print_faces: Default::default(), user_materials: Vec::new(), appearances: Default::default(), favorites: Default::default(), @@ -2997,7 +3001,7 @@ impl Document { } /// Rename body `old` to `new` where the design keeps things by body name outside its - /// features: materials, appearances, plastic rules, configuration columns, offsets, components and the + /// features: materials, print faces, appearances, plastic rules, configuration columns, offsets, components and the /// browser's groups and order. (The features are the rename command's to change.) /// /// A name the design numbered (`Body1`) is not used again after the rename: the design's @@ -3013,6 +3017,10 @@ impl Document { if let Some(m) = self.materials.remove(old) { self.materials.insert(new.to_string(), m); } + if let Some(mut face) = self.print_faces.remove(old) { + face.body = new.to_string(); + self.print_faces.insert(new.to_string(), face); + } if let Some(rule) = self.plastic.assigned.remove(old) { self.plastic.assigned.insert(new.to_string(), rule); } diff --git a/crates/doc/src/face_anchor.rs b/crates/doc/src/face_anchor.rs index a8f4ca49d..d32f962c1 100644 --- a/crates/doc/src/face_anchor.rs +++ b/crates/doc/src/face_anchor.rs @@ -172,32 +172,7 @@ impl Document { author: u64, author_path: &[u64], ) -> Result { - // A construction certificate that names this face alone, else its exact history name. - let certified = body - .body - .face_plane(index) - .ok_or_else(|| DocError::Invalid("this face has no exact planar source; choose a fixed plane instead".into())) - .and_then(|source| { - let target = self.strong_face_target(body, index, source.origin)?; - if target.certificate.is_none() { - return Err(DocError::Invalid("this face has no supported construction certificate; choose a fixed plane instead".into())); - } - let indices = self.configuration_face_indices(body, &target)?; - // A copy a pattern or mirror made on the same body carries its seed's certificate, - // which finds the seed's face: the copy is attached by its own history name below. - if !indices.contains(&index) { - return Err(DocError::Invalid("this face has no supported construction certificate; choose a fixed plane instead".into())); - } - self.coplanar_pieces(body, &indices, |_| true)?; - Ok(target) - }); - let target = match certified { - Ok(target) => target, - Err(error) => match body.body.planar_face(index).and_then(|plane| self.lineage_face_target(body, index, plane.origin)) { - Some(target) => target, - None => return Err(error), - }, - }; + let target = self.flat_face_target(body, index)?; let source = self .anchor_face_plane(body, index, target.certificate.as_ref()) .ok_or_else(|| DocError::Invalid("this face has no exact planar source; choose a fixed plane instead".into()))?; @@ -220,6 +195,34 @@ impl Document { Ok(anchor) } + /// A target for flat face `index` of `body` that a rebuild finds again: a construction + /// certificate that names this face alone, else its exact history name. What a sketch on a + /// face and a print face hold. + pub(crate) fn flat_face_target(&self, body: &ModelBody, index: usize) -> Result { + let certified = body + .body + .face_plane(index) + .ok_or_else(|| DocError::Invalid("this face has no exact planar source; choose a fixed plane instead".into())) + .and_then(|source| { + let target = self.strong_face_target(body, index, source.origin)?; + if target.certificate.is_none() { + return Err(DocError::Invalid("this face has no supported construction certificate; choose a fixed plane instead".into())); + } + let indices = self.configuration_face_indices(body, &target)?; + // A copy a pattern or mirror made on the same body carries its seed's certificate, + // which finds the seed's face: the copy is attached by its own history name below. + if !indices.contains(&index) { + return Err(DocError::Invalid("this face has no supported construction certificate; choose a fixed plane instead".into())); + } + self.coplanar_pieces(body, &indices, |_| true)?; + Ok(target) + }); + match certified { + Ok(target) => Ok(target), + Err(error) => body.body.planar_face(index).and_then(|plane| self.lineage_face_target(body, index, plane.origin)).ok_or(error), + } + } + /// The faces an attachment stands for, and a note when they were found by fallback. /// /// An extrude's cap is certified by the loop of sketch curves around it, so editing that diff --git a/crates/doc/src/format/pending/print-faces.rs b/crates/doc/src/format/pending/print-faces.rs new file mode 100644 index 000000000..88c7101e6 --- /dev/null +++ b/crates/doc/src/format/pending/print-faces.rs @@ -0,0 +1,5 @@ +//! A design saves the print face of its bodies (`print_faces`, by body name): the flat face a +//! slicer export lays on the print bed, held by the same face target a sketch on a face holds. +//! An older design has none, and every body is exported as it lies, as before. The last +//! release refuses a design that has print faces and asks for an update, instead of opening it +//! and losing them on the next save. diff --git a/crates/doc/src/lib.rs b/crates/doc/src/lib.rs index 0a750d01b..1d2d75dc2 100644 --- a/crates/doc/src/lib.rs +++ b/crates/doc/src/lib.rs @@ -61,6 +61,8 @@ pub use thread_catalog::{TappedThread, TappedThreadFamily, parse_tapped_thread, mod walk; pub use profile_refs::{capture_profile_selection, profile_fallback_notes, profile_selection_indices, profile_selection_indices_lenient}; pub mod plastic; +mod print_face; +pub use print_face::PrintFace; pub mod project; mod project3d; pub mod render_aging; diff --git a/crates/doc/src/placement_reuse.rs b/crates/doc/src/placement_reuse.rs index 473b4bd89..ca861e19d 100644 --- a/crates/doc/src/placement_reuse.rs +++ b/crates/doc/src/placement_reuse.rs @@ -127,6 +127,7 @@ fn same_geometry_inputs(a: &Document, b: &Document) -> bool { text_params, next_component_color_index, materials, + print_faces, user_materials, appearances, body_components, @@ -162,6 +163,7 @@ fn same_geometry_inputs(a: &Document, b: &Document) -> bool { && *text_params == b.text_params && *next_component_color_index == b.next_component_color_index && *materials == b.materials + && *print_faces == b.print_faces && *user_materials == b.user_materials && *appearances == b.appearances && *body_components == b.body_components diff --git a/crates/doc/src/print_face.rs b/crates/doc/src/print_face.rs new file mode 100644 index 000000000..180443b67 --- /dev/null +++ b/crates/doc/src/print_face.rs @@ -0,0 +1,105 @@ +//! The print face: the flat face of a body that a slicer export lays on the print bed (#8429). +//! A body has at most one (`Document::print_faces`, by body name). It is held by the target a +//! sketch on a face holds ([`Document::flat_face_target`]), so a rebuild that adds, removes or +//! reorders faces finds the same face again, or says it is gone. + +use solidcraft_geom::Vec3; + +use crate::config::ConfigFaceTarget; +use crate::{DocError, Document, ModelBody, ModelState, Result}; + +/// Where a print face is: a point on it and its outward unit normal, in the coordinates of the +/// body it was found on. +#[derive(Clone, Copy, Debug, PartialEq)] +pub struct PrintFace { + /// The face's index on the body (its first piece, when a change split it). + pub index: usize, + pub point: Vec3, + pub normal: Vec3, +} + +impl Document { + /// The target that marks flat face `index` of `body` as its print face. + pub fn print_face_target(&self, body: &ModelBody, index: usize) -> Result { + if body.body.is_mesh() { + return Err(DocError::Invalid("not supported yet: a print face on a mesh body".into())); + } + if body.body.planar_face(index).is_none() { + return Err(DocError::Invalid("only a flat face can be the print face".into())); + } + // The sketch-on-a-face wording ("choose a fixed plane") offers what a print face has not. + self.flat_face_target(body, index).map_err(|_| { + DocError::Invalid( + "this face can't be the print face: the body's history no longer tells it apart from its other faces (as after a shell of a shell body); pick a face of another body, or edit the feature that reshaped it".into(), + ) + }) + } + + /// Where `body`'s print face is now. `None`: it has none. An error: the face can't be found + /// any more, or is no longer flat. + pub fn print_face(&self, state: &ModelState, body: &ModelBody) -> Option> { + let target = self.print_faces.get(body.definition_name())?; + Some(self.locate_print_face(state, body, target)) + } + + /// The print face a copy of `source` gets (Move/Copy, Mirror): the face of `copy` named after + /// `source`'s print face (a copy's faces carry their source's names, followed by the copy's + /// instance, `F1:+x@F2.1`). `None`: + /// `source` has no print face. + pub fn copied_print_face(&self, state: &ModelState, source: &ModelBody, copy: &ModelBody) -> Option> { + let target = self.print_faces.get(source.definition_name())?; + let found = || { + let (indices, _) = self.anchored_face_indices(state, source, target)?; + let first = indices.first().copied().ok_or_else(|| DocError::Unknown("the print face no longer exists".into()))?; + let names = crate::naming::face_names(source); + let name = + names.get(first).map(|n| crate::naming::strip_piece(n)).ok_or_else(|| DocError::Unknown("the print face has no name".into()))?; + let index = crate::naming::face_names(copy) + .iter() + .position(|n| crate::naming::strip_piece(without_last_instance(n)) == name) + .ok_or_else(|| DocError::Unknown(format!("the copy has no face `{name}`")))?; + self.print_face_target(copy, index) + }; + Some(found()) + } + + fn locate_print_face(&self, state: &ModelState, body: &ModelBody, target: &ConfigFaceTarget) -> Result { + if body.body.is_mesh() { + return Err(DocError::Invalid("not supported yet: a print face on a mesh body".into())); + } + let (indices, _) = self.anchored_face_indices(state, body, target)?; + let first = indices.first().copied().ok_or_else(|| DocError::Unknown("the print face no longer exists".into()))?; + let plane = body.body.planar_face(first).ok_or_else(|| DocError::Invalid("the print face is no longer flat".into()))?; + let scale = 1. + body.body.size(); + for index in indices.iter().skip(1) { + let other = body.body.planar_face(*index).ok_or_else(|| DocError::Invalid("the print face is no longer flat".into()))?; + if plane.normal().dot(other.normal()).abs() < 1. - 1e-8 || (other.origin - plane.origin).dot(plane.normal()).abs() > 1e-7 * scale { + return Err(DocError::Invalid("the print face's pieces no longer lie on one plane".into())); + } + } + // The surface's own orientation is how the kernel built it, so the side the material is + // on is taken from the face's triangles, which point out of the body. + let mesh = body.mesh(); + let mut area = Vec3::ZERO; + for (t, f) in mesh.triangles.iter().zip(&mesh.tri_face) { + if let (true, Some([a, b, c])) = (indices.contains(&(*f as usize)), mesh.tri(t)) { + area += (b - a).cross(c - a); + } + } + let normal = plane.normal().normalized().ok_or_else(|| DocError::Invalid("the print face's plane is degenerate".into()))?; + let outward = area.dot(normal); + if !(outward.abs() > 0.) { + return Err(DocError::Invalid("the print face has no surface to lie on".into())); + } + Ok(PrintFace { index: first, point: plane.origin, normal: if outward < 0. { -normal } else { normal } }) + } +} + +/// A face name without the copy instance at its end (`F1:+x@F2.1` is `F1:+x`; a copy of a copy, +/// `F1:+x@F2.1@F5.1`, is `F1:+x@F2.1`). +fn without_last_instance(n: &str) -> &str { + let Some(at) = n.rfind('@') else { return n }; + let instance = n.get(at + 1..).and_then(|t| t.strip_prefix('F')).and_then(|t| t.split_once('.')); + let digits = |t: &str| !t.is_empty() && t.bytes().all(|b| b.is_ascii_digit()); + if instance.is_some_and(|(feature, k)| digits(feature) && digits(k)) { n.get(..at).unwrap_or(n) } else { n } +} diff --git a/crates/engine/src/cmd/features.rs b/crates/engine/src/cmd/features.rs index a9b53ef0b..9a38d94a2 100644 --- a/crates/engine/src/cmd/features.rs +++ b/crates/engine/src/cmd/features.rs @@ -1892,6 +1892,7 @@ fn move_body_feature(s: &mut Session, p: &Value) -> Result { )?; if copy { copy_keeps_appearance(s, &reply, &bodies, cmd)?; + super::print_face::copies_keep_print_faces(s, &reply, &bodies); } Ok(reply) } @@ -2098,7 +2099,12 @@ fn mirror(s: &mut Session, p: &Value) -> Result { let plane = plane_param(s, p.get("plane"), cmd)?; let combine = bool_(p, "combine").unwrap_or(false); let (bodies, placements) = placed_bodies(s, bodies, cmd)?; - add_feature(s, p, FeatureKind::Mirror { features, plane, bodies: bodies.into_iter().map(BodyName).collect(), combine, placements }) + let reply = + add_feature(s, p, FeatureKind::Mirror { features, plane, bodies: bodies.iter().cloned().map(BodyName).collect(), combine, placements })?; + if !combine { + super::print_face::copies_keep_print_faces(s, &reply, &bodies); + } + Ok(reply) } /// Bodies picked where the viewport shows them: each world name ("Body1", or "Body1 (Occ:2)" diff --git a/crates/engine/src/cmd/file.rs b/crates/engine/src/cmd/file.rs index 0ff5717d7..cb675a195 100644 --- a/crates/engine/src/cmd/file.rs +++ b/crates/engine/src/cmd/file.rs @@ -18,6 +18,7 @@ use solidcraft_doc::Document; use solidcraft_io::Format; use super::CommandSpec; +use super::print_face; use crate::params::{bad, bool_, num, str_, string_list}; use crate::{EngineError, Result, Session}; @@ -694,6 +695,26 @@ fn export_to( Ok(json!({"path": path, "bytes": bytes.len(), "format": format!("{format:?}")})) } +/// [`export_to`] for a mesh file a slicer is sent (STL or 3MF): each body laid on its print face. +#[cfg(not(target_arch = "wasm32"))] +fn export_laid_to( + s: &Session, + path: &str, + format: Format, + bodies: &[String], + parts: &[(String, Vec)], + quality: solidcraft_io::MeshQuality, +) -> Result { + let name = std::path::Path::new(path).file_stem().map(|x| x.to_string_lossy().to_string()).unwrap_or_else(|| s.doc.name.clone()); + let mut state = s.doc.painted(&s.world_state()); + let laid = print_face::lay_on_print_faces(s, &mut state, bodies, parts); + let bytes = solidcraft_io::export_with_parts(&state, bodies, parts, format, &name, &s.doc.metadata, quality)?; + solidcraft_io::vfs::write(path, &bytes).map_err(|e| EngineError::Other(format!("{path}: {e}")))?; + let mut out = json!({"path": path, "bytes": bytes.len(), "format": format!("{format:?}")}); + laid.report(&mut out); + Ok(out) +} + fn export(s: &mut Session, p: &Value) -> Result { let cmd = "file.export"; let path = path_arg(p, cmd)?; diff --git a/crates/engine/src/cmd/file_easyprint.rs b/crates/engine/src/cmd/file_easyprint.rs index ab8739269..64d71ea23 100644 --- a/crates/engine/src/cmd/file_easyprint.rs +++ b/crates/engine/src/cmd/file_easyprint.rs @@ -19,10 +19,12 @@ pub(super) struct Exported { pub fell_back: bool, /// The bodies that went in: the ones named, else the selected ones. pub bodies: Vec, + /// The bodies laid on their print face, and the ones that couldn't be. + pub laid: super::print_face::Laid, } -/// Export the bodies (the selected ones when none are named). A 3MF that can't be written is -/// written as an STL, and `fell_back` says so. +/// Export the bodies (the selected ones when none are named), each laid on its print face. A +/// 3MF that can't be written is written as an STL, and `fell_back` says so. pub(super) fn export_bodies(s: &Session, cmd: &str, named: &[String], format: Format) -> Result { let mut bodies = named.to_vec(); if bodies.is_empty() { @@ -31,7 +33,8 @@ pub(super) fn export_bodies(s: &Session, cmd: &str, named: &[String], format: Fo if bodies.is_empty() { return Err(bad(cmd, "select the bodies to send, or give `bodies`")); } - let doc = s.doc.painted(&s.world_state()); + let mut doc = s.doc.painted(&s.world_state()); + let laid = super::print_face::lay_on_print_faces(s, &mut doc, &bodies, &[]); let write = |format| solidcraft_io::export_with_metadata(&doc, &bodies, format, &s.doc.name, &s.doc.metadata); let mut fell_back = false; let (bytes, ext) = match (format, write(format)) { @@ -42,7 +45,7 @@ pub(super) fn export_bodies(s: &Session, cmd: &str, named: &[String], format: Fo } (_, Err(e)) => return Err(e.into()), }; - Ok(Exported { bytes, ext, fell_back, bodies }) + Ok(Exported { bytes, ext, fell_back, bodies, laid }) } pub(super) fn open_in_easyprint(s: &mut Session, p: &Value) -> Result { @@ -56,7 +59,7 @@ pub(super) fn open_in_easyprint(s: &mut Session, p: &Value) -> Result { if !bool_(p, "consent").unwrap_or(false) { return Err(bad(cmd, "this uploads the model to Printables' servers: ask the user, then pass `consent: true`")); } - let Exported { bytes, ext, fell_back, .. } = export_bodies(s, cmd, &string_list(cmd, p, "bodies")?, format)?; + let Exported { bytes, ext, fell_back, laid, .. } = export_bodies(s, cmd, &string_list(cmd, p, "bodies")?, format)?; if bytes.len() > MAX_BYTES { let mb = bytes.len().div_ceil(1_000_000); return Err(bad(cmd, format!("the model is {mb} MB and EasyPrint takes {} MB at most: send fewer bodies", MAX_BYTES / 1_000_000))); @@ -64,5 +67,7 @@ pub(super) fn open_in_easyprint(s: &mut Session, p: &Value) -> Result { let name = easyprint::file_name(&s.doc.name, ext); let size = bytes.len(); upload(&name, bytes).map_err(|e| bad(cmd, e))?; - Ok(json!({"file_name": name, "bytes": size, "format": ext, "stl_fallback": fell_back, "uploading": true})) + let mut out = json!({"file_name": name, "bytes": size, "format": ext, "stl_fallback": fell_back, "uploading": true}); + laid.report(&mut out); + Ok(out) } diff --git a/crates/engine/src/cmd/file_send.rs b/crates/engine/src/cmd/file_send.rs index 1ed3d64bc..dd8788704 100644 --- a/crates/engine/src/cmd/file_send.rs +++ b/crates/engine/src/cmd/file_send.rs @@ -11,7 +11,7 @@ use serde_json::{Value, json}; use solidcraft_io::Format; use super::easyprint::{Exported, export_bodies}; -use super::export_to; +use super::export_laid_to; use crate::params::bad; use crate::slicers::{self, Slicer, TargetKind}; use crate::{EngineError, Result, Session}; @@ -81,7 +81,7 @@ pub(super) fn send(s: &mut Session, r: Send<'_>) -> Result { return Err(bad(r.cmd, format!("{} does not take {}", target.name, format_name(r.format)))); } let mut out = match r.dest { - Dest::Path(path) => export_to(s, path, r.format, &r.bodies, &r.parts, r.quality)?, + Dest::Path(path) => export_laid_to(s, path, r.format, &r.bodies, &r.parts, r.quality)?, Dest::Folder => write_in_folder(s, &r)?, }; let path = out.get("path").and_then(Value::as_str).unwrap_or_default().to_string(); @@ -92,11 +92,13 @@ pub(super) fn send(s: &mut Session, r: Send<'_>) -> Result { /// Write the bodies into the slicer folder. fn write_in_folder(s: &mut Session, r: &Send<'_>) -> Result { use crate::slicer_files; - let Exported { bytes, ext, fell_back, bodies } = export_bodies(s, r.cmd, &r.bodies, r.format)?; + let Exported { bytes, ext, fell_back, bodies, laid } = export_bodies(s, r.cmd, &r.bodies, r.format)?; let dir = slicer_files::dir().ok_or_else(|| bad(r.cmd, "no per-user folder on this system"))?; let stem = slicer_files::stem(&s.doc.name, s.path.as_deref(), s.uid, &bodies); let (file, numbered) = slicer_files::write(&dir, &stem, ext, &bytes).map_err(|e| EngineError::Other(format!("{}: {e}", dir.display())))?; - Ok(json!({"path": file.to_string_lossy(), "bytes": bytes.len(), "format": ext, "numbered": numbered, "stl_fallback": fell_back})) + let mut out = json!({"path": file.to_string_lossy(), "bytes": bytes.len(), "format": ext, "numbered": numbered, "stl_fallback": fell_back}); + laid.report(&mut out); + Ok(out) } /// Hand the file at `path` to `target`, starting it first if it has to be, and say what happened in diff --git a/crates/engine/src/cmd/mod.rs b/crates/engine/src/cmd/mod.rs index e5750d203..ab45073b3 100644 --- a/crates/engine/src/cmd/mod.rs +++ b/crates/engine/src/cmd/mod.rs @@ -78,6 +78,7 @@ mod kernel_heal_tests; mod parameter_sweep; mod parameters; mod plastic; +mod print_face; mod render; mod render_ui; #[cfg(test)] @@ -332,6 +333,7 @@ pub fn command_specs() -> Vec<&'static CommandSpec> { v.extend(parameters::COMMANDS.iter()); v.extend(parameter_sweep::COMMANDS.iter()); v.extend(file::COMMANDS.iter()); + v.extend(print_face::COMMANDS.iter()); v.extend(metadata::COMMANDS.iter()); v.extend(inspect::COMMANDS.iter()); v.extend(compare::COMMANDS.iter()); diff --git a/crates/engine/src/cmd/print_face.rs b/crates/engine/src/cmd/print_face.rs new file mode 100644 index 000000000..f25448903 --- /dev/null +++ b/crates/engine/src/cmd/print_face.rs @@ -0,0 +1,417 @@ +//! Laying bodies on their print face for a slicer (#8429). The bodies being sent are copied (the +//! state the export writes is already a copy), and each copy whose body has a print face is +//! turned so the face points down, its centre of mass moved onto the world origin in X and Y, +//! and the face moved onto Z = 0: one rigid transform, applied once. The design and its timeline +//! are not touched. Each body is placed on its own, so several land on the origin together and +//! the slicer arranges them. + +use serde_json::Value; +use solidcraft_doc::{ModelState, PrintFace}; +use solidcraft_geom::Vec3; + +use super::CommandSpec; +use crate::params::{bad, str_}; +use crate::schema::print_face::PrintFaceResult; +use crate::{EngineError, Result, Session}; + +pub static COMMANDS: &[CommandSpec] = &[CommandSpec::new("body.print_face", "Print Face", crate::checked!("body.print_face", print_face)) + .icon("print_face") + .key("Ctrl+B") + .contract(&PRINT_FACE_CONTRACT) + .output(crate::schema::output_schema_for::) + .params("body: its name; point?: [x, y, z] on a flat face of it, in mm (omit to clear) → {body, face?}: marks the face a slicer export (file.send_to_slicer, file.save_mesh with slicer, file.open_in_easyprint) lays the body on: turned so the face points down at Z = 0, the centre of mass over the origin. One per body, replacing the last; flat faces of solid bodies only. A print face that is gone or no longer flat is reported in the export's warnings, and the body exported as it lies")]; + +const PRINT_FACE_CONTRACT: crate::schema::TypedContract = crate::schema::TypedContract::new(); + +/// Mark or clear a body's print face. +fn print_face(s: &mut Session, p: &Value) -> Result { + let cmd = "body.print_face"; + let name = str_(p, "body").ok_or_else(|| bad(cmd, "give `body`"))?; + let point = match p.get("point") { + None | Some(Value::Null) => None, + Some(v) => Some(crate::params::vec3(v).ok_or_else(|| bad(cmd, "`point` must be [x, y, z] of numbers"))?), + }; + let world = s.world_state(); + let body = world.body(name).ok_or_else(|| bad(cmd, format!("no body `{name}`")))?; + let key = body.definition_name().to_string(); + let face = match point { + None => { + s.doc_mut().print_faces.remove(&key); + None + } + Some(point) => { + let index = solidcraft_doc::appearance::face_index_at(body, point).ok_or_else(|| bad(cmd, "no face of the body at `point`"))?; + let target = s.doc.print_face_target(body, index).map_err(|e| bad(cmd, e.to_string()))?; + let face = target.name.clone(); + s.doc_mut().print_faces.insert(key, target); + Some(face) + } + }; + let reply = PrintFaceResult { body: name.to_string(), face, param_warnings: Vec::new() }; + serde_json::to_value(reply).map_err(|e| EngineError::Other(e.to_string())) +} + +/// Which bodies were laid on their print face, and a warning for each that has one but was +/// exported as it lies. +#[derive(Debug, Default)] +pub(super) struct Laid { + pub bodies: Vec, + pub warnings: Vec, +} + +impl Laid { + /// Add what happened to an export's reply. + pub(super) fn report(self, out: &mut serde_json::Value) { + let Some(obj) = out.as_object_mut() else { return }; + if !self.bodies.is_empty() { + obj.insert("print_faces".into(), serde_json::json!(self.bodies)); + } + if !self.warnings.is_empty() { + obj.insert("warnings".into(), serde_json::json!(self.warnings)); + } + } +} + +/// Copies keep the print faces of the bodies they were made from (Move/Copy, Mirror), as they +/// keep their look: the copies are the bodies feature `reply` made, in the order of `sources`. +/// A copy whose face can't be matched is left without one. +pub(super) fn copies_keep_print_faces(s: &mut Session, reply: &Value, sources: &[String]) { + let Some(id) = reply.get("feature").and_then(Value::as_u64) else { return }; + let state = s.model.state(); + let copies: Vec<_> = state.bodies.iter().filter(|b| b.feature == id).collect(); + if copies.len() != sources.len() { + return; + } + let mut inherited = Vec::new(); + for (source, copy) in sources.iter().zip(copies) { + let Some(source) = state.body(source) else { continue }; + if let Some(Ok(target)) = s.doc.copied_print_face(&state, source, copy) { + inherited.push((copy.definition_name().to_string(), target)); + } + } + for (body, target) in inherited { + s.doc_mut().print_faces.insert(body, target); + } +} + +/// Lay the bodies of `state` named in `bodies` (all of them when it is empty) on their print faces. +/// A body that is one of several parts of a 3MF object (`parts`, `objects: component`) stays as it +/// lies, so the object keeps its shape: turning one part on its own would pull it out of the rest. +pub(super) fn lay_on_print_faces(s: &Session, state: &mut ModelState, bodies: &[String], parts: &[(String, Vec)]) -> Laid { + let mut laid = Laid::default(); + let mut moves = Vec::new(); + for (i, b) in state.bodies.iter().enumerate() { + if !bodies.is_empty() && !bodies.contains(&b.name) { + continue; + } + if let Some((object, _)) = parts.iter().find(|(_, members)| members.contains(&b.name)) { + if s.doc.print_faces.contains_key(b.definition_name()) { + laid.warnings.push(format!("`{}` was exported as it lies: it is a part of the object `{object}`, which keeps its shape", b.name)); + } + continue; + } + let face = match s.doc.print_face(state, b) { + None => continue, + Some(Ok(face)) => face, + Some(Err(e)) => { + laid.warnings.push(format!("`{}` was exported as it lies: {e}", b.name)); + continue; + } + }; + let centre = match solidcraft_kernel::measure_mass(&b.body) { + Ok(m) => m.centroid, + Err(e) => { + laid.warnings.push(format!("`{}` was exported as it lies: no centre of mass ({e})", b.name)); + continue; + } + }; + moves.push((i, bed_matrix(face, centre))); + } + for (i, m) in moves { + let Some(b) = state.bodies.get_mut(i) else { continue }; + match solidcraft_kernel::transform_matrix(&b.body, m) { + Ok(body) => { + b.body = body; + laid.bodies.push(b.name.clone()); + } + Err(e) => laid.warnings.push(format!("`{}` was exported as it lies: {e}", b.name)), + } + } + laid +} + +/// The rotation (rows) that turns unit vector `n` to −Z. A face that already points down is +/// left as it is; one that points straight up is turned half a turn about X. +fn turn_down(n: Vec3) -> [Vec3; 3] { + let down = Vec3::new(0., 0., -1.); + let c = n.dot(down); + let v = n.cross(down); + let s2 = v.len2(); + if s2 <= 1e-24 { + return if c > 0. { [Vec3::X, Vec3::Y, Vec3::Z] } else { [Vec3::X, -Vec3::Y, -Vec3::Z] }; + } + // Rodrigues: R e = e + v × e + v × (v × e) (1 − c) / |v|²; these are R's columns. + let k = (1. - c) / s2; + let [x, y, z] = [Vec3::X, Vec3::Y, Vec3::Z].map(|e| e + v.cross(e) + v.cross(v.cross(e)) * k); + [Vec3::new(x.x, y.x, z.x), Vec3::new(x.y, y.y, z.y), Vec3::new(x.z, y.z, z.z)] +} + +/// The column-major transform that lays `face` on the bed with `centre` above the origin. +fn bed_matrix(face: PrintFace, centre: Vec3) -> [[f64; 4]; 4] { + let r = turn_down(face.normal); + let apply = |p: Vec3| Vec3::new(r[0].dot(p), r[1].dot(p), r[2].dot(p)); + let c = apply(centre); + let z = apply(face.point).z; + let t = Vec3::new(-c.x, -c.y, -z); + [[r[0].x, r[1].x, r[2].x, 0.], [r[0].y, r[1].y, r[2].y, 0.], [r[0].z, r[1].z, r[2].z, 0.], [t.x, t.y, t.z, 1.]] +} + +#[cfg(test)] +mod tests { + use super::*; + use serde_json::json; + + fn run(s: &mut Session, id: &str, p: Value) -> Value { + match s.execute(id, &p) { + Ok(v) => v, + Err(e) => panic!("{id} {p}: {e}"), + } + } + + /// A box `L` x 10 x 5 (L = 20 mm) from the origin, called Block. + fn block() -> Session { + let mut s = Session::default(); + run(&mut s, "parameters.add", json!({"name": "L", "expression": "20 mm"})); + run(&mut s, "solid.box", json!({"length": "L", "width": 10, "height": 5, "corner": [0, 0, 0], "body_name": "Block"})); + s + } + + /// Lay every body of `s` on its print face, as a slicer export does: Block's box and centre + /// of mass afterwards, and what was reported. + fn laid(s: &Session) -> (solidcraft_geom::Aabb3, Vec3, Laid) { + let mut state = s.doc.painted(&s.world_state()); + let laid = lay_on_print_faces(s, &mut state, &[], &[]); + let block = state.bodies.iter().find(|b| b.name == "Block").expect("Block"); + let m = solidcraft_kernel::measure_mass(&block.body).expect("measure"); + (m.bbox, m.centroid, laid) + } + + fn near(a: f64, b: f64) -> bool { + (a - b).abs() < 1e-6 + } + + #[test] + fn a_part_of_a_3mf_object_keeps_its_place_in_the_object() { + // With `objects: component` the bodies of a component are the parts of one object: + // turning one of them on its own would pull it out of the others, so it stays as it lies. + let mut s = block(); + run(&mut s, "body.print_face", json!({"body": "Block", "point": [20, 5, 2.5]})); + let mut state = s.doc.painted(&s.world_state()); + let parts = [("Bracket".to_string(), vec!["Block".to_string(), "Other".to_string()])]; + let laid = lay_on_print_faces(&s, &mut state, &[], &parts); + assert!(laid.bodies.is_empty(), "{:?}", laid.bodies); + assert_eq!(laid.warnings.len(), 1, "{:?}", laid.warnings); + assert!(laid.warnings.first().is_some_and(|w| w.contains("Block") && w.contains("Bracket")), "{:?}", laid.warnings); + let block = state.bodies.iter().find(|b| b.name == "Block").expect("Block"); + let bbox = solidcraft_kernel::measure_mass(&block.body).expect("measure").bbox; + assert!(near(bbox.min.x, 0.) && near(bbox.max.x, 20.) && near(bbox.max.z, 5.), "{bbox:?}"); + } + + #[test] + fn a_side_face_is_laid_down_at_z_0_with_the_centre_of_mass_over_the_origin() { + let mut s = block(); + let reply = run(&mut s, "body.print_face", json!({"body": "Block", "point": [20, 5, 2.5]})); + assert!(reply["face"].is_string(), "{reply}"); + let (bbox, centre, laid) = laid(&s); + assert_eq!(laid.bodies, ["Block"]); + assert!(laid.warnings.is_empty(), "{:?}", laid.warnings); + // The 10 x 5 end face is on the bed, so the 20 mm length now stands up. + assert!(near(bbox.min.z, 0.) && near(bbox.max.z, 20.), "{bbox:?}"); + assert!(near(centre.x, 0.) && near(centre.y, 0.) && near(centre.z, 10.), "{centre:?}"); + assert!(near((bbox.max.x - bbox.min.x) * (bbox.max.y - bbox.min.y), 50.), "{bbox:?}"); + // The design itself has not moved. + let m = solidcraft_kernel::measure_mass(&s.model.state().bodies[0].body).expect("measure"); + assert!(near(m.bbox.min.x, 0.) && near(m.bbox.max.x, 20.) && near(m.bbox.max.z, 5.), "{:?}", m.bbox); + } + + #[test] + fn a_face_that_points_up_is_turned_over() { + let mut s = block(); + run(&mut s, "body.print_face", json!({"body": "Block", "point": [10, 5, 5]})); + let (bbox, centre, laid) = laid(&s); + assert_eq!(laid.bodies, ["Block"]); + assert!(near(bbox.min.z, 0.) && near(bbox.max.z, 5.), "{bbox:?}"); + assert!(near(bbox.max.x - bbox.min.x, 20.) && near(bbox.max.y - bbox.min.y, 10.), "{bbox:?}"); + assert!(near(centre.x, 0.) && near(centre.y, 0.) && near(centre.z, 2.5), "{centre:?}"); + } + + #[test] + fn the_print_face_follows_the_body_through_a_rebuild() { + let mut s = block(); + run(&mut s, "body.print_face", json!({"body": "Block", "point": [20, 5, 2.5]})); + run(&mut s, "parameters.change", json!({"name": "L", "expression": "30 mm"})); + let (bbox, centre, laid) = laid(&s); + assert!(laid.warnings.is_empty(), "{:?}", laid.warnings); + assert!(near(bbox.min.z, 0.) && near(bbox.max.z, 30.), "{bbox:?}"); + assert!(near(centre.x, 0.) && near(centre.y, 0.) && near(centre.z, 15.), "{centre:?}"); + } + + #[test] + fn without_a_print_face_the_body_is_exported_as_it_lies() { + let mut s = block(); + run(&mut s, "body.print_face", json!({"body": "Block", "point": [10, 5, 5]})); + let reply = run(&mut s, "body.print_face", json!({"body": "Block"})); + assert!(reply.get("face").is_none(), "{reply}"); + assert!(s.doc.print_faces.is_empty()); + let (bbox, _, laid) = laid(&s); + assert!(laid.bodies.is_empty() && laid.warnings.is_empty()); + assert!(near(bbox.min.x, 0.) && near(bbox.max.x, 20.) && near(bbox.min.z, 0.) && near(bbox.max.z, 5.), "{bbox:?}"); + } + + #[test] + fn a_print_face_that_was_cut_away_is_reported_and_the_body_exported_as_it_lies() { + let mut s = block(); + run(&mut s, "body.print_face", json!({"body": "Block", "point": [10, 5, 5]})); + // A cut takes the top 2 mm off: the marked face is gone; the new top is the cut's. + run(&mut s, "solid.box", json!({"length": 30, "width": 20, "height": 5, "corner": [-5, -5, 3], "operation": "cut"})); + let (bbox, _, laid) = laid(&s); + assert!(laid.bodies.is_empty()); + assert_eq!(laid.warnings.len(), 1, "{:?}", laid.warnings); + assert!(laid.warnings[0].contains("Block"), "{:?}", laid.warnings); + assert!(near(bbox.min.x, 0.) && near(bbox.max.z, 3.), "{bbox:?}"); + } + + #[test] + fn a_print_face_is_saved_with_the_design_and_an_older_design_has_none() { + let mut s = block(); + run(&mut s, "body.print_face", json!({"body": "Block", "point": [10, 5, 5]})); + let saved = serde_json::to_value(&*s.doc).expect("save"); + assert!(saved["print_faces"]["Block"].is_object(), "{}", saved["print_faces"]); + let opened: solidcraft_doc::Document = serde_json::from_value(saved.clone()).expect("open"); + assert_eq!(opened.print_faces, s.doc.print_faces); + let mut older = saved; + older.as_object_mut().expect("object").remove("print_faces"); + let opened: solidcraft_doc::Document = serde_json::from_value(older).expect("open"); + assert!(opened.print_faces.is_empty()); + } + + #[test] + fn renaming_the_body_keeps_its_print_face() { + let mut s = block(); + run(&mut s, "body.print_face", json!({"body": "Block", "point": [10, 5, 5]})); + run(&mut s, "body.rename", json!({"body": "Block", "name": "Lid"})); + assert!(s.doc.print_faces.contains_key("Lid") && !s.doc.print_faces.contains_key("Block")); + assert_eq!(s.doc.print_faces["Lid"].body, "Lid"); + } + + /// Every body laid on its print face: (name, box, centre of mass) of those laid. + fn all_laid(s: &Session) -> Vec<(String, solidcraft_geom::Aabb3, Vec3)> { + let mut state = s.doc.painted(&s.world_state()); + let laid = lay_on_print_faces(s, &mut state, &[], &[]); + assert!(laid.warnings.is_empty(), "{:?}", laid.warnings); + laid.bodies + .iter() + .map(|name| { + let b = state.bodies.iter().find(|b| &b.name == name).expect("laid body"); + let m = solidcraft_kernel::measure_mass(&b.body).expect("measure"); + (name.clone(), m.bbox, m.centroid) + }) + .collect() + } + + #[test] + fn a_copy_keeps_the_print_face_of_the_body_it_was_copied_from() { + let mut s = block(); + run(&mut s, "body.print_face", json!({"body": "Block", "point": [20, 5, 2.5]})); + run(&mut s, "solid.move", json!({"bodies": ["Block"], "translate": [0, 50, 0], "copy": true})); + assert_eq!(s.doc.print_faces.len(), 2, "{:?}", s.doc.print_faces.keys().collect::>()); + let laid = all_laid(&s); + assert_eq!(laid.len(), 2, "{laid:?}"); + for (name, bbox, centre) in &laid { + assert!(near(bbox.min.z, 0.) && near(bbox.max.z, 20.), "{name}: {bbox:?}"); + assert!(near(centre.x, 0.) && near(centre.y, 0.), "{name}: {centre:?}"); + } + } + + #[test] + fn a_mirrored_copy_keeps_the_mirrored_print_face() { + let mut s = block(); + // The end at X = 20; its mirror image in YZ is the copy's end at X = -20. + run(&mut s, "body.print_face", json!({"body": "Block", "point": [20, 5, 2.5]})); + run(&mut s, "solid.mirror", json!({"bodies": ["Block"], "plane": "YZ"})); + assert_eq!(s.doc.print_faces.len(), 2, "{:?}", s.doc.print_faces.keys().collect::>()); + let copy = s.doc.print_faces.keys().find(|k| *k != "Block").expect("the copy's print face").clone(); + let world = s.world_state(); + let body = world.body(©).expect("copy"); + let face = s.doc.print_face(&world, body).expect("marked").expect("found"); + assert!(near(face.point.x, -20.) && near(face.normal.x, -1.), "{face:?}"); + let laid = all_laid(&s); + assert_eq!(laid.len(), 2, "{laid:?}"); + for (name, bbox, _) in &laid { + assert!(near(bbox.min.z, 0.) && near(bbox.max.z, 20.), "{name}: {bbox:?}"); + } + } + + #[test] + fn a_copy_of_a_body_without_a_print_face_gets_none() { + let mut s = block(); + run(&mut s, "solid.move", json!({"bodies": ["Block"], "translate": [0, 50, 0], "copy": true})); + run(&mut s, "solid.mirror", json!({"bodies": ["Block"], "plane": "XZ"})); + assert!(s.doc.print_faces.is_empty()); + } + + #[test] + fn a_point_off_the_body_or_a_body_that_is_not_there_is_refused() { + let mut s = block(); + assert!(s.execute("body.print_face", &json!({"body": "Block", "point": [100, 100, 100]})).is_err()); + assert!(s.execute("body.print_face", &json!({"body": "Nope", "point": [10, 5, 5]})).is_err()); + assert!(s.execute("body.print_face", &json!({"body": "Block", "point": "top"})).is_err()); + assert!(s.doc.print_faces.is_empty()); + } + + fn turned(n: Vec3) -> Vec3 { + let r = turn_down(n); + Vec3::new(r[0].dot(n), r[1].dot(n), r[2].dot(n)) + } + + #[test] + fn every_normal_is_turned_to_point_down_by_a_rotation() { + let down = Vec3::new(0., 0., -1.); + for n in [Vec3::X, -Vec3::X, Vec3::Y, -Vec3::Y, Vec3::Z, -Vec3::Z, Vec3::new(1., 2., 3.), Vec3::new(-0.3, 0.1, 0.9), Vec3::new(1e-9, 0., 1.)] + { + let n = n.normalized().unwrap(); + assert!(turned(n).dist(down) < 1e-12, "{n:?} → {:?}", turned(n)); + let r = turn_down(n); + // Orthonormal rows with a positive determinant: a rotation, never a mirror. + for i in 0..3 { + assert!((r[i].len() - 1.).abs() < 1e-12); + for j in i + 1..3 { + assert!(r[i].dot(r[j]).abs() < 1e-12); + } + } + assert!((r[0].cross(r[1]).dot(r[2]) - 1.).abs() < 1e-12); + } + } + + #[test] + fn a_face_that_points_straight_up_is_turned_half_a_turn_about_x() { + let r = turn_down(Vec3::Z); + assert_eq!(r, [Vec3::X, -Vec3::Y, -Vec3::Z]); + } + + #[test] + fn the_bed_matrix_puts_the_face_at_z_0_and_the_centre_over_the_origin() { + let face = PrintFace { index: 0, point: Vec3::new(3., 4., 10.), normal: Vec3::Z }; + let m = bed_matrix(face, Vec3::new(3., 4., 5.)); + let apply = |p: Vec3| { + Vec3::new( + m[0][0] * p.x + m[1][0] * p.y + m[2][0] * p.z + m[3][0], + m[0][1] * p.x + m[1][1] * p.y + m[2][1] * p.z + m[3][1], + m[0][2] * p.x + m[1][2] * p.y + m[2][2] * p.z + m[3][2], + ) + }; + assert!(apply(face.point).z.abs() < 1e-12); + let c = apply(Vec3::new(3., 4., 5.)); + assert!(c.x.abs() < 1e-12 && c.y.abs() < 1e-12 && c.z > 0., "{c:?}"); + } +} diff --git a/crates/engine/src/lib.rs b/crates/engine/src/lib.rs index 23f273d29..40fe32090 100644 --- a/crates/engine/src/lib.rs +++ b/crates/engine/src/lib.rs @@ -1976,6 +1976,7 @@ fn same_but_features(a: &Document, b: &Document) -> bool { point_clouds, param_comments, materials, + print_faces, user_materials, appearances, body_components, @@ -2011,6 +2012,7 @@ fn same_but_features(a: &Document, b: &Document) -> bool { && *point_clouds == b.point_clouds && *param_comments == b.param_comments && *materials == b.materials + && *print_faces == b.print_faces && *user_materials == b.user_materials && *appearances == b.appearances && *body_components == b.body_components diff --git a/crates/engine/src/schema/mod.rs b/crates/engine/src/schema/mod.rs index 7efaeae8e..04a13fbe4 100644 --- a/crates/engine/src/schema/mod.rs +++ b/crates/engine/src/schema/mod.rs @@ -59,6 +59,7 @@ pub mod construct; pub mod edit; pub mod features; pub mod inspect; +pub mod print_face; pub mod render; pub mod render_lights; pub mod render_ui; diff --git a/crates/engine/src/schema/print_face.rs b/crates/engine/src/schema/print_face.rs new file mode 100644 index 000000000..88d10bc9d --- /dev/null +++ b/crates/engine/src/schema/print_face.rs @@ -0,0 +1,74 @@ +//! Contracts and result types for the commands in `cmd/print_face.rs`. + +use schemars::JsonSchema; +use serde::{Deserialize, Serialize}; + +use super::types::Point3; + +/// Mark the flat face of a body at a point as the body's print face, or clear it. A slicer +/// export (`file.send_to_slicer`, `file.save_mesh` with `slicer`, `file.open_in_easyprint`) lays +/// the body on its print face: turned so the face points down and lies at Z = 0, the centre of +/// mass over the origin. A body has one print face at most; marking another replaces it. +#[derive(Debug, Deserialize, JsonSchema)] +#[schemars(deny_unknown_fields)] +pub struct PrintFaceParams { + /// The body, by name. Solid bodies only: a mesh body can't have a print face yet. + pub body: String, + /// A point on the flat face to mark, in mm. Default: none, which clears the body's print face. + #[serde(default)] + pub point: Option, +} + +/// What `body.print_face` returns. +#[derive(Debug, Serialize, JsonSchema)] +pub struct PrintFaceResult { + /// The body. + pub body: String, + /// The persistent name of the face now marked. Absent when the print face was cleared. + #[serde(default, skip_serializing_if = "Option::is_none")] + pub face: Option, + /// In the warn parameter-check mode: what the call's parameters got wrong. + #[serde(default, skip_serializing_if = "Vec::is_empty")] + pub param_warnings: Vec, +} + +#[cfg(test)] +mod tests { + use serde_json::json; + + use super::PrintFaceParams; + use crate::Session; + use crate::schema::input_schema_for; + use crate::schema::tests::assert_keys; + + #[test] + fn schemas_and_the_key_check_agree() { + assert_keys(input_schema_for::(), &["body", "point"]); + } + + #[test] + fn bad_calls_say_what_is_wrong_and_change_nothing() { + let mut s = Session::default(); + s.execute("solid.box", &json!({"length": 20, "width": 10, "height": 5, "body_name": "Block"})).unwrap_or_else(|e| panic!("{e}")); + let undo = s.undo.len(); + let e = s.execute("body.print_face", &json!({"point": [20, 5, 2.5]})).unwrap_err().to_string(); + assert!(e.contains("body"), "{e}"); + let e = s.execute("body.print_face", &json!({"body": "Bracket", "point": [20, 5, 2.5]})).unwrap_err().to_string(); + assert!(e.contains("Bracket"), "{e}"); + let e = s.execute("body.print_face", &json!({"body": "Block", "point": "top"})).unwrap_err().to_string(); + assert!(e.contains("point"), "{e}"); + assert!(s.doc.print_faces.is_empty() && s.undo.len() == undo); + } + + #[test] + fn the_reply_names_the_marked_face_and_leaves_it_out_when_cleared() { + let mut s = Session::default(); + s.execute("solid.box", &json!({"length": 20, "width": 10, "height": 5, "body_name": "Block"})).unwrap_or_else(|e| panic!("{e}")); + let r = s.execute("body.print_face", &json!({"body": "Block", "point": [20, 5, 2.5]})).unwrap_or_else(|e| panic!("{e}")); + assert_eq!(r["body"], "Block"); + assert!(r["face"].as_str().is_some_and(|f| !f.is_empty()), "{r}"); + let r = s.execute("body.print_face", &json!({"body": "Block"})).unwrap_or_else(|e| panic!("{e}")); + assert_eq!(r["body"], "Block"); + assert!(r.get("face").is_none(), "{r}"); + } +} diff --git a/crates/ui-egui/src/context_menu.rs b/crates/ui-egui/src/context_menu.rs index 993bd040d..643f061eb 100644 --- a/crates/ui-egui/src/context_menu.rs +++ b/crates/ui-egui/src/context_menu.rs @@ -667,6 +667,9 @@ fn viewport_items(app: &SolveApp) -> Vec { let planar = sel.iter().any(|s| matches!(s, Sel::Face { body, index, .. } if crate::dialogs::planar_face(&app.session, body, *index).is_some())); v.push(act("ui.lookAt", "Look At", "lookat").on(planar)); + let marked = matches!(sel.as_slice(), [Sel::Face { body, index, .. }] if crate::print_face_ui::is_print_face(app, body, *index)); + let one_flat = planar && matches!(sel.as_slice(), [Sel::Face { .. }]); + v.push(cmd(app, "body.print_face", if marked { "Clear Print Face" } else { "Print Face" }).on(one_flat)); v.push(Item::sep()); v.push(act("ui.appearance", "Appearance", "appearance").key("A")); v.push(act("ui.properties", "Properties", "measure").with(json!({ "bodies": [face] }))); diff --git a/crates/ui-egui/src/dialogs_save_mesh.rs b/crates/ui-egui/src/dialogs_save_mesh.rs index 495a4e516..c4ec7b72c 100644 --- a/crates/ui-egui/src/dialogs_save_mesh.rs +++ b/crates/ui-egui/src/dialogs_save_mesh.rs @@ -3,6 +3,10 @@ //! send the bodies to: it always asks, and pre-selects the slicer used last time. The list also has //! a plain text row for EasyPrint (`file.open_in_easyprint`), which works in a browser too. //! +//! Send to Slicer also has a Print face input (#8429): it shows the print face of the one body being +//! sent, takes a flat face picked in the viewport as that body's print face, and clears it when +//! emptied. Each change runs `body.print_face` at once, so it undoes like any other. +//! //! Every place that saves a mesh opens this dialog: File › Export STL / Export 3MF, the Mesh tab, and the //! Save As Mesh item of the body menus. The slicer list (Send to Slicer only) holds the programs the user added (kept //! between runs, newest first), then the slicers found on this machine, then "Custom…", which asks @@ -19,7 +23,7 @@ use solidcraft_engine::slicers::{self, Slicer}; use crate::SolveApp; use crate::dialogs::{Kind, form_row}; -use crate::selection::{BODIES, SelInput}; +use crate::selection::{BODIES, PLANAR_FACES, SelInput}; use crate::theme::Tokens; use solidcraft_engine::Sel; @@ -47,6 +51,9 @@ pub struct SaveMesh { slicer: String, /// The slicer list has not been read for this opening yet. stale: bool, + /// Send to Slicer: the bodies and the print face the Print face input last showed, to tell + /// a pick or a clear in it from a change of the bodies. + shown: Option<(Vec, Option)>, } impl SaveMesh { @@ -128,8 +135,12 @@ pub fn start(app: &SolveApp, id: &str) -> Option<(Kind, Vec)> { _ => String::new(), }; let quality = QUALITIES.iter().position(|q| q.1 == p.save_mesh_quality).unwrap_or(0); - let kind = Kind::SaveMesh(SaveMesh { format, quality, open, slicer, stale: true }); - Some((kind, vec![SelInput::new("Bodies", BODIES, true)])) + let kind = Kind::SaveMesh(SaveMesh { format, quality, open, slicer, stale: true, shown: None }); + let mut inputs = vec![SelInput::new("Bodies", BODIES, true)]; + if open { + inputs.push(SelInput::new("Print face", PLANAR_FACES, false)); + } + Some((kind, inputs)) } /// Send to Slicer needs a way to start a program (a browser has none) or a way to reach EasyPrint. @@ -310,8 +321,44 @@ pub(crate) fn body_picks(app: &SolveApp, visible: bool) -> Vec { st.bodies.iter().filter(|b| shown(&b.name)).map(|b| Sel::Body { name: b.name.clone() }).collect() } +/// Keep the Print face input and the design in step. A face picked into it becomes the print +/// face of its body, which must be the one body being sent; emptying it clears that body's print +/// face. When the bodies change, it shows the print face of the one body, or nothing for several. +fn sync_print_face(app: &mut SolveApp, k: &mut SaveMesh, inputs: &mut [SelInput]) { + let bodies = crate::selection::items(inputs, 0).body_names(); + let Some(input) = inputs.get_mut(1) else { return }; + let picked = input.items.first().cloned(); + match k.shown.take() { + Some((shown_bodies, shown)) if shown_bodies == bodies && shown != picked => { + let one = bodies.first().filter(|_| bodies.len() == 1).cloned(); + let target = match (&picked, &shown) { + (Some(Sel::Face { body, .. }), _) => Some(body.clone()), + (None, Some(Sel::Face { body, .. })) => Some(body.clone()), + _ => None, + }; + match (target, one) { + (Some(body), Some(one)) if body == one => { + crate::print_face_ui::set(app, &body, picked.as_ref()); + } + _ => app.set_status(crate::i18n::tr("ui.print_face_one_body"), true), + } + } + Some(shown) if shown.0 == bodies => { + k.shown = Some(shown); + return; + } + _ => {} + } + let current = bodies.first().filter(|_| bodies.len() == 1).and_then(|b| crate::print_face_ui::current(app, b)); + input.items = current.iter().cloned().collect(); + k.shown = Some((bodies, current)); +} + /// The rows after the Bodies input; true when Enter was pressed in a field. pub fn rows(app: &mut SolveApp, ui: &mut egui::Ui, k: &mut SaveMesh, inputs: &mut [SelInput]) -> bool { + if k.open { + sync_print_face(app, k, inputs); + } // One row each: the two side by side do not fit the dialog's width. for (label, visible) in [("Add all bodies", false), ("Add visible bodies", true)] { form_row(ui, "", |ui| { @@ -879,7 +926,7 @@ mod tests { #[test] fn send_to_slicer_asks_for_bodies_and_a_slicer_but_not_a_format() { - let k = SaveMesh { format: 0, quality: 0, open: true, slicer: "prusa".into(), stale: false }; + let k = SaveMesh { format: 0, quality: 0, open: true, slicer: "prusa".into(), stale: false, shown: None }; let mut input = SelInput::new("Bodies", BODIES, true); assert!(commands(&k, std::slice::from_ref(&input)).is_err()); input.items = vec![Sel::Body { name: "Part".into() }]; @@ -898,7 +945,7 @@ mod tests { fn a_remembered_quality_goes_to_save_but_not_to_send() { let mut input = SelInput::new("Bodies", BODIES, true); input.items = vec![Sel::Body { name: "Part".into() }]; - let k = SaveMesh { format: 0, quality: 2, open: true, slicer: "prusa".into(), stale: false }; + let k = SaveMesh { format: 0, quality: 2, open: true, slicer: "prusa".into(), stale: false, shown: None }; let (_, sent) = commands(&k, std::slice::from_ref(&input)).unwrap().remove(0); assert_eq!(sent.get("quality"), None, "sending has no quality row: the default applies"); let (_, saved) = commands(&SaveMesh { open: false, ..k }, &[input]).unwrap().remove(0); diff --git a/crates/ui-egui/src/lib.rs b/crates/ui-egui/src/lib.rs index 4b645b46f..564dec6fb 100644 --- a/crates/ui-egui/src/lib.rs +++ b/crates/ui-egui/src/lib.rs @@ -207,6 +207,7 @@ pub mod preview; mod primitive_placement; #[cfg(test)] mod primitive_units_tests; +mod print_face_ui; pub mod recovery_ui; pub mod ref_images; mod render_ui; @@ -1486,6 +1487,11 @@ impl SolveApp { } return; } + // Print Face (Ctrl+B) acts on the selected face at once: it has no dialog. + if id == "body.print_face" { + print_face_ui::toggle(self); + return; + } if id == "view.normal_to" { if self.run(id, json!({"camera": self.cam})).is_ok() { self.follow_view_request(true); diff --git a/crates/ui-egui/src/prefs.rs b/crates/ui-egui/src/prefs.rs index db633a825..c31184173 100644 --- a/crates/ui-egui/src/prefs.rs +++ b/crates/ui-egui/src/prefs.rs @@ -1231,6 +1231,9 @@ preference_settings! { send_slicer: String = String::new(); /// Slicers that can load a file into the window that is already open do so (default on). slicer_single_instance: bool = true, 0; + /// How strongly a print face stands out in the viewport (#8429): the share of the section + /// colour in its tint, 0 to 1; its outline follows. 0 draws no highlight. + print_face_highlight: f32 = 0.2, PAGE_GENERAL, accept(0.0..=1.0); /// The line about sending again replacing the slicer's file has been shown. slicer_resend_hint_seen: bool = false; /// The user has agreed to Open with EasyPrint uploading a model to Printables' servers. @@ -3431,6 +3434,9 @@ pub fn set(app: &mut SolveApp, p: &serde_json::Value) -> Result bool { + let world = app.session.world_state(); + world.body(body).and_then(|b| app.session.doc.print_face(&world, b)).and_then(Result::ok).is_some_and(|f| f.index == index) +} + +/// `body`'s print face as a face pick, for the Send to Slicer window; `None` when it has none, +/// or it can't be found. +pub(crate) fn current(app: &SolveApp, body: &str) -> Option { + let world = app.session.world_state(); + let b = world.body(body)?; + let face = app.session.doc.print_face(&world, b)?.ok()?; + let point = solidcraft_engine::doc::naming::face_spot(b, face.index).map_or(face.point, |spot| spot.point); + Some(Sel::Face { body: body.to_string(), index: face.index, point }) +} + +/// Mark face `face` as its body's print face (a face pick), or clear `body`'s with none. +pub(crate) fn set(app: &mut SolveApp, body: &str, face: Option<&Sel>) -> bool { + let params = match face { + Some(Sel::Face { body, point, .. }) => json!({"body": body, "point": [point.x, point.y, point.z]}), + _ => json!({"body": body}), + }; + app.run("body.print_face", params).is_ok() +} + +/// Ctrl+B and the face menu: the one selected face becomes its body's print face, or stops being +/// it when it already is. +pub(crate) fn toggle(app: &mut SolveApp) { + let picked = match app.session.selection.as_slice() { + [face @ Sel::Face { body, index, .. }] => Some((face.clone(), body.clone(), *index)), + _ => None, + }; + let Some((face, body, index)) = picked else { + app.set_status(crate::i18n::tr("ui.print_face_pick"), true); + return; + }; + let clear = is_print_face(app, &body, index); + if set(app, &body, if clear { None } else { Some(&face) }) { + let id = if clear { "ui.print_face_cleared" } else { "ui.print_face_set" }; + app.set_status(crate::i18n::format(id, &[("body", &body)]), false); + } +} + +#[cfg(test)] +mod tests { + use serde_json::json; + use solidcraft_engine::Sel; + + fn app() -> crate::SolveApp { + let mut app = crate::SolveApp::new(solidcraft_engine::Session::default(), crate::Services::default()); + app.run("solid.box", json!({"length": 20, "width": 10, "height": 5, "corner": [0, 0, 0], "body_name": "Block"})).unwrap(); + app + } + + /// Select the face of Block at `point`; its index. + fn select_face(app: &mut crate::SolveApp, point: [f64; 3]) -> usize { + let world = app.session.world_state(); + let body = world.body("Block").unwrap(); + let p = solidcraft_engine::geom::Vec3::new(point[0], point[1], point[2]); + let index = solidcraft_engine::doc::appearance::face_index_at(body, p).unwrap(); + app.session.selection = vec![Sel::Face { body: "Block".into(), index, point: p }]; + index + } + + #[test] + fn ctrl_b_marks_the_selected_face_and_clears_it_the_second_time() { + let mut app = app(); + let index = select_face(&mut app, [20.0, 5.0, 2.5]); + app.start("body.print_face"); + assert!(app.session.doc.print_faces.contains_key("Block")); + assert!(super::is_print_face(&app, "Block", index)); + assert!(super::current(&app, "Block").is_some()); + app.start("body.print_face"); + assert!(app.session.doc.print_faces.is_empty()); + assert!(super::current(&app, "Block").is_none()); + } + + #[test] + fn ctrl_b_without_one_face_selected_marks_nothing() { + let mut app = app(); + app.session.selection = vec![Sel::Body { name: "Block".into() }]; + app.start("body.print_face"); + assert!(app.session.doc.print_faces.is_empty()); + } + + #[test] + fn the_highlight_strength_defaults_to_a_fifth_and_ui_prefs_keeps_it_in_range() { + let mut app = app(); + assert!((app.preferences.print_face_highlight - 0.2).abs() < 1e-6); + crate::prefs::set(&mut app, &json!({"print_face_highlight": 0.5})).unwrap(); + assert!((app.preferences.print_face_highlight - 0.5).abs() < 1e-6); + assert!(crate::prefs::set(&mut app, &json!({"print_face_highlight": 1.5})).is_err()); + assert!((app.preferences.print_face_highlight - 0.5).abs() < 1e-6); + } +} diff --git a/crates/ui-egui/src/viewport.rs b/crates/ui-egui/src/viewport.rs index dd716dc54..1b12e2d94 100644 --- a/crates/ui-egui/src/viewport.rs +++ b/crates/ui-egui/src/viewport.rs @@ -3388,6 +3388,8 @@ fn highlight_geometry_key(app: &SolveApp) -> u64 { app.session.visibility.hidden_bodies.hash(&mut h); app.session.visibility.hidden_occurrences.hash(&mut h); app.session.visibility.hidden_folders.hash(&mut h); + // How strongly print faces are tinted (Preferences › General › Slicer). + app.preferences.print_face_highlight.to_bits().hash(&mut h); h.finish() } @@ -3745,6 +3747,32 @@ pub(crate) fn build_highlight(app: &SolveApp) -> GpuScene { (EdgeColours::new(&mut feedback, t.hover_edge, t.hover_edge_halo), EdgeColours::new(&mut feedback, t.sel_edge, t.sel_edge_rim)); let mut hover_instances = HighlightInstances::default(); let mut selected_instances = HighlightInstances::default(); + // Print faces (#8429): tinted towards the colour section views give cut faces, and outlined, + // so the face a slicer export lays its body on shows at a glance. Drawn before the selection, + // which lights over it. + // The share of that colour is the user's (Preferences › General › Slicer, default a fifth); the + // outline takes a little over twice it, so the face reads as marked without outshouting the model. + let strength = app.preferences.print_face_highlight.clamp(0.0, 1.0); + if !product && strength > 0.0 { + let cap = t.section_cap; + let blend = |from: u8, to: u8, k: f32| (f32::from(from) + (f32::from(to) - f32::from(from)) * k).round().clamp(0.0, 255.0) as u8; + let mix = |body: u8, tint: u8| blend(body, tint, strength); + let edge = t.body_edge; + let k = (strength * 2.25).min(1.0); + let rim = Color32::from_rgb(blend(edge.r(), cap.r(), k), blend(edge.g(), cap.g(), k), blend(edge.b(), cap.b(), k)); + let outline = EdgeColours::new(&mut feedback, rim, rim); + for b in st.bodies.iter().filter(|b| app.session.body_visible(&b.name) && !app.preview.effective_replaced().contains(&b.name)) { + let Some(Ok(face)) = s.doc.print_face(&st, b) else { continue }; + let (r, g, bl) = body_rgb(app, &b.name); + face_tris(&mut feedback, &shown(b), face.index, [mix(r, cap.r()), mix(g, cap.g()), mix(bl, cap.b()), 255], true); + let m = drawn_mesh(app, b); + for (ei, e) in m.edges.iter().enumerate() { + if m.edge_pickable(ei) && m.edge_faces.get(ei).is_some_and(|fs| fs.iter().any(|f| *f as usize == face.index)) { + edge_lines(&mut feedback, e, outline, 2.0, &[]); + } + } + } + } // Selected things. for x in &sel { match x { diff --git a/crates/ui-egui/tests/scenarios/print_face_ctrl_b.json b/crates/ui-egui/tests/scenarios/print_face_ctrl_b.json new file mode 100644 index 000000000..abb6cecfc --- /dev/null +++ b/crates/ui-egui/tests/scenarios/print_face_ctrl_b.json @@ -0,0 +1,16 @@ +[ + {"note":"#8429: Ctrl+B marks the one selected flat face as its body's print face, the design saves it, and Ctrl+B on it again clears it. Without a face selected it says what to select."}, + {"call":"engine.execute","params":{"command":"solid.box","params":{"length":20,"width":10,"height":5,"body_name":"Block"}}}, + {"call":"ui.camera","params":{"target":[10,5,2.5],"yaw":-0.785398,"pitch":0.61548,"distance":70}}, + {"key":"B","ctrl":true}, + {"expect":{"status":"Select one flat face","errors":0}}, + {"click":{"world":[20,5,2.5]}}, + {"expect":{"selection":1}}, + {"key":"B","ctrl":true}, + {"expect":{"status":"Block: print face set","errors":0}}, + {"shot":"print_face_ctrl_b"}, + {"call":"engine.execute","params":{"command":"file.save_as","params":{"path":"$DIR/print-face.json"}}}, + {"expect":{"file_contains":{"file":"print-face.json","text":"\"print_faces\""}}}, + {"key":"B","ctrl":true}, + {"expect":{"status":"Block: print face cleared","errors":0}} +] diff --git a/docs/book/src/guide/files.md b/docs/book/src/guide/files.md index 7156b007f..0e10f6be7 100644 --- a/docs/book/src/guide/files.md +++ b/docs/book/src/guide/files.md @@ -67,6 +67,17 @@ with a `slicer`, which sends without a dialog. They can start only the slicers i list and programs you added under **Custom…**; any other program path is refused, and an AI agent's request to save a mesh or send it to a slicer asks first and names the slicer. +A body can have a **print face**: the flat face it should lie on in the slicer. Select the face +and press **Ctrl+B** (or **Print Face** in the face's right-click menu); press it again to clear +it. The Send to Slicer window shows the print face of the one body being sent in its **Print +face** row, where you can pick another face in the viewport or clear it. Each send then turns a +copy of the body so the print face points down at Z = 0, with its centre of mass over the +origin; the design itself does not move. The face is tinted and outlined in the viewport, and a +copy made with Move/Copy or Mirror keeps it. A print face that is gone or no longer flat is +reported, and the body is sent as it lies. Curved faces and mesh bodies can't be print faces. +Known limitation: after a shell of a body that is already shelled, no face of that body can be +marked, as no sketch can be attached to one either; this needs kernel work, which is paused. + The list also has a plain **EasyPrint (Printables, in the browser)** row, and it is the one entry that works in the browser build too. EasyPrint is Printables' slicer, so choosing it uploads the selected bodies (a 3MF, 100 MB at most) to Printables' servers and opens the model there in your diff --git a/docs/book/src/reference/glossary.md b/docs/book/src/reference/glossary.md index 690a2e6bf..21740dc54 100644 --- a/docs/book/src/reference/glossary.md +++ b/docs/book/src/reference/glossary.md @@ -324,6 +324,19 @@ The first instance is the original. - **Elsewhere:** instance, element, occurrence. - **For translators:** not an occurrence of a component. +### print face + +The flat face of a body that lies on the print bed when the body is sent to a slicer. + +A body has one print face at most. The export turns a copy of the body so this face points down +at Z = 0, with the centre of mass over the origin; the design itself does not move. + +- **In SolidCraft:** `body.print_face`; the `print_faces` of a design; the `print_faces` and + `warnings` of a `file.send_to_slicer` reply. +- **Don't use:** bottom face, base face (both say where a face is now, not where it is printed). +- **Elsewhere:** place on face, lay flat, bed face. +- **For translators:** the face the part stands on while it prints, not the printer's bed. + ### reference edge A straight edge of a flat face that a Single hole's centre or a cylinder's base centre keeps a diff --git a/docs/control-protocol.md b/docs/control-protocol.md index d07a4bac1..54df79a9c 100644 --- a/docs/control-protocol.md +++ b/docs/control-protocol.md @@ -435,6 +435,7 @@ One setting per line, sorted by name. A change that adds a setting adds its own - `pan_reverse_y` (default false: vertical scrolling pans the other way) - `perspective_fov` (Perspective view's vertical field of view in radians, 0.2618…1.5708 (15°…90°), default 0.6; when it changes, the camera's distance scales so the view keeps its size) - `placement_handles` (default false: handles on the preview of a Rest, Boss or Snap Fit that move it across the model and turn it) +- `print_face_highlight` (0…1, default 0.2: how strongly a print face is tinted and outlined in the view, #8429; 0 draws no highlight) - `ribbon_reveal` (default false: hovering a result in Search commands switches the ribbon to the command's tab and marks its button, or opens the panel drop-down that holds it on its row, handle `ribbon:reveal`; leaving the results goes back to the tab before; a command started from the search blinks there, and a running command from a drop-down marks its panel label, `ribbon:running_section::
`, #7287) - `right_drag_orbits` (default true; false: a right drag the mouse preset would orbit leaves the camera alone, #6492) - `show_frame_rate` (default false: frames per second in the view's bottom-right corner, counting the frames the view draws anyway; it reads 0 FPS once the view is idle) diff --git a/docs/roadmap-detail.md b/docs/roadmap-detail.md index 157b420ab..9e680e194 100644 --- a/docs/roadmap-detail.md +++ b/docs/roadmap-detail.md @@ -404,6 +404,10 @@ completed drawings publish atomically. The browser still exports synchronously. - Associative shell-face sketches require a unique certified planar source. Nested shell attachments and ambiguous coincident sources remain unsupported. +- Print faces (#8429) are held like sketches on faces, so the same limit applies: after a shell + of a body that is already shelled, no face of that body has an exact name, and none can be + marked (`body.print_face` says so). Fixing it needs the shell to report its face history, + which is kernel work, paused for now (CONTRIBUTING.md, "Kernel work is paused"). - G2 fillets: exact quintic blends of straight edges between planar faces, with one planar end face at each end, including sloped ends (#2708). The UI and `solid.fillet` expose `curvature` (alias `g2`); the size is an equivalent circular setback. Curved faces/edges,