"""网格编辑(局部重拓扑)— local_edit on a 智能网格 (Nexus) model. tripocli edit -p --bbox "-1,-1,-1,1,1,1" --face-limit 8000 --wait The studio shows this as the 「编辑」 tab: pick a bounding box on a Nexus mesh and re-topologise just that region. Verified body: ``{project_id, source_operator_id, bbox:[[min],[max]], face_limit}``. ⚠️ Only offered for **智能网格 (Nexus)** models that are not yet textured / rigged / segmented / PBR (the studio hides the tab otherwise). ``bbox`` coordinates are normalised to the model's own space, ``-1..1`` per axis (the UI clamps them), so the default ``-1,-1,-1,1,1,1`` covers the whole model. """ from . import _common NAME = "edit" HELP = "网格编辑:在包围盒内对智能网格(Nexus)模型做局部重拓扑" FULL_BBOX = [-1.0, -1.0, -1.0, 1.0, 1.0, 1.0] def add_arguments(parser): _common.add_op_options(parser, "编辑完成后保存到该路径(可选)") parser.add_argument( "--bbox", default=",".join(str(v) for v in FULL_BBOX), help="包围盒 x1,y1,z1,x2,y2,z2(归一化 -1..1,默认整个模型)", ) parser.add_argument("--face-limit", type=int, default=8000, help="该区域面数上限(默认 8000)") def parse_bbox(text): values = [float(part) for part in text.replace(" ", "").split(",")] if len(values) != 6: raise ValueError("--bbox 需要 6 个数字:x1,y1,z1,x2,y2,z2") lower = [min(1.0, max(-1.0, v)) for v in values[:3]] upper = [min(1.0, max(-1.0, v)) for v in values[3:]] return [lower, upper] def run(ctx): args = ctx.args operator_id = ctx.client.project_operator(args.project).get("operator_id") body = { "project_id": args.project, "source_operator_id": operator_id, "bbox": parse_bbox(args.bbox), "face_limit": args.face_limit, } data = ctx.client.get_data("POST", "/v2/studio/operation/local_edit", body=body) return _common.run_operator(ctx, data, output=args.output, wait=args.wait, label="网格编辑")