1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
//! # ALICE-LOL: Law-Oriented Language
//!
//! A text language for signed distance fields: the `lol!` macro (compile time)
//! and [`runtime_parser`] (run time) turn the same text into an
//! [`SdfNode`] tree, which can be evaluated on the CPU, transpiled to
//! GLSL / WGSL / HLSL, exported for 3D printing, and checked against
//! geometric constraints ([`law`]). [`research_law`] holds unit-checked
//! formulas with valid ranges, residuals and provenance.
//!
//! ```rust
//! use alice_lol::lol;
//! use alice_lol::runtime_parser::parse_lol;
//! use alice_lol::Vec3;
//!
//! // Compile time: the macro builds the tree
//! let scene = lol! {
//! smooth_union(0.2,
//! sphere(1.0),
//! translate(2.0, 0.0, 0.0, box3d(0.5, 0.5, 0.5))
//! )
//! };
//!
//! // Run time: the same text through the parser (from a file or a language model)
//! let parsed = parse_lol(
//! "smooth_union(0.2, sphere(1.0), translate(2.0, 0.0, 0.0, box3d(0.5, 0.5, 0.5)))",
//! )
//! .unwrap();
//!
//! // Both are the same field; the origin is inside the sphere
//! let p = Vec3::new(0.3, 0.1, 0.0);
//! assert_eq!(alice_lol::eval(&scene, p), alice_lol::eval(&parsed, p));
//! assert!(alice_lol::eval(&scene, Vec3::ZERO) < 0.0);
//!
//! // GLSL source for a shader (default feature `glsl`)
//! let glsl = alice_lol::to_glsl(&scene);
//! assert!(!glsl.is_empty());
//! ```
// ── ランタイム LOL パーサー(LLM Text-to-3D 用) ──
// `parse_lol("sphere(1.0)")` → `SdfNode` に変換
/// The LOL DSL grammar (`lol.gbnf`, GBNF) as shipped with this crate version.
///
/// Feature-free on purpose: downstream crates (the pipeline crate → text-to-print,
/// or any llama.cpp-compatible runtime) embed the *same* bytes instead of
/// keeping a copy that drifts. With `llm-bridge` enabled,
/// [`bridge::lol_grammar`] parses exactly this text.
///
/// The grammar is deliberately stricter than [`runtime_parser`] (no `//`
/// comments, at most one whitespace char between tokens); see the file
/// header for why.
pub const LOL_GBNF: &str = include_str!;
/// Canonicalizing a user-supplied angle before it is converted to radians
/// `SdfNode` → LOL text (runtime parser の逆変換、Track C0)
/// When two evaluations of a field agree (IEEE-total: ±∞ and NaN are results)
// ── 3Dプリント向けエクスポート ──
// LOL → SdfNode → Mesh → STL/3MF のワンストップパイプライン
// ── Roblox 向けエクスポート ──
// LOL → SdfNode → Mesh → OBJ/FBX (MeshPart / アクセサリー用)
// ── LLM Guided Generation ブリッジ (Phase X.8 B-6) ──
// alice-llm の GBNF parser + FSM + logits mask を薄く再輸出し、
// `lol.gbnf` の LazyLock cached parse を提供する
// ── レーザー彫刻向け2Dパターン生成 ──
// hatch, crosshatch, halftone, dither, guilloche, lissajous, rose, phyllotaxis, turing
// ── 空間枝刈りコンパイラ ──
// ── 法則(Law)制約チェッカー ──
// LawSet ビルダー、静的矛盾検出、残差フィルタリング
// ── 幾何評価 (text→`SdfNode`→評価結果) の意味論の識別子 ──
// `law_id` (監査 / 研究 Law 専用) とは別軸: rotate/rotate_q の算術世代・TPMS の
// 受理境界・emit の canonical form 等、`SdfNode` の数値評価そのものを pin する
// ── 研究 Law (単位付きの多変数の式 + 成立範囲 + 残差 + 出典 + oracle) ──
// 上の `law` (SDF の幾何制約チェッカー) とは別物: データに対する主張としての式を扱う
// ── 監査 Law (検査器が何件比べたか / 既知の違反がどこまでか を主張する) ──
// 上の 2 つとも別物: 一致を検査する対象が測定そのもので、判定は 6 値
// ── 入力の読み方 (型を持つ x-input と request の JSON) ──
// 型に合わない値は入力全体が合わない: 監査は測られていない、量の法則は拒否
// ── 構文名の一覧 (parser の dispatch と README の構文表を突き合わせる test 専用) ──
// ── Intent Layer (Milestone B.1、Phase 3 Intent 相 IR skeleton) ──
// IntentNode + Program 独立型、GPU backend との型分離、L1 Physical Intent 14 verb + Sequence/Parallel
// ── Standard Library (Phase A.1、hardsurface primitive collection) ──
// 実プリント検証済みの機械要素 primitive (fastener/joint/reinforcement/mount) を SdfNode helper で提供
// ── crate 内専用の決定論的 max / min (clippy-lib gate が f32/f64::max/min 直呼びを禁止) ──
// ── G2: 証明済みに安全な raw max/min 呼び出しの唯一の置き場 (scripts/raw_minmax_manifest.py が数える) ──
// ── Re-export the proc_macro ──
pub use lol;
// ── Re-exports used by macro-generated code ──
pub use SdfNode;
pub use ;
// ── Transpile functions ──
/// Transpile an `SdfNode` tree to GLSL (hardcoded constants).
/// Transpile an `SdfNode` tree to GLSL with dynamic parameters (uniform block).
/// Transpile an `SdfNode` tree to WGSL (hardcoded constants).
/// Transpile an `SdfNode` tree to WGSL with dynamic parameters.
/// Transpile an `SdfNode` tree to HLSL (hardcoded constants).
/// Transpile an `SdfNode` tree to HLSL with dynamic parameters.
/// フルレンダリングパイプライン付きGLSLを生成
///
/// PBR (Cook-Torrance), 大気散乱, 昼夜サイクル, 天候, ポストプロセスを含む
/// 完全なフラグメントシェーダーを出力する。
// ── RenderConfig re-export ──
pub use RenderConfig;
/// Evaluate the SDF distance at a single point (CPU).
// ── Interval arithmetic re-exports (for spatial pruning) ──
pub use ;
// ── Autodiff re-exports (勾配・曲率解析) ──
pub use ;
// ── CompiledSdf re-exports (高速評価) ──
pub use ;
// ── Physics bridge re-exports (物理連携) ──
// alice-sdf 1.7.7 以降 physics_bridge / sim_bridge module は crates.io publish のため
// alice-sdf 側 physics feature ごと削除済 (source 上は cfg-gate 保持) alice-sdf が
// physics feature を復活させたら以下 pub use を再度有効化する
// #[cfg(feature = "physics")]
// pub use alice_sdf::physics_bridge::{sdf_to_physics_field, CompiledSdfField};
// #[cfg(feature = "physics")]
// pub use alice_sdf::sim_bridge::{attach_physics, simulate_sdf, SimulatedSdf};