cad_pixel_to_surface — CADMAP raycast op

• Data kinds: mesh × keypoints → table

• Call: import fullseye as fs; fs.ledger.cad_pixel_to_surface(mesh, pixels, K=None, R=None, t=None, cull_backfaces=True, image_size=None, strict=False) (implementation को सीधे call करना हो तो import cadmap; cadmap.cad_pixel_to_surface(mesh, pixels, K=None, R=None, t=None, cull_backfaces=True, image_size=None, strict=False), registry से लेना हो तो opscadmap.get("cad_pixel_to_surface"))

उपयोग

pixel (N,2) → CAD सतह पर (face_id, barycentric coordinates, 3-D point) (closed form)।

हर pixel के लिए एक viewing ray बनाता है (camera.py convention: केंद्र integer coordinates पर, u = column, v = row), Möller-Trumbore से सभी triangles के साथ intersect करता है, और सबसे सामने वाला hit लेता है। जिन pixels पर कुछ नहीं टकराता, उनके लिए face_id = -1 लौटाता है और कभी भी निकटतम face पर round नहीं करता (ताकि inspection में "defect background पर था" बदलकर "face 17 का defect" न बन जाए)। cull_backfaces=True (default) में जिन faces का normal camera की ओर नहीं है, उन्हें hit नहीं माना जाता।

return एक dict है:

• face_id (N,) int64 -- hit हुए triangle का row index। miss पर -1।

• bary (N,3) -- barycentric coordinates (w0, w1, w2), F[face_id] के 3 vertices के क्रम में। point = w0*V[i0] + w1*V[i1] + w2*V[i2] ठीक-ठीक लागू होता है। miss पर NaN। edge या vertex पर 1 component 0 होता है (tolerance 1e-9)।

• point (N,3) -- world coordinates में intersection point। miss पर NaN।

• depth (N,) -- camera coordinates का Z (ray के साथ दूरी नहीं)। miss पर NaN।

• normal (N,3) -- hit हुए face का unit normal (world coordinates, winding के अनुसार)। miss पर NaN (bary/point/depth जैसी ही convention)।

• hit (N,) bool।

• camera वास्तव में इस्तेमाल हुए K/R/t/width/height। default पर लौट आने का मामला भी यहाँ देखकर पता चलता है।

• winding_fixed bool -- क्या अंदर की ओर wound closed mesh पहचाना गया और इसी call के अंदर winding ठीक की गई। हमेशा मौजूद रहता है (False होने पर भी)।

cull_backfaces=True (default) में यदि mesh closed है और उसका signed volume negative है, तो default रूप से winding ठीक करके winding_fixed=True लौटाता है। strict=True करने पर ठीक नहीं करता बल्कि ValueError से reject करता है। cull_backfaces=False होने पर backface जाँच नहीं होती, इसलिए winding की दिशा परिणाम पर असर नहीं डालती; जाँच भी नहीं होती और winding_fixed हमेशा False रहता है (normal input winding के sign के साथ लौटता है)। विवरण के लिए देखें _orient_for_culling।

K/R/t छोड़ने पर एक default camera बनता है जो mesh को image में समा लेता है (R = I, camera centroid के -Z की ओर)। image_size छोड़ने पर दिए गए pixels के bounding box से image size तय होता है -- ताकि default camera वहीं देखे जहाँ pixels हैं; जब K स्पष्ट रूप से दिया गया हो, तो यह केवल in_image जाँच पर असर डालता है।

संदर्भ (sample data, साहित्य)

• Sample data catalog (DL URL / license) — 2-D के लिए skimage.data (BSD/public) + synthetic, 3-D के लिए real data sources (Stanford/PDS आदि) के DL URL।

• Operators का स्रोत और संदर्भ — इस op family के मूल research/methods के स्रोत।

• Algorithm का मानक स्रोत (लेखक, वर्ष) और उपयोग ऊपर की family usage guide में दिए गए हैं।

चलाए जा सकने वाले उदाहरण (verified samples जो सच में यह op call करते हैं)

• defect_to_cad — py -3.11 examples/defect_to_cad.py

वे अगले ops जिनसे type जुड़ता है (table को input के रूप में लेते हैं)

—

इसी category के (raycast)

—


*Provenance: cadmap.py — CADMAP operator registry. यह per-op note tools/opdocs.py md से अपने-आप generate होता है (हाथ से edit न करें)।*

© 2026 Kazufumi Furuse — Fullseye operator documentation. Licensed under Apache-2.0.