diff --git a/.github/scripts/inactive_pr_notices.py b/.github/scripts/inactive_pr_notices.py new file mode 100644 index 0000000000..9de6c07de7 --- /dev/null +++ b/.github/scripts/inactive_pr_notices.py @@ -0,0 +1,346 @@ +"""Posts a notice on inactive PRs and adds the labels stale.yml needs to close them. + +stale.yml sets the limits and day counts in its environment. It needs the workflow's token, because the +stale bot counts a comment from a person as activity. +""" + +import datetime +import json +import os +import re +import subprocess +import sys +import time +import urllib.parse + +REPO = os.environ["GITHUB_REPOSITORY"] +LIMIT = max(0, int(os.environ["NOTICE_LIMIT"])) +RENOTICE_DAYS = int(os.environ["RENOTICE_DAYS"]) +CLOSE_DAYS = int(os.environ["PR_CLOSE_DAYS"]) +DRY_RUN = os.environ.get("DRY_RUN", "false") == "true" +# Dry runs post nothing, so they have no deadline +DEADLINE = None if DRY_RUN else time.monotonic() + 60 * int(os.environ["NOTICE_MINUTES"]) +WAIT_LABEL = "wait for response" +STALE_LABEL = "stale" +TEAM = ("MEMBER", "OWNER", "COLLABORATOR") +MARKER = "" +GH_TRIES = 3 +GH_TIMEOUT = 120 +# gh errors worth another try; others, such as a 404, fail at once +TRANSIENT = re.compile(r"HTTP (5\d\d|429)|rate limit|timed? ?out|connection|EOF|Something went wrong", re.IGNORECASE) + +# Days without activity before each notice, and its text +NOTICES = { + "waiting": (int(os.environ["PR_STALE_DAYS"]), """We asked for changes or more information on this PR, and nothing has happened on it for at least {days} days. It will be closed in {close} days. + +To keep it open, leave a comment. If you push new commits, please also leave a comment so we know it's ready for review again. If you no longer have time for it, that's fine. You can close it yourself."""), + "conflicts": (int(os.environ["CONFLICT_DAYS"]), """This PR has conflicts with the main branch, and nothing has happened on it for at least {days} days. It will be closed in {close} days. + +If you still want to work on it, please fix the conflicts and leave a comment. If you no longer have time for it, that's fine. You can close it yourself."""), + "unreviewed-conflicts": (int(os.environ["CONFLICT_DAYS"]), """We're sorry that nobody on the team has reviewed this PR yet. It has conflicts with the main branch, and nothing has happened on it for at least {days} days. It will be closed in {close} days. + +If you still want a review, please fix the conflicts and leave a comment. If you no longer have time for it, that's fine. You can close it yourself."""), + "unreviewed": (int(os.environ["UNREVIEWED_DAYS"]), """We're sorry that nobody on the team has reviewed this PR yet. Nothing has happened on it for at least {days} days. It will be closed in {close} days. + +If you still want a review, leave a comment. If you no longer have time for it, that's fine. You can close it yourself."""), + "draft": (int(os.environ["DRAFT_DAYS"]), """Nothing has happened on this draft PR for at least {days} days. It will be closed in {close} days. + +If you're still working on it, leave a comment to keep it open. If it is closed, you can open a new PR later and link this one."""), +} + +QUERY = """query($owner: String!, $name: String!, $cursor: String) { + repository(owner: $owner, name: $name) { + pullRequests(states: OPEN, first: 40, after: $cursor) { + pageInfo { hasNextPage endCursor } + nodes { + number isDraft mergeable baseRefName authorAssociation + author { __typename login } + labels(first: 100) { nodes { name } } + assignees { totalCount } + milestone { title } + commits(last: 1) { nodes { commit { committedDate } } } + comments(last: 30) { totalCount nodes { author { __typename login } authorAssociation createdAt body } } + reviews(last: 20) { totalCount nodes { author { __typename login } authorAssociation submittedAt } } + labelEvents: timelineItems(last: 100, itemTypes: [LABELED_EVENT]) { + nodes { ... on LabeledEvent { createdAt label { name } actor { login } } } + } + } + } + } +}""" + +# One page of a PR's comments or reviews +HISTORY = """query($owner: String!, $name: String!, $number: Int!, $cursor: String) { + repository(owner: $owner, name: $name) { + pullRequest(number: $number) { + %s(first: 100, after: $cursor) { pageInfo { hasNextPage endCursor } nodes { author { __typename login } authorAssociation createdAt body } } + } + } +}""" + + +def gh(*args, tries=GH_TRIES, missing_ok=False): + target = next((a for a in args if a.startswith("repos/") or a == "graphql"), args[0]) + for attempt in range(1, tries + 1): + try: + result = subprocess.run(["gh", *args], capture_output=True, encoding="utf-8", timeout=GH_TIMEOUT) + except subprocess.TimeoutExpired: + result = subprocess.CompletedProcess(args, 1, "", f"timed out after {GH_TIMEOUT} s") + if result.returncode == 0 or (missing_ok and "HTTP 404" in result.stderr): + return result.stdout + print(f"gh api {target} failed (try {attempt} of {tries}): {result.stderr.strip()}", file=sys.stderr) + if attempt == tries or not TRANSIENT.search(result.stderr): + break + time.sleep(10 * attempt) + raise RuntimeError(f"gh api {target} failed") + + +def paged(query, path, *variables): + """All nodes of the connection at path, where path starts below the query's data.""" + owner, name = REPO.split("/") + cursor, nodes = None, [] + while True: + args = ["api", "graphql", "-f", "query=" + query, "-f", "owner=" + owner, "-f", "name=" + name, *variables] + if cursor: + args += ["-f", "cursor=" + cursor] + page = json.loads(gh(*args))["data"] + for key in path: + page = page[key] + nodes += page["nodes"] + if not page["pageInfo"]["hasNextPage"]: + return nodes + cursor = page["pageInfo"]["endCursor"] + + +def days_since(stamp, now): + return (now - parse_time(stamp)).days + + +def is_person(actor): + return bool(actor) and actor["__typename"] == "User" + + +def parse_time(stamp): + return datetime.datetime.fromisoformat(stamp.replace("Z", "+00:00")) + + +def full_comments(pr): + """The PR's comments, reading the whole history when the fetched window doesn't hold them all.""" + nodes = pr["comments"]["nodes"] + if pr["comments"]["totalCount"] <= len(nodes): + return nodes + return paged(HISTORY % "comments", ("repository", "pullRequest", "comments"), "-F", f"number={pr['number']}") + + +def answered_notice(pr): + """Whether a person replied to this PR's notice while the wait label that the notice added is still on it.""" + labels = {label["name"] for label in pr["labels"]["nodes"]} + added = [e for e in pr["labelEvents"]["nodes"] if e and e["label"]["name"] == WAIT_LABEL] + if WAIT_LABEL not in labels or STALE_LABEL in labels or not added or not added[-1]["actor"]: + return False + + def notices(nodes): + return [c for c in nodes if c["author"] and not is_person(c["author"]) and c["body"].startswith(MARKER)] + + comments = pr["comments"]["nodes"] + # A notice can be older than the fetched window + if not notices(comments): + comments = full_comments(pr) + if not notices(comments): + return False + notice, added = notices(comments)[-1], added[-1] + # The notice adds the label seconds before it posts, so a later add came from someone else + gap = (parse_time(notice["createdAt"]) - parse_time(added["createdAt"])).total_seconds() + if added["actor"]["login"] != notice["author"]["login"] or not 0 <= gap <= 300: + return False + replies = [c["createdAt"] for c in comments if is_person(c["author"])] + replies += [r["submittedAt"] for r in pr["reviews"]["nodes"] if is_person(r["author"]) and r["submittedAt"]] + replies += [c["commit"]["committedDate"] for c in pr["commits"]["nodes"]] + return max(replies) > notice["createdAt"] + + +def team_replied(pr): + author = pr["author"]["login"] + + def replied(nodes): + return any(is_person(x["author"]) and x["author"]["login"] != author and x["authorAssociation"] in TEAM + for x in nodes) + + for key in ("comments", "reviews"): + fetched = pr[key] + nodes = fetched["nodes"] + # An older reply can be outside the fetched window + if not replied(nodes) and fetched["totalCount"] > len(nodes): + nodes = paged(HISTORY % key, ("repository", "pullRequest", key), "-F", f"number={pr['number']}") + if replied(nodes): + return True + return False + + +def pick_notice(pr, now): + """The case and idle days of the notice this PR should get now, or None.""" + labels = {label["name"] for label in pr["labels"]["nodes"]} + if (STALE_LABEL in labels or not is_person(pr["author"]) or pr["baseRefName"] != "main" + or pr["assignees"]["totalCount"] or pr["milestone"]): + return None + comments, reviews = pr["comments"]["nodes"], pr["reviews"]["nodes"] + + def noticed(nodes): + return any(c["body"].startswith(MARKER) and days_since(c["createdAt"], now) < RENOTICE_DAYS for c in nodes) + + if noticed(comments): + return None + + activity = [c["createdAt"] for c in comments if is_person(c["author"])] + activity += [r["submittedAt"] for r in reviews if is_person(r["author"]) and r["submittedAt"]] + # A rebase or amend sets a new commit date + activity += [c["commit"]["committedDate"] for c in pr["commits"]["nodes"]] + idle = days_since(max(activity), now) + + if WAIT_LABEL in labels: + case = "waiting" if not pr["isDraft"] else None + elif pr["authorAssociation"] in TEAM: + case = None + elif pr["isDraft"]: + case = "draft" + # GitHub computes this on request, so the next run sees the real value + elif pr["mergeable"] == "UNKNOWN": + case = None + elif pr["mergeable"] == "CONFLICTING": + case = "conflicts" + else: + case = "unreviewed" + if not case or idle < NOTICES[case][0]: + return None + # Checked last because they can read a PR's whole history + if noticed(full_comments(pr)): + return None + if case in ("conflicts", "unreviewed"): + replied = team_replied(pr) + if case == "unreviewed" and replied: + return None + if case == "conflicts" and not replied: + case = "unreviewed-conflicts" + return case, idle + + +def find_notices(number, since): + """The ids of the notices posted on this PR since the given time.""" + return gh("api", f"repos/{REPO}/issues/{number}/comments?since={since}", "--jq", + f'.[] | select(.user.type == "Bot" and (.body | startswith("{MARKER}"))) | .id').split() + + +def post_comment(number, body, since): + """The id of the new comment, posted once even when GitHub fails after creating it.""" + for attempt in range(1, GH_TRIES + 1): + try: + return gh("api", f"repos/{REPO}/issues/{number}/comments", "-f", f"body={body}", "--jq", ".id", tries=1).strip() + except RuntimeError: + # Posting again is only safe once GitHub confirms the last try created nothing + if posted := find_notices(number, since): + return posted[0] + if attempt < GH_TRIES: + time.sleep(10 * attempt) + raise RuntimeError(f"posting the notice on #{number} failed") + + +def post_notice(number, case, labels): + # The stale bot counts any change after the stale label as activity, so the stale label goes on last + added_wait = WAIT_LABEL not in labels + # A minute early, so a GitHub clock behind the runner's still finds a notice this call posted + since = (datetime.datetime.now(datetime.timezone.utc) - datetime.timedelta(minutes=1)).strftime("%Y-%m-%dT%H:%M:%SZ") + # Adding a label the PR already has changes nothing, and the fetched labels can be minutes old + gh("api", f"repos/{REPO}/issues/{number}/labels", "-f", f"labels[]={WAIT_LABEL}", "--silent") + comment = None + try: + days, text = NOTICES[case] + comment = post_comment(number, MARKER + "\n" + text.format(days=days, close=CLOSE_DAYS), since) + gh("api", f"repos/{REPO}/issues/{number}/labels", "-f", f"labels[]={STALE_LABEL}", "--silent") + except RuntimeError: + # Without the stale label nothing closes the PR, so the notice is undone and the next run tries again + try: + comments = set(find_notices(number, since)) + except RuntimeError: + comments = set() + comments |= {comment} if comment else set() + undo = [f"repos/{REPO}/issues/comments/{c}" for c in comments] + if added_wait: + undo.append(wait_label_path(number)) + # Each step is tried even when one before it fails; gh logs the failure + for path in undo: + try: + gh("api", "-X", "DELETE", path, "--silent", missing_ok=True) + except RuntimeError: + pass + raise + + +def wait_label_path(number): + return f"repos/{REPO}/issues/{number}/labels/{urllib.parse.quote(WAIT_LABEL)}" + + +def main(): + now = datetime.datetime.now(datetime.timezone.utc) + prs = paged(QUERY, ("repository", "pullRequests")) + failed = [] + + for pr in prs: + labels = {label["name"] for label in pr["labels"]["nodes"]} + # A draft is only on the stale track while a notice is open, so the stale step never starts its own clock on one + draft = pr["isDraft"] and WAIT_LABEL in labels and STALE_LABEL not in labels + try: + if not (draft or answered_notice(pr)): + continue + print(f"#{pr['number']} {'draft' if draft else 'answered'}: removing {WAIT_LABEL}") + if not DRY_RUN: + # Another bot can remove the label between the fetch and this call + gh("api", "-X", "DELETE", wait_label_path(pr["number"]), "--silent", missing_ok=True) + except RuntimeError: + failed.append(pr["number"]) + + todo = [] + for pr in prs: + try: + if notice := pick_notice(pr, now): + todo.append((notice, pr)) + except RuntimeError: + failed.append(pr["number"]) + # Longest idle first + todo.sort(key=lambda item: item[0][1], reverse=True) + posted = 0 + for position, ((case, idle), pr) in enumerate(todo): + if position == LIMIT: + if not DRY_RUN: + break + print(f"-- over the limit of {LIMIT}, not posted tonight --") + # A notice cut off by the step timeout would stay up with nothing to close the PR + if DEADLINE and time.monotonic() > DEADLINE: + print(f"Out of time after {posted} notices; the rest wait for the next run") + break + print(f"#{pr['number']} {case}: idle {idle} days") + if DRY_RUN: + if position < LIMIT: + posted += 1 + continue + try: + post_notice(pr["number"], case, {label["name"] for label in pr["labels"]["nodes"]}) + posted += 1 + except RuntimeError: + failed.append(pr["number"]) + # Stays under GitHub's limit on comments per minute + time.sleep(2) + failed = sorted(set(failed)) + print(f"{'would-post' if DRY_RUN else 'posted'}={posted} eligible={len(todo)} limit={LIMIT} failed={len(failed)} dry-run={str(DRY_RUN).lower()}") + # Doesn't count against the limits it reports + try: + print(gh("api", "rate_limit", "--jq", + r'.resources | "rate-limit rest-used=\(.core.used) rest-remaining=\(.core.remaining) ' + r'graphql-used=\(.graphql.used) graphql-remaining=\(.graphql.remaining)"').strip()) + except RuntimeError: + pass + if failed: + sys.exit("Failed on " + " ".join(f"#{n}" for n in failed)) + + +if __name__ == "__main__": + main() diff --git a/.github/workflows/stale.yml b/.github/workflows/stale.yml index 9d75d85845..6cd6f85f59 100644 --- a/.github/workflows/stale.yml +++ b/.github/workflows/stale.yml @@ -4,9 +4,16 @@ on: schedule: - cron: "30 1 * * *" workflow_dispatch: + inputs: + notices: + description: What the notice step does on this run + type: choice + options: [dry-run, post, skip] + default: dry-run permissions: actions: write # save the run state in the actions cache + contents: read # check out the notice script issues: write pull-requests: write @@ -17,11 +24,42 @@ concurrency: jobs: stale: runs-on: ubuntu-latest + env: + ISSUE_STALE_DAYS: 90 + ISSUE_CLOSE_DAYS: 14 + # CONTRIBUTING's "If your PR is closed" section repeats these day counts, so update it too + PR_STALE_DAYS: 90 + PR_CLOSE_DAYS: 14 + CONFLICT_DAYS: 90 + UNREVIEWED_DAYS: 180 + DRAFT_DAYS: 180 + # A PR that answered a notice gets no new one for this long + RENOTICE_DAYS: 90 + # Each notice posts one comment, which counts toward the stale step's hourly limit + NOTICE_LIMIT: 40 steps: + - uses: actions/checkout@v7 + if: github.repository == 'OrcaSlicer/OrcaSlicer' && inputs.notices != 'skip' + with: + sparse-checkout: .github/scripts + persist-credentials: false + # Posts the notice on long-inactive PRs, which the stale step closes if nothing changes + - name: Post notices on inactive PRs + if: github.repository == 'OrcaSlicer/OrcaSlicer' && inputs.notices != 'skip' + timeout-minutes: 30 + env: + GH_TOKEN: ${{ github.token }} + DRY_RUN: ${{ inputs.notices == 'dry-run' }} + # Stops starting notices with time to finish the last one before the timeout + NOTICE_MINUTES: 20 + run: python3 .github/scripts/inactive_pr_notices.py - uses: actions/stale@v11 + # A failed notice step doesn't stop the stale run + if: ${{ !cancelled() }} with: # Each stale label or close costs about 2 operations and posts one - # comment, so 800 stays under GitHub's limit of 500 comments an hour. + # comment, so 800 stays under GitHub's limit of 500 comments an hour + # together with the notice step's NOTICE_LIMIT comments. # Runs that stop early continue from the same place the next day. operations-per-run: 800 ascending: true @@ -33,13 +71,13 @@ jobs: # Update its filters when they change. # Issues - days-before-issue-stale: 90 - days-before-issue-close: 14 + days-before-issue-stale: ${{ env.ISSUE_STALE_DAYS }} + days-before-issue-close: ${{ env.ISSUE_CLOSE_DAYS }} close-issue-reason: not_planned exempt-all-issue-assignees: true exempt-all-issue-milestones: true stale-issue-message: | - This issue has had no activity for 90 days, so it will be closed in 14 days. + This issue has had no activity for ${{ env.ISSUE_STALE_DAYS }} days, so it will be closed in ${{ env.ISSUE_CLOSE_DAYS }} days. If it's a bug that still happens on the latest OrcaSlicer release, please leave a comment with the version you tested. If it's a feature request you still want, please leave a comment saying so. Either one keeps it open. close-issue-message: | @@ -49,20 +87,21 @@ jobs: # PRs: only PRs where we asked the author for something only-pr-labels: "wait for response" - days-before-pr-stale: 90 - days-before-pr-close: 14 - exempt-draft-pr: true + days-before-pr-stale: ${{ env.PR_STALE_DAYS }} + days-before-pr-close: ${{ env.PR_CLOSE_DAYS }} + # Drafts aren't exempt because the notice step removes the label from drafts without a notice + exempt-draft-pr: false exempt-all-pr-assignees: true exempt-all-pr-milestones: true delete-branch: false stale-pr-message: | - We asked for changes or more information on this PR, and there has been no activity for 90 days. It will be closed in 14 days. + We asked for changes or more information on this PR, and nothing has happened on it for at least ${{ env.PR_STALE_DAYS }} days. It will be closed in ${{ env.PR_CLOSE_DAYS }} days. - To keep it open, leave a comment. If you push new commits, please also leave a short comment so we know it's ready for another look. If you no longer have time for it, that is fine, just let us know. + To keep it open, leave a comment. If you push new commits, please also leave a comment so we know it's ready for review again. If you no longer have time for it, that's fine. You can close it yourself. close-pr-message: | - This PR was closed because we did not hear back after the reminder. Thank you for the work you put into it. + This PR was closed because we did not get a reply after the reminder. Thank you for the work you put into it. - If you want to continue, push your changes and reopen it, or open a new PR. + If you want to continue, open a new PR and link this one. You can also leave a comment here, and a team member can reopen it. # The stale bot checks exemptions before activity, so it never comes back # to a stale item that became exempt. Remove the label from those here. @@ -77,8 +116,8 @@ jobs: --json number,assignees,milestone \ --jq '.[] | select((.assignees | length > 0) or .milestone != null) | .number' gh pr list -R "$GITHUB_REPOSITORY" --label stale --state open --limit 1000 \ - --json number,isDraft,assignees,milestone,labels \ - --jq '.[] | select(.isDraft or (.assignees | length > 0) or .milestone != null + --json number,assignees,milestone,labels \ + --jq '.[] | select((.assignees | length > 0) or .milestone != null or ([.labels[].name] | index("wait for response") | not)) | .number' } | while read -r n; do gh api -X DELETE "repos/$GITHUB_REPOSITORY/issues/$n/labels/stale" --silent < /dev/null || diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 3dbdfd0447..f8397d1a5a 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -110,6 +110,15 @@ There are more PRs than reviewers can handle, so we may close a PR that doesn't You're welcome to open a new PR once the change meets this guide. Please link the old PR in the description, so reviewers can see the earlier discussion. Thank you for the time you put into it. +We also close PRs that have been inactive for a long time. A bot first leaves a comment saying the PR will be closed in 14 days. It does this when: + +- We asked you for changes or more information, and nothing has happened for 90 days. +- The PR has conflicts with the main branch, and nothing has happened for 90 days. +- Nobody on the team has reviewed or commented on the PR, and nothing has happened for 180 days. +- The PR is a draft, and nothing has happened for 180 days. + +"Nothing has happened" means no comment, review or new commit from a person. To keep the PR open, leave a comment. + ## Security issues Please don't report security problems in a public issue. See [SECURITY.md](SECURITY.md). diff --git a/README.md b/README.md index c14ff19a7b..e5c64a7ba8 100644 --- a/README.md +++ b/README.md @@ -250,4 +250,4 @@ The OrcaSlicer logo was designed by community member [Justin Levine](https://git - **OrcaSlicer** is licensed under the GNU Affero General Public License, version 3. - The **GNU Affero General Public License**, version 3 ensures that if you use any part of this software in any way (even behind a web server), your software must be released under the same license. - OrcaSlicer includes a **pressure advance calibration pattern test** adapted from Andrew Ellis' generator, which is licensed under GNU General Public License, version 3. Ellis' generator is itself adapted from a generator developed by Sineos for Marlin, which is licensed under GNU General Public License, version 3. -- The **Bambu networking plugin** is based on non-free libraries from BambuLab. It is optional to the OrcaSlicer and provides extended functionalities for Bambulab printer users. +- The **Bambu networking plugin** is based on non-free libraries from BambuLab. It is optional to OrcaSlicer and provides extended functionalities for Bambulab printer users. diff --git a/deps/OpenCV/OpenCV.cmake b/deps/OpenCV/OpenCV.cmake index cde7666834..6592301b9a 100644 --- a/deps/OpenCV/OpenCV.cmake +++ b/deps/OpenCV/OpenCV.cmake @@ -82,6 +82,9 @@ orcaslicer_add_cmake_project(OpenCV -DWITH_IMGCODEC_GIF=OFF -DWITH_KLEIDICV=OFF -DENABLE_PRECOMPILED_HEADERS=OFF + # Build only the baseline CPU code, without the per-CPU copies OpenCV picks from at runtime. + # Orca's image work is too light to gain from them, and they make OpenCV slower to build and the app bigger. + -DCPU_DISPATCH= -DINSTALL_TESTS=OFF -DINSTALL_C_EXAMPLES=OFF -DINSTALL_PYTHON_EXAMPLES=OFF diff --git a/docs/HLSD/precise-seam.md b/docs/HLSD/precise-seam.md index 3168b1884e..84931a0263 100644 --- a/docs/HLSD/precise-seam.md +++ b/docs/HLSD/precise-seam.md @@ -42,10 +42,18 @@ retypes, and where needed adds, the candidates inside its intersection, like painting does. An **intersection** is a continuous part of the external perimeter's centerline -that lies inside the modifier's slice on that layer. It is a portion of the -perimeter, never a chord through the object. The centerline lies half an -extrusion width inside the model surface and depends on print settings, so a -modifier must reach clearly past the surface to cross it unambiguously. +whose model surface lies inside the modifier's slice on that layer. It is a +portion of the perimeter, never a chord through the object. The centerline lies +about half an extrusion width inside the printed wall and is invisible to the user, +who places modifiers against the model surface. Extraction therefore +reconstructs that surface from the centerline, clips it, and carries the +result back onto the centerline along the normal (see +[Surface reconstruction](#surface-reconstruction)). A modifier acts when it +reaches the reconstructed surface, which lies a margin of 5 µm inside the model +surface, and has no effect when it stays inside the body, even if it crosses the +centerline. A modifier that enters the model by less than the margin does not +act. An open extrusion (a thin wall printed as one line) is left out: its +G-code does not depend on where the seam is. ### Terms @@ -133,7 +141,11 @@ threads without locking. ## Perimeter preparation The seam placer works on external perimeter loops, including the walls of -holes. For objects with Precise Seam volumes, consecutive duplicate points and +holes. Precise Seam processes closed loops only: an open extrusion (a thin wall +printed as one line) keeps its ordinary seam candidates, and modifiers are not +evaluated on it. A modifier that crosses only such a wall has no effect, and the +"had no effect" warning names it when it was evaluated on a closed loop. For +objects with Precise Seam volumes, consecutive duplicate points and the repeated closing point of each extrusion loop are removed: adjacent extrusion paths share endpoints, and the resulting zero-length edges would prevent point insertion at their junctions. Distinct visits to one point of a @@ -142,13 +154,197 @@ original points, so ordinary seam candidates are unaffected. Each polygon is made counter-clockwise. A single `PreparedPerimeter` is then built for all modifiers of that perimeter. It holds a validity check (at least -three points, no consecutive or closing duplicates), the bounding box, and the -clipping line: the polygon as an open polyline with its first point repeated at -the end. The preparation borrows the polygon and is used only while the polygon +three points, no consecutive or closing duplicates), the bounding box, the +clipping line (the polygon as an open polyline with its first point repeated at +the end), the side of the air (outside a contour, inside a hole, by the loop +role) and the surface shift. The surface line is built from it on the first +request, so perimeters that no modifier approaches never pay for it. + +The **surface shift** is the distance from the centerline to the model surface +the user sees, less a margin. Its nominal value is `d = w/2 - c - m`: + +- `w` is the region's nominal external perimeter width, the flow the perimeter + generator uses for the outer loop on that layer, first layer included. A loop + of the classic generator takes the width of its own outer wall line instead + (`ExtrusionPath::width` of its first external perimeter path): with thin wall + detection off, an island too narrow for two lines and short enough is printed + with a thinner line, inset by half of that width. Bridged paths lie on the + same centerline with the overhang flow's width and are not asked; a loop + without an external perimeter path keeps the region's width. +- `c` is the XY compensation that moved this wall away from the model, + positive towards air: `xy_contour_compensation` for a contour and minus + `xy_hole_compensation` for a hole (a positive value enlarges holes). It is + zero where slicing skips compensation, for multi-material painting with + several filaments. It is also zero for a hole on a layer with several + regions when the hole setting is negative: slicing then clips the regions by + the compensated islands, and clipping cannot add the material that would make + the hole smaller. Both values are taken once per object in + `SeamPlacer::init()`, so they describe the outer contours and holes of the + object. A wall on the boundary between two regions of one object is + compensated differently by slicing, and there the surface is not restored + exactly (see [Known limitations](#known-limitations)). Modifier slices are not + compensated, so they stay in the frame of the model. +- `m` is `SURFACE_MARGIN` (5 µm). A modifier face placed flush against a model + face would otherwise touch the reconstructed surface by rounding noise and + act on some layers only; the margin moves that unstable position 5 µm deep, + where it is not reached by accident. + +**Measured shift.** On the layers with elephant foot compensation (printing +directly on the bed, below `elefant_foot_compensation_layers`) and on every +layer of Arachne perimeters (not in spiral vase mode, which uses the classic +generator), the centerline does not lie at depth `w/2`: elephant foot +compensation shrinks the contour the perimeters are built on by an amount that +changes along it, and Arachne lines vary in width. There the shift is measured: +`d(P) = D(P) - c' - m` at a point `P` of the centerline, where `D(P)` is the +depth of `P` below the boundary of the layer's islands (`Layer::lslices`) and +`c'` the part of `c` those islands contain. The depth is the offset from `P` to +the nearest point of the boundary, projected on the normal of the edge (at a +vertex, the larger of the projections on its two edges' normals). At an inner +corner the nearest point is the corner of the boundary, farther away than +either side; its projections are the distances to the sides. + +- Slicing stores the islands of an elephant foot layer from before that + compensation, and those of other layers as the perimeters see them, so `D` + includes the elephant foot compensation at that point and the half width of + the line actually printed there. The islands contain the XY compensation + (`c' = c`), except on an elephant foot layer with several regions: slicing + keeps those islands from before a negative contour compensation and applies + it to the perimeters only, so there `c'` is zero for contours. +- A distance is accepted only within the range of the wall's own line: from half + the narrowest line the generator prints to half the widest, widened by the + elephant foot compensation of the layer, by the part of `c` missing from the + islands, by half the difference between line width and spacing (Arachne keeps + a precise outer wall that much deeper where it prints one line) and by the + slicing resolution plus 1 µm. The narrowest line is half the nominal width for + Arachne, which splits a wall into two lines narrower than its minimum bead + width, and slightly under it for the classic generator, which prints narrow + loops thinner; the widest is twice the nominal width for Arachne and the + nominal width for the classic generator. A distance outside that range does not + come from the wall's own surface: the wall is thinner than a line, or it lies + on the boundary between two regions, which the islands do not contain. Such a + point takes the nominal shift. +- Every vertex is measured, and an edge longer than 0.5 mm (the step at which + elephant foot compensation is resampled) also at points at most 0.5 mm apart + along it. If they all follow the straight change between its vertices within + the snapping radius, the edge stays one piece; otherwise they all split it. +- A negative value is taken as zero. A perimeter whose values all equal the + nominal shift within the snapping radius keeps the constant shift, so a wall at + its nominal depth gives exactly the result of the nominal shift. A perimeter + whose largest value is within the snapping radius keeps the centerline; a + single point at zero does not change that. +- The measurement is decided per loop. A loop with fuzzy skin is measured on its + smooth centerline (see [Fuzzy skin](#fuzzy-skin)). A noisy line itself is never + measured: the noise moves it off the smooth outline, so measuring would pull + its points within the range back to the outline while the points outside it + kept the noise. A loop without a smooth centerline on a layer where any region + adds fuzzy skin to the outer walls of that kind of loop keeps the nominal shift, + since nothing tells an unchanged loop from a noisy one that lost its centerline. +- The islands are indexed once per layer and only on layers where a Precise + Seam modifier has a region, and only loops that some modifier on the layer + approaches are measured. + +A shift within the snapping radius is treated as zero: extraction then clips the +centerline itself. The preparation borrows the polygon and is used only while the polygon is unchanged: strong processing returns immediately after inserting its point, and weak processing collects all segments before it inserts anything. An invalid perimeter receives no Precise Seam processing. +### Fuzzy skin + +Fuzzy skin is applied by the perimeter generator, which resamples a loop and moves +its points off the smooth centerline (Arachne's extrusion mode changes the line +width instead). Only the noisy line reaches the seam placer, and a surface +shifted from it would repeat the noise. The generator therefore keeps the +centerline before texturing of an external loop whose points the texture +changed, in `ExtrusionLoop::untextured` (classic `traverse_loops()`, Arachne +`traverse_extrusions()`, which copies the junctions only where the layer has +fuzzy skin on that kind of loop). A list of points equal to the printed one is +not kept. The field is kept for every such loop, whether or not the object has +Precise Seam volumes, because adding a volume does not regenerate perimeters +(see [Print invalidation](#print-invalidation)). Copying, moving, reversing or +turning the start of the loop keeps it, and so do the simplification and arc +fitting of its paths after the generator, which leave the same textured loop; +giving the loop other geometry must reset it. + +For such a loop the preparation has two polygons: the smooth centerline, from +which the surface is reconstructed and on which the shift is measured, clipping, +binding, segments, lengths, Center and full containment are worked out; and the +noisy loop, into which the results are inserted. Both are normalized alike (no +repeated points, counterclockwise). + +- **Pairs.** A segment keeps the surface points its ends were carried from, and + merging intervals keeps the pair of the outer end, also across vertex zero. An + arc still collapses into its vertex, but the end keeps its real point on the + arc: a zero-length segment has the two ends of its piece of arc, and separate + pieces of one arc make one vertex point from the piece nearest the arc's start + to the end of the farthest. A vertex point that continues a segment gives the + segment's end its arc point. Left and Right take the pair of their end. + Center, the middle by length of the smooth segment, takes as its pair the point + of the shifted edge at the same parameter (shift profile included), the middle + of the arc or bridge at a vertex (of the piece covered, for a zero-length + segment), the point where the shifted edges meet at a vertex without either + (collinear edges; the smooth point itself, as an emergency fallback, should + the edge have no element left), or the crossing `K` in the dead stretch of a + concave corner. +- **Transfer.** The line through the surface point and the smooth point is + intersected with the edges of the noisy loop within a window of the smooth + point, and the crossing nearest to it is taken; an edge lying along the line + gives its point nearest to the smooth point. The window is an estimate from the + settings, not a measured distance or a proven bound, computed separately for + contours and holes: only the regions that texture the loop's kind count, as + FuzzySkin.cpp decides it. Regions texture a loop one after another, each over the + result of the previous ones, so it adds up the amplitudes of their different + noises (regions that differ only in which walls they texture make one noise). + An amplitude is the thickness times the largest value of its noise module: + Perlin, Billow and RidgedMulti add octaves and can exceed one. These bounds rest + on the range libnoise states for its coherent noise, from -1 to 1. + Arachne's combined mode moves a point by half its change of width, which adds + half the smallest width it keeps. On top come the largest point distance, the + farthest a chord cutting a convex corner passes from the smooth point, and a + micrometre of rounding. There are three outcomes: + - **exact**: such a crossing exists; + - **approximate**: the pair coincides (the centerline path, where the surface + is the centerline) or the line crosses nothing within the window; the + nearest point of the noisy loop within the window is taken, and counted in + the log; + - **failed**: not even that; the point is a discarded fragment, with its + counter, log marker and the type in the warning. A strong segment whose point + fails takes no part; a weak zone with a failed boundary is dropped. +- **Strong modifiers** choose the segment and the point on the smooth loop, ties + included, and insert the carried point into the noisy one. Among candidates + that are carried the noise never changes the winner; a candidate whose + transfer fails drops out, and the next one wins. +- **Weak zones** carry each boundary separately. Before anything is inserted, a + policy, not a proven guarantee, tells some zones whose boundaries came out in + the reverse order. It assumes that the points of a zone's true noisy arc lie + within the window of the smooth zone, as its carried boundaries do; the window + is an estimate. A short zone's true arc then stays within a circle around its + smooth boundary, however much the noise lengthens it, while the arc round the + rest of the loop leaves that circle wherever the loop spreads beyond it; its + length tells nothing, as the noise may lengthen a stretch many times over. With + a threshold of four windows on the smooth loop: + - for a zone shorter than that, the circle lies around its smooth left boundary + with the zone's length plus a window for radius. The zone is reversed when the + noisy arc from its carried left boundary forward to its right one leaves the + circle; otherwise it keeps its order when the arc from the right boundary + forward to the left one leaves it; with both arcs inside, it is reversed when + the first arc is the longer; + - otherwise, for a zone whose rest of the loop is that short, the same holds + around its smooth right boundary, with the rest's length plus a window for + radius and the arcs swapped: the arc from the right boundary forward to the + left one is the rest's; + - otherwise the order is not checked; a transfer onto another part of the loop + there is a limitation of the direct transfer. + + An arc leaves the circle when either carried boundary or a vertex of the noisy + loop between them, across its start, lies outside; boundaries on one edge with + the second behind the first make an arc round the whole loop. A reversed zone + is reduced to its left boundary, a zero-length zone that types the one + candidate there. This is a declared degradation, counted in the log: it + happens, for example, for a piece of a convex corner's arc where the noisy + loop cuts the corner inside it, since the lines through the corner then cross + the noise behind it in the reverse order. + ## Segment extraction `extract_perimeter_segments()` turns one modifier's regions on one layer into @@ -156,24 +352,79 @@ segments of the perimeter, each with its geometry and its position on the source contour. Both modifier kinds consume these segments; the extractor is told the modifier type so that it prepares only the data that type needs. +### Surface reconstruction + +The surface is the set of points on the air side at the shift `d` from the +centerline. `build_surface_line()` builds it as a closed line whose every edge +remembers its source: + +- **Shifted edge.** Each source edge moved along its normal into the air. With a + constant shift along the edge, the shift is rounded once per edge, so the + shifted edge is an exact integer translate of its source and keeps its + parameters. Where a measured shift changes along the edge, the shifted edge is + a chain of straight parts through the points moved by the shift at its + vertices and at its measured interior points; each part maps linearly onto the + range of parameters of the source edge between those points. +- **Arc.** Where shifted edges diverge (a convex vertex as seen from the air), + an arc around the vertex whose radius is the shift at that vertex, + approximated by chords with a sagitta of at most 40 units. Both shifted edges + take that shift at the vertex, so the line stays continuous; with no shift + there they meet at the vertex itself. A reversal of direction turns by half a + circle. +- **Crossing.** Where shifted edges cross (a concave vertex) at a point `K` + inside both of the parts meeting there, they end exactly at `K`: no part of + them lies beyond it. A part trimmed this way covers only part of its range of + the source edge, and its parameters are carried over proportionally. Both + trims of one part must leave at least 4 units of it. +- **Bridge.** At any other concave vertex (shifted edges crossing beyond the end + of one of them, as in a fillet finer than the shift), a straight edge between + the ends of the full shifted edges, carried onto the vertex like an arc. The + shifted edges keep their tails beyond the crossing. + +Each crossing is the end of a **dead stretch**: the part of the centerline +around the vertex that has no surface of its own. It is recorded at once, with +the elements of the surface line that end and start at `K`. Resolving these +corners exactly matters on shallow corners, such as the many vertices of a +tessellated hole: there the parts of the full shifted edges beyond `K` stay +within micrometers of the surface, and a modifier boundary crossing them would +split the segment. + +The surface line is not filtered further: every part of it counts as surface, +even where it comes closer than `d` to another part of the centerline. The +centerline is itself the model contour shifted inwards by half the line width, +so shifting it back by slightly less returns to that contour and does not fold: +a concave fillet of radius `r` on the surface is a fillet of radius `r + d` on +the centerline, and a sharp inner corner stays sharp and resolves exactly. The +line folds only on corners that are not resolved exactly: a very sharp inner +corner that the slicer bevels, a sharp change of the measured shift, or relief +finer than the shift (see [Known limitations](#known-limitations)). There the tails and bridges +of the line stay part of it, and the user's rule that a modifier enters the wall +by a clear depth keeps such corners out of play. A general offset of the polygon +could not replace the surface line: it rounds and cuts corners and loses the +link to source edges. + ### Clipping -Regions whose bounding box does not overlap the perimeter's are skipped. The -clipping line is intersected with each remaining region by `intersection_pl()`, -which clips an open path against an `ExPolygon` with its holes attached, using -the nonzero rule. Clipping an open line yields only pieces of the perimeter, so -a modifier crossing the whole object produces two separate pieces rather than a -chord through the body. Holes in a modifier and several regions of one modifier -simply produce more pieces. The line is cut at vertex zero, so a piece crossing -that vertex arrives as two fragments. A border that only touches the line can -come back as a single point; such fragments carry no coverage and are dropped -before binding. +Regions whose bounding box does not overlap the perimeter's, enlarged by the +shift, are skipped. The surface line, as an open path closed at its start, is +intersected with each remaining region by `intersection_pl()`, which clips open +paths against an `ExPolygon` with its holes attached, using the nonzero rule. +Clipping an open line yields only pieces of the surface, so a modifier crossing +the whole object produces two separate pieces rather than a chord through the +body. Holes in a modifier and several regions of one modifier simply produce +more pieces. The line is cut at its start, so a piece crossing it arrives as two +fragments. A border that +only touches the surface can come back as a single point; such fragments carry +no coverage and are dropped before binding. With a shift of zero the +centerline's own clipping line is clipped instead, without offsets or contact +rules. ### Binding fragments to source edges Clipper returns coordinates only. Insertion needs the source edge of every point, and coordinates alone are ambiguous where a contour visits the same -point twice. Each fragment is therefore bound to the source edges it covers, +point twice. Each fragment is therefore bound to the edges of the line it was +clipped from (the surface line, or the centerline for a shift of zero), producing intervals: an edge index with a parameter range on that edge. - **Exact path.** For fragments with interior points, the second point is used @@ -214,11 +465,39 @@ normal path never pays for them: Both outcomes are recoveries, not failures: they show no user warning but leave a log marker. +### Carrying the surface onto the centerline + +Intervals on the surface line are carried onto the centerline through their +source: + +| Surface | Centerline | +| --- | --- | +| Shifted edge, parameters `t0..t1` | the same source edge, the same parameters (proportionally on a trimmed part or a part of a split edge) | +| Arc or bridge around a vertex | that vertex, as a **vertex point** | +| Both ends of a dead stretch covered | the whole centerline between them | + +A point of an edge with a constant shift moves back by subtracting that edge's +integer shift, which is the same as following the normal. On an edge whose +shift changes, the point is the one at the same parameter of the source edge. + +The last rule covers the crossing point `K` of a concave corner: when the +modifier covers the surface on both sides of `K`, the centerline around the +vertex, which has no surface of its own, joins them. When only one side is +covered, the segment ends under the modifier's crossing, outside the dead +stretch. An end counts as covered when coverage ends within the snapping radius +of it on the same edge of the surface line, so a modifier boundary passing +exactly through `K` covers it. + ### Assembling segments The intervals are sorted by edge and parameter. Intervals on the same occurrence of an edge are united when they overlap or meet, by parameter or at the same -integer point; equal coordinates on different edges are never united. A +integer point; equal coordinates on different edges are never united. A vertex +point adds no edge: next to coverage that reaches its vertex it disappears, and +alone it forms a **zero-length segment**, a single point with no edges, where +the modifier reached the surface only around a convex corner. Its strong target +is the vertex in every mode, and as a weak zone it types the one candidate +there. A parameter of 1 is stored as parameter 0 of the next edge, so intervals on adjacent edges meet exactly at their shared vertex. Consecutive intervals that meet form one `PerimeterSegment`, and the last segment is joined with the first @@ -250,8 +529,12 @@ Enforced, Neutral and Blocked take part in the usual priority order (see [Weak modifiers](#weak-modifiers)). The perimeter is fully contained when the united intervals cover every source -edge from parameter 0 to 1. A modifier boundary that merely touches the -perimeter counts as well: +edge from parameter 0 to 1, which is the case when the modifier covers the whole +surface: every shifted edge and every dead stretch. A modifier that covers the +whole centerline but leaves part of the surface outside gives ordinary segments. +An uncovered part of a single arc carries onto one vertex, a gap of zero +length, and so still counts as full containment. A modifier boundary that merely +touches the perimeter counts as well: - At a vertex or on an axis-aligned edge, clipping splits the line exactly at the touch, the pieces meet at one point, and the coverage is complete. @@ -270,7 +553,8 @@ where insertion collapses it, exactly up to edges shorter than 2 µm: each end then snaps onto it from its own edge. A cheap filter runs first: both cases bring the segment's ends within 2 µm of -each other. +each other. A zero-length segment covers nothing and is never full containment, +although its ends coincide. ## Strong modifiers @@ -284,7 +568,7 @@ before anything is inserted, together with the source edge it lies on: Arc length is the sum of Euclidean edge lengths, not the chord or a vertex count. `insert_strong_seam_point()` selects the longest segment of the first modifier -that has one. Exactly equal lengths are resolved by the prepared target points: +that has one; a zero-length segment loses to any other. Exactly equal lengths are resolved by the prepared target points: greater bed Y first, then smaller X; a complete tie keeps the first segment. Slice coordinates already include instance rotation and have the bed axes; centering and XY translation do not change this order. Nearly equal lengths are @@ -348,6 +632,16 @@ lowest priority first; a whole-perimeter zone types every candidate. Blocked and Enforced zones therefore take precedence over painting, and Neutral clears painting inside its zone. +A loop on which a candidate is left Enforced by a zone has exact ends (see +[Seam alignment](seam-alignment.md)): the zone ends at its inserted boundaries, +so alignment and the Random position keep the seam between them. The mark is one +per loop and is set after painting has typed the candidates. A run enforced on +the same loop only by paint near the layer keeps its candidates, but the seam no +longer passes its ends either. A zone reduced to a single candidate holds the +aligned seam on that candidate: alignment cannot smooth its shift between +layers, which may show where the loop differs from layer to layer, as with +fuzzy skin. + ## Numeric tolerances Coordinates are integers in scaled units: 1 nm by default, and 10 nm when a bed @@ -363,7 +657,11 @@ larger. The enforced subdivision step is a physical distance and stays 0.2 mm. | Value | Role | | --- | --- | | `MACHINE_PRECISION_SQUARED` (2.5 units², about 1.6 nm) | A point lies on an edge if it is this close. It absorbs Clipper's truncation of cuts to whole units (under √2 units from the edge) and never bridges a real gap: a one-unit uncovered gap stays a gap. | -| `TOLERANCE_LINEAR` (1000 units, 1 µm) | Insertion snaps points this close to an existing vertex, and helper points are placed this far from boundaries. The same radius bounds the rounding fallback, contacts and the sub-micron full-containment rule, so those decisions match what insertion would produce anyway. | +| `TOLERANCE_LINEAR` (1000 units, 1 µm) | Insertion snaps points this close to an existing vertex, and helper points are placed this far from boundaries. The same radius bounds the rounding fallback, contacts and the sub-micron full-containment rule, so those decisions match what insertion would produce anyway. It is also the reach of a dead-stretch end, the smallest surface shift, and the agreement of measured shifts with the nominal shift and with a straight change along an edge. | +| `SURFACE_MARGIN` (5000 units, 5 µm) | The reconstructed surface lies this far inside the model surface, so a modifier flush with a model face does not act. | +| `SURFACE_ARC_SAGITTA` (40 units) | Maximum sagitta of the chords of surface arcs. | +| `SHIFT_SAMPLING_STEP` (0.5 mm) | Largest spacing of shift measurements along an edge, the step at which elephant foot compensation is resampled. | +| Slicing resolution plus 1 µm | Widens the accepted range of measured depths: perimeters are built on a contour simplified by the resolution. | | `enforcer_oversampling_distance` (0.2 mm) | Maximum step of enforced subdivision. | Raising the on-edge tolerance would not help with cuts beside a vertex: more @@ -409,18 +707,19 @@ The causes are: the first flagged modifier in print and volume order is named, followed by "(N in total)" when there are several. The type name reuses the menu's translation. -- **modifier "" of "" had no effect on the seam (it might not reach - the centerline of the printed perimeter):** a modifier was evaluated on at - least one perimeter and never gave a segment, full containment or a discarded - fragment. Only the first such modifier in print and volume order is named, - followed by "(N in total)" when there are several. +- **modifier "" of "" had no effect on the seam:** a modifier was + evaluated on at least one perimeter and never gave a segment, full containment + or a discarded fragment. Only the first such modifier in print and volume order + is named, followed by "(N in total)" when there are several. - Only the effect is certain, so the cause is given as a hint. A modifier is + Only the effect is certain, so the text names no cause. A modifier is evaluated only when its turn comes: on a perimeter where a higher strong modifier placed the seam, lower strong and all weak modifiers are not evaluated. A modifier that was never evaluated is not reported, since nothing - is known about it. A point contact gives no segment and does not count as - reaching the perimeter. + is known about it. One that was overridden on the perimeters it crosses and + evaluated only on others it does not reach is reported, although it does reach + the model surface; a cause given in the text would mislead there. A point + contact gives no segment and does not count as reaching the perimeter. The log records the following diagnostic markers: @@ -437,16 +736,73 @@ The log records the following diagnostic markers: Failures and recoveries are counted separately. The first 10 of each per `init()` call are logged in detail, in parallel processing order; if a limit is -exceeded, one summary marker reports the total and the number omitted. +exceeded, one summary marker reports the total. ## Known limitations -- **The modifier must reach the perimeter centerline.** Contacts are taken as - clipping returns them, without offsets or tangency rules, so boundaries that - only graze the centerline are the user's responsibility. Several near-touches - on inclined edges can leave several segments separated by gaps of a few units; - their zones then cover nearly the whole perimeter instead of being treated as - full containment. +- **Where the shift is not measured, or only approximately.** A noisy loop + without its smooth centerline + (sliced data loaded from a cache) gets a surface that repeats the noise. A + measured point moves along the normal of its + edge by the depth projected on that normal: where elephant foot compensation + changes along a wall, the centerline's edges are inclined to the outline, and + the surface falls short of it by `D * (1 / cos a - cos a)` for an inclination + `a`, a few micrometers for usual changes. A closed Arachne loop of + a single line (a ring thinner than two lines) gets a surface on its contour or + hole side only. +- **Fuzzy skin.** The crossing nearest to the smooth point is taken without + knowing which part of the noisy loop a noisy point came from: with steep noise, + or where another part of the same loop lies within the window (a thin part, an + acute corner), the nearest crossing may belong to another place than the one + the smooth point was textured into. Points carried without the line + (approximate outcome) do not lie on it, and weak zones whose boundaries reverse + are reduced to one point. The window is estimated from the settings. A transfer + fails only when neither a crossing nor a nearest point of the noisy loop lies + within the window, so a boundary that the noise moved farther may be carried + onto another crossing or point within it instead; inner points of a noisy arc + farther than the window can mislead the order policy. The order of a + weak zone's boundaries is checked only where the zone or the rest of the loop is + shorter than four windows; where both are longer, boundaries carried onto + another part of the loop are not noticed. A loop that lies wholly within the + circle of that check (its spread comparable with the window) leaves the + decision to the lengths of the two noisy arcs: noise lengthening one of them + unevenly may then reduce a correct zone or miss a reversal. When both smooth + arcs are shorter than four windows, the zone's rule takes priority. Sliced data loaded from a cache keeps only the + extrusions, without the untextured centerline: such loops keep the noisy + surface and the nominal shift, so the same project may get another seam after + loading. The tests only clear the field by hand; they do not go through + writing and loading the cache. A closed thin wall that the classic generator + builds outside its loops has no untextured centerline either. +- **Grazing contacts.** Contacts are taken as clipping returns them, without + tangency rules, so boundaries that only graze the surface are the user's + responsibility. Several near-touches on inclined edges can leave several + segments separated by gaps of a few units; their zones then cover nearly the + whole perimeter instead of being treated as full containment. +- **Concave corners not resolved exactly.** At a very sharp inner corner that + the slicer bevels, at a sharp change of the measured shift, with a noisy loop + without its smooth centerline whose points are closer than the trim of a corner + (`d * tan(turn / 2)`) or with + artificially fine relief, the surface line keeps its tails and bridges. A modifier boundary + closer than `d` to such a corner can give an extra segment, the + multiple-intersection warning and a local distortion of the segment of up to + `d`; a modifier in the air closer than `d` to such a corner can act. `d` + bounds the distortion, not the movement of the seam: if the distortion changes + which segment of a strong modifier is the longest, the seam moves to another + segment, which may lie at any distance. +- **Walls between regions.** XY compensation is taken once per object, for its + outer contours and its holes. Where an external perimeter runs along the + boundary between two regions of one object (regions whose perimeters are + generated separately), slicing compensates that boundary differently: a + negative compensation does not move it, and a positive one moves it according + to the order of the regions. With a nonzero compensation the reconstructed + surface of such a wall is therefore off the real region boundary by the + amount of the compensation, and a modifier near that boundary may act or not + act accordingly. Restoring it exactly would need the shift actually applied to + each part of the loop, since one loop can contain both such a boundary and a + compensated outer contour. The measured shift does not change this: the + islands do not contain such a boundary, so its points fall outside the + accepted range and take the nominal shift, except near the place where the + boundary meets the outer contour. - **Self-touching perimeters.** Extraction keeps distinct visits of one coordinate apart through its source-edge bindings, but the consumers locate inserted points by coordinates. A weak zone is typed and subdivided from the @@ -566,6 +922,26 @@ last modifier would. type changes and ordering; [3DScene.cpp](../../src/slic3r/GUI/3DScene.cpp) defines the colors. - [Segment extraction tests](../../tests/libslic3r/test_precise_seam.cpp) cover + surface reconstruction (convex and concave corners, holes), crossing the surface without reaching the centerline, modifiers + inside the body, arcs giving zero-length segments, dead stretches covered or + not, contacts and flush faces on straight, inclined and tessellated walls, + full containment of the surface versus the centerline (also with part of one + arc uncovered), a fully covered concave fillet finer than the shift, reversals, nearly collinear vertices, + vertex points at vertex zero and on holes, the bounds of the surface shift, + and independence of contour origin and direction. A shift that changes along + the perimeter is checked at vertices, arcs and a vertex without shift, at a + resolved concave corner and on a split long edge swept by a boundary; its + measurement against an outline at the nominal depth, deeper, beyond the + accepted range, with compensation inside and outside the outline, within the + margin, and with a step along an edge. Fuzzy skin: the transfer onto hand-made + noisy loops across a straight edge, at an acute corner, with several crossings, + along an edge on the line, and its three outcomes; the surface pairs of segment + ends, of a piece of arc, of separate pieces of one arc, across the start of the + loop, and of Center inside an edge, at a vertex, at a collinear vertex (also + vertex zero and a changing shift) and in a dead stretch; a loop keeping its + untextured centerline when copied, reversed or turned. A boundary swept in sub-micron steps across shallow concave + vertices of tessellated holes and notches must move a single segment end + monotonically. On the centerline they cover clipping and binding: holes and components, contour origin and reversal, repeated coordinates, collinear vertices and rounding, rollback and the diagnostic limits, the rounding fallback on synthetic and real Clipper @@ -573,8 +949,15 @@ last modifier would. gaps on inclined edges and around vertices. - [Precise Seam tests](../../tests/fff_print/test_precise_seam.cpp) cover the consumers: strong targets in every mode, including a midpoint on an existing - vertex or the closing edge, longest-arc selection and tie order in bed axes, - priorities, weak boundaries that coincide or share an edge, enforced + vertex or the closing edge and a zero-length segment, longest-arc selection + (also of a longer segment over a zero-length one) and tie order in bed axes, + zero-length weak zones of every type, with fuzzy skin strong points chosen on + the smooth loop and inserted into the noisy one or discarded when they cannot be + carried, and weak zones short, zero-length at a convex corner, reversed (for + every type, also on a loop that lies wholly within the circle of the order + check), across the start of both loops, long or short with noise + lengthening only their part of the loop and almost all round, also with noise + lengthening only the short rest (each for every type), priorities, weak boundaries that coincide or share an edge, enforced subdivision, whole-perimeter weak zones with painting and priorities, weak zones over painting's oversampled candidates, the warning type masks, usage tracking for the "had no effect" and whole-perimeter Blocked warnings, volume @@ -582,7 +965,21 @@ last modifier would. alignment, raft layer indexing and structured slices. End-to-end tests slice a real object with Precise Seam volumes and check the outer wall starts in the exported G-code: every strong - mode under several seam positions and with a raft, Enforced and Blocked zones, + mode under several seam positions and with a raft, a modifier reaching only + 0.1 mm into the model, contour and hole walls under positive and negative XY + compensation with both generators, a first layer with a wider line, a narrow + island the classic generator prints with a thinner line, the + measured shift on elephant foot layers with both generators (the same + modifier depth as above, flush and slightly deeper modifiers, a hole, a thin + part they cannot shrink fully, a raft), XY compensation together with elephant + foot compensation in one region and in several, an Arachne wall narrower than + its line, fuzzy skin on contours or holes (measured on the smooth centerline; + which loops keep it; with sine noise a modifier acts at the model surface, not + at the noise, also on part of a wall; a weak zone; Arachne's combined mode with + the smallest noise; elephant foot compensation in one region and in several; a + closed classic thin wall; loops whose untextured centerline is cleared by hand, + as loading cached data leaves them), a modifier + crossing only an open thin wall, Enforced and Blocked zones, a perimeter blocked all round under every seam position, a modifier with a hole, and the user warning. - [Seam placer tests](../../tests/fff_print/test_seam_placer.cpp) cover diff --git a/docs/HLSD/seam-alignment.md b/docs/HLSD/seam-alignment.md index 8dfbda1a2f..7d9c6792ad 100644 --- a/docs/HLSD/seam-alignment.md +++ b/docs/HLSD/seam-alignment.md @@ -49,8 +49,9 @@ no penalty and do not change candidate ranking. Precise Seam modifiers apply aft classification and take priority over it. Random placement samples an outgoing edge of its selected candidate. On loops with exact -green ranges, an Enforced candidate followed by a non-Enforced candidate contributes no outgoing -edge length: the endpoint belongs to the paint, but the following segment leaves the permitted run. +green ranges, and on loops with an Enforced zone of a Precise Seam modifier in effect, an Enforced +candidate followed by a non-Enforced candidate contributes no outgoing edge length: the endpoint +belongs to the paint or the zone, but the following segment leaves the permitted run. This also respects weak modifiers that retype part of a painted run as Blocked or Neutral. On loops with exact red ranges, a permitted candidate followed by a Blocked candidate contributes no outgoing edge length, so Random cannot sample toward the closed red boundary. A zero-length selected @@ -243,6 +244,9 @@ Properties: ### Allowed arc - For an Enforced C on a loop with exact ends: the Enforced run itself, which ends at the paint. + A loop with an Enforced zone of a Precise Seam modifier in effect counts as one here and for + Random placement only: the zone ends at its inserted boundaries, and its candidates are typed by + the zone, not by painted ranges. - For another Enforced C: the Enforced run, extended past each open end by the oversampling distance (0.2 mm) but never into a Blocked candidate. The run ends sit on candidates and move in sampling steps between layers, and Rear tends to choose the candidate right at an end; without the diff --git a/localization/i18n/OrcaSlicer.pot b/localization/i18n/OrcaSlicer.pot index 960b645c84..8138a321b3 100644 --- a/localization/i18n/OrcaSlicer.pot +++ b/localization/i18n/OrcaSlicer.pot @@ -13623,11 +13623,11 @@ msgid "%1% modifier \"%2%\" of \"%3%\" (%4% in total) covers an entire perimeter msgstr "" #, possible-boost-format -msgid "modifier \"%1%\" of \"%2%\" had no effect on the seam (it might not reach the centerline of the printed perimeter)" +msgid "modifier \"%1%\" of \"%2%\" had no effect on the seam" msgstr "" #, possible-boost-format -msgid "modifier \"%1%\" of \"%2%\" (%3% in total) had no effect on the seam (it might not reach the centerline of the printed perimeter)" +msgid "modifier \"%1%\" of \"%2%\" (%3% in total) had no effect on the seam" msgstr "" msgid "Seam placement may differ from expected." diff --git a/localization/i18n/ca/OrcaSlicer_ca.po b/localization/i18n/ca/OrcaSlicer_ca.po index 6c253b0e71..1cd16cf398 100644 --- a/localization/i18n/ca/OrcaSlicer_ca.po +++ b/localization/i18n/ca/OrcaSlicer_ca.po @@ -15449,13 +15449,13 @@ msgstr "El modificador %1% \"%2%\" de \"%3%\" (%4% en total) cobreix un perímet # AI Translated #, boost-format -msgid "modifier \"%1%\" of \"%2%\" had no effect on the seam (it might not reach the centerline of the printed perimeter)" -msgstr "el modificador \"%1%\" de \"%2%\" no ha tingut cap efecte sobre la costura (potser no arriba a la línia central del perímetre imprès)" +msgid "modifier \"%1%\" of \"%2%\" had no effect on the seam" +msgstr "el modificador \"%1%\" de \"%2%\" no ha tingut cap efecte sobre la costura" # AI Translated #, boost-format -msgid "modifier \"%1%\" of \"%2%\" (%3% in total) had no effect on the seam (it might not reach the centerline of the printed perimeter)" -msgstr "el modificador \"%1%\" de \"%2%\" (%3% en total) no ha tingut cap efecte sobre la costura (potser no arriba a la línia central del perímetre imprès)" +msgid "modifier \"%1%\" of \"%2%\" (%3% in total) had no effect on the seam" +msgstr "el modificador \"%1%\" de \"%2%\" (%3% en total) no ha tingut cap efecte sobre la costura" # AI Translated msgid "Seam placement may differ from expected." diff --git a/localization/i18n/cs/OrcaSlicer_cs.po b/localization/i18n/cs/OrcaSlicer_cs.po index 0765ad5c6c..fdd10f7ec0 100644 --- a/localization/i18n/cs/OrcaSlicer_cs.po +++ b/localization/i18n/cs/OrcaSlicer_cs.po @@ -15501,13 +15501,13 @@ msgstr "Modifikátor %1% „%2%“ objektu „%3%“ (celkem %4%) pokrývá cel # AI Translated #, boost-format -msgid "modifier \"%1%\" of \"%2%\" had no effect on the seam (it might not reach the centerline of the printed perimeter)" -msgstr "modifikátor „%1%“ objektu „%2%“ neměl na šev žádný vliv (možná nezasahuje ke středové linii tištěného obvodu)" +msgid "modifier \"%1%\" of \"%2%\" had no effect on the seam" +msgstr "modifikátor „%1%“ objektu „%2%“ neměl na šev žádný vliv" # AI Translated #, boost-format -msgid "modifier \"%1%\" of \"%2%\" (%3% in total) had no effect on the seam (it might not reach the centerline of the printed perimeter)" -msgstr "modifikátor „%1%“ objektu „%2%“ (celkem %3%) neměl na šev žádný vliv (možná nezasahuje ke středové linii tištěného obvodu)" +msgid "modifier \"%1%\" of \"%2%\" (%3% in total) had no effect on the seam" +msgstr "modifikátor „%1%“ objektu „%2%“ (celkem %3%) neměl na šev žádný vliv" # AI Translated msgid "Seam placement may differ from expected." diff --git a/localization/i18n/de/OrcaSlicer_de.po b/localization/i18n/de/OrcaSlicer_de.po index ff8c31153b..56aeee7dbf 100644 --- a/localization/i18n/de/OrcaSlicer_de.po +++ b/localization/i18n/de/OrcaSlicer_de.po @@ -15218,13 +15218,13 @@ msgstr "Modifizierer „%2%“ (%1%) von „%3%“ (%4% insgesamt) deckt eine ga # AI Translated #, boost-format -msgid "modifier \"%1%\" of \"%2%\" had no effect on the seam (it might not reach the centerline of the printed perimeter)" -msgstr "Modifizierer „%1%“ von „%2%“ hatte keine Auswirkung auf die Naht (er erreicht möglicherweise nicht die Mittellinie der gedruckten Wand)" +msgid "modifier \"%1%\" of \"%2%\" had no effect on the seam" +msgstr "Modifizierer „%1%“ von „%2%“ hatte keine Auswirkung auf die Naht" # AI Translated #, boost-format -msgid "modifier \"%1%\" of \"%2%\" (%3% in total) had no effect on the seam (it might not reach the centerline of the printed perimeter)" -msgstr "Modifizierer „%1%“ von „%2%“ (%3% insgesamt) hatte keine Auswirkung auf die Naht (er erreicht möglicherweise nicht die Mittellinie der gedruckten Wand)" +msgid "modifier \"%1%\" of \"%2%\" (%3% in total) had no effect on the seam" +msgstr "Modifizierer „%1%“ von „%2%“ (%3% insgesamt) hatte keine Auswirkung auf die Naht" # AI Translated msgid "Seam placement may differ from expected." diff --git a/localization/i18n/en/OrcaSlicer_en.po b/localization/i18n/en/OrcaSlicer_en.po index 5b23f06779..d9b8dd5e2c 100644 --- a/localization/i18n/en/OrcaSlicer_en.po +++ b/localization/i18n/en/OrcaSlicer_en.po @@ -13619,11 +13619,11 @@ msgid "%1% modifier \"%2%\" of \"%3%\" (%4% in total) covers an entire perimeter msgstr "" #, boost-format -msgid "modifier \"%1%\" of \"%2%\" had no effect on the seam (it might not reach the centerline of the printed perimeter)" +msgid "modifier \"%1%\" of \"%2%\" had no effect on the seam" msgstr "" #, boost-format -msgid "modifier \"%1%\" of \"%2%\" (%3% in total) had no effect on the seam (it might not reach the centerline of the printed perimeter)" +msgid "modifier \"%1%\" of \"%2%\" (%3% in total) had no effect on the seam" msgstr "" msgid "Seam placement may differ from expected." diff --git a/localization/i18n/es/OrcaSlicer_es.po b/localization/i18n/es/OrcaSlicer_es.po index 5097dfdbcb..3c932379f6 100644 --- a/localization/i18n/es/OrcaSlicer_es.po +++ b/localization/i18n/es/OrcaSlicer_es.po @@ -14883,13 +14883,13 @@ msgstr "El modificador %1% «%2%» de «%3%» (%4% en total) cubre un perímetro # AI Translated #, boost-format -msgid "modifier \"%1%\" of \"%2%\" had no effect on the seam (it might not reach the centerline of the printed perimeter)" -msgstr "el modificador \"%1%\" de \"%2%\" no tuvo efecto en la costura (puede que no alcance la línea central del perímetro impreso)" +msgid "modifier \"%1%\" of \"%2%\" had no effect on the seam" +msgstr "el modificador \"%1%\" de \"%2%\" no tuvo efecto en la costura" # AI Translated #, boost-format -msgid "modifier \"%1%\" of \"%2%\" (%3% in total) had no effect on the seam (it might not reach the centerline of the printed perimeter)" -msgstr "el modificador \"%1%\" de \"%2%\" (%3% en total) no tuvo efecto en la costura (puede que no alcance la línea central del perímetro impreso)" +msgid "modifier \"%1%\" of \"%2%\" (%3% in total) had no effect on the seam" +msgstr "el modificador \"%1%\" de \"%2%\" (%3% en total) no tuvo efecto en la costura" # AI Translated msgid "Seam placement may differ from expected." diff --git a/localization/i18n/eu/OrcaSlicer_eu.po b/localization/i18n/eu/OrcaSlicer_eu.po index ae953cd07f..1a4a5c9320 100644 --- a/localization/i18n/eu/OrcaSlicer_eu.po +++ b/localization/i18n/eu/OrcaSlicer_eu.po @@ -15044,13 +15044,13 @@ msgstr "%1% motako \"%2%\" aldatzaileak (\"%3%\" objektukoak, guztira %4%) perim # AI Translated #, boost-format -msgid "modifier \"%1%\" of \"%2%\" had no effect on the seam (it might not reach the centerline of the printed perimeter)" -msgstr "\"%2%\" objektuaren \"%1%\" aldatzaileak ez du eraginik izan josturan (baliteke inprimatutako perimetroaren erdiko lerrora ez iristea)" +msgid "modifier \"%1%\" of \"%2%\" had no effect on the seam" +msgstr "\"%2%\" objektuaren \"%1%\" aldatzaileak ez du eraginik izan josturan" # AI Translated #, boost-format -msgid "modifier \"%1%\" of \"%2%\" (%3% in total) had no effect on the seam (it might not reach the centerline of the printed perimeter)" -msgstr "\"%2%\" objektuaren \"%1%\" aldatzaileak (%3% guztira) ez du eraginik izan josturan (baliteke inprimatutako perimetroaren erdiko lerrora ez iristea)" +msgid "modifier \"%1%\" of \"%2%\" (%3% in total) had no effect on the seam" +msgstr "\"%2%\" objektuaren \"%1%\" aldatzaileak (%3% guztira) ez du eraginik izan josturan" # AI Translated msgid "Seam placement may differ from expected." diff --git a/localization/i18n/fr/OrcaSlicer_fr.po b/localization/i18n/fr/OrcaSlicer_fr.po index ab36ada111..63e48f5097 100644 --- a/localization/i18n/fr/OrcaSlicer_fr.po +++ b/localization/i18n/fr/OrcaSlicer_fr.po @@ -15028,13 +15028,13 @@ msgstr "Le modificateur %1% « %2% » de « %3% » (%4% au total) couvre un pér # AI Translated #, boost-format -msgid "modifier \"%1%\" of \"%2%\" had no effect on the seam (it might not reach the centerline of the printed perimeter)" -msgstr "le modificateur « %1% » de « %2% » n’a eu aucun effet sur la couture (il n’atteint peut-être pas la ligne médiane du périmètre imprimé)" +msgid "modifier \"%1%\" of \"%2%\" had no effect on the seam" +msgstr "le modificateur « %1% » de « %2% » n’a eu aucun effet sur la couture" # AI Translated #, boost-format -msgid "modifier \"%1%\" of \"%2%\" (%3% in total) had no effect on the seam (it might not reach the centerline of the printed perimeter)" -msgstr "le modificateur « %1% » de « %2% » (%3% au total) n’a eu aucun effet sur la couture (il n’atteint peut-être pas la ligne médiane du périmètre imprimé)" +msgid "modifier \"%1%\" of \"%2%\" (%3% in total) had no effect on the seam" +msgstr "le modificateur « %1% » de « %2% » (%3% au total) n’a eu aucun effet sur la couture" # AI Translated msgid "Seam placement may differ from expected." diff --git a/localization/i18n/hu/OrcaSlicer_hu.po b/localization/i18n/hu/OrcaSlicer_hu.po index e76ebefa07..2ab5f79f76 100644 --- a/localization/i18n/hu/OrcaSlicer_hu.po +++ b/localization/i18n/hu/OrcaSlicer_hu.po @@ -15368,13 +15368,13 @@ msgstr "%1% módosító „%2%” (objektum: „%3%”, összesen: %4%) a teljes # AI Translated #, boost-format -msgid "modifier \"%1%\" of \"%2%\" had no effect on the seam (it might not reach the centerline of the printed perimeter)" -msgstr "a(z) \"%2%\" \"%1%\" módosítója nem volt hatással a varratra (lehet, hogy nem éri el a nyomtatott kerület középvonalát)" +msgid "modifier \"%1%\" of \"%2%\" had no effect on the seam" +msgstr "a(z) \"%2%\" \"%1%\" módosítója nem volt hatással a varratra" # AI Translated #, boost-format -msgid "modifier \"%1%\" of \"%2%\" (%3% in total) had no effect on the seam (it might not reach the centerline of the printed perimeter)" -msgstr "a(z) \"%2%\" \"%1%\" módosítója (összesen %3%) nem volt hatással a varratra (lehet, hogy nem éri el a nyomtatott kerület középvonalát)" +msgid "modifier \"%1%\" of \"%2%\" (%3% in total) had no effect on the seam" +msgstr "a(z) \"%2%\" \"%1%\" módosítója (összesen %3%) nem volt hatással a varratra" # AI Translated msgid "Seam placement may differ from expected." diff --git a/localization/i18n/it/OrcaSlicer_it.po b/localization/i18n/it/OrcaSlicer_it.po index 212db7a890..4746d8ca6d 100644 --- a/localization/i18n/it/OrcaSlicer_it.po +++ b/localization/i18n/it/OrcaSlicer_it.po @@ -15294,13 +15294,13 @@ msgstr "Il modificatore %1% \"%2%\" di \"%3%\" (%4% in totale) copre un intero p # AI Translated #, boost-format -msgid "modifier \"%1%\" of \"%2%\" had no effect on the seam (it might not reach the centerline of the printed perimeter)" -msgstr "il modificatore \"%1%\" di \"%2%\" non ha avuto effetto sulla cucitura (potrebbe non raggiungere la linea centrale del perimetro stampato)" +msgid "modifier \"%1%\" of \"%2%\" had no effect on the seam" +msgstr "il modificatore \"%1%\" di \"%2%\" non ha avuto effetto sulla cucitura" # AI Translated #, boost-format -msgid "modifier \"%1%\" of \"%2%\" (%3% in total) had no effect on the seam (it might not reach the centerline of the printed perimeter)" -msgstr "il modificatore \"%1%\" di \"%2%\" (%3% in totale) non ha avuto effetto sulla cucitura (potrebbe non raggiungere la linea centrale del perimetro stampato)" +msgid "modifier \"%1%\" of \"%2%\" (%3% in total) had no effect on the seam" +msgstr "il modificatore \"%1%\" di \"%2%\" (%3% in totale) non ha avuto effetto sulla cucitura" # AI Translated msgid "Seam placement may differ from expected." diff --git a/localization/i18n/ja/OrcaSlicer_ja.po b/localization/i18n/ja/OrcaSlicer_ja.po index a0fedc178d..2fb5e86ab8 100644 --- a/localization/i18n/ja/OrcaSlicer_ja.po +++ b/localization/i18n/ja/OrcaSlicer_ja.po @@ -15808,13 +15808,13 @@ msgstr "「%3%」の %1% モディファイア「%2%」(合計%4%個) は外周 # AI Translated #, boost-format -msgid "modifier \"%1%\" of \"%2%\" had no effect on the seam (it might not reach the centerline of the printed perimeter)" -msgstr "「%2%」のモディファイア「%1%」は継ぎ目に影響しませんでした (印刷される外周の中心線に届いていない可能性があります)" +msgid "modifier \"%1%\" of \"%2%\" had no effect on the seam" +msgstr "「%2%」のモディファイア「%1%」は継ぎ目に影響しませんでした" # AI Translated #, boost-format -msgid "modifier \"%1%\" of \"%2%\" (%3% in total) had no effect on the seam (it might not reach the centerline of the printed perimeter)" -msgstr "「%2%」のモディファイア「%1%」(合計%3%個) は継ぎ目に影響しませんでした (印刷される外周の中心線に届いていない可能性があります)" +msgid "modifier \"%1%\" of \"%2%\" (%3% in total) had no effect on the seam" +msgstr "「%2%」のモディファイア「%1%」(合計%3%個) は継ぎ目に影響しませんでした" # AI Translated msgid "Seam placement may differ from expected." diff --git a/localization/i18n/ko/OrcaSlicer_ko.po b/localization/i18n/ko/OrcaSlicer_ko.po index 680c041950..3611fa7b06 100644 --- a/localization/i18n/ko/OrcaSlicer_ko.po +++ b/localization/i18n/ko/OrcaSlicer_ko.po @@ -15521,13 +15521,13 @@ msgstr "\"%3%\"의 %1% 수정자 \"%2%\"(총 %4%개)이(가) 둘레 전체를 # AI Translated #, boost-format -msgid "modifier \"%1%\" of \"%2%\" had no effect on the seam (it might not reach the centerline of the printed perimeter)" -msgstr "\"%2%\"의 수정자 \"%1%\"이(가) 재봉선에 영향을 주지 않았습니다(출력된 둘레의 중심선에 닿지 않았을 수 있습니다)" +msgid "modifier \"%1%\" of \"%2%\" had no effect on the seam" +msgstr "\"%2%\"의 수정자 \"%1%\"이(가) 재봉선에 영향을 주지 않았습니다" # AI Translated #, boost-format -msgid "modifier \"%1%\" of \"%2%\" (%3% in total) had no effect on the seam (it might not reach the centerline of the printed perimeter)" -msgstr "\"%2%\"의 수정자 \"%1%\"(총 %3%개)이(가) 재봉선에 영향을 주지 않았습니다(출력된 둘레의 중심선에 닿지 않았을 수 있습니다)" +msgid "modifier \"%1%\" of \"%2%\" (%3% in total) had no effect on the seam" +msgstr "\"%2%\"의 수정자 \"%1%\"(총 %3%개)이(가) 재봉선에 영향을 주지 않았습니다" # AI Translated msgid "Seam placement may differ from expected." diff --git a/localization/i18n/lt/OrcaSlicer_lt.po b/localization/i18n/lt/OrcaSlicer_lt.po index b38a7c9085..1151ce95db 100644 --- a/localization/i18n/lt/OrcaSlicer_lt.po +++ b/localization/i18n/lt/OrcaSlicer_lt.po @@ -15325,13 +15325,13 @@ msgstr "Modifikatorius %1% „%2%“ objekto „%3%“ (iš viso %4%) apima vis # AI Translated #, boost-format -msgid "modifier \"%1%\" of \"%2%\" had no effect on the seam (it might not reach the centerline of the printed perimeter)" -msgstr "objekto „%2%“ modifikatorius „%1%“ neturėjo įtakos siūlei (galbūt jis nesiekia spausdinamo perimetro vidurio linijos)" +msgid "modifier \"%1%\" of \"%2%\" had no effect on the seam" +msgstr "objekto „%2%“ modifikatorius „%1%“ neturėjo įtakos siūlei" # AI Translated #, boost-format -msgid "modifier \"%1%\" of \"%2%\" (%3% in total) had no effect on the seam (it might not reach the centerline of the printed perimeter)" -msgstr "objekto „%2%“ modifikatorius „%1%“ (iš viso %3%) neturėjo įtakos siūlei (galbūt jis nesiekia spausdinamo perimetro vidurio linijos)" +msgid "modifier \"%1%\" of \"%2%\" (%3% in total) had no effect on the seam" +msgstr "objekto „%2%“ modifikatorius „%1%“ (iš viso %3%) neturėjo įtakos siūlei" # AI Translated msgid "Seam placement may differ from expected." diff --git a/localization/i18n/nl/OrcaSlicer_nl.po b/localization/i18n/nl/OrcaSlicer_nl.po index d5c23bbcfe..5d797e24db 100644 --- a/localization/i18n/nl/OrcaSlicer_nl.po +++ b/localization/i18n/nl/OrcaSlicer_nl.po @@ -16362,13 +16362,13 @@ msgstr "Aanpasser \"%2%\" (%1%) van \"%3%\" (%4% in totaal) bedekt een volledige # AI Translated #, boost-format -msgid "modifier \"%1%\" of \"%2%\" had no effect on the seam (it might not reach the centerline of the printed perimeter)" -msgstr "aanpasser \"%1%\" van \"%2%\" had geen effect op de naad (mogelijk reikt deze niet tot de middellijn van de geprinte perimeter)" +msgid "modifier \"%1%\" of \"%2%\" had no effect on the seam" +msgstr "aanpasser \"%1%\" van \"%2%\" had geen effect op de naad" # AI Translated #, boost-format -msgid "modifier \"%1%\" of \"%2%\" (%3% in total) had no effect on the seam (it might not reach the centerline of the printed perimeter)" -msgstr "aanpasser \"%1%\" van \"%2%\" (%3% in totaal) had geen effect op de naad (mogelijk reikt deze niet tot de middellijn van de geprinte perimeter)" +msgid "modifier \"%1%\" of \"%2%\" (%3% in total) had no effect on the seam" +msgstr "aanpasser \"%1%\" van \"%2%\" (%3% in totaal) had geen effect op de naad" # AI Translated msgid "Seam placement may differ from expected." diff --git a/localization/i18n/pl/OrcaSlicer_pl.po b/localization/i18n/pl/OrcaSlicer_pl.po index 83bb9bea49..f0a7eebe98 100644 --- a/localization/i18n/pl/OrcaSlicer_pl.po +++ b/localization/i18n/pl/OrcaSlicer_pl.po @@ -15632,13 +15632,13 @@ msgstr "Modyfikator „%2%” (%1%) obiektu „%3%” (łącznie %4%) obejmuje c # AI Translated #, boost-format -msgid "modifier \"%1%\" of \"%2%\" had no effect on the seam (it might not reach the centerline of the printed perimeter)" -msgstr "modyfikator „%1%” obiektu „%2%” nie wpłynął na szew (może nie sięgać linii środkowej drukowanego obrysu)" +msgid "modifier \"%1%\" of \"%2%\" had no effect on the seam" +msgstr "modyfikator „%1%” obiektu „%2%” nie wpłynął na szew" # AI Translated #, boost-format -msgid "modifier \"%1%\" of \"%2%\" (%3% in total) had no effect on the seam (it might not reach the centerline of the printed perimeter)" -msgstr "modyfikator „%1%” obiektu „%2%” (łącznie %3%) nie wpłynął na szew (może nie sięgać linii środkowej drukowanego obrysu)" +msgid "modifier \"%1%\" of \"%2%\" (%3% in total) had no effect on the seam" +msgstr "modyfikator „%1%” obiektu „%2%” (łącznie %3%) nie wpłynął na szew" # AI Translated msgid "Seam placement may differ from expected." diff --git a/localization/i18n/pt_BR/OrcaSlicer_pt_BR.po b/localization/i18n/pt_BR/OrcaSlicer_pt_BR.po index 7a8c39f7bd..696005a48d 100644 --- a/localization/i18n/pt_BR/OrcaSlicer_pt_BR.po +++ b/localization/i18n/pt_BR/OrcaSlicer_pt_BR.po @@ -14375,12 +14375,12 @@ msgid "%1% modifier \"%2%\" of \"%3%\" (%4% in total) covers an entire perimeter msgstr "O modificador %1% \"%2%\" de \"%3%\" (%4% no total) cobre um perímetro inteiro" #, boost-format -msgid "modifier \"%1%\" of \"%2%\" had no effect on the seam (it might not reach the centerline of the printed perimeter)" -msgstr "o modificador \"%1%\" de \"%2%\" não teve efeito na costura (talvez não alcance a linha central do perímetro impresso)" +msgid "modifier \"%1%\" of \"%2%\" had no effect on the seam" +msgstr "o modificador \"%1%\" de \"%2%\" não teve efeito na costura" #, boost-format -msgid "modifier \"%1%\" of \"%2%\" (%3% in total) had no effect on the seam (it might not reach the centerline of the printed perimeter)" -msgstr "o modificador \"%1%\" de \"%2%\" (%3% no total) não teve efeito na costura (talvez não alcance a linha central do perímetro impresso)" +msgid "modifier \"%1%\" of \"%2%\" (%3% in total) had no effect on the seam" +msgstr "o modificador \"%1%\" de \"%2%\" (%3% no total) não teve efeito na costura" msgid "Seam placement may differ from expected." msgstr "A posição da costura pode diferir do esperado." diff --git a/localization/i18n/ru/OrcaSlicer_ru.po b/localization/i18n/ru/OrcaSlicer_ru.po index 52efa944e8..29631e654c 100644 --- a/localization/i18n/ru/OrcaSlicer_ru.po +++ b/localization/i18n/ru/OrcaSlicer_ru.po @@ -14849,12 +14849,12 @@ msgid "%1% modifier \"%2%\" of \"%3%\" (%4% in total) covers an entire perimeter msgstr "Модификатор «%2%» (%1%) модели «%3%» (всего: %4%) охватывает периметр целиком" #, boost-format -msgid "modifier \"%1%\" of \"%2%\" had no effect on the seam (it might not reach the centerline of the printed perimeter)" -msgstr "модификатор «%1%» модели «%2%» не повлиял на шов (возможно, он не достигает осевой линии печатаемого периметра)" +msgid "modifier \"%1%\" of \"%2%\" had no effect on the seam" +msgstr "модификатор «%1%» модели «%2%» не повлиял на шов" #, boost-format -msgid "modifier \"%1%\" of \"%2%\" (%3% in total) had no effect on the seam (it might not reach the centerline of the printed perimeter)" -msgstr "модификатор «%1%» модели «%2%» (всего: %3%) не повлиял на шов (возможно, он не достигает осевой линии печатаемого периметра)" +msgid "modifier \"%1%\" of \"%2%\" (%3% in total) had no effect on the seam" +msgstr "модификатор «%1%» модели «%2%» (всего: %3%) не повлиял на шов" msgid "Seam placement may differ from expected." msgstr "Размещение шва может отличаться от ожидаемого." diff --git a/localization/i18n/sv/OrcaSlicer_sv.po b/localization/i18n/sv/OrcaSlicer_sv.po index 2c6af23d01..36f03be7eb 100644 --- a/localization/i18n/sv/OrcaSlicer_sv.po +++ b/localization/i18n/sv/OrcaSlicer_sv.po @@ -16548,13 +16548,13 @@ msgstr "Modifieraren \"%2%\" (%1%) för \"%3%\" (%4% totalt) täcker en hel peri # AI Translated #, boost-format -msgid "modifier \"%1%\" of \"%2%\" had no effect on the seam (it might not reach the centerline of the printed perimeter)" -msgstr "modifieraren \"%1%\" för \"%2%\" hade ingen effekt på sömmen (den kanske inte når mittlinjen för den utskrivna perimetern)" +msgid "modifier \"%1%\" of \"%2%\" had no effect on the seam" +msgstr "modifieraren \"%1%\" för \"%2%\" hade ingen effekt på sömmen" # AI Translated #, boost-format -msgid "modifier \"%1%\" of \"%2%\" (%3% in total) had no effect on the seam (it might not reach the centerline of the printed perimeter)" -msgstr "modifieraren \"%1%\" för \"%2%\" (%3% totalt) hade ingen effekt på sömmen (den kanske inte når mittlinjen för den utskrivna perimetern)" +msgid "modifier \"%1%\" of \"%2%\" (%3% in total) had no effect on the seam" +msgstr "modifieraren \"%1%\" för \"%2%\" (%3% totalt) hade ingen effekt på sömmen" # AI Translated msgid "Seam placement may differ from expected." diff --git a/localization/i18n/th/OrcaSlicer_th.po b/localization/i18n/th/OrcaSlicer_th.po index 796226ed42..c06336678a 100644 --- a/localization/i18n/th/OrcaSlicer_th.po +++ b/localization/i18n/th/OrcaSlicer_th.po @@ -15255,13 +15255,13 @@ msgstr "ตัวปรับแต่ง %1% \"%2%\" ของ \"%3%\" (ทั # AI Translated #, boost-format -msgid "modifier \"%1%\" of \"%2%\" had no effect on the seam (it might not reach the centerline of the printed perimeter)" -msgstr "ตัวปรับแต่ง \"%1%\" ของ \"%2%\" ไม่มีผลต่อรอยตะเข็บ (อาจไม่ถึงเส้นกึ่งกลางของเส้นรอบวงที่พิมพ์)" +msgid "modifier \"%1%\" of \"%2%\" had no effect on the seam" +msgstr "ตัวปรับแต่ง \"%1%\" ของ \"%2%\" ไม่มีผลต่อรอยตะเข็บ" # AI Translated #, boost-format -msgid "modifier \"%1%\" of \"%2%\" (%3% in total) had no effect on the seam (it might not reach the centerline of the printed perimeter)" -msgstr "ตัวปรับแต่ง \"%1%\" ของ \"%2%\" (ทั้งหมด %3% รายการ) ไม่มีผลต่อรอยตะเข็บ (อาจไม่ถึงเส้นกึ่งกลางของเส้นรอบวงที่พิมพ์)" +msgid "modifier \"%1%\" of \"%2%\" (%3% in total) had no effect on the seam" +msgstr "ตัวปรับแต่ง \"%1%\" ของ \"%2%\" (ทั้งหมด %3% รายการ) ไม่มีผลต่อรอยตะเข็บ" # AI Translated msgid "Seam placement may differ from expected." diff --git a/localization/i18n/tr/OrcaSlicer_tr.po b/localization/i18n/tr/OrcaSlicer_tr.po index fa52822f8a..314b858af4 100644 --- a/localization/i18n/tr/OrcaSlicer_tr.po +++ b/localization/i18n/tr/OrcaSlicer_tr.po @@ -15182,13 +15182,13 @@ msgstr "\"%3%\" nesnesinin %1% değiştiricisi \"%2%\" (toplam %4%), bir çevren # AI Translated #, boost-format -msgid "modifier \"%1%\" of \"%2%\" had no effect on the seam (it might not reach the centerline of the printed perimeter)" -msgstr "\"%2%\" nesnesinin \"%1%\" değiştiricisinin dikiş üzerinde etkisi olmadı (basılan çevrenin merkez çizgisine ulaşmıyor olabilir)" +msgid "modifier \"%1%\" of \"%2%\" had no effect on the seam" +msgstr "\"%2%\" nesnesinin \"%1%\" değiştiricisinin dikiş üzerinde etkisi olmadı" # AI Translated #, boost-format -msgid "modifier \"%1%\" of \"%2%\" (%3% in total) had no effect on the seam (it might not reach the centerline of the printed perimeter)" -msgstr "\"%2%\" nesnesinin \"%1%\" değiştiricisinin (toplam %3%) dikiş üzerinde etkisi olmadı (basılan çevrenin merkez çizgisine ulaşmıyor olabilir)" +msgid "modifier \"%1%\" of \"%2%\" (%3% in total) had no effect on the seam" +msgstr "\"%2%\" nesnesinin \"%1%\" değiştiricisinin (toplam %3%) dikiş üzerinde etkisi olmadı" # AI Translated msgid "Seam placement may differ from expected." diff --git a/localization/i18n/uk/OrcaSlicer_uk.po b/localization/i18n/uk/OrcaSlicer_uk.po index b927aa8605..551704db1f 100644 --- a/localization/i18n/uk/OrcaSlicer_uk.po +++ b/localization/i18n/uk/OrcaSlicer_uk.po @@ -15533,13 +15533,13 @@ msgstr "Модифікатор «%2%» (%1%) обʼєкта «%3%» (усьог # AI Translated #, boost-format -msgid "modifier \"%1%\" of \"%2%\" had no effect on the seam (it might not reach the centerline of the printed perimeter)" -msgstr "модифікатор \"%1%\" обʼєкта \"%2%\" не вплинув на шов (можливо, він не досягає осьової лінії надрукованого периметра)" +msgid "modifier \"%1%\" of \"%2%\" had no effect on the seam" +msgstr "модифікатор \"%1%\" обʼєкта \"%2%\" не вплинув на шов" # AI Translated #, boost-format -msgid "modifier \"%1%\" of \"%2%\" (%3% in total) had no effect on the seam (it might not reach the centerline of the printed perimeter)" -msgstr "модифікатор \"%1%\" обʼєкта \"%2%\" (усього %3%) не вплинув на шов (можливо, він не досягає осьової лінії надрукованого периметра)" +msgid "modifier \"%1%\" of \"%2%\" (%3% in total) had no effect on the seam" +msgstr "модифікатор \"%1%\" обʼєкта \"%2%\" (усього %3%) не вплинув на шов" # AI Translated msgid "Seam placement may differ from expected." diff --git a/localization/i18n/vi/OrcaSlicer_vi.po b/localization/i18n/vi/OrcaSlicer_vi.po index b974f8f1f3..fad0776a5c 100644 --- a/localization/i18n/vi/OrcaSlicer_vi.po +++ b/localization/i18n/vi/OrcaSlicer_vi.po @@ -15982,13 +15982,13 @@ msgstr "Modifier %1% \"%2%\" của \"%3%\" (tổng cộng %4%) bao phủ toàn b # AI Translated #, boost-format -msgid "modifier \"%1%\" of \"%2%\" had no effect on the seam (it might not reach the centerline of the printed perimeter)" -msgstr "modifier \"%1%\" của \"%2%\" không có tác dụng lên đường nối (có thể nó không chạm tới đường tâm của chu vi được in)" +msgid "modifier \"%1%\" of \"%2%\" had no effect on the seam" +msgstr "modifier \"%1%\" của \"%2%\" không có tác dụng lên đường nối" # AI Translated #, boost-format -msgid "modifier \"%1%\" of \"%2%\" (%3% in total) had no effect on the seam (it might not reach the centerline of the printed perimeter)" -msgstr "modifier \"%1%\" của \"%2%\" (tổng cộng %3%) không có tác dụng lên đường nối (có thể nó không chạm tới đường tâm của chu vi được in)" +msgid "modifier \"%1%\" of \"%2%\" (%3% in total) had no effect on the seam" +msgstr "modifier \"%1%\" của \"%2%\" (tổng cộng %3%) không có tác dụng lên đường nối" # AI Translated msgid "Seam placement may differ from expected." diff --git a/localization/i18n/zh_CN/OrcaSlicer_zh_CN.po b/localization/i18n/zh_CN/OrcaSlicer_zh_CN.po index 938b64d8b7..94c6971dca 100644 --- a/localization/i18n/zh_CN/OrcaSlicer_zh_CN.po +++ b/localization/i18n/zh_CN/OrcaSlicer_zh_CN.po @@ -15641,13 +15641,13 @@ msgstr "“%3%”的%1%修改器“%2%”(共 %4% 个)覆盖了整条墙" # AI Translated #, boost-format -msgid "modifier \"%1%\" of \"%2%\" had no effect on the seam (it might not reach the centerline of the printed perimeter)" -msgstr "“%2%”的修改器“%1%”对接缝没有影响(它可能未触及所打印墙的中心线)" +msgid "modifier \"%1%\" of \"%2%\" had no effect on the seam" +msgstr "“%2%”的修改器“%1%”对接缝没有影响" # AI Translated #, boost-format -msgid "modifier \"%1%\" of \"%2%\" (%3% in total) had no effect on the seam (it might not reach the centerline of the printed perimeter)" -msgstr "“%2%”的修改器“%1%”(共 %3% 个)对接缝没有影响(它们可能未触及所打印墙的中心线)" +msgid "modifier \"%1%\" of \"%2%\" (%3% in total) had no effect on the seam" +msgstr "“%2%”的修改器“%1%”(共 %3% 个)对接缝没有影响" # AI Translated msgid "Seam placement may differ from expected." diff --git a/localization/i18n/zh_TW/OrcaSlicer_zh_TW.po b/localization/i18n/zh_TW/OrcaSlicer_zh_TW.po index 55743462c0..b4fd417fd5 100644 --- a/localization/i18n/zh_TW/OrcaSlicer_zh_TW.po +++ b/localization/i18n/zh_TW/OrcaSlicer_zh_TW.po @@ -15937,13 +15937,13 @@ msgstr "「%3%」的%1%修改器「%2%」(共 %4% 個)覆蓋整道牆" # AI Translated #, boost-format -msgid "modifier \"%1%\" of \"%2%\" had no effect on the seam (it might not reach the centerline of the printed perimeter)" -msgstr "「%2%」的修改器「%1%」對接縫沒有作用(可能未觸及所列印牆的中心線)" +msgid "modifier \"%1%\" of \"%2%\" had no effect on the seam" +msgstr "「%2%」的修改器「%1%」對接縫沒有作用" # AI Translated #, boost-format -msgid "modifier \"%1%\" of \"%2%\" (%3% in total) had no effect on the seam (it might not reach the centerline of the printed perimeter)" -msgstr "「%2%」的修改器「%1%」(共 %3% 個)對接縫沒有作用(可能未觸及所列印牆的中心線)" +msgid "modifier \"%1%\" of \"%2%\" (%3% in total) had no effect on the seam" +msgstr "「%2%」的修改器「%1%」(共 %3% 個)對接縫沒有作用" # AI Translated msgid "Seam placement may differ from expected." diff --git a/resources/profiles/Anycubic.json b/resources/profiles/Anycubic.json index 739b41b9ae..30fad42f14 100644 --- a/resources/profiles/Anycubic.json +++ b/resources/profiles/Anycubic.json @@ -1,6 +1,6 @@ { "name": "Anycubic", - "version": "02.04.00.10", + "version": "02.04.00.11", "force_update": "0", "description": "Anycubic configurations", "machine_model_list": [ @@ -48,6 +48,10 @@ "name": "Anycubic Kobra 3 Max", "sub_path": "machine/Anycubic Kobra 3 Max.json" }, + { + "name": "Anycubic Kobra 3 Max V2", + "sub_path": "machine/Anycubic Kobra 3 Max V2.json" + }, { "name": "Anycubic Kobra 3 V2", "sub_path": "machine/Anycubic Kobra 3 V2.json" @@ -518,6 +522,10 @@ "name": "0.56mm Standard @Anycubic Kobra S1 Max 0.8 nozzle", "sub_path": "process/0.56mm Standard @Anycubic Kobra S1 Max 0.8 nozzle.json" }, + { + "name": "fdm_process_anycubic_kobra_3_max_v2_common", + "sub_path": "process/fdm_process_anycubic_kobra_3_max_v2_common.json" + }, { "name": "0.12mm High Quality @Anycubic Kobra 3 V2 0.4 nozzle", "sub_path": "process/0.12mm High Quality @Anycubic Kobra 3 V2 0.4 nozzle.json" @@ -545,6 +553,110 @@ { "name": "0.48mm Standard @Anycubic Kobra 3 V2 0.8 nozzle", "sub_path": "process/0.48mm Standard @Anycubic Kobra 3 V2 0.8 nozzle.json" + }, + { + "name": "fdm_process_anycubic_kobra_3_max_v2_nozzle_0.25", + "sub_path": "process/fdm_process_anycubic_kobra_3_max_v2_nozzle_0.25.json" + }, + { + "name": "fdm_process_anycubic_kobra_3_max_v2_nozzle_0.4", + "sub_path": "process/fdm_process_anycubic_kobra_3_max_v2_nozzle_0.4.json" + }, + { + "name": "fdm_process_anycubic_kobra_3_max_v2_nozzle_0.6", + "sub_path": "process/fdm_process_anycubic_kobra_3_max_v2_nozzle_0.6.json" + }, + { + "name": "fdm_process_anycubic_kobra_3_max_v2_nozzle_0.8", + "sub_path": "process/fdm_process_anycubic_kobra_3_max_v2_nozzle_0.8.json" + }, + { + "name": "0.06mm Standard @Anycubic Kobra 3 Max V2 0.25 nozzle", + "sub_path": "process/0.06mm Standard @Anycubic Kobra 3 Max V2 0.25 nozzle.json" + }, + { + "name": "0.08mm Standard @Anycubic Kobra 3 Max V2 0.25 nozzle", + "sub_path": "process/0.08mm Standard @Anycubic Kobra 3 Max V2 0.25 nozzle.json" + }, + { + "name": "0.10mm Standard @Anycubic Kobra 3 Max V2 0.25 nozzle", + "sub_path": "process/0.10mm Standard @Anycubic Kobra 3 Max V2 0.25 nozzle.json" + }, + { + "name": "0.12mm Standard @Anycubic Kobra 3 Max V2 0.25 nozzle", + "sub_path": "process/0.12mm Standard @Anycubic Kobra 3 Max V2 0.25 nozzle.json" + }, + { + "name": "0.14mm Standard @Anycubic Kobra 3 Max V2 0.25 nozzle", + "sub_path": "process/0.14mm Standard @Anycubic Kobra 3 Max V2 0.25 nozzle.json" + }, + { + "name": "0.08mm Standard @Anycubic Kobra 3 Max V2 0.4 nozzle", + "sub_path": "process/0.08mm Standard @Anycubic Kobra 3 Max V2 0.4 nozzle.json" + }, + { + "name": "0.12mm Standard @Anycubic Kobra 3 Max V2 0.4 nozzle", + "sub_path": "process/0.12mm Standard @Anycubic Kobra 3 Max V2 0.4 nozzle.json" + }, + { + "name": "0.16mm Standard @Anycubic Kobra 3 Max V2 0.4 nozzle", + "sub_path": "process/0.16mm Standard @Anycubic Kobra 3 Max V2 0.4 nozzle.json" + }, + { + "name": "0.20mm Standard @Anycubic Kobra 3 Max V2 0.4 nozzle", + "sub_path": "process/0.20mm Standard @Anycubic Kobra 3 Max V2 0.4 nozzle.json" + }, + { + "name": "0.24mm Standard @Anycubic Kobra 3 Max V2 0.4 nozzle", + "sub_path": "process/0.24mm Standard @Anycubic Kobra 3 Max V2 0.4 nozzle.json" + }, + { + "name": "0.28mm Standard @Anycubic Kobra 3 Max V2 0.4 nozzle", + "sub_path": "process/0.28mm Standard @Anycubic Kobra 3 Max V2 0.4 nozzle.json" + }, + { + "name": "0.18mm Standard @Anycubic Kobra 3 Max V2 0.6 nozzle", + "sub_path": "process/0.18mm Standard @Anycubic Kobra 3 Max V2 0.6 nozzle.json" + }, + { + "name": "0.24mm Standard @Anycubic Kobra 3 Max V2 0.6 nozzle", + "sub_path": "process/0.24mm Standard @Anycubic Kobra 3 Max V2 0.6 nozzle.json" + }, + { + "name": "0.30mm Standard @Anycubic Kobra 3 Max V2 0.6 nozzle", + "sub_path": "process/0.30mm Standard @Anycubic Kobra 3 Max V2 0.6 nozzle.json" + }, + { + "name": "0.36mm Standard @Anycubic Kobra 3 Max V2 0.6 nozzle", + "sub_path": "process/0.36mm Standard @Anycubic Kobra 3 Max V2 0.6 nozzle.json" + }, + { + "name": "0.42mm Standard @Anycubic Kobra 3 Max V2 0.6 nozzle", + "sub_path": "process/0.42mm Standard @Anycubic Kobra 3 Max V2 0.6 nozzle.json" + }, + { + "name": "0.20mm Standard @Anycubic Kobra 3 Max V2 0.8 nozzle", + "sub_path": "process/0.20mm Standard @Anycubic Kobra 3 Max V2 0.8 nozzle.json" + }, + { + "name": "0.24mm Standard @Anycubic Kobra 3 Max V2 0.8 nozzle", + "sub_path": "process/0.24mm Standard @Anycubic Kobra 3 Max V2 0.8 nozzle.json" + }, + { + "name": "0.32mm Standard @Anycubic Kobra 3 Max V2 0.8 nozzle", + "sub_path": "process/0.32mm Standard @Anycubic Kobra 3 Max V2 0.8 nozzle.json" + }, + { + "name": "0.40mm Standard @Anycubic Kobra 3 Max V2 0.8 nozzle", + "sub_path": "process/0.40mm Standard @Anycubic Kobra 3 Max V2 0.8 nozzle.json" + }, + { + "name": "0.48mm Standard @Anycubic Kobra 3 Max V2 0.8 nozzle", + "sub_path": "process/0.48mm Standard @Anycubic Kobra 3 Max V2 0.8 nozzle.json" + }, + { + "name": "0.56mm Standard @Anycubic Kobra 3 Max V2 0.8 nozzle", + "sub_path": "process/0.56mm Standard @Anycubic Kobra 3 Max V2 0.8 nozzle.json" } ], "filament_list": [ @@ -596,6 +708,10 @@ "name": "Anycubic ABS @Anycubic Kobra 3 Max 0.8 nozzle", "sub_path": "filament/Anycubic ABS @Anycubic Kobra 3 Max 0.8 nozzle.json" }, + { + "name": "Anycubic ABS @Anycubic Kobra 3 Max V2 0.4 nozzle", + "sub_path": "filament/Anycubic ABS @Anycubic Kobra 3 Max V2 0.4 nozzle.json" + }, { "name": "Anycubic ABS @Anycubic Kobra 3 V2 0.4 nozzle", "sub_path": "filament/Anycubic ABS @Anycubic Kobra 3 V2 0.4 nozzle.json" @@ -636,6 +752,10 @@ "name": "Anycubic ASA @Anycubic Kobra 3 Max 0.8 nozzle", "sub_path": "filament/Anycubic ASA @Anycubic Kobra 3 Max 0.8 nozzle.json" }, + { + "name": "Anycubic ASA @Anycubic Kobra 3 Max V2 0.4 nozzle", + "sub_path": "filament/Anycubic ASA @Anycubic Kobra 3 Max V2 0.4 nozzle.json" + }, { "name": "Anycubic ASA @Anycubic Kobra 3 V2 0.4 nozzle", "sub_path": "filament/Anycubic ASA @Anycubic Kobra 3 V2 0.4 nozzle.json" @@ -780,6 +900,10 @@ "name": "Anycubic PETG @Anycubic Kobra 3 Max 0.8 nozzle", "sub_path": "filament/Anycubic PETG @Anycubic Kobra 3 Max 0.8 nozzle.json" }, + { + "name": "Anycubic PETG @Anycubic Kobra 3 Max V2 0.4 nozzle", + "sub_path": "filament/Anycubic PETG @Anycubic Kobra 3 Max V2 0.4 nozzle.json" + }, { "name": "Anycubic PETG @Anycubic Kobra 3 V2 0.4 nozzle", "sub_path": "filament/Anycubic PETG @Anycubic Kobra 3 V2 0.4 nozzle.json" @@ -848,6 +972,10 @@ "name": "Anycubic PLA @Anycubic Kobra 3 Max 0.8 nozzle", "sub_path": "filament/Anycubic PLA @Anycubic Kobra 3 Max 0.8 nozzle.json" }, + { + "name": "Anycubic PLA @Anycubic Kobra 3 Max V2 0.4 nozzle", + "sub_path": "filament/Anycubic PLA @Anycubic Kobra 3 Max V2 0.4 nozzle.json" + }, { "name": "Anycubic PLA @Anycubic Kobra 3 V2 0.2 nozzle", "sub_path": "filament/Anycubic PLA @Anycubic Kobra 3 V2 0.2 nozzle.json" @@ -900,6 +1028,10 @@ "name": "Anycubic PLA Galaxy @Anycubic Kobra 3 V2 0.8 nozzle", "sub_path": "filament/Anycubic PLA Galaxy @Anycubic Kobra 3 V2 0.8 nozzle.json" }, + { + "name": "Anycubic PLA Glow @Anycubic Kobra 3 Max V2 0.4 nozzle", + "sub_path": "filament/Anycubic PLA Glow @Anycubic Kobra 3 Max V2 0.4 nozzle.json" + }, { "name": "Anycubic PLA Glow @Anycubic Kobra 3 V2 0.4 nozzle", "sub_path": "filament/Anycubic PLA Glow @Anycubic Kobra 3 V2 0.4 nozzle.json" @@ -912,6 +1044,10 @@ "name": "Anycubic PLA High Speed @Anycubic Kobra 3 Max 0.4 nozzle", "sub_path": "filament/Anycubic PLA High Speed @Anycubic Kobra 3 Max 0.4 nozzle.json" }, + { + "name": "Anycubic PLA High Speed @Anycubic Kobra 3 Max V2 0.4 nozzle", + "sub_path": "filament/Anycubic PLA High Speed @Anycubic Kobra 3 Max V2 0.4 nozzle.json" + }, { "name": "Anycubic PLA High Speed @Anycubic Kobra 3 V2 0.4 nozzle", "sub_path": "filament/Anycubic PLA High Speed @Anycubic Kobra 3 V2 0.4 nozzle.json" @@ -956,6 +1092,10 @@ "name": "Anycubic PLA Matte @Anycubic Kobra 3 Max 0.4 nozzle", "sub_path": "filament/Anycubic PLA Matte @Anycubic Kobra 3 Max 0.4 nozzle.json" }, + { + "name": "Anycubic PLA Matte @Anycubic Kobra 3 Max V2 0.4 nozzle", + "sub_path": "filament/Anycubic PLA Matte @Anycubic Kobra 3 Max V2 0.4 nozzle.json" + }, { "name": "Anycubic PLA Matte @Anycubic Kobra 3 V2 0.4 nozzle", "sub_path": "filament/Anycubic PLA Matte @Anycubic Kobra 3 V2 0.4 nozzle.json" @@ -996,6 +1136,10 @@ "name": "Anycubic PLA Silk @Anycubic Kobra 3 Max 0.4 nozzle", "sub_path": "filament/Anycubic PLA Silk @Anycubic Kobra 3 Max 0.4 nozzle.json" }, + { + "name": "Anycubic PLA Silk @Anycubic Kobra 3 Max V2 0.4 nozzle", + "sub_path": "filament/Anycubic PLA Silk @Anycubic Kobra 3 Max V2 0.4 nozzle.json" + }, { "name": "Anycubic PLA Silk @Anycubic Kobra 3 V2 0.4 nozzle", "sub_path": "filament/Anycubic PLA Silk @Anycubic Kobra 3 V2 0.4 nozzle.json" @@ -1032,6 +1176,10 @@ "name": "Anycubic PLA+ @Anycubic Kobra 3 Max 0.4 nozzle", "sub_path": "filament/Anycubic PLA+ @Anycubic Kobra 3 Max 0.4 nozzle.json" }, + { + "name": "Anycubic PLA+ @Anycubic Kobra 3 Max V2 0.4 nozzle", + "sub_path": "filament/Anycubic PLA+ @Anycubic Kobra 3 Max V2 0.4 nozzle.json" + }, { "name": "Anycubic PLA+ @Anycubic Kobra S1 0.4 nozzle", "sub_path": "filament/Anycubic PLA+ @Anycubic Kobra S1 0.4 nozzle.json" @@ -1096,6 +1244,10 @@ "name": "Anycubic PEBA 95A @Anycubic Kobra 3 Max 0.4 nozzle", "sub_path": "filament/Anycubic PEBA 95A @Anycubic Kobra 3 Max 0.4 nozzle.json" }, + { + "name": "Anycubic PEBA 95A @Anycubic Kobra 3 Max V2 0.4 nozzle", + "sub_path": "filament/Anycubic PEBA 95A @Anycubic Kobra 3 Max V2 0.4 nozzle.json" + }, { "name": "Anycubic PEBA @Anycubic Kobra S1 Max 0.4 nozzle", "sub_path": "filament/Anycubic PEBA @Anycubic Kobra S1 Max 0.4 nozzle.json" @@ -1136,6 +1288,10 @@ "name": "Anycubic TPU @Anycubic Kobra 3 Max 0.8 nozzle", "sub_path": "filament/Anycubic TPU @Anycubic Kobra 3 Max 0.8 nozzle.json" }, + { + "name": "Anycubic TPU @Anycubic Kobra 3 Max V2 0.4 nozzle", + "sub_path": "filament/Anycubic TPU @Anycubic Kobra 3 Max V2 0.4 nozzle.json" + }, { "name": "Anycubic TPU @Anycubic Kobra 3 V2 0.4 nozzle", "sub_path": "filament/Anycubic TPU @Anycubic Kobra 3 V2 0.4 nozzle.json" @@ -1164,18 +1320,78 @@ "name": "Generic TPU @Anycubic", "sub_path": "filament/Generic TPU @Anycubic.json" }, + { + "name": "Anycubic ABS @Anycubic Kobra 3 Max V2 0.25 nozzle", + "sub_path": "filament/Anycubic ABS @Anycubic Kobra 3 Max V2 0.25 nozzle.json" + }, + { + "name": "Anycubic ABS @Anycubic Kobra 3 Max V2 0.6 nozzle", + "sub_path": "filament/Anycubic ABS @Anycubic Kobra 3 Max V2 0.6 nozzle.json" + }, + { + "name": "Anycubic ABS @Anycubic Kobra 3 Max V2 0.8 nozzle", + "sub_path": "filament/Anycubic ABS @Anycubic Kobra 3 Max V2 0.8 nozzle.json" + }, + { + "name": "Generic ABS @Anycubic Kobra 3 Max V2 0.4 nozzle", + "sub_path": "filament/Generic ABS @Anycubic Kobra 3 Max V2 0.4 nozzle.json" + }, { "name": "Generic ABS @Anycubic Kobra 3 0.4 nozzle", "sub_path": "filament/Generic ABS @Anycubic Kobra 3 0.4 nozzle.json" }, + { + "name": "Anycubic ASA @Anycubic Kobra 3 Max V2 0.25 nozzle", + "sub_path": "filament/Anycubic ASA @Anycubic Kobra 3 Max V2 0.25 nozzle.json" + }, + { + "name": "Anycubic ASA @Anycubic Kobra 3 Max V2 0.6 nozzle", + "sub_path": "filament/Anycubic ASA @Anycubic Kobra 3 Max V2 0.6 nozzle.json" + }, + { + "name": "Anycubic ASA @Anycubic Kobra 3 Max V2 0.8 nozzle", + "sub_path": "filament/Anycubic ASA @Anycubic Kobra 3 Max V2 0.8 nozzle.json" + }, { "name": "Anycubic ASA @Anycubic Kobra 3 0.4 nozzle", "sub_path": "filament/Anycubic ASA @Anycubic Kobra 3 0.4 nozzle.json" }, + { + "name": "Anycubic PETG @Anycubic Kobra 3 Max V2 0.25 nozzle", + "sub_path": "filament/Anycubic PETG @Anycubic Kobra 3 Max V2 0.25 nozzle.json" + }, + { + "name": "Anycubic PETG @Anycubic Kobra 3 Max V2 0.6 nozzle", + "sub_path": "filament/Anycubic PETG @Anycubic Kobra 3 Max V2 0.6 nozzle.json" + }, + { + "name": "Anycubic PETG @Anycubic Kobra 3 Max V2 0.8 nozzle", + "sub_path": "filament/Anycubic PETG @Anycubic Kobra 3 Max V2 0.8 nozzle.json" + }, + { + "name": "Generic PETG @Anycubic Kobra 3 Max V2 0.4 nozzle", + "sub_path": "filament/Generic PETG @Anycubic Kobra 3 Max V2 0.4 nozzle.json" + }, { "name": "Anycubic PETG @Anycubic Kobra 3 0.4 nozzle", "sub_path": "filament/Anycubic PETG @Anycubic Kobra 3 0.4 nozzle.json" }, + { + "name": "Anycubic PLA @Anycubic Kobra 3 Max V2 0.25 nozzle", + "sub_path": "filament/Anycubic PLA @Anycubic Kobra 3 Max V2 0.25 nozzle.json" + }, + { + "name": "Anycubic PLA @Anycubic Kobra 3 Max V2 0.6 nozzle", + "sub_path": "filament/Anycubic PLA @Anycubic Kobra 3 Max V2 0.6 nozzle.json" + }, + { + "name": "Anycubic PLA @Anycubic Kobra 3 Max V2 0.8 nozzle", + "sub_path": "filament/Anycubic PLA @Anycubic Kobra 3 Max V2 0.8 nozzle.json" + }, + { + "name": "Generic PLA @Anycubic Kobra 3 Max V2 0.4 nozzle", + "sub_path": "filament/Generic PLA @Anycubic Kobra 3 Max V2 0.4 nozzle.json" + }, { "name": "Anycubic PETG @Anycubic Kobra 3 V2 0.6 nozzle", "sub_path": "filament/Anycubic PETG @Anycubic Kobra 3 V2 0.6 nozzle.json" @@ -1192,6 +1408,50 @@ "name": "Anycubic PLA Silk @Anycubic Kobra 3 V2 0.8 nozzle", "sub_path": "filament/Anycubic PLA Silk @Anycubic Kobra 3 V2 0.8 nozzle.json" }, + { + "name": "Anycubic PLA Glow @Anycubic Kobra 3 Max V2 0.6 nozzle", + "sub_path": "filament/Anycubic PLA Glow @Anycubic Kobra 3 Max V2 0.6 nozzle.json" + }, + { + "name": "Anycubic PLA Glow @Anycubic Kobra 3 Max V2 0.8 nozzle", + "sub_path": "filament/Anycubic PLA Glow @Anycubic Kobra 3 Max V2 0.8 nozzle.json" + }, + { + "name": "Anycubic PLA High Speed @Anycubic Kobra 3 Max V2 0.6 nozzle", + "sub_path": "filament/Anycubic PLA High Speed @Anycubic Kobra 3 Max V2 0.6 nozzle.json" + }, + { + "name": "Anycubic PLA High Speed @Anycubic Kobra 3 Max V2 0.8 nozzle", + "sub_path": "filament/Anycubic PLA High Speed @Anycubic Kobra 3 Max V2 0.8 nozzle.json" + }, + { + "name": "Anycubic PLA Matte @Anycubic Kobra 3 Max V2 0.6 nozzle", + "sub_path": "filament/Anycubic PLA Matte @Anycubic Kobra 3 Max V2 0.6 nozzle.json" + }, + { + "name": "Anycubic PLA Matte @Anycubic Kobra 3 Max V2 0.8 nozzle", + "sub_path": "filament/Anycubic PLA Matte @Anycubic Kobra 3 Max V2 0.8 nozzle.json" + }, + { + "name": "Anycubic PLA Silk @Anycubic Kobra 3 Max V2 0.6 nozzle", + "sub_path": "filament/Anycubic PLA Silk @Anycubic Kobra 3 Max V2 0.6 nozzle.json" + }, + { + "name": "Anycubic PLA Silk @Anycubic Kobra 3 Max V2 0.8 nozzle", + "sub_path": "filament/Anycubic PLA Silk @Anycubic Kobra 3 Max V2 0.8 nozzle.json" + }, + { + "name": "Generic PLA Silk @Anycubic Kobra 3 Max V2 0.4 nozzle", + "sub_path": "filament/Generic PLA Silk @Anycubic Kobra 3 Max V2 0.4 nozzle.json" + }, + { + "name": "Anycubic PLA+ @Anycubic Kobra 3 Max V2 0.6 nozzle", + "sub_path": "filament/Anycubic PLA+ @Anycubic Kobra 3 Max V2 0.6 nozzle.json" + }, + { + "name": "Anycubic PLA+ @Anycubic Kobra 3 Max V2 0.8 nozzle", + "sub_path": "filament/Anycubic PLA+ @Anycubic Kobra 3 Max V2 0.8 nozzle.json" + }, { "name": "Anycubic PLA @Anycubic Kobra 2 Max 0.4 nozzle", "sub_path": "filament/Anycubic PLA @Anycubic Kobra 2 Max 0.4 nozzle.json" @@ -1276,6 +1536,18 @@ "name": "Anycubic PLA-CF @Anycubic Kobra S1 Max 0.8 nozzle", "sub_path": "filament/Anycubic PLA-CF @Anycubic Kobra S1 Max 0.8 nozzle.json" }, + { + "name": "Anycubic TPU @Anycubic Kobra 3 Max V2 0.6 nozzle", + "sub_path": "filament/Anycubic TPU @Anycubic Kobra 3 Max V2 0.6 nozzle.json" + }, + { + "name": "Anycubic TPU @Anycubic Kobra 3 Max V2 0.8 nozzle", + "sub_path": "filament/Anycubic TPU @Anycubic Kobra 3 Max V2 0.8 nozzle.json" + }, + { + "name": "Generic TPU @Anycubic Kobra 3 Max V2 0.4 nozzle", + "sub_path": "filament/Generic TPU @Anycubic Kobra 3 Max V2 0.4 nozzle.json" + }, { "name": "Generic TPU @Anycubic Kobra 3 0.4 nozzle", "sub_path": "filament/Generic TPU @Anycubic Kobra 3 0.4 nozzle.json" @@ -1413,6 +1685,26 @@ { "name": "Anycubic i3 Mega S 0.4 nozzle", "sub_path": "machine/Anycubic i3 Mega S 0.4 nozzle.json" + }, + { + "name": "fdm_anycubic_kobra_3_max_v2_common", + "sub_path": "machine/fdm_anycubic_kobra_3_max_v2_common.json" + }, + { + "name": "Anycubic Kobra 3 Max V2 0.25 nozzle", + "sub_path": "machine/Anycubic Kobra 3 Max V2 0.25 nozzle.json" + }, + { + "name": "Anycubic Kobra 3 Max V2 0.4 nozzle", + "sub_path": "machine/Anycubic Kobra 3 Max V2 0.4 nozzle.json" + }, + { + "name": "Anycubic Kobra 3 Max V2 0.6 nozzle", + "sub_path": "machine/Anycubic Kobra 3 Max V2 0.6 nozzle.json" + }, + { + "name": "Anycubic Kobra 3 Max V2 0.8 nozzle", + "sub_path": "machine/Anycubic Kobra 3 Max V2 0.8 nozzle.json" } ] } diff --git a/resources/profiles/Anycubic/Anycubic Kobra 3 Max V2_cover.png b/resources/profiles/Anycubic/Anycubic Kobra 3 Max V2_cover.png new file mode 100644 index 0000000000..9c0cc00918 Binary files /dev/null and b/resources/profiles/Anycubic/Anycubic Kobra 3 Max V2_cover.png differ diff --git a/resources/profiles/Anycubic/Anycubic Kobra 3 Max_buildplate_texture.svg b/resources/profiles/Anycubic/Anycubic Kobra 3 Max_buildplate_texture.svg index a1a1285c57..3e0bf3a8dc 100644 --- a/resources/profiles/Anycubic/Anycubic Kobra 3 Max_buildplate_texture.svg +++ b/resources/profiles/Anycubic/Anycubic Kobra 3 Max_buildplate_texture.svg @@ -1,23 +1,8 @@ - - - - - - - - - - - - - - - - - - - - - + + + + + + diff --git a/resources/profiles/Anycubic/filament/Anycubic ABS @Anycubic Kobra 3 Max V2 0.25 nozzle.json b/resources/profiles/Anycubic/filament/Anycubic ABS @Anycubic Kobra 3 Max V2 0.25 nozzle.json new file mode 100644 index 0000000000..91d126f4f4 --- /dev/null +++ b/resources/profiles/Anycubic/filament/Anycubic ABS @Anycubic Kobra 3 Max V2 0.25 nozzle.json @@ -0,0 +1,39 @@ +{ + "type": "filament", + "name": "Anycubic ABS @Anycubic Kobra 3 Max V2 0.25 nozzle", + "inherits": "Anycubic ABS @Anycubic Kobra 3 Max V2 0.4 nozzle", + "from": "system", + "setting_id": "cT93s5AV0CWH0vvn", + "filament_id": "OF223rZv", + "instantiation": "true", + "filament_max_volumetric_speed": [ + "2" + ], + "cool_plate_temp": [ + "0" + ], + "cool_plate_temp_initial_layer": [ + "0" + ], + "filament_flush_temp": [ + "nil" + ], + "filament_flush_volumetric_speed": [ + "nil" + ], + "hot_plate_temp": [ + "100" + ], + "hot_plate_temp_initial_layer": [ + "100" + ], + "textured_plate_temp": [ + "100" + ], + "textured_plate_temp_initial_layer": [ + "100" + ], + "compatible_printers": [ + "Anycubic Kobra 3 Max V2 0.25 nozzle" + ] +} diff --git a/resources/profiles/Anycubic/filament/Anycubic ABS @Anycubic Kobra 3 Max V2 0.4 nozzle.json b/resources/profiles/Anycubic/filament/Anycubic ABS @Anycubic Kobra 3 Max V2 0.4 nozzle.json new file mode 100644 index 0000000000..01fbc2f333 --- /dev/null +++ b/resources/profiles/Anycubic/filament/Anycubic ABS @Anycubic Kobra 3 Max V2 0.4 nozzle.json @@ -0,0 +1,141 @@ +{ + "type": "filament", + "name": "Anycubic ABS @Anycubic Kobra 3 Max V2 0.4 nozzle", + "inherits": "fdm_filament_abs", + "from": "system", + "setting_id": "LuWN1dGaxVTOpo0a", + "filament_id": "OF223rZv", + "instantiation": "true", + "fan_min_speed": [ + "1" + ], + "filament_vendor": [ + "Anycubic" + ], + "filament_flow_ratio": [ + "0.98" + ], + "filament_max_volumetric_speed": [ + "5" + ], + "close_fan_the_first_x_layers": [ + "5" + ], + "cool_plate_temp": [ + "35" + ], + "cool_plate_temp_initial_layer": [ + "35" + ], + "enable_pressure_advance": [ + "1" + ], + "eng_plate_temp": [ + "45" + ], + "eng_plate_temp_initial_layer": [ + "45" + ], + "fan_cooling_layer_time": [ + "20" + ], + "fan_max_speed": [ + "15" + ], + "filament_density": [ + "1.05" + ], + "filament_deretraction_speed": [ + "0" + ], + "filament_end_gcode": [ + "; filament end gcode" + ], + "filament_long_retractions_when_cut": [ + "nil" + ], + "filament_minimal_purge_on_wipe_tower": [ + "41" + ], + "filament_retract_before_wipe": [ + "0%" + ], + "filament_retract_lift_above": [ + "0.3" + ], + "filament_retract_lift_below": [ + "499" + ], + "filament_retract_lift_enforce": [ + "All Surfaces" + ], + "filament_retract_restart_extra": [ + "0" + ], + "filament_retract_when_changing_layer": [ + "1" + ], + "filament_retraction_distances_when_cut": [ + "nil" + ], + "filament_retraction_length": [ + "0.8" + ], + "filament_retraction_minimum_travel": [ + "1" + ], + "filament_retraction_speed": [ + "30" + ], + "filament_start_gcode": [ + "; filament start gcode" + ], + "filament_wipe": [ + "1" + ], + "filament_wipe_distance": [ + "1" + ], + "filament_z_hop": [ + "0.4" + ], + "filament_z_hop_types": [ + "Slope Lift" + ], + "full_fan_speed_layer": [ + "100" + ], + "hot_plate_temp": [ + "95" + ], + "hot_plate_temp_initial_layer": [ + "95" + ], + "nozzle_temperature": [ + "250" + ], + "nozzle_temperature_range_low": [ + "230" + ], + "pressure_advance": [ + "0.03" + ], + "slow_down_layer_time": [ + "16" + ], + "slow_down_min_speed": [ + "20" + ], + "temperature_vitrification": [ + "60" + ], + "textured_plate_temp": [ + "95" + ], + "textured_plate_temp_initial_layer": [ + "95" + ], + "compatible_printers": [ + "Anycubic Kobra 3 Max V2 0.4 nozzle" + ] +} diff --git a/resources/profiles/Anycubic/filament/Anycubic ABS @Anycubic Kobra 3 Max V2 0.6 nozzle.json b/resources/profiles/Anycubic/filament/Anycubic ABS @Anycubic Kobra 3 Max V2 0.6 nozzle.json new file mode 100644 index 0000000000..9d3528d546 --- /dev/null +++ b/resources/profiles/Anycubic/filament/Anycubic ABS @Anycubic Kobra 3 Max V2 0.6 nozzle.json @@ -0,0 +1,120 @@ +{ + "type": "filament", + "name": "Anycubic ABS @Anycubic Kobra 3 Max V2 0.6 nozzle", + "inherits": "Anycubic ABS @Anycubic Kobra 3 Max V2 0.4 nozzle", + "from": "system", + "setting_id": "5VahPpqYLS5YwvcU", + "filament_id": "OF223rZv", + "instantiation": "true", + "filament_flow_ratio": [ + "0.95" + ], + "filament_max_volumetric_speed": [ + "15" + ], + "close_fan_the_first_x_layers": [ + "1" + ], + "cool_plate_temp": [ + "0" + ], + "cool_plate_temp_initial_layer": [ + "0" + ], + "filament_cooling_final_speed": [ + "0" + ], + "filament_cooling_initial_speed": [ + "0" + ], + "filament_cooling_moves": [ + "0" + ], + "filament_density": [ + "1.24" + ], + "filament_deretraction_speed": [ + "nil" + ], + "filament_loading_speed": [ + "0" + ], + "filament_loading_speed_start": [ + "0" + ], + "filament_minimal_purge_on_wipe_tower": [ + "0" + ], + "filament_retract_before_wipe": [ + "nil" + ], + "filament_retract_lift_above": [ + "nil" + ], + "filament_retract_lift_below": [ + "nil" + ], + "filament_retract_lift_enforce": [ + "nil" + ], + "filament_retract_restart_extra": [ + "nil" + ], + "filament_retract_when_changing_layer": [ + "nil" + ], + "filament_retraction_length": [ + "nil" + ], + "filament_retraction_minimum_travel": [ + "nil" + ], + "filament_retraction_speed": [ + "nil" + ], + "filament_unloading_speed": [ + "0" + ], + "filament_unloading_speed_start": [ + "0" + ], + "filament_wipe": [ + "nil" + ], + "filament_wipe_distance": [ + "nil" + ], + "filament_z_hop": [ + "nil" + ], + "filament_z_hop_types": [ + "nil" + ], + "full_fan_speed_layer": [ + "0" + ], + "hot_plate_temp": [ + "100" + ], + "hot_plate_temp_initial_layer": [ + "100" + ], + "nozzle_temperature_range_high": [ + "280" + ], + "nozzle_temperature_range_low": [ + "240" + ], + "overhang_fan_speed": [ + "100" + ], + "textured_plate_temp": [ + "100" + ], + "textured_plate_temp_initial_layer": [ + "100" + ], + "compatible_printers": [ + "Anycubic Kobra 3 Max V2 0.6 nozzle" + ] +} diff --git a/resources/profiles/Anycubic/filament/Anycubic ABS @Anycubic Kobra 3 Max V2 0.8 nozzle.json b/resources/profiles/Anycubic/filament/Anycubic ABS @Anycubic Kobra 3 Max V2 0.8 nozzle.json new file mode 100644 index 0000000000..d353a399c8 --- /dev/null +++ b/resources/profiles/Anycubic/filament/Anycubic ABS @Anycubic Kobra 3 Max V2 0.8 nozzle.json @@ -0,0 +1,99 @@ +{ + "type": "filament", + "name": "Anycubic ABS @Anycubic Kobra 3 Max V2 0.8 nozzle", + "inherits": "Anycubic ABS @Anycubic Kobra 3 Max V2 0.4 nozzle", + "from": "system", + "setting_id": "WjlPY49zlt2N1RaN", + "filament_id": "OF223rZv", + "instantiation": "true", + "filament_flow_ratio": [ + "0.95" + ], + "filament_max_volumetric_speed": [ + "15" + ], + "close_fan_the_first_x_layers": [ + "1" + ], + "cool_plate_temp": [ + "0" + ], + "cool_plate_temp_initial_layer": [ + "0" + ], + "fan_max_speed": [ + "30" + ], + "filament_density": [ + "1.24" + ], + "filament_deretraction_speed": [ + "nil" + ], + "filament_retract_before_wipe": [ + "nil" + ], + "filament_retract_lift_above": [ + "nil" + ], + "filament_retract_lift_below": [ + "nil" + ], + "filament_retract_lift_enforce": [ + "nil" + ], + "filament_retract_restart_extra": [ + "nil" + ], + "filament_retract_when_changing_layer": [ + "nil" + ], + "filament_retraction_length": [ + "nil" + ], + "filament_retraction_minimum_travel": [ + "nil" + ], + "filament_retraction_speed": [ + "nil" + ], + "filament_wipe": [ + "nil" + ], + "filament_wipe_distance": [ + "nil" + ], + "filament_z_hop": [ + "nil" + ], + "filament_z_hop_types": [ + "nil" + ], + "full_fan_speed_layer": [ + "0" + ], + "hot_plate_temp": [ + "100" + ], + "hot_plate_temp_initial_layer": [ + "100" + ], + "nozzle_temperature_initial_layer": [ + "250" + ], + "nozzle_temperature_range_high": [ + "280" + ], + "nozzle_temperature_range_low": [ + "240" + ], + "textured_plate_temp": [ + "100" + ], + "textured_plate_temp_initial_layer": [ + "100" + ], + "compatible_printers": [ + "Anycubic Kobra 3 Max V2 0.8 nozzle" + ] +} diff --git a/resources/profiles/Anycubic/filament/Anycubic ASA @Anycubic Kobra 3 Max V2 0.25 nozzle.json b/resources/profiles/Anycubic/filament/Anycubic ASA @Anycubic Kobra 3 Max V2 0.25 nozzle.json new file mode 100644 index 0000000000..4501ba8ff6 --- /dev/null +++ b/resources/profiles/Anycubic/filament/Anycubic ASA @Anycubic Kobra 3 Max V2 0.25 nozzle.json @@ -0,0 +1,39 @@ +{ + "type": "filament", + "name": "Anycubic ASA @Anycubic Kobra 3 Max V2 0.25 nozzle", + "inherits": "Anycubic ASA @Anycubic Kobra 3 Max V2 0.4 nozzle", + "from": "system", + "setting_id": "0jsqGTQLJLkfskLu", + "filament_id": "OF0yFLkY", + "instantiation": "true", + "filament_max_volumetric_speed": [ + "2" + ], + "cool_plate_temp": [ + "0" + ], + "cool_plate_temp_initial_layer": [ + "0" + ], + "filament_flush_temp": [ + "nil" + ], + "filament_flush_volumetric_speed": [ + "nil" + ], + "hot_plate_temp": [ + "100" + ], + "hot_plate_temp_initial_layer": [ + "100" + ], + "textured_plate_temp": [ + "100" + ], + "textured_plate_temp_initial_layer": [ + "100" + ], + "compatible_printers": [ + "Anycubic Kobra 3 Max V2 0.25 nozzle" + ] +} diff --git a/resources/profiles/Anycubic/filament/Anycubic ASA @Anycubic Kobra 3 Max V2 0.4 nozzle.json b/resources/profiles/Anycubic/filament/Anycubic ASA @Anycubic Kobra 3 Max V2 0.4 nozzle.json new file mode 100644 index 0000000000..1a6183d449 --- /dev/null +++ b/resources/profiles/Anycubic/filament/Anycubic ASA @Anycubic Kobra 3 Max V2 0.4 nozzle.json @@ -0,0 +1,141 @@ +{ + "type": "filament", + "name": "Anycubic ASA @Anycubic Kobra 3 Max V2 0.4 nozzle", + "inherits": "fdm_filament_asa", + "from": "system", + "setting_id": "4404uvVbaWSULdPV", + "filament_id": "OF0yFLkY", + "instantiation": "true", + "fan_min_speed": [ + "1" + ], + "filament_vendor": [ + "Anycubic" + ], + "filament_flow_ratio": [ + "0.98" + ], + "filament_max_volumetric_speed": [ + "5" + ], + "close_fan_the_first_x_layers": [ + "5" + ], + "cool_plate_temp": [ + "35" + ], + "cool_plate_temp_initial_layer": [ + "35" + ], + "enable_pressure_advance": [ + "1" + ], + "eng_plate_temp": [ + "45" + ], + "eng_plate_temp_initial_layer": [ + "45" + ], + "fan_cooling_layer_time": [ + "20" + ], + "fan_max_speed": [ + "15" + ], + "filament_density": [ + "1.05" + ], + "filament_deretraction_speed": [ + "0" + ], + "filament_end_gcode": [ + "; filament end gcode" + ], + "filament_long_retractions_when_cut": [ + "nil" + ], + "filament_minimal_purge_on_wipe_tower": [ + "41" + ], + "filament_retract_before_wipe": [ + "0%" + ], + "filament_retract_lift_above": [ + "0.3" + ], + "filament_retract_lift_below": [ + "499" + ], + "filament_retract_lift_enforce": [ + "All Surfaces" + ], + "filament_retract_restart_extra": [ + "0" + ], + "filament_retract_when_changing_layer": [ + "1" + ], + "filament_retraction_distances_when_cut": [ + "nil" + ], + "filament_retraction_length": [ + "0.8" + ], + "filament_retraction_minimum_travel": [ + "1" + ], + "filament_retraction_speed": [ + "30" + ], + "filament_start_gcode": [ + "; filament start gcode" + ], + "filament_wipe": [ + "1" + ], + "filament_wipe_distance": [ + "1" + ], + "filament_z_hop": [ + "0.4" + ], + "filament_z_hop_types": [ + "Slope Lift" + ], + "full_fan_speed_layer": [ + "100" + ], + "hot_plate_temp": [ + "95" + ], + "hot_plate_temp_initial_layer": [ + "95" + ], + "nozzle_temperature": [ + "250" + ], + "nozzle_temperature_range_low": [ + "230" + ], + "pressure_advance": [ + "0.03" + ], + "slow_down_layer_time": [ + "16" + ], + "slow_down_min_speed": [ + "20" + ], + "temperature_vitrification": [ + "60" + ], + "textured_plate_temp": [ + "95" + ], + "textured_plate_temp_initial_layer": [ + "95" + ], + "compatible_printers": [ + "Anycubic Kobra 3 Max V2 0.4 nozzle" + ] +} diff --git a/resources/profiles/Anycubic/filament/Anycubic ASA @Anycubic Kobra 3 Max V2 0.6 nozzle.json b/resources/profiles/Anycubic/filament/Anycubic ASA @Anycubic Kobra 3 Max V2 0.6 nozzle.json new file mode 100644 index 0000000000..bd33334f4c --- /dev/null +++ b/resources/profiles/Anycubic/filament/Anycubic ASA @Anycubic Kobra 3 Max V2 0.6 nozzle.json @@ -0,0 +1,117 @@ +{ + "type": "filament", + "name": "Anycubic ASA @Anycubic Kobra 3 Max V2 0.6 nozzle", + "inherits": "Anycubic ASA @Anycubic Kobra 3 Max V2 0.4 nozzle", + "from": "system", + "setting_id": "XeTzbVQTCuElEAQV", + "filament_id": "OF0yFLkY", + "instantiation": "true", + "filament_flow_ratio": [ + "0.95" + ], + "filament_max_volumetric_speed": [ + "15" + ], + "close_fan_the_first_x_layers": [ + "1" + ], + "cool_plate_temp": [ + "0" + ], + "cool_plate_temp_initial_layer": [ + "0" + ], + "filament_cooling_final_speed": [ + "0" + ], + "filament_cooling_initial_speed": [ + "0" + ], + "filament_cooling_moves": [ + "0" + ], + "filament_density": [ + "1.24" + ], + "filament_deretraction_speed": [ + "nil" + ], + "filament_loading_speed": [ + "0" + ], + "filament_loading_speed_start": [ + "0" + ], + "filament_minimal_purge_on_wipe_tower": [ + "0" + ], + "filament_retract_before_wipe": [ + "nil" + ], + "filament_retract_lift_above": [ + "nil" + ], + "filament_retract_lift_below": [ + "nil" + ], + "filament_retract_lift_enforce": [ + "nil" + ], + "filament_retract_restart_extra": [ + "nil" + ], + "filament_retract_when_changing_layer": [ + "nil" + ], + "filament_retraction_length": [ + "1.4" + ], + "filament_retraction_minimum_travel": [ + "nil" + ], + "filament_retraction_speed": [ + "45" + ], + "filament_unloading_speed": [ + "0" + ], + "filament_unloading_speed_start": [ + "0" + ], + "filament_wipe": [ + "nil" + ], + "filament_wipe_distance": [ + "nil" + ], + "filament_z_hop": [ + "nil" + ], + "filament_z_hop_types": [ + "nil" + ], + "full_fan_speed_layer": [ + "0" + ], + "hot_plate_temp": [ + "100" + ], + "hot_plate_temp_initial_layer": [ + "100" + ], + "nozzle_temperature_range_high": [ + "280" + ], + "nozzle_temperature_range_low": [ + "240" + ], + "textured_plate_temp": [ + "100" + ], + "textured_plate_temp_initial_layer": [ + "100" + ], + "compatible_printers": [ + "Anycubic Kobra 3 Max V2 0.6 nozzle" + ] +} diff --git a/resources/profiles/Anycubic/filament/Anycubic ASA @Anycubic Kobra 3 Max V2 0.8 nozzle.json b/resources/profiles/Anycubic/filament/Anycubic ASA @Anycubic Kobra 3 Max V2 0.8 nozzle.json new file mode 100644 index 0000000000..7d04fa2c78 --- /dev/null +++ b/resources/profiles/Anycubic/filament/Anycubic ASA @Anycubic Kobra 3 Max V2 0.8 nozzle.json @@ -0,0 +1,99 @@ +{ + "type": "filament", + "name": "Anycubic ASA @Anycubic Kobra 3 Max V2 0.8 nozzle", + "inherits": "Anycubic ASA @Anycubic Kobra 3 Max V2 0.4 nozzle", + "from": "system", + "setting_id": "idVQgRzVM99sVPNN", + "filament_id": "OF0yFLkY", + "instantiation": "true", + "filament_flow_ratio": [ + "0.95" + ], + "filament_max_volumetric_speed": [ + "15" + ], + "close_fan_the_first_x_layers": [ + "1" + ], + "cool_plate_temp": [ + "0" + ], + "cool_plate_temp_initial_layer": [ + "0" + ], + "fan_max_speed": [ + "30" + ], + "filament_density": [ + "1.24" + ], + "filament_deretraction_speed": [ + "nil" + ], + "filament_retract_before_wipe": [ + "nil" + ], + "filament_retract_lift_above": [ + "nil" + ], + "filament_retract_lift_below": [ + "nil" + ], + "filament_retract_lift_enforce": [ + "nil" + ], + "filament_retract_restart_extra": [ + "nil" + ], + "filament_retract_when_changing_layer": [ + "nil" + ], + "filament_retraction_length": [ + "1.4" + ], + "filament_retraction_minimum_travel": [ + "nil" + ], + "filament_retraction_speed": [ + "45" + ], + "filament_wipe": [ + "nil" + ], + "filament_wipe_distance": [ + "nil" + ], + "filament_z_hop": [ + "nil" + ], + "filament_z_hop_types": [ + "nil" + ], + "full_fan_speed_layer": [ + "0" + ], + "hot_plate_temp": [ + "100" + ], + "hot_plate_temp_initial_layer": [ + "100" + ], + "nozzle_temperature_initial_layer": [ + "250" + ], + "nozzle_temperature_range_high": [ + "280" + ], + "nozzle_temperature_range_low": [ + "240" + ], + "textured_plate_temp": [ + "100" + ], + "textured_plate_temp_initial_layer": [ + "100" + ], + "compatible_printers": [ + "Anycubic Kobra 3 Max V2 0.8 nozzle" + ] +} diff --git a/resources/profiles/Anycubic/filament/Anycubic PEBA 95A @Anycubic Kobra 3 Max V2 0.4 nozzle.json b/resources/profiles/Anycubic/filament/Anycubic PEBA 95A @Anycubic Kobra 3 Max V2 0.4 nozzle.json new file mode 100644 index 0000000000..64ff123668 --- /dev/null +++ b/resources/profiles/Anycubic/filament/Anycubic PEBA 95A @Anycubic Kobra 3 Max V2 0.4 nozzle.json @@ -0,0 +1,129 @@ +{ + "type": "filament", + "name": "Anycubic PEBA 95A @Anycubic Kobra 3 Max V2 0.4 nozzle", + "inherits": "fdm_filament_tpu", + "from": "system", + "setting_id": "RZlFadfb4vk4Id9z", + "filament_id": "OFUaHEO9", + "instantiation": "true", + "filament_vendor": [ + "Anycubic" + ], + "filament_type": [ + "PEBA" + ], + "filament_max_volumetric_speed": [ + "5" + ], + "nozzle_temperature": [ + "230" + ], + "additional_cooling_fan_speed": [ + "0" + ], + "cool_plate_temp": [ + "35" + ], + "cool_plate_temp_initial_layer": [ + "35" + ], + "eng_plate_temp": [ + "45" + ], + "eng_plate_temp_initial_layer": [ + "45" + ], + "filament_density": [ + "1.08" + ], + "filament_deretraction_speed": [ + "8" + ], + "filament_end_gcode": [ + "; filament end gcode" + ], + "filament_long_retractions_when_cut": [ + "nil" + ], + "filament_minimal_purge_on_wipe_tower": [ + "41" + ], + "filament_retract_before_wipe": [ + "100%" + ], + "filament_retract_lift_above": [ + "0" + ], + "filament_retract_lift_below": [ + "499" + ], + "filament_retract_lift_enforce": [ + "All Surfaces" + ], + "filament_retract_restart_extra": [ + "0" + ], + "filament_retract_when_changing_layer": [ + "1" + ], + "filament_retraction_distances_when_cut": [ + "nil" + ], + "filament_retraction_length": [ + "1.6" + ], + "filament_retraction_minimum_travel": [ + "1" + ], + "filament_retraction_speed": [ + "30" + ], + "filament_start_gcode": [ + "; filament start gcode" + ], + "filament_wipe": [ + "1" + ], + "filament_wipe_distance": [ + "1" + ], + "filament_z_hop": [ + "0.4" + ], + "filament_z_hop_types": [ + "Slope Lift" + ], + "hot_plate_temp": [ + "60" + ], + "hot_plate_temp_initial_layer": [ + "60" + ], + "nozzle_temperature_initial_layer": [ + "230" + ], + "nozzle_temperature_range_high": [ + "230" + ], + "nozzle_temperature_range_low": [ + "190" + ], + "overhang_fan_threshold": [ + "50%" + ], + "pressure_advance": [ + "0" + ], + "slow_down_min_speed": [ + "20" + ], + "textured_plate_temp": [ + "65" + ], + "textured_plate_temp_initial_layer": [ + "65" + ], + "compatible_printers": [ + "Anycubic Kobra 3 Max V2 0.4 nozzle" + ] +} diff --git a/resources/profiles/Anycubic/filament/Anycubic PETG @Anycubic Kobra 3 Max V2 0.25 nozzle.json b/resources/profiles/Anycubic/filament/Anycubic PETG @Anycubic Kobra 3 Max V2 0.25 nozzle.json new file mode 100644 index 0000000000..894fd8e92a --- /dev/null +++ b/resources/profiles/Anycubic/filament/Anycubic PETG @Anycubic Kobra 3 Max V2 0.25 nozzle.json @@ -0,0 +1,27 @@ +{ + "type": "filament", + "name": "Anycubic PETG @Anycubic Kobra 3 Max V2 0.25 nozzle", + "inherits": "Anycubic PETG @Anycubic Kobra 3 Max V2 0.4 nozzle", + "from": "system", + "setting_id": "bCVYACr5SISq9yEh", + "filament_id": "OFo6n2pB", + "instantiation": "true", + "filament_max_volumetric_speed": [ + "2" + ], + "filament_flush_temp": [ + "nil" + ], + "filament_flush_volumetric_speed": [ + "nil" + ], + "supertack_plate_temp": [ + "35" + ], + "supertack_plate_temp_initial_layer": [ + "35" + ], + "compatible_printers": [ + "Anycubic Kobra 3 Max V2 0.25 nozzle" + ] +} diff --git a/resources/profiles/Anycubic/filament/Anycubic PETG @Anycubic Kobra 3 Max V2 0.4 nozzle.json b/resources/profiles/Anycubic/filament/Anycubic PETG @Anycubic Kobra 3 Max V2 0.4 nozzle.json new file mode 100644 index 0000000000..fded4034d4 --- /dev/null +++ b/resources/profiles/Anycubic/filament/Anycubic PETG @Anycubic Kobra 3 Max V2 0.4 nozzle.json @@ -0,0 +1,150 @@ +{ + "type": "filament", + "name": "Anycubic PETG @Anycubic Kobra 3 Max V2 0.4 nozzle", + "inherits": "fdm_filament_pet", + "from": "system", + "setting_id": "GYAym2WhB9k29s3a", + "filament_id": "OFo6n2pB", + "instantiation": "true", + "fan_max_speed": [ + "80" + ], + "filament_vendor": [ + "Anycubic" + ], + "filament_flow_ratio": [ + "0.95" + ], + "filament_max_volumetric_speed": [ + "8" + ], + "close_fan_the_first_x_layers": [ + "5" + ], + "cool_plate_temp": [ + "35" + ], + "cool_plate_temp_initial_layer": [ + "35" + ], + "enable_pressure_advance": [ + "1" + ], + "eng_plate_temp": [ + "45" + ], + "eng_plate_temp_initial_layer": [ + "45" + ], + "fan_min_speed": [ + "50" + ], + "filament_cost": [ + "20" + ], + "filament_density": [ + "1.3" + ], + "filament_deretraction_speed": [ + "0" + ], + "filament_end_gcode": [ + "; filament end gcode" + ], + "filament_long_retractions_when_cut": [ + "nil" + ], + "filament_minimal_purge_on_wipe_tower": [ + "41" + ], + "filament_retract_before_wipe": [ + "0%" + ], + "filament_retract_lift_above": [ + "0.3" + ], + "filament_retract_lift_below": [ + "499" + ], + "filament_retract_lift_enforce": [ + "All Surfaces" + ], + "filament_retract_restart_extra": [ + "0" + ], + "filament_retract_when_changing_layer": [ + "1" + ], + "filament_retraction_distances_when_cut": [ + "nil" + ], + "filament_retraction_length": [ + "0.8" + ], + "filament_retraction_minimum_travel": [ + "1" + ], + "filament_retraction_speed": [ + "30" + ], + "filament_start_gcode": [ + "; filament start gcode" + ], + "filament_wipe": [ + "1" + ], + "filament_wipe_distance": [ + "1" + ], + "filament_z_hop": [ + "0.4" + ], + "filament_z_hop_types": [ + "Slope Lift" + ], + "full_fan_speed_layer": [ + "6" + ], + "hot_plate_temp": [ + "75" + ], + "hot_plate_temp_initial_layer": [ + "75" + ], + "nozzle_temperature": [ + "225" + ], + "nozzle_temperature_initial_layer": [ + "235" + ], + "nozzle_temperature_range_high": [ + "270" + ], + "nozzle_temperature_range_low": [ + "215" + ], + "overhang_fan_threshold": [ + "10%" + ], + "pressure_advance": [ + "0.035" + ], + "slow_down_layer_time": [ + "10" + ], + "slow_down_min_speed": [ + "20" + ], + "temperature_vitrification": [ + "60" + ], + "textured_plate_temp": [ + "75" + ], + "textured_plate_temp_initial_layer": [ + "75" + ], + "compatible_printers": [ + "Anycubic Kobra 3 Max V2 0.4 nozzle" + ] +} diff --git a/resources/profiles/Anycubic/filament/Anycubic PETG @Anycubic Kobra 3 Max V2 0.6 nozzle.json b/resources/profiles/Anycubic/filament/Anycubic PETG @Anycubic Kobra 3 Max V2 0.6 nozzle.json new file mode 100644 index 0000000000..35daf6f1a2 --- /dev/null +++ b/resources/profiles/Anycubic/filament/Anycubic PETG @Anycubic Kobra 3 Max V2 0.6 nozzle.json @@ -0,0 +1,102 @@ +{ + "type": "filament", + "name": "Anycubic PETG @Anycubic Kobra 3 Max V2 0.6 nozzle", + "inherits": "Anycubic PETG @Anycubic Kobra 3 Max V2 0.4 nozzle", + "from": "system", + "setting_id": "wrKL77B508lb5Ad5", + "filament_id": "OFo6n2pB", + "instantiation": "true", + "filament_flow_ratio": [ + "0.96" + ], + "cool_plate_temp": [ + "70" + ], + "cool_plate_temp_initial_layer": [ + "70" + ], + "filament_cooling_final_speed": [ + "0" + ], + "filament_cooling_initial_speed": [ + "0" + ], + "filament_cooling_moves": [ + "0" + ], + "filament_density": [ + "1.24" + ], + "filament_deretraction_speed": [ + "nil" + ], + "filament_loading_speed": [ + "0" + ], + "filament_loading_speed_start": [ + "0" + ], + "filament_minimal_purge_on_wipe_tower": [ + "0" + ], + "filament_retract_before_wipe": [ + "nil" + ], + "filament_retract_lift_above": [ + "nil" + ], + "filament_retract_lift_below": [ + "nil" + ], + "filament_retract_lift_enforce": [ + "nil" + ], + "filament_retract_restart_extra": [ + "nil" + ], + "filament_retract_when_changing_layer": [ + "nil" + ], + "filament_retraction_length": [ + "1" + ], + "filament_retraction_minimum_travel": [ + "nil" + ], + "filament_retraction_speed": [ + "nil" + ], + "filament_unloading_speed": [ + "0" + ], + "filament_unloading_speed_start": [ + "0" + ], + "filament_wipe": [ + "nil" + ], + "filament_wipe_distance": [ + "nil" + ], + "filament_z_hop": [ + "nil" + ], + "filament_z_hop_types": [ + "nil" + ], + "nozzle_temperature_range_high": [ + "250" + ], + "nozzle_temperature_range_low": [ + "230" + ], + "overhang_fan_threshold": [ + "50%" + ], + "pressure_advance": [ + "0.036" + ], + "compatible_printers": [ + "Anycubic Kobra 3 Max V2 0.6 nozzle" + ] +} diff --git a/resources/profiles/Anycubic/filament/Anycubic PETG @Anycubic Kobra 3 Max V2 0.8 nozzle.json b/resources/profiles/Anycubic/filament/Anycubic PETG @Anycubic Kobra 3 Max V2 0.8 nozzle.json new file mode 100644 index 0000000000..1a893b1780 --- /dev/null +++ b/resources/profiles/Anycubic/filament/Anycubic PETG @Anycubic Kobra 3 Max V2 0.8 nozzle.json @@ -0,0 +1,78 @@ +{ + "type": "filament", + "name": "Anycubic PETG @Anycubic Kobra 3 Max V2 0.8 nozzle", + "inherits": "Anycubic PETG @Anycubic Kobra 3 Max V2 0.4 nozzle", + "from": "system", + "setting_id": "rzpwh8h7Mz7Lmsss", + "filament_id": "OFo6n2pB", + "instantiation": "true", + "filament_flow_ratio": [ + "0.96" + ], + "cool_plate_temp": [ + "70" + ], + "cool_plate_temp_initial_layer": [ + "70" + ], + "filament_density": [ + "1.24" + ], + "filament_deretraction_speed": [ + "nil" + ], + "filament_retract_before_wipe": [ + "nil" + ], + "filament_retract_lift_above": [ + "nil" + ], + "filament_retract_lift_below": [ + "nil" + ], + "filament_retract_lift_enforce": [ + "nil" + ], + "filament_retract_restart_extra": [ + "nil" + ], + "filament_retract_when_changing_layer": [ + "nil" + ], + "filament_retraction_length": [ + "nil" + ], + "filament_retraction_minimum_travel": [ + "nil" + ], + "filament_retraction_speed": [ + "nil" + ], + "filament_wipe": [ + "nil" + ], + "filament_wipe_distance": [ + "nil" + ], + "filament_z_hop": [ + "nil" + ], + "filament_z_hop_types": [ + "nil" + ], + "nozzle_temperature_range_high": [ + "250" + ], + "nozzle_temperature_range_low": [ + "230" + ], + "overhang_fan_threshold": [ + "50%" + ], + "pressure_advance": [ + "0.036" + ], + "compatible_printers": [ + "Anycubic Kobra 3 Max V2 0.8 nozzle" + ] +} diff --git a/resources/profiles/Anycubic/filament/Anycubic PLA @Anycubic Kobra 3 Max V2 0.25 nozzle.json b/resources/profiles/Anycubic/filament/Anycubic PLA @Anycubic Kobra 3 Max V2 0.25 nozzle.json new file mode 100644 index 0000000000..8c89eba9c4 --- /dev/null +++ b/resources/profiles/Anycubic/filament/Anycubic PLA @Anycubic Kobra 3 Max V2 0.25 nozzle.json @@ -0,0 +1,24 @@ +{ + "type": "filament", + "name": "Anycubic PLA @Anycubic Kobra 3 Max V2 0.25 nozzle", + "inherits": "Anycubic PLA @Anycubic Kobra 3 Max V2 0.4 nozzle", + "from": "system", + "setting_id": "AIkM2PqhzX7VVIPW", + "filament_id": "OFmjN2bc", + "instantiation": "true", + "filament_max_volumetric_speed": [ + "2" + ], + "filament_flush_temp": [ + "nil" + ], + "filament_flush_volumetric_speed": [ + "nil" + ], + "filament_retraction_length": [ + "0.8" + ], + "compatible_printers": [ + "Anycubic Kobra 3 Max V2 0.25 nozzle" + ] +} diff --git a/resources/profiles/Anycubic/filament/Anycubic PLA @Anycubic Kobra 3 Max V2 0.4 nozzle.json b/resources/profiles/Anycubic/filament/Anycubic PLA @Anycubic Kobra 3 Max V2 0.4 nozzle.json new file mode 100644 index 0000000000..06d663f485 --- /dev/null +++ b/resources/profiles/Anycubic/filament/Anycubic PLA @Anycubic Kobra 3 Max V2 0.4 nozzle.json @@ -0,0 +1,108 @@ +{ + "type": "filament", + "name": "Anycubic PLA @Anycubic Kobra 3 Max V2 0.4 nozzle", + "inherits": "fdm_filament_pla", + "from": "system", + "setting_id": "OJWR4GTyk5sIWytG", + "filament_id": "OFmjN2bc", + "instantiation": "true", + "filament_vendor": [ + "Anycubic" + ], + "filament_flow_ratio": [ + "0.96" + ], + "filament_max_volumetric_speed": [ + "13" + ], + "additional_cooling_fan_speed": [ + "0" + ], + "enable_pressure_advance": [ + "1" + ], + "eng_plate_temp": [ + "45" + ], + "eng_plate_temp_initial_layer": [ + "45" + ], + "filament_deretraction_speed": [ + "0" + ], + "filament_end_gcode": [ + "; filament end gcode" + ], + "filament_long_retractions_when_cut": [ + "nil" + ], + "filament_minimal_purge_on_wipe_tower": [ + "41" + ], + "filament_retract_lift_above": [ + "0.3" + ], + "filament_retract_lift_below": [ + "499" + ], + "filament_retract_lift_enforce": [ + "All Surfaces" + ], + "filament_retract_restart_extra": [ + "0" + ], + "filament_retract_when_changing_layer": [ + "1" + ], + "filament_retraction_distances_when_cut": [ + "nil" + ], + "filament_retraction_length": [ + "0.4" + ], + "filament_retraction_minimum_travel": [ + "1" + ], + "filament_retraction_speed": [ + "30" + ], + "filament_start_gcode": [ + "; filament start gcode" + ], + "filament_z_hop": [ + "0.4" + ], + "filament_z_hop_types": [ + "Slope Lift" + ], + "full_fan_speed_layer": [ + "3" + ], + "hot_plate_temp": [ + "65" + ], + "hot_plate_temp_initial_layer": [ + "65" + ], + "nozzle_temperature": [ + "210" + ], + "pressure_advance": [ + "0.03" + ], + "slow_down_layer_time": [ + "9" + ], + "slow_down_min_speed": [ + "20" + ], + "textured_plate_temp": [ + "65" + ], + "textured_plate_temp_initial_layer": [ + "65" + ], + "compatible_printers": [ + "Anycubic Kobra 3 Max V2 0.4 nozzle" + ] +} diff --git a/resources/profiles/Anycubic/filament/Anycubic PLA @Anycubic Kobra 3 Max V2 0.6 nozzle.json b/resources/profiles/Anycubic/filament/Anycubic PLA @Anycubic Kobra 3 Max V2 0.6 nozzle.json new file mode 100644 index 0000000000..e6180315e5 --- /dev/null +++ b/resources/profiles/Anycubic/filament/Anycubic PLA @Anycubic Kobra 3 Max V2 0.6 nozzle.json @@ -0,0 +1,84 @@ +{ + "type": "filament", + "name": "Anycubic PLA @Anycubic Kobra 3 Max V2 0.6 nozzle", + "inherits": "Anycubic PLA @Anycubic Kobra 3 Max V2 0.4 nozzle", + "from": "system", + "setting_id": "4FFYuYAqVILdx7fF", + "filament_id": "OFmjN2bc", + "instantiation": "true", + "filament_flow_ratio": [ + "0.95" + ], + "filament_max_volumetric_speed": [ + "8" + ], + "filament_cooling_final_speed": [ + "0" + ], + "filament_cooling_initial_speed": [ + "0" + ], + "filament_cooling_moves": [ + "0" + ], + "filament_deretraction_speed": [ + "nil" + ], + "filament_loading_speed": [ + "0" + ], + "filament_loading_speed_start": [ + "0" + ], + "filament_minimal_purge_on_wipe_tower": [ + "0" + ], + "filament_retract_lift_above": [ + "nil" + ], + "filament_retract_lift_below": [ + "nil" + ], + "filament_retract_lift_enforce": [ + "nil" + ], + "filament_retract_restart_extra": [ + "nil" + ], + "filament_retract_when_changing_layer": [ + "nil" + ], + "filament_retraction_length": [ + "nil" + ], + "filament_retraction_minimum_travel": [ + "nil" + ], + "filament_retraction_speed": [ + "nil" + ], + "filament_unloading_speed": [ + "0" + ], + "filament_unloading_speed_start": [ + "0" + ], + "filament_z_hop": [ + "nil" + ], + "filament_z_hop_types": [ + "nil" + ], + "full_fan_speed_layer": [ + "0" + ], + "nozzle_temperature": [ + "220" + ], + "pressure_advance": [ + "0.036" + ], + "compatible_printers": [ + "Anycubic Kobra 3 Max V2 0.6 nozzle" + ] +} diff --git a/resources/profiles/Anycubic/filament/Anycubic PLA @Anycubic Kobra 3 Max V2 0.8 nozzle.json b/resources/profiles/Anycubic/filament/Anycubic PLA @Anycubic Kobra 3 Max V2 0.8 nozzle.json new file mode 100644 index 0000000000..1835a5eda1 --- /dev/null +++ b/resources/profiles/Anycubic/filament/Anycubic PLA @Anycubic Kobra 3 Max V2 0.8 nozzle.json @@ -0,0 +1,57 @@ +{ + "type": "filament", + "name": "Anycubic PLA @Anycubic Kobra 3 Max V2 0.8 nozzle", + "inherits": "Anycubic PLA @Anycubic Kobra 3 Max V2 0.4 nozzle", + "from": "system", + "setting_id": "wURL4iRUB0yeN1Ay", + "filament_id": "OFmjN2bc", + "instantiation": "true", + "filament_max_volumetric_speed": [ + "12" + ], + "filament_deretraction_speed": [ + "nil" + ], + "filament_retract_lift_above": [ + "nil" + ], + "filament_retract_lift_below": [ + "nil" + ], + "filament_retract_lift_enforce": [ + "nil" + ], + "filament_retract_restart_extra": [ + "nil" + ], + "filament_retract_when_changing_layer": [ + "nil" + ], + "filament_retraction_length": [ + "nil" + ], + "filament_retraction_minimum_travel": [ + "nil" + ], + "filament_retraction_speed": [ + "nil" + ], + "filament_z_hop": [ + "nil" + ], + "filament_z_hop_types": [ + "nil" + ], + "full_fan_speed_layer": [ + "0" + ], + "nozzle_temperature": [ + "220" + ], + "pressure_advance": [ + "0.036" + ], + "compatible_printers": [ + "Anycubic Kobra 3 Max V2 0.8 nozzle" + ] +} diff --git a/resources/profiles/Anycubic/filament/Anycubic PLA Glow @Anycubic Kobra 3 Max V2 0.4 nozzle.json b/resources/profiles/Anycubic/filament/Anycubic PLA Glow @Anycubic Kobra 3 Max V2 0.4 nozzle.json new file mode 100644 index 0000000000..e49069c633 --- /dev/null +++ b/resources/profiles/Anycubic/filament/Anycubic PLA Glow @Anycubic Kobra 3 Max V2 0.4 nozzle.json @@ -0,0 +1,120 @@ +{ + "type": "filament", + "name": "Anycubic PLA Glow @Anycubic Kobra 3 Max V2 0.4 nozzle", + "inherits": "fdm_filament_pla", + "from": "system", + "setting_id": "yHdp6N0rUpH96Pqt", + "filament_id": "OF5PtjTp", + "instantiation": "true", + "filament_vendor": [ + "Anycubic" + ], + "filament_flow_ratio": [ + "0.95" + ], + "filament_max_volumetric_speed": [ + "13" + ], + "additional_cooling_fan_speed": [ + "0" + ], + "enable_pressure_advance": [ + "1" + ], + "eng_plate_temp": [ + "45" + ], + "eng_plate_temp_initial_layer": [ + "45" + ], + "filament_deretraction_speed": [ + "0" + ], + "filament_end_gcode": [ + "; filament end gcode" + ], + "filament_long_retractions_when_cut": [ + "nil" + ], + "filament_minimal_purge_on_wipe_tower": [ + "41" + ], + "filament_retract_before_wipe": [ + "0%" + ], + "filament_retract_lift_above": [ + "0.3" + ], + "filament_retract_lift_below": [ + "499" + ], + "filament_retract_lift_enforce": [ + "All Surfaces" + ], + "filament_retract_restart_extra": [ + "0" + ], + "filament_retract_when_changing_layer": [ + "1" + ], + "filament_retraction_distances_when_cut": [ + "nil" + ], + "filament_retraction_length": [ + "0.8" + ], + "filament_retraction_minimum_travel": [ + "1" + ], + "filament_retraction_speed": [ + "30" + ], + "filament_start_gcode": [ + "; filament start gcode" + ], + "filament_wipe": [ + "1" + ], + "filament_wipe_distance": [ + "1" + ], + "filament_z_hop": [ + "0.4" + ], + "filament_z_hop_types": [ + "Slope Lift" + ], + "full_fan_speed_layer": [ + "3" + ], + "hot_plate_temp": [ + "65" + ], + "hot_plate_temp_initial_layer": [ + "65" + ], + "nozzle_temperature": [ + "190" + ], + "nozzle_temperature_initial_layer": [ + "200" + ], + "pressure_advance": [ + "0.03" + ], + "slow_down_layer_time": [ + "9" + ], + "slow_down_min_speed": [ + "20" + ], + "textured_plate_temp": [ + "65" + ], + "textured_plate_temp_initial_layer": [ + "65" + ], + "compatible_printers": [ + "Anycubic Kobra 3 Max V2 0.4 nozzle" + ] +} diff --git a/resources/profiles/Anycubic/filament/Anycubic PLA Glow @Anycubic Kobra 3 Max V2 0.6 nozzle.json b/resources/profiles/Anycubic/filament/Anycubic PLA Glow @Anycubic Kobra 3 Max V2 0.6 nozzle.json new file mode 100644 index 0000000000..30b286cc47 --- /dev/null +++ b/resources/profiles/Anycubic/filament/Anycubic PLA Glow @Anycubic Kobra 3 Max V2 0.6 nozzle.json @@ -0,0 +1,93 @@ +{ + "type": "filament", + "name": "Anycubic PLA Glow @Anycubic Kobra 3 Max V2 0.6 nozzle", + "inherits": "Anycubic PLA Glow @Anycubic Kobra 3 Max V2 0.4 nozzle", + "from": "system", + "setting_id": "tMmwO6rO93QPHvvB", + "filament_id": "OF5PtjTp", + "instantiation": "true", + "filament_max_volumetric_speed": [ + "12" + ], + "filament_cooling_final_speed": [ + "0" + ], + "filament_cooling_initial_speed": [ + "0" + ], + "filament_cooling_moves": [ + "0" + ], + "filament_deretraction_speed": [ + "nil" + ], + "filament_loading_speed": [ + "0" + ], + "filament_loading_speed_start": [ + "0" + ], + "filament_minimal_purge_on_wipe_tower": [ + "0" + ], + "filament_retract_before_wipe": [ + "nil" + ], + "filament_retract_lift_above": [ + "nil" + ], + "filament_retract_lift_below": [ + "nil" + ], + "filament_retract_lift_enforce": [ + "nil" + ], + "filament_retract_restart_extra": [ + "nil" + ], + "filament_retract_when_changing_layer": [ + "nil" + ], + "filament_retraction_length": [ + "nil" + ], + "filament_retraction_minimum_travel": [ + "nil" + ], + "filament_retraction_speed": [ + "nil" + ], + "filament_unloading_speed": [ + "0" + ], + "filament_unloading_speed_start": [ + "0" + ], + "filament_wipe": [ + "nil" + ], + "filament_wipe_distance": [ + "nil" + ], + "filament_z_hop": [ + "nil" + ], + "filament_z_hop_types": [ + "nil" + ], + "full_fan_speed_layer": [ + "0" + ], + "nozzle_temperature": [ + "220" + ], + "nozzle_temperature_initial_layer": [ + "220" + ], + "pressure_advance": [ + "0.033" + ], + "compatible_printers": [ + "Anycubic Kobra 3 Max V2 0.6 nozzle" + ] +} diff --git a/resources/profiles/Anycubic/filament/Anycubic PLA Glow @Anycubic Kobra 3 Max V2 0.8 nozzle.json b/resources/profiles/Anycubic/filament/Anycubic PLA Glow @Anycubic Kobra 3 Max V2 0.8 nozzle.json new file mode 100644 index 0000000000..a205d8ca19 --- /dev/null +++ b/resources/profiles/Anycubic/filament/Anycubic PLA Glow @Anycubic Kobra 3 Max V2 0.8 nozzle.json @@ -0,0 +1,69 @@ +{ + "type": "filament", + "name": "Anycubic PLA Glow @Anycubic Kobra 3 Max V2 0.8 nozzle", + "inherits": "Anycubic PLA Glow @Anycubic Kobra 3 Max V2 0.4 nozzle", + "from": "system", + "setting_id": "8yv9WLDXGVfw0C7i", + "filament_id": "OF5PtjTp", + "instantiation": "true", + "filament_max_volumetric_speed": [ + "12" + ], + "filament_deretraction_speed": [ + "nil" + ], + "filament_retract_before_wipe": [ + "nil" + ], + "filament_retract_lift_above": [ + "nil" + ], + "filament_retract_lift_below": [ + "nil" + ], + "filament_retract_lift_enforce": [ + "nil" + ], + "filament_retract_restart_extra": [ + "nil" + ], + "filament_retract_when_changing_layer": [ + "nil" + ], + "filament_retraction_length": [ + "nil" + ], + "filament_retraction_minimum_travel": [ + "nil" + ], + "filament_retraction_speed": [ + "nil" + ], + "filament_wipe": [ + "nil" + ], + "filament_wipe_distance": [ + "nil" + ], + "filament_z_hop": [ + "nil" + ], + "filament_z_hop_types": [ + "nil" + ], + "full_fan_speed_layer": [ + "0" + ], + "nozzle_temperature": [ + "220" + ], + "nozzle_temperature_initial_layer": [ + "220" + ], + "pressure_advance": [ + "0.033" + ], + "compatible_printers": [ + "Anycubic Kobra 3 Max V2 0.8 nozzle" + ] +} diff --git a/resources/profiles/Anycubic/filament/Anycubic PLA High Speed @Anycubic Kobra 3 Max V2 0.4 nozzle.json b/resources/profiles/Anycubic/filament/Anycubic PLA High Speed @Anycubic Kobra 3 Max V2 0.4 nozzle.json new file mode 100644 index 0000000000..0cd5df8a33 --- /dev/null +++ b/resources/profiles/Anycubic/filament/Anycubic PLA High Speed @Anycubic Kobra 3 Max V2 0.4 nozzle.json @@ -0,0 +1,117 @@ +{ + "type": "filament", + "name": "Anycubic PLA High Speed @Anycubic Kobra 3 Max V2 0.4 nozzle", + "inherits": "fdm_filament_pla", + "from": "system", + "setting_id": "yVKrkpL8Llj63pcK", + "filament_id": "OFjVOWfJ", + "instantiation": "true", + "filament_vendor": [ + "Anycubic" + ], + "filament_flow_ratio": [ + "0.97" + ], + "filament_max_volumetric_speed": [ + "18" + ], + "additional_cooling_fan_speed": [ + "0" + ], + "enable_pressure_advance": [ + "1" + ], + "eng_plate_temp": [ + "45" + ], + "eng_plate_temp_initial_layer": [ + "45" + ], + "filament_deretraction_speed": [ + "0" + ], + "filament_end_gcode": [ + "; filament end gcode" + ], + "filament_long_retractions_when_cut": [ + "nil" + ], + "filament_minimal_purge_on_wipe_tower": [ + "41" + ], + "filament_retract_before_wipe": [ + "0%" + ], + "filament_retract_lift_above": [ + "0.3" + ], + "filament_retract_lift_below": [ + "499" + ], + "filament_retract_lift_enforce": [ + "All Surfaces" + ], + "filament_retract_restart_extra": [ + "0" + ], + "filament_retract_when_changing_layer": [ + "1" + ], + "filament_retraction_distances_when_cut": [ + "nil" + ], + "filament_retraction_length": [ + "0.8" + ], + "filament_retraction_minimum_travel": [ + "1" + ], + "filament_retraction_speed": [ + "30" + ], + "filament_start_gcode": [ + "; filament start gcode" + ], + "filament_wipe": [ + "1" + ], + "filament_wipe_distance": [ + "1" + ], + "filament_z_hop": [ + "0.4" + ], + "filament_z_hop_types": [ + "Slope Lift" + ], + "full_fan_speed_layer": [ + "3" + ], + "hot_plate_temp": [ + "65" + ], + "hot_plate_temp_initial_layer": [ + "65" + ], + "nozzle_temperature": [ + "205" + ], + "pressure_advance": [ + "0.026" + ], + "slow_down_layer_time": [ + "8" + ], + "slow_down_min_speed": [ + "20" + ], + "textured_plate_temp": [ + "65" + ], + "textured_plate_temp_initial_layer": [ + "65" + ], + "compatible_printers": [ + "Anycubic Kobra 3 Max V2 0.4 nozzle" + ] +} diff --git a/resources/profiles/Anycubic/filament/Anycubic PLA High Speed @Anycubic Kobra 3 Max V2 0.6 nozzle.json b/resources/profiles/Anycubic/filament/Anycubic PLA High Speed @Anycubic Kobra 3 Max V2 0.6 nozzle.json new file mode 100644 index 0000000000..b6582c3692 --- /dev/null +++ b/resources/profiles/Anycubic/filament/Anycubic PLA High Speed @Anycubic Kobra 3 Max V2 0.6 nozzle.json @@ -0,0 +1,93 @@ +{ + "type": "filament", + "name": "Anycubic PLA High Speed @Anycubic Kobra 3 Max V2 0.6 nozzle", + "inherits": "Anycubic PLA High Speed @Anycubic Kobra 3 Max V2 0.4 nozzle", + "from": "system", + "setting_id": "XMZjfbQq4AyroDpy", + "filament_id": "OFjVOWfJ", + "instantiation": "true", + "filament_flow_ratio": [ + "0.96" + ], + "filament_cooling_final_speed": [ + "0" + ], + "filament_cooling_initial_speed": [ + "0" + ], + "filament_cooling_moves": [ + "0" + ], + "filament_deretraction_speed": [ + "nil" + ], + "filament_loading_speed": [ + "0" + ], + "filament_loading_speed_start": [ + "0" + ], + "filament_minimal_purge_on_wipe_tower": [ + "0" + ], + "filament_retract_before_wipe": [ + "nil" + ], + "filament_retract_lift_above": [ + "nil" + ], + "filament_retract_lift_below": [ + "nil" + ], + "filament_retract_lift_enforce": [ + "nil" + ], + "filament_retract_restart_extra": [ + "nil" + ], + "filament_retract_when_changing_layer": [ + "nil" + ], + "filament_retraction_length": [ + "nil" + ], + "filament_retraction_minimum_travel": [ + "nil" + ], + "filament_retraction_speed": [ + "nil" + ], + "filament_unloading_speed": [ + "0" + ], + "filament_unloading_speed_start": [ + "0" + ], + "filament_wipe": [ + "nil" + ], + "filament_wipe_distance": [ + "nil" + ], + "filament_z_hop": [ + "nil" + ], + "filament_z_hop_types": [ + "nil" + ], + "full_fan_speed_layer": [ + "0" + ], + "nozzle_temperature": [ + "220" + ], + "pressure_advance": [ + "0.035" + ], + "slow_down_layer_time": [ + "9" + ], + "compatible_printers": [ + "Anycubic Kobra 3 Max V2 0.6 nozzle" + ] +} diff --git a/resources/profiles/Anycubic/filament/Anycubic PLA High Speed @Anycubic Kobra 3 Max V2 0.8 nozzle.json b/resources/profiles/Anycubic/filament/Anycubic PLA High Speed @Anycubic Kobra 3 Max V2 0.8 nozzle.json new file mode 100644 index 0000000000..db43a7a0ae --- /dev/null +++ b/resources/profiles/Anycubic/filament/Anycubic PLA High Speed @Anycubic Kobra 3 Max V2 0.8 nozzle.json @@ -0,0 +1,69 @@ +{ + "type": "filament", + "name": "Anycubic PLA High Speed @Anycubic Kobra 3 Max V2 0.8 nozzle", + "inherits": "Anycubic PLA High Speed @Anycubic Kobra 3 Max V2 0.4 nozzle", + "from": "system", + "setting_id": "aotegu1BjfHiLYqF", + "filament_id": "OFjVOWfJ", + "instantiation": "true", + "filament_flow_ratio": [ + "0.96" + ], + "filament_deretraction_speed": [ + "nil" + ], + "filament_retract_before_wipe": [ + "nil" + ], + "filament_retract_lift_above": [ + "nil" + ], + "filament_retract_lift_below": [ + "nil" + ], + "filament_retract_lift_enforce": [ + "nil" + ], + "filament_retract_restart_extra": [ + "nil" + ], + "filament_retract_when_changing_layer": [ + "nil" + ], + "filament_retraction_length": [ + "nil" + ], + "filament_retraction_minimum_travel": [ + "nil" + ], + "filament_retraction_speed": [ + "nil" + ], + "filament_wipe": [ + "nil" + ], + "filament_wipe_distance": [ + "nil" + ], + "filament_z_hop": [ + "nil" + ], + "filament_z_hop_types": [ + "nil" + ], + "full_fan_speed_layer": [ + "0" + ], + "nozzle_temperature": [ + "220" + ], + "pressure_advance": [ + "0.035" + ], + "slow_down_layer_time": [ + "9" + ], + "compatible_printers": [ + "Anycubic Kobra 3 Max V2 0.8 nozzle" + ] +} diff --git a/resources/profiles/Anycubic/filament/Anycubic PLA Matte @Anycubic Kobra 3 Max V2 0.4 nozzle.json b/resources/profiles/Anycubic/filament/Anycubic PLA Matte @Anycubic Kobra 3 Max V2 0.4 nozzle.json new file mode 100644 index 0000000000..030719bb10 --- /dev/null +++ b/resources/profiles/Anycubic/filament/Anycubic PLA Matte @Anycubic Kobra 3 Max V2 0.4 nozzle.json @@ -0,0 +1,117 @@ +{ + "type": "filament", + "name": "Anycubic PLA Matte @Anycubic Kobra 3 Max V2 0.4 nozzle", + "inherits": "fdm_filament_pla", + "from": "system", + "setting_id": "svFyLFWmxSxDKIaG", + "filament_id": "OFIE3vOf", + "instantiation": "true", + "additional_cooling_fan_speed": [ + "0" + ], + "enable_pressure_advance": [ + "1" + ], + "eng_plate_temp": [ + "45" + ], + "eng_plate_temp_initial_layer": [ + "45" + ], + "filament_deretraction_speed": [ + "0" + ], + "filament_end_gcode": [ + "; filament end gcode" + ], + "filament_flow_ratio": [ + "0.98" + ], + "filament_long_retractions_when_cut": [ + "nil" + ], + "filament_max_volumetric_speed": [ + "13" + ], + "filament_minimal_purge_on_wipe_tower": [ + "41" + ], + "filament_retract_before_wipe": [ + "0%" + ], + "filament_retract_lift_above": [ + "0.3" + ], + "filament_retract_lift_below": [ + "499" + ], + "filament_retract_lift_enforce": [ + "All Surfaces" + ], + "filament_retract_restart_extra": [ + "0" + ], + "filament_retract_when_changing_layer": [ + "1" + ], + "filament_retraction_distances_when_cut": [ + "nil" + ], + "filament_retraction_length": [ + "0.8" + ], + "filament_retraction_minimum_travel": [ + "1" + ], + "filament_retraction_speed": [ + "30" + ], + "filament_start_gcode": [ + "; filament start gcode" + ], + "filament_vendor": [ + "Anycubic" + ], + "filament_wipe": [ + "1" + ], + "filament_wipe_distance": [ + "1" + ], + "filament_z_hop": [ + "0.4" + ], + "filament_z_hop_types": [ + "Slope Lift" + ], + "full_fan_speed_layer": [ + "3" + ], + "hot_plate_temp": [ + "65" + ], + "hot_plate_temp_initial_layer": [ + "65" + ], + "nozzle_temperature": [ + "210" + ], + "pressure_advance": [ + "0.03" + ], + "slow_down_layer_time": [ + "9" + ], + "slow_down_min_speed": [ + "20" + ], + "textured_plate_temp": [ + "65" + ], + "textured_plate_temp_initial_layer": [ + "65" + ], + "compatible_printers": [ + "Anycubic Kobra 3 Max V2 0.4 nozzle" + ] +} diff --git a/resources/profiles/Anycubic/filament/Anycubic PLA Matte @Anycubic Kobra 3 Max V2 0.6 nozzle.json b/resources/profiles/Anycubic/filament/Anycubic PLA Matte @Anycubic Kobra 3 Max V2 0.6 nozzle.json new file mode 100644 index 0000000000..92e19967e7 --- /dev/null +++ b/resources/profiles/Anycubic/filament/Anycubic PLA Matte @Anycubic Kobra 3 Max V2 0.6 nozzle.json @@ -0,0 +1,102 @@ +{ + "type": "filament", + "name": "Anycubic PLA Matte @Anycubic Kobra 3 Max V2 0.6 nozzle", + "inherits": "Anycubic PLA Matte @Anycubic Kobra 3 Max V2 0.4 nozzle", + "from": "system", + "setting_id": "3YoN68ppP7sqOXTN", + "filament_id": "OFIE3vOf", + "instantiation": "true", + "filament_flow_ratio": [ + "0.97" + ], + "filament_max_volumetric_speed": [ + "8" + ], + "filament_cooling_final_speed": [ + "0" + ], + "filament_cooling_initial_speed": [ + "0" + ], + "filament_cooling_moves": [ + "0" + ], + "filament_deretraction_speed": [ + "nil" + ], + "filament_loading_speed": [ + "0" + ], + "filament_loading_speed_start": [ + "0" + ], + "filament_minimal_purge_on_wipe_tower": [ + "0" + ], + "filament_retract_before_wipe": [ + "nil" + ], + "filament_retract_lift_above": [ + "nil" + ], + "filament_retract_lift_below": [ + "nil" + ], + "filament_retract_lift_enforce": [ + "nil" + ], + "filament_retract_restart_extra": [ + "nil" + ], + "filament_retract_when_changing_layer": [ + "nil" + ], + "filament_retraction_length": [ + "nil" + ], + "filament_retraction_minimum_travel": [ + "nil" + ], + "filament_retraction_speed": [ + "nil" + ], + "filament_unloading_speed": [ + "0" + ], + "filament_unloading_speed_start": [ + "0" + ], + "filament_wipe": [ + "nil" + ], + "filament_wipe_distance": [ + "nil" + ], + "filament_z_hop": [ + "nil" + ], + "filament_z_hop_types": [ + "nil" + ], + "full_fan_speed_layer": [ + "0" + ], + "hot_plate_temp": [ + "60" + ], + "hot_plate_temp_initial_layer": [ + "60" + ], + "nozzle_temperature": [ + "220" + ], + "textured_plate_temp": [ + "60" + ], + "textured_plate_temp_initial_layer": [ + "60" + ], + "compatible_printers": [ + "Anycubic Kobra 3 Max V2 0.6 nozzle" + ] +} diff --git a/resources/profiles/Anycubic/filament/Anycubic PLA Matte @Anycubic Kobra 3 Max V2 0.8 nozzle.json b/resources/profiles/Anycubic/filament/Anycubic PLA Matte @Anycubic Kobra 3 Max V2 0.8 nozzle.json new file mode 100644 index 0000000000..1eee6c3fe8 --- /dev/null +++ b/resources/profiles/Anycubic/filament/Anycubic PLA Matte @Anycubic Kobra 3 Max V2 0.8 nozzle.json @@ -0,0 +1,78 @@ +{ + "type": "filament", + "name": "Anycubic PLA Matte @Anycubic Kobra 3 Max V2 0.8 nozzle", + "inherits": "Anycubic PLA Matte @Anycubic Kobra 3 Max V2 0.4 nozzle", + "from": "system", + "setting_id": "WxomG0jk8KgZgUou", + "filament_id": "OFIE3vOf", + "instantiation": "true", + "filament_flow_ratio": [ + "0.95" + ], + "filament_max_volumetric_speed": [ + "12" + ], + "filament_deretraction_speed": [ + "nil" + ], + "filament_retract_before_wipe": [ + "nil" + ], + "filament_retract_lift_above": [ + "nil" + ], + "filament_retract_lift_below": [ + "nil" + ], + "filament_retract_lift_enforce": [ + "nil" + ], + "filament_retract_restart_extra": [ + "nil" + ], + "filament_retract_when_changing_layer": [ + "nil" + ], + "filament_retraction_length": [ + "nil" + ], + "filament_retraction_minimum_travel": [ + "nil" + ], + "filament_retraction_speed": [ + "nil" + ], + "filament_wipe": [ + "nil" + ], + "filament_wipe_distance": [ + "nil" + ], + "filament_z_hop": [ + "nil" + ], + "filament_z_hop_types": [ + "nil" + ], + "full_fan_speed_layer": [ + "0" + ], + "hot_plate_temp": [ + "60" + ], + "hot_plate_temp_initial_layer": [ + "60" + ], + "nozzle_temperature": [ + "220" + ], + "textured_plate_temp": [ + "60" + ], + "textured_plate_temp_initial_layer": [ + "60" + ], + "compatible_printers": [ + "Anycubic Kobra 3 Max V2 0.8 nozzle" + ] +} diff --git a/resources/profiles/Anycubic/filament/Anycubic PLA Silk @Anycubic Kobra 3 Max V2 0.4 nozzle.json b/resources/profiles/Anycubic/filament/Anycubic PLA Silk @Anycubic Kobra 3 Max V2 0.4 nozzle.json new file mode 100644 index 0000000000..db5922bcbd --- /dev/null +++ b/resources/profiles/Anycubic/filament/Anycubic PLA Silk @Anycubic Kobra 3 Max V2 0.4 nozzle.json @@ -0,0 +1,126 @@ +{ + "type": "filament", + "name": "Anycubic PLA Silk @Anycubic Kobra 3 Max V2 0.4 nozzle", + "inherits": "fdm_filament_pla", + "from": "system", + "setting_id": "Bsm5fHsN7bG4eZ1M", + "filament_id": "OFFwJWea", + "instantiation": "true", + "filament_vendor": [ + "Anycubic" + ], + "filament_flow_ratio": [ + "0.96" + ], + "filament_max_volumetric_speed": [ + "13" + ], + "additional_cooling_fan_speed": [ + "0" + ], + "enable_pressure_advance": [ + "1" + ], + "eng_plate_temp": [ + "45" + ], + "eng_plate_temp_initial_layer": [ + "45" + ], + "filament_deretraction_speed": [ + "0" + ], + "filament_end_gcode": [ + "; filament end gcode" + ], + "filament_long_retractions_when_cut": [ + "nil" + ], + "filament_minimal_purge_on_wipe_tower": [ + "41" + ], + "filament_retract_before_wipe": [ + "0%" + ], + "filament_retract_lift_above": [ + "0" + ], + "filament_retract_lift_below": [ + "499" + ], + "filament_retract_lift_enforce": [ + "All Surfaces" + ], + "filament_retract_restart_extra": [ + "0" + ], + "filament_retract_when_changing_layer": [ + "1" + ], + "filament_retraction_distances_when_cut": [ + "nil" + ], + "filament_retraction_length": [ + "0.8" + ], + "filament_retraction_minimum_travel": [ + "1" + ], + "filament_retraction_speed": [ + "30" + ], + "filament_start_gcode": [ + "; filament start gcode" + ], + "filament_unloading_speed": [ + "0" + ], + "filament_unloading_speed_start": [ + "0" + ], + "filament_wipe": [ + "1" + ], + "filament_wipe_distance": [ + "1" + ], + "filament_z_hop": [ + "0.4" + ], + "filament_z_hop_types": [ + "Slope Lift" + ], + "full_fan_speed_layer": [ + "3" + ], + "hot_plate_temp": [ + "65" + ], + "hot_plate_temp_initial_layer": [ + "65" + ], + "nozzle_temperature": [ + "210" + ], + "nozzle_temperature_initial_layer": [ + "210" + ], + "pressure_advance": [ + "0.04" + ], + "slow_down_layer_time": [ + "9" + ], + "slow_down_min_speed": [ + "20" + ], + "textured_plate_temp": [ + "65" + ], + "textured_plate_temp_initial_layer": [ + "65" + ], + "compatible_printers": [ + "Anycubic Kobra 3 Max V2 0.4 nozzle" + ] +} diff --git a/resources/profiles/Anycubic/filament/Anycubic PLA Silk @Anycubic Kobra 3 Max V2 0.6 nozzle.json b/resources/profiles/Anycubic/filament/Anycubic PLA Silk @Anycubic Kobra 3 Max V2 0.6 nozzle.json new file mode 100644 index 0000000000..07bcc30cff --- /dev/null +++ b/resources/profiles/Anycubic/filament/Anycubic PLA Silk @Anycubic Kobra 3 Max V2 0.6 nozzle.json @@ -0,0 +1,90 @@ +{ + "type": "filament", + "name": "Anycubic PLA Silk @Anycubic Kobra 3 Max V2 0.6 nozzle", + "inherits": "Anycubic PLA Silk @Anycubic Kobra 3 Max V2 0.4 nozzle", + "from": "system", + "setting_id": "bcod7Z8UNlcR1Hg7", + "filament_id": "OFFwJWea", + "instantiation": "true", + "filament_flow_ratio": [ + "0.95" + ], + "filament_max_volumetric_speed": [ + "12" + ], + "filament_cooling_final_speed": [ + "0" + ], + "filament_cooling_initial_speed": [ + "0" + ], + "filament_cooling_moves": [ + "0" + ], + "filament_deretraction_speed": [ + "nil" + ], + "filament_loading_speed": [ + "0" + ], + "filament_loading_speed_start": [ + "0" + ], + "filament_minimal_purge_on_wipe_tower": [ + "0" + ], + "filament_retract_before_wipe": [ + "nil" + ], + "filament_retract_lift_above": [ + "nil" + ], + "filament_retract_lift_below": [ + "nil" + ], + "filament_retract_lift_enforce": [ + "nil" + ], + "filament_retract_restart_extra": [ + "nil" + ], + "filament_retract_when_changing_layer": [ + "nil" + ], + "filament_retraction_length": [ + "nil" + ], + "filament_retraction_minimum_travel": [ + "nil" + ], + "filament_retraction_speed": [ + "nil" + ], + "filament_wipe": [ + "nil" + ], + "filament_wipe_distance": [ + "nil" + ], + "filament_z_hop": [ + "nil" + ], + "filament_z_hop_types": [ + "nil" + ], + "full_fan_speed_layer": [ + "0" + ], + "nozzle_temperature": [ + "220" + ], + "nozzle_temperature_initial_layer": [ + "220" + ], + "pressure_advance": [ + "0.032" + ], + "compatible_printers": [ + "Anycubic Kobra 3 Max V2 0.6 nozzle" + ] +} diff --git a/resources/profiles/Anycubic/filament/Anycubic PLA Silk @Anycubic Kobra 3 Max V2 0.8 nozzle.json b/resources/profiles/Anycubic/filament/Anycubic PLA Silk @Anycubic Kobra 3 Max V2 0.8 nozzle.json new file mode 100644 index 0000000000..089552e1b4 --- /dev/null +++ b/resources/profiles/Anycubic/filament/Anycubic PLA Silk @Anycubic Kobra 3 Max V2 0.8 nozzle.json @@ -0,0 +1,78 @@ +{ + "type": "filament", + "name": "Anycubic PLA Silk @Anycubic Kobra 3 Max V2 0.8 nozzle", + "inherits": "Anycubic PLA Silk @Anycubic Kobra 3 Max V2 0.4 nozzle", + "from": "system", + "setting_id": "rYajHRGstEnZUEGK", + "filament_id": "OFFwJWea", + "instantiation": "true", + "filament_flow_ratio": [ + "0.95" + ], + "filament_max_volumetric_speed": [ + "12" + ], + "filament_deretraction_speed": [ + "nil" + ], + "filament_retract_before_wipe": [ + "nil" + ], + "filament_retract_lift_above": [ + "nil" + ], + "filament_retract_lift_below": [ + "nil" + ], + "filament_retract_lift_enforce": [ + "nil" + ], + "filament_retract_restart_extra": [ + "nil" + ], + "filament_retract_when_changing_layer": [ + "nil" + ], + "filament_retraction_length": [ + "nil" + ], + "filament_retraction_minimum_travel": [ + "nil" + ], + "filament_retraction_speed": [ + "nil" + ], + "filament_unloading_speed": [ + "90" + ], + "filament_unloading_speed_start": [ + "100" + ], + "filament_wipe": [ + "nil" + ], + "filament_wipe_distance": [ + "nil" + ], + "filament_z_hop": [ + "nil" + ], + "filament_z_hop_types": [ + "nil" + ], + "full_fan_speed_layer": [ + "0" + ], + "nozzle_temperature": [ + "220" + ], + "nozzle_temperature_initial_layer": [ + "220" + ], + "pressure_advance": [ + "0.032" + ], + "compatible_printers": [ + "Anycubic Kobra 3 Max V2 0.8 nozzle" + ] +} diff --git a/resources/profiles/Anycubic/filament/Anycubic PLA+ @Anycubic Kobra 3 Max V2 0.4 nozzle.json b/resources/profiles/Anycubic/filament/Anycubic PLA+ @Anycubic Kobra 3 Max V2 0.4 nozzle.json new file mode 100644 index 0000000000..a8017ed6fa --- /dev/null +++ b/resources/profiles/Anycubic/filament/Anycubic PLA+ @Anycubic Kobra 3 Max V2 0.4 nozzle.json @@ -0,0 +1,120 @@ +{ + "type": "filament", + "name": "Anycubic PLA+ @Anycubic Kobra 3 Max V2 0.4 nozzle", + "inherits": "fdm_filament_pla", + "from": "system", + "setting_id": "k01mI3GyJ2EFDJYw", + "filament_id": "OFnmp6rt", + "instantiation": "true", + "filament_vendor": [ + "Anycubic" + ], + "filament_flow_ratio": [ + "0.97" + ], + "filament_max_volumetric_speed": [ + "14" + ], + "additional_cooling_fan_speed": [ + "0" + ], + "enable_pressure_advance": [ + "1" + ], + "eng_plate_temp": [ + "45" + ], + "eng_plate_temp_initial_layer": [ + "45" + ], + "filament_deretraction_speed": [ + "0" + ], + "filament_end_gcode": [ + "; filament end gcode" + ], + "filament_long_retractions_when_cut": [ + "nil" + ], + "filament_minimal_purge_on_wipe_tower": [ + "41" + ], + "filament_retract_before_wipe": [ + "0%" + ], + "filament_retract_lift_above": [ + "0.3" + ], + "filament_retract_lift_below": [ + "499" + ], + "filament_retract_lift_enforce": [ + "All Surfaces" + ], + "filament_retract_restart_extra": [ + "0" + ], + "filament_retract_when_changing_layer": [ + "1" + ], + "filament_retraction_distances_when_cut": [ + "nil" + ], + "filament_retraction_length": [ + "0.4" + ], + "filament_retraction_minimum_travel": [ + "1" + ], + "filament_retraction_speed": [ + "30" + ], + "filament_start_gcode": [ + "; filament start gcode" + ], + "filament_wipe": [ + "1" + ], + "filament_wipe_distance": [ + "1" + ], + "filament_z_hop": [ + "0.4" + ], + "filament_z_hop_types": [ + "Slope Lift" + ], + "full_fan_speed_layer": [ + "3" + ], + "hot_plate_temp": [ + "65" + ], + "hot_plate_temp_initial_layer": [ + "65" + ], + "nozzle_temperature": [ + "205" + ], + "nozzle_temperature_initial_layer": [ + "215" + ], + "pressure_advance": [ + "0.03" + ], + "slow_down_layer_time": [ + "9" + ], + "slow_down_min_speed": [ + "20" + ], + "textured_plate_temp": [ + "65" + ], + "textured_plate_temp_initial_layer": [ + "65" + ], + "compatible_printers": [ + "Anycubic Kobra 3 Max V2 0.4 nozzle" + ] +} diff --git a/resources/profiles/Anycubic/filament/Anycubic PLA+ @Anycubic Kobra 3 Max V2 0.6 nozzle.json b/resources/profiles/Anycubic/filament/Anycubic PLA+ @Anycubic Kobra 3 Max V2 0.6 nozzle.json new file mode 100644 index 0000000000..65c5170b07 --- /dev/null +++ b/resources/profiles/Anycubic/filament/Anycubic PLA+ @Anycubic Kobra 3 Max V2 0.6 nozzle.json @@ -0,0 +1,93 @@ +{ + "type": "filament", + "name": "Anycubic PLA+ @Anycubic Kobra 3 Max V2 0.6 nozzle", + "inherits": "Anycubic PLA+ @Anycubic Kobra 3 Max V2 0.4 nozzle", + "from": "system", + "setting_id": "GKYyVfrIX6IlWnX2", + "filament_id": "OFnmp6rt", + "instantiation": "true", + "filament_flow_ratio": [ + "0.96" + ], + "filament_cooling_final_speed": [ + "0" + ], + "filament_cooling_initial_speed": [ + "0" + ], + "filament_cooling_moves": [ + "0" + ], + "filament_deretraction_speed": [ + "nil" + ], + "filament_loading_speed": [ + "0" + ], + "filament_loading_speed_start": [ + "0" + ], + "filament_minimal_purge_on_wipe_tower": [ + "0" + ], + "filament_retract_before_wipe": [ + "nil" + ], + "filament_retract_lift_above": [ + "nil" + ], + "filament_retract_lift_below": [ + "nil" + ], + "filament_retract_lift_enforce": [ + "nil" + ], + "filament_retract_restart_extra": [ + "nil" + ], + "filament_retract_when_changing_layer": [ + "nil" + ], + "filament_retraction_length": [ + "nil" + ], + "filament_retraction_minimum_travel": [ + "nil" + ], + "filament_retraction_speed": [ + "nil" + ], + "filament_unloading_speed": [ + "0" + ], + "filament_unloading_speed_start": [ + "0" + ], + "filament_wipe": [ + "nil" + ], + "filament_wipe_distance": [ + "nil" + ], + "filament_z_hop": [ + "nil" + ], + "filament_z_hop_types": [ + "nil" + ], + "full_fan_speed_layer": [ + "0" + ], + "nozzle_temperature": [ + "220" + ], + "nozzle_temperature_initial_layer": [ + "220" + ], + "pressure_advance": [ + "0.033" + ], + "compatible_printers": [ + "Anycubic Kobra 3 Max V2 0.6 nozzle" + ] +} diff --git a/resources/profiles/Anycubic/filament/Anycubic PLA+ @Anycubic Kobra 3 Max V2 0.8 nozzle.json b/resources/profiles/Anycubic/filament/Anycubic PLA+ @Anycubic Kobra 3 Max V2 0.8 nozzle.json new file mode 100644 index 0000000000..fd9d5982cb --- /dev/null +++ b/resources/profiles/Anycubic/filament/Anycubic PLA+ @Anycubic Kobra 3 Max V2 0.8 nozzle.json @@ -0,0 +1,69 @@ +{ + "type": "filament", + "name": "Anycubic PLA+ @Anycubic Kobra 3 Max V2 0.8 nozzle", + "inherits": "Anycubic PLA+ @Anycubic Kobra 3 Max V2 0.4 nozzle", + "from": "system", + "setting_id": "lM6UhYloEJRvY1DX", + "filament_id": "OFnmp6rt", + "instantiation": "true", + "filament_flow_ratio": [ + "0.96" + ], + "filament_deretraction_speed": [ + "nil" + ], + "filament_retract_before_wipe": [ + "nil" + ], + "filament_retract_lift_above": [ + "nil" + ], + "filament_retract_lift_below": [ + "nil" + ], + "filament_retract_lift_enforce": [ + "nil" + ], + "filament_retract_restart_extra": [ + "nil" + ], + "filament_retract_when_changing_layer": [ + "nil" + ], + "filament_retraction_length": [ + "nil" + ], + "filament_retraction_minimum_travel": [ + "nil" + ], + "filament_retraction_speed": [ + "nil" + ], + "filament_wipe": [ + "nil" + ], + "filament_wipe_distance": [ + "nil" + ], + "filament_z_hop": [ + "nil" + ], + "filament_z_hop_types": [ + "nil" + ], + "full_fan_speed_layer": [ + "0" + ], + "nozzle_temperature": [ + "220" + ], + "nozzle_temperature_initial_layer": [ + "220" + ], + "pressure_advance": [ + "0.033" + ], + "compatible_printers": [ + "Anycubic Kobra 3 Max V2 0.8 nozzle" + ] +} diff --git a/resources/profiles/Anycubic/filament/Anycubic TPU @Anycubic Kobra 3 Max V2 0.4 nozzle.json b/resources/profiles/Anycubic/filament/Anycubic TPU @Anycubic Kobra 3 Max V2 0.4 nozzle.json new file mode 100644 index 0000000000..d57766b074 --- /dev/null +++ b/resources/profiles/Anycubic/filament/Anycubic TPU @Anycubic Kobra 3 Max V2 0.4 nozzle.json @@ -0,0 +1,135 @@ +{ + "type": "filament", + "name": "Anycubic TPU @Anycubic Kobra 3 Max V2 0.4 nozzle", + "inherits": "fdm_filament_tpu", + "from": "system", + "setting_id": "kTsJQE4Dyt6pyT91", + "filament_id": "OFMsDGbs", + "instantiation": "true", + "additional_cooling_fan_speed": [ + "0" + ], + "cool_plate_temp": [ + "35" + ], + "cool_plate_temp_initial_layer": [ + "35" + ], + "enable_pressure_advance": [ + "1" + ], + "eng_plate_temp": [ + "45" + ], + "eng_plate_temp_initial_layer": [ + "45" + ], + "filament_density": [ + "1.08" + ], + "filament_deretraction_speed": [ + "0" + ], + "filament_end_gcode": [ + "; filament end gcode" + ], + "filament_flow_ratio": [ + "0.95" + ], + "filament_long_retractions_when_cut": [ + "nil" + ], + "filament_max_volumetric_speed": [ + "3.2" + ], + "filament_minimal_purge_on_wipe_tower": [ + "41" + ], + "filament_retract_before_wipe": [ + "0%" + ], + "filament_retract_lift_above": [ + "0.3" + ], + "filament_retract_lift_below": [ + "499" + ], + "filament_retract_lift_enforce": [ + "All Surfaces" + ], + "filament_retract_restart_extra": [ + "0" + ], + "filament_retract_when_changing_layer": [ + "1" + ], + "filament_retraction_distances_when_cut": [ + "nil" + ], + "filament_retraction_length": [ + "0.8" + ], + "filament_retraction_minimum_travel": [ + "1" + ], + "filament_retraction_speed": [ + "30" + ], + "filament_start_gcode": [ + "; filament start gcode" + ], + "filament_vendor": [ + "Anycubic" + ], + "filament_wipe": [ + "1" + ], + "filament_wipe_distance": [ + "1" + ], + "filament_z_hop": [ + "0.4" + ], + "filament_z_hop_types": [ + "Slope Lift" + ], + "full_fan_speed_layer": [ + "3" + ], + "hot_plate_temp": [ + "65" + ], + "hot_plate_temp_initial_layer": [ + "65" + ], + "nozzle_temperature": [ + "205" + ], + "nozzle_temperature_initial_layer": [ + "215" + ], + "nozzle_temperature_range_high": [ + "230" + ], + "nozzle_temperature_range_low": [ + "190" + ], + "overhang_fan_threshold": [ + "50%" + ], + "pressure_advance": [ + "0.02" + ], + "slow_down_min_speed": [ + "20" + ], + "textured_plate_temp": [ + "65" + ], + "textured_plate_temp_initial_layer": [ + "65" + ], + "compatible_printers": [ + "Anycubic Kobra 3 Max V2 0.4 nozzle" + ] +} diff --git a/resources/profiles/Anycubic/filament/Anycubic TPU @Anycubic Kobra 3 Max V2 0.6 nozzle.json b/resources/profiles/Anycubic/filament/Anycubic TPU @Anycubic Kobra 3 Max V2 0.6 nozzle.json new file mode 100644 index 0000000000..396a294844 --- /dev/null +++ b/resources/profiles/Anycubic/filament/Anycubic TPU @Anycubic Kobra 3 Max V2 0.6 nozzle.json @@ -0,0 +1,126 @@ +{ + "type": "filament", + "name": "Anycubic TPU @Anycubic Kobra 3 Max V2 0.6 nozzle", + "inherits": "Anycubic TPU @Anycubic Kobra 3 Max V2 0.4 nozzle", + "from": "system", + "setting_id": "HiLLxOk6W9lpFVg0", + "filament_id": "OFMsDGbs", + "instantiation": "true", + "fan_max_speed": [ + "80" + ], + "fan_min_speed": [ + "50" + ], + "filament_flow_ratio": [ + "1" + ], + "nozzle_temperature": [ + "240" + ], + "close_fan_the_first_x_layers": [ + "5" + ], + "fan_cooling_layer_time": [ + "20" + ], + "filament_cooling_final_speed": [ + "0" + ], + "filament_cooling_initial_speed": [ + "0" + ], + "filament_cooling_moves": [ + "0" + ], + "filament_density": [ + "1.24" + ], + "filament_deretraction_speed": [ + "nil" + ], + "filament_loading_speed": [ + "0" + ], + "filament_loading_speed_start": [ + "0" + ], + "filament_minimal_purge_on_wipe_tower": [ + "0" + ], + "filament_retract_before_wipe": [ + "nil" + ], + "filament_retract_lift_above": [ + "nil" + ], + "filament_retract_lift_below": [ + "nil" + ], + "filament_retract_lift_enforce": [ + "nil" + ], + "filament_retract_restart_extra": [ + "nil" + ], + "filament_retract_when_changing_layer": [ + "nil" + ], + "filament_retraction_length": [ + "nil" + ], + "filament_retraction_minimum_travel": [ + "nil" + ], + "filament_retraction_speed": [ + "nil" + ], + "filament_unloading_speed": [ + "0" + ], + "filament_unloading_speed_start": [ + "0" + ], + "filament_wipe": [ + "nil" + ], + "filament_wipe_distance": [ + "nil" + ], + "filament_z_hop": [ + "nil" + ], + "filament_z_hop_types": [ + "nil" + ], + "full_fan_speed_layer": [ + "6" + ], + "hot_plate_temp": [ + "35" + ], + "hot_plate_temp_initial_layer": [ + "35" + ], + "nozzle_temperature_initial_layer": [ + "240" + ], + "overhang_fan_threshold": [ + "95%" + ], + "pressure_advance": [ + "0.036" + ], + "slow_down_layer_time": [ + "10" + ], + "textured_plate_temp": [ + "35" + ], + "textured_plate_temp_initial_layer": [ + "35" + ], + "compatible_printers": [ + "Anycubic Kobra 3 Max V2 0.6 nozzle" + ] +} diff --git a/resources/profiles/Anycubic/filament/Anycubic TPU @Anycubic Kobra 3 Max V2 0.8 nozzle.json b/resources/profiles/Anycubic/filament/Anycubic TPU @Anycubic Kobra 3 Max V2 0.8 nozzle.json new file mode 100644 index 0000000000..43e5d24433 --- /dev/null +++ b/resources/profiles/Anycubic/filament/Anycubic TPU @Anycubic Kobra 3 Max V2 0.8 nozzle.json @@ -0,0 +1,105 @@ +{ + "type": "filament", + "name": "Anycubic TPU @Anycubic Kobra 3 Max V2 0.8 nozzle", + "inherits": "Anycubic TPU @Anycubic Kobra 3 Max V2 0.4 nozzle", + "from": "system", + "setting_id": "RQ3EXw0jXeWeWr0L", + "filament_id": "OFMsDGbs", + "instantiation": "true", + "fan_max_speed": [ + "80" + ], + "fan_min_speed": [ + "50" + ], + "filament_flow_ratio": [ + "1" + ], + "close_fan_the_first_x_layers": [ + "5" + ], + "enable_pressure_advance": [ + "0" + ], + "fan_cooling_layer_time": [ + "20" + ], + "filament_density": [ + "1.24" + ], + "filament_deretraction_speed": [ + "nil" + ], + "filament_retract_before_wipe": [ + "nil" + ], + "filament_retract_lift_above": [ + "nil" + ], + "filament_retract_lift_below": [ + "nil" + ], + "filament_retract_lift_enforce": [ + "nil" + ], + "filament_retract_restart_extra": [ + "nil" + ], + "filament_retract_when_changing_layer": [ + "nil" + ], + "filament_retraction_length": [ + "nil" + ], + "filament_retraction_minimum_travel": [ + "nil" + ], + "filament_retraction_speed": [ + "nil" + ], + "filament_wipe": [ + "nil" + ], + "filament_wipe_distance": [ + "nil" + ], + "filament_z_hop": [ + "nil" + ], + "filament_z_hop_types": [ + "nil" + ], + "full_fan_speed_layer": [ + "6" + ], + "hot_plate_temp": [ + "35" + ], + "hot_plate_temp_initial_layer": [ + "35" + ], + "nozzle_temperature": [ + "240" + ], + "nozzle_temperature_initial_layer": [ + "240" + ], + "overhang_fan_threshold": [ + "95%" + ], + "pressure_advance": [ + "0.036" + ], + "slow_down_layer_time": [ + "10" + ], + "textured_plate_temp": [ + "35" + ], + "textured_plate_temp_initial_layer": [ + "35" + ], + "compatible_printers": [ + "Anycubic Kobra 3 Max V2 0.8 nozzle" + ] +} diff --git a/resources/profiles/Anycubic/filament/Generic ABS @Anycubic Kobra 3 Max V2 0.4 nozzle.json b/resources/profiles/Anycubic/filament/Generic ABS @Anycubic Kobra 3 Max V2 0.4 nozzle.json new file mode 100644 index 0000000000..cc3b81d542 --- /dev/null +++ b/resources/profiles/Anycubic/filament/Generic ABS @Anycubic Kobra 3 Max V2 0.4 nozzle.json @@ -0,0 +1,24 @@ +{ + "type": "filament", + "name": "Generic ABS @Anycubic Kobra 3 Max V2 0.4 nozzle", + "inherits": "Anycubic ABS @Anycubic Kobra 3 Max V2 0.4 nozzle", + "from": "system", + "setting_id": "MSwqVnaB3CqAl76d", + "filament_id": "OFY9muEs", + "instantiation": "true", + "filament_vendor": [ + "Generic" + ], + "filament_flow_ratio": [ + "1" + ], + "textured_plate_temp": [ + "100" + ], + "textured_plate_temp_initial_layer": [ + "100" + ], + "compatible_printers": [ + "Anycubic Kobra 3 Max V2 0.4 nozzle" + ] +} diff --git a/resources/profiles/Anycubic/filament/Generic PETG @Anycubic Kobra 3 Max V2 0.4 nozzle.json b/resources/profiles/Anycubic/filament/Generic PETG @Anycubic Kobra 3 Max V2 0.4 nozzle.json new file mode 100644 index 0000000000..32898fdfa5 --- /dev/null +++ b/resources/profiles/Anycubic/filament/Generic PETG @Anycubic Kobra 3 Max V2 0.4 nozzle.json @@ -0,0 +1,18 @@ +{ + "type": "filament", + "name": "Generic PETG @Anycubic Kobra 3 Max V2 0.4 nozzle", + "inherits": "Anycubic PETG @Anycubic Kobra 3 Max V2 0.4 nozzle", + "from": "system", + "setting_id": "McU40ysmhrHhdvGr", + "filament_id": "OFYPdQJh", + "instantiation": "true", + "filament_vendor": [ + "Generic" + ], + "nozzle_temperature": [ + "235" + ], + "compatible_printers": [ + "Anycubic Kobra 3 Max V2 0.4 nozzle" + ] +} diff --git a/resources/profiles/Anycubic/filament/Generic PLA @Anycubic Kobra 3 Max V2 0.4 nozzle.json b/resources/profiles/Anycubic/filament/Generic PLA @Anycubic Kobra 3 Max V2 0.4 nozzle.json new file mode 100644 index 0000000000..1ddf1dbe88 --- /dev/null +++ b/resources/profiles/Anycubic/filament/Generic PLA @Anycubic Kobra 3 Max V2 0.4 nozzle.json @@ -0,0 +1,27 @@ +{ + "type": "filament", + "name": "Generic PLA @Anycubic Kobra 3 Max V2 0.4 nozzle", + "inherits": "Anycubic PLA @Anycubic Kobra 3 Max V2 0.4 nozzle", + "from": "system", + "setting_id": "TPjqgj2ZgVJ7ndau", + "filament_id": "OFDSrzZ8", + "instantiation": "true", + "filament_vendor": [ + "Generic" + ], + "filament_flow_ratio": [ + "0.97" + ], + "filament_max_volumetric_speed": [ + "8" + ], + "pressure_advance": [ + "0.04" + ], + "slow_down_layer_time": [ + "11" + ], + "compatible_printers": [ + "Anycubic Kobra 3 Max V2 0.4 nozzle" + ] +} diff --git a/resources/profiles/Anycubic/filament/Generic PLA Silk @Anycubic Kobra 3 Max V2 0.4 nozzle.json b/resources/profiles/Anycubic/filament/Generic PLA Silk @Anycubic Kobra 3 Max V2 0.4 nozzle.json new file mode 100644 index 0000000000..7798778bee --- /dev/null +++ b/resources/profiles/Anycubic/filament/Generic PLA Silk @Anycubic Kobra 3 Max V2 0.4 nozzle.json @@ -0,0 +1,33 @@ +{ + "type": "filament", + "name": "Generic PLA Silk @Anycubic Kobra 3 Max V2 0.4 nozzle", + "inherits": "Anycubic PLA Silk @Anycubic Kobra 3 Max V2 0.4 nozzle", + "from": "system", + "setting_id": "cTC59V3kbacRtwMN", + "filament_id": "OFesA6rF", + "instantiation": "true", + "filament_vendor": [ + "Generic" + ], + "filament_flow_ratio": [ + "0.98" + ], + "filament_max_volumetric_speed": [ + "8" + ], + "nozzle_temperature": [ + "220" + ], + "nozzle_temperature_initial_layer": [ + "220" + ], + "pressure_advance": [ + "0.02" + ], + "slow_down_layer_time": [ + "12" + ], + "compatible_printers": [ + "Anycubic Kobra 3 Max V2 0.4 nozzle" + ] +} diff --git a/resources/profiles/Anycubic/filament/Generic TPU @Anycubic Kobra 3 Max V2 0.4 nozzle.json b/resources/profiles/Anycubic/filament/Generic TPU @Anycubic Kobra 3 Max V2 0.4 nozzle.json new file mode 100644 index 0000000000..64ffcea068 --- /dev/null +++ b/resources/profiles/Anycubic/filament/Generic TPU @Anycubic Kobra 3 Max V2 0.4 nozzle.json @@ -0,0 +1,21 @@ +{ + "type": "filament", + "name": "Generic TPU @Anycubic Kobra 3 Max V2 0.4 nozzle", + "inherits": "Anycubic TPU @Anycubic Kobra 3 Max V2 0.4 nozzle", + "from": "system", + "setting_id": "zbc8ereHguQjCeHq", + "filament_id": "OFgbpcy9", + "instantiation": "true", + "filament_flow_ratio": [ + "0.97" + ], + "filament_max_volumetric_speed": [ + "3" + ], + "filament_vendor": [ + "Generic" + ], + "compatible_printers": [ + "Anycubic Kobra 3 Max V2 0.4 nozzle" + ] +} diff --git a/resources/profiles/Anycubic/machine/Anycubic Kobra 3 Max V2 0.25 nozzle.json b/resources/profiles/Anycubic/machine/Anycubic Kobra 3 Max V2 0.25 nozzle.json new file mode 100644 index 0000000000..f6040afb64 --- /dev/null +++ b/resources/profiles/Anycubic/machine/Anycubic Kobra 3 Max V2 0.25 nozzle.json @@ -0,0 +1,26 @@ +{ + "type": "machine", + "name": "Anycubic Kobra 3 Max V2 0.25 nozzle", + "inherits": "fdm_anycubic_kobra_3_max_v2_common", + "from": "system", + "setting_id": "MHLPN21YYDQbjcpf", + "instantiation": "true", + "printer_model": "Anycubic Kobra 3 Max V2", + "printer_variant": "0.25", + "nozzle_diameter": [ + "0.25" + ], + "default_print_profile": "0.12mm Standard @Anycubic Kobra 3 Max V2 0.25 nozzle", + "default_filament_profile": [ + "Anycubic PLA @Anycubic Kobra 3 Max V2 0.25 nozzle" + ], + "max_layer_height": [ + "0.18" + ], + "min_layer_height": [ + "0.05" + ], + "nozzle_type": [ + "hardened_steel" + ] +} diff --git a/resources/profiles/Anycubic/machine/Anycubic Kobra 3 Max V2 0.4 nozzle.json b/resources/profiles/Anycubic/machine/Anycubic Kobra 3 Max V2 0.4 nozzle.json new file mode 100644 index 0000000000..943196c882 --- /dev/null +++ b/resources/profiles/Anycubic/machine/Anycubic Kobra 3 Max V2 0.4 nozzle.json @@ -0,0 +1,26 @@ +{ + "type": "machine", + "name": "Anycubic Kobra 3 Max V2 0.4 nozzle", + "inherits": "fdm_anycubic_kobra_3_max_v2_common", + "from": "system", + "setting_id": "t5F9fC2XQjvytqvM", + "instantiation": "true", + "printer_model": "Anycubic Kobra 3 Max V2", + "printer_variant": "0.4", + "nozzle_diameter": [ + "0.4" + ], + "default_print_profile": "0.20mm Standard @Anycubic Kobra 3 Max V2 0.4 nozzle", + "default_filament_profile": [ + "Anycubic PLA @Anycubic Kobra 3 Max V2 0.4 nozzle" + ], + "max_layer_height": [ + "0.28" + ], + "min_layer_height": [ + "0.08" + ], + "nozzle_type": [ + "hardened_steel" + ] +} diff --git a/resources/profiles/Anycubic/machine/Anycubic Kobra 3 Max V2 0.6 nozzle.json b/resources/profiles/Anycubic/machine/Anycubic Kobra 3 Max V2 0.6 nozzle.json new file mode 100644 index 0000000000..5076d94c8c --- /dev/null +++ b/resources/profiles/Anycubic/machine/Anycubic Kobra 3 Max V2 0.6 nozzle.json @@ -0,0 +1,26 @@ +{ + "type": "machine", + "name": "Anycubic Kobra 3 Max V2 0.6 nozzle", + "inherits": "fdm_anycubic_kobra_3_max_v2_common", + "from": "system", + "setting_id": "k3ZMogk2NTOZhx9R", + "instantiation": "true", + "printer_model": "Anycubic Kobra 3 Max V2", + "printer_variant": "0.6", + "nozzle_diameter": [ + "0.6" + ], + "default_print_profile": "0.30mm Standard @Anycubic Kobra 3 Max V2 0.6 nozzle", + "default_filament_profile": [ + "Anycubic PLA @Anycubic Kobra 3 Max V2 0.6 nozzle" + ], + "max_layer_height": [ + "0.42" + ], + "min_layer_height": [ + "0.12" + ], + "nozzle_type": [ + "hardened_steel" + ] +} diff --git a/resources/profiles/Anycubic/machine/Anycubic Kobra 3 Max V2 0.8 nozzle.json b/resources/profiles/Anycubic/machine/Anycubic Kobra 3 Max V2 0.8 nozzle.json new file mode 100644 index 0000000000..b0af9fd661 --- /dev/null +++ b/resources/profiles/Anycubic/machine/Anycubic Kobra 3 Max V2 0.8 nozzle.json @@ -0,0 +1,26 @@ +{ + "type": "machine", + "name": "Anycubic Kobra 3 Max V2 0.8 nozzle", + "inherits": "fdm_anycubic_kobra_3_max_v2_common", + "from": "system", + "setting_id": "6Xx3in12IoGgTqoj", + "instantiation": "true", + "printer_model": "Anycubic Kobra 3 Max V2", + "printer_variant": "0.8", + "nozzle_diameter": [ + "0.8" + ], + "default_print_profile": "0.40mm Standard @Anycubic Kobra 3 Max V2 0.8 nozzle", + "default_filament_profile": [ + "Anycubic PLA @Anycubic Kobra 3 Max V2 0.8 nozzle" + ], + "max_layer_height": [ + "0.56" + ], + "min_layer_height": [ + "0.16" + ], + "nozzle_type": [ + "hardened_steel" + ] +} diff --git a/resources/profiles/Anycubic/machine/Anycubic Kobra 3 Max V2.json b/resources/profiles/Anycubic/machine/Anycubic Kobra 3 Max V2.json new file mode 100644 index 0000000000..b6522f6215 --- /dev/null +++ b/resources/profiles/Anycubic/machine/Anycubic Kobra 3 Max V2.json @@ -0,0 +1,12 @@ +{ + "type": "machine_model", + "name": "Anycubic Kobra 3 Max V2", + "machine_tech": "FFF", + "family": "Anycubic", + "model_id": "Anycubic Kobra 3 Max V2", + "nozzle_diameter": "0.4;0.6;0.8;0.25", + "bed_model": "Anycubic Kobra 3 Max_buildplate_model.stl", + "bed_texture": "Anycubic Kobra 3 Max_buildplate_texture.svg", + "hotend_model": "", + "default_materials": "Anycubic ABS @Anycubic Kobra 3 Max V2 0.25 nozzle;Anycubic ABS @Anycubic Kobra 3 Max V2 0.4 nozzle;Anycubic ABS @Anycubic Kobra 3 Max V2 0.6 nozzle;Anycubic ABS @Anycubic Kobra 3 Max V2 0.8 nozzle;Anycubic ASA @Anycubic Kobra 3 Max V2 0.25 nozzle;Anycubic ASA @Anycubic Kobra 3 Max V2 0.4 nozzle;Anycubic ASA @Anycubic Kobra 3 Max V2 0.6 nozzle;Anycubic ASA @Anycubic Kobra 3 Max V2 0.8 nozzle;Anycubic PEBA 95A @Anycubic Kobra 3 Max V2 0.4 nozzle;Anycubic PETG @Anycubic Kobra 3 Max V2 0.25 nozzle;Anycubic PETG @Anycubic Kobra 3 Max V2 0.4 nozzle;Anycubic PETG @Anycubic Kobra 3 Max V2 0.6 nozzle;Anycubic PETG @Anycubic Kobra 3 Max V2 0.8 nozzle;Anycubic PLA @Anycubic Kobra 3 Max V2 0.25 nozzle;Anycubic PLA @Anycubic Kobra 3 Max V2 0.4 nozzle;Anycubic PLA @Anycubic Kobra 3 Max V2 0.6 nozzle;Anycubic PLA @Anycubic Kobra 3 Max V2 0.8 nozzle;Anycubic PLA Glow @Anycubic Kobra 3 Max V2 0.4 nozzle;Anycubic PLA Glow @Anycubic Kobra 3 Max V2 0.6 nozzle;Anycubic PLA Glow @Anycubic Kobra 3 Max V2 0.8 nozzle;Anycubic PLA High Speed @Anycubic Kobra 3 Max V2 0.4 nozzle;Anycubic PLA High Speed @Anycubic Kobra 3 Max V2 0.6 nozzle;Anycubic PLA High Speed @Anycubic Kobra 3 Max V2 0.8 nozzle;Anycubic PLA Matte @Anycubic Kobra 3 Max V2 0.4 nozzle;Anycubic PLA Matte @Anycubic Kobra 3 Max V2 0.6 nozzle;Anycubic PLA Matte @Anycubic Kobra 3 Max V2 0.8 nozzle;Anycubic PLA Silk @Anycubic Kobra 3 Max V2 0.4 nozzle;Anycubic PLA Silk @Anycubic Kobra 3 Max V2 0.6 nozzle;Anycubic PLA Silk @Anycubic Kobra 3 Max V2 0.8 nozzle;Anycubic PLA+ @Anycubic Kobra 3 Max V2 0.4 nozzle;Anycubic PLA+ @Anycubic Kobra 3 Max V2 0.6 nozzle;Anycubic PLA+ @Anycubic Kobra 3 Max V2 0.8 nozzle;Anycubic TPU @Anycubic Kobra 3 Max V2 0.4 nozzle;Anycubic TPU @Anycubic Kobra 3 Max V2 0.6 nozzle;Anycubic TPU @Anycubic Kobra 3 Max V2 0.8 nozzle;Generic ABS @Anycubic Kobra 3 Max V2 0.4 nozzle;Generic PETG @Anycubic Kobra 3 Max V2 0.4 nozzle;Generic PLA @Anycubic Kobra 3 Max V2 0.4 nozzle;Generic PLA Silk @Anycubic Kobra 3 Max V2 0.4 nozzle;Generic TPU @Anycubic Kobra 3 Max V2 0.4 nozzle" +} diff --git a/resources/profiles/Anycubic/machine/fdm_anycubic_kobra_3_max_v2_common.json b/resources/profiles/Anycubic/machine/fdm_anycubic_kobra_3_max_v2_common.json new file mode 100644 index 0000000000..b2d83eb68a --- /dev/null +++ b/resources/profiles/Anycubic/machine/fdm_anycubic_kobra_3_max_v2_common.json @@ -0,0 +1,123 @@ +{ + "type": "machine", + "name": "fdm_anycubic_kobra_3_max_v2_common", + "inherits": "fdm_machine_common", + "from": "system", + "instantiation": "false", + "bed_exclude_area": [], + "bed_mesh_max": "0,0", + "bed_mesh_min": "0,0", + "bed_mesh_probe_distance": "0,0", + "before_layer_change_gcode": "; BEFORE_LAYER_CHANGE [layer_num] @ [layer_z]mm", + "change_filament_gcode": "; FLUSH_START\n;;; M400 P0\nT[next_extruder] ; change extruder\n; 1\n;;; G1 E-2 F2400\n;;; G1 Z{max(toolchange_z+0.6, 5.0)} F600\n;;; G1 X445.0 F12000\n;;; G1 E-5 F600\n;;; G1 X472.7 F600\n;;; M400 P3530\n;;; G1 E-1 F600\n;;; G1 Z{max(toolchange_z+2.6, 7.0)} F600\n;;; G1 X445 F18000\n;;; G1 X457 F1200\n;;; G1 X445 F1200\n;;; G1 E2 F300\n;;; M400 P31050\n;;; M400 P17510\n; 2\n;;; G1 X445 F18000\n;;; G1 X457 F1200\n;;; G1 X445 F1200\n;;; G1 E2 F300\n;;; M400 P0\n;;; G1 X420 F6000\n;;; M400 P0\n;;; G1 X445 F18000\n;;; G1 X457 F1200\n;;; G1 X445 F1200\n;;; G1 E2 F300\n;;; M400 P0\n; 3.1\n;;; M106 S255\n;;; G1 X42 Y430.5 Z-0.8 F9600\n;;; G1 X46 Y430.5 Z1 F9600\n;;; G1 X98 Y430.5 Z1 F9600\n;;; G1 X102 Y430.5 Z-0.8 F9600\n;;; G1 X102 Y428 Z-0.8 F9600\n;;; G1 X98 Y428 Z1 F9600\n;;; G1 X48 Y428 Z1 F9600\n;;; G1 X42 Y428 Z-0.8 F9600\n; 3.2\n;;; G1 X42 Y430.5 Z-0.8 F9600\n;;; G1 X46 Y430.5 Z1 F9600\n;;; G1 X98 Y430.5 Z1 F9600\n;;; G1 X102 Y430.5 Z-0.8 F9600\n;;; G1 X102 Y428 Z-0.8 F9600\n;;; G1 X98 Y428 Z1 F9600\n;;; G1 X48 Y428 Z1 F9600\n;;; G1 X42 Y428 Z-0.8 F9600\n; 3.3\n;;; G1 X42 Y430.5 Z-0.8 F9600\n;;; G1 X46 Y430.5 Z1 F9600\n;;; G1 X98 Y430.5 Z1 F9600\n;;; G1 X102 Y430.5 Z-0.8 F9600\n;;; G1 X102 Y428 Z-0.8 F9600\n;;; G1 X98 Y428 Z1 F9600\n;;; G1 X48 Y428 Z1 F9600\n;;; G1 X42 Y428 Z-0.8 F9600\n;;; G1 Z{toolchange_z}\n;;; M400 P0\n; FLUSH_END", + "cooling_tube_length": "0", + "cooling_tube_retraction": "0", + "default_bed_type": "Textured PEI Plate", + "deretraction_speed": [ + "0" + ], + "enable_filament_ramming": "0", + "extra_loading_move": "0", + "extruder_clearance_height_to_lid": "500", + "extruder_clearance_height_to_rod": "20", + "extruder_clearance_radius": "57", + "extruder_colour": [ + "#FF4D4F" + ], + "gcode_flavor": "klipper", + "layer_change_gcode": "; AFTER_LAYER_CHANGE [layer_num] @ [layer_z]mm", + "machine_end_gcode": "M400\nG92 E0 ; zero the extruder\nG1 E-2 F3600\n{if max_layer_z < max_print_height-1}G1 Z{max_layer_z+2} F900 ; Move print head further up{endif}\nG1 X420 Y420 F12000 ; present print\nM140 S0 ; turn off heatbed\nM104 S0 ; turn off temperature\nM107;turn off fan\nM84; disable motors\n; disable stepper motors", + "machine_load_filament_time": "75", + "machine_max_acceleration_e": [ + "6500", + "6500" + ], + "machine_max_acceleration_extruding": [ + "6500", + "6500" + ], + "machine_max_acceleration_retracting": [ + "6500", + "6500" + ], + "machine_max_acceleration_travel": [ + "10000", + "10000" + ], + "machine_max_acceleration_x": [ + "10000", + "10000" + ], + "machine_max_acceleration_y": [ + "10000", + "10000" + ], + "machine_max_acceleration_z": [ + "100", + "100" + ], + "machine_max_jerk_e": [ + "20", + "20" + ], + "machine_max_jerk_x": [ + "20", + "20" + ], + "machine_max_jerk_y": [ + "20", + "20" + ], + "machine_max_jerk_z": [ + "20", + "20" + ], + "machine_max_speed_e": [ + "600", + "300" + ], + "machine_max_speed_x": [ + "600", + "300" + ], + "machine_max_speed_y": [ + "600", + "300" + ], + "machine_max_speed_z": [ + "20", + "10" + ], + "machine_pause_gcode": "M601", + "machine_start_gcode": "G9111 bedTemp=[first_layer_bed_temperature] extruderTemp=[first_layer_temperature[initial_tool]]\nM117\n; print_bed_min = {print_bed_min[0]},{print_bed_min[1]}\n; print_bed_max = {print_bed_max[0]},{print_bed_max[1]}\n; print_bed_size = {print_bed_size[0]},{print_bed_size[1]}\n; first_layer_print_min = {first_layer_print_min[0]},{first_layer_print_min[1]}\n; first_layer_print_max = {first_layer_print_max[0]},{first_layer_print_max[1]}\n; first_layer_print_size = {first_layer_print_size[0]},{first_layer_print_size[1]}", + "nozzle_height": "4", + "nozzle_volume": [ + "71.9" + ], + "parking_pos_retraction": "0", + "printable_area": [ + "0x0", + "426x0", + "426x420", + "0x420" + ], + "printable_height": "501", + "printer_structure": "i3", + "purge_in_prime_tower": "0", + "retract_before_wipe": [ + "0%" + ], + "retract_length_toolchange": [ + "0" + ], + "retract_lift_below": [ + "499" + ], + "support_air_filtration": "0", + "support_chamber_temp_control": "0", + "support_multi_bed_types": "1", + "thumbnails": "230x110/PNG", + "z_hop_types": [ + "Slope Lift" + ] +} diff --git a/resources/profiles/Anycubic/process/0.06mm Standard @Anycubic Kobra 3 Max V2 0.25 nozzle.json b/resources/profiles/Anycubic/process/0.06mm Standard @Anycubic Kobra 3 Max V2 0.25 nozzle.json new file mode 100644 index 0000000000..95f6658f45 --- /dev/null +++ b/resources/profiles/Anycubic/process/0.06mm Standard @Anycubic Kobra 3 Max V2 0.25 nozzle.json @@ -0,0 +1,12 @@ +{ + "type": "process", + "name": "0.06mm Standard @Anycubic Kobra 3 Max V2 0.25 nozzle", + "inherits": "fdm_process_anycubic_kobra_3_max_v2_nozzle_0.25", + "from": "system", + "setting_id": "1LVjcpKbJC6XsQ8v", + "instantiation": "true", + "layer_height": "0.06", + "compatible_printers": [ + "Anycubic Kobra 3 Max V2 0.25 nozzle" + ] +} diff --git a/resources/profiles/Anycubic/process/0.08mm Standard @Anycubic Kobra 3 Max V2 0.25 nozzle.json b/resources/profiles/Anycubic/process/0.08mm Standard @Anycubic Kobra 3 Max V2 0.25 nozzle.json new file mode 100644 index 0000000000..016b0d5fd9 --- /dev/null +++ b/resources/profiles/Anycubic/process/0.08mm Standard @Anycubic Kobra 3 Max V2 0.25 nozzle.json @@ -0,0 +1,13 @@ +{ + "type": "process", + "name": "0.08mm Standard @Anycubic Kobra 3 Max V2 0.25 nozzle", + "inherits": "fdm_process_anycubic_kobra_3_max_v2_nozzle_0.25", + "from": "system", + "setting_id": "WqD1ilUvXVjsjBje", + "instantiation": "true", + "initial_layer_print_height": "0.125", + "layer_height": "0.08", + "compatible_printers": [ + "Anycubic Kobra 3 Max V2 0.25 nozzle" + ] +} diff --git a/resources/profiles/Anycubic/process/0.08mm Standard @Anycubic Kobra 3 Max V2 0.4 nozzle.json b/resources/profiles/Anycubic/process/0.08mm Standard @Anycubic Kobra 3 Max V2 0.4 nozzle.json new file mode 100644 index 0000000000..71a3bcec5f --- /dev/null +++ b/resources/profiles/Anycubic/process/0.08mm Standard @Anycubic Kobra 3 Max V2 0.4 nozzle.json @@ -0,0 +1,24 @@ +{ + "type": "process", + "name": "0.08mm Standard @Anycubic Kobra 3 Max V2 0.4 nozzle", + "inherits": "fdm_process_anycubic_kobra_3_max_v2_nozzle_0.4", + "from": "system", + "setting_id": "xbUiVCquj4AzyMz2", + "instantiation": "true", + "initial_layer_infill_speed": [ + "45" + ], + "initial_layer_speed": [ + "45" + ], + "inner_wall_speed": [ + "90" + ], + "layer_height": "0.08", + "outer_wall_speed": [ + "70" + ], + "compatible_printers": [ + "Anycubic Kobra 3 Max V2 0.4 nozzle" + ] +} diff --git a/resources/profiles/Anycubic/process/0.10mm Standard @Anycubic Kobra 3 Max V2 0.25 nozzle.json b/resources/profiles/Anycubic/process/0.10mm Standard @Anycubic Kobra 3 Max V2 0.25 nozzle.json new file mode 100644 index 0000000000..17530b3678 --- /dev/null +++ b/resources/profiles/Anycubic/process/0.10mm Standard @Anycubic Kobra 3 Max V2 0.25 nozzle.json @@ -0,0 +1,12 @@ +{ + "type": "process", + "name": "0.10mm Standard @Anycubic Kobra 3 Max V2 0.25 nozzle", + "inherits": "fdm_process_anycubic_kobra_3_max_v2_nozzle_0.25", + "from": "system", + "setting_id": "EwKiQbTFkQPG2ZJl", + "instantiation": "true", + "layer_height": "0.1", + "compatible_printers": [ + "Anycubic Kobra 3 Max V2 0.25 nozzle" + ] +} diff --git a/resources/profiles/Anycubic/process/0.12mm Standard @Anycubic Kobra 3 Max V2 0.25 nozzle.json b/resources/profiles/Anycubic/process/0.12mm Standard @Anycubic Kobra 3 Max V2 0.25 nozzle.json new file mode 100644 index 0000000000..b12e83f0cb --- /dev/null +++ b/resources/profiles/Anycubic/process/0.12mm Standard @Anycubic Kobra 3 Max V2 0.25 nozzle.json @@ -0,0 +1,12 @@ +{ + "type": "process", + "name": "0.12mm Standard @Anycubic Kobra 3 Max V2 0.25 nozzle", + "inherits": "fdm_process_anycubic_kobra_3_max_v2_nozzle_0.25", + "from": "system", + "setting_id": "IOsSvR02EIwEKK10", + "instantiation": "true", + "layer_height": "0.12", + "compatible_printers": [ + "Anycubic Kobra 3 Max V2 0.25 nozzle" + ] +} diff --git a/resources/profiles/Anycubic/process/0.12mm Standard @Anycubic Kobra 3 Max V2 0.4 nozzle.json b/resources/profiles/Anycubic/process/0.12mm Standard @Anycubic Kobra 3 Max V2 0.4 nozzle.json new file mode 100644 index 0000000000..392c18f1cf --- /dev/null +++ b/resources/profiles/Anycubic/process/0.12mm Standard @Anycubic Kobra 3 Max V2 0.4 nozzle.json @@ -0,0 +1,27 @@ +{ + "type": "process", + "name": "0.12mm Standard @Anycubic Kobra 3 Max V2 0.4 nozzle", + "inherits": "fdm_process_anycubic_kobra_3_max_v2_nozzle_0.4", + "from": "system", + "setting_id": "N2EKdHU5Q3y2oPeC", + "instantiation": "true", + "initial_layer_infill_speed": [ + "45" + ], + "initial_layer_speed": [ + "45" + ], + "inner_wall_speed": [ + "120" + ], + "internal_solid_infill_speed": [ + "120" + ], + "layer_height": "0.12", + "outer_wall_speed": [ + "90" + ], + "compatible_printers": [ + "Anycubic Kobra 3 Max V2 0.4 nozzle" + ] +} diff --git a/resources/profiles/Anycubic/process/0.14mm Standard @Anycubic Kobra 3 Max V2 0.25 nozzle.json b/resources/profiles/Anycubic/process/0.14mm Standard @Anycubic Kobra 3 Max V2 0.25 nozzle.json new file mode 100644 index 0000000000..1225e82f68 --- /dev/null +++ b/resources/profiles/Anycubic/process/0.14mm Standard @Anycubic Kobra 3 Max V2 0.25 nozzle.json @@ -0,0 +1,12 @@ +{ + "type": "process", + "name": "0.14mm Standard @Anycubic Kobra 3 Max V2 0.25 nozzle", + "inherits": "fdm_process_anycubic_kobra_3_max_v2_nozzle_0.25", + "from": "system", + "setting_id": "PsNiWmjR8fRnYB3Q", + "instantiation": "true", + "layer_height": "0.14", + "compatible_printers": [ + "Anycubic Kobra 3 Max V2 0.25 nozzle" + ] +} diff --git a/resources/profiles/Anycubic/process/0.16mm Standard @Anycubic Kobra 3 Max V2 0.4 nozzle.json b/resources/profiles/Anycubic/process/0.16mm Standard @Anycubic Kobra 3 Max V2 0.4 nozzle.json new file mode 100644 index 0000000000..344c12f776 --- /dev/null +++ b/resources/profiles/Anycubic/process/0.16mm Standard @Anycubic Kobra 3 Max V2 0.4 nozzle.json @@ -0,0 +1,27 @@ +{ + "type": "process", + "name": "0.16mm Standard @Anycubic Kobra 3 Max V2 0.4 nozzle", + "inherits": "fdm_process_anycubic_kobra_3_max_v2_nozzle_0.4", + "from": "system", + "setting_id": "JXot9cUgJ4U45ZdK", + "instantiation": "true", + "initial_layer_infill_speed": [ + "45" + ], + "initial_layer_speed": [ + "45" + ], + "inner_wall_speed": [ + "140" + ], + "layer_height": "0.16", + "outer_wall_speed": [ + "120" + ], + "sparse_infill_speed": [ + "300" + ], + "compatible_printers": [ + "Anycubic Kobra 3 Max V2 0.4 nozzle" + ] +} diff --git a/resources/profiles/Anycubic/process/0.18mm Standard @Anycubic Kobra 3 Max V2 0.6 nozzle.json b/resources/profiles/Anycubic/process/0.18mm Standard @Anycubic Kobra 3 Max V2 0.6 nozzle.json new file mode 100644 index 0000000000..f905839cf6 --- /dev/null +++ b/resources/profiles/Anycubic/process/0.18mm Standard @Anycubic Kobra 3 Max V2 0.6 nozzle.json @@ -0,0 +1,17 @@ +{ + "type": "process", + "name": "0.18mm Standard @Anycubic Kobra 3 Max V2 0.6 nozzle", + "inherits": "fdm_process_anycubic_kobra_3_max_v2_nozzle_0.6", + "from": "system", + "setting_id": "Eq5iPwjb3Qy7Ipct", + "instantiation": "true", + "layer_height": "0.18", + "outer_wall_line_width": "0.62", + "top_shell_layers": "5", + "top_shell_thickness": "1", + "top_surface_line_width": "0.65", + "brim_type": "no_brim", + "compatible_printers": [ + "Anycubic Kobra 3 Max V2 0.6 nozzle" + ] +} diff --git a/resources/profiles/Anycubic/process/0.20mm Standard @Anycubic Kobra 3 Max V2 0.4 nozzle.json b/resources/profiles/Anycubic/process/0.20mm Standard @Anycubic Kobra 3 Max V2 0.4 nozzle.json new file mode 100644 index 0000000000..44e723457e --- /dev/null +++ b/resources/profiles/Anycubic/process/0.20mm Standard @Anycubic Kobra 3 Max V2 0.4 nozzle.json @@ -0,0 +1,45 @@ +{ + "type": "process", + "name": "0.20mm Standard @Anycubic Kobra 3 Max V2 0.4 nozzle", + "inherits": "fdm_process_anycubic_kobra_3_max_v2_nozzle_0.4", + "from": "system", + "setting_id": "eh4cGWAXEw8zOjm8", + "instantiation": "true", + "gap_infill_speed": [ + "250" + ], + "initial_layer_speed": [ + "50" + ], + "inner_wall_acceleration": [ + "3000" + ], + "inner_wall_speed": [ + "200" + ], + "outer_wall_acceleration": [ + "1000" + ], + "outer_wall_speed": [ + "150" + ], + "sparse_infill_pattern": "grid", + "sparse_infill_speed": [ + "300" + ], + "top_shell_layers": "5", + "top_shell_thickness": "1", + "infill_anchor_max": "20", + "scarf_joint_speed": "30%", + "seam_slope_conditional": "1", + "seam_slope_inner_walls": "1", + "seam_slope_min_length": "10", + "seam_slope_start_height": "10", + "top_bottom_infill_wall_overlap": "40%", + "top_solid_infill_flow_ratio": [ + "1" + ], + "compatible_printers": [ + "Anycubic Kobra 3 Max V2 0.4 nozzle" + ] +} diff --git a/resources/profiles/Anycubic/process/0.20mm Standard @Anycubic Kobra 3 Max V2 0.8 nozzle.json b/resources/profiles/Anycubic/process/0.20mm Standard @Anycubic Kobra 3 Max V2 0.8 nozzle.json new file mode 100644 index 0000000000..8fac33e912 --- /dev/null +++ b/resources/profiles/Anycubic/process/0.20mm Standard @Anycubic Kobra 3 Max V2 0.8 nozzle.json @@ -0,0 +1,32 @@ +{ + "type": "process", + "name": "0.20mm Standard @Anycubic Kobra 3 Max V2 0.8 nozzle", + "inherits": "fdm_process_anycubic_kobra_3_max_v2_nozzle_0.8", + "from": "system", + "setting_id": "TC2cyEg58TvRDF0Q", + "instantiation": "true", + "inner_wall_speed": [ + "120" + ], + "internal_solid_infill_speed": [ + "120" + ], + "layer_height": "0.20", + "outer_wall_speed": [ + "60" + ], + "overhang_4_4_speed": [ + "5" + ], + "sparse_infill_pattern": "3dhoneycomb", + "sparse_infill_speed": [ + "100" + ], + "top_shell_thickness": "1", + "top_solid_infill_flow_ratio": [ + "1" + ], + "compatible_printers": [ + "Anycubic Kobra 3 Max V2 0.8 nozzle" + ] +} diff --git a/resources/profiles/Anycubic/process/0.24mm Standard @Anycubic Kobra 3 Max V2 0.4 nozzle.json b/resources/profiles/Anycubic/process/0.24mm Standard @Anycubic Kobra 3 Max V2 0.4 nozzle.json new file mode 100644 index 0000000000..8b5e5ff55d --- /dev/null +++ b/resources/profiles/Anycubic/process/0.24mm Standard @Anycubic Kobra 3 Max V2 0.4 nozzle.json @@ -0,0 +1,17 @@ +{ + "type": "process", + "name": "0.24mm Standard @Anycubic Kobra 3 Max V2 0.4 nozzle", + "inherits": "fdm_process_anycubic_kobra_3_max_v2_nozzle_0.4", + "from": "system", + "setting_id": "T3SbCAnNSOUAQiDb", + "instantiation": "true", + "initial_layer_print_height": "0.24", + "initial_layer_speed": [ + "50" + ], + "layer_height": "0.24", + "top_bottom_infill_wall_overlap": "40%", + "compatible_printers": [ + "Anycubic Kobra 3 Max V2 0.4 nozzle" + ] +} diff --git a/resources/profiles/Anycubic/process/0.24mm Standard @Anycubic Kobra 3 Max V2 0.6 nozzle.json b/resources/profiles/Anycubic/process/0.24mm Standard @Anycubic Kobra 3 Max V2 0.6 nozzle.json new file mode 100644 index 0000000000..e12e40f4c1 --- /dev/null +++ b/resources/profiles/Anycubic/process/0.24mm Standard @Anycubic Kobra 3 Max V2 0.6 nozzle.json @@ -0,0 +1,18 @@ +{ + "type": "process", + "name": "0.24mm Standard @Anycubic Kobra 3 Max V2 0.6 nozzle", + "inherits": "fdm_process_anycubic_kobra_3_max_v2_nozzle_0.6", + "from": "system", + "setting_id": "ksPjaBGcXzXPj3Nc", + "instantiation": "true", + "layer_height": "0.24", + "outer_wall_line_width": "0.62", + "overhang_2_4_speed": [ + "15" + ], + "top_shell_layers": "5", + "brim_type": "no_brim", + "compatible_printers": [ + "Anycubic Kobra 3 Max V2 0.6 nozzle" + ] +} diff --git a/resources/profiles/Anycubic/process/0.24mm Standard @Anycubic Kobra 3 Max V2 0.8 nozzle.json b/resources/profiles/Anycubic/process/0.24mm Standard @Anycubic Kobra 3 Max V2 0.8 nozzle.json new file mode 100644 index 0000000000..008021e0f6 --- /dev/null +++ b/resources/profiles/Anycubic/process/0.24mm Standard @Anycubic Kobra 3 Max V2 0.8 nozzle.json @@ -0,0 +1,22 @@ +{ + "type": "process", + "name": "0.24mm Standard @Anycubic Kobra 3 Max V2 0.8 nozzle", + "inherits": "fdm_process_anycubic_kobra_3_max_v2_nozzle_0.8", + "from": "system", + "setting_id": "kJt8QMAksaIzZM9N", + "instantiation": "true", + "internal_solid_infill_speed": [ + "120" + ], + "layer_height": "0.24", + "sparse_infill_speed": [ + "120" + ], + "top_shell_thickness": "1", + "top_solid_infill_flow_ratio": [ + "1" + ], + "compatible_printers": [ + "Anycubic Kobra 3 Max V2 0.8 nozzle" + ] +} diff --git a/resources/profiles/Anycubic/process/0.28mm Standard @Anycubic Kobra 3 Max V2 0.4 nozzle.json b/resources/profiles/Anycubic/process/0.28mm Standard @Anycubic Kobra 3 Max V2 0.4 nozzle.json new file mode 100644 index 0000000000..5ef9a72931 --- /dev/null +++ b/resources/profiles/Anycubic/process/0.28mm Standard @Anycubic Kobra 3 Max V2 0.4 nozzle.json @@ -0,0 +1,16 @@ +{ + "type": "process", + "name": "0.28mm Standard @Anycubic Kobra 3 Max V2 0.4 nozzle", + "inherits": "fdm_process_anycubic_kobra_3_max_v2_nozzle_0.4", + "from": "system", + "setting_id": "J8fSBSie9XucD6yS", + "instantiation": "true", + "initial_layer_print_height": "0.28", + "initial_layer_speed": [ + "50" + ], + "layer_height": "0.28", + "compatible_printers": [ + "Anycubic Kobra 3 Max V2 0.4 nozzle" + ] +} diff --git a/resources/profiles/Anycubic/process/0.30mm Standard @Anycubic Kobra 3 Max V2 0.6 nozzle.json b/resources/profiles/Anycubic/process/0.30mm Standard @Anycubic Kobra 3 Max V2 0.6 nozzle.json new file mode 100644 index 0000000000..1e4c745db4 --- /dev/null +++ b/resources/profiles/Anycubic/process/0.30mm Standard @Anycubic Kobra 3 Max V2 0.6 nozzle.json @@ -0,0 +1,17 @@ +{ + "type": "process", + "name": "0.30mm Standard @Anycubic Kobra 3 Max V2 0.6 nozzle", + "inherits": "fdm_process_anycubic_kobra_3_max_v2_nozzle_0.6", + "from": "system", + "setting_id": "Yhrz7XblYM4fpEC9", + "instantiation": "true", + "layer_height": "0.30", + "overhang_3_4_speed": [ + "15" + ], + "sparse_infill_pattern": "grid", + "top_surface_line_width": "0.7", + "compatible_printers": [ + "Anycubic Kobra 3 Max V2 0.6 nozzle" + ] +} diff --git a/resources/profiles/Anycubic/process/0.32mm Standard @Anycubic Kobra 3 Max V2 0.8 nozzle.json b/resources/profiles/Anycubic/process/0.32mm Standard @Anycubic Kobra 3 Max V2 0.8 nozzle.json new file mode 100644 index 0000000000..ceddf74d92 --- /dev/null +++ b/resources/profiles/Anycubic/process/0.32mm Standard @Anycubic Kobra 3 Max V2 0.8 nozzle.json @@ -0,0 +1,12 @@ +{ + "type": "process", + "name": "0.32mm Standard @Anycubic Kobra 3 Max V2 0.8 nozzle", + "inherits": "fdm_process_anycubic_kobra_3_max_v2_nozzle_0.8", + "from": "system", + "setting_id": "y50zgBNO9j6rqYnG", + "instantiation": "true", + "layer_height": "0.32", + "compatible_printers": [ + "Anycubic Kobra 3 Max V2 0.8 nozzle" + ] +} diff --git a/resources/profiles/Anycubic/process/0.36mm Standard @Anycubic Kobra 3 Max V2 0.6 nozzle.json b/resources/profiles/Anycubic/process/0.36mm Standard @Anycubic Kobra 3 Max V2 0.6 nozzle.json new file mode 100644 index 0000000000..1513316e89 --- /dev/null +++ b/resources/profiles/Anycubic/process/0.36mm Standard @Anycubic Kobra 3 Max V2 0.6 nozzle.json @@ -0,0 +1,13 @@ +{ + "type": "process", + "name": "0.36mm Standard @Anycubic Kobra 3 Max V2 0.6 nozzle", + "inherits": "fdm_process_anycubic_kobra_3_max_v2_nozzle_0.6", + "from": "system", + "setting_id": "xleFeNsSqb8DM4Re", + "instantiation": "true", + "layer_height": "0.36", + "brim_type": "no_brim", + "compatible_printers": [ + "Anycubic Kobra 3 Max V2 0.6 nozzle" + ] +} diff --git a/resources/profiles/Anycubic/process/0.40mm Standard @Anycubic Kobra 3 Max V2 0.8 nozzle.json b/resources/profiles/Anycubic/process/0.40mm Standard @Anycubic Kobra 3 Max V2 0.8 nozzle.json new file mode 100644 index 0000000000..fa0316e202 --- /dev/null +++ b/resources/profiles/Anycubic/process/0.40mm Standard @Anycubic Kobra 3 Max V2 0.8 nozzle.json @@ -0,0 +1,18 @@ +{ + "type": "process", + "name": "0.40mm Standard @Anycubic Kobra 3 Max V2 0.8 nozzle", + "inherits": "fdm_process_anycubic_kobra_3_max_v2_nozzle_0.8", + "from": "system", + "setting_id": "H7B3yk7GBXWPuWBi", + "instantiation": "true", + "inner_wall_speed": [ + "120" + ], + "layer_height": "0.40", + "outer_wall_speed": [ + "60" + ], + "compatible_printers": [ + "Anycubic Kobra 3 Max V2 0.8 nozzle" + ] +} diff --git a/resources/profiles/Anycubic/process/0.42mm Standard @Anycubic Kobra 3 Max V2 0.6 nozzle.json b/resources/profiles/Anycubic/process/0.42mm Standard @Anycubic Kobra 3 Max V2 0.6 nozzle.json new file mode 100644 index 0000000000..50bd1042dd --- /dev/null +++ b/resources/profiles/Anycubic/process/0.42mm Standard @Anycubic Kobra 3 Max V2 0.6 nozzle.json @@ -0,0 +1,18 @@ +{ + "type": "process", + "name": "0.42mm Standard @Anycubic Kobra 3 Max V2 0.6 nozzle", + "inherits": "fdm_process_anycubic_kobra_3_max_v2_nozzle_0.6", + "from": "system", + "setting_id": "YsBP2EfsxSpVgTQC", + "instantiation": "true", + "layer_height": "0.42", + "overhang_1_4_speed": [ + "0" + ], + "overhang_3_4_speed": [ + "20" + ], + "compatible_printers": [ + "Anycubic Kobra 3 Max V2 0.6 nozzle" + ] +} diff --git a/resources/profiles/Anycubic/process/0.48mm Standard @Anycubic Kobra 3 Max V2 0.8 nozzle.json b/resources/profiles/Anycubic/process/0.48mm Standard @Anycubic Kobra 3 Max V2 0.8 nozzle.json new file mode 100644 index 0000000000..30d1159939 --- /dev/null +++ b/resources/profiles/Anycubic/process/0.48mm Standard @Anycubic Kobra 3 Max V2 0.8 nozzle.json @@ -0,0 +1,12 @@ +{ + "type": "process", + "name": "0.48mm Standard @Anycubic Kobra 3 Max V2 0.8 nozzle", + "inherits": "fdm_process_anycubic_kobra_3_max_v2_nozzle_0.8", + "from": "system", + "setting_id": "dESXIvvvtx4sxN0X", + "instantiation": "true", + "layer_height": "0.48", + "compatible_printers": [ + "Anycubic Kobra 3 Max V2 0.8 nozzle" + ] +} diff --git a/resources/profiles/Anycubic/process/0.56mm Standard @Anycubic Kobra 3 Max V2 0.8 nozzle.json b/resources/profiles/Anycubic/process/0.56mm Standard @Anycubic Kobra 3 Max V2 0.8 nozzle.json new file mode 100644 index 0000000000..73e0e6649b --- /dev/null +++ b/resources/profiles/Anycubic/process/0.56mm Standard @Anycubic Kobra 3 Max V2 0.8 nozzle.json @@ -0,0 +1,12 @@ +{ + "type": "process", + "name": "0.56mm Standard @Anycubic Kobra 3 Max V2 0.8 nozzle", + "inherits": "fdm_process_anycubic_kobra_3_max_v2_nozzle_0.8", + "from": "system", + "setting_id": "GR5m70YPX3uKwnE1", + "instantiation": "true", + "layer_height": "0.56", + "compatible_printers": [ + "Anycubic Kobra 3 Max V2 0.8 nozzle" + ] +} diff --git a/resources/profiles/Anycubic/process/fdm_process_anycubic_kobra_3_max_v2_common.json b/resources/profiles/Anycubic/process/fdm_process_anycubic_kobra_3_max_v2_common.json new file mode 100644 index 0000000000..6a755a460f --- /dev/null +++ b/resources/profiles/Anycubic/process/fdm_process_anycubic_kobra_3_max_v2_common.json @@ -0,0 +1,108 @@ +{ + "type": "process", + "name": "fdm_process_anycubic_kobra_3_max_v2_common", + "inherits": "fdm_process_common", + "from": "system", + "instantiation": "false", + "bridge_acceleration": [ + "3000" + ], + "bridge_speed": [ + "30" + ], + "default_acceleration": [ + "5000" + ], + "default_jerk": [ + "9" + ], + "elefant_foot_compensation": "0.1", + "exclude_object": "1", + "filename_format": "{if plate_name==\"\" then input_filename_base+\"_plate\" else plate_name endif}{\"(\"+plate_number+\")\"}_{filament_type[initial_tool]}_{layer_height}_{print_time}.gcode", + "fuzzy_skin": "none", + "fuzzy_skin_point_distance": "0.8", + "fuzzy_skin_thickness": "0.3", + "gap_fill_target": "topbottom", + "gap_infill_speed": [ + "50" + ], + "infill_wall_overlap": "15%", + "initial_layer_infill_speed": [ + "100" + ], + "initial_layer_min_bead_width": "100%", + "initial_layer_speed": [ + "40" + ], + "inner_wall_acceleration": [ + "5000" + ], + "inner_wall_speed": [ + "150" + ], + "internal_solid_infill_acceleration": [ + "5000" + ], + "internal_solid_infill_pattern": "rectilinear", + "ironing_angle": "-1", + "max_volumetric_extrusion_rate_slope_segment_length": "1", + "only_one_wall_top": "1", + "outer_wall_acceleration": [ + "2000" + ], + "outer_wall_speed": [ + "60" + ], + "precise_outer_wall": "0", + "prime_tower_brim_width": "5", + "prime_tower_width": "30", + "prime_volume": "30", + "raft_first_layer_expansion": "5", + "scarf_joint_speed": "30", + "seam_slope_conditional": "1", + "seam_slope_inner_walls": "1", + "seam_slope_min_length": "10", + "slow_down_layers": "1", + "sparse_infill_acceleration": [ + "5000" + ], + "sparse_infill_pattern": "grid", + "standby_temperature_delta": "0", + "support_base_pattern": "default", + "support_interface_bottom_layers": "-1", + "support_interface_spacing": "0.2", + "support_interface_top_layers": "3", + "support_on_build_plate_only": "1", + "support_speed": [ + "100" + ], + "support_top_z_distance": "0.15", + "support_type": "tree(auto)", + "thick_internal_bridges": "0", + "top_bottom_infill_wall_overlap": "15%", + "top_shell_layers": "3", + "top_surface_acceleration": [ + "1000" + ], + "top_surface_speed": [ + "100" + ], + "travel_acceleration": [ + "10000" + ], + "travel_jerk": [ + "9" + ], + "travel_speed": [ + "300" + ], + "tree_support_branch_angle": "45", + "tree_support_branch_diameter": "2", + "tree_support_tip_diameter": "1.5", + "tree_support_top_rate": "10%", + "wall_direction": "auto", + "wall_generator": "classic", + "wall_loops": "2", + "wipe_tower_cone_angle": "15", + "wipe_tower_extra_spacing": "120%" +} diff --git a/resources/profiles/Anycubic/process/fdm_process_anycubic_kobra_3_max_v2_nozzle_0.25.json b/resources/profiles/Anycubic/process/fdm_process_anycubic_kobra_3_max_v2_nozzle_0.25.json new file mode 100644 index 0000000000..f2e43db401 --- /dev/null +++ b/resources/profiles/Anycubic/process/fdm_process_anycubic_kobra_3_max_v2_nozzle_0.25.json @@ -0,0 +1,40 @@ +{ + "type": "process", + "name": "fdm_process_anycubic_kobra_3_max_v2_nozzle_0.25", + "inherits": "fdm_process_anycubic_kobra_3_max_v2_common", + "from": "system", + "instantiation": "false", + "bottom_shell_layers": "5", + "bottom_surface_pattern": "monotonicline", + "filename_format": "{timestamp}-{if plate_name==\"\" then input_filename_base+\"_plate\" else plate_name endif}{\"(\"+plate_number+\")\"}_{filament_type[initial_tool]}_{layer_height}_{print_time}.gcode", + "gap_infill_speed": [ + "100" + ], + "initial_layer_line_width": "0.3", + "initial_layer_print_height": "0.15", + "initial_layer_speed": [ + "50" + ], + "inner_wall_acceleration": [ + "3000" + ], + "inner_wall_line_width": "0.3", + "inner_wall_speed": [ + "120" + ], + "internal_solid_infill_line_width": "0.27", + "line_width": "0.27", + "outer_wall_acceleration": [ + "1000" + ], + "outer_wall_line_width": "0.27", + "scarf_joint_speed": "30%", + "seam_slope_start_height": "10", + "sparse_infill_line_width": "0.3", + "support_line_width": "0.27", + "top_bottom_infill_wall_overlap": "40%", + "top_shell_layers": "7", + "top_surface_line_width": "0.27", + "wall_loops": "4", + "wipe_tower_wall_type": "rectangle" +} diff --git a/resources/profiles/Anycubic/process/fdm_process_anycubic_kobra_3_max_v2_nozzle_0.4.json b/resources/profiles/Anycubic/process/fdm_process_anycubic_kobra_3_max_v2_nozzle_0.4.json new file mode 100644 index 0000000000..ad9be22706 --- /dev/null +++ b/resources/profiles/Anycubic/process/fdm_process_anycubic_kobra_3_max_v2_nozzle_0.4.json @@ -0,0 +1,32 @@ +{ + "type": "process", + "name": "fdm_process_anycubic_kobra_3_max_v2_nozzle_0.4", + "inherits": "fdm_process_anycubic_kobra_3_max_v2_common", + "from": "system", + "instantiation": "false", + "bottom_surface_pattern": "monotonicline", + "bridge_flow": "0.9", + "gap_infill_speed": [ + "150" + ], + "infill_anchor_max": "10", + "internal_solid_infill_line_width": "0.42", + "line_width": "0.42", + "outer_wall_line_width": "0.42", + "outer_wall_speed": [ + "140" + ], + "scarf_joint_speed": "100%", + "seam_slope_conditional": "0", + "seam_slope_inner_walls": "0", + "seam_slope_min_length": "20", + "sparse_infill_pattern": "rectilinear", + "support_line_width": "0.42", + "top_bottom_infill_wall_overlap": "25%", + "top_shell_layers": "4", + "top_shell_thickness": "0", + "top_solid_infill_flow_ratio": [ + "0.96" + ], + "top_surface_line_width": "0.42" +} diff --git a/resources/profiles/Anycubic/process/fdm_process_anycubic_kobra_3_max_v2_nozzle_0.6.json b/resources/profiles/Anycubic/process/fdm_process_anycubic_kobra_3_max_v2_nozzle_0.6.json new file mode 100644 index 0000000000..e2d2a54de8 --- /dev/null +++ b/resources/profiles/Anycubic/process/fdm_process_anycubic_kobra_3_max_v2_nozzle_0.6.json @@ -0,0 +1,59 @@ +{ + "type": "process", + "name": "fdm_process_anycubic_kobra_3_max_v2_nozzle_0.6", + "inherits": "fdm_process_anycubic_kobra_3_max_v2_common", + "from": "system", + "instantiation": "false", + "bridge_no_support": "1", + "detect_thin_wall": "1", + "extra_perimeters_on_overhangs": "1", + "infill_wall_overlap": "80%", + "initial_layer_acceleration": [ + "5000" + ], + "initial_layer_infill_speed": [ + "50" + ], + "initial_layer_line_width": "0.62", + "initial_layer_print_height": "0.3", + "inner_wall_line_width": "0.62", + "internal_solid_infill_line_width": "0.62", + "line_width": "0.62", + "outer_wall_line_width": "0.7", + "overhang_1_4_speed": [ + "50" + ], + "overhang_2_4_speed": [ + "25" + ], + "overhang_3_4_speed": [ + "10" + ], + "prime_tower_width": "35", + "prime_volume": "20", + "raft_first_layer_density": "100%", + "seam_slope_inner_walls": "0", + "seam_slope_start_height": "10%", + "sparse_infill_line_width": "0.62", + "sparse_infill_pattern": "3dhoneycomb", + "sparse_infill_speed": [ + "100" + ], + "standby_temperature_delta": "-5", + "support_interface_spacing": "0.5", + "support_interface_top_layers": "2", + "support_line_width": "0.62", + "support_on_build_plate_only": "0", + "support_top_z_distance": "0.2", + "top_surface_acceleration": [ + "4000" + ], + "top_surface_line_width": "0.62", + "top_surface_speed": [ + "150" + ], + "travel_acceleration": [ + "5000" + ], + "tree_support_tip_diameter": "0.8" +} diff --git a/resources/profiles/Anycubic/process/fdm_process_anycubic_kobra_3_max_v2_nozzle_0.8.json b/resources/profiles/Anycubic/process/fdm_process_anycubic_kobra_3_max_v2_nozzle_0.8.json new file mode 100644 index 0000000000..9233f32d6c --- /dev/null +++ b/resources/profiles/Anycubic/process/fdm_process_anycubic_kobra_3_max_v2_nozzle_0.8.json @@ -0,0 +1,35 @@ +{ + "type": "process", + "name": "fdm_process_anycubic_kobra_3_max_v2_nozzle_0.8", + "inherits": "fdm_process_anycubic_kobra_3_max_v2_common", + "from": "system", + "instantiation": "false", + "bridge_no_support": "1", + "detect_thin_wall": "1", + "extra_perimeters_on_overhangs": "1", + "initial_layer_infill_speed": [ + "40" + ], + "initial_layer_line_width": "0.82", + "initial_layer_print_height": "0.4", + "inner_wall_line_width": "0.82", + "internal_solid_infill_line_width": "0.82", + "line_width": "0.82", + "outer_wall_line_width": "0.82", + "outer_wall_speed": [ + "120" + ], + "overhang_2_4_speed": [ + "40" + ], + "overhang_3_4_speed": [ + "15" + ], + "seam_slope_start_height": "10%", + "sparse_infill_line_width": "0.82", + "support_line_width": "0.82", + "top_solid_infill_flow_ratio": [ + "0.96" + ], + "top_surface_line_width": "0.82" +} diff --git a/resources/web/dialog/ColorPickerDialog/colorpicker.js b/resources/web/dialog/ColorPickerDialog/colorpicker.js index b812ffb784..35e7cc33e8 100644 --- a/resources/web/dialog/ColorPickerDialog/colorpicker.js +++ b/resources/web/dialog/ColorPickerDialog/colorpicker.js @@ -73,7 +73,9 @@ const width = Math.min(1200, Math.max(300, Math.ceil(rect.width ))); if (height !== lastContentHeight || width !== lastContentWidth) { lastContentHeight = height; lastContentWidth = width; - emit("resize", {width, height}); + // viewport: the host compares it with the WebView's real width to learn the page zoom + // (WebKitGTK zooms pages by the system text scaling), so it can convert CSS px to window px. + emit("resize", {width, height, viewport: window.innerWidth}); } }); } diff --git a/scripts/flatpak/com.orcaslicer.OrcaSlicer.yml b/scripts/flatpak/com.orcaslicer.OrcaSlicer.yml index c803c48cf8..ecf54cc66a 100644 --- a/scripts/flatpak/com.orcaslicer.OrcaSlicer.yml +++ b/scripts/flatpak/com.orcaslicer.OrcaSlicer.yml @@ -119,10 +119,10 @@ modules: # submodules (PCRE2, etc.) that are not included in GitHub tarballs. - type: git url: https://github.com/OrcaSlicer/Orca-deps-wxWidgets.git - # flatpak-builder requires a named branch's tip to be the pinned commit, so this names no - # branch and clones in full, which git needs to check out a commit that is not a tip. + # No branch and no tag: flatpak-builder checks that a named branch's tip is the pinned + # commit, which fails once the fork's branch moves past it. With the commit alone it + # fetches as much history as the commit needs on its own. commit: 89844cb1f80b17a5916d5274cd88317cac3e2a3c - disable-shallow-clone: true # OrcaSlicer C++ dependencies (built offline with pre-downloaded archives) - name: orca_deps diff --git a/scripts/linux.d/fedora b/scripts/linux.d/fedora index ff65705f37..06379b5932 100644 --- a/scripts/linux.d/fedora +++ b/scripts/linux.d/fedora @@ -26,6 +26,8 @@ REQUIRED_DEV_PACKAGES=( ninja-build openssl-devel perl-FindBin + perl-IPC-Cmd + perl-Time-Piece texinfo wayland-protocols-devel webkit2gtk4.1-devel diff --git a/src/libslic3r/ExtrusionEntity.hpp b/src/libslic3r/ExtrusionEntity.hpp index 9df77a0cc7..271705af4f 100644 --- a/src/libslic3r/ExtrusionEntity.hpp +++ b/src/libslic3r/ExtrusionEntity.hpp @@ -9,6 +9,7 @@ #include #include #include +#include #include #include #include @@ -473,6 +474,13 @@ public: // nothing to lean on until this layer is bridged, so the G-code writer holds it back until the // infill is down. See defer_unsupported_loops() in PerimeterGenerator.cpp. bool print_after_infill = false; + // ORCA: The centerline of this loop before surface texturing (fuzzy skin), or null. The perimeter generator sets + // it on an external loop whose points the texture changed; Precise Seam reconstructs the model surface from it. + // Copying, moving, reversing or turning the start of the same geometry keeps it, and so does simplifying or + // arc fitting the paths: that is still the same textured loop. Giving the loop other geometry must reset it. + // Kept whether or not Precise Seam is used, since adding its helpers does not regenerate perimeters. The + // storage could be optimized later. + std::shared_ptr untextured; ExtrusionLoop(ExtrusionLoopRole role = elrDefault) : m_loop_role(role) {} ExtrusionLoop(const ExtrusionPaths &paths, ExtrusionLoopRole role = elrDefault) : paths(paths), m_loop_role(role) {} diff --git a/src/libslic3r/FilamentMixer.hpp b/src/libslic3r/FilamentMixer.hpp index 39707aec4e..aedbf981d8 100644 --- a/src/libslic3r/FilamentMixer.hpp +++ b/src/libslic3r/FilamentMixer.hpp @@ -13,6 +13,36 @@ namespace Slic3r { class ConfigBase; +inline constexpr const char *feature_filament_keys[] = { + "outer_wall_filament_id", "inner_wall_filament_id", "sparse_infill_filament_id", + "internal_solid_filament_id", "top_surface_filament_id", "bottom_surface_filament_id" +}; + +// Config values are one-based (0 inherits). The map uses zero-based slots, with -1 for a removed slot. +template +bool remap_filament_option(Config &config, const char *key, const std::map &slots) +{ + if (!config.has(key)) + return false; + const int slot = config.opt_int(key); + if (slot <= 0) + return false; + const auto it = slots.find(slot - 1); + if (it == slots.end() || it->second + 1 == slot) + return false; + config.set(key, it->second + 1); + return true; +} + +template +bool remap_feature_filaments(Config &config, const std::map &slots) +{ + bool changed = false; + for (const char *key : feature_filament_keys) + changed |= remap_filament_option(config, key, slots); + return changed; +} + // Photoshop-style gradient curve control point in [0,1] x [0,1]. // (x, y) is the anchor position; (m_in, m_out) are optional cubic Hermite tangent // overrides. NaN means "use the PCHIP-computed default", which is the case for plain diff --git a/src/libslic3r/Format/objparser.cpp b/src/libslic3r/Format/objparser.cpp index 5146a21e80..caac6b23ac 100644 --- a/src/libslic3r/Format/objparser.cpp +++ b/src/libslic3r/Format/objparser.cpp @@ -46,14 +46,14 @@ static bool obj_parseline(const char *line, ObjData &data) return false; EATWS(); char *endptr = 0; - double u = strtod(line, &endptr); + double u = Slic3r::strtod_decimal_point(line, &endptr); if (endptr == 0 || (*endptr != ' ' && *endptr != '\t')) return false; line = endptr; EATWS(); double v = 0; if (*line != 0) { - v = strtod(line, &endptr); + v = Slic3r::strtod_decimal_point(line, &endptr); if (endptr == 0 || (*endptr != ' ' && *endptr != '\t' && *endptr != 0)) return false; line = endptr; @@ -61,7 +61,7 @@ static bool obj_parseline(const char *line, ObjData &data) } // The optional w is accepted but not stored: only u and v are used. if (*line != 0) { - strtod(line, &endptr); + Slic3r::strtod_decimal_point(line, &endptr); if (endptr == 0 || (*endptr != ' ' && *endptr != '\t' && *endptr != 0)) return false; line = endptr; @@ -82,17 +82,17 @@ static bool obj_parseline(const char *line, ObjData &data) return false; EATWS(); char *endptr = 0; - double x = strtod(line, &endptr); + double x = Slic3r::strtod_decimal_point(line, &endptr); if (endptr == 0 || (*endptr != ' ' && *endptr != '\t')) return false; line = endptr; EATWS(); - double y = strtod(line, &endptr); + double y = Slic3r::strtod_decimal_point(line, &endptr); if (endptr == 0 || (*endptr != ' ' && *endptr != '\t')) return false; line = endptr; EATWS(); - double z = strtod(line, &endptr); + double z = Slic3r::strtod_decimal_point(line, &endptr); if (endptr == 0 || (*endptr != ' ' && *endptr != '\t' && *endptr != 0)) return false; line = endptr; @@ -112,19 +112,19 @@ static bool obj_parseline(const char *line, ObjData &data) return false; EATWS(); char *endptr = 0; - double u = strtod(line, &endptr); + double u = Slic3r::strtod_decimal_point(line, &endptr); if (endptr == 0 || (*endptr != ' ' && *endptr != '\t' && *endptr != 0)) return false; line = endptr; EATWS(); - double v = strtod(line, &endptr); + double v = Slic3r::strtod_decimal_point(line, &endptr); if (endptr == 0 || (*endptr != ' ' && *endptr != '\t' && *endptr != 0)) return false; line = endptr; EATWS(); double w = 0; if (*line != 0) { - w = strtod(line, &endptr); + w = Slic3r::strtod_decimal_point(line, &endptr); if (endptr == 0 || (*endptr != ' ' && *endptr != '\t' && *endptr != 0)) return false; line = endptr; @@ -144,17 +144,17 @@ static bool obj_parseline(const char *line, ObjData &data) return false; EATWS(); char *endptr = 0; - double x = strtod(line, &endptr); + double x = Slic3r::strtod_decimal_point(line, &endptr); if (endptr == 0 || (*endptr != ' ' && *endptr != '\t')) return false; line = endptr; EATWS(); - double y = strtod(line, &endptr); + double y = Slic3r::strtod_decimal_point(line, &endptr); if (endptr == 0 || (*endptr != ' ' && *endptr != '\t')) return false; line = endptr; EATWS(); - double z = strtod(line, &endptr); + double z = Slic3r::strtod_decimal_point(line, &endptr); if (endptr == 0 || (*endptr != ' ' && *endptr != '\t' && *endptr != 0)) return false; line = endptr; @@ -164,24 +164,24 @@ static bool obj_parseline(const char *line, ObjData &data) if (!data.has_vertex_color) { data.has_vertex_color = true; } - color_x = strtod(line, &endptr); + color_x = Slic3r::strtod_decimal_point(line, &endptr); if (endptr == 0 || (*endptr != ' ' && *endptr != '\t' && *endptr != 0)) return false; line = endptr; EATWS(); - color_y = strtod(line, &endptr); + color_y = Slic3r::strtod_decimal_point(line, &endptr); if (endptr == 0 || (*endptr != ' ' && *endptr != '\t' && *endptr != 0)) return false; line = endptr; EATWS(); - color_z = strtod(line, &endptr); + color_z = Slic3r::strtod_decimal_point(line, &endptr); if (endptr == 0 || (*endptr != ' ' && *endptr != '\t' && *endptr != 0)) return false; line = endptr; EATWS(); color_w = 1.0;//default define alpha = 1.0 if (*line != 0) { - color_w = strtod(line, &endptr); + color_w = Slic3r::strtod_decimal_point(line, &endptr); if (endptr == 0 || (*endptr != ' ' && *endptr != '\t' && *endptr != 0)) return false; line = endptr; EATWS(); @@ -418,7 +418,7 @@ static bool mtl_skip_numeric_token(const char *&line) if (*begin == 0) return false; char *endptr = 0; - strtod(begin, &endptr); + Slic3r::strtod_decimal_point(begin, &endptr); if (endptr == begin || (!mtl_is_space(*endptr) && *endptr != 0)) return false; line = mtl_skip_ws(endptr); @@ -515,14 +515,14 @@ static bool mtl_parseline(const char *line, MtlData &data) if (cur_char == 's') { EATWS(); char * endptr = 0; - double ns = strtod(line, &endptr); + double ns = Slic3r::strtod_decimal_point(line, &endptr); if (data.new_mtl_unmap.find(cur_mtl_name) != data.new_mtl_unmap.end()) { data.new_mtl_unmap[cur_mtl_name]->Ns = (float) ns; } } else if (cur_char == 'i') { EATWS(); char * endptr = 0; - double ni = strtod(line, &endptr); + double ni = Slic3r::strtod_decimal_point(line, &endptr); if (data.new_mtl_unmap.find(cur_mtl_name) != data.new_mtl_unmap.end()) { data.new_mtl_unmap[cur_mtl_name]->Ni = (float) ni; } @@ -534,15 +534,15 @@ static bool mtl_parseline(const char *line, MtlData &data) if (cur_char == 'a') { EATWS(); char * endptr = 0; - double x = strtod(line, &endptr); + double x = Slic3r::strtod_decimal_point(line, &endptr); if (endptr == 0 || (*endptr != ' ' && *endptr != '\t')) return false; line = endptr; EATWS(); - double y = strtod(line, &endptr); + double y = Slic3r::strtod_decimal_point(line, &endptr); if (endptr == 0 || (*endptr != ' ' && *endptr != '\t')) return false; line = endptr; EATWS(); - double z = strtod(line, &endptr); + double z = Slic3r::strtod_decimal_point(line, &endptr); if (endptr == 0 || (*endptr != ' ' && *endptr != '\t' && *endptr != 0)) return false; line = endptr; EATWS(); @@ -554,15 +554,15 @@ static bool mtl_parseline(const char *line, MtlData &data) } else if (cur_char == 'd') { EATWS(); char * endptr = 0; - double x = strtod(line, &endptr); + double x = Slic3r::strtod_decimal_point(line, &endptr); if (endptr == 0 || (*endptr != ' ' && *endptr != '\t')) return false; line = endptr; EATWS(); - double y = strtod(line, &endptr); + double y = Slic3r::strtod_decimal_point(line, &endptr); if (endptr == 0 || (*endptr != ' ' && *endptr != '\t')) return false; line = endptr; EATWS(); - double z = strtod(line, &endptr); + double z = Slic3r::strtod_decimal_point(line, &endptr); if (endptr == 0 || (*endptr != ' ' && *endptr != '\t' && *endptr != 0)) return false; line = endptr; EATWS(); @@ -574,15 +574,15 @@ static bool mtl_parseline(const char *line, MtlData &data) } else if (cur_char == 's') { EATWS(); char * endptr = 0; - double x = strtod(line, &endptr); + double x = Slic3r::strtod_decimal_point(line, &endptr); if (endptr == 0 || (*endptr != ' ' && *endptr != '\t')) return false; line = endptr; EATWS(); - double y = strtod(line, &endptr); + double y = Slic3r::strtod_decimal_point(line, &endptr); if (endptr == 0 || (*endptr != ' ' && *endptr != '\t')) return false; line = endptr; EATWS(); - double z = strtod(line, &endptr); + double z = Slic3r::strtod_decimal_point(line, &endptr); if (endptr == 0 || (*endptr != ' ' && *endptr != '\t' && *endptr != 0)) return false; line = endptr; EATWS(); @@ -594,15 +594,15 @@ static bool mtl_parseline(const char *line, MtlData &data) } else if (cur_char == 'e') { EATWS(); char * endptr = 0; - double x = strtod(line, &endptr); + double x = Slic3r::strtod_decimal_point(line, &endptr); if (endptr == 0 || (*endptr != ' ' && *endptr != '\t')) return false; line = endptr; EATWS(); - double y = strtod(line, &endptr); + double y = Slic3r::strtod_decimal_point(line, &endptr); if (endptr == 0 || (*endptr != ' ' && *endptr != '\t')) return false; line = endptr; EATWS(); - double z = strtod(line, &endptr); + double z = Slic3r::strtod_decimal_point(line, &endptr); if (endptr == 0 || (*endptr != ' ' && *endptr != '\t' && *endptr != 0)) return false; line = endptr; EATWS(); @@ -619,7 +619,7 @@ static bool mtl_parseline(const char *line, MtlData &data) return false; EATWS(); char * endptr = 0; - double illum = strtod(line, &endptr); + double illum = Slic3r::strtod_decimal_point(line, &endptr); if (data.new_mtl_unmap.find(cur_mtl_name) != data.new_mtl_unmap.end()) { data.new_mtl_unmap[cur_mtl_name]->illum = (float) illum; } @@ -628,7 +628,7 @@ static bool mtl_parseline(const char *line, MtlData &data) case 'd': { EATWS(); char * endptr = 0; - double d = strtod(line, &endptr); + double d = Slic3r::strtod_decimal_point(line, &endptr); if (data.new_mtl_unmap.find(cur_mtl_name) != data.new_mtl_unmap.end()) { data.new_mtl_unmap[cur_mtl_name]->d = (float) d; } @@ -639,7 +639,7 @@ static bool mtl_parseline(const char *line, MtlData &data) if (cur_char == 'r') { EATWS(); char * endptr = 0; - double tr = strtod(line, &endptr); + double tr = Slic3r::strtod_decimal_point(line, &endptr); if (data.new_mtl_unmap.find(cur_mtl_name) != data.new_mtl_unmap.end()) { data.new_mtl_unmap[cur_mtl_name]->Tr = (float) tr; } @@ -647,15 +647,15 @@ static bool mtl_parseline(const char *line, MtlData &data) } else if (cur_char == 'f') { EATWS(); char * endptr = 0; - double x = strtod(line, &endptr); + double x = Slic3r::strtod_decimal_point(line, &endptr); if (endptr == 0 || (*endptr != ' ' && *endptr != '\t')) return false; line = endptr; EATWS(); - double y = strtod(line, &endptr); + double y = Slic3r::strtod_decimal_point(line, &endptr); if (endptr == 0 || (*endptr != ' ' && *endptr != '\t')) return false; line = endptr; EATWS(); - double z = strtod(line, &endptr); + double z = Slic3r::strtod_decimal_point(line, &endptr); if (endptr == 0 || (*endptr != ' ' && *endptr != '\t' && *endptr != 0)) return false; line = endptr; EATWS(); diff --git a/src/libslic3r/GCode/PreciseSeam.cpp b/src/libslic3r/GCode/PreciseSeam.cpp index 7c053bde09..5fb9a14248 100644 --- a/src/libslic3r/GCode/PreciseSeam.cpp +++ b/src/libslic3r/GCode/PreciseSeam.cpp @@ -1,6 +1,7 @@ // Precise Seam implementation. Design: docs/HLSD/precise-seam.md #include "PreciseSeam.hpp" #include "PreciseSeamInternal.hpp" +#include "libslic3r/AABBTreeLines.hpp" #include "libslic3r/Polygon.hpp" #include "libslic3r/Polyline.hpp" #include "libslic3r/Point.hpp" @@ -11,14 +12,21 @@ #include "libslic3r/ClipperUtils.hpp" #include "libslic3r/Layer.hpp" #include "libslic3r/Print.hpp" +#include "libslic3r/PrintConfig.hpp" +#include "libslic3r/PerimeterGenerator.hpp" +#include "libslic3r/Feature/FuzzySkin/FuzzySkin.hpp" #include #include +#include #include #include #include #include +#include #include #include +#include +#include #include #include #include @@ -46,7 +54,8 @@ ModifierSlices prepare_modifier_slices(std::vector slices) return cached; } -PreparedPerimeter::PreparedPerimeter(const Polygon &perimeter) : polygon(perimeter) +PreparedPerimeter::PreparedPerimeter(const Polygon &perimeter, coord_t surface_shift, bool is_hole) + : polygon(perimeter), shift(surface_shift), hole(is_hole) { const size_t count = polygon.size(); if (count < 3) @@ -62,6 +71,19 @@ PreparedPerimeter::PreparedPerimeter(const Polygon &perimeter) : polygon(perimet valid = true; } +PreparedPerimeter::~PreparedPerimeter() = default; + +void PreparedPerimeter::set_target(const Polygon &noisy, coord_t noise_window) +{ + target = &noisy; + window = noise_window; + const size_t count = noisy.size(); + bool usable = count >= 3; + for (size_t edge = 0; usable && edge < count; ++edge) + usable = noisy.points[edge] != noisy.points[(edge + 1) % count]; + valid = valid && usable; +} + // Import EnforcedBlockedSeamPoint from SeamPlacerImpl namespace for convenience using SeamPlacerImpl::EnforcedBlockedSeamPoint; @@ -74,6 +96,102 @@ static constexpr double MACHINE_PRECISION_SQUARED = 2.5; static constexpr coord_t TOLERANCE_LINEAR = 1000; static constexpr coord_t TOLERANCE_SQUARED = TOLERANCE_LINEAR * TOLERANCE_LINEAR; +// The surface is reconstructed this much inside the model surface, so a modifier face placed flush against +// a model face stays clear of it on every layer instead of touching it by rounding noise. +static constexpr coord_t SURFACE_MARGIN = 5 * TOLERANCE_LINEAR; +// Maximum sagitta of the chords that approximate the surface arcs around convex vertices, in units. +static constexpr double SURFACE_ARC_SAGITTA = 40.; + +coord_t surface_shift(double line_width, double compensation) +{ + const double shift = scale_(0.5 * line_width - compensation) - double(SURFACE_MARGIN); + // A shift within the snapping radius cannot change what insertion produces: keep the centerline path. + return shift > double(TOLERANCE_LINEAR) ? coord_t(std::lround(shift)) : 0; +} + +// Spacing of the measurements along a long edge: the step at which elephant foot compensation is resampled. +static constexpr double SHIFT_SAMPLING_STEP = 0.5; + +ShiftProfile measure_shift_profile(const Polygon &perimeter, bool hole, const ShiftMeasurement &measurement) +{ + const double nominal = scale_(0.5 * measurement.line_width - measurement.compensation) - double(SURFACE_MARGIN); + const double correction = scale_(measurement.outline_compensation) + double(SURFACE_MARGIN); + const double min_depth = scale_(measurement.min_depth); + const double max_depth = scale_(measurement.max_depth); + // Normals towards air, as the surface line takes them. + const size_t count = perimeter.size(); + const double side = (hole ? -1. : 1.) * (perimeter.is_counter_clockwise() ? 1. : -1.); + std::vector normals(count); + for (size_t i = 0; i < count; ++i) { + const Vec2d direction = (perimeter[(i + 1) % count] - perimeter[i]).cast(); + normals[i] = side * Vec2d(direction.y(), -direction.x()) / direction.norm(); + } + // The depth along the normals: the distance to the nearest outline point would be the corner's at an inner + // corner, deeper than either side. A point not inside the material (signed distance not negative) is not measured. + const auto shift_at = [&](const Point &point, const Vec2d &before, const Vec2d &after) { + const auto [distance, line, nearest] = measurement.outline.distance_from_lines_extra(point); + const Vec2d offset = nearest - point.cast(); + const double depth = distance < 0. ? std::max(offset.dot(before), offset.dot(after)) : -1.; + const double shift = depth >= min_depth && depth <= max_depth ? depth - correction : nominal; + return coord_t(std::lround(std::max(0., shift))); + }; + const coord_t nominal_shift = coord_t(std::lround(std::max(0., nominal))); + const auto same = [](double a, double b) { return std::abs(a - b) <= double(TOLERANCE_LINEAR); }; + + ShiftProfile profile; + profile.vertices.reserve(count); + bool nominal_everywhere = true; + for (size_t i = 0; i < count; ++i) { + profile.vertices.push_back(shift_at(perimeter[i], normals[(i + count - 1) % count], normals[i])); + nominal_everywhere = nominal_everywhere && same(double(profile.vertices.back()), double(nominal_shift)); + } + // A long edge is measured in between as well. If every value there follows the line between its vertices, the + // edge stays one part; otherwise all of them split it. + const double step = scale_(SHIFT_SAMPLING_STEP); + profile.interior.resize(count); + bool split = false; + for (size_t i = 0; i < count; ++i) { + const size_t next = (i + 1) % count; + const Vec2d a = perimeter[i].cast(); + const Vec2d edge = perimeter[next].cast() - a; + const size_t intervals = size_t(std::ceil(edge.norm() / step)); + bool linear = true; + std::vector> samples; + for (size_t k = 1; k < intervals; ++k) { + const double t = double(k) / double(intervals); + const Vec2d at = a + t * edge; + const coord_t value = shift_at(Point(coord_t(std::lround(at.x())), coord_t(std::lround(at.y()))), normals[i], normals[i]); + linear = linear && same(double(value), (1. - t) * double(profile.vertices[i]) + t * double(profile.vertices[next])); + samples.emplace_back(t, value); + } + if (!linear) { + profile.interior[i] = std::move(samples); + split = true; + } + } + if (nominal_everywhere && !split) + return {}; + if (!split) + profile.interior.clear(); + return profile; +} + +PreparedPerimeter::PreparedPerimeter(const Polygon &perimeter, ShiftProfile shift_profile, bool is_hole) + : PreparedPerimeter(perimeter, coord_t(0), is_hole) +{ + coord_t largest = 0; + for (const coord_t value : shift_profile.vertices) + largest = std::max(largest, value); + for (const auto &edge : shift_profile.interior) + for (const auto &sample : edge) + largest = std::max(largest, sample.second); + // Same snapping as surface_shift(): a surface this close cannot change what insertion produces. + if (largest <= TOLERANCE_LINEAR) + return; + shift = largest; + profile = std::move(shift_profile); +} + namespace detail { // Use the existing clipping tolerance only to recover rounded coordinates, not to @@ -363,10 +481,476 @@ bool append_fragment(const Polyline &fragment, const Polygon &perimeter, << " perimeter_points=" << perimeter.size(); return false; } + +void cover_centerline(const Polygon &perimeter, CenterlinePoint from, const CenterlinePoint &to, + std::vector &intervals) +{ + const size_t count = perimeter.size(); + if (from.edge == to.edge && from.parameter > to.parameter) + return; + for (size_t steps = 0; steps <= count; ++steps) { + if (from.edge == to.edge && from.parameter <= to.parameter) { + if (from.parameter < to.parameter) + intervals.push_back({from.edge, from.parameter, to.parameter, from.point, to.point}); + return; + } + const size_t next = (from.edge + 1) % count; + if (from.parameter < 1.) + intervals.push_back({from.edge, from.parameter, 1., from.point, perimeter[next]}); + from = {next, 0., perimeter[next]}; + } +} + +SurfaceLine build_surface_line(const Polygon &perimeter, coord_t shift, bool hole) +{ + ShiftProfile profile; + profile.vertices.assign(perimeter.size(), shift); + return build_surface_line(perimeter, profile, hole); +} + +SurfaceLine build_surface_line(const Polygon &perimeter, const ShiftProfile &profile, bool hole) +{ + SurfaceLine surface; + const size_t count = perimeter.size(); + assert(profile.vertices.size() == count); + assert(profile.interior.empty() || profile.interior.size() == count); + // Air lies to the right of a counter-clockwise contour and to the left of a counter-clockwise hole; + // a clockwise input swaps the sides. + const bool ccw = perimeter.is_counter_clockwise(); + const double side = (hole ? -1. : 1.) * (ccw ? 1. : -1.); + const auto round_point = [](const Vec2d &p) { return Point(coord_t(std::lround(p.x())), coord_t(std::lround(p.y()))); }; + const auto cross = [](const Vec2d &a, const Vec2d &b) { return a.x() * b.y() - a.y() * b.x(); }; + std::vector normals(count); + for (size_t i = 0; i < count; ++i) { + const Vec2d direction = (perimeter[(i + 1) % count] - perimeter[i]).cast(); + normals[i] = side * Vec2d(direction.y(), -direction.x()) / direction.norm(); + } + + // Every shifted edge is a chain of straight parts between the points where its shift is given: from the edge's + // start vertex through the interior samples to its end vertex, each point moved along the edge's normal. + // A part maps linearly onto its range of parameters on the source edge. + struct Part { + double begin; + double end; + Point a; + Point b; + }; + std::vector parts; + std::vector first_part(count + 1); + surface.shifts.assign(count, Point(0, 0)); + surface.translated.assign(count, false); + for (size_t i = 0; i < count; ++i) { + const size_t next = (i + 1) % count; + first_part[i] = parts.size(); + const bool interior = !profile.interior.empty() && !profile.interior[i].empty(); + Point from = perimeter[i] + round_point(double(profile.vertices[i]) * normals[i]); + double begin = 0.; + if (interior) + for (const auto &[parameter, value] : profile.interior[i]) { + const Vec2d at = perimeter[i].cast() + parameter * (perimeter[next] - perimeter[i]).cast(); + const Point to = round_point(at + double(value) * normals[i]); + parts.push_back({begin, parameter, from, to}); + from = to; + begin = parameter; + } + parts.push_back({begin, 1., from, perimeter[next] + round_point(double(profile.vertices[next]) * normals[i])}); + // One rounded shift for a constant edge keeps its shifted edge an exact translate of the source edge. + if (!interior && profile.vertices[i] == profile.vertices[next]) { + surface.shifts[i] = round_point(double(profile.vertices[i]) * normals[i]); + surface.translated[i] = true; + } + } + first_part[count] = parts.size(); + const auto last_part = [&first_part](size_t edge) { return first_part[edge + 1] - 1; }; + const auto direction = [&parts](size_t part) -> Vec2d { return (parts[part].b - parts[part].a).cast(); }; + + // A concave corner whose shifted edges cross within both of the parts meeting there is resolved exactly: the + // shifted edges end at the crossing K, with no tails and no bridge, and the dead stretch around the vertex is + // known at once. The trims of both corners of one part must leave a piece of it, so a fillet finer than the + // shift keeps its tails and bridges. A candidate counts against its neighbours even when it is not resolved + // itself. + std::vector end_at(count, 1.); // Per vertex: fraction of the part before it where that part ends. + std::vector start_at(count, 0.); // Per vertex: fraction of the part after it where that part starts. + std::vector candidate(count, false); + std::vector crossing(count); + for (size_t v = 0; v < count; ++v) { + const size_t before = (v + count - 1) % count; + const Vec2d into = direction(last_part(before)); + const Vec2d out = direction(first_part[v]); + const double turn = cross(normals[before], normals[v]); + const double denominator = cross(into, out); + if (side * turn >= 0. || denominator == 0.) + continue; // Convex, collinear or a reversal. + const Vec2d a = parts[last_part(before)].a.cast(); + const Vec2d offset = parts[first_part[v]].a.cast() - a; + end_at[v] = cross(offset, out) / denominator; + start_at[v] = cross(offset, into) / denominator; + crossing[v] = a + end_at[v] * into; + candidate[v] = end_at[v] > 0. && end_at[v] < 1. && start_at[v] > 0. && start_at[v] < 1.; + } + // A trimmed part keeps at least this many units, so its rounded ends stay distinct. The far corner trims the + // same part only when the edge is a single part. + const double min_part = 4.; + const auto single = [&](size_t edge) { return first_part[edge] == last_part(edge); }; + std::vector resolved(count, false); + for (size_t v = 0; v < count; ++v) { + const size_t before = (v + count - 1) % count; + const size_t after = (v + 1) % count; + resolved[v] = candidate[v] && + (end_at[v] - (single(before) && candidate[before] ? start_at[before] : 0.)) * + direction(last_part(before)).norm() > min_part && + ((single(v) && candidate[after] ? end_at[after] : 1.) - start_at[v]) * + direction(first_part[v]).norm() > min_part; + } + + Points &points = surface.polygon.points; + std::vector first_element(count, size_t(-1)); + std::vector last_element(count, size_t(-1)); + // A point equal to the previous one ends a zero-length element: the new element replaces it. + const auto push = [&](const Point &point, SurfaceElement element) { + if (!points.empty() && points.back() == point) { + surface.elements.back() = element; + return; + } + points.push_back(point); + surface.elements.push_back(element); + }; + for (size_t i = 0; i < count; ++i) { + const size_t next = (i + 1) % count; + const Point &vertex = perimeter[next]; + for (size_t k = first_part[i]; k <= last_part(i); ++k) { + const Part &part = parts[k]; + const bool first = k == first_part[i]; + // Fractions of the part kept between the crossings of resolved corners. + const double from = first && resolved[i] ? start_at[i] : 0.; + const double to = k == last_part(i) && resolved[next] ? end_at[next] : 1.; + push(first && resolved[i] ? round_point(crossing[i]) : part.a, + {i, false, part.begin + from * (part.end - part.begin), part.begin + to * (part.end - part.begin)}); + if (first) + first_element[i] = surface.elements.size() - 1; + } + last_element[i] = surface.elements.size() - 1; + if (resolved[next]) + continue; // The next edge starts at the crossing that ends this one. + const Point end = parts[last_part(i)].b; + const Point resume = parts[first_part[next]].a; + if (end == resume) + continue; // Collinear edges or no shift at the vertex: the shifted edges meet exactly. + push(end, {next, true}); + // The normal turns like the edge; a reversal turns by half a circle around the air side. + const double turn = cross(normals[i], normals[next]); + const double dot = normals[i].dot(normals[next]); + const double sweep = turn == 0. && dot < 0. ? side * PI : std::atan2(turn, dot); + // Concave towards air and not resolved: a straight bridge, carried onto the vertex like an arc. + if (side * sweep <= 0.) + continue; + // An arc of the vertex's shift; both edges take that shift at the vertex, so the line stays continuous. + const double radius = double(profile.vertices[next]); + // Chord angle of an arc of this radius whose sagitta stays within the limit. + const double max_step = 2. * std::acos(std::max(-1., 1. - SURFACE_ARC_SAGITTA / radius)); + const double start = std::atan2(normals[i].y(), normals[i].x()); + const size_t steps = size_t(std::ceil(std::abs(sweep) / max_step)); + for (size_t step = 1; step < steps; ++step) { + const double angle = start + sweep * double(step) / double(steps); + push(round_point(vertex.cast() + radius * Vec2d(std::cos(angle), std::sin(angle))), {next, true}); + } + } + if (points.size() > 1 && points.back() == points.front()) { + points.pop_back(); + surface.elements.pop_back(); + } + if (points.size() < 3) + return surface; + // Resolved corners: the crossing ends the element of the edge before and starts the one after. + for (size_t v = 0; v < count; ++v) { + const size_t before = (v + count - 1) % count; + if (resolved[v] && last_element[before] < points.size() && first_element[v] < points.size()) { + const Point at = points[first_element[v]]; + surface.gaps.push_back({last_element[before], at, first_element[v], at}); + } + } + + // Clipped as an open path closed at its start, like the centerline. + surface.line.points = points; + surface.line.points.push_back(points.front()); + // Point by point: a box built from an axis-aligned line counts as undefined. + for (const Point &point : points) + surface.bounds.merge(point); + return surface; +} + +Transfer transfer_point(const AABBTreeLines::LinesDistancer &target, const Point &point, const Point &surface, + double window) +{ + const std::vector &lines = target.get_lines(); + const size_t count = lines.size(); + // A position on the noisy loop; a vertex is represented by its outgoing edge. + const auto position = [&lines, count](size_t index, double parameter, const Vec2d &at) -> CenterlinePoint { + if (parameter >= 1.) + return {(index + 1) % count, 0., lines[index].b}; + if (parameter <= 0.) + return {index, 0., lines[index].a}; + return {index, parameter, Point(coord_t(std::lround(at.x())), coord_t(std::lround(at.y())))}; + }; + const Vec2d from = point.cast(); + const Vec2d pair = (surface - point).cast(); + if (pair.squaredNorm() >= double(TOLERANCE_SQUARED)) { + // The line through the pair; a crossing within the window lies on an edge within the window of the point. + const Vec2d direction = pair.normalized(); + std::optional crossing; + double nearest = window; + for (const size_t index : target.all_lines_in_radius(point, window)) { + const Vec2d a = lines[index].a.cast(); + const Vec2d ab = lines[index].b.cast() - a; + const Vec2d to_a = a - from; + const double denominator = cross2(direction, ab); + double parameter = 0.; + double along = 0.; + if (std::abs(denominator) <= EPSILON * ab.norm()) { + // An edge along the line gives its point nearest to the point; one beside the line gives nothing. + if (std::abs(cross2(direction, to_a)) > 1.) + continue; + parameter = std::clamp(-to_a.dot(ab) / ab.squaredNorm(), 0., 1.); + along = std::abs((to_a + parameter * ab).dot(direction)); + } else { + parameter = cross2(to_a, direction) / denominator; + if (parameter < 0. || parameter > 1.) + continue; + along = std::abs(cross2(to_a, ab) / denominator); + } + // The nearest crossing; of equally near ones the first found, in the deterministic order of the tree. + if (along > window || (crossing && along >= nearest)) + continue; + nearest = along; + crossing = position(index, parameter, a + parameter * ab); + } + if (crossing) + return {TransferOutcome::Exact, *crossing}; + } + const auto [distance, index, nearest] = target.distance_from_lines_extra(point); + if (index >= count || distance > window) + return {TransferOutcome::Failed, {0, 0., point}}; + const Vec2d a = lines[index].a.cast(); + const Vec2d ab = lines[index].b.cast() - a; + return {TransferOutcome::Approximate, position(index, std::clamp((nearest - a).dot(ab) / ab.squaredNorm(), 0., 1.), nearest)}; +} + +// The largest |GetValue()| of the noise fuzzy skin scales by its thickness, assuming libnoise's coherent noise lies +// within [-1, 1] as libnoise states (a premise, not checked here). Perlin and Billow add octaves weighted by powers of +// the persistence (Billow folds each one into [-1, 1] and adds 0.5), RidgedMulti adds octaves of [0, 1] weighted by +// powers of 1/2 (its default lacunarity is 2) and maps their sum s to 1.25 s - 1. Uniform, Voronoi (displacement 1, +// no distance) and Ripple stay within [-1, 1]. +static double fuzzy_skin_noise_bound(const FuzzySkinConfig &fuzzy) +{ + const int octaves = std::max(fuzzy.noise_octaves, 1); + const auto octave_sum = [octaves](double ratio) { + double sum = 0.; + double weight = 1.; + for (int octave = 0; octave < octaves; ++octave, weight *= ratio) + sum += weight; + return sum; + }; + switch (fuzzy.noise_type) { + case NoiseType::Perlin: return octave_sum(std::abs(fuzzy.noise_persistence)); + case NoiseType::Billow: return octave_sum(std::abs(fuzzy.noise_persistence)) + 0.5; + case NoiseType::RidgedMulti: return std::max(1., 1.25 * octave_sum(0.5) - 1.); + default: return 1.; + } +} + +// An estimate from the settings, not a proven bound. As FuzzySkin.cpp textures an external loop, only regions that +// texture its kind make noise on it. They texture the loop one after another, each over the result of the previous +// ones, so the amplitudes of different noises add up; regions differing only in which walls they texture make the same +// noise once. Arachne's combined mode moves a point by half its change of width, which adds half the smallest width it +// keeps (as FuzzySkin.cpp works it out from the layer height). The largest point distance on top is the farthest a +// chord cutting a convex corner passes from it, and a micrometre the rounding. +double fuzzy_skin_window(const std::vector ®ions, double layer_height, bool arachne, bool contour) +{ + std::vector noises; + double amplitudes = 0.; + double point_distance = 0.; + for (const FuzzySkinConfig ®ion : regions) { + if (!Feature::FuzzySkin::should_fuzzify(region, region.layer_id, 0, contour)) + continue; + point_distance = std::max(point_distance, unscaled(region.point_distance)); + // The type and the first layer flag are left out of the comparison, as FuzzySkin.cpp merges regions that + // differ only in them. + FuzzySkinConfig noise = region; + noise.type = FuzzySkinType::External; + noise.fuzzy_first_layer = false; + if (std::find(noises.begin(), noises.end(), noise) != noises.end()) + continue; + noises.push_back(noise); + amplitudes += unscaled(region.thickness) * fuzzy_skin_noise_bound(region); + if (arachne && region.mode == FuzzySkinMode::Combined && region.noise_type != NoiseType::Ripple) + amplitudes += 0.5 * layer_height * (1. - 0.25 * PI) * 1.05; + } + return noises.empty() ? 0. : amplitudes + point_distance + 0.001; +} } // namespace detail +const detail::SurfaceLine &PreparedPerimeter::surface() const +{ + assert(valid && shift > 0); + if (!m_surface) + m_surface = std::make_unique(profile.empty() ? detail::build_surface_line(polygon, shift, hole) : + detail::build_surface_line(polygon, profile, hole)); + return *m_surface; +} + +const AABBTreeLines::LinesDistancer &PreparedPerimeter::target_lines() const +{ + assert(valid && target != nullptr); + if (!m_target_lines) + m_target_lines = std::make_unique>(target->lines()); + return *m_target_lines; +} + +// The edges of the surface polygon that make the arc or bridge of a vertex, in order; empty for a vertex without them. +static std::vector vertex_chain(const detail::SurfaceLine &surface, size_t vertex) +{ + const size_t count = surface.elements.size(); + const auto of_vertex = [&surface, vertex](size_t i) { return surface.elements[i].vertex && surface.elements[i].source == vertex; }; + size_t first = 0; + while (first < count && !of_vertex(first)) + ++first; + std::vector chain; + if (first == count) + return chain; + // The run may wrap round the start of the polygon. + for (size_t k = 0; k < count && of_vertex((first + count - 1) % count); ++k) + first = (first + count - 1) % count; + for (size_t k = 0, i = first; k < count && of_vertex(i); ++k, i = (i + 1) % count) + chain.push_back(i); + return chain; +} + +// Arc length along a chain of surface polygon edges at the foot of a point, and the point at an arc length. +static double chain_position(const detail::SurfaceLine &surface, const std::vector &chain, const Point &point) +{ + double best = std::numeric_limits::max(); + double result = 0.; + double start = 0.; + for (const size_t i : chain) { + const Vec2d a = surface.polygon[i].cast(); + const Vec2d ab = surface.polygon[(i + 1) % surface.polygon.size()].cast() - a; + const double t = std::clamp((point.cast() - a).dot(ab) / ab.squaredNorm(), 0., 1.); + const double distance = (a + t * ab - point.cast()).squaredNorm(); + if (distance < best) { + best = distance; + result = start + t * ab.norm(); + } + start += ab.norm(); + } + return result; +} + +static Point chain_point(const detail::SurfaceLine &surface, const std::vector &chain, double position) +{ + Vec2d at = surface.polygon[chain.front()].cast(); + for (const size_t i : chain) { + const Vec2d a = surface.polygon[i].cast(); + const Vec2d ab = surface.polygon[(i + 1) % surface.polygon.size()].cast() - a; + const double length = ab.norm(); + at = a + ab * std::clamp(position / length, 0., 1.); + if (position <= length) + break; + position -= length; + } + return Point(coord_t(std::lround(at.x())), coord_t(std::lround(at.y()))); +} + +static double chain_length(const detail::SurfaceLine &surface, const std::vector &chain) +{ + double length = 0.; + for (const size_t i : chain) + length += (surface.polygon[(i + 1) % surface.polygon.size()] - surface.polygon[i]).cast().norm(); + return length; +} + +// The crossing of the shifted edges at a resolved concave vertex, where its dead stretch begins and ends. +static std::optional concave_crossing(const detail::SurfaceLine &surface, size_t vertex) +{ + for (const detail::SurfaceGap &gap : surface.gaps) + if (!surface.elements[gap.start_element].vertex && surface.elements[gap.start_element].source == vertex) + return gap.start; + return std::nullopt; +} + +// Where the shifted edge leaving a vertex starts: the surface point of a vertex without an arc or bridge (collinear +// edges or no shift there), with the shift profile at the vertex. Empty when that edge has no element left. +static std::optional edge_start(const detail::SurfaceLine &surface, size_t vertex) +{ + std::optional first; + for (size_t i = 0; i < surface.elements.size(); ++i) + if (!surface.elements[i].vertex && surface.elements[i].source == vertex && + (!first || surface.elements[i].begin < surface.elements[*first].begin)) + first = i; + if (!first) + return std::nullopt; + return surface.polygon[*first]; +} + +// The surface point paired with a Center point of the smooth centerline: on a shifted edge, the point of that edge at +// the same parameter; at a vertex, the middle of its arc or bridge (of the piece covered, for a zero-length segment), +// or where its shifted edges meet when it has neither; in the dead stretch of a concave corner, the crossing that +// makes it. +static Point center_surface_point(const PreparedPerimeter &prepared, const PerimeterSegment &segment, const Point &point, + size_t edge) +{ + if (prepared.shift == 0) + return point; + const detail::SurfaceLine &surface = prepared.surface(); + const Polygon &perimeter = prepared.polygon; + const size_t count = perimeter.size(); + std::optional vertex; + if (segment.edge_indices.empty()) + vertex = segment.begin.edge_index; + else if (point == perimeter[edge]) + vertex = edge; + else if (point == perimeter[(edge + 1) % count]) + vertex = (edge + 1) % count; + if (vertex) { + const std::vector chain = vertex_chain(surface, *vertex); + if (chain.empty()) { + if (const std::optional crossing = concave_crossing(surface, *vertex)) + return *crossing; + // The shifted edges meet at one point, the vertex itself where the shift there is zero. Without an element + // of the edge the point itself is kept, an emergency fallback. + return edge_start(surface, *vertex).value_or(point); + } + double from = 0.; + double to = chain_length(surface, chain); + if (segment.edge_indices.empty()) { + from = chain_position(surface, chain, segment.surface_first); + to = chain_position(surface, chain, segment.surface_last); + } + return chain_point(surface, chain, 0.5 * (from + to)); + } + const Vec2d a = perimeter[edge].cast(); + const Vec2d ab = perimeter[(edge + 1) % count].cast() - a; + const double t = std::clamp((point.cast() - a).dot(ab) / ab.squaredNorm(), 0., 1.); + double highest = 0.; + for (size_t i = 0; i < surface.elements.size(); ++i) { + const detail::SurfaceElement &element = surface.elements[i]; + if (element.vertex || element.source != edge) + continue; + highest = std::max(highest, element.end); + // Each part of a shifted edge maps linearly onto its range of the source edge. + if (t >= element.begin && t <= element.end && element.end > element.begin) { + const Vec2d from = surface.polygon[i].cast(); + const Vec2d at = from + (t - element.begin) / (element.end - element.begin) * + (surface.polygon[(i + 1) % surface.polygon.size()].cast() - from); + return Point(coord_t(std::lround(at.x())), coord_t(std::lround(at.y()))); + } + } + // A dead stretch, next to the vertex beyond the edge's surface or before it. + return concave_crossing(surface, t > highest ? (edge + 1) % count : edge).value_or(point); +} + // Finalize one joined strong segment; only Center needs temporary per-edge lengths. -static void prepare_strong_segment(PerimeterSegment &segment, ModelVolumeType mode, bool compare_lengths) +static void prepare_strong_segment(PerimeterSegment &segment, ModelVolumeType mode, bool compare_lengths, + const PreparedPerimeter &prepared) { const bool center = mode == ModelVolumeType::PRECISE_SEAM_CENTER; std::vector edge_lengths; @@ -383,12 +967,18 @@ static void prepare_strong_segment(PerimeterSegment &segment, ModelVolumeType mo } } if (mode == ModelVolumeType::PRECISE_SEAM_LEFT) { - segment.strong_target = StrongSeamTarget{segment.polyline.points.front(), segment.begin.edge_index}; + segment.strong_target = StrongSeamTarget{segment.polyline.points.front(), segment.begin.edge_index, segment.surface_first}; return; } - segment.strong_target = StrongSeamTarget{segment.polyline.points.back(), segment.end.edge_index}; + segment.strong_target = StrongSeamTarget{segment.polyline.points.back(), segment.end.edge_index, segment.surface_last}; if (!center) return; + // Only a point carried onto a noisy loop needs the pair of the middle. + const auto pair_center = [&segment, &prepared]() { + if (prepared.target != nullptr) + segment.strong_target->surface = center_surface_point(prepared, segment, segment.strong_target->point, + segment.strong_target->edge_index); + }; // The total is now known; reuse local lengths to locate its half without new square roots. double remaining = segment.length * 0.5; @@ -399,10 +989,106 @@ static void prepare_strong_segment(PerimeterSegment &segment, ModelVolumeType mo const Point &b = segment.polyline.points[i + 1]; segment.strong_target = StrongSeamTarget{ a + ((remaining / length) * (b - a).cast()).cast(), segment.edge_indices[i]}; + pair_center(); return; } remaining -= length; } + pair_center(); +} + +// Clipper returns a single point where a border only touches the line: nothing to bind. +static void append_fragments(Polylines &&clipped, Polylines &fragments) +{ + for (Polyline &fragment : clipped) + if (fragment.size() >= 2) + fragments.push_back(std::move(fragment)); +} + +// Centerline path, used when the surface coincides with the centerline: clip it as an open line, without +// offsets or contact rules, and bind the fragments to the perimeter itself. The open path keeps +// self-touching vertices apart. +static std::vector centerline_intervals(const PreparedPerimeter &prepared, + const std::vector ®ions, const ExtractionContext &context, size_t &discarded) +{ + std::vector intervals; + Polylines fragments; + // Clip only accepted regions, with their holes still attached to the exterior. + for (const ModifierRegion *region : regions) + append_fragments(intersection_pl(prepared.line, region->polygon), fragments); + for (size_t i = 0; i < fragments.size(); ++i) + if (!detail::append_fragment(fragments[i], prepared.polygon, intervals, context, i)) + ++discarded; + return intervals; +} + +// Surface path: clip the surface line, bind the fragments to it, then carry them onto the centerline along +// the normal. A shifted edge keeps its parameters, an arc or bridge collapses to its vertex, and a dead stretch +// whose two ends are both covered covers the centerline between them. +static std::vector surface_intervals(const PreparedPerimeter &prepared, + const std::vector ®ions, const ExtractionContext &context, size_t &discarded) +{ + using detail::ClippedEdgeInterval; + std::vector intervals; + const detail::SurfaceLine &surface = prepared.surface(); + Polylines fragments; + for (const ModifierRegion *region : regions) + if (surface.bounds.defined && surface.bounds.overlap(region->bounds)) + append_fragments(intersection_pl(surface.line, region->polygon), fragments); + std::vector bound; + for (size_t i = 0; i < fragments.size(); ++i) + if (!detail::append_fragment(fragments[i], surface.polygon, bound, context, i)) + ++discarded; + if (bound.empty()) + return intervals; + + const Polygon &perimeter = prepared.polygon; + using detail::CenterlinePoint; + // An edge with a constant shift is an exact translate, so a point moves back by the same integer shift. Where + // the shift changes, the point on the source edge follows from the parameter. A shifted edge that ends at a + // concave crossing covers only part of its source edge. + const auto to_centerline = [&](size_t element, double parameter, const Point &point) -> CenterlinePoint { + const detail::SurfaceElement &source = surface.elements[element]; + if (source.vertex) + return {source.source, 0., perimeter[source.source]}; + const double t = source.begin + parameter * (source.end - source.begin); + if (surface.translated[source.source]) + return {source.source, t, point - surface.shifts[source.source]}; + const Vec2d a = perimeter[source.source].cast(); + const Vec2d at = a + t * (perimeter[(source.source + 1) % perimeter.size()].cast() - a); + return {source.source, t, Point(coord_t(std::lround(at.x())), coord_t(std::lround(at.y())))}; + }; + for (const ClippedEdgeInterval &interval : bound) { + const CenterlinePoint first = to_centerline(interval.edge, interval.begin, interval.first); + const CenterlinePoint last = to_centerline(interval.edge, interval.end, interval.last); + // An arc gives a vertex point, a shifted edge the same interval on its source edge. + intervals.push_back({first.edge, first.parameter, last.parameter, first.point, last.point, interval.first, interval.last}); + } + + // A stretch counts as reached when coverage ends at its end point on the same element; the snapping + // radius absorbs a modifier boundary passing through the corner itself. + const auto reaches = [](const Point &a, const Point &b) { + return (a - b).cast().squaredNorm() < double(TOLERANCE_SQUARED); + }; + // Indexed by element: a hole has a gap at every vertex, a covered hole an interval on every element. + std::unordered_multimap by_element; + by_element.reserve(bound.size()); + for (const ClippedEdgeInterval &interval : bound) + by_element.emplace(interval.edge, &interval); + for (const detail::SurfaceGap &gap : surface.gaps) { + const ClippedEdgeInterval *before = nullptr; + const ClippedEdgeInterval *after = nullptr; + for (auto [it, end] = by_element.equal_range(gap.end_element); it != end; ++it) + if (reaches(it->second->last, gap.end)) + before = it->second; + for (auto [it, end] = by_element.equal_range(gap.start_element); it != end; ++it) + if (reaches(it->second->first, gap.start)) + after = it->second; + if (before != nullptr && after != nullptr) + detail::cover_centerline(perimeter, to_centerline(before->edge, before->end, before->last), + to_centerline(after->edge, after->begin, after->first), intervals); + } + return intervals; } SegmentExtraction extract_perimeter_segments(const PreparedPerimeter &prepared, const ModifierRegions &modifier, @@ -416,28 +1102,20 @@ SegmentExtraction extract_perimeter_segments(const PreparedPerimeter &prepared, } const Polygon &perimeter = prepared.polygon; const size_t count = perimeter.size(); - std::vector nearby_regions; + // The surface of an outer contour reaches the shift beyond the centerline's bounds. + BoundingBox reach = prepared.bounds; + if (prepared.shift > 0) + reach.offset(coordf_t(prepared.shift)); + std::vector nearby_regions; for (const ModifierRegion ®ion : modifier) - if (!region.polygon.empty() && prepared.bounds.overlap(region.bounds)) - nearby_regions.push_back(®ion.polygon); + if (!region.polygon.empty() && reach.overlap(region.bounds)) + nearby_regions.push_back(®ion); if (nearby_regions.empty()) return result; - // Clip as an open line, without offsets or contact rules: modifiers should cross the perimeter - // clearly, and the open path keeps self-touching vertices apart. - std::vector intervals; - Polylines fragments; - // Clip only accepted regions, with their holes still attached to the exterior. - for (const ExPolygon *region : nearby_regions) { - Polylines clipped = intersection_pl(prepared.line, *region); - for (Polyline &fragment : clipped) - // Clipper returns a single point where a border only touches the line: nothing to bind. - if (fragment.size() >= 2) - fragments.push_back(std::move(fragment)); - } - for (size_t i = 0; i < fragments.size(); ++i) - if (!detail::append_fragment(fragments[i], perimeter, intervals, context, i)) - ++result.discarded_fragments; + std::vector intervals = prepared.shift > 0 ? + surface_intervals(prepared, nearby_regions, context, result.discarded_fragments) : + centerline_intervals(prepared, nearby_regions, context, result.discarded_fragments); std::sort(intervals.begin(), intervals.end(), [](const auto &a, const auto &b) { if (a.edge != b.edge) return a.edge < b.edge; @@ -454,6 +1132,20 @@ SegmentExtraction extract_perimeter_segments(const PreparedPerimeter &prepared, if (interval.end > merged.back().end) { merged.back().end = interval.end; merged.back().last = interval.last; + merged.back().surface_last = interval.surface_last; + } else if (prepared.target != nullptr && interval.begin == interval.end && merged.back().begin == merged.back().end && + interval.surface_first && merged.back().surface_first) { + // Separate pieces of one arc make one vertex point, from the piece nearest the arc's start to the + // end of the farthest, whatever order sorting left them in. + const detail::SurfaceLine &surface = prepared.surface(); + const std::vector chain = vertex_chain(surface, interval.edge); + const auto at = [&](const std::optional &point) { return chain_position(surface, chain, *point); }; + if (!chain.empty()) { + if (at(interval.surface_first) < at(merged.back().surface_first)) + merged.back().surface_first = interval.surface_first; + if (at(interval.surface_last) > at(merged.back().surface_last)) + merged.back().surface_last = interval.surface_last; + } } } else merged.push_back(interval); @@ -468,16 +1160,32 @@ SegmentExtraction extract_perimeter_segments(const PreparedPerimeter &prepared, for (const ClippedEdgeInterval &interval : merged) { const auto begin = position(interval.edge, interval.begin); const auto end = position(interval.edge, interval.end); - if (result.segments.empty() || !same_position(result.segments.back().end, begin)) { + const bool continues = !result.segments.empty() && same_position(result.segments.back().end, begin); + // A vertex point (surface arc) adds no edge: it only starts a zero-length segment if nothing reaches it. + if (interval.begin == interval.end) { + if (!continues) { + PerimeterSegment segment; + segment.begin = segment.end = begin; + segment.polyline.points.push_back(interval.first); + segment.surface_first = interval.surface_first.value_or(interval.first); + segment.surface_last = interval.surface_last.value_or(interval.last); + result.segments.push_back(std::move(segment)); + } else // The arc beyond the segment's last edge: its surface point pairs with the vertex the segment ends at. + result.segments.back().surface_last = interval.surface_last.value_or(interval.last); + continue; + } + if (!continues) { PerimeterSegment segment; segment.begin = begin; segment.polyline.points.push_back(interval.first); + segment.surface_first = interval.surface_first.value_or(interval.first); result.segments.push_back(std::move(segment)); } PerimeterSegment &segment = result.segments.back(); segment.polyline.points.push_back(interval.last); segment.edge_indices.push_back(interval.edge); segment.end = end; + segment.surface_last = interval.surface_last.value_or(interval.last); } if (result.segments.size() > 1 && same_position(result.segments.back().end, result.segments.front().begin)) { // Only the artificial cut at vertex zero can join the last and first intervals. @@ -487,16 +1195,25 @@ SegmentExtraction extract_perimeter_segments(const PreparedPerimeter &prepared, tail.polyline.points.insert(tail.polyline.points.end(), head.polyline.points.begin() + 1, head.polyline.points.end()); tail.edge_indices.insert(tail.edge_indices.end(), head.edge_indices.begin(), head.edge_indices.end()); tail.end = head.end; + tail.surface_last = head.surface_last; head = std::move(tail); } - // A full loop must cover every original edge, not merely have equal endpoint coordinates. - result.full_containment = merged.size() == count; - for (size_t i = 0; result.full_containment && i < count; ++i) - result.full_containment = merged[i].edge == i && merged[i].begin == 0. && merged[i].end == 1.; + // A full loop must cover every original edge, not merely have equal endpoint coordinates. Vertex points + // carry no coverage of their own. + size_t covered_edges = 0; + result.full_containment = true; + for (const ClippedEdgeInterval &interval : merged) + if (interval.begin != interval.end) { + result.full_containment = result.full_containment && interval.edge == covered_edges && + interval.begin == 0. && interval.end == 1.; + ++covered_edges; + } + result.full_containment = result.full_containment && covered_edges == count; // A touch on an inclined edge leaves a sub-micron gap. Treat the single segment as full containment // when the gap is shorter than the snapping radius, or spans one vertex with both ends within it - // (exact for edges of 2 um and longer). The 2 um end distance is a cheap pre-filter. - if (!result.full_containment && result.segments.size() == 1) { + // (exact for edges of 2 um and longer). The 2 um end distance is a cheap pre-filter. A zero-length + // segment covers nothing, so it never qualifies. + if (!result.full_containment && result.segments.size() == 1 && !result.segments.front().edge_indices.empty()) { const PerimeterSegment &only = result.segments.front(); const Point &first = only.polyline.points.front(); const Point &last = only.polyline.points.back(); @@ -528,7 +1245,7 @@ SegmentExtraction extract_perimeter_segments(const PreparedPerimeter &prepared, // Strong skips full containment and weak handles it by type; neither needs strong data for it. if (!result.full_containment && is_precise_seam_strong(mode)) for (PerimeterSegment &segment : result.segments) - prepare_strong_segment(segment, mode, result.segments.size() > 1); + prepare_strong_segment(segment, mode, result.segments.size() > 1, prepared); return result; } @@ -691,6 +1408,25 @@ static void record_extraction(PreciseSeamWarnings *warnings, const ModelVolume * PreciseSeamWarnings::set(usage.reached); } +// Carries a point found on the smooth loop onto the noisy loop it is inserted into, through the line to its surface +// point. Counts the approximate outcomes, and logs a failure like a discarded fragment, which it then counts as. +static detail::Transfer to_insertion(const PreparedPerimeter &prepared, const Point &point, const Point &surface, + const ExtractionContext &context) +{ + const detail::Transfer moved = detail::transfer_point(prepared.target_lines(), point, surface, double(prepared.window)); + if (context.warnings != nullptr && moved.outcome == detail::TransferOutcome::Approximate) + context.warnings->approximate_transfers.fetch_add(1, std::memory_order_relaxed); + if (moved.outcome == detail::TransferOutcome::Failed) { + if (context.warnings != nullptr && context.modifier != nullptr) + PreciseSeamWarnings::mark(context.warnings->failed_types, context.modifier->type()); + if (context.warnings == nullptr || + context.warnings->failed_fragments.fetch_add(1, std::memory_order_relaxed) < failed_fragment_log_limit) + BOOST_LOG_TRIVIAL(warning) << "[PreciseSeamTransferFailed] No point of the fuzzy skin loop near the seam point" + << detail::fragment_location(context, 0) << " window=" << prepared.window; + } + return moved; +} + // Strong priority is per modifier, never a global maximum across different modifiers. std::optional insert_strong_seam_point( const std::vector &strong_volumes, @@ -700,7 +1436,7 @@ std::optional insert_strong_seam_point( const ModifierRegionsCache &slices_cache, PreciseSeamWarnings* warnings) { - assert(&prepared.polygon == &polygon); + assert(&prepared.insertion() == &polygon); if (strong_volumes.empty() || layer == nullptr || !prepared.valid) return std::nullopt; const size_t layer_id = layer->id() - layer->object()->slicing_parameters().raft_layers(); @@ -726,19 +1462,35 @@ std::optional insert_strong_seam_point( // Lengths are compared exactly: for a symmetric modifier the chosen face may alternate between // layers, which is accepted (the user gets the multiple-intersections warning). StrongSeamTarget target{Point(0, 0), 0}; + // The winner's point on the smooth loop breaks ties, so the noise of a fuzzy skin loop never changes the winner. + Point chosen(0, 0); double longest = -1.; + const ExtractionContext context{layer, modifier, warnings}; for (const PerimeterSegment &segment : extracted.segments) { assert(segment.strong_target.has_value()); const StrongSeamTarget &candidate = *segment.strong_target; // Slice coordinates already include object rotation and retain bed axes. // Centering/instance translation cannot change rear (+Y), then left (-X) ordering. - const bool farther_or_left = candidate.point.y() > target.point.y() || - (candidate.point.y() == target.point.y() && candidate.point.x() < target.point.x()); - if (segment.length > longest || (segment.length == longest && farther_or_left)) { - longest = segment.length; - target = candidate; + const bool farther_or_left = candidate.point.y() > chosen.y() || + (candidate.point.y() == chosen.y() && candidate.point.x() < chosen.x()); + if (!(segment.length > longest || (segment.length == longest && farther_or_left))) + continue; + StrongSeamTarget inserted = candidate; + // Chosen on the smooth loop, inserted into the noisy one with fuzzy skin. A point that cannot be carried + // is a discarded fragment: its segment takes no part. + if (prepared.target != nullptr) { + const detail::Transfer moved = to_insertion(prepared, candidate.point, candidate.surface.value_or(candidate.point), context); + if (moved.outcome == detail::TransferOutcome::Failed) + continue; + inserted = StrongSeamTarget{moved.position.point, moved.position.edge}; } + longest = segment.length; + chosen = candidate.point; + target = inserted; } + // Every segment failed to be carried: the turn passes to the next modifier. + if (longest < 0.) + continue; const auto [seam_point, seam_index] = insert_point_into_perimeter(target.point, target.edge_index, polygon); // Preserve the insertion order: refining before first would shift the seam index. refine_at_vertex(seam_index, +1, polygon); @@ -935,10 +1687,116 @@ std::vector collect_weak_modifier_segments( const ModifierRegionsCache &slices_cache, PreciseSeamWarnings* warnings) { - assert(&prepared.polygon == &polygon); + assert(&prepared.insertion() == &polygon); std::vector result; if (weak_volumes.empty() || layer == nullptr || !prepared.valid) return result; + // With fuzzy skin the zones are found on the smooth loop and their boundaries carried onto the noisy one; before + // any insertion, a policy tells some zones whose boundaries came out in the reverse order. + std::vector source_arc; + const auto arc_at = [&source_arc](const PerimeterPosition &position) { + return source_arc[position.edge_index] + + position.parameter * (source_arc[position.edge_index + 1] - source_arc[position.edge_index]); + }; + // The length of the smooth loop from one position forward to another, across its start if need be. + const auto forward = [&](const PerimeterPosition &from, const PerimeterPosition &to) { + const double length = arc_at(to) - arc_at(from); + return length >= 0. ? length : length + source_arc.back(); + }; + // Walks the noisy loop from one carried position forward to another: the first position, every vertex between them + // across the start of the loop, then the second position. Positions on one edge with the second behind the first go + // round the whole loop. Stops where `visit` returns false. + const auto walk = [&prepared](const detail::CenterlinePoint &from, const detail::CenterlinePoint &to, const auto &visit) { + const Polygon &noisy = *prepared.target; + const size_t count = noisy.size(); + size_t vertices = (to.edge + count - from.edge) % count; + if (vertices == 0 && to.parameter < from.parameter) + vertices = count; + if (!visit(from.point)) + return; + for (size_t i = 1; i <= vertices; ++i) + if (!visit(noisy[(from.edge + i) % count])) + return; + visit(to.point); + }; + // Whether that noisy arc leaves the circle around `center`: a point of it lies farther than `radius`. + const auto leaves = [&walk](const detail::CenterlinePoint &from, const detail::CenterlinePoint &to, const Point ¢er, + double radius) { + bool outside = false; + walk(from, to, [&outside, ¢er, limit = radius * radius](const Point &point) { + outside = (point - center).cast().squaredNorm() > limit; + return !outside; + }); + return outside; + }; + // The length of that noisy arc. + const auto noisy_length = [&walk](const detail::CenterlinePoint &from, const detail::CenterlinePoint &to) { + double length = 0.; + std::optional last; + walk(from, to, [&length, &last](const Point &point) { + if (last) + length += (point - *last).cast().norm(); + last = point; + return true; + }); + return length; + }; + // A policy, not a proven guarantee. It assumes the points of a zone's true noisy arc lie within the window of the + // smooth zone, as its boundaries do; the window is an estimate. Then for a zone shorter than four windows that arc + // stays within the circle around its smooth left boundary whose radius is the zone's length plus a window, however + // much the noise lengthens it, and the arc round the rest of the loop leaves the circle wherever the loop spreads + // beyond it (its length tells nothing). So: the arc forward from the left boundary to the right one leaving the + // circle reverses the zone; the other arc leaving it keeps the order; with both inside, a loop that lies within the + // circle, the longer arc is taken for the rest of the loop, which may reduce a zone wrongly or miss a reversal. + // Coinciding carried positions within the circle give two arcs of zero length and keep the order. The same holds + // round the smooth right boundary for the short rest of an almost whole zone, with the arcs swapped. + // Longer on both sides, the order is not checked: a transfer onto another part of the loop there is a limitation of + // the direct transfer. + const double window = double(prepared.window); + const auto decide = [&](const detail::CenterlinePoint &from, const detail::CenterlinePoint &to, const Point ¢er, + double radius) { + if (leaves(from, to, center, radius)) + return true; + if (leaves(to, from, center, radius)) + return false; + return noisy_length(from, to) > noisy_length(to, from); + }; + const auto reversed = [&](const PerimeterSegment &segment, const detail::CenterlinePoint &left, + const detail::CenterlinePoint &right) { + const double zone = forward(segment.begin, segment.end); + const double rest = source_arc.back() - zone; + if (zone < 4. * window) + return decide(left, right, segment.polyline.points.front(), zone + window); + if (rest < 4. * window) + return decide(right, left, segment.polyline.points.back(), rest + window); + return false; + }; + // False when a boundary cannot be carried: the zone is then a discarded fragment. + const auto carry = [&](const PerimeterSegment &segment, WeakModifierSegment &zone, const ExtractionContext &context) { + if (source_arc.empty()) { + source_arc.push_back(0.); + const Polygon &smooth = prepared.polygon; + for (size_t edge = 0; edge < smooth.size(); ++edge) + source_arc.push_back(source_arc.back() + (smooth[(edge + 1) % smooth.size()] - smooth[edge]).cast().norm()); + } + const detail::Transfer left = to_insertion(prepared, segment.polyline.points.front(), segment.surface_first, context); + if (left.outcome == detail::TransferOutcome::Failed) + return false; + detail::Transfer right = to_insertion(prepared, segment.polyline.points.back(), segment.surface_last, context); + if (right.outcome == detail::TransferOutcome::Failed) + return false; + // A zone whose boundaries came out in the reverse order is reduced to its left boundary, a declared degradation. + if (reversed(segment, left.position, right.position)) { + right = left; + if (context.warnings != nullptr) + context.warnings->reversed_zones.fetch_add(1, std::memory_order_relaxed); + } + zone.left_point = left.position.point; + zone.left_position = {left.position.edge, left.position.parameter}; + zone.right_point = right.position.point; + zone.right_position = {right.position.edge, right.position.parameter}; + return true; + }; // Modifier cache indices exclude raft layers, unlike Layer::id(). const size_t raft_layers = layer->object()->slicing_parameters().raft_layers(); @@ -960,13 +1818,15 @@ std::vector collect_weak_modifier_segments( for (const PerimeterSegment &segment : extracted.segments) { result.push_back({type, segment.polyline.points.front(), segment.begin, segment.polyline.points.back(), segment.end, false, modifier_volume}); + if (prepared.target != nullptr && !carry(segment, result.back(), context)) + result.pop_back(); } } // Boundary insertion, refinement and last-write-wins priority use the established path. return prepare_weak_modifier_segments(std::move(result), polygon); } -void apply_weak_modifiers_to_perimeter( +bool apply_weak_modifiers_to_perimeter( const std::vector &weak_segments, PrintObjectSeamData::LayerSeams &result, const SeamPlacerImpl::Perimeter &perimeter, @@ -976,6 +1836,8 @@ void apply_weak_modifiers_to_perimeter( // Get z-coordinate for unscaling boundary points const float z_coord = result.points[perimeter.start_index].position.z(); const size_t perimeter_size = perimeter.end_index - perimeter.start_index; + // Candidates whose last zone is Enforced; painting may have enforced others. + std::vector zone_enforced(perimeter_size, 0); // Helper lambda: search for point index in result.points by unscaled coordinates. // Linear scan is intentional — O(N×M) is acceptable for typical M ≤ 5 weak segments. @@ -997,6 +1859,7 @@ void apply_weak_modifiers_to_perimeter( if (segment.whole_perimeter) { for (size_t i = perimeter.start_index; i < perimeter.end_index; ++i) result.points[i].type = segment.type; + std::fill(zone_enforced.begin(), zone_enforced.end(), segment.type == EnforcedBlockedSeamPoint::Enforced); if (segment.type == EnforcedBlockedSeamPoint::Enforced) some_point_enforced = true; continue; @@ -1014,6 +1877,7 @@ void apply_weak_modifiers_to_perimeter( // Apply modifier type to range [left_idx, right_idx] with wraparound for (size_t idx = left_idx.value(); ; idx = (idx + 1) % perimeter_size) { result.points[perimeter.start_index + idx].type = segment.type; + zone_enforced[idx] = segment.type == EnforcedBlockedSeamPoint::Enforced; if (idx == right_idx.value()) break; } @@ -1022,18 +1886,20 @@ void apply_weak_modifiers_to_perimeter( } } + const bool enforced_by_zone = std::find(zone_enforced.begin(), zone_enforced.end(), 1) != zone_enforced.end(); // Only the highest whole zone is in effect, and a higher band may still unblock part of it. if (warnings == nullptr) - return; + return enforced_by_zone; const auto last_whole = std::find_if(weak_segments.rbegin(), weak_segments.rend(), [](const WeakModifierSegment &segment) { return segment.whole_perimeter; }); if (last_whole == weak_segments.rend() || last_whole->type != EnforcedBlockedSeamPoint::Blocked) - return; + return enforced_by_zone; for (size_t i = perimeter.start_index; i < perimeter.end_index; ++i) if (result.points[i].type != EnforcedBlockedSeamPoint::Blocked) - return; + return enforced_by_zone; if (const auto usage = warnings->modifier_usage.find(last_whole->modifier); usage != warnings->modifier_usage.end()) PreciseSeamWarnings::set(usage->second.fully_blocked); + return enforced_by_zone; } // Restore precise seam positions that may have been modified diff --git a/src/libslic3r/GCode/PreciseSeam.hpp b/src/libslic3r/GCode/PreciseSeam.hpp index 486af1cb2e..451c2ba698 100644 --- a/src/libslic3r/GCode/PreciseSeam.hpp +++ b/src/libslic3r/GCode/PreciseSeam.hpp @@ -4,15 +4,19 @@ #include #include #include +#include #include #include #include #include +#include "libslic3r/AABBTreeLines.hpp" #include "libslic3r/BoundingBox.hpp" +#include "libslic3r/Line.hpp" #include "libslic3r/ExPolygon.hpp" #include "libslic3r/Point.hpp" #include "libslic3r/Polygon.hpp" #include "libslic3r/Polyline.hpp" +#include "libslic3r/libslic3r.h" #include "libslic3r/Model.hpp" #include "SeamPlacer.hpp" @@ -55,6 +59,10 @@ struct PreciseSeamWarnings { // Fragments saved by the rare-case fallback or accepted as contacts; log only, no user warning. // Clipper is deterministic, so a prismatic model can repeat the same case on every layer. std::atomic recovered_fragments{0}; + // Fuzzy skin, log only: points carried onto the noisy loop without the line through their surface point, and weak + // zones whose carried boundaries came out in the reverse order and were reduced to one point. + std::atomic approximate_transfers{0}; + std::atomic reversed_zones{0}; // Per-modifier flags for the "had no effect" and "covers an entire perimeter" warnings. Modifiers are // registered before the parallel phase, so workers only set flags; unregistered ones (e.g. in tests) @@ -93,16 +101,81 @@ struct ExtractionContext { PreciseSeamWarnings *warnings = nullptr; }; +namespace detail { struct SurfaceLine; } + +// Scaled distance from the perimeter centerline to the model surface the user sees: half the line width, +// less the object's XY compensation for contours or holes (positive towards air) and a small margin. Zero when +// the surface practically coincides with the centerline; extraction then clips the centerline itself. +coord_t surface_shift(double line_width, double compensation); + +// A shift that changes along the perimeter: one value per vertex and, on an edge where it does not change +// linearly between its vertices, values at interior points as (parameter, shift) in increasing parameter order. +struct ShiftProfile { + std::vector vertices; + std::vector>> interior; // One list per edge. + bool empty() const { return vertices.empty(); } +}; + // Borrows the source polygon; use only until insertion/refinement changes that polygon. struct PreparedPerimeter { + // The smooth centerline modifiers are evaluated on. const Polygon &polygon; + // With fuzzy skin, the noisy loop the results are inserted into, made from `polygon`; null when they are + // inserted into `polygon` itself. Points are carried onto it within `window` of the smooth line. + const Polygon *target = nullptr; + coord_t window = 0; BoundingBox bounds; Polyline line; bool valid = false; + // Largest distance to the reconstructed surface and its side: air lies inside the polygon of a hole. + coord_t shift = 0; + bool hole = false; + // The shift at every point when it changes along the perimeter; empty when it is `shift` everywhere. + ShiftProfile profile; - explicit PreparedPerimeter(const Polygon &perimeter); + explicit PreparedPerimeter(const Polygon &perimeter, coord_t surface_shift = 0, bool is_hole = false); + // A profile whose largest shift is within the snapping radius keeps the centerline, as a constant one does. + PreparedPerimeter(const Polygon &perimeter, ShiftProfile shift_profile, bool is_hole); + ~PreparedPerimeter(); + // Sets the noisy loop made from `polygon` by fuzzy skin and the window within which its points are looked for + // around `polygon`: an estimate from the fuzzy skin settings, not a measured largest distance. An unusable loop + // (as the constructor checks) makes the preparation invalid. + void set_target(const Polygon &noisy, coord_t noise_window); + // The polygon insertion changes. + const Polygon &insertion() const { return target != nullptr ? *target : polygon; } + // Built on the first request, so perimeters that no modifier approaches never pay for it. Internal to + // extraction. + const detail::SurfaceLine &surface() const; + // The same for the edges of the noisy loop; requires a target. + const AABBTreeLines::LinesDistancer &target_lines() const; + +private: + mutable std::unique_ptr m_surface; + mutable std::unique_ptr> m_target_lines; }; +// What measuring the shift along one perimeter needs. Lengths in mm. +struct ShiftMeasurement { + // Boundary of the layer's islands as slicing stored them, before elephant foot compensation. + const AABBTreeLines::LinesDistancer &outline; + double line_width; // Of the external perimeter; half of it is the nominal depth of the centerline. + double compensation; // XY compensation of this kind of wall, positive towards air. + double outline_compensation; // The part of `compensation` the outline already contains. + // Depths of the centerline below the outline that belong to the wall's own surface; elsewhere (a wall thinner + // than expected, a boundary between regions) the nominal shift applies. + double min_depth; + double max_depth; +}; + +// The shift at every vertex of a perimeter, and at interior points of edges longer than the sampling step where it +// does not change linearly along them: the measured depth of the centerline below the outline, less the +// compensation the outline contains and the margin, never negative. The depth is the offset to the nearest point of +// the outline projected on the normal of the edge (the larger of the two at a vertex), so at an inner corner, whose +// nearest outline point is the corner, it is still the distance to each side. Returns an empty profile when every +// value equals the nominal shift of surface_shift() within the snapping radius, so that walls at their nominal depth +// keep the constant shift exactly. +ShiftProfile measure_shift_profile(const Polygon &perimeter, bool hole, const ShiftMeasurement &measurement); + // A vertex is represented by its outgoing edge and parameter zero, including vertex 0. struct PerimeterPosition { size_t edge_index; @@ -113,14 +186,22 @@ struct PerimeterPosition { struct StrongSeamTarget { Point point; size_t edge_index; + // The surface point paired with `point`: the segment end's for Left and Right; for Center, worked out only when + // the point is carried onto a noisy loop. + std::optional surface = std::nullopt; }; struct PerimeterSegment { + // A single point with no edges when the surface was reached only around a convex vertex. Polyline polyline; // One bound source edge per polyline interval. std::vector edge_indices; PerimeterPosition begin; PerimeterPosition end; + // The reconstructed surface points paired with the polyline's ends, kept through merging; the ends themselves on + // the centerline path. A zero-length segment has the two ends of its piece of arc. + Point surface_first; + Point surface_last; std::optional strong_target; // Absent for weak modifiers and full containment. // Scaled arc length, calculated only for Center or comparison of multiple strong segments. double length = 0.; // Zero means unmeasured for weak, full containment, and a single Left/Right segment. @@ -183,7 +264,8 @@ std::vector collect_weak_modifier_segments( // Retypes the candidates inside each zone in the given order (pass zones lowest priority first); // sets some_point_enforced when an Enforced zone applies. When the whole perimeter ends up Blocked and // the highest whole-perimeter zone is Blocked, flags that zone's modifier for the warning. -void apply_weak_modifiers_to_perimeter( +// Returns whether a candidate is left Enforced by a zone, not overwritten by a later one. +bool apply_weak_modifiers_to_perimeter( const std::vector &weak_segments, PrintObjectSeamData::LayerSeams &result, const SeamPlacerImpl::Perimeter &perimeter, diff --git a/src/libslic3r/GCode/PreciseSeamInternal.hpp b/src/libslic3r/GCode/PreciseSeamInternal.hpp index bfd230ba3d..ab4d8914c4 100644 --- a/src/libslic3r/GCode/PreciseSeamInternal.hpp +++ b/src/libslic3r/GCode/PreciseSeamInternal.hpp @@ -1,12 +1,19 @@ #pragma once #include "PreciseSeam.hpp" +#include "libslic3r/AABBTreeLines.hpp" +#include "libslic3r/BoundingBox.hpp" +#include "libslic3r/Line.hpp" #include "libslic3r/Point.hpp" #include "libslic3r/Polygon.hpp" #include "libslic3r/Polyline.hpp" +#include "libslic3r/libslic3r.h" #include +#include #include +namespace Slic3r { struct FuzzySkinConfig; } + namespace Slic3r::PreciseSeam::detail { // Binding intermediates retain source edge identity until segment assembly. @@ -16,8 +23,85 @@ struct ClippedEdgeInterval { double end; Point first; Point last; + // The points of the reconstructed surface that `first` and `last` were carried from, on the surface path. + std::optional surface_first; + std::optional surface_last; }; +// Source of one edge of the surface line: a source edge shifted towards air, or the arc (convex) or +// bridge (unresolved concave) around a source vertex. Both map to their vertex. +struct SurfaceElement { + size_t source; // Source edge or vertex index. + bool vertex; + // Parameters on the source edge where this part of a shifted edge starts and ends: a shifted edge is split + // where its shift changes along it, and ends at the crossing of a concave corner instead of the shifted vertex. + double begin = 0.; + double end = 1.; +}; + +// Where coverage of the surface ends on one side of a dead stretch of the centerline (around a resolved +// concave corner) and resumes on the other. Both points are the crossing of the shifted edges, so coverage +// of both covers the stretch. +struct SurfaceGap { + size_t end_element; + Point end; + size_t start_element; + Point start; +}; + +// The reconstructed surface of one perimeter: the centerline shifted towards air, as a closed line with the +// source of every edge. +struct SurfaceLine { + Polygon polygon; // No consecutive or closing duplicates. + std::vector elements; // One per polygon edge. + // Integer shift of every source edge whose shift is constant along it: its shifted edge is an exact translate, + // so a point maps back by subtraction. Other edges map back through the parameter. + std::vector shifts; + std::vector translated; // Per source edge: whether `shifts` applies. + Polyline line; // The polygon as an open path closed at its start, for clipping. + std::vector gaps; + BoundingBox bounds; // Of the polygon. +}; + +// Builds the surface line of a perimeter accepted by PreparedPerimeter (either direction), shift > 0. +SurfaceLine build_surface_line(const Polygon &perimeter, coord_t shift, bool hole); +// The same with a shift that changes along the perimeter; no shift is negative. +SurfaceLine build_surface_line(const Polygon &perimeter, const ShiftProfile &profile, bool hole); + +// A position on the centerline with its point. +struct CenterlinePoint { + size_t edge; + double parameter; + Point point; +}; + +// Appends intervals covering the perimeter forward from `from` to `to`. Refuses to go around the whole loop: +// `to` before `from` on one edge appends nothing. +void cover_centerline(const Polygon &perimeter, CenterlinePoint from, const CenterlinePoint &to, + std::vector &intervals); + +// How a point of the smooth centerline of a fuzzy skin loop was carried onto its noisy loop. +enum class TransferOutcome { + Exact, // The crossing of the line through the point and its surface point nearest to the point. + Approximate, // The pair coincides or the line crosses nothing within the window: the nearest point of the loop. + Failed, // Nothing of the noisy loop within the window. +}; + +struct Transfer { + TransferOutcome outcome; + CenterlinePoint position; // On the noisy loop; unset when the transfer failed. +}; + +// Carries `point` onto the noisy loop whose edges `target` indexes (line i is edge i), within `window` of it. An edge +// lying along the line gives its point nearest to `point`. Every edge must have non-zero length, as +// PreparedPerimeter::set_target() requires of the loop. +Transfer transfer_point(const AABBTreeLines::LinesDistancer &target, const Point &point, const Point &surface, + double window); + +// The transfer window of the external fuzzy skin loops of one kind (contours or holes) on a layer, in mm, from the +// fuzzy skin settings of its regions; each setting carries the layer id. Zero where no region textures these loops. +double fuzzy_skin_window(const std::vector ®ions, double layer_height, bool arachne, bool contour); + struct FragmentBindingFailure { size_t pair_index = 0; const char *reason = "empty fragment"; diff --git a/src/libslic3r/GCode/SeamPlacer.cpp b/src/libslic3r/GCode/SeamPlacer.cpp index 5bcfc8b94b..2231978994 100644 --- a/src/libslic3r/GCode/SeamPlacer.cpp +++ b/src/libslic3r/GCode/SeamPlacer.cpp @@ -55,6 +55,9 @@ #include "libslic3r/Utils.hpp" #include "PreciseSeam.hpp" +#include "PreciseSeamInternal.hpp" +#include "libslic3r/Feature/FuzzySkin/FuzzySkin.hpp" +#include "libslic3r/PerimeterGenerator.hpp" //#define DEBUG_FILES @@ -371,6 +374,10 @@ struct GlobalModelInfo { // Slice each modifier once; both consumers share structured regions and source provenance. PreciseSeam::ModifierRegionsCache precise_seam_slices; + // XY compensation that moved the object's contours and hole walls away from the model, positive towards air. + // Walls between regions of one object are compensated differently by slicing; that is not modelled. + double precise_seam_contour_compensation = 0.; + double precise_seam_hole_compensation = 0.; bool is_enforced(const Vec3f &position, float radius) const { if (enforcers.empty()) { @@ -471,12 +478,27 @@ struct GlobalModelInfo { //Extract perimeter polygons of the given layer Polygons extract_perimeter_polygons(const Layer *layer, std::vector &corresponding_regions_out, std::vector> &boundary_types_out, + std::vector &untextured_out, + std::vector &line_widths_out, bool has_precise_seam_modifiers) { Polygons polygons; const auto boundary_type = [](const ExtrusionEntity *entity) -> std::optional { if (!entity->is_loop()) return std::nullopt; return (static_cast(entity)->loop_role() & elrHole) != 0; }; + // The centerline of a loop before fuzzy skin, where the noise changed it. + const auto untextured = [](const ExtrusionEntity *entity) -> const Polygon* { + return entity->is_loop() ? static_cast(entity)->untextured.get() : nullptr; + }; + // The width of a loop's own outer wall line, zero where unknown. Bridges lie on the same centerline with the + // overhang flow's width, which says nothing about the wall. + const auto line_width = [](const ExtrusionEntity *entity) -> double { + if (entity->is_loop()) + for (const ExtrusionPath &path : static_cast(entity)->paths) + if (path.role() == ExtrusionRole::erExternalPerimeter) + return path.width; + return 0.; + }; for (const LayerRegion *layer_region : layer->regions()) { for (const ExtrusionEntity *ex_entity : layer_region->perimeters.entities) { if (ex_entity->is_collection()) { //collection of inner, outer, and overhang perimeters @@ -492,6 +514,8 @@ Polygons extract_perimeter_polygons(const Layer *layer, std::vector box = std::nullopt, coord_t reach = 0) { + if (box) + box->offset(reach); + // Modifier cache indices exclude raft layers, unlike Layer::id(). + const size_t layer_id = layer->id() - layer->object()->slicing_parameters().raft_layers(); + for (const auto &[volume, slices] : global_model_info.precise_seam_slices) + if (layer_id < slices.size()) + for (const PreciseSeam::ModifierRegion ®ion : slices[layer_id]) + if (region.bounds.defined && (!box || box->overlap(region.bounds))) + return true; + return false; +} + +// Layers where Precise Seam measures how deep the centerline lies below the model surface instead of taking half +// the line width: the first layers with elephant foot compensation and every layer of Arachne perimeters. +struct LayerShiftMeasurement { + std::unique_ptr> outline; // Set on a measured layer with modifier regions. + double elephant_foot = 0.; // Compensation of this layer, mm. + bool arachne = false; + bool several_regions = false; + // Which kinds of noisy loops without their smooth centerline are measured; fuzzy skin keeps the nominal shift. + bool contours = false; + bool holes = false; + // How far a point of a fuzzy skin contour or hole is expected to lie from its smooth centerline, scaled: an estimate + // from the settings (see PreciseSeam::detail::fuzzy_skin_window()), not a measured largest distance. + coord_t fuzzy_window_contours = 0; + coord_t fuzzy_window_holes = 0; +}; + +LayerShiftMeasurement layer_shift_measurement(const PrintObject *po, size_t layer_idx, + const GlobalModelInfo &global_model_info) { + LayerShiftMeasurement measurement; + const PrintObjectConfig &config = po->config(); + const Layer *layer = po->get_layer(int(layer_idx)); + // As PrintObject::slice_volumes() applies it: directly on the bed only, decreasing to zero over its layers. + const int foot_layers = config.elefant_foot_compensation_layers.value; + if (config.raft_layers.value == 0 && config.elefant_foot_compensation.value > 0. && int(layer_idx) < foot_layers) + measurement.elephant_foot = config.elefant_foot_compensation.value * (1. - double(layer_idx) / double(foot_layers)); + // As LayerRegion::make_perimeters() chooses the generator. + measurement.arachne = config.wall_generator.value == PerimeterGeneratorType::Arachne && !po->print()->config().spiral_mode.value; + // Without a modifier region on the layer no loop is processed. + if (!precise_seam_modifier_near(global_model_info, layer)) + return measurement; + // The fuzzy skin settings of every region, as FuzzySkin.cpp reads them. + std::vector fuzzy_regions; + for (const LayerRegion *region : layer->regions()) { + const PrintRegionConfig ®ion_config = region->region().config(); + fuzzy_regions.push_back({region_config.fuzzy_skin.value, scaled(region_config.fuzzy_skin_thickness.value), + scaled(region_config.fuzzy_skin_point_distance.value), + region_config.fuzzy_skin_first_layer.value, region_config.fuzzy_skin_noise_type.value, + region_config.fuzzy_skin_scale.value, region_config.fuzzy_skin_octaves.value, + region_config.fuzzy_skin_persistence.value, region_config.fuzzy_skin_mode.value, + region_config.fuzzy_skin_ripples_per_layer.value, + region_config.fuzzy_skin_ripple_offset.value, + region_config.fuzzy_skin_layers_between_ripple_offset.value, int(layer->id())}); + } + measurement.fuzzy_window_contours = coord_t( + scale_(PreciseSeam::detail::fuzzy_skin_window(fuzzy_regions, layer->height, measurement.arachne, true))); + measurement.fuzzy_window_holes = coord_t( + scale_(PreciseSeam::detail::fuzzy_skin_window(fuzzy_regions, layer->height, measurement.arachne, false))); + // Only these layers are measured: skip the outline index elsewhere. + if (measurement.elephant_foot <= 0. && !measurement.arachne) + return measurement; + // Fuzzy skin moves the centerline off the smooth outline; measuring a noisy loop would pull some points back and + // leave others. Loops that keep their smooth centerline are measured on it. + measurement.contours = measurement.holes = true; + for (const FuzzySkinConfig &fuzzy : fuzzy_regions) { + measurement.contours = measurement.contours && !Feature::FuzzySkin::should_fuzzify(fuzzy, int(layer->id()), 0, true); + measurement.holes = measurement.holes && !Feature::FuzzySkin::should_fuzzify(fuzzy, int(layer->id()), 0, false); + } + measurement.outline = std::make_unique>(to_lines(layer->lslices)); + measurement.several_regions = layer->regions().size() > 1; + return measurement; +} + +// The measured shift of one closed loop, or an empty profile where the constant shift of its line width applies. +PreciseSeam::ShiftProfile measured_shift_profile(const Polygon &polygon, bool hole, double line_width, + double compensation, const LayerRegion *region, + const LayerShiftMeasurement &measurement, + const GlobalModelInfo &global_model_info, bool smooth) { + if (!measurement.outline || (!smooth && !(hole ? measurement.holes : measurement.contours))) + return {}; + const Layer *layer = region->layer(); + const PrintObject *object = layer->object(); + const Flow flow = region->flow(FlowRole::frExternalPerimeter); + const double width = flow.width(); + const double spacing = flow.spacing(); + // With several regions, slicing stores the outline of an elephant foot layer before a negative contour + // compensation, which it then applies to the perimeters. (A negative hole value has no effect there at all.) + const double excluded = measurement.elephant_foot > 0. && measurement.several_regions && !hole && compensation < 0. ? + compensation : 0.; + // Arachne splits a wall into two lines narrower than its minimum bead width before it falls back to one; the + // classic generator prints narrow loops slightly thinner. + const double narrowest = measurement.arachne ? 0.5 * width : width - 0.25 * spacing; + // A single Arachne line may be up to about 1.6 spacings wide. Arachne keeps a precise outer wall deeper by + // (w - s) / 2 where it prints one line. + const double widest = measurement.arachne ? 2. * width : width; + // The slicing resolution, by which the outline may differ from the contour perimeters were built on, and the + // snapping radius. + const double tolerance = object->print()->config().resolution.value + 1000. * SCALING_FACTOR; + const PreciseSeam::ShiftMeasurement shift_measurement{ + *measurement.outline, line_width, compensation, compensation - excluded, + 0.5 * narrowest - excluded - tolerance, + 0.5 * widest + 0.5 * (width - spacing) + measurement.elephant_foot - excluded + tolerance}; + // Far from every modifier the shift cannot matter; skip the measurement. The largest shift is the deepest accepted + // depth less the compensation in the outline, or the nominal one; a negative compensation makes it deeper. A + // compensation beyond the whole depth leaves no shift (the surface is the centerline), not a negative reach. + const double largest = std::max(std::max(shift_measurement.max_depth - shift_measurement.outline_compensation, + 0.5 * width - compensation), 0.); + if (!precise_seam_modifier_near(global_model_info, layer, BoundingBox(polygon.points), coord_t(scale_(largest)))) + return {}; + return PreciseSeam::measure_shift_profile(polygon, hole, shift_measurement); +} + // Painted range of a loop along its length from its first vertex; `end` exceeds the loop length if the range // passes the first vertex. struct PaintedInterval { @@ -663,7 +810,9 @@ std::vector exact_painted_intervals(const std::vector &l void process_perimeter_polygon(const Polygon &orig_polygon, float z_coord, const LayerRegion *region, const GlobalModelInfo &global_model_info, PrintObjectSeamData::LayerSeams &result, PreciseSeam::PreciseSeamWarnings* warnings = nullptr, - std::optional boundary_hole = std::nullopt) { + std::optional boundary_hole = std::nullopt, + const LayerShiftMeasurement *shift_measurement = nullptr, + const Polygon *untextured = nullptr, double line_width = 0.) { if (orig_polygon.size() == 0) { return; } @@ -679,10 +828,51 @@ void process_perimeter_polygon(const Polygon &orig_polygon, float z_coord, const std::optional seam_point; std::vector weak_segments; - if (layer != nullptr && (!strong_volumes.empty() || !weak_volumes.empty())) { + // Closed loops only: the G-code of an open extrusion (thin wall) does not depend on where its seam is. + if (layer != nullptr && boundary_hole.has_value() && (!strong_volumes.empty() || !weak_volumes.empty())) { + // Modifiers act where they cross the model surface the user sees: the centerline lies half a line width + // inside the printed wall, which XY compensation moved away from the model. + const bool hole = *boundary_hole; + double compensation = hole ? global_model_info.precise_seam_hole_compensation + : global_model_info.precise_seam_contour_compensation; + // With several regions on a layer slicing never shrinks a hole: it clips the regions by the compensated + // islands, and clipping cannot add material. A negative hole setting then has no effect. + if (hole && compensation > 0. && layer->regions().size() > 1) + compensation = 0.; + // The classic generator prints narrow islands with a thinner line than the region's: the loop's own width + // tells how deep its centerline lies. An Arachne line varies along the loop and is measured instead. + const bool arachne = shift_measurement != nullptr && shift_measurement->arachne; + const double width = line_width > 0. && !arachne ? line_width : region->flow(FlowRole::frExternalPerimeter).width(); + const coord_t shift = PreciseSeam::surface_shift(width, compensation); + // With fuzzy skin, modifiers are evaluated on the smooth centerline and the result is carried onto the noisy + // loop. Normalized as the loop is: no repeated points, counterclockwise. + Polygon smooth; + if (untextured != nullptr) { + smooth = *untextured; + smooth.points.erase(std::unique(smooth.points.begin(), smooth.points.end()), smooth.points.end()); + while (smooth.size() > 1 && smooth.points.front() == smooth.points.back()) + smooth.points.pop_back(); + smooth.make_counter_clockwise(); + } + const bool fuzzy = smooth.size() >= 3; + const Polygon &source = fuzzy ? smooth : polygon; + // Where the centerline is not at its nominal depth, the shift is measured against the layer outline. + PreciseSeam::ShiftProfile profile; + if (shift_measurement != nullptr) + profile = measured_shift_profile(source, hole, width, compensation, region, *shift_measurement, global_model_info, fuzzy); // Share validation, bounds and clipping line across all modifiers while the polygon is unchanged. // A strong insertion ends processing; otherwise weak reads the same preparation before inserting. - const PreciseSeam::PreparedPerimeter prepared(polygon); + // Built in place: the preparation borrows the polygons and is neither copied nor moved. + std::optional preparation; + if (profile.empty()) + preparation.emplace(source, shift, hole); + else + preparation.emplace(source, std::move(profile), hole); + if (fuzzy) + preparation->set_target(polygon, shift_measurement == nullptr ? 0 : + hole ? shift_measurement->fuzzy_window_holes : + shift_measurement->fuzzy_window_contours); + const PreciseSeam::PreparedPerimeter &prepared = *preparation; seam_point = PreciseSeam::insert_strong_seam_point( strong_volumes, polygon, prepared, layer, global_model_info.precise_seam_slices, warnings); if (!seam_point.has_value()) @@ -871,8 +1061,10 @@ void process_perimeter_polygon(const Polygon &orig_polygon, float z_coord, const // Apply weak modifiers if no strong modifier was inserted if (!inserted_seam_position.has_value() && !weak_segments.empty()) { - PreciseSeam::apply_weak_modifiers_to_perimeter( - weak_segments, result, perimeter, some_point_enforced, warnings); + // An Enforced zone ends at its inserted boundaries, as exactly as paint crossing the layer: alignment and + // Random must keep the seam inside it. Set here, after painting has typed the candidates by this flag. + if (PreciseSeam::apply_weak_modifiers_to_perimeter(weak_segments, result, perimeter, some_point_enforced, warnings)) + perimeter.exact_enforced_ends = true; } if (some_point_enforced) { @@ -1637,14 +1829,20 @@ void SeamPlacer::gather_seam_candidates(const PrintObject *po, const SeamPlacerI auto unscaled_z = layer->slice_z; std::vector regions; std::vector> boundary_types; + std::vector untextured; + std::vector line_widths; //NOTE corresponding region ptr may be null, if the layer has zero perimeters const bool has_precise_seam_modifiers = !global_model_info.precise_seam_strong_volumes.empty() || !global_model_info.precise_seam_weak_volumes.empty(); - Polygons polygons = extract_perimeter_polygons(layer, regions, boundary_types, has_precise_seam_modifiers); + Polygons polygons = extract_perimeter_polygons(layer, regions, boundary_types, untextured, line_widths, has_precise_seam_modifiers); + // Built once per layer, only on layers with Precise Seam modifier regions. + const LayerShiftMeasurement shift_measurement = has_precise_seam_modifiers ? + layer_shift_measurement(po, layer_idx, global_model_info) : LayerShiftMeasurement{}; for (size_t poly_index = 0; poly_index < polygons.size(); ++poly_index) { process_perimeter_polygon(polygons[poly_index], unscaled_z, regions[poly_index], global_model_info, layer_seams, - warnings, boundary_types[poly_index]); + warnings, boundary_types[poly_index], &shift_measurement, + untextured[poly_index], line_widths[poly_index]); } auto functor = SeamCandidateCoordinateFunctor { layer_seams.points }; seam_data.layers[layer_idx].points_tree = @@ -2135,7 +2333,7 @@ void SeamPlacer::init(const Print &print, std::function throw_if_can precise_seam_warnings.modifier_usage.try_emplace(vol); } - auto place_seams = [this, &throw_if_canceled_func, &precise_seam_warnings](ObjectSeams &object) { + auto place_seams = [this, &print, &throw_if_canceled_func, &precise_seam_warnings](ObjectSeams &object) { const PrintObject *po = object.po; throw_if_canceled_func(); SeamPosition configured_seam_preference = po->config().seam_position.value; @@ -2152,6 +2350,13 @@ void SeamPlacer::init(const Print &print, std::function throw_if_can global_model_info.precise_seam_slices[vol] = PreciseSeam::prepare_modifier_slices(po->slice_single_volume_regions(vol)); for (const ModelVolume* vol : global_model_info.precise_seam_weak_volumes) global_model_info.precise_seam_slices[vol] = PreciseSeam::prepare_modifier_slices(po->slice_single_volume_regions(vol)); + // Slicing skips XY compensation for multi-material painting with several filaments, as in + // PrintObject::slice_volumes(); a positive hole value enlarges holes, moving their walls into the material. + if (!global_model_info.precise_seam_slices.empty() && + !(print.config().filament_diameter.size() > 1 && po->is_mm_painted())) { + global_model_info.precise_seam_contour_compensation = po->config().xy_contour_compensation.value; + global_model_info.precise_seam_hole_compensation = -po->config().xy_hole_compensation.value; + } throw_if_canceled_func(); if (configured_seam_preference == spAligned || configured_seam_preference == spNearest || configured_seam_preference == spAlignedBack) { @@ -2243,6 +2448,13 @@ void SeamPlacer::init(const Print &print, std::function throw_if_can << " fragments discarded; first " << PreciseSeam::failed_fragment_log_limit << " logged (parallel processing order), " << (failed - PreciseSeam::failed_fragment_log_limit) << " omitted"; + // Fuzzy skin degradations are log-only totals. + const size_t approximate = precise_seam_warnings.approximate_transfers.load(std::memory_order_relaxed); + const size_t reversed = precise_seam_warnings.reversed_zones.load(std::memory_order_relaxed); + if (approximate > 0 || reversed > 0) + BOOST_LOG_TRIVIAL(warning) << "[PreciseSeamFuzzySkin] " << approximate + << " points carried onto noisy loops without their surface line, " << reversed + << " weak zones reduced to one point after their boundaries reversed"; // Recoveries are log-only: no user warning, but the same bounded detail and a total. const size_t recovered = precise_seam_warnings.recovered_fragments.load(std::memory_order_relaxed); if (recovered > PreciseSeam::failed_fragment_log_limit) @@ -2316,10 +2528,10 @@ void SeamPlacer::init(const Print &print, std::function throw_if_can if (!no_effect.empty()) { const ModelVolume *first = no_effect.front(); if (no_effect.size() == 1) - parts.push_back((boost::format(_u8L("modifier \"%1%\" of \"%2%\" had no effect on the seam (it might not reach the centerline of the printed perimeter)")) + parts.push_back((boost::format(_u8L("modifier \"%1%\" of \"%2%\" had no effect on the seam")) % first->name % first->get_object()->name).str()); else - parts.push_back((boost::format(_u8L("modifier \"%1%\" of \"%2%\" (%3% in total) had no effect on the seam (it might not reach the centerline of the printed perimeter)")) + parts.push_back((boost::format(_u8L("modifier \"%1%\" of \"%2%\" (%3% in total) had no effect on the seam")) % first->name % first->get_object()->name % no_effect.size()).str()); } if (!parts.empty()) { @@ -2416,8 +2628,12 @@ void SeamPlacer::place_seam(const Layer *layer, ExtrusionLoop &loop, perimeter_point.perimeter.start_index : seam_index + 1; + // At a hairpin (angle close to -pi) beta_angle is close to zero and the snap below would move the point + // millions of mm away, so such corners are treated like convex ones. + constexpr float min_concave_beta_angle = 0.05f; // corners sharper than about 174 degrees if ((seam_position - perimeter_point.position).squaredNorm() < depth && // seam is on perimeter point - perimeter_point.local_ccw_angle < -EPSILON // In concave angles + perimeter_point.local_ccw_angle < -EPSILON && // In concave angles + beta_angle > min_concave_beta_angle ) { // In this case, we are at internal perimeter, where the external perimeter has seam in concave angle. We want to align // the internal seam into the concave corner, and not on the perpendicular projection on the closest edge (which is what the split_at function does) Vec2f dir_to_middle = @@ -2441,6 +2657,8 @@ void SeamPlacer::place_seam(const Layer *layer, ExtrusionLoop &loop, if (po->config().staggered_inner_seams && loop.length() > 0.0) { //fix depth, it is sometimes strongly underestimated depth = std::max(loop.paths[projected_point.path_idx].width, depth); + // Whole laps end where they started; dropping them keeps the walk below one lap. The walk measures in XY. + depth = std::fmod(depth, static_cast(unscale(loop.polygon().length()))); while (depth > 0.0f) { auto next_point = get_next_loop_point(projected_point); diff --git a/src/libslic3r/LocalesUtils.cpp b/src/libslic3r/LocalesUtils.cpp index fd6afb0018..51157e679a 100644 --- a/src/libslic3r/LocalesUtils.cpp +++ b/src/libslic3r/LocalesUtils.cpp @@ -105,6 +105,19 @@ double atof_decimal_point(std::string_view str) return string_to_double_decimal_point(str.substr(i)); } +double strtod_decimal_point(const char *str, char **endptr) +{ + const char *begin = str; + while (*begin == ' ' || (*begin >= '\t' && *begin <= '\r')) + ++begin; + if (*begin == '+' && begin[1] != '-') + ++begin; + size_t parsed = 0; + const double out = string_to_double_decimal_point(begin, &parsed); + *endptr = const_cast(parsed == 0 ? str : begin + parsed); + return out; +} + std::string float_to_string_decimal_point(double value, int precision/* = -1*/) { // Every branch prints the same digits in the classic locale as the stream at the end, which takes over when a branch diff --git a/src/libslic3r/LocalesUtils.hpp b/src/libslic3r/LocalesUtils.hpp index c2e020044a..33cd6a8345 100644 --- a/src/libslic3r/LocalesUtils.hpp +++ b/src/libslic3r/LocalesUtils.hpp @@ -51,6 +51,9 @@ double string_to_double_decimal_point(const std::string_view str, size_t* pos = // Parses like atof in the C locale, skipping leading whitespace and a '+', // without the C runtime's per-call locale lookup. double atof_decimal_point(std::string_view str); +// Parses a decimal number like strtod in the C locale, and sets *endptr past it, or to str when there is none. +// strtod on macOS 13.3 to 14.0 reads the process locale, so a CNumericLocalesSetter does not affect it. +double strtod_decimal_point(const char *str, char **endptr); } // namespace Slic3r diff --git a/src/libslic3r/Model.cpp b/src/libslic3r/Model.cpp index 6ffd003143..3b84239760 100644 --- a/src/libslic3r/Model.cpp +++ b/src/libslic3r/Model.cpp @@ -1,4 +1,5 @@ #include "Model.hpp" +#include "FilamentMixer.hpp" #include "calib.hpp" #include "Format/STEP.hpp" #include "TriangleMesh.hpp" @@ -837,6 +838,42 @@ void Model::set_assembly_pos(ModelObject *model_object, const std::vectorset_assemble_offset(instance->get_assemble_offset() + shift); } +void Model::set_assembly_pos_of_copies(ModelObject *model_object, size_t source_idx, size_t first_copy) +{ + ModelInstancePtrs &instances = model_object->instances; + if (source_idx >= first_copy || first_copy >= instances.size()) + return; + + // ORCA: A source without an assembly pose (e.g. a text object) is placed as a new object first. + // Its copies sit on it meanwhile, so that they do not widen its bounding box. + if (!instances[source_idx]->is_assemble_initialized()) { + for (size_t i = first_copy; i < instances.size(); ++i) + instances[i]->set_assemble_transformation(instances[source_idx]->get_transformation()); + this->set_assembly_pos(model_object); + } + + const ModelInstance &source = *instances[source_idx]; + Geometry::Transformation pose = source.get_assemble_transformation(); + const BoundingBoxf3 &raw_box = model_object->raw_mesh_bounding_box(); + const BoundingBoxf3 source_box = raw_box.transformed(pose.get_matrix()); + // ORCA: Bounding box of everything in the assembly view, except the copies. + BoundingBoxf3 placed; + for (const ModelObject *o : this->objects) + if (o != model_object) + placed.merge(o->bounding_box_in_assembly_view()); + for (size_t i = 0; i < first_copy; ++i) + placed.merge(raw_box.transformed(instances[i]->get_assemble_transformation().get_matrix())); + + // ORCA: Line the copies up to the right of that box, 10 mm apart. + Vec3d offset = pose.get_offset() + (placed.max.x() - source_box.max.x()) * Vec3d::UnitX(); + for (size_t i = first_copy; i < instances.size(); ++i) { + offset.x() += source_box.size().x() + 10.; + pose.set_offset(offset); + instances[i]->set_assemble_transformation(pose); + instances[i]->set_offset_to_assembly(source.get_offset_to_assembly()); + } +} + // this returns the bounding box of the *transformed* instances BoundingBoxf3 Model::bounding_box_approx() const { @@ -1610,6 +1647,9 @@ void ModelObject::delete_volume(size_t idx) for (ModelInstance* inst : this->instances) { inst->set_transformation(Geometry::Transformation(inst->get_transformation().get_matrix() * v_t)); + // ORCA: Same for the pose in the assembly view, otherwise the object turns or moves there. + if (inst->is_assemble_initialized()) + inst->set_assemble_from_transform(inst->get_assemble_transformation().get_matrix() * v_t); } Geometry::Transformation t; v->set_transformation(t); @@ -2513,20 +2553,16 @@ void ModelObject::split(ModelObjectPtrs* new_objects, const bool remap_paint) // BBS: clear volume's config, as we already set them into object new_vol->config.reset(); + const Vec3d volume_offset = new_vol->get_offset(); for (ModelInstance* model_instance : new_object->instances) { - const Vec3d shift = model_instance->get_transformation().get_matrix_no_offset() * new_vol->get_offset(); + const Vec3d shift = model_instance->get_transformation().get_matrix_no_offset() * volume_offset; model_instance->set_offset(model_instance->get_offset() + shift); - //BBS: add assemble_view related logic - Geometry::Transformation instance_transformation_copy = model_instance->get_transformation(); - instance_transformation_copy.set_offset(-new_vol->get_offset()); - const Transform3d &assemble_matrix = model_instance->get_assemble_transformation().get_matrix(); - const Transform3d &instance_inverse_matrix = instance_transformation_copy.get_matrix().inverse(); - Transform3d new_instance_inverse_matrix = instance_inverse_matrix * model_instance->get_transformation().get_matrix_no_offset().inverse(); - Transform3d new_assemble_transform = assemble_matrix * new_instance_inverse_matrix; - model_instance->set_assemble_from_transform(new_assemble_transform); - model_instance->set_offset_to_assembly(new_vol->get_offset()); + // Absorb the part's local offset before clearing it below. + const Transform3d &assembly = model_instance->get_assemble_transformation().get_matrix(); + model_instance->set_assemble_from_transform(assembly * Geometry::translation_transform(volume_offset)); + model_instance->set_offset_to_assembly(volume_offset); } new_vol->set_offset(Vec3d::Zero()); @@ -3360,6 +3396,14 @@ void ModelVolume::convert_from_meters() this->source.is_converted_from_meters = true; } +bool ModelVolume::is_mm_painted_everywhere() const +{ + const TriangleSelector::TriangleSplittingData &data = this->mmu_segmentation_facets.get_data(); + // Unpainted facets are not stored, and the unpainted parts of a split facet are stored as NONE. + return data.triangles_to_split.size() == this->mesh().its.indices.size() && + !data.used_states[static_cast(EnforcerBlockerType::NONE)]; +} + // Orca: Implement prusa's filament shrink compensation approach // Returns 0-based indices of extruders painted by multi-material painting gizmo. std::vector ModelVolume::get_extruders_from_multi_material_painting() const { @@ -4538,41 +4582,41 @@ bool model_has_advanced_features(const Model &model) return false; } +void remap_model_filament_configs(Model &model, const std::map &slots, bool include_extruder) +{ + auto remap = [&](ModelConfig &config) { + remap_feature_filaments(config, slots); + if (include_extruder) + remap_filament_option(config, "extruder", slots); + }; + for (auto &[id, material] : model.materials) + remap(material->config); + for (ModelObject *object : model.objects) { + remap(object->config); + for (auto &[range, config] : object->layer_config_ranges) + remap(config); + for (ModelVolume *volume : object->volumes) + remap(volume->config); + } +} + void remap_model_filament_slots(Model &model, const std::map &slot_relocations) { if (slot_relocations.empty()) return; - // Paint states and the object/volume "extruder" configs store one-based slot numbers - // (see Sidebar::on_action_add_filament's insertion remap for the same encoding). - std::map one_based_slots; - for (const auto &[from, to] : slot_relocations) - one_based_slots.emplace(from + 1, to + 1); - + remap_model_filament_configs(model, slot_relocations, true); EnforcerBlockerStateMap paint_state_map; for (size_t state = 0; state < paint_state_map.size(); ++state) paint_state_map[state] = EnforcerBlockerType(state); - for (const auto &[one_based_from, one_based_to] : one_based_slots) { - assert(one_based_from >= 0 && size_t(one_based_from) < paint_state_map.size()); - assert(one_based_to > 0 && size_t(one_based_to) < paint_state_map.size()); - paint_state_map[size_t(one_based_from)] = EnforcerBlockerType(one_based_to); + for (const auto &[from, to] : slot_relocations) { + assert(from >= 0 && size_t(from + 1) < paint_state_map.size()); + assert(to >= 0 && size_t(to + 1) < paint_state_map.size()); + paint_state_map[size_t(from + 1)] = EnforcerBlockerType(to + 1); } - - auto remap_extruder_config = [&one_based_slots](ModelConfig &config) -> bool { - const auto it = config.has("extruder") ? one_based_slots.find(config.extruder()) : one_based_slots.end(); - if (it == one_based_slots.end()) - return false; - config.set("extruder", it->second); - return true; - }; - - for (ModelObject *object : model.objects) { - remap_extruder_config(object->config); - for (ModelVolume *volume : object->volumes) { - remap_extruder_config(volume->config); + for (ModelObject *object : model.objects) + for (ModelVolume *volume : object->volumes) volume->mmu_segmentation_facets.remap_states(*volume, paint_state_map); - } - } } #ifndef NDEBUG diff --git a/src/libslic3r/Model.hpp b/src/libslic3r/Model.hpp index 7d981a3062..070344afb9 100644 --- a/src/libslic3r/Model.hpp +++ b/src/libslic3r/Model.hpp @@ -1195,6 +1195,8 @@ public: bool is_fdm_support_painted() const { return !this->supported_facets.empty(); } bool is_seam_painted() const { return !this->seam_facets.empty(); } bool is_mm_painted() const { return !this->mmu_segmentation_facets.empty(); } + // Whether multi-material painting covers every facet. + bool is_mm_painted_everywhere() const; bool is_fuzzy_skin_painted() const { return !this->fuzzy_skin_facets.empty(); } bool is_texture_displacement_painted() const { return !this->texture_displacement_facets_all_empty(); } bool is_any_painted() const { @@ -1883,6 +1885,9 @@ public: // overlap the others there. Keeps its height and the layout of its instances. Instances that have no // assembly pose yet start from their pose on the plate. void set_assembly_pos(ModelObject *model_object, const std::vector &ignore = {}); + // ORCA: Places the copies of instance source_idx (the instances from first_copy on) in the assembly view: + // in the pose of their source, in a row to the right of everything else. + void set_assembly_pos_of_copies(ModelObject *model_object, size_t source_idx, size_t first_copy); // Returns approximate axis aligned bounding box of this model. BoundingBoxf3 bounding_box_approx() const; // Returns exact axis aligned bounding box of this model. @@ -2012,8 +2017,11 @@ bool model_has_multi_part_objects(const Model &model); // If the model has advanced features, then it cannot be processed in simple mode. bool model_has_advanced_features(const Model &model); +// Deletion handles the base extruder separately because objects and modifiers use different fallbacks. +void remap_model_filament_configs(Model &model, const std::map &slots, bool include_extruder); + // Remap the model's filament-slot references after a published-3MF import relocated -// mixed-filament definitions onto new slot numbers: object/volume "extruder" configs and +// mixed-filament definitions onto new slot numbers: base and per-feature filament assignments and // multi-material color-painting states (paint state stores the one-based slot number). // slot_relocations maps the author's zero-based slot number to its final zero-based slot; // entries are applied simultaneously (no chained lookups), untouched slots keep everything. diff --git a/src/libslic3r/PerimeterGenerator.cpp b/src/libslic3r/PerimeterGenerator.cpp index fae9019ca3..0a06ccb2ab 100644 --- a/src/libslic3r/PerimeterGenerator.cpp +++ b/src/libslic3r/PerimeterGenerator.cpp @@ -28,6 +28,7 @@ #include #include #include +#include #include #include #include @@ -253,7 +254,11 @@ static ExtrusionEntityCollection traverse_loops(const PerimeterGenerator &perime paths.emplace_back(std::move(path)); } - coll.append(ExtrusionLoop(std::move(paths), loop_role)); + ExtrusionLoop extrusion_loop(std::move(paths), loop_role); + // ORCA: The centerline before fuzzy skin, for an external loop whose points it changed. + if (is_external && polygon.points != loop.polygon.points) + extrusion_loop.untextured = std::make_shared(loop.polygon); + coll.append(std::move(extrusion_loop)); } // Append thin walls to the nearest-neighbor search (only for first iteration) @@ -421,7 +426,17 @@ static ExtrusionEntityCollection traverse_extrusions(const PerimeterGenerator& p ExtrusionRole role = is_external ? erExternalPerimeter : erPerimeter; const bool is_contour = !extrusion->is_closed || pg_extrusion.is_contour; + // ORCA: The centerline before fuzzy skin, for a closed external loop whose points it changes. Copied only where + // the layer has fuzzy skin on this kind of loop. + Polygon untextured; + if (is_external && extrusion->is_closed && + (pg_extrusion.is_contour ? perimeter_generator.has_fuzzy_skin : perimeter_generator.has_fuzzy_hole)) + for (const Arachne::ExtrusionJunction &junction : extrusion->junctions) + untextured.points.push_back(junction.p); apply_fuzzy_skin(extrusion, perimeter_generator, is_contour, extrusion->is_closed); + const bool textured = !untextured.empty() && + !std::equal(untextured.points.begin(), untextured.points.end(), extrusion->junctions.begin(), extrusion->junctions.end(), + [](const Point &point, const Arachne::ExtrusionJunction &junction) { return point == junction.p; }); ExtrusionPaths paths; // detect overhanging/bridging perimeters @@ -564,6 +579,8 @@ static ExtrusionEntityCollection traverse_extrusions(const PerimeterGenerator& p if (extrusion->is_closed) { ExtrusionLoop extrusion_loop(std::move(paths), pg_extrusion.is_contour ? elrDefault : elrHole); extrusion_loop.inset_idx = extrusion->inset_idx; + if (textured) + extrusion_loop.untextured = std::make_shared(std::move(untextured)); if ((perimeter_generator.config->wall_direction == WallDirection::CounterClockwise) == (pg_extrusion.is_contour || pg_extrusions.size() == 2)) extrusion_loop.make_counter_clockwise(); diff --git a/src/libslic3r/Preset.cpp b/src/libslic3r/Preset.cpp index 1b54f24a93..1f1e5c6a21 100644 --- a/src/libslic3r/Preset.cpp +++ b/src/libslic3r/Preset.cpp @@ -3064,6 +3064,7 @@ std::pair PresetCollection::load_external_preset( it = this->find_preset_renamed(original_name); found = it != m_presets.end(); } + const bool found_by_name = found; t_config_option_keys keys; DynamicPrintConfig cfg = Preset::load_external_config(m_type, this->default_preset_for(combined_config).config, combined_config, different_settings_list, @@ -3083,6 +3084,11 @@ std::pair PresetCollection::load_external_preset( } return nullptr; }, &keys); + // A project does not store a filament's compatible_printers or compatible_prints, so they are not applied over the existing preset. + if (m_type == Preset::TYPE_FILAMENT) + keys.erase(std::remove_if(keys.begin(), keys.end(), + [](const std::string &key) { return key == "compatible_printers" || key == "compatible_prints"; }), + keys.end()); std::string &inherits = Preset::inherits(cfg); //BBS: add config related logs @@ -3183,6 +3189,9 @@ std::pair PresetCollection::load_external_preset( // There is a profile with the same name already loaded. Should we update the "inherits" field? inherits = it->vendor ? it->name : it->inherits(); } + // The new preset built from cfg copies compatible_printers and compatible_prints from the filament the project names, since the project does not store them. + if (m_type == Preset::TYPE_FILAMENT && found_by_name) + cfg.apply_only(it->config, {"compatible_printers", "compatible_prints"}); } // The external preset does not match an internal preset, load the external preset. diff --git a/src/libslic3r/PresetBundle.cpp b/src/libslic3r/PresetBundle.cpp index baf2100836..e2d36c0a08 100644 --- a/src/libslic3r/PresetBundle.cpp +++ b/src/libslic3r/PresetBundle.cpp @@ -5568,7 +5568,8 @@ DynamicPrintConfig PresetBundle::full_fff_config(bool apply_extruder, std::optio out.apply(this->project_config); // BBS - size_t num_filaments = this->filament_presets.size(); + // Before the presets load, filament_presets is empty; that bundle has one filament, the edited preset. + size_t num_filaments = std::max(this->filament_presets.size(), 1); std::vector filament_maps = out.option("filament_map")->values; std::vector filament_volume_maps(num_filaments, (int)nvtStandard); @@ -5655,7 +5656,7 @@ DynamicPrintConfig PresetBundle::full_fff_config(bool apply_extruder, std::optio compatible_prints_condition .emplace_back(this->filaments.get_edited_preset().compatible_prints_condition()); //BBS: add logic for settings check between different system presets //std::string filament_inherits = this->filaments.get_edited_preset().inherits(); - std::string current_preset_name = this->filament_presets[0]; + std::string current_preset_name = this->filament_presets.empty() ? this->filaments.get_edited_preset().name : this->filament_presets[0]; const Preset* preset = this->filaments.find_preset(current_preset_name, true); std::string filament_inherits = preset->inherits(); inherits .emplace_back(filament_inherits); @@ -6744,9 +6745,6 @@ void PresetBundle::load_config_file_config(const std::string &name_or_path, bool swept_mix_slots.insert(slot); receiver_mix_moves.emplace_back(slot, dest); any_mixed_relocated = true; - // A payload mix authored at the same slot (a mix inside the physical region) is - // processed after this sweep and overrides its own destination below. - published_config->mixed_slot_relocations.insert_or_assign(int(slot), int(dest)); // TRN Filament slot change after loading a published project. %1% and %2% are slot numbers. published_config->material_replacements.emplace_back( (boost::format(L("slot %1% -> slot %2%: mixed filament")) % slot % dest).str()); @@ -6847,6 +6845,15 @@ void PresetBundle::load_config_file_config(const std::string &name_or_path, bool ++entry_it; } } + // Published process options refer to the author's slots. Options kept from the + // edited preset follow the receiver's own mixes, which may have moved elsewhere. + if (!mixed_moves.empty() || !receiver_mix_moves.empty()) { + const std::map receiver_slots(receiver_mix_moves.begin(), receiver_mix_moves.end()); + for (const char *key : feature_filament_keys) { + const auto &slots = applied_keys.count(key) ? published_config->mixed_slot_relocations : receiver_slots; + remap_filament_option(prints.get_edited_preset().config, key, slots); + } + } if (!mixed_moves.empty()) for (const std::string& mixed_key : mixed_definitions) apply_mixed_config_relocations(config, mixed_key, mixed_moves); diff --git a/src/libslic3r/Print.cpp b/src/libslic3r/Print.cpp index 4dbcffef2f..eb1ac1726d 100644 --- a/src/libslic3r/Print.cpp +++ b/src/libslic3r/Print.cpp @@ -2521,7 +2521,25 @@ StringObjectException Print::validate(std::vector *warnin // spiral vase cannot print. const auto &is_mixed = m_config.filament_is_mixed.values; for (const PrintObject *object : m_objects) { - const auto used_filament_ids = object->object_extruders(); + auto used_filament_ids = object->object_extruders(); + // Painted all over, the object prints only its painted filaments, unless the segmented region + // max width or interlocking depth limits the paint to a band and fills the rest with its own filament. + // Beam interlocking turns that band off. + const PrintObjectConfig &object_config = object->config(); + const ModelVolumePtrs &volumes = object->model_object()->volumes; + if ((object_config.interlocking_beam.value || + (object_config.mmu_segmented_region_max_width.value == 0. && + object_config.mmu_segmented_region_interlocking_depth.value == 0.)) && + std::all_of(volumes.begin(), volumes.end(), [](const ModelVolume *volume) { + return !volume->is_model_part() || volume->is_mm_painted_everywhere(); + })) { + used_filament_ids.clear(); + for (const ModelVolume *volume : volumes) + if (volume->is_model_part()) + for (size_t filament_id : volume->get_extruders_from_multi_material_painting()) + used_filament_ids.push_back(static_cast(filament_id)); + sort_remove_duplicates(used_filament_ids); + } if (used_filament_ids.size() > 1 || std::any_of(used_filament_ids.begin(), used_filament_ids.end(), [&is_mixed](unsigned int filament_id) { return filament_id < is_mixed.size() && is_mixed[filament_id]; diff --git a/src/libslic3r/PrintApply.cpp b/src/libslic3r/PrintApply.cpp index f4d4dedca3..6e31f8214a 100644 --- a/src/libslic3r/PrintApply.cpp +++ b/src/libslic3r/PrintApply.cpp @@ -1428,6 +1428,12 @@ Print::ApplyStatus Print::apply(const Model &model, DynamicPrintConfig new_full_ BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << ", has_scarf_joint_seam:" << has_scarf_joint_seam; } + // A plate's filament maps can be longer than the filament list after a printer switch removes filaments. + if (const auto* diameter_opt = new_full_config.option("filament_diameter"); diameter_opt && !diameter_opt->values.empty()) + for (const char* key : {"filament_map", "filament_volume_map", "filament_nozzle_map"}) + if (auto* map_opt = new_full_config.option(key); map_opt && map_opt->values.size() > diameter_opt->values.size()) + map_opt->values.resize(diameter_opt->values.size()); + // A value outside [1, nozzle count] means nozzle 1. Normalize it here so the slicing engine // (Extruder::extruder_id(), the machine envelope, the variant expansion and the snapshot below) // only sees in-range values. This works on this print's copy of the config; readers of the diff --git a/src/slic3r/GUI/CalibrationWizardPresetPage.cpp b/src/slic3r/GUI/CalibrationWizardPresetPage.cpp index f4bda48973..b8cfc51ac9 100644 --- a/src/slic3r/GUI/CalibrationWizardPresetPage.cpp +++ b/src/slic3r/GUI/CalibrationWizardPresetPage.cpp @@ -1685,8 +1685,8 @@ void CalibrationPresetPage::update_combobox_filaments(MachineObject* obj) auto opt_extruder_type = printer_preset->config.option("extruder_type"); if (opt_extruder_type) { - assert(opt_extruder_type->values.size() <= 2); - for (size_t i = 0; i < opt_extruder_type->values.size(); ++i) { + // Presets for printers with more than 2 extruders list more types than m_extrder_types holds. + for (size_t i = 0; i < std::min(opt_extruder_type->values.size(), m_extrder_types.size()); ++i) { m_extrder_types[i] = (ExtruderType)(opt_extruder_type->values[i]); } } diff --git a/src/slic3r/GUI/ColorPickerDialog.cpp b/src/slic3r/GUI/ColorPickerDialog.cpp index f3f3c99685..cb504b6b29 100644 --- a/src/slic3r/GUI/ColorPickerDialog.cpp +++ b/src/slic3r/GUI/ColorPickerDialog.cpp @@ -890,7 +890,9 @@ void ColorPickerDialog::position_panel() return; m_positioning = true; // Both dimensions come from the page: width changes when the palette sidebar opens or closes. - wxSize size = FromDIP(wxSize(m_content_width, m_content_height)); + // m_content_* are CSS pixels as reported by the page; m_page_zoom converts them to DIPs. + wxSize size = FromDIP(wxSize(static_cast(std::ceil(m_content_width * m_page_zoom)), + static_cast(std::ceil(m_content_height * m_page_zoom)))); // The work-area limit includes the native title bar and fixed frame. const wxSize frame = GetSize() - GetClientSize(); size.x = std::min(size.x, std::max(1, m_work_area.width - frame.x)); @@ -1051,6 +1053,21 @@ void ColorPickerDialog::handle_web_command(const nlohmann::json& payload) return; m_content_width = static_cast(std::ceil(width_value)); } + // The viewport width the page sees (CSS px) against the WebView's real width (DIP) is the + // page zoom. Optional, so an older page keeps the current factor. + const auto viewport = payload.find("viewport"); + if (viewport != payload.end() && viewport->is_number()) { + const double css_width = viewport->get(); + const int dip_width = ToDIP(browser()->GetClientSize().x); + if (std::isfinite(css_width) && css_width >= 1 && dip_width > 0) { + double zoom = dip_width / css_width; + if (std::abs(zoom - 1.0) < 0.03) + zoom = 1.0; // integer rounding of either width, not a real zoom + // Ignore re-measurements that only differ by rounding, so the size stays stable. + if (zoom >= 0.5 && zoom <= 4.0 && std::abs(zoom - m_page_zoom) > 0.02 * m_page_zoom) + m_page_zoom = zoom; + } + } resize_to_content(static_cast(std::ceil(value))); return; } diff --git a/src/slic3r/GUI/ColorPickerDialog.hpp b/src/slic3r/GUI/ColorPickerDialog.hpp index ab4050f77e..411757e140 100644 --- a/src/slic3r/GUI/ColorPickerDialog.hpp +++ b/src/slic3r/GUI/ColorPickerDialog.hpp @@ -99,6 +99,9 @@ private: wxRect m_work_area; int m_content_height = 360; int m_content_width = 330; + // Window pixels (DIP) per CSS pixel of the page. Not always 1: WebKitGTK zooms the whole + // page by the system font DPI / text scaling. Measured from the page's "resize" message. + double m_page_zoom = 1.0; bool m_positioning = false; std::shared_ptr> m_alive = std::make_shared>(true); }; diff --git a/src/slic3r/GUI/ConfigManipulation.cpp b/src/slic3r/GUI/ConfigManipulation.cpp index 4d69214862..024e5c7d46 100644 --- a/src/slic3r/GUI/ConfigManipulation.cpp +++ b/src/slic3r/GUI/ConfigManipulation.cpp @@ -9,6 +9,7 @@ #include "libslic3r/MaterialType.hpp" #include "MsgDialog.hpp" #include "libslic3r/PrintConfig.hpp" +#include "libslic3r/FilamentMixer.hpp" #include "libslic3r/GCode/AdaptivePAProcessor.hpp" #include "Plater.hpp" @@ -638,9 +639,6 @@ void ConfigManipulation::update_print_fff_config(DynamicPrintConfig* config, con // tower additionally reject mixed slots: the engine consumes those keys directly, so a virtual // slot would reach the G-code unresolved, while the per-feature keys are resolved per layer. static const char* physical_only_keys[] = { "support_filament", "support_interface_filament", "brim_filament_id", "wipe_tower_filament" }; - static const char* feature_keys[] = { "outer_wall_filament_id", "inner_wall_filament_id", - "sparse_infill_filament_id", "internal_solid_filament_id", - "top_surface_filament_id", "bottom_surface_filament_id" }; auto reset_invalid_filament = [this, config, filament_cnt](const char* key, bool allow_mixed) { auto* opt = dynamic_cast(config->option(key, false)); if (opt == nullptr) @@ -663,7 +661,7 @@ void ConfigManipulation::update_print_fff_config(DynamicPrintConfig* config, con }; for (const char* key : physical_only_keys) reset_invalid_filament(key, false); - for (const char* key : feature_keys) + for (const char* key : feature_filament_keys) reset_invalid_filament(key, true); // Sub-layer splitting divides each layer by the mix ratio; an adaptive layer profile makes diff --git a/src/slic3r/GUI/CreatePresetsDialog.cpp b/src/slic3r/GUI/CreatePresetsDialog.cpp index 77d3e94943..17a182682d 100644 --- a/src/slic3r/GUI/CreatePresetsDialog.cpp +++ b/src/slic3r/GUI/CreatePresetsDialog.cpp @@ -54,6 +54,7 @@ #include #include #include +#include #include #include #include @@ -4018,6 +4019,9 @@ void ExportConfigsDialog::select_curr_radiobox(std::vectorFit(); int width = m_presets_window->GetSize().GetWidth(); int height = m_presets_window->GetSize().GetHeight(); + // Past the width cap the list gets a horizontal scrollbar, which takes its height from the list and can cover the checkboxes + if (width > 1200) + height += wxSystemSettings::GetMetric(wxSYS_HSCROLL_Y, m_scrolled_preset_window); m_scrolled_preset_window->SetMinSize(wxSize(std::min(1200, width), std::min(600, height))); m_scrolled_preset_window->SetMaxSize(wxSize(std::min(1200, width), std::min(600, height))); m_scrolled_preset_window->SetSize(wxSize(std::min(1200, width), std::min(600, height))); diff --git a/src/slic3r/GUI/DeviceCore/DevManager.cpp b/src/slic3r/GUI/DeviceCore/DevManager.cpp index 52e238fd1a..08a219bc1f 100644 --- a/src/slic3r/GUI/DeviceCore/DevManager.cpp +++ b/src/slic3r/GUI/DeviceCore/DevManager.cpp @@ -502,10 +502,12 @@ namespace Slic3r obj->printer_agent_id = get_current_printer_agent_id(); localMachineList.insert(std::make_pair(machine.dev_id, obj)); } - if (machine.printer_type.empty()) - obj->printer_type = _parse_printer_type("C11"); - else + // Only Bambu printers use the C11 fallback. Other agents may not report a model, + // so leave their existing model unchanged when none is provided. + if (!machine.printer_type.empty()) obj->printer_type = _parse_printer_type(machine.printer_type); + else if (obj->printer_agent_id == BBL_PRINTER_AGENT_ID) + obj->printer_type = _parse_printer_type("C11"); obj->dev_connection_type = connection_type == "farm" ? "lan":connection_type; obj->bind_state = connection_type == "farm" ? "free":bind_state; obj->bind_sec_link = "secure"; diff --git a/src/slic3r/GUI/FilamentMapDialog.cpp b/src/slic3r/GUI/FilamentMapDialog.cpp index 00fdfe6d21..2f43f3ee5a 100644 --- a/src/slic3r/GUI/FilamentMapDialog.cpp +++ b/src/slic3r/GUI/FilamentMapDialog.cpp @@ -9,6 +9,8 @@ #include "MsgDialog.hpp" #include "libslic3r/PrintConfig.hpp" #include "libslic3r/Config.hpp" +#include "libslic3r/PresetBundle.hpp" +#include #include #include #include @@ -16,7 +18,6 @@ #include "slic3r/GUI/Widgets/CheckBox.hpp" #include #include -#include #include #include #include "slic3r/GUI/FilamentMapPanel.hpp" @@ -154,8 +155,10 @@ bool try_pop_up_before_slice(bool is_slice_all, Plater* plater_ref, PartPlate* p std::vector filament_lists; if (is_slice_all) { - filament_lists.resize(filament_colors.size()); - std::iota(filament_lists.begin(), filament_lists.end(), 1); + // A mixed slot prints with the nozzles of its component filaments. + for (size_t i = 0; i < filament_colors.size(); ++i) + if (!preset->is_mixed_filament(i)) + filament_lists.push_back(int(i) + 1); } else { filament_lists = partplate_ref->get_extruders(); diff --git a/src/slic3r/GUI/GLCanvas3D.cpp b/src/slic3r/GUI/GLCanvas3D.cpp index 746488d49b..f0f23a8524 100644 --- a/src/slic3r/GUI/GLCanvas3D.cpp +++ b/src/slic3r/GUI/GLCanvas3D.cpp @@ -5201,6 +5201,8 @@ void GLCanvas3D::on_key(wxKeyEvent& evt) m_mouse.ignore_left_up = true; m_dirty = true; } + else if (m_is_touchpad_navigation && m_mouse.drag.camera_pan_anchor.has_value()) + mouse_up_cleanup(); // set_cursor(Standard); } else if (keyCode == WXK_ALT) { @@ -5210,13 +5212,11 @@ void GLCanvas3D::on_key(wxKeyEvent& evt) m_mouse.ignore_left_up = true; m_dirty = true; } + // Orbit stores its last pointer position in the 3D slot. A pan or a new button press sets the 2D slot. + else if (m_is_touchpad_navigation && m_camera_movement && m_mouse.is_start_position_3D_defined() && + !m_mouse.is_start_position_2D_defined()) + mouse_up_cleanup(); // set_cursor(Standard); -#ifdef __WXMSW__ - if (m_camera_movement && m_is_touchpad_navigation) { - m_camera_movement = false; - m_mouse.set_start_position_3D_as_invalid(); - } -#endif } else if (keyCode == WXK_CONTROL) m_dirty = true; @@ -5917,6 +5917,8 @@ void GLCanvas3D::on_mouse(wxMouseEvent& evt) && m_gizmos.get_current_type() != GLGizmosManager::Cut && m_gizmos.get_current_type() != GLGizmosManager::MmSegmentation && m_gizmos.get_current_type() != GLGizmosManager::FuzzySkin + && m_gizmos.get_current_type() != GLGizmosManager::Measure + && m_gizmos.get_current_type() != GLGizmosManager::Assembly && m_gizmos.get_current_type() != GLGizmosManager::PaintedModifier) { m_rectangle_selection.start_dragging(m_mouse.position, evt.ShiftDown() ? GLSelectionRectangle::Select : GLSelectionRectangle::Deselect); @@ -6257,7 +6259,9 @@ void GLCanvas3D::on_mouse(wxMouseEvent& evt) // forces a frame render to ensure that m_hover_volume_idxs is updated even when the user right clicks while // the context menu is already shown render(); - if (!m_hover_volume_idxs.empty()) { + // Orca: do not select the hovered volume when ending a camera pan/rotation + const bool camera_dragged = m_mouse.ignore_right_up; + if (!camera_dragged && !m_hover_volume_idxs.empty()) { // if right clicking on volume, propagate event through callback (shows context menu) int volume_idx = get_first_hover_volume_idx(); if (!m_volumes.volumes[volume_idx]->is_wipe_tower // no context menu for the wipe tower @@ -6780,7 +6784,14 @@ void GLCanvas3D::do_scale(const std::string& snapshot_type) continue; if (selection_mode == Selection::Instance) { - model_object->instances[instance_idx]->set_transformation(v->get_instance_transformation()); + ModelInstance* instance = model_object->instances[instance_idx]; + // ORCA: Apply the same change of scale to the pose in the assembly view. + // Done here, after the snapshot is taken, so that undo reverts it. + const Transform3d change = instance->get_transformation().get_matrix_no_offset().inverse() * + v->get_instance_transformation().get_matrix_no_offset(); + if (instance->is_assemble_initialized() && !change.isApprox(Transform3d::Identity())) + instance->set_assemble_from_transform(instance->get_assemble_transformation().get_matrix() * change); + instance->set_transformation(v->get_instance_transformation()); } else if (selection_mode == Selection::Volume) { auto cur_mv = model_object->volumes[volume_idx]; diff --git a/src/slic3r/GUI/GUI_App.cpp b/src/slic3r/GUI/GUI_App.cpp index a0a32a0360..003ff11047 100644 --- a/src/slic3r/GUI/GUI_App.cpp +++ b/src/slic3r/GUI/GUI_App.cpp @@ -326,6 +326,10 @@ typedef BOOL (WINAPI *LPFN_ISWOW64PROCESS2)( #include "LinuxDisplayBackend.hpp" #endif +#if !defined(_WIN32) && !defined(__APPLE__) +#include +#endif + // Needed for forcing menu icons back under gtk2 and gtk3 #if defined(__WXGTK20__) || defined(__WXGTK3__) #include @@ -3668,10 +3672,8 @@ bool GUI_App::on_init_inner() wxYield(); } - // Initialize plugins after network then register on_load callbacks so once the plugin loads finish, it gets registered automatically. - // initialize() also installs the libslic3r hooks (capability resolver, - // slicing-pipeline dispatcher) via plugin_hooks::install() -- no - // per-capability wiring belongs here. + // initialize() installs the libslic3r hooks (capability resolver, slicing-pipeline dispatcher) + // through plugin_hooks::install(), so per-capability wiring does not belong here. PluginManager& plugin_mgr = PluginManager::instance(); plugin_mgr.initialize(); @@ -3689,13 +3691,6 @@ bool GUI_App::on_init_inner() // Subscribe to the plugin loader and enumerate current actions (UI thread, once). m_action_registry->init(); - for (const std::string& plugin_key : plugin_mgr.get_enabled_plugin_keys()) { - if (!plugin_mgr.is_plugin_loaded(plugin_key)) { - plugin_mgr.load_plugin(plugin_key, false); - BOOST_LOG_TRIVIAL(info) << "Auto-loading plugin on startup: " << plugin_key; - } - } - copy_network_if_available(); on_init_network(); @@ -3849,6 +3844,15 @@ bool GUI_App::on_init_inner() plater_->get_partplate_list().set_filament_count(preset_bundle->filament_presets.size()); } + // Plugin code runs on the load thread and may read the presets, so start the loads only once + // the presets are loaded and selected. + for (const std::string& plugin_key : plugin_mgr.get_enabled_plugin_keys()) { + if (!plugin_mgr.is_plugin_loaded(plugin_key)) { + plugin_mgr.load_plugin(plugin_key, false); + BOOST_LOG_TRIVIAL(info) << "Auto-loading plugin on startup: " << plugin_key; + } + } + // BBS: #ifdef __WINDOWS__ mainframe->topbar()->SaveNormalRect(); @@ -8862,6 +8866,7 @@ bool GUI_App::load_language(wxString language, bool initial) } } + bool use_environment_locale = false; // Generic fallback chain for all platforms if (locale_language_info == nullptr || !wxLocale::IsAvailable(locale_language_info->Language)) { auto try_locale = [](const wxLanguageInfo* candidate) -> const wxLanguageInfo* { @@ -8878,6 +8883,15 @@ bool GUI_App::load_language(wxString language, bool initial) % fallback_locale_info->CanonicalName.ToUTF8().data() % requested_language_code.ToUTF8().data(); locale_language_info = fallback_locale_info; } +#if !defined(_WIN32) && !defined(__APPLE__) + // Uses the environment's locale last, since wxLocale::IsAvailable() can't report it (the AppImage forces LC_ALL=C). + else if (locale_t environment_locale = newlocale(LC_ALL_MASK, "", locale_t(0))) { + freelocale(environment_locale); + use_environment_locale = true; + BOOST_LOG_TRIVIAL(info) << boost::format("No locale for %1% or its fallbacks is installed. Using the environment locale instead.") + % requested_language_code.ToUTF8().data(); + } +#endif } if (initial) { @@ -8914,9 +8928,10 @@ bool GUI_App::load_language(wxString language, bool initial) //} } - BOOST_LOG_TRIVIAL(trace) << boost::format("Switching wxLocales to %1%") % locale_language_info->CanonicalName.ToUTF8().data(); + const std::string locale_name = use_environment_locale ? "the environment locale" : into_u8(locale_language_info->CanonicalName); + BOOST_LOG_TRIVIAL(trace) << boost::format("Switching wxLocales to %1%") % locale_name; - if (!wxLocale::IsAvailable(locale_language_info->Language)) { + if (!use_environment_locale && !wxLocale::IsAvailable(locale_language_info->Language)) { // Loading the language dictionary failed. wxString message = wxString::Format(_L("Switching Orca Slicer to language %s failed."), requested_language_code); #if !defined(_WIN32) && !defined(__APPLE__) @@ -8936,10 +8951,13 @@ bool GUI_App::load_language(wxString language, bool initial) //FIXME wxWidgets cause havoc if the current locale is deleted. We just forget it causing memory leaks for now. m_wxLocale.release(); m_wxLocale = Slic3r::make_unique(); - m_wxLocale->Init(locale_language_info->Language); + // Defers the wxstd catalog until after SetLanguage() below, so it matches the dictionary's language. + if (!m_wxLocale->Init(use_environment_locale ? wxLANGUAGE_DEFAULT : locale_language_info->Language, wxLOCALE_DONT_LOAD_DEFAULT)) + BOOST_LOG_TRIVIAL(error) << boost::format("Failed to set the locale to %1%") % locale_name; // Override language at the active wxTranslations class (which is stored in the active m_wxLocale) // to load possibly different dictionary, for example, load Czech dictionary for Slovak language. wxTranslations::Get()->SetLanguage(language_dict); + wxTranslations::Get()->AddStdCatalog(); m_wxLocale->AddCatalog(SLIC3R_APP_KEY); m_active_language_code = requested_language_code; m_imgui->set_language(into_u8(requested_language_code)); diff --git a/src/slic3r/GUI/GUI_Factories.cpp b/src/slic3r/GUI/GUI_Factories.cpp index 6bcb9b9587..a735d2f0b7 100644 --- a/src/slic3r/GUI/GUI_Factories.cpp +++ b/src/slic3r/GUI/GUI_Factories.cpp @@ -2500,11 +2500,7 @@ void MenuFactory::append_menu_item_center(wxMenu* menu) if (plater()->canvas3D()->get_canvas_type() != GLCanvas3D::ECanvasType::CanvasView3D) return false; else { - Selection& selection = plater()->get_view3D_canvas3D()->get_selection(); - PartPlate* plate = plater()->get_partplate_list().get_selected_plate(); - Vec3d model_pos = selection.get_bounding_box().center(); - Vec3d center_pos = plate->get_center_origin(); - return !( (model_pos.x() == center_pos.x()) && (model_pos.y() == center_pos.y()) ); + return plater()->get_view3D_canvas3D()->get_selection().can_center(); } //disable if model is at center / not in View3D }, m_parent); } diff --git a/src/slic3r/GUI/GUI_ObjectList.cpp b/src/slic3r/GUI/GUI_ObjectList.cpp index b15db6ca68..ccaed5f57a 100644 --- a/src/slic3r/GUI/GUI_ObjectList.cpp +++ b/src/slic3r/GUI/GUI_ObjectList.cpp @@ -789,6 +789,19 @@ void ObjectList::update_filament_values_for_items(const size_t filaments_count) if (object->config.has(key) && object->config.opt_int(key) > filaments_count) object->config.erase(key); + if (const auto layer_root = m_objects_model->GetLayerRootItem(item)) { + wxDataViewItemArray layer_items; + m_objects_model->GetChildren(layer_root, layer_items); + for (const auto &layer_item : layer_items) { + const auto range = object->layer_config_ranges.find(m_objects_model->GetLayerRangeByItem(layer_item)); + if (range == object->layer_config_ranges.end() || !range->second.has("extruder")) + continue; + const int slot = range->second.extruder(); + if (slot != m_objects_model->GetExtruderNumber(layer_item)) + m_objects_model->SetExtruder(slot == 0 ? _L("default") : wxString::Format("%d", slot), layer_item); + } + } + if (object->volumes.size() > 1) { for (size_t id = 0; id < object->volumes.size(); id++) { item = m_objects_model->GetItemByVolumeId(i, id); @@ -7621,32 +7634,36 @@ ModelObject* ObjectList::object(const int obj_idx) const void ObjectList::apply_object_instance_transfrom_to_all_volumes(ModelObject *model_object, bool need_update_assemble_matrix) { - const Geometry::Transformation &instance_transformation = model_object->instances[0]->get_transformation(); - Vec3d original_instance_center = instance_transformation.get_offset(); + // ORCA: Rotation, scale and mirror of the first instance, without its offset. + const Transform3d instance_matrix = model_object->instances[0]->get_transformation().get_matrix_no_offset(); + const Transform3d instance_inverse_matrix = instance_matrix.inverse(); - if (need_update_assemble_matrix) { - // apply the instance_transform(except offset) to assemble_transform - Geometry::Transformation instance_transformation_copy = instance_transformation; - instance_transformation_copy.set_offset(Vec3d(0, 0, 0)); // remove the effect of offset - const Transform3d &instance_inverse_matrix = instance_transformation_copy.get_matrix().inverse(); - const Transform3d &assemble_matrix = model_object->instances[0]->get_assemble_transformation().get_matrix(); - Transform3d new_assemble_transform = assemble_matrix * instance_inverse_matrix; - model_object->instances[0]->set_assemble_from_transform(new_assemble_transform); - } - - // apply the instance_transform to volumn - const Transform3d &transformation_matrix = instance_transformation.get_matrix(); + // ORCA: Apply this transform to the volumes. for (ModelVolume *volume : model_object->volumes) { - const Transform3d &volume_matrix = volume->get_matrix(); - Transform3d new_matrix = transformation_matrix * volume_matrix; + const Transform3d new_matrix = instance_matrix * volume->get_matrix(); volume->set_transformation(new_matrix); } - model_object->instances[0]->set_transformation(Geometry::Transformation()); + // ORCA: Remove it from every instance, so that none of them moves: the volumes are shared by all instances. + for (ModelInstance *instance : model_object->instances) { + // ORCA: Skip instances without an assembly pose: setting one here would mark them as initialized. + if (need_update_assemble_matrix && instance->is_assemble_initialized()) { + const Transform3d new_assemble_transform = instance->get_assemble_transformation().get_matrix() * instance_inverse_matrix; + instance->set_assemble_from_transform(new_assemble_transform); + } + + const Vec3d offset = instance->get_offset(); + Transform3d new_matrix = instance->get_transformation().get_matrix_no_offset() * instance_inverse_matrix; + // ORCA: Usual case, same rotation and scale as the first instance: exact identity instead of rounding noise. + if (new_matrix.isApprox(Transform3d::Identity())) + new_matrix.setIdentity(); + new_matrix.translation() = offset; + instance->set_transformation(Geometry::Transformation(new_matrix)); + } + + // ORCA: The setters above do not invalidate the cached bounding boxes. + model_object->invalidate_bounding_box(); model_object->ensure_on_bed(); - // keep new instance center the same as the original center - model_object->translate(-original_instance_center); - model_object->translate_instances(original_instance_center); // update the cache data in selection to keep the data of ModelVolume and GLVolume are consistent wxGetApp().plater()->update(); diff --git a/src/slic3r/GUI/Gizmos/GLGizmoEmboss.cpp b/src/slic3r/GUI/Gizmos/GLGizmoEmboss.cpp index 12a53242db..ab4a24450d 100644 --- a/src/slic3r/GUI/Gizmos/GLGizmoEmboss.cpp +++ b/src/slic3r/GUI/Gizmos/GLGizmoEmboss.cpp @@ -394,18 +394,40 @@ bool GLGizmoEmboss::create_volume(ModelVolumeType volume_type) bool GLGizmoEmboss::on_shortcut_key() { + // Already opened: close it like the other gizmos do. Text stays selected, so next press edits it again. + auto& mng = m_parent.get_gizmos_manager(); + if (mng.get_current_type() == GLGizmosManager::Emboss) { + close(); + return false; + } + + // Text object selected with more instances: edit works with one of them, so keep selected only the first. + Selection& selection = m_parent.get_selection(); + bool is_selection_reduced = false; + if (selection.get_object_idx() >= 0 && selection.get_volume_idxs().size() > 1) { + const ModelVolume *volume = get_model_volume(*selection.get_first_volume(), selection.get_model()->objects); + if (volume != nullptr && volume->is_text() && volume->get_object()->volumes.size() == 1) { + selection.add_volumes(selection.get_mode(), {*selection.get_volume_idxs().begin()}); + is_selection_reduced = true; + } + } + set_volume_by_selection(); + bool creation_started = false; if (m_volume == nullptr) { // No volume to select from selection so create volume. // NOTE: After finish job for creation emboss Text volume, // GLGizmoEmboss will be opened - return create_volume(ModelVolumeType::MODEL_PART); + creation_started = create_volume(ModelVolumeType::MODEL_PART); } - // shortcut is pressed when text is selected soo start edit it. - auto& mng = m_parent.get_gizmos_manager(); - if (mng.get_current_type() != GLGizmosManager::Emboss) + else { + // shortcut is pressed when text is selected soo start edit it. mng.open_gizmo(GLGizmosManager::Emboss); - return false; + } + + if (is_selection_reduced) + wxGetApp().obj_list()->update_selections(); + return creation_started; } bool GLGizmoEmboss::re_emboss(const ModelVolume &text_volume, std::shared_ptr> job_cancel) @@ -547,7 +569,9 @@ void add_style_for_default_text(EmbossStyles &styles) if (text == default_text || can_write(styles.front(), text)) return; - for (const char *face_name : {"HarmonyOS Sans SC", "NanumGothic", "Sarabun"}) { + // Sarabun ships as Medium and SemiBold only. Windows lists such weights as families of their own, + // "Sarabun Medium" and "Sarabun SemiBold", so the plain family name is not a valid face name there. + for (const char *face_name : {"HarmonyOS Sans SC", "NanumGothic", "Sarabun", "Sarabun Medium"}) { wxFont wx_font = *wxNORMAL_FONT; if (!wx_font.SetFaceName(face_name)) continue; diff --git a/src/slic3r/GUI/Gizmos/GizmoObjectManipulation.cpp b/src/slic3r/GUI/Gizmos/GizmoObjectManipulation.cpp index 6bcca9623e..9d0d65a610 100644 --- a/src/slic3r/GUI/Gizmos/GizmoObjectManipulation.cpp +++ b/src/slic3r/GUI/Gizmos/GizmoObjectManipulation.cpp @@ -280,6 +280,8 @@ void GizmoObjectManipulation::update_reset_buttons_visibility() // Assembly view has its own selection and transformations, which drop_selection() doesn't update m_enable_drop_to_bed = m_glcanvas.get_canvas_type() == GLCanvas3D::ECanvasType::CanvasView3D && selection.can_drop(); + m_enable_center_to_bed = m_glcanvas.get_canvas_type() == GLCanvas3D::ECanvasType::CanvasView3D && selection.can_center(); + if (selection.is_single_full_instance() || selection.is_single_volume_or_modifier()) { const GLVolume * volume = selection.get_first_volume(); @@ -1096,6 +1098,17 @@ void GizmoObjectManipulation::do_render_move_window(ImGuiWrapper *imgui_wrapper, if(ImGui::IsItemHovered(ImGuiHoveredFlags_AllowWhenDisabled)) imgui_wrapper->tooltip(_L("Move the selection along Z so that its lowest point touches the bed."), ImGui::GetFontSize() * 20.0f); + // ORCA + imgui_wrapper->disabled_begin(!m_enable_center_to_bed); + ImGui::SameLine(0, space_size); + if (imgui_wrapper->button(_L("Center"))) { + wxGetApp().plater()->center_selection(); + UpdateAndShow(true); + } + imgui_wrapper->disabled_end(); + if (ImGui::IsItemHovered(ImGuiHoveredFlags_AllowWhenDisabled)) + imgui_wrapper->tooltip(_L("Move the selection in X and Y to the center of the current plate, even if it is on another plate."), ImGui::GetFontSize() * 20.0f); + ImGui::SameLine(); GLGizmoUtils::begin_right_aligned_buttons({ _L("Done") }); if (imgui_wrapper->button(_L("Done"))) { diff --git a/src/slic3r/GUI/Gizmos/GizmoObjectManipulation.hpp b/src/slic3r/GUI/Gizmos/GizmoObjectManipulation.hpp index 196daec9fe..f50ca30ca6 100644 --- a/src/slic3r/GUI/Gizmos/GizmoObjectManipulation.hpp +++ b/src/slic3r/GUI/Gizmos/GizmoObjectManipulation.hpp @@ -104,6 +104,7 @@ public: bool m_show_clear_rotation { false }; bool m_show_clear_scale { false }; bool m_enable_drop_to_bed { false }; + bool m_enable_center_to_bed { false }; enum class RotateType { None, Relative, Absolute }; RotateType m_last_rotate_type{RotateType::None}; // 0:no input 1:relative 2:absolute diff --git a/src/slic3r/GUI/Jobs/EmbossJob.cpp b/src/slic3r/GUI/Jobs/EmbossJob.cpp index 471359b8b7..b17032f339 100644 --- a/src/slic3r/GUI/Jobs/EmbossJob.cpp +++ b/src/slic3r/GUI/Jobs/EmbossJob.cpp @@ -402,6 +402,8 @@ void CreateObjectJob::finalize(bool canceled, std::exception_ptr &eptr) Slic3r::Geometry::Transformation tr(m_transformation); new_object->instances.front()->set_transformation(tr); new_object->ensure_on_bed(); + // ORCA: Give it a pose in the assembly view, as other new objects get. + model.set_assembly_pos(new_object); // Actualize right panel and set inside of selection app.obj_list()->paste_objects_into_list({model.objects.size() - 1}); diff --git a/src/slic3r/GUI/Jobs/FillBedJob.cpp b/src/slic3r/GUI/Jobs/FillBedJob.cpp index 3f4017e279..a288cc0610 100644 --- a/src/slic3r/GUI/Jobs/FillBedJob.cpp +++ b/src/slic3r/GUI/Jobs/FillBedJob.cpp @@ -56,6 +56,7 @@ void FillBedJob::prepare() //select current plate at first int sel_id = m_plater->get_selection().get_instance_idx(); sel_id = std::max(sel_id, 0); + m_instance_idx = sel_id; int sel_ret = plate_list.select_plate_by_obj(m_object_idx, sel_id); BOOST_LOG_TRIVIAL(debug) << __FUNCTION__ << boost::format(":select plate obj_id %1%, ins_id %2%, ret %3%}") % m_object_idx % sel_id % sel_ret; @@ -401,6 +402,8 @@ void FillBedJob::finalize(bool canceled, std::exception_ptr &eptr) // without asking once per copy, as the objects Fill bed with copies adds do. for (size_t i = inst_cnt; i < model_object->instances.size(); ++i) plate_list.notify_instance_update(m_object_idx, int(i), true); + // ORCA: Place the copies in the assembly view, otherwise they all sit on their source. + m_plater->model().set_assembly_pos_of_copies(model_object, size_t(m_instance_idx), inst_cnt); // Match the normal add-instance flow: update the scene before the // object tree starts referring to the newly created instances. m_plater->update(); diff --git a/src/slic3r/GUI/Jobs/FillBedJob.hpp b/src/slic3r/GUI/Jobs/FillBedJob.hpp index 6a2300dc60..703ad4bfd0 100644 --- a/src/slic3r/GUI/Jobs/FillBedJob.hpp +++ b/src/slic3r/GUI/Jobs/FillBedJob.hpp @@ -14,6 +14,8 @@ class Plater; class FillBedJob : public Job { int m_object_idx = -1; + // ORCA: Source instance of the copies. + int m_instance_idx = 0; using ArrangePolygon = arrangement::ArrangePolygon; using ArrangePolygons = arrangement::ArrangePolygons; diff --git a/src/slic3r/GUI/ObjectDataViewModel.cpp b/src/slic3r/GUI/ObjectDataViewModel.cpp index 3f96069748..c9a74f6312 100644 --- a/src/slic3r/GUI/ObjectDataViewModel.cpp +++ b/src/slic3r/GUI/ObjectDataViewModel.cpp @@ -2101,6 +2101,13 @@ bool ObjectDataViewModel::IsContainer(const wxDataViewItem &item) const return node->IsContainer(); } +const ModelObject* ObjectDataViewModel::live_model_object(const ModelObject* row_object, const std::vector& model_objects) +{ + if (row_object == nullptr) + return nullptr; + return std::find(model_objects.begin(), model_objects.end(), row_object) != model_objects.end() ? row_object : nullptr; +} + unsigned int ObjectDataViewModel::GetChildren(const wxDataViewItem &parent, wxDataViewItemArray &array) const { ObjectDataViewModelNode *node = static_cast(parent.GetID()); @@ -2128,8 +2135,9 @@ unsigned int ObjectDataViewModel::GetChildren(const wxDataViewItem &parent, wxDa std::vector children; for (auto* child : node->GetChildren()) children.push_back(child); - if (node->m_type == itObject && node->m_model_object != nullptr) { - const ModelObject& object = *node->m_model_object; + const ModelObject* live_object = node->m_type == itObject ? live_model_object(node->m_model_object, wxGetApp().model().objects) : nullptr; + if (live_object != nullptr) { + const ModelObject& object = *live_object; if (std::any_of(object.volumes.begin(), object.volumes.end(), [](const ModelVolume* volume) { return volume->import_display_order >= 0; })) { diff --git a/src/slic3r/GUI/ObjectDataViewModel.hpp b/src/slic3r/GUI/ObjectDataViewModel.hpp index 25cea565a6..fb614f2575 100644 --- a/src/slic3r/GUI/ObjectDataViewModel.hpp +++ b/src/slic3r/GUI/ObjectDataViewModel.hpp @@ -368,6 +368,9 @@ public: ~ObjectDataViewModel(); void Init(); + // `row_object` while `model_objects` holds it, else null. A delete frees the model object before its row + // goes, and macOS reads the row in between; compares pointers only, so a freed one is never read. + static const ModelObject* live_model_object(const ModelObject* row_object, const std::vector& model_objects); std::map> &get_ui_and_3d_volume_map() { return m_ui_and_3d_volume_maps; } int get_real_volume_index_in_3d(int ui_object_value, int ui_volume_value) { diff --git a/src/slic3r/GUI/Operations/ObjectOps.cpp b/src/slic3r/GUI/Operations/ObjectOps.cpp index 8ddcab27dc..8ab216dcaa 100644 --- a/src/slic3r/GUI/Operations/ObjectOps.cpp +++ b/src/slic3r/GUI/Operations/ObjectOps.cpp @@ -682,7 +682,7 @@ Outcome>> center_objects(const CenterObjectsArgs& if (args.targets.from_selection) { if (args.plate) canvas.do_center_plate(*args.plate); - else + else if (plater.get_selection().can_center()) // as the Center menu item is enabled: a centred selection adds no undo step plater.center_selection(); const std::set objects = objects_of(args.targets); return std::map>{{args.plate.value_or(current), std::vector(objects.begin(), objects.end())}}; diff --git a/src/slic3r/GUI/PartPlate.cpp b/src/slic3r/GUI/PartPlate.cpp index 4c00e59111..50aeb9517a 100644 --- a/src/slic3r/GUI/PartPlate.cpp +++ b/src/slic3r/GUI/PartPlate.cpp @@ -2994,19 +2994,69 @@ int PartPlate::picking_id_component(int idx) const return this->m_plate_index * GRABBER_COUNT + idx; } +static int filament_slot_count(const DynamicPrintConfig& config) +{ + const auto* colours = config.option("filament_colour"); + return colours != nullptr ? int(colours->values.size()) : std::numeric_limits::max(); +} + +// The slicer prints an object's, part's or layer range's filament id past the last slot with filament 1. +static int printed_filament(int filament_id, int filament_count) +{ + return filament_id <= filament_count ? filament_id : 1; +} + +static int print_wide_filament(const DynamicPrintConfig& config, const char* key, int filament_count, int past_last_slot) +{ + const ConfigOption* opt = config.option(key); + const int filament_id = opt != nullptr ? opt->getInt() : 0; + return filament_id <= filament_count ? filament_id : past_last_slot; +} + +static void append_filament_setting(const ModelConfig& config, const char* key, int filament_count, std::vector& filaments) +{ + if (const ConfigOption* opt = config.option(key); opt != nullptr && opt->getInt() > 0) + filaments.push_back(printed_filament(opt->getInt(), filament_count)); +} + +static void append_feature_filaments(const ModelConfig& config, int filament_count, std::vector& filaments) +{ + for (const char* key : {"outer_wall_filament_id", "inner_wall_filament_id", "sparse_infill_filament_id", + "internal_solid_filament_id", "top_surface_filament_id", "bottom_surface_filament_id"}) + append_filament_setting(config, key, filament_count, filaments); +} + +static void append_volume_and_layer_range_filaments(const ModelObject& object, int filament_count, std::vector& filaments) +{ + for (const ModelVolume* mv : object.volumes) { + std::vector volume_extruders = mv->get_extruders(); + // The slicer prints the volume's own filament id past the last slot with filament 1. + if (const int own_filament = mv->extruder_id(); own_filament > filament_count) + std::replace(volume_extruders.begin(), volume_extruders.end(), own_filament, 1); + filaments.insert(filaments.end(), volume_extruders.begin(), volume_extruders.end()); + // Only parts and modifiers make print regions, so another volume's feature filaments never print. + if (mv->is_model_part() || mv->is_region_modifier()) + append_feature_filaments(mv->config, filament_count, filaments); + } + for (const auto& [range, config] : object.layer_config_ranges) { + append_filament_setting(config, "extruder", filament_count, filaments); + append_feature_filaments(config, filament_count, filaments); + } +} + std::vector PartPlate::get_extruders(bool conside_custom_gcode, bool expand_mixed_slots) const { std::vector plate_extruders; if (check_objects_empty_and_gcode3mf(plate_extruders)) { return plate_extruders; } - return get_extruders(conside_custom_gcode, wxGetApp().preset_bundle->prints.get_edited_preset().config, wxGetApp().preset_bundle->project_config, expand_mixed_slots); + return get_extruders(conside_custom_gcode, wxGetApp().preset_bundle->prints.get_edited_preset().config, wxGetApp().preset_bundle->project_config, expand_mixed_slots, true); } // The plate's filaments, with the global keys read from the given configs rather than the // application's presets: the wipe tower estimate is also called under the CLI, which has no // application object. get_extruders(bool) passes the edited presets; a full config serves both. -std::vector PartPlate::get_extruders(bool conside_custom_gcode, const DynamicPrintConfig& glb_config, const DynamicPrintConfig& project_config, bool expand_mixed_slots) const +std::vector PartPlate::get_extruders(bool conside_custom_gcode, const DynamicPrintConfig& glb_config, const DynamicPrintConfig& project_config, bool expand_mixed_slots, bool reset_print_wide_ids) const { std::vector plate_extruders; // A plate from a sliced .gcode.3mf holds no objects, so report the filaments the G-code @@ -3017,17 +3067,23 @@ std::vector PartPlate::get_extruders(bool conside_custom_gcode, const Dynam plate_extruders.push_back(info.id + 1); return plate_extruders; } - int glb_support_intf_extr = glb_config.opt_int("support_interface_filament"); - int glb_support_extr = glb_config.opt_int("support_filament"); - int glb_outer_wall_extr = glb_config.opt_int("outer_wall_filament_id"); - int glb_inner_wall_extr = glb_config.opt_int("inner_wall_filament_id"); + const int filament_count = filament_slot_count(project_config); + // PresetBundle::full_config() resets a print-wide feature id past the last slot to the default and caps a support + // id at the last slot, while the slicer prints either with filament 1. + const int stale_feature_extr = reset_print_wide_ids ? 0 : 1; + const int stale_support_extr = reset_print_wide_ids ? filament_count : 1; + int glb_support_intf_extr = print_wide_filament(glb_config, "support_interface_filament", filament_count, stale_support_extr); + int glb_support_extr = print_wide_filament(glb_config, "support_filament", filament_count, stale_support_extr); + int glb_outer_wall_extr = print_wide_filament(glb_config, "outer_wall_filament_id", filament_count, stale_feature_extr); + int glb_inner_wall_extr = print_wide_filament(glb_config, "inner_wall_filament_id", filament_count, stale_feature_extr); if (glb_outer_wall_extr == 0) glb_outer_wall_extr = glb_inner_wall_extr; if (glb_inner_wall_extr == 0) glb_inner_wall_extr = glb_outer_wall_extr; - int glb_sparse_infill_extr = glb_config.opt_int("sparse_infill_filament_id"); - int glb_internal_solid_extr = glb_config.opt_int("internal_solid_filament_id"); - int glb_top_surface_extr = glb_config.opt_int("top_surface_filament_id"); - int glb_bottom_surface_extr = glb_config.opt_int("bottom_surface_filament_id"); - const int glb_brim_extr = glb_config.opt_int("brim_filament_id"); + int glb_sparse_infill_extr = print_wide_filament(glb_config, "sparse_infill_filament_id", filament_count, stale_feature_extr); + int glb_internal_solid_extr = print_wide_filament(glb_config, "internal_solid_filament_id", filament_count, stale_feature_extr); + int glb_top_surface_extr = print_wide_filament(glb_config, "top_surface_filament_id", filament_count, stale_feature_extr); + int glb_bottom_surface_extr = print_wide_filament(glb_config, "bottom_surface_filament_id", filament_count, stale_feature_extr); + // PresetBundle::full_config() and the slicer both reset a print-wide brim filament id past the last slot to the default. + const int glb_brim_extr = print_wide_filament(glb_config, "brim_filament_id", filament_count, 0); const bool glb_brim = glb_config.option("brim_type")->getInt() != int(BrimType::btNoBrim); bool glb_support = glb_config.opt_bool("enable_support"); glb_support |= glb_config.opt_int("raft_layers") > 0; @@ -3039,18 +3095,7 @@ std::vector PartPlate::get_extruders(bool conside_custom_gcode, const Dynam continue; ModelObject* mo = m_model->objects[obj_idx]; - for (ModelVolume* mv : mo->volumes) { - std::vector volume_extruders = mv->get_extruders(); - plate_extruders.insert(plate_extruders.end(), volume_extruders.begin(), volume_extruders.end()); - } - - // layer range - for (auto layer_range : mo->layer_config_ranges) { - if (layer_range.second.has("extruder")) { - if (auto id = layer_range.second.option("extruder")->getInt(); id > 0) - plate_extruders.push_back(id); - } - } + append_volume_and_layer_range_filaments(*mo, filament_count, plate_extruders); bool obj_support = false; const ConfigOption* obj_support_opt = mo->config.option("enable_support"); @@ -3070,7 +3115,7 @@ std::vector PartPlate::get_extruders(bool conside_custom_gcode, const Dynam if (support_intf_extr_opt != nullptr) obj_support_intf_extr = support_intf_extr_opt->getInt(); if (obj_support_intf_extr != 0) - plate_extruders.push_back(obj_support_intf_extr); + plate_extruders.push_back(printed_filament(obj_support_intf_extr, filament_count)); else if (glb_support_intf_extr != 0) plate_extruders.push_back(glb_support_intf_extr); @@ -3079,7 +3124,7 @@ std::vector PartPlate::get_extruders(bool conside_custom_gcode, const Dynam if (support_extr_opt != nullptr) obj_support_extr = support_extr_opt->getInt(); if (obj_support_extr != 0) - plate_extruders.push_back(obj_support_extr); + plate_extruders.push_back(printed_filament(obj_support_extr, filament_count)); else if (glb_support_extr != 0) plate_extruders.push_back(glb_support_extr); } @@ -3091,7 +3136,7 @@ std::vector PartPlate::get_extruders(bool conside_custom_gcode, const Dynam if (const ConfigOption* wall_opt = mo->config.option("inner_wall_filament_id"); wall_opt != nullptr) obj_outer_wall_extr = wall_opt->getInt(); if (obj_outer_wall_extr != 0) - plate_extruders.push_back(obj_outer_wall_extr); + plate_extruders.push_back(printed_filament(obj_outer_wall_extr, filament_count)); else if (glb_outer_wall_extr != 0) plate_extruders.push_back(glb_outer_wall_extr); @@ -3102,7 +3147,7 @@ std::vector PartPlate::get_extruders(bool conside_custom_gcode, const Dynam if (const ConfigOption* wall_opt = mo->config.option("outer_wall_filament_id"); wall_opt != nullptr) obj_inner_wall_extr = wall_opt->getInt(); if (obj_inner_wall_extr != 0) - plate_extruders.push_back(obj_inner_wall_extr); + plate_extruders.push_back(printed_filament(obj_inner_wall_extr, filament_count)); else if (glb_inner_wall_extr != 0) plate_extruders.push_back(glb_inner_wall_extr); @@ -3111,7 +3156,7 @@ std::vector PartPlate::get_extruders(bool conside_custom_gcode, const Dynam if (sparse_infill_opt != nullptr) obj_sparse_infill_extr = sparse_infill_opt->getInt(); if (obj_sparse_infill_extr != 0) - plate_extruders.push_back(obj_sparse_infill_extr); + plate_extruders.push_back(printed_filament(obj_sparse_infill_extr, filament_count)); else if (glb_sparse_infill_extr != 0) plate_extruders.push_back(glb_sparse_infill_extr); @@ -3119,7 +3164,7 @@ std::vector PartPlate::get_extruders(bool conside_custom_gcode, const Dynam if (const ConfigOption* solid_opt = mo->config.option("internal_solid_filament_id"); solid_opt != nullptr) obj_internal_solid_extr = solid_opt->getInt(); if (obj_internal_solid_extr != 0) - plate_extruders.push_back(obj_internal_solid_extr); + plate_extruders.push_back(printed_filament(obj_internal_solid_extr, filament_count)); else if (glb_internal_solid_extr != 0) plate_extruders.push_back(glb_internal_solid_extr); @@ -3127,7 +3172,7 @@ std::vector PartPlate::get_extruders(bool conside_custom_gcode, const Dynam if (const ConfigOption* top_opt = mo->config.option("top_surface_filament_id"); top_opt != nullptr) obj_top_surface_extr = top_opt->getInt(); if (obj_top_surface_extr != 0) - plate_extruders.push_back(obj_top_surface_extr); + plate_extruders.push_back(printed_filament(obj_top_surface_extr, filament_count)); else if (glb_top_surface_extr != 0) plate_extruders.push_back(glb_top_surface_extr); @@ -3135,14 +3180,15 @@ std::vector PartPlate::get_extruders(bool conside_custom_gcode, const Dynam if (const ConfigOption* bottom_opt = mo->config.option("bottom_surface_filament_id"); bottom_opt != nullptr) obj_bottom_surface_extr = bottom_opt->getInt(); if (obj_bottom_surface_extr != 0) - plate_extruders.push_back(obj_bottom_surface_extr); + plate_extruders.push_back(printed_filament(obj_bottom_surface_extr, filament_count)); else if (glb_bottom_surface_extr != 0) plate_extruders.push_back(glb_bottom_surface_extr); const ConfigOption* brim_type_opt = mo->config.option("brim_type"); if (brim_type_opt != nullptr ? brim_type_opt->getInt() != int(BrimType::btNoBrim) : glb_brim) { const ConfigOption* brim_opt = mo->config.option("brim_filament_id"); - if (const int brim_extr = brim_opt != nullptr ? brim_opt->getInt() : glb_brim_extr; brim_extr != 0) + // The slicer resets an object's brim filament id past the last slot to the default. + if (const int brim_extr = brim_opt != nullptr ? brim_opt->getInt() : glb_brim_extr; brim_extr != 0 && brim_extr <= filament_count) plate_extruders.push_back(brim_extr); } } @@ -3188,20 +3234,22 @@ std::vector PartPlate::get_extruders(bool conside_custom_gcode, const Dynam std::vector PartPlate::get_extruders_under_cli(bool conside_custom_gcode, DynamicPrintConfig& full_config, bool expand_mixed_slots) const { std::vector plate_extruders; + const int filament_count = filament_slot_count(full_config); // if 3mf file - int glb_support_intf_extr = full_config.opt_int("support_interface_filament"); - int glb_support_extr = full_config.opt_int("support_filament"); - int glb_outer_wall_extr = full_config.opt_int("outer_wall_filament_id"); - int glb_inner_wall_extr = full_config.opt_int("inner_wall_filament_id"); + // The slicer prints a print-wide support or feature filament id past the last slot with filament 1. + int glb_support_intf_extr = print_wide_filament(full_config, "support_interface_filament", filament_count, 1); + int glb_support_extr = print_wide_filament(full_config, "support_filament", filament_count, 1); + int glb_outer_wall_extr = print_wide_filament(full_config, "outer_wall_filament_id", filament_count, 1); + int glb_inner_wall_extr = print_wide_filament(full_config, "inner_wall_filament_id", filament_count, 1); if (glb_outer_wall_extr == 0) glb_outer_wall_extr = glb_inner_wall_extr; if (glb_inner_wall_extr == 0) glb_inner_wall_extr = glb_outer_wall_extr; - int glb_sparse_infill_extr = full_config.opt_int("sparse_infill_filament_id"); - int glb_internal_solid_extr = full_config.opt_int("internal_solid_filament_id"); - int glb_top_surface_extr = full_config.opt_int("top_surface_filament_id"); - int glb_bottom_surface_extr = full_config.opt_int("bottom_surface_filament_id"); - const ConfigOption* glb_brim_opt = full_config.option("brim_filament_id"); - const int glb_brim_extr = glb_brim_opt != nullptr ? glb_brim_opt->getInt() : 0; + int glb_sparse_infill_extr = print_wide_filament(full_config, "sparse_infill_filament_id", filament_count, 1); + int glb_internal_solid_extr = print_wide_filament(full_config, "internal_solid_filament_id", filament_count, 1); + int glb_top_surface_extr = print_wide_filament(full_config, "top_surface_filament_id", filament_count, 1); + int glb_bottom_surface_extr = print_wide_filament(full_config, "bottom_surface_filament_id", filament_count, 1); + // The slicer resets a print-wide brim filament id past the last slot to the default. + const int glb_brim_extr = print_wide_filament(full_config, "brim_filament_id", filament_count, 0); const bool glb_brim = full_config.option("brim_type")->getInt() != int(BrimType::btNoBrim); bool glb_support = full_config.opt_bool("enable_support"); @@ -3220,18 +3268,7 @@ std::vector PartPlate::get_extruders_under_cli(bool conside_custom_gcode, D if (!instance->printable) continue; - for (ModelVolume* mv : object->volumes) { - std::vector volume_extruders = mv->get_extruders(); - plate_extruders.insert(plate_extruders.end(), volume_extruders.begin(), volume_extruders.end()); - } - - // layer range - for (auto layer_range : object->layer_config_ranges) { - if (layer_range.second.has("extruder")) { - if (auto id = layer_range.second.option("extruder")->getInt(); id > 0) - plate_extruders.push_back(id); - } - } + append_volume_and_layer_range_filaments(*object, filament_count, plate_extruders); bool obj_support = false; const ConfigOption* obj_support_opt = object->config.option("enable_support"); @@ -3251,7 +3288,7 @@ std::vector PartPlate::get_extruders_under_cli(bool conside_custom_gcode, D if (support_intf_extr_opt != nullptr) obj_support_intf_extr = support_intf_extr_opt->getInt(); if (obj_support_intf_extr != 0) - plate_extruders.push_back(obj_support_intf_extr); + plate_extruders.push_back(printed_filament(obj_support_intf_extr, filament_count)); else if (glb_support_intf_extr != 0) plate_extruders.push_back(glb_support_intf_extr); @@ -3260,7 +3297,7 @@ std::vector PartPlate::get_extruders_under_cli(bool conside_custom_gcode, D if (support_extr_opt != nullptr) obj_support_extr = support_extr_opt->getInt(); if (obj_support_extr != 0) - plate_extruders.push_back(obj_support_extr); + plate_extruders.push_back(printed_filament(obj_support_extr, filament_count)); else if (glb_support_extr != 0) plate_extruders.push_back(glb_support_extr); } @@ -3272,7 +3309,7 @@ std::vector PartPlate::get_extruders_under_cli(bool conside_custom_gcode, D if (const ConfigOption* wall_opt = object->config.option("inner_wall_filament_id"); wall_opt != nullptr) obj_outer_wall_extr = wall_opt->getInt(); if (obj_outer_wall_extr != 0) - plate_extruders.push_back(obj_outer_wall_extr); + plate_extruders.push_back(printed_filament(obj_outer_wall_extr, filament_count)); else if (glb_outer_wall_extr != 0) plate_extruders.push_back(glb_outer_wall_extr); @@ -3283,7 +3320,7 @@ std::vector PartPlate::get_extruders_under_cli(bool conside_custom_gcode, D if (const ConfigOption* wall_opt = object->config.option("outer_wall_filament_id"); wall_opt != nullptr) obj_inner_wall_extr = wall_opt->getInt(); if (obj_inner_wall_extr != 0) - plate_extruders.push_back(obj_inner_wall_extr); + plate_extruders.push_back(printed_filament(obj_inner_wall_extr, filament_count)); else if (glb_inner_wall_extr != 0) plate_extruders.push_back(glb_inner_wall_extr); @@ -3292,7 +3329,7 @@ std::vector PartPlate::get_extruders_under_cli(bool conside_custom_gcode, D if (sparse_infill_opt != nullptr) obj_sparse_infill_extr = sparse_infill_opt->getInt(); if (obj_sparse_infill_extr != 0) - plate_extruders.push_back(obj_sparse_infill_extr); + plate_extruders.push_back(printed_filament(obj_sparse_infill_extr, filament_count)); else if (glb_sparse_infill_extr != 0) plate_extruders.push_back(glb_sparse_infill_extr); @@ -3300,7 +3337,7 @@ std::vector PartPlate::get_extruders_under_cli(bool conside_custom_gcode, D if (const ConfigOption* solid_opt = object->config.option("internal_solid_filament_id"); solid_opt != nullptr) obj_internal_solid_extr = solid_opt->getInt(); if (obj_internal_solid_extr != 0) - plate_extruders.push_back(obj_internal_solid_extr); + plate_extruders.push_back(printed_filament(obj_internal_solid_extr, filament_count)); else if (glb_internal_solid_extr != 0) plate_extruders.push_back(glb_internal_solid_extr); @@ -3308,7 +3345,7 @@ std::vector PartPlate::get_extruders_under_cli(bool conside_custom_gcode, D if (const ConfigOption* top_opt = object->config.option("top_surface_filament_id"); top_opt != nullptr) obj_top_surface_extr = top_opt->getInt(); if (obj_top_surface_extr != 0) - plate_extruders.push_back(obj_top_surface_extr); + plate_extruders.push_back(printed_filament(obj_top_surface_extr, filament_count)); else if (glb_top_surface_extr != 0) plate_extruders.push_back(glb_top_surface_extr); @@ -3316,14 +3353,15 @@ std::vector PartPlate::get_extruders_under_cli(bool conside_custom_gcode, D if (const ConfigOption* bottom_opt = object->config.option("bottom_surface_filament_id"); bottom_opt != nullptr) obj_bottom_surface_extr = bottom_opt->getInt(); if (obj_bottom_surface_extr != 0) - plate_extruders.push_back(obj_bottom_surface_extr); + plate_extruders.push_back(printed_filament(obj_bottom_surface_extr, filament_count)); else if (glb_bottom_surface_extr != 0) plate_extruders.push_back(glb_bottom_surface_extr); const ConfigOption* brim_type_opt = object->config.option("brim_type"); if (brim_type_opt != nullptr ? brim_type_opt->getInt() != int(BrimType::btNoBrim) : glb_brim) { const ConfigOption* brim_opt = object->config.option("brim_filament_id"); - if (const int brim_extr = brim_opt != nullptr ? brim_opt->getInt() : glb_brim_extr; brim_extr != 0) + // The slicer resets an object's brim filament id past the last slot to the default. + if (const int brim_extr = brim_opt != nullptr ? brim_opt->getInt() : glb_brim_extr; brim_extr != 0 && brim_extr <= filament_count) plate_extruders.push_back(brim_extr); } } diff --git a/src/slic3r/GUI/PartPlate.hpp b/src/slic3r/GUI/PartPlate.hpp index d008f44ef6..29c7388d3b 100644 --- a/src/slic3r/GUI/PartPlate.hpp +++ b/src/slic3r/GUI/PartPlate.hpp @@ -512,7 +512,9 @@ public: // Callers that mirror Print::validate need that form: validate counts the mixed slot itself, // so an expanded list makes the two disagree. std::vector get_extruders(bool conside_custom_gcode = false, bool expand_mixed_slots = true) const; - std::vector get_extruders(bool conside_custom_gcode, const DynamicPrintConfig& glb_config, const DynamicPrintConfig& project_config, bool expand_mixed_slots = true) const; + // reset_print_wide_ids = true resolves a print-wide filament id past the last slot as PresetBundle::full_config() + // does for the edited print preset, and false resolves it as the slicer does. + std::vector get_extruders(bool conside_custom_gcode, const DynamicPrintConfig& glb_config, const DynamicPrintConfig& project_config, bool expand_mixed_slots = true, bool reset_print_wide_ids = false) const; std::vector get_extruders_under_cli(bool conside_custom_gcode, DynamicPrintConfig& full_config, bool expand_mixed_slots = true) const; std::vector get_extruders_without_support(bool conside_custom_gcode = false) const; // get used filaments from gcode result, 1 based idx diff --git a/src/slic3r/GUI/Plater.cpp b/src/slic3r/GUI/Plater.cpp index 3f77d92595..06ef668dae 100644 --- a/src/slic3r/GUI/Plater.cpp +++ b/src/slic3r/GUI/Plater.cpp @@ -2812,12 +2812,8 @@ Sidebar::Sidebar(Plater *parent) { Choice::register_dynamic_list("support_filament", &dynamic_physical_filament_list); Choice::register_dynamic_list("support_interface_filament", &dynamic_physical_filament_list); - Choice::register_dynamic_list("outer_wall_filament_id", &dynamic_filament_list); - Choice::register_dynamic_list("inner_wall_filament_id", &dynamic_filament_list); - Choice::register_dynamic_list("sparse_infill_filament_id", &dynamic_filament_list); - Choice::register_dynamic_list("internal_solid_filament_id", &dynamic_filament_list); - Choice::register_dynamic_list("top_surface_filament_id", &dynamic_filament_list); - Choice::register_dynamic_list("bottom_surface_filament_id", &dynamic_filament_list); + for (const char *key : feature_filament_keys) + Choice::register_dynamic_list(key, &dynamic_filament_list); Choice::register_dynamic_list("brim_filament_id", &dynamic_physical_filament_list); Choice::register_dynamic_list("wipe_tower_filament", &dynamic_physical_filament_list); @@ -5870,6 +5866,17 @@ void Sidebar::add_filament() { filament_list->Scroll(-1, INT_MAX); // ORCA scroll to end of list on changes to inform user about filament count } +// Refresh the controls after the sidebar has rebuilt their list of available slots. +static void update_print_tab_after_filament_change(bool process_changed) +{ + Tab *tab = wxGetApp().get_tab(Preset::TYPE_PRINT); + if (process_changed) { + tab->update_dirty(); + tab->reload_config(); + } + tab->update(); +} + void Sidebar::delete_filament(size_t filament_id, int replace_filament_id) { if (is_new_project_in_gcode3mf()) { return; } if (p->combos_filament.size() <= 1) return; @@ -5907,14 +5914,23 @@ void Sidebar::delete_filament(size_t filament_id, int replace_filament_id) { if (auto* opt = wxGetApp().preset_bundle->project_config.option("filament_is_mixed")) is_mixed_snapshot = opt->values; + // Replacement is expressed in the list before deletion. Resolve its final index once. + if (replace_filament_id > int(filament_id)) + --replace_filament_id; + std::map slots{{int(filament_id), replace_filament_id}}; + for (int i = int(filament_id) + 1; i < int(total_filaments); ++i) + slots.emplace(i, i - 1); + remap_model_filament_configs(wxGetApp().model(), slots, false); + const bool process_changed = remap_feature_filaments(wxGetApp().preset_bundle->prints.get_edited_preset().config, slots); + wxGetApp().preset_bundle->update_num_filaments(filament_id); // filament_count only counts physical combos, so with mixed slots present it is not the // new number of slots; recompute from the shrunk preset list for the downstream updates. size_t total_after_delete = wxGetApp().preset_bundle->filament_presets.size(); wxGetApp().plater()->get_partplate_list().on_filament_deleted(total_after_delete, filament_id); - wxGetApp().plater()->on_filaments_delete(total_after_delete, filament_id, replace_filament_id > (int)filament_id ? (replace_filament_id - 1) : replace_filament_id, is_mixed_snapshot); - wxGetApp().get_tab(Preset::TYPE_PRINT)->update(); + wxGetApp().plater()->on_filaments_delete(total_after_delete, filament_id, replace_filament_id, is_mixed_snapshot); + update_print_tab_after_filament_change(process_changed); wxGetApp().preset_bundle->export_selections(*wxGetApp().app_config); wxGetApp().plater()->update(); @@ -5989,6 +6005,7 @@ void Sidebar::add_custom_filament(wxColour new_col, const std::string& preset_na std::string new_color = new_col.GetAsString(wxC2S_HTML_SYNTAX).ToStdString(); bundle->set_num_filaments(filament_count, new_color); + bool process_changed = false; // Maintain physical-first ordering: rotate the new slot from end to insert_pos. // No mixed slots -> insert_pos == total -> every rotate below is a no-op. if (insert_pos < total) { @@ -6031,24 +6048,17 @@ void Sidebar::add_custom_filament(wxColour new_col, const std::string& preset_na if (ams_mc.size() > total) std::rotate(ams_mc.begin() + insert_pos, ams_mc.begin() + total, ams_mc.end()); - // Remap object/volume extruder IDs and paint data: anything >= insert_pos+1 (1-based) shifts up by 1 - int threshold_1based = (int)(insert_pos + 1); - auto ebt_threshold = EnforcerBlockerType(threshold_1based); - for (auto* obj : wxGetApp().plater()->model().objects) { - if (obj->config.has("extruder")) { - int ext = obj->config.extruder(); - if (ext >= threshold_1based) - obj->config.set("extruder", ext + 1); - } - for (auto* vol : obj->volumes) { - if (vol->config.has("extruder")) { - int ext = vol->config.extruder(); - if (ext >= threshold_1based) - vol->config.set("extruder", ext + 1); - } + // Model configs and paint states store one-based filament slots. + std::map slots; + for (int i = int(insert_pos); i < int(total); ++i) + slots.emplace(i, i + 1); + Model &model = wxGetApp().model(); + remap_model_filament_configs(model, slots, true); + process_changed = remap_feature_filaments(bundle->prints.get_edited_preset().config, slots); + auto ebt_threshold = EnforcerBlockerType(insert_pos + 1); + for (ModelObject *obj : model.objects) + for (ModelVolume *vol : obj->volumes) vol->mmu_segmentation_facets.shift_states_above(*vol, ebt_threshold, +1); - } - } } if (!preset_name.empty() && @@ -6059,7 +6069,7 @@ void Sidebar::add_custom_filament(wxColour new_col, const std::string& preset_na wxGetApp().plater()->get_partplate_list().on_filament_added(filament_count); wxGetApp().plater()->on_filament_count_change(filament_count); - wxGetApp().get_tab(Preset::TYPE_PRINT)->update(); + update_print_tab_after_filament_change(process_changed); wxGetApp().preset_bundle->export_selections(*wxGetApp().app_config); auto_calc_flushing_volumes(insert_pos); } @@ -20131,9 +20141,15 @@ void Plater::increase_instances(size_t num) double offset = offset_base; for (size_t i = 0; i < num; i++, offset += offset_base) { Vec3d offset_vec = model_instance->get_offset() + Vec3d(offset, offset, 0.0); - model_object->add_instance(offset_vec, model_instance->get_scaling_factor(), model_instance->get_rotation(), model_instance->get_mirror()); + // ORCA: Copy the whole transformation. Rebuilt from scale, rotation and mirror it loses a skew. + Geometry::Transformation transformation = model_instance->get_transformation(); + transformation.set_offset(offset_vec); + model_object->add_instance()->set_transformation(transformation); // p->print.get_object(obj_idx)->add_copy(Slic3r::to_2d(offset_vec)); } + // ORCA: Place the copies of the last instance in the assembly view, otherwise they overlap. + const size_t first_copy = model_object->instances.size() - num; + p->model.set_assembly_pos_of_copies(model_object, first_copy - 1, first_copy); // Register the copies with the plate they land on before the scene reloads: the plate's // filament list and wipe tower preview are read from that registry. for (size_t i = model_object->instances.size() - num; i < model_object->instances.size(); ++i) @@ -21506,10 +21522,19 @@ int Plater::export_3mf(const boost::filesystem::path& output_path, SaveStrategy // The printer reads slice_info.config and knows only its own catalog ids. auto* id_agent = preset_bundle.is_bbl_vendor() ? wxGetApp().getAgent() : nullptr; + // The bbox data outlives an export, so plates left out of this one must not keep a previous export's filaments. + for (PlateBBoxData* bbox : store_params.id_bboxes) { + bbox->filament_ids.clear(); + bbox->filament_colors.clear(); + } + for (int i = 0; i < plate_data_list.size(); i++) { PlateData *plate_data = plate_data_list[i]; plate_data->printer_model_id = printer_model_id; plate_data->nozzle_diameters = nozzle_diameter_str; + PlateBBoxData* plate_bbox = nullptr; + if (plate_data->is_sliced_valid && plate_data->plate_index >= 0 && plate_data->plate_index < (int) store_params.id_bboxes.size()) + plate_bbox = store_params.id_bboxes[plate_data->plate_index]; for (auto it = plate_data->slice_filaments_info.begin(); it != plate_data->slice_filaments_info.end(); it++) { std::string display_filament_type; it->type = cfg.get_filament_type(display_filament_type, it->id); @@ -21517,11 +21542,9 @@ int Plater::export_3mf(const boost::filesystem::path& output_path, SaveStrategy if (id_agent) it->filament_id = id_agent->from_orca_filament_id(it->filament_id); it->color = filament_color ? filament_color->get_at(it->id) : "#FFFFFF"; - // save filament info used in curr plate - int index = p->partplate_list.get_curr_plate_index(); - if (store_params.id_bboxes.size() > index) { - store_params.id_bboxes[index]->filament_ids.push_back(it->id); - store_params.id_bboxes[index]->filament_colors.push_back(it->color); + if (plate_bbox) { + plate_bbox->filament_ids.push_back(it->id); + plate_bbox->filament_colors.push_back(it->color); } } } diff --git a/src/slic3r/GUI/PrintHostDialogs.cpp b/src/slic3r/GUI/PrintHostDialogs.cpp index c0bfa0d607..e5edec3145 100644 --- a/src/slic3r/GUI/PrintHostDialogs.cpp +++ b/src/slic3r/GUI/PrintHostDialogs.cpp @@ -815,6 +815,12 @@ void FlashforgePrintHostSendDialog::init() sync_mapping_section_visibility(); }, &m_checkbox_ifs); + const std::string printer_model = wxGetApp().preset_bundle->printers.get_edited_preset().config.opt_string("printer_model"); + if (printer_model == "Flashforge Creator 5" || printer_model == "Flashforge Creator 5 Pro") { + add_option_checkbox(m_flashforge_options_sizer, _L("Flow calibration"), m_flow_calibration, + [this](bool checked) { m_flow_calibration = checked; }); + } + if (m_checkbox_ifs != nullptr && !m_supports_material_station) m_checkbox_ifs->Enable(false); @@ -935,6 +941,7 @@ std::map FlashforgePrintHostSendDialog::extendedInfo() {"levelingBeforePrint", m_leveling_before_print ? "1" : "0"}, {"timeLapseVideo", m_time_lapse_video ? "1" : "0"}, {"useMatlStation", m_use_material_station ? "1" : "0"}, + {"flowCalibration", m_flow_calibration ? "1" : "0"}, {"gcodeToolCnt", std::to_string(mapped_count)}, {"materialMappings", mappings.dump()} }; diff --git a/src/slic3r/GUI/PrintHostDialogs.hpp b/src/slic3r/GUI/PrintHostDialogs.hpp index 66de45178d..1d72a7137a 100644 --- a/src/slic3r/GUI/PrintHostDialogs.hpp +++ b/src/slic3r/GUI/PrintHostDialogs.hpp @@ -309,6 +309,7 @@ private: ::CheckBox* m_checkbox_leveling {nullptr}; ::CheckBox* m_checkbox_timelapse {nullptr}; ::CheckBox* m_checkbox_ifs {nullptr}; + bool m_flow_calibration {false}; bool m_leveling_before_print {true}; bool m_time_lapse_video {false}; bool m_use_material_station {false}; diff --git a/src/slic3r/GUI/ReleaseNote.cpp b/src/slic3r/GUI/ReleaseNote.cpp index 186aa3ed8b..fb5d51a82d 100644 --- a/src/slic3r/GUI/ReleaseNote.cpp +++ b/src/slic3r/GUI/ReleaseNote.cpp @@ -34,6 +34,7 @@ #include #include #include +#include #include #include "slic3r/GUI/Widgets/AMSItem.hpp" #include "slic3r/GUI/Widgets/TextInput.hpp" @@ -1733,6 +1734,7 @@ InputIpAddressDialog::InputIpAddressDialog(wxWindow *parent) CentreOnParent(wxBOTH); Move(wxPoint(GetScreenPosition().x, GetScreenPosition().y - FromDIP(50))); + clamp_to_work_area(); wxGetApp().UpdateDlgDarkUI(this); closeTimer = new wxTimer(); @@ -1760,6 +1762,22 @@ InputIpAddressDialog::InputIpAddressDialog(wxWindow *parent) }); } +void InputIpAddressDialog::clamp_to_work_area() +{ + // CentreOnParent picks the display from the parent, so the clamp has to use the same one. + const wxRect work_area = wxDisplay(GetParent() ? GetParent() : this).GetClientArea(); + const wxSize size = GetSize(); + const wxPoint pos = GetScreenPosition(); + + wxPoint clamped = pos; + // std::max runs last, so a dialog bigger than the work area keeps its top left corner, and its title bar, on screen. + clamped.x = std::max(work_area.x, std::min(clamped.x, work_area.x + work_area.width - size.x)); + clamped.y = std::max(work_area.y, std::min(clamped.y, work_area.y + work_area.height - size.y)); + + if (clamped != pos) + Move(clamped); +} + void InputIpAddressDialog::switch_input_panel(int index) { m_button_manual_setup->Hide(); @@ -1916,8 +1934,7 @@ void InputIpAddressDialog::on_ok(wxMouseEvent& evt) std::string port; Http::get_host_from_url(str_ip, &port); config.opt_string("print_host") = str_ip; - if (!port.empty()) - config.opt_string("printhost_port") = port; + config.opt_string("printhost_port") = port; if (!is_bbl_agent() && Http::ca_file_supported()) config.opt_string("printhost_cafile") = m_input_cafile->GetValue().ToStdString(); } diff --git a/src/slic3r/GUI/ReleaseNote.hpp b/src/slic3r/GUI/ReleaseNote.hpp index f78bcc274a..f32d5f8535 100644 --- a/src/slic3r/GUI/ReleaseNote.hpp +++ b/src/slic3r/GUI/ReleaseNote.hpp @@ -353,6 +353,7 @@ public: std::map m_models_map;// display_name -> model_id void switch_input_panel(int index); + void clamp_to_work_area(); void on_cancel(); void update_title(wxString title); void set_machine_obj(MachineObject* obj); diff --git a/src/slic3r/GUI/Selection.cpp b/src/slic3r/GUI/Selection.cpp index 47e169eb73..aa3e75bfc7 100644 --- a/src/slic3r/GUI/Selection.cpp +++ b/src/slic3r/GUI/Selection.cpp @@ -557,15 +557,29 @@ void Selection::center() PartPlate* plate = wxGetApp().plater()->get_partplate_list().get_selected_plate(); // calc distance - Vec3d src_pos = this->get_bounding_box().center(); - Vec3d tar_pos = plate->get_center_origin(); - Vec3d distance = Vec3d(tar_pos.x() - src_pos.x(), tar_pos.y() - src_pos.y(), 0); + const Vec3d src_pos = this->get_bounding_box().center(); + const Vec3d tar_pos = plate->get_center_origin(); + const Vec3d distance = Vec3d(tar_pos.x() - src_pos.x(), tar_pos.y() - src_pos.y(), 0); this->move_to_center(distance); wxGetApp().plater()->get_view3D_canvas3D()->do_move(L("Move object")); return; } +bool Selection::can_center() const +{ + if (!m_valid || is_empty() || is_wipe_tower()) + return false; + + PartPlate* plate = wxGetApp().plater()->get_partplate_list().get_selected_plate(); + if (plate == nullptr) + return false; + + // center() moves in XY only. Compare with a tolerance: the bounding box is recomputed after the move. + const Vec3d distance = plate->get_center_origin() - this->get_bounding_box().center(); + return std::abs(distance.x()) > EPSILON || std::abs(distance.y()) > EPSILON; +} + double Selection::get_drop_min_z() const { if (!m_valid) @@ -1264,7 +1278,9 @@ void Selection::move_to_center(const Vec3d& displacement, bool local) if (local) v.set_volume_offset(m_cache.volumes_data[i].get_volume_position() + displacement); else { - const Vec3d local_displacement = (m_cache.volumes_data[i].get_instance_rotation_matrix() * m_cache.volumes_data[i].get_instance_scale_matrix() * m_cache.volumes_data[i].get_instance_mirror_matrix()).inverse() * displacement; + // The instance matrix itself, not rotation * scale * mirror: those pieces do not rebuild a skewed instance + // (rotated, then scaled along a world axis), and the part then lands off the target. + const Vec3d local_displacement = m_cache.volumes_data[i].get_instance_transform().get_matrix_no_offset().inverse() * displacement; v.set_volume_offset(m_cache.volumes_data[i].get_volume_position() + local_displacement); } } @@ -1273,12 +1289,20 @@ void Selection::move_to_center(const Vec3d& displacement, bool local) v.set_instance_offset(m_cache.volumes_data[i].get_instance_position() + displacement); } else { - const Vec3d local_displacement = (m_cache.volumes_data[i].get_instance_rotation_matrix() * m_cache.volumes_data[i].get_instance_scale_matrix() * m_cache.volumes_data[i].get_instance_mirror_matrix()).inverse() * displacement; + const Vec3d local_displacement = m_cache.volumes_data[i].get_instance_transform().get_matrix_no_offset().inverse() * displacement; v.set_volume_offset(m_cache.volumes_data[i].get_volume_position() + local_displacement); translation_type = Volume; } } } + +#if !DISABLE_INSTANCES_SYNCH + // A part is shared by every instance of its object, but only the selected copy was moved. Bring the other + // copies along as translate() does, otherwise do_move() writes a stale copy's old offset back to the model. + if (translation_type == Volume) + synchronize_unselected_volumes(); +#endif // !DISABLE_INSTANCES_SYNCH + this->set_bounding_boxes_dirty(); } @@ -1674,11 +1698,6 @@ void Selection::scale_and_translate(const Vec3d &scale, const Vec3d &world_trans } else transform_instance_relative(v, volume_data, transformation_type, Geometry::translation_transform(world_translation) * Geometry::scale_transform(relative_scale), m_cache.dragging_center); - // update the instance assemble transform - ModelObject * object = m_model->objects[v.object_idx()]; - Geometry::Transformation assemble_transform = object->instances[v.instance_idx()]->get_assemble_transformation(); - assemble_transform.set_scaling_factor(v.get_instance_scaling_factor()); - object->instances[v.instance_idx()]->set_assemble_transformation(assemble_transform); } else { if (!is_single_volume_or_modifier()) { assert(transformation_type.world()); diff --git a/src/slic3r/GUI/Selection.hpp b/src/slic3r/GUI/Selection.hpp index 1c36e5a989..93efd6ec72 100644 --- a/src/slic3r/GUI/Selection.hpp +++ b/src/slic3r/GUI/Selection.hpp @@ -250,6 +250,7 @@ public: // copy; returning false stops there, and clone() returns false. bool clone(int numbers = 1, const std::function& pasted = {}); void center(); + bool can_center() const; void drop(); bool can_drop() const; // Lowest world Z that drop() moves to the bed; whole objects count model parts only, as auto drop does. diff --git a/src/slic3r/GUI/Tab.cpp b/src/slic3r/GUI/Tab.cpp index 43612c0596..f9929e0f0f 100644 --- a/src/slic3r/GUI/Tab.cpp +++ b/src/slic3r/GUI/Tab.cpp @@ -7795,7 +7795,13 @@ bool Tab::select_preset( // Orca: update presets for the selected printer if (m_type == Preset::TYPE_PRINTER && wxGetApp().app_config->get_bool("remember_printer_config")) { m_preset_bundle->update_selections(*wxGetApp().app_config); - wxGetApp().plater()->sidebar().on_filament_count_change(m_preset_bundle->filament_presets.size()); + const size_t filament_count = m_preset_bundle->filament_presets.size(); + wxGetApp().plater()->sidebar().on_filament_count_change(filament_count); + // Model paint and filament assignments past the new count must survive, so switching back restores them. + PartPlateList &plate_list = wxGetApp().plater()->get_partplate_list(); + plate_list.set_filament_count(filament_count); + for (int i = 0; i < plate_list.get_plate_count(); ++i) + plate_list.get_plate(i)->update_first_layer_print_sequence(filament_count); } load_current_preset(); diff --git a/src/slic3r/GUI/Widgets/Label.cpp b/src/slic3r/GUI/Widgets/Label.cpp index b618a055e6..16685dfee3 100644 --- a/src/slic3r/GUI/Widgets/Label.cpp +++ b/src/slic3r/GUI/Widgets/Label.cpp @@ -108,7 +108,7 @@ void Label::initSysFont() // because FcConfigAppFontAddFile invalidates Pango's cached font map. bool load_fonts = true; #ifdef __linux__ - load_fonts = !fc_font_available("HarmonyOS Sans SC") || !fc_font_available("NanumGothic"); + load_fonts = !fc_font_available("HarmonyOS Sans SC") || !fc_font_available("NanumGothic") || !fc_font_available("Sarabun"); #endif if (load_fonts) { const std::string &resource_path = Slic3r::resources_dir(); @@ -116,6 +116,8 @@ void Label::initSysFont() wxFont::AddPrivateFont(wxString::FromUTF8(resource_path + "/fonts/HarmonyOS_Sans_SC_Regular.ttf")); wxFont::AddPrivateFont(wxString::FromUTF8(resource_path + "/fonts/NanumGothic-Regular.ttf")); wxFont::AddPrivateFont(wxString::FromUTF8(resource_path + "/fonts/NanumGothic-Bold.ttf")); + wxFont::AddPrivateFont(wxString::FromUTF8(resource_path + "/fonts/Sarabun-Medium.ttf")); + wxFont::AddPrivateFont(wxString::FromUTF8(resource_path + "/fonts/Sarabun-SemiBold.ttf")); } #endif Head_48 = Label::sysFont(48, true); diff --git a/src/slic3r/Utils/Flashforge.cpp b/src/slic3r/Utils/Flashforge.cpp index 488e30bedf..411ab3fc45 100644 --- a/src/slic3r/Utils/Flashforge.cpp +++ b/src/slic3r/Utils/Flashforge.cpp @@ -11,6 +11,7 @@ #include #include #include +#include #include #include #include @@ -197,7 +198,7 @@ bool validate_local_api_response(const std::string& response_body, wxString& err return true; } -std::string sanitize_flashforge_filename(const std::string& filename, const std::string& fallback_extension = {}) +std::string sanitize_flashforge_filename(const std::string& filename, const std::string& fallback_extension = {}, bool local_api = false) { std::string basename = fs::path(filename).filename().string(); if (basename.empty()) { @@ -208,7 +209,9 @@ std::string sanitize_flashforge_filename(const std::string& filename, const std: for (char& ch : basename) { const bool is_ascii_alnum = (ch >= '0' && ch <= '9') || (ch >= 'A' && ch <= 'Z') || (ch >= 'a' && ch <= 'z'); - if (!is_ascii_alnum && ch != '.' && ch != '_' && ch != '-') { + // Local API accepts the same names as FlashPrint/Orca-Flashforge: everything except <>[]:/\|?*" and control chars + const bool is_allowed = local_api && static_cast(ch) >= 0x20 && !std::strchr("<>[]:/\\|?*\"", ch); + if (!is_ascii_alnum && !is_allowed && ch != '.' && ch != '_' && ch != '-') { ch = '_'; } } @@ -596,6 +599,7 @@ bool Flashforge::upload_local_api(PrintHostUpload upload_data, ProgressFn progre auto leveling_before_print = upload_data.extended_info["levelingBeforePrint"] == "1"; auto time_lapse_video = upload_data.extended_info["timeLapseVideo"] == "1"; auto use_material_station = upload_data.extended_info["useMatlStation"] == "1"; + auto flow_calibration = upload_data.extended_info["flowCalibration"] == "1"; if (auto it = upload_data.extended_info.find("materialMappings"); it != upload_data.extended_info.end()) material_map_json = it->second; @@ -605,7 +609,7 @@ bool Flashforge::upload_local_api(PrintHostUpload upload_data, ProgressFn progre auto url = make_http_url("uploadGcode"); const std::string fallback_extension = upload_data.source_path.extension().string().empty() ? (upload_data.use_3mf ? ".3mf" : ".gcode") : upload_data.source_path.extension().string(); - auto filename = sanitize_flashforge_filename(upload_data.upload_path.string(), fallback_extension); + auto filename = sanitize_flashforge_filename(upload_data.upload_path.string(), fallback_extension, true); std::string file_size; try { file_size = std::to_string(fs::file_size(upload_data.source_path)); @@ -619,7 +623,7 @@ bool Flashforge::upload_local_api(PrintHostUpload upload_data, ProgressFn progre .header("fileSize", file_size) .header("printNow", upload_data.post_action == PrintHostPostUploadAction::StartPrint ? "true" : "false") .header("levelingBeforePrint", leveling_before_print ? "true" : "false") - .header("flowCalibration", "false") + .header("flowCalibration", flow_calibration ? "true" : "false") .header("firstLayerInspection", "false") .header("timeLapseVideo", time_lapse_video ? "true" : "false") .header("useMatlStation", use_material_station ? "true" : "false") diff --git a/src/slic3r/Utils/MoonrakerFilamentSources.hpp b/src/slic3r/Utils/MoonrakerFilamentSources.hpp new file mode 100644 index 0000000000..46038d9440 --- /dev/null +++ b/src/slic3r/Utils/MoonrakerFilamentSources.hpp @@ -0,0 +1,44 @@ +#pragma once + +#include + +namespace Slic3r { + +enum class MoonrakerFilamentSource { None, Lanes, HappyHare, CrealityCfs, EmptyLanes }; + +// Select the first usable filament source, preserving empty lane topology. +// Each reader fills trays and the highest slot index; failed readers own no result. +template +MoonrakerFilamentSource select_moonraker_filament_data( + Trays& trays, int& max_lane_index, LaneReader read_lanes, HappyHareReader read_happy_hare, CfsReader read_cfs) +{ + trays.clear(); + max_lane_index = 0; + int empty_lane_data_max_index = -1; + if (read_lanes(trays, max_lane_index)) { + if (std::any_of(trays.begin(), trays.end(), [](const auto& tray) { return tray.has_filament; })) + return MoonrakerFilamentSource::Lanes; + empty_lane_data_max_index = max_lane_index; + } + + trays.clear(); + max_lane_index = 0; + if (read_happy_hare(trays, max_lane_index)) { + max_lane_index = std::max(max_lane_index, empty_lane_data_max_index); + return MoonrakerFilamentSource::HappyHare; + } + + trays.clear(); + max_lane_index = 0; + if (read_cfs(trays, max_lane_index)) + return MoonrakerFilamentSource::CrealityCfs; + + trays.clear(); + max_lane_index = empty_lane_data_max_index; + if (empty_lane_data_max_index >= 0) + return MoonrakerFilamentSource::EmptyLanes; + max_lane_index = 0; + return MoonrakerFilamentSource::None; +} + +} // namespace Slic3r diff --git a/src/slic3r/Utils/MoonrakerPrinterAgent.cpp b/src/slic3r/Utils/MoonrakerPrinterAgent.cpp index 0e17a1f35b..081c4998db 100644 --- a/src/slic3r/Utils/MoonrakerPrinterAgent.cpp +++ b/src/slic3r/Utils/MoonrakerPrinterAgent.cpp @@ -1,4 +1,5 @@ #include "MoonrakerPrinterAgent.hpp" +#include "MoonrakerFilamentSources.hpp" #include "AsioUtils.hpp" #include "CrealityCfs.hpp" #include "Http.hpp" @@ -395,12 +396,18 @@ int MoonrakerPrinterAgent::bind_detect(std::string dev_ip, std::string sec_link, { (void) sec_link; - detect.dev_id = device_info.dev_id.empty() ? dev_ip : device_info.dev_id; - detect.model_id = device_info.model_id.empty() ? device_info.model_name : device_info.model_id; - // Prefer fetched hostname, then preset model name, then generic fallback - detect.dev_name = device_info.dev_name.empty() ? dev_ip : device_info.dev_name; - detect.model_id = device_info.model_id; - detect.version = device_info.version; + // The binding target is the address the user entered. device_info may still describe the + // printer the agent was connected to before, so its identity must not be used for another + // address. Split it the way the input dialog stores the print host and port, then derive + // the dev_id the same way GUI_App::select_machine does. + std::string port; + std::string host = Http::get_host_from_url(dev_ip, &port); + const std::string dev_id = MachineObject::dev_id_from_address(host, port); + + detect.dev_id = dev_id; + detect.dev_name = dev_id; + detect.model_id.clear(); + detect.version.clear(); detect.connect_type = "lan"; detect.bind_state = "free"; @@ -747,38 +754,35 @@ bool MoonrakerPrinterAgent::fetch_filament_info(std::string dev_id, FilamentSync { std::vector trays; int max_lane_index = 0; + const auto source = select_moonraker_filament_data(trays, max_lane_index, + [this](auto& out, int& index) { return fetch_moonraker_filament_data(out, index); }, + [this](auto& out, int& index) { return fetch_hh_filament_info(out, index); }, + [this](auto& out, int& index) { return fetch_creality_cfs_data(out, index); }); - // Try Moonraker filament data (more generic, supports any filament changer - // software that reports lane data to Moonraker like AFC and recent Happy - // Hare as of Feb 15, 2026) - if (fetch_moonraker_filament_data(trays, max_lane_index)) { + switch (source) { + case MoonrakerFilamentSource::Lanes: BOOST_LOG_TRIVIAL(info) << "MoonrakerPrinterAgent::fetch_filament_info: Detected Moonraker filament system with " << (max_lane_index + 1) << " lanes"; - int ams_count = (max_lane_index + 4) / 4; - build_ams_payload(ams_count, max_lane_index, trays); - return true; - } - - // Attempt Happy Hare first (more widely adopted, supports more filament changers) - if (fetch_hh_filament_info(trays, max_lane_index)) { + break; + case MoonrakerFilamentSource::HappyHare: BOOST_LOG_TRIVIAL(info) << "MoonrakerPrinterAgent::fetch_filament_info: Detected Happy Hare MMU with " - << (max_lane_index + 1) << " gates"; - int ams_count = (max_lane_index + 4) / 4; - build_ams_payload(ams_count, max_lane_index, trays); - return true; - } - - // Creality Hi exposes CFS slots as a Moonraker box printer object. - if (fetch_creality_cfs_data(trays, max_lane_index)) { + << trays.size() << " loaded gates and " << (max_lane_index + 1) << " slots"; + break; + case MoonrakerFilamentSource::CrealityCfs: BOOST_LOG_TRIVIAL(info) << "MoonrakerPrinterAgent::fetch_filament_info: Detected Creality CFS with " << (max_lane_index + 1) << " slots"; - build_ams_payload((max_lane_index + 4) / 4, max_lane_index, trays); - return true; + break; + case MoonrakerFilamentSource::EmptyLanes: + BOOST_LOG_TRIVIAL(info) << "MoonrakerPrinterAgent::fetch_filament_info: Preserving empty lane_data topology with " + << (max_lane_index + 1) << " lanes"; + break; + case MoonrakerFilamentSource::None: + BOOST_LOG_TRIVIAL(info) << "MoonrakerPrinterAgent::fetch_filament_info: No MMU system detected"; + return false; } - // No MMU detected - this is normal for printers without MMU, not an error. - BOOST_LOG_TRIVIAL(info) << "MoonrakerPrinterAgent::fetch_filament_info: No MMU system detected"; - return false; + build_ams_payload((max_lane_index + 4) / 4, max_lane_index, trays); + return true; } std::string MoonrakerPrinterAgent::trim_and_upper(const std::string& input) diff --git a/tests/fff_print/test_multifilament.cpp b/tests/fff_print/test_multifilament.cpp index 2b8527c9bc..82f89891e8 100644 --- a/tests/fff_print/test_multifilament.cpp +++ b/tests/fff_print/test_multifilament.cpp @@ -5,6 +5,7 @@ #include #include #include +#include #include "libslic3r/GCode/GCodeProcessor.hpp" #include "libslic3r/GCodeReader.hpp" #include "libslic3r/TriangleSelector.hpp" @@ -87,6 +88,49 @@ TEST_CASE("Painted filaments slice when the display palette is shorter than the REQUIRE(second_filament_present); } +TEST_CASE("Spiral vase mode prints a model painted all over with a filament other than its own", "[MultiFilament]") +{ + // Painting the whole cube leaves only filament 2. Painting half of it, or limiting the paint to a band near the + // walls, leaves two filaments, which spiral vase can't print. Beam interlocking turns the band off. + const bool all_over = GENERATE(true, false); + const std::string band_key = GENERATE("", "mmu_segmented_region_max_width", "mmu_segmented_region_interlocking_depth"); + const bool beam = GENERATE(false, true); + CAPTURE(all_over, band_key, beam); + auto config = multifilament_config(2, { + { "spiral_mode", 1 }, + { "enable_prime_tower", 0 }, + { "skirt_loops", 0 }, + { "brim_type", "no_brim" }, + { "gcode_comments", 1 }, + { "layer_change_gcode", "G92 E0" }, + { "interlocking_beam", beam }, + }); + if (!band_key.empty()) + config.set_deserialize_strict(band_key, "1"); + Print print; + Model model; + init_print({cube(20)}, print, model, config); + ModelVolume *volume = model.objects.front()->volumes.front(); + TriangleSelector selector(volume->mesh()); + const int facets = int(volume->mesh().its.indices.size()); + for (int facet = 0; facet < (all_over ? facets : facets / 2); ++facet) + selector.set_facet(facet, EnforcerBlockerType::Extruder2); + REQUIRE(volume->mmu_segmentation_facets.set(selector)); + CHECK(volume->is_mm_painted_everywhere() == all_over); + print.apply(model, config); + + const std::string error = print.validate().string; + if (!all_over || (!band_key.empty() && !beam)) { + CHECK_THAT(error, Catch::Matchers::ContainsSubstring("more than one material")); + return; + } + INFO(error); + REQUIRE(error.empty()); + const std::string gcode = Test::gcode(print); + CHECK(tools_for_role(gcode, "perimeter") == std::set{ 1 }); + CHECK(tools_for_role(gcode, "infill") == std::set{ 1 }); +} + // X where the nozzle sits while each tagged _WAIT_FOR_TEMP_ON_WIPE_TOWER M109 blocks: // the nearest preceding G1 carrying an X (the park travel emitted just before the wait). static std::vector wait_park_xs(const std::string& gcode) @@ -2539,6 +2583,19 @@ TEST_CASE("A filament_map within the nozzle range is not changed", "[MultiFilame CHECK(print.config().filament_map.values == std::vector({ 1, 2 })); } +TEST_CASE("Filament maps longer than the filament list are cut to the filament count", "[MultiFilament]") +{ + DynamicPrintConfig config = two_nozzle_map_config("1,2,1,1"); + config.set_key_value("filament_volume_map", new ConfigOptionInts({ 0, 0, 0, 0 })); + config.set_key_value("filament_nozzle_map", new ConfigOptionInts({ 0, 1, 0, 0 })); + Print print; + init_and_process_print({ cube(20) }, print, config); + CHECK(print.config().filament_map.values == std::vector({ 1, 2 })); + CHECK(print.config().filament_volume_map.values.size() == 2); + CHECK(print.config().filament_nozzle_map.values.size() == 2); + CHECK(gcode_body(slice({ cube(20) }, config)) == gcode_body(slice({ cube(20) }, two_nozzle_map_config("1,2")))); +} + // The map value is a firmware tool number, so a value outside the nozzle range must not index the // per-nozzle first-filament table. TEST_CASE("A physical_extruder_map entry outside the nozzle range still exports", "[MultiFilament]") diff --git a/tests/fff_print/test_precise_seam.cpp b/tests/fff_print/test_precise_seam.cpp index 78e2709afb..9c179251fb 100644 --- a/tests/fff_print/test_precise_seam.cpp +++ b/tests/fff_print/test_precise_seam.cpp @@ -6,12 +6,20 @@ #include #include #include "test_helpers.hpp" +#include "admesh/stl.h" #include "libslic3r/BoundingBox.hpp" +#include "libslic3r/Config.hpp" #include "libslic3r/GCode/PreciseSeam.hpp" +#include "libslic3r/Line.hpp" +#include "libslic3r/AABBTreeLines.hpp" +#include "libslic3r/GCode/PreciseSeamInternal.hpp" #include "libslic3r/Layer.hpp" +#include "libslic3r/ExtrusionEntityCollection.hpp" +#include "libslic3r/ExtrusionEntity.hpp" #include "libslic3r/Print.hpp" #include +#include #include #include "libslic3r/Point.hpp" #include "libslic3r/Polygon.hpp" @@ -591,6 +599,408 @@ TEST_CASE("Weak boundaries sharing a vertex refine both sides", "[PreciseSeam]") check_square_boundary(perimeter); } +namespace { +// A noisy loop made from a counterclockwise `smooth` loop as fuzzy skin makes one: points every 0.25 mm along each edge +// from 0.125 mm, moved along the edge's outward normal by `amplitude`, alternately out and in, without the smooth +// vertices. +Polygon fuzzify(const Polygon &smooth, double amplitude) +{ + Polygon noisy; + double sign = 1.; + for (size_t edge = 0; edge < smooth.size(); ++edge) { + const Vec2d a = smooth[edge].cast(); + const Vec2d b = smooth[(edge + 1) % smooth.size()].cast(); + const Vec2d direction = (b - a).normalized(); + for (double along = scale_(0.125); along < (b - a).norm(); along += scale_(0.25)) { + const Vec2d point = a + along * direction + sign * scale_(amplitude) * Vec2d(direction.y(), -direction.x()); + sign = -sign; + noisy.points.emplace_back(coord_t(std::lround(point.x())), coord_t(std::lround(point.y()))); + } + } + return noisy; +} +} // namespace + +TEST_CASE("With fuzzy skin a strong point is chosen on the smooth loop and inserted into the noisy one", "[PreciseSeam][Fuzzy]") +{ + const auto [type, x] = GENERATE(table({ + {ModelVolumeType::PRECISE_SEAM_LEFT, 4.}, {ModelVolumeType::PRECISE_SEAM_CENTER, 5.}, + {ModelVolumeType::PRECISE_SEAM_RIGHT, 6.}})); + CAPTURE(x); + SeamFixture fixture; + const Polygon smooth = rectangle(0, 0, 20, 20); + Polygon noisy = fuzzify(smooth, 0.1); + const size_t noisy_size = noisy.size(); + // Across the front face from x = 4 to 6 mm. + const auto *modifier = fixture.add(type, {rectangle(4, -1, 6, 0.1)}); + PreciseSeam::PreparedPerimeter prepared(smooth, PreciseSeam::surface_shift(0.4, 0.), false); + prepared.set_target(noisy, coord_t(scale_(0.5))); + REQUIRE(prepared.valid); + const auto seam = PreciseSeam::insert_strong_seam_point({modifier}, noisy, prepared, fixture.layer, fixture.cache); + REQUIRE(seam.has_value()); + // Across the smooth edge, where the noisy edge between the points at x - 0.125 and x + 0.125 mm, 0.1 mm on either + // side, crosses y = 0; inserted with its two helpers. + CHECK(std::abs(seam->x() - mm(x, 0).x()) <= 1); + CHECK(std::abs(seam->y()) <= 1); + CHECK(std::find(noisy.points.begin(), noisy.points.end(), *seam) != noisy.points.end()); + CHECK(noisy.size() == noisy_size + 3); + CHECK(smooth.size() == 4); +} + +TEST_CASE("With fuzzy skin a strong point that cannot be carried is a discarded fragment", "[PreciseSeam][Fuzzy]") +{ + SeamFixture fixture; + const Polygon smooth = rectangle(0, 0, 20, 20); + // The whole noisy loop lies 0.3 mm outside, beyond a window of 0.1 mm. + Polygon noisy = rectangle(-0.3, -0.3, 20.3, 20.3); + const auto *modifier = fixture.add(ModelVolumeType::PRECISE_SEAM_CENTER, {rectangle(4, -1, 6, 0.1)}); + PreciseSeam::PreparedPerimeter prepared(smooth, PreciseSeam::surface_shift(0.4, 0.), false); + prepared.set_target(noisy, coord_t(scale_(0.1))); + PreciseSeam::PreciseSeamWarnings warnings; + CHECK_FALSE(PreciseSeam::insert_strong_seam_point({modifier}, noisy, prepared, fixture.layer, fixture.cache, &warnings).has_value()); + CHECK(warnings.failed_fragments == 1); + CHECK(warnings.failed_types == PreciseSeam::PreciseSeamWarnings::type_bit(ModelVolumeType::PRECISE_SEAM_CENTER)); + CHECK(noisy.size() == 4); +} + +TEST_CASE("With fuzzy skin a short weak zone keeps both boundaries on the noisy loop", "[PreciseSeam][Fuzzy]") +{ + using Type = SeamPlacerImpl::EnforcedBlockedSeamPoint; + SeamFixture fixture; + const Polygon smooth = rectangle(0, 0, 20, 20); + Polygon noisy = fuzzify(smooth, 0.1); + const auto *modifier = fixture.add(ModelVolumeType::PRECISE_SEAM_ENFORCED, {rectangle(4, -1, 6, 0.1)}); + PreciseSeam::PreparedPerimeter prepared(smooth, PreciseSeam::surface_shift(0.4, 0.), false); + prepared.set_target(noisy, coord_t(scale_(0.5))); + PreciseSeam::PreciseSeamWarnings warnings; + const auto segments = PreciseSeam::collect_weak_modifier_segments({modifier}, noisy, prepared, fixture.layer, fixture.cache, &warnings); + REQUIRE(segments.size() == 1); + CHECK(std::abs(segments.front().left_point.x() - mm(4, 0).x()) <= 1); + CHECK(std::abs(segments.front().right_point.x() - mm(6, 0).x()) <= 1); + CHECK(warnings.reversed_zones == 0); + // Exactly the noisy points across the zone are Enforced. + const auto types = weak_candidate_types(noisy, segments); + size_t enforced = 0; + for (size_t i = 0; i < noisy.size(); ++i) { + const bool inside = noisy[i].y() < scale_(1.) && noisy[i].x() >= mm(4, 0).x() - 1 && noisy[i].x() <= mm(6, 0).x() + 1; + CAPTURE(i, noisy[i].x(), noisy[i].y()); + CHECK((types[i] == Type::Enforced) == inside); + enforced += types[i] == Type::Enforced; + } + CHECK(enforced > 8); +} + +TEST_CASE("With fuzzy skin a zero-length weak zone at a convex corner spreads between its two arc points", "[PreciseSeam][Fuzzy]") +{ + SeamFixture fixture; + const Polygon smooth = rectangle(0, 0, 20, 20); + // The noisy loop cuts the corner (20, 0) outside it, along x - y = 20.05 mm. + Polygon noisy(Points{mm(0, 0), mm(19.9, -0.15), mm(20.15, 0.1), mm(20, 20), mm(0, 20)}); + // Around the arc point at -45 degrees: a vertex point whose two arc points lie on either side of the bisector. + const auto *modifier = fixture.add(ModelVolumeType::PRECISE_SEAM_ENFORCED, {rectangle(20.11, -0.17, 20.17, -0.11)}); + PreciseSeam::PreparedPerimeter prepared(smooth, PreciseSeam::surface_shift(0.4, 0.), false); + prepared.set_target(noisy, coord_t(scale_(0.5))); + PreciseSeam::PreciseSeamWarnings warnings; + const auto segments = PreciseSeam::collect_weak_modifier_segments({modifier}, noisy, prepared, fixture.layer, fixture.cache, &warnings); + REQUIRE(segments.size() == 1); + const Point &left = segments.front().left_point; + const Point &right = segments.front().right_point; + CAPTURE(left.x(), left.y(), right.x(), right.y()); + // Both on the cut, in the order of the arc, mirror images across the bisector through the corner. + for (const Point &point : {left, right}) + CHECK(std::abs(double(point.x() - point.y()) - scale_(20.05)) <= 2.); + CHECK(left.x() < right.x()); + CHECK(std::abs(double(left.x() - mm(20, 0).x() + right.y())) <= 2.); + CHECK(warnings.reversed_zones == 0); +} + +TEST_CASE("With fuzzy skin a weak zone whose boundaries reverse is reduced to its left one", "[PreciseSeam][Fuzzy]") +{ + using Type = SeamPlacerImpl::EnforcedBlockedSeamPoint; + const auto [zone, type, background] = GENERATE(table({ + {ModelVolumeType::PRECISE_SEAM_ENFORCED, Type::Enforced, Type::Neutral}, + {ModelVolumeType::PRECISE_SEAM_BLOCKED, Type::Blocked, Type::Neutral}, + {ModelVolumeType::PRECISE_SEAM_NEUTRAL, Type::Neutral, Type::Enforced}})); + CAPTURE(int(type)); + SeamFixture fixture; + const Polygon smooth = rectangle(0, 0, 20, 20); + // Without displacement the noisy loop only cuts the corners: (19.875, 0) to (20, 0.125) at the corner (20, 0). + Polygon noisy = fuzzify(smooth, 0.); + // A wedge from the corner covering the front surface from x = 19.97 mm and the arc down to about 11 degrees below + // the horizontal. Across the cut behind the corner, the left boundary lands at (19.971, 0.096) and the right one, + // along the line to its arc point, near (19.896, 0.021): before the left one. + const auto *modifier = fixture.add(zone, {Polygon(Points{mm(20, 0), mm(19.85, -1), mm(21, -0.2)})}); + PreciseSeam::PreparedPerimeter prepared(smooth, PreciseSeam::surface_shift(0.4, 0.), false); + prepared.set_target(noisy, coord_t(scale_(0.5))); + PreciseSeam::PreciseSeamWarnings warnings; + const auto segments = PreciseSeam::collect_weak_modifier_segments({modifier}, noisy, prepared, fixture.layer, fixture.cache, &warnings); + REQUIRE(segments.size() == 1); + CHECK_FALSE(segments.front().whole_perimeter); + CHECK(segments.front().left_point == segments.front().right_point); + CHECK(std::abs(segments.front().left_point.x() - mm(19.971, 0).x()) <= scale_(0.002)); + CHECK(std::abs(segments.front().left_point.y() - mm(0, 0.096).y()) <= scale_(0.002)); + CHECK(warnings.reversed_zones == 1); + // One candidate of the zone's type, as a zero-length zone types it; the rest keep their painted type. + const auto types = weak_candidate_types(noisy, segments, [background = background](const Point &) { return background; }); + CHECK(std::count(types.begin(), types.end(), type) == 1); + CHECK(std::count(types.begin(), types.end(), background) == ptrdiff_t(types.size()) - 1); +} + +TEST_CASE("With fuzzy skin a weak zone whose boundaries reverse on a loop within the circle of the check is reduced to its left one", "[PreciseSeam][Fuzzy]") +{ + using Type = SeamPlacerImpl::EnforcedBlockedSeamPoint; + const auto [zone, type, background] = GENERATE(table({ + {ModelVolumeType::PRECISE_SEAM_ENFORCED, Type::Enforced, Type::Neutral}, + {ModelVolumeType::PRECISE_SEAM_BLOCKED, Type::Blocked, Type::Neutral}, + {ModelVolumeType::PRECISE_SEAM_NEUTRAL, Type::Neutral, Type::Enforced}})); + CAPTURE(int(type)); + SeamFixture fixture; + // The smooth loop is a box of 1 x 1.2 mm whose top left half zigzags between y = 0.5 and 1.2 mm + // (x = 0.5 - 0.05 j for j = 1..9): about 10.92 mm long, yet within 1.35 mm of (0.4, 0). The noisy loop is the + // same but cuts the corner (1, 0) along the chord from (0.25, 0) to (1, 0.9), y = 1.2 x - 0.3. + Points top; + for (int j = 1; j <= 9; ++j) + top.push_back(mm(0.5 - 0.05 * j, j % 2 == 1 ? 0.5 : 1.2)); + top.push_back(mm(0, 1.2)); + Points smooth_points{mm(0, 0), mm(1, 0), mm(1, 1.2), mm(0.5, 1.2)}; + Points noisy_points{mm(0, 0), mm(0.25, 0), mm(1, 0.9), mm(1, 1.2), mm(0.5, 1.2)}; + smooth_points.insert(smooth_points.end(), top.begin(), top.end()); + noisy_points.insert(noisy_points.end(), top.begin(), top.end()); + const Polygon smooth(smooth_points); + Polygon noisy(noisy_points); + // The window of 1.402 mm (0.001 mm thickness, 1.4 mm point distance and 1 um): the zone below is shorter than four + // windows, its rest longer. + const double window = 1.402; + // The boundaries as they are carried, before the order is checked. The line x = 0.4 mm through the left one + // crosses the chord at (0.4, 0.18), a fifth along it; the line through the right one, the corner (1, 0), along + // its arc point's direction (1, -0.2) crosses the chord at (5/14, 9/70), a seventh along it: behind the left one. + const AABBTreeLines::LinesDistancer lines(noisy.lines()); + const auto left = PreciseSeam::detail::transfer_point(lines, mm(0.4, 0), mm(0.4, -0.045), scale_(window)); + CHECK(left.outcome == PreciseSeam::detail::TransferOutcome::Exact); + CHECK(left.position.edge == 1); + CHECK_THAT(left.position.parameter, Catch::Matchers::WithinAbs(0.2, 1e-6)); + CHECK((left.position.point - mm(0.4, 0.18)).cast().norm() <= 1.5); + const auto right = PreciseSeam::detail::transfer_point(lines, mm(1, 0), mm(1.2, -0.04), scale_(window)); + CHECK(right.outcome == PreciseSeam::detail::TransferOutcome::Exact); + CHECK(right.position.edge == 1); + CHECK_THAT(right.position.parameter, Catch::Matchers::WithinAbs(1. / 7., 1e-6)); + CHECK((right.position.point - mm(5. / 14., 9. / 70.)).cast().norm() <= 1.5); + // A triangle over the front surface from x = 0.4 mm and the arc of the corner (1, 0) down to its edge along + // (1, -0.2): one zone from (0.4, 0) to (1, 0), 0.6 mm long. The whole noisy loop lies within the circle of + // 0.6 + 1.402 mm around (0.4, 0), so the noisy arc from the left boundary forward round the loop, far the longer, + // tells the reversal. + const auto *modifier = fixture.add(zone, {Polygon(Points{mm(1, 0), mm(-5. / 3., -0.2), mm(2, -0.2)})}); + PreciseSeam::PreparedPerimeter prepared(smooth, PreciseSeam::surface_shift(0.1, 0.), false); + prepared.set_target(noisy, coord_t(scale_(window))); + REQUIRE(prepared.valid); + PreciseSeam::PreciseSeamWarnings warnings; + const auto segments = PreciseSeam::collect_weak_modifier_segments({modifier}, noisy, prepared, fixture.layer, fixture.cache, &warnings); + REQUIRE(segments.size() == 1); + CHECK_FALSE(segments.front().whole_perimeter); + CHECK(segments.front().left_point == segments.front().right_point); + CAPTURE(segments.front().left_point.x(), segments.front().left_point.y()); + CHECK((segments.front().left_point - mm(0.4, 0.18)).cast().norm() <= 3.); + CHECK(warnings.reversed_zones == 1); + // One candidate of the zone's type, as a zero-length zone types it; the rest keep their painted type. + const auto types = weak_candidate_types(noisy, segments, [background = background](const Point &) { return background; }); + CHECK(std::count(types.begin(), types.end(), type) == 1); + CHECK(std::count(types.begin(), types.end(), background) == ptrdiff_t(types.size()) - 1); +} + +TEST_CASE("With fuzzy skin a weak zone across the start of both loops keeps its order", "[PreciseSeam][Fuzzy]") +{ + using Type = SeamPlacerImpl::EnforcedBlockedSeamPoint; + SeamFixture fixture; + const Polygon smooth = rectangle(0, 0, 20, 20); + // Both loops start at the corner (0, 0): the smooth one at it, the noisy one just after it. + Polygon noisy = fuzzify(smooth, 0.1); + const size_t noisy_size = noisy.size(); + // Around the corner from y = 1 mm on the left side to x = 1 mm on the front. + const auto *modifier = fixture.add(ModelVolumeType::PRECISE_SEAM_ENFORCED, {rectangle(-1, -1, 1, 1)}); + PreciseSeam::PreparedPerimeter prepared(smooth, PreciseSeam::surface_shift(0.4, 0.), false); + prepared.set_target(noisy, coord_t(scale_(0.5))); + PreciseSeam::PreciseSeamWarnings warnings; + const auto segments = PreciseSeam::collect_weak_modifier_segments({modifier}, noisy, prepared, fixture.layer, fixture.cache, &warnings); + REQUIRE(segments.size() == 1); + const auto &zone = segments.front(); + CHECK(std::abs(zone.left_point.y() - mm(0, 1).y()) <= 1); + CHECK(std::abs(zone.left_point.x()) <= scale_(0.1) + 1); + CHECK(std::abs(zone.right_point.x() - mm(1, 0).x()) <= 1); + CHECK(std::abs(zone.right_point.y()) <= scale_(0.1) + 1); + CHECK(zone.left_position.edge_index > noisy_size / 2); + CHECK(zone.right_position.edge_index < 8); + CHECK(warnings.reversed_zones == 0); + // The corner is Enforced, the far side is not. + const auto types = weak_candidate_types(noisy, segments); + for (size_t i = 0; i < noisy.size(); ++i) { + const bool inside = std::max(noisy[i].x(), noisy[i].y()) <= mm(1, 1).x() + 1; + CAPTURE(i, noisy[i].x(), noisy[i].y()); + CHECK((types[i] == Type::Enforced) == inside); + } +} + +TEST_CASE("With fuzzy skin a long weak zone keeps its boundaries where noise lengthens only its part of the loop", "[PreciseSeam][Fuzzy]") +{ + using Type = SeamPlacerImpl::EnforcedBlockedSeamPoint; + const auto [zone, type, background] = GENERATE(table({ + {ModelVolumeType::PRECISE_SEAM_ENFORCED, Type::Enforced, Type::Neutral}, + {ModelVolumeType::PRECISE_SEAM_BLOCKED, Type::Blocked, Type::Neutral}, + {ModelVolumeType::PRECISE_SEAM_NEUTRAL, Type::Neutral, Type::Enforced}})); + CAPTURE(int(type)); + SeamFixture fixture; + const Polygon smooth = rectangle(0, 0, 20, 20); + // The noisy loop is the smooth one except between (2, 0) and (18, 0) mm, where it zigzags 1 mm either side every + // 0.1 mm (x = 2 + 0.1 j, y = (-1)^j for j = 1..159): that stretch is about 318.4 mm long against 64 mm for the rest, + // over 0.83 of the loop for a zone of 0.2 of the smooth one. + Points points{mm(0, 0), mm(2, 0)}; + for (int j = 1; j < 160; ++j) + points.push_back(mm(2. + 0.1 * j, j % 2 == 0 ? 1. : -1.)); + for (const Point &point : {mm(18, 0), mm(20, 0), mm(20, 20), mm(0, 20)}) + points.push_back(point); + Polygon noisy(points); + // The zone covers the front surface from x = 2 to 18 mm; the lines x = 2 and x = 18 mm through its boundaries meet + // the noisy loop at the boundaries themselves. + const auto *modifier = fixture.add(zone, {rectangle(2, -0.3, 18, 0.05)}); + PreciseSeam::PreparedPerimeter prepared(smooth, PreciseSeam::surface_shift(0.4, 0.), false); + // The window of this noise: 1 mm amplitude, 0.1 mm point distance and 1 um. + prepared.set_target(noisy, coord_t(scale_(1.101))); + PreciseSeam::PreciseSeamWarnings warnings; + const auto segments = PreciseSeam::collect_weak_modifier_segments({modifier}, noisy, prepared, fixture.layer, fixture.cache, &warnings); + REQUIRE(segments.size() == 1); + CHECK((segments.front().left_point - mm(2, 0)).cast().norm() <= 1.5); + CHECK((segments.front().right_point - mm(18, 0)).cast().norm() <= 1.5); + CHECK(warnings.reversed_zones == 0); + // The whole zigzag takes the zone's type, the rest keeps the painted one. + const auto types = weak_candidate_types(noisy, segments, [background = background](const Point &) { return background; }); + size_t typed = 0; + for (size_t i = 0; i < noisy.size(); ++i) { + const bool inside = noisy[i].x() >= mm(2, 0).x() - 1 && noisy[i].x() <= mm(18, 0).x() + 1 && noisy[i].y() <= mm(0, 1).y(); + CAPTURE(i, noisy[i].x(), noisy[i].y()); + CHECK(types[i] == (inside ? type : background)); + typed += inside; + } + CHECK(typed >= 161); +} + +namespace { +// Everything round the 20 x 20 mm square but its front surface from x = `from` to `to` mm. +Polygon all_but_front(double from, double to) +{ + return Polygon(Points{mm(-1, -1), mm(from, -1), mm(from, 0.1), mm(to, 0.1), mm(to, -1), mm(21, -1), mm(21, 21), mm(-1, 21)}); +} + +// The 20 x 20 mm square whose front surface between x = 9 and 11 mm zigzags 1 mm either side every 0.01 mm +// (x = 9 + 0.01 j, y = (-1)^j for j = 1..199): that stretch is about 398 mm long against 78 mm for the rest. +Polygon zigzag_between_9_and_11() +{ + Points points{mm(0, 0), mm(9, 0)}; + for (int j = 1; j < 200; ++j) + points.push_back(mm(9. + 0.01 * j, j % 2 == 0 ? 1. : -1.)); + for (const Point &point : {mm(11, 0), mm(20, 0), mm(20, 20), mm(0, 20)}) + points.push_back(point); + return Polygon(points); +} + +// Collects the zones of one weak modifier over `region` on the 20 x 20 mm square carried onto `noisy` within `window` +// mm, and checks they make one zone from `left` to `right` (within a unit), with no zone reduced. +std::vector carried_weak_zone(SeamFixture &fixture, ModelVolumeType type, const Polygon ®ion, + Polygon &noisy, double window, const Point &left, const Point &right) +{ + const Polygon smooth = rectangle(0, 0, 20, 20); + const auto *modifier = fixture.add(type, {region}); + PreciseSeam::PreparedPerimeter prepared(smooth, PreciseSeam::surface_shift(0.4, 0.), false); + prepared.set_target(noisy, coord_t(scale_(window))); + PreciseSeam::PreciseSeamWarnings warnings; + auto segments = PreciseSeam::collect_weak_modifier_segments({modifier}, noisy, prepared, fixture.layer, fixture.cache, &warnings); + REQUIRE(segments.size() == 1); + CHECK_FALSE(segments.front().whole_perimeter); + const Point &carried_left = segments.front().left_point; + const Point &carried_right = segments.front().right_point; + CAPTURE(carried_left.x(), carried_left.y(), carried_right.x(), carried_right.y()); + CHECK((carried_left - left).cast().norm() <= 1.5); + CHECK((carried_right - right).cast().norm() <= 1.5); + CHECK(warnings.reversed_zones == 0); + return segments; +} +} // namespace + +TEST_CASE("With fuzzy skin a weak zone almost all round the loop keeps its order", "[PreciseSeam][Fuzzy]") +{ + using Type = SeamPlacerImpl::EnforcedBlockedSeamPoint; + const auto [zone, type, background] = GENERATE(table({ + {ModelVolumeType::PRECISE_SEAM_ENFORCED, Type::Enforced, Type::Neutral}, + {ModelVolumeType::PRECISE_SEAM_BLOCKED, Type::Blocked, Type::Neutral}, + {ModelVolumeType::PRECISE_SEAM_NEUTRAL, Type::Neutral, Type::Enforced}})); + CAPTURE(int(type)); + SeamFixture fixture; + const Polygon smooth = rectangle(0, 0, 20, 20); + Polygon noisy = fuzzify(smooth, 0.1); + // Everything but the front surface from x = 9.5 to 10.5 mm: a zone from (10.5, 0) round the loop, across its start, + // to (9.5, 0), whose rest of 1 mm is shorter than four windows of 0.5 mm. The noisy edges between the points at + // x = 10.375 and 10.625 mm, and 9.375 and 9.625 mm, 0.1 mm either side, cross the boundaries' lines at y = 0. + const auto segments = carried_weak_zone(fixture, zone, all_but_front(9.5, 10.5), noisy, 0.5, mm(10.5, 0), mm(9.5, 0)); + // All of the loop but the gap takes the zone's type. + const auto types = weak_candidate_types(noisy, segments, [background = background](const Point &) { return background; }); + for (size_t i = 0; i < noisy.size(); ++i) { + const bool gap = noisy[i].y() < mm(0, 1).y() && noisy[i].x() > mm(9.5, 0).x() + 1 && noisy[i].x() < mm(10.5, 0).x() - 1; + CAPTURE(i, noisy[i].x(), noisy[i].y()); + CHECK(types[i] == (gap ? background : type)); + } +} + +TEST_CASE("With fuzzy skin a short weak zone keeps its boundaries where noise lengthens it many times over", "[PreciseSeam][Fuzzy]") +{ + using Type = SeamPlacerImpl::EnforcedBlockedSeamPoint; + const auto [zone, type, background] = GENERATE(table({ + {ModelVolumeType::PRECISE_SEAM_ENFORCED, Type::Enforced, Type::Neutral}, + {ModelVolumeType::PRECISE_SEAM_BLOCKED, Type::Blocked, Type::Neutral}, + {ModelVolumeType::PRECISE_SEAM_NEUTRAL, Type::Neutral, Type::Enforced}})); + CAPTURE(int(type)); + SeamFixture fixture; + Polygon noisy = zigzag_between_9_and_11(); + // The zone covers the front surface from x = 9 to 11 mm, 2 mm of the smooth loop, shorter than four windows of + // 1.011 mm (1 mm amplitude, 0.01 mm point distance and 1 um). The lines x = 9 and x = 11 mm through its boundaries + // meet the noisy loop at the boundaries themselves; the zigzag stays within 2 + 1.011 mm of (9, 0). + const auto segments = carried_weak_zone(fixture, zone, rectangle(9, -0.3, 11, 0.05), noisy, 1.011, mm(9, 0), mm(11, 0)); + // The whole zigzag with its ends takes the zone's type, the rest keeps the painted one. + const auto types = weak_candidate_types(noisy, segments, [background = background](const Point &) { return background; }); + size_t typed = 0; + for (size_t i = 0; i < noisy.size(); ++i) { + const bool inside = noisy[i].x() >= mm(9, 0).x() - 1 && noisy[i].x() <= mm(11, 0).x() + 1 && noisy[i].y() <= mm(0, 1).y(); + CAPTURE(i, noisy[i].x(), noisy[i].y()); + CHECK(types[i] == (inside ? type : background)); + typed += inside; + } + CHECK(typed >= 201); +} + +TEST_CASE("With fuzzy skin a weak zone almost all round keeps its boundaries where noise lengthens its rest many times over", "[PreciseSeam][Fuzzy]") +{ + using Type = SeamPlacerImpl::EnforcedBlockedSeamPoint; + const auto [zone, type, background] = GENERATE(table({ + {ModelVolumeType::PRECISE_SEAM_ENFORCED, Type::Enforced, Type::Neutral}, + {ModelVolumeType::PRECISE_SEAM_BLOCKED, Type::Blocked, Type::Neutral}, + {ModelVolumeType::PRECISE_SEAM_NEUTRAL, Type::Neutral, Type::Enforced}})); + CAPTURE(int(type)); + SeamFixture fixture; + Polygon noisy = zigzag_between_9_and_11(); + // Everything but the front surface from x = 9 to 11 mm: a zone from (11, 0) round the loop, across its start, to + // (9, 0), whose rest of 2 mm is shorter than four windows of 1.011 mm. The zigzag of that rest stays within + // 2 + 1.011 mm of (9, 0). + const auto segments = carried_weak_zone(fixture, zone, all_but_front(9, 11), noisy, 1.011, mm(11, 0), mm(9, 0)); + // All of the loop but the zigzag between the boundaries takes the zone's type; refining the boundaries adds a point + // into the zigzag next to each of them. + const auto types = weak_candidate_types(noisy, segments, [background = background](const Point &) { return background; }); + size_t untyped = 0; + for (size_t i = 0; i < noisy.size(); ++i) { + const bool gap = noisy[i].y() <= mm(0, 1).y() && noisy[i].x() > mm(9, 0).x() + 1 && noisy[i].x() < mm(11, 0).x() - 1; + CAPTURE(i, noisy[i].x(), noisy[i].y()); + CHECK(types[i] == (gap ? background : type)); + untyped += gap; + } + CHECK(untyped >= 199); +} + TEST_CASE("Weak processing applies every ready interval and leaves gaps unchanged", "[PreciseSeam][SegmentExtraction]") { SeamFixture fixture; @@ -1280,6 +1690,101 @@ TEST_CASE("Weak zones type painting's oversampled candidates between their bound CHECK(cleared_oversampled >= 15); // About 4 mm of 0.2 mm steps inside the zone. } +TEST_CASE("Strong modes put the seam on the vertex of a zero-length surface segment", "[PreciseSeam]") +{ + const auto [mode, x] = GENERATE(table({ + {ModelVolumeType::PRECISE_SEAM_LEFT, 8.}, + {ModelVolumeType::PRECISE_SEAM_CENTER, 10.}, + {ModelVolumeType::PRECISE_SEAM_RIGHT, 12.}})); + SeamFixture fixture; + const coord_t shift = coord_t(scale_(0.2)); + // Covers only the surface arc around the corner (20, 0). + const Polygon arc_only = rectangle(20.11, -0.17, 20.17, -0.11); + Polygon perimeter = rectangle(0, 0, 20, 20); + const ModelVolume *corner = fixture.add(mode, {arc_only}); + PreciseSeam::PreciseSeamWarnings warnings; + const auto seam = PreciseSeam::insert_strong_seam_point({corner}, perimeter, PreciseSeam::PreparedPerimeter(perimeter, shift), + fixture.layer, fixture.cache, &warnings); + REQUIRE(seam.has_value()); + CHECK(*seam == mm(20, 0)); + require_vertex(perimeter, mm(19.999, 0)); + require_vertex(perimeter, mm(20, 0.001)); + check_square_boundary(perimeter); + CHECK_FALSE(warnings.full_containment.load()); + CHECK_FALSE(warnings.multiple_intersections.load()); + + // Any segment of nonzero length is longer: here the crossing of the front face at x = 8..12. + Polygon second = rectangle(0, 0, 20, 20); + const ModelVolume *both = fixture.add(mode, {arc_only, rectangle(8, -1, 12, -0.1)}); + const auto longer = PreciseSeam::insert_strong_seam_point({both}, second, PreciseSeam::PreparedPerimeter(second, shift), + fixture.layer, fixture.cache, &warnings); + REQUIRE(longer.has_value()); + CHECK(*longer == mm(x, 0)); + CHECK(warnings.multiple_intersections.load() != 0); +} + +TEST_CASE("A strong modifier leaving only part of one surface arc uncovered is skipped as full containment", "[PreciseSeam]") +{ + const auto mode = GENERATE(ModelVolumeType::PRECISE_SEAM_LEFT, ModelVolumeType::PRECISE_SEAM_CENTER, + ModelVolumeType::PRECISE_SEAM_RIGHT); + SeamFixture fixture; + // Everything is covered but a small hole on the arc around (20, 0): the gap carries onto one vertex. + ExPolygon region(rectangle(-1, -1, 21, 21)); + region.holes.push_back(rectangle(20.12, -0.16, 20.16, -0.12)); + region.holes.back().reverse(); + const ModelVolume *modifier = fixture.add_regions(mode, {region}); + Polygon perimeter = rectangle(0, 0, 20, 20); + PreciseSeam::PreciseSeamWarnings warnings; + const auto seam = PreciseSeam::insert_strong_seam_point({modifier}, perimeter, PreciseSeam::PreparedPerimeter(perimeter, coord_t(scale_(0.2))), + fixture.layer, fixture.cache, &warnings); + CHECK_FALSE(seam.has_value()); + CHECK(warnings.full_containment.load() == PreciseSeam::PreciseSeamWarnings::type_bit(mode)); + CHECK(perimeter.points == rectangle(0, 0, 20, 20).points); +} + +TEST_CASE("A zero-length weak zone types the single candidate at its vertex", "[PreciseSeam]") +{ + using Type = SeamPlacerImpl::EnforcedBlockedSeamPoint; + // Every zone type over candidates of another type, so a change shows exactly where the zone acted. + const auto [mode, zone, base] = GENERATE(table({ + {ModelVolumeType::PRECISE_SEAM_ENFORCED, Type::Enforced, Type::Neutral}, + {ModelVolumeType::PRECISE_SEAM_BLOCKED, Type::Blocked, Type::Neutral}, + {ModelVolumeType::PRECISE_SEAM_NEUTRAL, Type::Neutral, Type::Enforced}, + {ModelVolumeType::PRECISE_SEAM_NEUTRAL, Type::Neutral, Type::Blocked}})); + CAPTURE(int(zone), int(base)); + SeamFixture fixture; + Polygon perimeter = rectangle(0, 0, 20, 20); + const ModelVolume *modifier = fixture.add(mode, {rectangle(20.11, -0.17, 20.17, -0.11)}); + const auto segments = PreciseSeam::collect_weak_modifier_segments( + {modifier}, perimeter, PreciseSeam::PreparedPerimeter(perimeter, coord_t(scale_(0.2))), fixture.layer, fixture.cache); + REQUIRE(segments.size() == 1); + CHECK_FALSE(segments.front().whole_perimeter); + CHECK(segments.front().left_point == mm(20, 0)); + CHECK(segments.front().right_point == mm(20, 0)); + check_square_boundary(perimeter); + + PrintObjectSeamData::LayerSeams candidates; + candidates.perimeters.emplace_back(); + auto &loop = candidates.perimeters.back(); + loop.start_index = 0; + for (const Point &point : perimeter.points) { + const Vec2f position = unscale(point).cast(); + candidates.points.emplace_back(Vec3f(position.x(), position.y(), 0), loop, 0, base); + } + loop.end_index = candidates.points.size(); + bool enforced = false; + PreciseSeam::apply_weak_modifiers_to_perimeter(segments, candidates, loop, enforced); + CHECK(enforced == (zone == Type::Enforced)); + size_t changed = 0; + for (const auto &candidate : candidates.points) { + CAPTURE(candidate.position.x(), candidate.position.y()); + const bool at_vertex = candidate.position.x() == 20.f && candidate.position.y() == 0.f; + CHECK(candidate.type == (at_vertex ? zone : base)); + changed += candidate.type != base ? 1 : 0; + } + CHECK(changed == 1); +} + namespace { // A 20 x 20 x 2 mm cube sliced at 0.2 mm, so ten layers, each with one outer wall loop. struct ExportFixture { @@ -1288,7 +1793,7 @@ struct ExportFixture { DynamicPrintConfig config = DynamicPrintConfig::full_print_config(); Vec3d cube_min; - explicit ExportFixture(const std::string &seam_position, int raft_layers = 0) + explicit ExportFixture(const std::string &seam_position, int raft_layers = 0, TriangleMesh object = make_cube(20, 20, 2)) { config.set_deserialize_strict("seam_position", seam_position); config.set_deserialize_strict("seam_slope_type", "none"); // The loop then starts exactly at the seam. @@ -1297,7 +1802,7 @@ struct ExportFixture { config.set_deserialize_strict("outer_wall_line_width", "0.4"); config.set_deserialize_strict("initial_layer_line_width", "0.4"); config.set_deserialize_strict("raft_layers", std::to_string(raft_layers)); - Test::init_print({make_cube(20, 20, 2)}, print, model, config); + Test::init_print({std::move(object)}, print, model, config); const ModelVolume *cube = model.objects.front()->volumes.front(); cube_min = cube->mesh().transformed_bounding_box(cube->get_matrix()).min; } @@ -1330,6 +1835,7 @@ struct ExportFixture { struct OuterLoop { Vec2d seam; // Relative to the loop's centre, which is the cube's centre. BoundingBoxf bounds; + float z = 0.f; }; std::vector outer_wall_loops(const std::string &gcode) @@ -1337,6 +1843,7 @@ std::vector outer_wall_loops(const std::string &gcode) std::vector loops; bool outer_wall = false; bool in_loop = false; + float loop_z = 0.f; GCodeReader parser; parser.parse_buffer(gcode, [&](GCodeReader &self, const GCodeReader::GCodeLine &line) { const std::string_view comment = line.comment(); @@ -1346,8 +1853,12 @@ std::vector outer_wall_loops(const std::string &gcode) } if (!outer_wall || !line.extruding(self) || line.dist_XY(self) == 0.f) return; + // A loop never spans layers; an object of outer walls only keeps its type across layers. + if (in_loop && self.z() != loop_z) + in_loop = false; + loop_z = self.z(); if (!in_loop) { - loops.push_back({Vec2d(self.x(), self.y()), {}}); + loops.push_back({Vec2d(self.x(), self.y()), {}, self.z()}); loops.back().bounds.merge(loops.back().seam); in_loop = true; } @@ -1358,6 +1869,18 @@ std::vector outer_wall_loops(const std::string &gcode) return loops; } +// The 20 x 20 x 2 mm cube with a 6 x 6 mm hole at x, y = 7..13 mm between z = 0.4 and 1.6 mm, clear of the +// slicing planes. +TriangleMesh cube_with_hole() +{ + TriangleMesh cube = make_cube(20, 20, 2); + TriangleMesh cavity = make_cube(6, 6, 1.2); + cavity.translate(7., 7., 0.4); + cavity.flip_triangles(); + cube.merge(cavity); + return cube; +} + TriangleMesh helper_with_hole() { // 8 x 6 x 4 mm with a 4 x 3 mm hole through every layer of the cube. @@ -1418,6 +1941,38 @@ TEST_CASE("Weak modifiers move the exported seam into or out of their zone", "[P CHECK(fixture.warning().empty()); } +TEST_CASE("Alignment keeps the seam inside an Enforced zone whose end steps between layers", "[PreciseSeam][Regression]") +{ + // The loop runs towards the rear on the right face and towards the front on the left one, so the stepping + // rear end of the zones is the last candidate of the Enforced run on one face and the first on the other. + for (const bool left_face : {false, true}) { + CAPTURE(left_face); + // A 20 x 20 x 2 mm cube at 0.2 mm layers: ten layers. + ExportFixture fixture("back"); + // Zones on the face from y = 4 mm: to 6 mm on the lower five layers, to 6.5 mm on the upper five. The + // back seam takes the rear end of each zone, and the curve fitted through the layers smooths the step, so + // its targets pass the end of a zone on some layers. + const double zone_x = left_face ? -3. : 17.; + fixture.add(ModelVolumeType::PRECISE_SEAM_ENFORCED, make_cube(6, 2, 2), Vec3d(zone_x, 4, -1), "lower zone"); + fixture.add(ModelVolumeType::PRECISE_SEAM_ENFORCED, make_cube(6, 2.5, 2), Vec3d(zone_x, 4, 1), "upper zone"); + const auto loops = outer_wall_loops(fixture.export_gcode()); + REQUIRE(loops.size() == 10); + size_t lower = 0; + for (const OuterLoop &loop : loops) { + CAPTURE(loop.z, loop.seam.x(), loop.seam.y()); + const bool in_lower = loop.z < 1.1f; + lower += in_lower ? 1 : 0; + const double face_x = (left_face ? loop.bounds.min.x() : loop.bounds.max.x()) - loop.bounds.center().x(); + CHECK_THAT(loop.seam.x(), Catch::Matchers::WithinAbs(face_x, 0.01)); + // From the cube's centre the zones span y = -6 to -4 mm and -6 to -3.5 mm. + CHECK(loop.seam.y() >= -6.01); + CHECK(loop.seam.y() <= (in_lower ? -3.99 : -3.49)); + } + CHECK(lower == 5); + CHECK(fixture.warning().empty()); + } +} + TEST_CASE("A higher-priority Enforced band suppresses the whole-perimeter Blocked export warning", "[PreciseSeam][Regression]") { ExportFixture fixture("back"); @@ -1452,15 +2007,628 @@ TEST_CASE("A strong modifier with a hole uses the left of two equal crossings", CHECK(fixture.warning().find("Seam Center") != std::string::npos); } -TEST_CASE("The export warning names a modifier that misses the outer wall centreline", "[PreciseSeam]") +TEST_CASE("The export warning names a modifier that misses the model surface", "[PreciseSeam]") { - // The helper reaches 0.1 mm into the cube, short of the centreline 0.2 mm inside a 0.4 mm outer wall. + // The helper stops 0.1 mm in front of the cube. ExportFixture fixture("back"); - fixture.add(ModelVolumeType::PRECISE_SEAM_ENFORCED, make_cube(2, 3.1, 4), Vec3d(4, -3, -1), "short helper"); + fixture.add(ModelVolumeType::PRECISE_SEAM_ENFORCED, make_cube(2, 2.9, 4), Vec3d(4, -3, -1), "short helper"); fixture.export_gcode(); CHECK(fixture.warning().find("short helper") != std::string::npos); } +TEST_CASE("A modifier reaching into the model surface places the seam short of the centreline", "[PreciseSeam]") +{ + // The helper reaches 0.1 mm into the cube, half way to the centreline of the 0.4 mm outer wall. + ExportFixture fixture("back"); + fixture.add(ModelVolumeType::PRECISE_SEAM_CENTER, make_cube(2, 3.1, 4), Vec3d(4, -3, -1)); + const auto loops = outer_wall_loops(fixture.export_gcode()); + REQUIRE(loops.size() == 10); + for (const OuterLoop &loop : loops) { + CHECK_THAT(loop.seam.x(), Catch::Matchers::WithinAbs(5. - 10., 0.01)); + CHECK_THAT(loop.seam.y(), Catch::Matchers::WithinAbs(loop.bounds.min.y() - loop.bounds.center().y(), 0.01)); + } + CHECK(fixture.warning().empty()); +} + +TEST_CASE("XY compensation does not change which modifiers reach the model surface", "[PreciseSeam]") +{ + const double compensation = GENERATE(-0.1, 0., 0.1); + const bool hole = GENERATE(false, true); + const bool reaches = GENERATE(true, false); + // Classic walls without elephant foot compensation keep the constant shift; Arachne measures it. + const std::string generator = GENERATE(as{}, "classic", "arachne"); + CAPTURE(compensation, hole, reaches, generator); + // The helper ends 0.05 mm inside or in front of the model face, however far compensation moved the wall. + const double depth = reaches ? 0.05 : -0.05; + ExportFixture fixture("back", 0, hole ? cube_with_hole() : make_cube(20, 20, 2)); + fixture.config.set_deserialize_strict("wall_generator", generator); + fixture.config.set_deserialize_strict(hole ? "xy_hole_compensation" : "xy_contour_compensation", std::to_string(compensation)); + // Elephant foot compensation would move the first layer's wall as well. + fixture.config.set_deserialize_strict("elefant_foot_compensation", "0"); + if (hole) + fixture.add(ModelVolumeType::PRECISE_SEAM_CENTER, make_cube(2, 2. + depth, 4), Vec3d(9, 7. - depth, -1)); // Hole wall y = 7. + else + fixture.add(ModelVolumeType::PRECISE_SEAM_CENTER, make_cube(2, 3. + depth, 4), Vec3d(4, -3, -1)); // Front face. + const auto loops = outer_wall_loops(fixture.export_gcode()); + size_t checked = 0; + for (const OuterLoop &loop : loops) { + // Hole loops are about 6 mm wide, outer loops about 20 mm. + if ((loop.bounds.size().x() < 10.) != hole) + continue; + ++checked; + CAPTURE(loop.seam.x(), loop.seam.y()); + if (reaches) { + CHECK_THAT(loop.seam.x(), Catch::Matchers::WithinAbs(hole ? 0. : 5. - 10., 0.01)); + CHECK_THAT(loop.seam.y(), Catch::Matchers::WithinAbs(loop.bounds.min.y() - loop.bounds.center().y(), 0.01)); + } else + CHECK(loop.seam.y() > 0.); // The back seam, away from the helper. + } + CHECK(checked >= (hole ? 4u : 10u)); +} + +TEST_CASE("A wider first layer line does not change which modifiers reach the model surface", "[PreciseSeam]") +{ + const bool reaches = GENERATE(true, false); + CAPTURE(reaches); + // The first layer's wall lies 0.3 mm inside the model face, the others 0.2 mm. A helper ending 0.05 mm inside + // the face is short of the surface a 0.4 mm line would give the first layer; one ending 0.05 mm in front of + // it would reach the surface a 0.6 mm line would give the upper layers. + const double depth = reaches ? 0.05 : -0.05; + ExportFixture fixture("back"); + fixture.config.set_deserialize_strict("initial_layer_line_width", "0.6"); + // Elephant foot compensation would move the first layer's wall as well. + fixture.config.set_deserialize_strict("elefant_foot_compensation", "0"); + fixture.add(ModelVolumeType::PRECISE_SEAM_CENTER, make_cube(2, 3. + depth, 4), Vec3d(4, -3, -1)); // Front face. + const auto loops = outer_wall_loops(fixture.export_gcode()); + REQUIRE(loops.size() == 10); + for (const OuterLoop &loop : loops) { + CAPTURE(loop.seam.x(), loop.seam.y()); + if (reaches) { + CHECK_THAT(loop.seam.x(), Catch::Matchers::WithinAbs(5. - 10., 0.01)); + CHECK_THAT(loop.seam.y(), Catch::Matchers::WithinAbs(loop.bounds.min.y() - loop.bounds.center().y(), 0.01)); + } else + CHECK(loop.seam.y() > 0.); // The back seam, away from the helper. + } +} + +TEST_CASE("On a narrow island printed with a thinner line a flush modifier stays clear and a slightly deeper one acts", "[PreciseSeam]") +{ + const double depth = GENERATE(0., 0.02); + CAPTURE(depth); + // An 8 x 0.6 mm island: too narrow for two 0.4 mm lines and under 10 mm long, so without thin wall detection + // the classic generator prints it as one loop of a thinner line, whose centerline lies closer to the faces. + ExportFixture fixture("back", 0, make_cube(8, 0.6, 2)); + fixture.config.set_deserialize_strict("wall_generator", "classic"); + fixture.config.set_deserialize_strict("detect_thin_wall", "0"); + // Elephant foot layers are measured; here the shift comes from the loop's own line width. + fixture.config.set_deserialize_strict("elefant_foot_compensation", "0"); + // Flush with the front face, or 0.02 mm into it: the margin keeps the surface 5 um inside the model face. + fixture.add(ModelVolumeType::PRECISE_SEAM_CENTER, make_cube(2, 3. + depth, 4), Vec3d(3, -3, -1)); + const auto loops = outer_wall_loops(fixture.export_gcode()); + REQUIRE(loops.size() == 10); + for (const OuterLoop &loop : loops) { + CAPTURE(loop.seam.x(), loop.seam.y()); + // Thinner than 0.4 mm: the loop is wider than the 0.2 mm a nominal line would leave it. + CHECK(loop.bounds.size().y() > 0.21); + if (depth > 0.) { + CHECK_THAT(loop.seam.x(), Catch::Matchers::WithinAbs(4. - 4., 0.01)); + CHECK_THAT(loop.seam.y(), Catch::Matchers::WithinAbs(loop.bounds.min.y() - loop.bounds.center().y(), 0.01)); + } else + CHECK(loop.seam.y() > 0.); // The back seam, away from the helper. + } +} + +namespace { +// A wall of the given thickness along a quarter circle of radius 10 mm around the origin, 2 mm high: from (10, 0) +// to (0, 10) through 90 segments. +TriangleMesh quarter_ring(double thickness) +{ + indexed_triangle_set its; + const int segments = 90; + for (int i = 0; i <= segments; ++i) { + const double angle = 0.5 * PI * i / segments; + const Vec2d direction(std::cos(angle), std::sin(angle)); + for (const double radius : {10. - 0.5 * thickness, 10. + 0.5 * thickness}) + for (const double z : {0., 2.}) + its.vertices.emplace_back(Vec3f(float(radius * direction.x()), float(radius * direction.y()), float(z))); + } + // Vertex 4 i + 2 r + h: r = 0 inner, 1 outer; h = 0 bottom, 1 top. Faces wind counterclockwise from outside. + const auto v = [](int i, int r, int h) { return 4 * i + 2 * r + h; }; + const auto quad = [&its](int a, int b, int c, int d) { + its.indices.emplace_back(a, b, c); + its.indices.emplace_back(a, c, d); + }; + for (int i = 0; i < segments; ++i) { + quad(v(i, 0, 0), v(i + 1, 0, 0), v(i + 1, 1, 0), v(i, 1, 0)); // Bottom. + quad(v(i, 0, 1), v(i, 1, 1), v(i + 1, 1, 1), v(i + 1, 0, 1)); // Top. + quad(v(i, 1, 0), v(i + 1, 1, 0), v(i + 1, 1, 1), v(i, 1, 1)); // Outer side. + quad(v(i, 0, 0), v(i, 0, 1), v(i + 1, 0, 1), v(i + 1, 0, 0)); // Inner side. + } + quad(v(0, 0, 0), v(0, 1, 0), v(0, 1, 1), v(0, 0, 1)); // End at angle 0. + quad(v(segments, 0, 0), v(segments, 0, 1), v(segments, 1, 1), v(segments, 1, 0)); // End at 90 degrees. + return TriangleMesh(std::move(its)); +} +} // namespace + +TEST_CASE("A modifier crossing only an open thin wall has no effect", "[PreciseSeam]") +{ + const std::string generator = GENERATE(as{}, "classic", "arachne"); + CAPTURE(generator); + // A 0.3 mm wall, thinner than one line, printed as a single open line along its middle, radius 10 mm. Its + // G-code does not depend on a seam, so Precise Seam leaves it out. + ExportFixture fixture("back", 0, quarter_ring(0.3)); + fixture.config.set_deserialize_strict("wall_generator", generator); + fixture.config.set_deserialize_strict("detect_thin_wall", "1"); + fixture.config.set_deserialize_strict("elefant_foot_compensation", "0"); + // A closed loop on the same layers, inside the ring at x, y = 2..5 mm: the helpers are evaluated on it. + fixture.add(ModelVolumeType::MODEL_PART, make_cube(3, 3, 2), Vec3d(2, 2, 0), "block"); + // The fixture's corner is the ring's centre. At y = 3..4 mm the wall lies at x = 9.0..9.7: the first helper + // crosses all of it, centerline included, and nothing else. At y = 4.2..4.8 mm the second one crosses the wall + // and enters the block's right face x = 5 by 1 mm. + fixture.add(ModelVolumeType::PRECISE_SEAM_ENFORCED, make_cube(4, 1, 4), Vec3d(9, 3, -1), "thin wall only"); + fixture.add(ModelVolumeType::PRECISE_SEAM_ENFORCED, make_cube(9, 0.6, 4), Vec3d(4, 4.2, -1), "thin wall and block"); + fixture.export_gcode(); + const std::string warning = fixture.warning(); + CAPTURE(warning); + // The user warning names the first modifier without effect and counts the rest: only the first helper is one. + CHECK(warning.find("had no effect") != std::string::npos); + CHECK(warning.find("thin wall only") != std::string::npos); + CHECK(warning.find("in total") == std::string::npos); +} + +namespace { +// Elephant foot compensation decreasing over the first layers: by default 0.3, 0.2 and 0.1 mm. +void set_elephant_foot(ExportFixture &fixture, double compensation = 0.3, int layers = 3) +{ + fixture.config.set_deserialize_strict("elefant_foot_compensation", std::to_string(compensation)); + fixture.config.set_deserialize_strict("elefant_foot_compensation_layers", std::to_string(layers)); +} + +// Completes a fixture built on make_cube(7, 20, 2) into a 20 x 20 x 2 mm frame with a 6 x 6 mm hole through every +// layer at x, y = 7..13 mm. +void make_frame(ExportFixture &fixture) +{ + fixture.add(ModelVolumeType::MODEL_PART, make_cube(7, 20, 2), Vec3d(13, 0, 0), "right side"); + fixture.add(ModelVolumeType::MODEL_PART, make_cube(6, 7, 2), Vec3d(7, 0, 0), "front side"); + fixture.add(ModelVolumeType::MODEL_PART, make_cube(6, 7, 2), Vec3d(7, 13, 0), "back side"); +} + +// Checks the outer loops, or the hole loops (under 10 mm wide), of every layer: all have the seam on their front +// at x relative to their centre, or none has it at the front. +void check_front_seams(const std::vector &loops, bool hole, bool at_front, double x, double front = 0.01) +{ + size_t checked = 0; + for (const OuterLoop &loop : loops) { + if ((loop.bounds.size().x() < 10.) != hole) + continue; + ++checked; + CAPTURE(checked, loop.seam.x(), loop.seam.y()); + if (at_front) { + CHECK_THAT(loop.seam.x(), Catch::Matchers::WithinAbs(x, 0.01)); + CHECK_THAT(loop.seam.y(), Catch::Matchers::WithinAbs(loop.bounds.min.y() - loop.bounds.center().y(), front)); + } else + CHECK(loop.seam.y() > 0.); // The back seam, away from the helper. + } + CHECK(checked == 10); +} +} // namespace + +TEST_CASE("Elephant foot layers act at the same modifier depth as the layers above", "[PreciseSeam]") +{ + const std::string generator = GENERATE(as{}, "classic", "arachne"); + CAPTURE(generator); + ExportFixture fixture("back"); + fixture.config.set_deserialize_strict("wall_generator", generator); + set_elephant_foot(fixture); + // The helper enters the front face by 0.1 mm: short of a surface half a line width off the centerline on the + // first three layers, whose walls lie 0.3, 0.2 and 0.1 mm deeper. + fixture.add(ModelVolumeType::PRECISE_SEAM_CENTER, make_cube(2, 3.1, 4), Vec3d(4, -3, -1)); + const auto loops = outer_wall_loops(fixture.export_gcode()); + REQUIRE(loops.size() == 10); + check_front_seams(loops, false, true, 5. - 10.); + // The same place along the face on every layer; across it the walls of the first layers lie deeper. + const double first = loops.front().seam.x() + loops.front().bounds.center().x(); + for (const OuterLoop &loop : loops) + CHECK_THAT(loop.seam.x() + loop.bounds.center().x(), Catch::Matchers::WithinAbs(first, 0.01)); + CHECK(fixture.warning().empty()); +} + +TEST_CASE("On elephant foot layers a flush modifier stays clear and a slightly deeper one acts", "[PreciseSeam]") +{ + const std::string generator = GENERATE(as{}, "classic", "arachne"); + const double depth = GENERATE(0., 0.02); + CAPTURE(generator, depth); + ExportFixture fixture("back"); + fixture.config.set_deserialize_strict("wall_generator", generator); + set_elephant_foot(fixture); + // Flush with the front face, or 0.02 mm into it: the margin keeps the surface 5 um inside the model face. + fixture.add(ModelVolumeType::PRECISE_SEAM_CENTER, make_cube(2, 3. + depth, 4), Vec3d(4, -3, -1)); + const auto loops = outer_wall_loops(fixture.export_gcode()); + REQUIRE(loops.size() == 10); + check_front_seams(loops, false, depth > 0., 5. - 10.); +} + +TEST_CASE("A segment across a thin part with less elephant foot compensation ends under the modifier", "[PreciseSeam]") +{ + // A U of two 8 mm blocks joined by a 1 mm front wall at x = 8..12 mm. The first layers cannot shrink that wall + // fully, so the depth of the centerline changes along the front face. + const auto [type, x] = GENERATE(table({ + {ModelVolumeType::PRECISE_SEAM_LEFT, 6.}, + {ModelVolumeType::PRECISE_SEAM_CENTER, 10.}, + {ModelVolumeType::PRECISE_SEAM_RIGHT, 14.}})); + const std::string generator = GENERATE(as{}, "classic", "arachne"); + CAPTURE(generator, x); + ExportFixture fixture("back", 0, make_cube(8, 20, 2)); + fixture.config.set_deserialize_strict("wall_generator", generator); + set_elephant_foot(fixture); + fixture.add(ModelVolumeType::MODEL_PART, make_cube(8, 20, 2), Vec3d(12, 0, 0), "right block"); + fixture.add(ModelVolumeType::MODEL_PART, make_cube(4, 1, 2), Vec3d(8, 0, 0), "front wall"); + // 0.1 mm into the front face across the thin wall and both sides of it: one segment from x = 6 to 14 mm. + fixture.add(type, make_cube(8, 3.1, 4), Vec3d(6, -3, -1)); + const auto loops = outer_wall_loops(fixture.export_gcode()); + REQUIRE(loops.size() == 10); + // The front of the loop steps where the thin wall starts: the seam lies on it within that step. + check_front_seams(loops, false, true, x - 10., 0.3); + CHECK(fixture.warning().empty()); +} + +TEST_CASE("A hole wall on elephant foot layers acts at the same modifier depth as above", "[PreciseSeam]") +{ + const std::string generator = GENERATE(as{}, "classic", "arachne"); + CAPTURE(generator); + ExportFixture fixture("back", 0, make_cube(7, 20, 2)); + fixture.config.set_deserialize_strict("wall_generator", generator); + set_elephant_foot(fixture); + make_frame(fixture); + // From inside the hole 0.1 mm into its front wall y = 7 mm; elephant foot compensation widens the hole. + fixture.add(ModelVolumeType::PRECISE_SEAM_CENTER, make_cube(2, 2.1, 4), Vec3d(9, 6.9, -1)); + const auto loops = outer_wall_loops(fixture.export_gcode()); + check_front_seams(loops, true, true, 0.); +} + +TEST_CASE("Loops with fuzzy skin are measured on their smooth centerline", "[PreciseSeam]") +{ + // Fuzzy skin on the outer contours or on the holes, from the second layer on. + const auto [fuzzy_skin, hole] = GENERATE(table({ + {"external", false}, {"external", true}, {"hole", false}, {"hole", true}})); + const std::string generator = GENERATE(as{}, "classic", "arachne"); + CAPTURE(fuzzy_skin, hole, generator); + ExportFixture fixture("back", 0, make_cube(7, 20, 2)); + fixture.config.set_deserialize_strict("wall_generator", generator); + fixture.config.set_deserialize_strict("fuzzy_skin", fuzzy_skin); + fixture.config.set_deserialize_strict("fuzzy_skin_first_layer", "0"); + // The smallest noise slicing keeps: the walls stay where they were, only the kind of loop matters. + fixture.config.set_deserialize_strict("fuzzy_skin_thickness", "0.001"); + set_elephant_foot(fixture); + make_frame(fixture); + // 0.05 mm into the front face or the hole wall y = 7 mm. A constant shift would put the surface 0.3, 0.2 and + // 0.1 mm deeper on the first three layers, out of its reach; measured, it acts on every layer, noisy or not. + if (hole) + fixture.add(ModelVolumeType::PRECISE_SEAM_CENTER, make_cube(2, 2.05, 4), Vec3d(9, 6.95, -1)); + else + fixture.add(ModelVolumeType::PRECISE_SEAM_CENTER, make_cube(2, 3.05, 4), Vec3d(4, -3, -1)); + const auto loops = outer_wall_loops(fixture.export_gcode()); + check_front_seams(loops, hole, true, hole ? 0. : 5. - 10.); +} + +namespace { +// Fuzzy skin as a sine of 0.3 mm amplitude along the loop, the same on every run, from the first layer on. +void set_ripple_fuzzy_skin(ExportFixture &fixture, const std::string &type) +{ + fixture.config.set_deserialize_strict("fuzzy_skin", type); + fixture.config.set_deserialize_strict("fuzzy_skin_noise_type", "ripple"); + fixture.config.set_deserialize_strict("fuzzy_skin_thickness", "0.3"); + fixture.config.set_deserialize_strict("fuzzy_skin_point_distance", "0.3"); + fixture.config.set_deserialize_strict("fuzzy_skin_first_layer", "1"); +} + +// Checks the noisy outer loops, or hole loops, of a frame (make_frame()) against the smooth loop of the other kind on +// the same layer, whose centre is the frame's. Every one has its seam at (x, y) from that centre, within `along` and +// `across`, or none has it on the front. +void check_fuzzy_seams(const std::vector &loops, bool hole, bool at_front, double x, double y, double along, + double across) +{ + size_t checked = 0; + for (const OuterLoop &loop : loops) { + if ((loop.bounds.size().x() < 10.) != hole) + continue; + const auto smooth = std::find_if(loops.begin(), loops.end(), [&loop, hole](const OuterLoop &other) { + return other.z == loop.z && (other.bounds.size().x() < 10.) != hole; + }); + REQUIRE(smooth != loops.end()); + const Vec2d seam = loop.seam + loop.bounds.center() - smooth->bounds.center(); + ++checked; + CAPTURE(checked, seam.x(), seam.y()); + if (at_front) { + CHECK_THAT(seam.x(), Catch::Matchers::WithinAbs(x, along)); + CHECK_THAT(seam.y(), Catch::Matchers::WithinAbs(y, across)); + } else + CHECK(seam.y() > 0.); // The back seam, away from the helper. + } + CHECK(checked == 10); +} +} // namespace + +TEST_CASE("With fuzzy skin a modifier acts at the model surface, not at the noise", "[PreciseSeam]") +{ + const bool hole = GENERATE(false, true); + const bool reaches = GENERATE(true, false); + const std::string generator = GENERATE(as{}, "classic", "arachne"); + CAPTURE(hole, reaches, generator); + ExportFixture fixture("back", 0, make_cube(7, 20, 2)); + fixture.config.set_deserialize_strict("wall_generator", generator); + fixture.config.set_deserialize_strict("elefant_foot_compensation", "0"); + set_ripple_fuzzy_skin(fixture, hole ? "hole" : "external"); + make_frame(fixture); + // 0.05 mm into or in front of the front face or the hole wall y = 7 mm. The noise reaches 0.1 mm beyond the model + // surface, so the surface of the noisy loop itself would reach the helper in front of it. + const double depth = reaches ? 0.05 : -0.05; + if (hole) + fixture.add(ModelVolumeType::PRECISE_SEAM_CENTER, make_cube(2, 2. + depth, 4), Vec3d(9, 7. - depth, -1)); + else + fixture.add(ModelVolumeType::PRECISE_SEAM_CENTER, make_cube(2, 3. + depth, 4), Vec3d(4, -3, -1)); + const auto loops = outer_wall_loops(fixture.export_gcode()); + // On the noisy loop across the smooth centerline, 0.2 mm inside the wall, within the noise. + check_fuzzy_seams(loops, hole, reaches, hole ? 0. : -5., hole ? -3.2 : -9.8, 0.01, 0.35); +} + +TEST_CASE("With fuzzy skin a weak zone keeps its boundaries on the noisy loop", "[PreciseSeam]") +{ + const std::string generator = GENERATE(as{}, "classic", "arachne"); + CAPTURE(generator); + ExportFixture fixture("back", 0, make_cube(7, 20, 2)); + fixture.config.set_deserialize_strict("wall_generator", generator); + fixture.config.set_deserialize_strict("elefant_foot_compensation", "0"); + set_ripple_fuzzy_skin(fixture, "external"); + make_frame(fixture); + // Enforced from x = 4 to 6 mm, 0.05 mm into the front face: the seam moves into the zone. + fixture.add(ModelVolumeType::PRECISE_SEAM_ENFORCED, make_cube(2, 3.05, 4), Vec3d(4, -3, -1)); + const auto loops = outer_wall_loops(fixture.export_gcode()); + check_fuzzy_seams(loops, false, true, -5., -9.8, 1.01, 0.35); +} + +TEST_CASE("With fuzzy skin in Arachne's combined mode at the smallest noise a modifier still applies", "[PreciseSeam][Fuzzy]") +{ + const bool strong = GENERATE(true, false); + CAPTURE(strong); + ExportFixture fixture("back", 0, make_cube(7, 20, 2)); + fixture.config.set_deserialize_strict("wall_generator", "arachne"); + fixture.config.set_deserialize_strict("elefant_foot_compensation", "0"); + fixture.config.set_deserialize_strict("layer_height", "0.2"); + fixture.config.set_deserialize_strict("fuzzy_skin", "external"); + fixture.config.set_deserialize_strict("fuzzy_skin_noise_type", "classic"); + fixture.config.set_deserialize_strict("fuzzy_skin_mode", "combined"); + // The smallest thickness and point distance slicing keeps. Combined moves the points by half their change of + // width, which takes the smallest width it keeps: about 0.022 mm at 0.2 mm layers, beyond the 0.012 mm the + // thickness and the point distance make. + fixture.config.set_deserialize_strict("fuzzy_skin_thickness", "0.001"); + fixture.config.set_deserialize_strict("fuzzy_skin_point_distance", "0.01"); + fixture.config.set_deserialize_strict("fuzzy_skin_first_layer", "1"); + make_frame(fixture); + // Center, or Enforced from x = 4 to 6 mm, 0.05 mm into the front face. + fixture.add(strong ? ModelVolumeType::PRECISE_SEAM_CENTER : ModelVolumeType::PRECISE_SEAM_ENFORCED, make_cube(2, 3.05, 4), + Vec3d(4, -3, -1)); + const auto loops = outer_wall_loops(fixture.export_gcode()); + // A transfer that failed would leave the seam at the back. + check_fuzzy_seams(loops, false, true, -5., -9.8, strong ? 0.01 : 1.01, 0.35); +} + +TEST_CASE("With fuzzy skin elephant foot layers act at the same modifier depth, in one region or several", "[PreciseSeam]") +{ + const bool several_regions = GENERATE(false, true); + const std::string generator = GENERATE(as{}, "classic", "arachne"); + CAPTURE(several_regions, generator); + ExportFixture fixture("back", 0, make_cube(7, 20, 2)); + fixture.config.set_deserialize_strict("wall_generator", generator); + set_elephant_foot(fixture); + set_ripple_fuzzy_skin(fixture, "external"); + make_frame(fixture); + if (several_regions) { + // A different infill density over the right half makes a second region without a wall between them. + fixture.add(ModelVolumeType::PARAMETER_MODIFIER, make_cube(15, 30, 4), Vec3d(10, -5, -1), "infill"); + DynamicPrintConfig infill; + infill.set_key_value("sparse_infill_density", new ConfigOptionPercent(50)); + fixture.model.objects.front()->volumes.back()->config.apply(infill); + } + // 0.05 mm into the front face; the walls of the first three layers lie 0.3, 0.2 and 0.1 mm deeper. + fixture.add(ModelVolumeType::PRECISE_SEAM_CENTER, make_cube(2, 3.05, 4), Vec3d(4, -3, -1)); + const auto loops = outer_wall_loops(fixture.export_gcode()); + if (several_regions) + REQUIRE(fixture.print.get_object(0)->get_layer(0)->regions().size() > 1); + check_fuzzy_seams(loops, false, true, -5., -9.8, 0.01, 0.65); +} + +namespace { +// Calls `visit` on every extrusion loop of the object's layers, through nested collections. +void for_each_loop(PrintObject &object, const std::function &visit) +{ + const std::function walk = [&](ExtrusionEntityCollection &collection) { + for (ExtrusionEntity *entity : collection.entities) { + if (entity->is_collection()) + walk(*static_cast(entity)); + else if (entity->is_loop()) + visit(*static_cast(entity)); + } + }; + for (size_t layer = 0; layer < object.layer_count(); ++layer) + for (size_t region = 0; region < object.get_layer(int(layer))->regions().size(); ++region) + walk(object.get_layer(int(layer))->get_region(int(region))->perimeters); +} +} // namespace + +TEST_CASE("Only external loops that fuzzy skin changes keep their untextured centerline", "[PreciseSeam][Fuzzy]") +{ + const std::string fuzzy_skin = GENERATE(as{}, "none", "external", "hole"); + const std::string generator = GENERATE(as{}, "classic", "arachne"); + CAPTURE(fuzzy_skin, generator); + ExportFixture fixture("back", 0, make_cube(7, 20, 2)); + fixture.config.set_deserialize_strict("wall_generator", generator); + set_ripple_fuzzy_skin(fixture, fuzzy_skin); + make_frame(fixture); + fixture.export_gcode(); + size_t contours = 0; + size_t holes = 0; + for_each_loop(*fixture.print.get_object(0), [&](ExtrusionLoop &loop) { + if (loop.untextured == nullptr) + return; + // Only external walls, and the untextured line differs from the printed one. + CHECK(loop.role() == erExternalPerimeter); + CHECK(loop.untextured->points != loop.polygon().points); + ++((loop.loop_role() & elrHole) ? holes : contours); + }); + // One contour and one hole on each of the 10 layers. + CHECK(contours == (fuzzy_skin == "external" ? 10u : 0u)); + CHECK(holes == (fuzzy_skin == "hole" ? 10u : 0u)); +} + +TEST_CASE("With fuzzy skin on part of a wall a modifier acts at the model surface there", "[PreciseSeam][Fuzzy]") +{ + const bool reaches = GENERATE(true, false); + const std::string generator = GENERATE(as{}, "classic", "arachne"); + CAPTURE(reaches, generator); + ExportFixture fixture("back", 0, make_cube(7, 20, 2)); + fixture.config.set_deserialize_strict("wall_generator", generator); + fixture.config.set_deserialize_strict("elefant_foot_compensation", "0"); + // The classic generator builds a wall along the edge of the fuzzy region across the hole, printed as an overhang + // there; that would split the outer wall in the G-code into several loops. + fixture.config.set_deserialize_strict("detect_overhang_wall", "0"); + make_frame(fixture); + // Fuzzy skin on the outer walls over the right half only. + fixture.add(ModelVolumeType::PARAMETER_MODIFIER, make_cube(15, 30, 4), Vec3d(10, -5, -1), "fuzzy half"); + DynamicPrintConfig fuzzy; + fuzzy.set_key_value("fuzzy_skin", new ConfigOptionEnum(FuzzySkinType::External)); + fuzzy.set_key_value("fuzzy_skin_noise_type", new ConfigOptionEnum(NoiseType::Ripple)); + fuzzy.set_key_value("fuzzy_skin_thickness", new ConfigOptionFloat(0.3)); + fuzzy.set_key_value("fuzzy_skin_point_distance", new ConfigOptionFloat(0.3)); + fuzzy.set_key_value("fuzzy_skin_first_layer", new ConfigOptionBool(true)); + fixture.model.objects.front()->volumes.back()->config.apply(fuzzy); + // 0.05 mm into or in front of the front face at x = 14..16 mm, in the noisy part. + const double depth = reaches ? 0.05 : -0.05; + fixture.add(ModelVolumeType::PRECISE_SEAM_CENTER, make_cube(2, 3. + depth, 4), Vec3d(14, -3, -1)); + const auto loops = outer_wall_loops(fixture.export_gcode()); + size_t textured = 0; + for_each_loop(*fixture.print.get_object(0), [&textured](ExtrusionLoop &loop) { textured += loop.untextured != nullptr; }); + CHECK(textured >= 10); + check_fuzzy_seams(loops, false, reaches, 5., -9.8, 0.01, 0.35); +} + +TEST_CASE("A closed thin wall with fuzzy skin keeps no untextured centerline in the classic generator", "[PreciseSeam][Fuzzy]") +{ + // A ring 0.3 mm thick, thinner than one line: the classic generator prints it as a closed thin wall, which it + // builds outside the loops of its perimeters and textures there. + ExportFixture fixture("back", 0, make_cylinder(5.15, 2)); + fixture.config.set_deserialize_strict("wall_generator", "classic"); + fixture.config.set_deserialize_strict("detect_thin_wall", "1"); + fixture.config.set_deserialize_strict("elefant_foot_compensation", "0"); + set_ripple_fuzzy_skin(fixture, "external"); + fixture.add(ModelVolumeType::NEGATIVE_VOLUME, make_cylinder(4.85, 4), Vec3d(0.3, 0.3, -1), "bore"); + fixture.add(ModelVolumeType::PRECISE_SEAM_CENTER, make_cube(1, 3, 4), Vec3d(4.65, -2, -1)); + const auto loops = outer_wall_loops(fixture.export_gcode()); + CHECK_FALSE(loops.empty()); + size_t closed = 0; + for_each_loop(*fixture.print.get_object(0), [&closed](ExtrusionLoop &loop) { + ++closed; + CHECK(loop.untextured == nullptr); + }); + CHECK(closed > 0); +} + +TEST_CASE("Loops whose untextured centerline is cleared by hand keep the noisy surface, as loading cached data leaves them", "[PreciseSeam][Fuzzy]") +{ + const std::string generator = GENERATE(as{}, "classic", "arachne"); + CAPTURE(generator); + ExportFixture fixture("back", 0, make_cube(7, 20, 2)); + fixture.config.set_deserialize_strict("wall_generator", generator); + fixture.config.set_deserialize_strict("elefant_foot_compensation", "0"); + set_ripple_fuzzy_skin(fixture, "external"); + make_frame(fixture); + // 0.05 mm in front of the front face: clear of the model surface, within reach of the noise. + fixture.add(ModelVolumeType::PRECISE_SEAM_CENTER, make_cube(2, 2.95, 4), Vec3d(4, -3, -1)); + fixture.print.apply(fixture.model, fixture.config); + fixture.print.process(); + // Loading sliced data from a cache restores the extrusions without the field; here it is cleared by hand, without + // writing and loading the cache. + for_each_loop(*fixture.print.get_object(0), [](ExtrusionLoop &loop) { loop.untextured.reset(); }); + const auto loops = outer_wall_loops(Test::gcode(fixture.print)); + // The surface then follows the noise and reaches the modifier on some layers, as before. + size_t front = 0; + for (const OuterLoop &loop : loops) + if (loop.bounds.size().x() >= 10. && loop.seam.y() < 0.) + ++front; + CHECK(front > 0); +} + +TEST_CASE("With a raft the modifier depth needed is that of the constant shift", "[PreciseSeam]") +{ + const std::string generator = GENERATE(as{}, "classic", "arachne"); + const bool reaches = GENERATE(true, false); + CAPTURE(generator, reaches); + // Slicing applies elephant foot compensation only directly on the bed. + ExportFixture fixture("back", 2); + fixture.config.set_deserialize_strict("wall_generator", generator); + set_elephant_foot(fixture); + const double depth = reaches ? 0.05 : -0.05; + fixture.add(ModelVolumeType::PRECISE_SEAM_CENTER, make_cube(2, 3. + depth, 4), Vec3d(4, -3, -1)); + const auto loops = outer_wall_loops(fixture.export_gcode()); + REQUIRE(loops.size() == 10); + check_front_seams(loops, false, reaches, 5. - 10.); +} + +TEST_CASE("XY compensation with elephant foot compensation keeps the modifier depth, in one region or several", "[PreciseSeam]") +{ + const bool hole = GENERATE(false, true); + const double compensation = GENERATE(-0.1, 0.1); + const bool several_regions = GENERATE(false, true); + const bool reaches = GENERATE(true, false); + const std::string generator = GENERATE(as{}, "classic", "arachne"); + CAPTURE(hole, compensation, several_regions, reaches, generator); + ExportFixture fixture("back", 0, make_cube(7, 20, 2)); + fixture.config.set_deserialize_strict("wall_generator", generator); + fixture.config.set_deserialize_strict(hole ? "xy_hole_compensation" : "xy_contour_compensation", std::to_string(compensation)); + set_elephant_foot(fixture, 0.15); + make_frame(fixture); + if (several_regions) { + // A different infill density over the right half makes a second region without a wall between them. With + // several regions slicing keeps the outline of elephant foot layers before negative XY compensation. + fixture.add(ModelVolumeType::PARAMETER_MODIFIER, make_cube(15, 30, 4), Vec3d(10, -5, -1), "infill"); + DynamicPrintConfig infill; + infill.set_key_value("sparse_infill_density", new ConfigOptionPercent(50)); + fixture.model.objects.front()->volumes.back()->config.apply(infill); + } + // 0.05 mm into or in front of the model face, wherever the compensations moved the wall. + const double depth = reaches ? 0.05 : -0.05; + if (hole) + fixture.add(ModelVolumeType::PRECISE_SEAM_CENTER, make_cube(2, 2. + depth, 4), Vec3d(9, 7. - depth, -1)); // Hole wall y = 7. + else + fixture.add(ModelVolumeType::PRECISE_SEAM_CENTER, make_cube(2, 3. + depth, 4), Vec3d(4, -3, -1)); // Front face. + const auto loops = outer_wall_loops(fixture.export_gcode()); + if (several_regions) + REQUIRE(fixture.print.get_object(0)->get_layer(0)->regions().size() > 1); + check_front_seams(loops, hole, reaches, hole ? 0. : 5. - 10.); +} + +TEST_CASE("An Arachne wall narrower than its nominal line acts at the model surface", "[PreciseSeam]") +{ + const double depth = GENERATE(0., 0.02); + CAPTURE(depth); + // A 0.7 mm wall is split into two Arachne lines of about 0.37 mm, so the centerline lies about 0.186 mm inside the + // face instead of 0.2: half the nominal width would put the surface outside the model face. + ExportFixture fixture("back", 0, make_cube(20, 0.7, 2)); + fixture.config.set_deserialize_strict("wall_generator", "arachne"); + fixture.config.set_deserialize_strict("elefant_foot_compensation", "0"); + fixture.add(ModelVolumeType::PRECISE_SEAM_CENTER, make_cube(2, 3. + depth, 4), Vec3d(4, -3, -1)); + const auto loops = outer_wall_loops(fixture.export_gcode()); + REQUIRE(loops.size() == 10); + for (const OuterLoop &loop : loops) { + CAPTURE(loop.seam.x(), loop.seam.y()); + if (depth > 0.) { + CHECK_THAT(loop.seam.x(), Catch::Matchers::WithinAbs(5. - 10., 0.01)); + CHECK_THAT(loop.seam.y(), Catch::Matchers::WithinAbs(loop.bounds.min.y() - loop.bounds.center().y(), 0.01)); + } else + CHECK(loop.seam.y() > 0.); // The back face. + } +} + TEST_CASE("Full containment warns for Blocked but not for Enforced", "[PreciseSeam]") { const auto type = GENERATE(ModelVolumeType::PRECISE_SEAM_ENFORCED, ModelVolumeType::PRECISE_SEAM_BLOCKED); diff --git a/tests/fff_print/test_seam_placer.cpp b/tests/fff_print/test_seam_placer.cpp index 4a6f1d6699..bd992cf461 100644 --- a/tests/fff_print/test_seam_placer.cpp +++ b/tests/fff_print/test_seam_placer.cpp @@ -1539,6 +1539,55 @@ TEST_CASE("Seam extraction preserves unknown boundary roles for open extrusion p CHECK(perimeters.front().contour_reliable == !open); } +TEST_CASE("Staggered inner seam stays next to a seam on a hairpin corner", "[SeamPlacer][Regression]") +{ + PipelineFixture fixture(false, 0.2f); // One layer. + fixture.config.set_deserialize_strict("staggered_inner_seams", "1"); + fixture.print.apply(fixture.model, fixture.config); + PrintObject &object = fixture.prepare(); + auto ®ion = clear_first_layer(object); + + // A hole with an 8 mm slit into the material, 1 nm wide at its opening: the slit tip is the hole's rearmost point + // and turns the wall back by a hair less than 180 degrees. + const Point tip = fixture.points_in_layer(object, {{10, 14}}).front(); + Points hole = fixture.points_in_layer(object, {{10, 6}, {6, 6}, {6, 4}, {14, 4}, {14, 6}}); + hole.push_back(hole.front() + Point(1, 0)); + hole.push_back(tip); + std::reverse(hole.begin(), hole.end()); // Holes run clockwise. + ExtrusionLoop hole_loop = make_loop(hole, erExternalPerimeter, 0); + hole_loop.set_loop_role(elrHole); + // The inner wall sits 0.4 mm into the material and runs around the slit. + ExtrusionLoop inner = make_loop(fixture.points_in_layer(object, {{9.6, 6.4}, {5.6, 6.4}, {5.6, 3.6}, {14.4, 3.6}, + {14.4, 6.4}, {10.4, 6.4}, {10.4, 14.4}, {9.6, 14.4}}), + erPerimeter, 1); + std::reverse(inner.paths.front().polyline.points.begin(), inner.paths.front().polyline.points.end()); + ExtrusionEntityCollection island; + island.append(make_loop(fixture.points_in_layer(object, {{2, 2}, {18, 2}, {18, 18}, {2, 18}}), erExternalPerimeter, 0)); + island.append(std::move(hole_loop)); + island.append(inner); + region.perimeters.append(std::move(island)); + + SeamPlacer placer; + placer.init(fixture.print, [] {}); + + // The planned seam of the hole is the slit tip, a concave corner within a float step of a full reversal. + const auto &layer_seams = placer.m_seam_per_object.at(&object).layers.front(); + const auto hole_seam = std::find_if(layer_seams.points.begin(), layer_seams.points.end(), [&](const auto &candidate) { + return candidate.perimeter.seam_index < layer_seams.points.size() && + &layer_seams.points[candidate.perimeter.seam_index] == &candidate && + (unscale(tip).cast() - candidate.position.template head<2>()).norm() < 0.01f; + }); + REQUIRE(hole_seam != layer_seams.points.end()); + REQUIRE(hole_seam->local_ccw_angle < -3.14159f); + REQUIRE(hole_seam->local_ccw_angle > -static_cast(PI)); // Short of a full reversal: cos(angle / 2) is positive. + + ExtrusionLoop placed = inner; + float overhang = 0.0f; + placer.place_seam(object.layers().front(), placed, Point(0, 0), overhang); + // Staggering moves the inner seam about a line width along the wall, never around the loop at random. + CHECK_THAT((unscale(placed.first_point()) - unscale(tip)).norm(), Catch::Matchers::WithinAbs(0.0, 1.0)); +} + TEST_CASE("Seams are picked on every loop of every object when init() places several objects at once", "[SeamPlacer]") { // Random seams are picked by the workers of each object alone, and they finalize every loop. Sixteen objects make diff --git a/tests/libslic3r/test_locales_utils.cpp b/tests/libslic3r/test_locales_utils.cpp index c4ee69fe11..3ec9530516 100644 --- a/tests/libslic3r/test_locales_utils.cpp +++ b/tests/libslic3r/test_locales_utils.cpp @@ -12,6 +12,7 @@ #include #include +#include #include using namespace Slic3r; @@ -89,6 +90,37 @@ TEST_CASE("atof_decimal_point parses what atof parses in the C locale", "[Locale CHECK_THAT(atof_decimal_point(text), Catch::Matchers::WithinAbs(value, 1e-12)); } +TEST_CASE("strtod_decimal_point parses what strtod parses in the C locale", "[LocalesUtils]") +{ + const auto [text, value, length] = GENERATE(table({ + { "5", 5., 1 }, + { " 12.5 7", 12.5, 6 }, + { "\t+3", 3., 3 }, + { "-1.25", -1.25, 5 }, + { "1e2", 100., 3 }, + { ".5", 0.5, 2 }, + { "0,5", 0., 1 }, + { "+-5", 0., 0 }, + { "", 0., 0 }, + { "abc", 0., 0 }, + })); + INFO(text); + char *end = nullptr; + CHECK_THAT(strtod_decimal_point(text, &end), Catch::Matchers::WithinAbs(value, 1e-12)); + CHECK(size_t(end - text) == length); +} + +TEST_CASE("strtod_decimal_point reads a decimal point when the process locale uses a comma", "[LocalesUtils]") +{ + ProcessCommaNumericLocale comma; + if (! comma.apply()) + SKIP("no locale with a comma decimal separator is installed"); + const char *text = "0.5 1"; + char *end = nullptr; + CHECK_THAT(strtod_decimal_point(text, &end), Catch::Matchers::WithinAbs(0.5, 1e-12)); + CHECK(end == text + 3); +} + TEST_CASE("Nozzle diameter strings read back in a locale whose decimal separator is a comma", "[LocalesUtils]") { CommaNumericLocale comma; diff --git a/tests/libslic3r/test_model.cpp b/tests/libslic3r/test_model.cpp index 8b0fcff8a9..f6695a04fc 100644 --- a/tests/libslic3r/test_model.cpp +++ b/tests/libslic3r/test_model.cpp @@ -1,9 +1,11 @@ #include #include #include +#include #include #include #include +#include "libslic3r/PrintConfig.hpp" #include "libslic3r/TriangleMesh.hpp" #include "libslic3r/Polygon.hpp" #include "libslic3r/BoundingBox.hpp" @@ -120,6 +122,34 @@ TriangleMesh flat_triangle_then_cubes(const std::vector &cube_offsets) } // namespace +TEST_CASE("Splitting a scaled object keeps each part in place in the assembly view", "[Model]") +{ + Model model; + ModelObject *object = model.add_object(); + ModelInstance *instance = object->add_instance(); + instance->set_scaling_factor(Vec3d::Constant(2.)); + Geometry::Transformation assembly = instance->get_transformation(); + assembly.set_rotation(Z, 0.5 * PI); + assembly.set_offset(Vec3d(40., 30., 10.)); + instance->set_assemble_transformation(assembly); + + std::vector expected; + for (double x : {0., 20.}) { + ModelVolume *volume = object->add_volume(make_cube(10., 10., 10.)); + volume->set_offset(Vec3d(x, 0., 0.)); + expected.push_back(assembly.get_matrix() * volume->get_matrix()); + } + + ModelObjectPtrs parts; + object->split(&parts, false); + REQUIRE(parts.size() == expected.size()); + for (size_t i = 0; i < parts.size(); ++i) { + const ModelObject &part = *parts[i]; + const Transform3d actual = part.instances.front()->get_assemble_transformation().get_matrix() * part.volumes.front()->get_matrix(); + CHECK(actual.isApprox(expected[i])); + } +} + TEST_CASE("Splitting a part drops pieces enclosing no volume and keeps the part itself", "[Model]") { Model model; @@ -623,3 +653,42 @@ TEST_CASE("Converting a part's units keeps an id whose material is missing", "[M Model owner; owner.objects = std::move(converted); } + +TEST_CASE("Per-feature filament assignments follow mixed slots at each model scope", "[Model][FilamentMixer]") +{ + const char *key = GENERATE("outer_wall_filament_id", "inner_wall_filament_id", "sparse_infill_filament_id", + "internal_solid_filament_id", "top_surface_filament_id", "bottom_surface_filament_id"); + CAPTURE(key); + Model model; + ModelObject *object = model.add_object(); + ModelVolume *part = object->add_volume(make_cube(10, 10, 10)); + ModelVolume *painted_modifier = object->add_painted_modifier(*part); + auto &modifier = object->add_volume(make_cube(5, 5, 5), ModelVolumeType::PARAMETER_MODIFIER)->config; + auto &range = object->layer_config_ranges[{0., 5.}]; + auto &material = model.add_material("shared")->config; + auto &inherited = object->layer_config_ranges[{5., 10.}]; + auto &physical = model.add_object()->config; + physical.set(key, 2); + inherited.set("extruder", 0); + + ModelConfig *scopes[] = {&object->config, &part->config, &modifier, &painted_modifier->config, &range, &material}; + for (ModelConfig *config : scopes) + config->set(key, 3); + remap_model_filament_configs(model, {{2, 3}, {3, 4}}, true); + auto check_assignments = [&](int expected) { + for (const ModelConfig *config : scopes) + CHECK(config->opt_int(key) == expected); + CHECK(physical.opt_int(key) == 2); + CHECK_FALSE(inherited.has(key)); + }; + check_assignments(4); + remap_model_filament_configs(model, {{2, -1}, {3, 2}, {4, 3}}, false); + check_assignments(3); + remap_model_filament_slots(model, {{2, 4}}); + check_assignments(5); + // Merge the selected slot into slot 4, then remove it without a replacement. + remap_model_filament_configs(model, {{4, 3}}, false); + check_assignments(4); + remap_model_filament_configs(model, {{3, -1}}, false); + check_assignments(0); +} diff --git a/tests/libslic3r/test_obj.cpp b/tests/libslic3r/test_obj.cpp index abab016b2a..f4df8b132b 100644 --- a/tests/libslic3r/test_obj.cpp +++ b/tests/libslic3r/test_obj.cpp @@ -4,6 +4,8 @@ #include #include #include +#include "libslic3r/BoundingBox.hpp" +#include "libslic3r/Color.hpp" #include "libslic3r/TriangleMesh.hpp" #include "libslic3r/Format/OBJ.hpp" @@ -27,13 +29,13 @@ struct LoadedObj }; // Loads an OBJ made of the given lines, with a material library that defines material "a". -LoadedObj load_textured_obj(const std::string &body) +LoadedObj load_textured_obj(const std::string &body, const std::string &materials = "newmtl a\nKd 1 0 0\n") { ScopedTemporaryFile obj(".obj"); ScopedTemporaryFile mtl(".mtl"); { boost::nowide::ofstream out(mtl.string()); - out << "newmtl a\nKd 1 0 0\n"; + out << materials; } { boost::nowide::ofstream out(obj.string()); @@ -172,3 +174,35 @@ TEST_CASE("Texture coordinates follow the corners of a mesh that is flipped on l for (int corner = 0; corner < 3; ++corner) check_uv_is_vt(loaded.info.uvs[face][corner], its.indices[face][corner] + 1); } + +TEST_CASE("Numbers with a decimal point load when the process locale uses a decimal comma", "[OBJ][Regression]") +{ + // The GUI sets the process locale from its language. On macOS 13.3 to 14.0, strtod read that locale + // inside the parser's CNumericLocalesSetter, so it dropped every vertex and the faces failed to load. + ProcessCommaNumericLocale comma; + if (! comma.apply()) + SKIP("no locale with a comma decimal separator is installed"); + const LoadedObj loaded = load_textured_obj("v 0.5 0.5 0.5 1 0.5 0.25\nv 10.5 0.5 0.5 1 0.5 0.25\n" + "v 0.5 10.5 0.5 1 0.5 0.25\nv 0.5 0.5 10.5 1 0.5 0.25\n" + "vt 0.25 0.5\n" + "usemtl a\n" + "f 1/1 3/1 2/1\nf 1/1 2/1 4/1\nf 1/1 4/1 3/1\nf 2/1 3/1 4/1\n", + "newmtl a\nKd 0.5 0.25 0.125\n"); + + REQUIRE(loaded.ok); + REQUIRE(loaded.mesh.facets_count() == 4); + const BoundingBoxf3 box = loaded.mesh.bounding_box(); + for (int axis = 0; axis < 3; ++axis) { + CHECK_THAT(box.min[axis], WithinAbs(0.5, 1e-6)); + CHECK_THAT(box.max[axis], WithinAbs(10.5, 1e-6)); + } + REQUIRE(loaded.info.vertex_colors.size() == 4); + CHECK_THAT(loaded.info.vertex_colors.front()[1], WithinAbs(0.5, 1e-6)); + CHECK_THAT(loaded.info.vertex_colors.front()[2], WithinAbs(0.25, 1e-6)); + REQUIRE(loaded.info.face_colors.size() == 4); + CHECK_THAT(loaded.info.face_colors.front()[0], WithinAbs(0.5, 1e-6)); + CHECK_THAT(loaded.info.face_colors.front()[2], WithinAbs(0.125, 1e-6)); + REQUIRE(loaded.info.uvs.size() == 4); + CHECK_THAT(loaded.info.uvs.front()[0].x(), WithinAbs(0.25, 1e-6)); + CHECK_THAT(loaded.info.uvs.front()[0].y(), WithinAbs(0.5, 1e-6)); +} diff --git a/tests/libslic3r/test_precise_seam.cpp b/tests/libslic3r/test_precise_seam.cpp index d31c645f13..77ca2e3669 100644 --- a/tests/libslic3r/test_precise_seam.cpp +++ b/tests/libslic3r/test_precise_seam.cpp @@ -7,8 +7,13 @@ #include "libslic3r/GCode/PreciseSeam.hpp" #include "libslic3r/GCode/PreciseSeamInternal.hpp" #include "libslic3r/ClipperUtils.hpp" +#include "libslic3r/AABBTreeLines.hpp" +#include "libslic3r/Line.hpp" +#include +#include "libslic3r/ExtrusionEntity.hpp" #include +#include #include #include "libslic3r/Point.hpp" #include "libslic3r/Polygon.hpp" @@ -19,6 +24,8 @@ #include #include "libslic3r/libslic3r.h" #include "libslic3r/Polyline.hpp" +#include "libslic3r/PerimeterGenerator.hpp" +#include "libslic3r/PrintConfig.hpp" using namespace Slic3r; @@ -1055,3 +1062,994 @@ TEST_CASE("Rounded intersections on an inclined edge retain their original edge" CHECK_THAT(segment.length, Catch::Matchers::WithinAbs((last - first).norm(), 2. * std::sqrt(2.))); CHECK_FALSE(result.full_containment); } + +namespace { +// 0.2 mm, the shift of a 0.4 mm line without margin or compensation; keeps the expected points round. +const coord_t surface_distance = coord_t(scale_(0.2)); + +// The L-shaped contour has its only concave vertex at (10, 10): edge 2 arrives along y = 10, edge 3 leaves +// along x = 10, and their shifted copies cross at (10.2, 10.2). +Polygon l_shape() +{ + return Polygon(Points{mm(0, 0), mm(20, 0), mm(20, 10), mm(10, 10), mm(10, 20), mm(0, 20)}); +} + +PreciseSeam::SegmentExtraction surface_extraction(const Polygon &perimeter, ExPolygons regions, bool hole = false, + ModelVolumeType mode = ModelVolumeType::PRECISE_SEAM_CENTER, + coord_t shift = surface_distance) +{ + const PreciseSeam::PreparedPerimeter prepared(perimeter, shift, hole); + return PreciseSeam::extract_perimeter_segments(prepared, PreciseSeam::prepare_modifier_regions(std::move(regions)), mode); +} + +PreciseSeam::SegmentExtraction surface_extraction(const Polygon &perimeter, const Polygon ®ion, bool hole = false, + ModelVolumeType mode = ModelVolumeType::PRECISE_SEAM_CENTER, + coord_t shift = surface_distance) +{ + return surface_extraction(perimeter, ExPolygons{ExPolygon(region)}, hole, mode, shift); +} + +bool contains_point(const Polyline &polyline, const Point &point) +{ + return std::find(polyline.points.begin(), polyline.points.end(), point) != polyline.points.end(); +} +} // namespace + +TEST_CASE("The surface line shifts edges towards air, follows convex corners and bridges concave ones", "[PreciseSeam][SegmentExtraction]") +{ + // A convex contour has no dead stretches; the clipping line closes the polygon at its start. + const Polygon square = rectangle(0, 0, 20, 20); + const auto convex = PreciseSeam::detail::build_surface_line(square, surface_distance, false); + REQUIRE(convex.shifts.size() == 4); + CHECK(convex.shifts[0] == Point(0, -surface_distance)); + CHECK(convex.shifts[1] == Point(surface_distance, 0)); + REQUIRE(convex.elements.size() == convex.polygon.size()); + size_t arc_chords = 0; + for (size_t i = 0; i < convex.polygon.size(); ++i) { + CHECK(convex.polygon.points[i] != convex.polygon.points[(i + 1) % convex.polygon.size()]); + arc_chords += convex.elements[i].vertex ? 1 : 0; + } + CHECK(arc_chords > 4); // Every corner is an arc of several chords. + REQUIRE(convex.line.size() == convex.polygon.size() + 1); + CHECK(convex.line.first_point() == convex.line.last_point()); + CHECK(convex.gaps.empty()); + + // One concave corner leaves one dead stretch whose ends meet near the crossing of the shifted edges. + const auto concave = PreciseSeam::detail::build_surface_line(l_shape(), surface_distance, false); + REQUIRE(concave.gaps.size() == 1); + CHECK((concave.gaps.front().end - mm(10.2, 10.2)).cast().norm() < scale_(0.001)); + CHECK((concave.gaps.front().start - mm(10.2, 10.2)).cast().norm() < scale_(0.001)); + + // The wall of a hole is shifted into the hole, where its corners are concave: the shifted edges end at their + // crossings, with a dead stretch at every corner. + const auto hole = PreciseSeam::detail::build_surface_line(rectangle(0, 0, 10, 10), surface_distance, true); + CHECK(hole.shifts[0] == Point(0, surface_distance)); + CHECK(hole.gaps.size() == 4); + CHECK(hole.polygon.points == Points{mm(0.2, 0.2), mm(9.8, 0.2), mm(9.8, 9.8), mm(0.2, 9.8)}); + CHECK(hole.bounds.defined); +} + +TEST_CASE("A modifier crossing the surface acts without reaching the centerline", "[PreciseSeam][SegmentExtraction]") +{ + const Polygon square = rectangle(0, 0, 20, 20); + // 0.1 mm past the surface, 0.1 mm short of the centerline. + const Polygon shallow = rectangle(8, -1, 12, -0.1); + CHECK(surface_extraction(square, shallow, false, ModelVolumeType::PRECISE_SEAM_CENTER, 0).segments.empty()); + const auto result = surface_extraction(square, shallow); + check_provenance(square, result); + REQUIRE(result.segments.size() == 1); + CHECK(result.segments.front().polyline.points.front() == mm(8, 0)); + CHECK(result.segments.front().polyline.points.back() == mm(12, 0)); + CHECK_FALSE(result.full_containment); + + // An inclined side maps along the normal: it crosses the surface y = -0.2 at x = 7 + 0.8 / 0.9. + const Polygon inclined(Points{mm(7, -1), mm(12, -1), mm(12, -0.1), mm(8, -0.1)}); + const auto slanted = surface_extraction(square, inclined); + check_provenance(square, slanted); + REQUIRE(slanted.segments.size() == 1); + CHECK_THAT(unscale(slanted.segments.front().polyline.points.front().x()), + Catch::Matchers::WithinAbs(7. + 0.8 / 0.9, 1e-5)); + CHECK(slanted.segments.front().polyline.points.front().y() == 0); +} + +TEST_CASE("A modifier that does not cross the surface has no effect even across the centerline", "[PreciseSeam][SegmentExtraction]") +{ + const Polygon square = rectangle(0, 0, 20, 20); + // Stops 0.1 mm short of the surface. + const auto short_of_surface = surface_extraction(square, rectangle(8, -1, 12, -0.3)); + CHECK(short_of_surface.segments.empty()); + CHECK_FALSE(short_of_surface.full_containment); + // Lies inside the body: crosses the centerline but never reaches the surface. + const auto inside = surface_extraction(square, rectangle(8, -0.15, 12, 0.5)); + CHECK(inside.segments.empty()); + CHECK_FALSE(inside.full_containment); + CHECK(inside.discarded_fragments == 0); +} + +TEST_CASE("Covering only the arc of a convex corner gives a zero-length segment at its vertex", "[PreciseSeam][SegmentExtraction]") +{ + const auto mode = GENERATE(ModelVolumeType::PRECISE_SEAM_LEFT, ModelVolumeType::PRECISE_SEAM_CENTER, + ModelVolumeType::PRECISE_SEAM_RIGHT, ModelVolumeType::PRECISE_SEAM_ENFORCED); + const Polygon square = rectangle(0, 0, 20, 20); + // Around the arc point at -45 degrees from (20, 0), clear of both shifted edges. + const auto arc = surface_extraction(square, rectangle(20.11, -0.17, 20.17, -0.11), false, mode); + REQUIRE(arc.valid); + CHECK(arc.discarded_fragments == 0); + REQUIRE(arc.segments.size() == 1); + const auto &point = arc.segments.front(); + CHECK(point.edge_indices.empty()); + CHECK(point.polyline.points == Points{mm(20, 0)}); + CHECK(point.begin.edge_index == 1); + CHECK(point.begin.parameter == 0.); + CHECK(point.end.edge_index == 1); + CHECK(point.end.parameter == 0.); + CHECK_FALSE(arc.full_containment); + if (is_precise_seam_strong(mode)) { + REQUIRE(point.strong_target.has_value()); + CHECK(point.strong_target->point == mm(20, 0)); + CHECK(point.strong_target->edge_index == 1); + } else + CHECK_FALSE(point.strong_target.has_value()); + + // The arc together with part of the next shifted edge is an ordinary segment starting at the vertex. + const auto longer = surface_extraction(square, rectangle(20.11, -0.17, 20.5, 3), false, mode); + // Only strong modes prepare the targets the provenance check expects; only Center measures one segment. + if (is_precise_seam_strong(mode)) + check_provenance(square, longer, mode == ModelVolumeType::PRECISE_SEAM_CENTER); + REQUIRE(longer.segments.size() == 1); + CHECK(longer.segments.front().polyline.points.front() == mm(20, 0)); + CHECK(longer.segments.front().polyline.points.back() == mm(20, 3)); + CHECK(longer.segments.front().begin.edge_index == 1); + CHECK(longer.segments.front().begin.parameter == 0.); +} + +TEST_CASE("Covering the crossing of a concave corner covers its dead stretch of the centerline", "[PreciseSeam][SegmentExtraction]") +{ + const Polygon perimeter = l_shape(); + // The crossing (10.2, 10.2) inside: one segment through the vertex. + const auto across = surface_extraction(perimeter, rectangle(10.1, 10.1, 10.4, 10.4)); + check_provenance(perimeter, across); + REQUIRE(across.segments.size() == 1); + CHECK(across.segments.front().polyline.points == Points{mm(10.4, 10), mm(10, 10), mm(10, 10.4)}); + CHECK(across.segments.front().edge_indices == std::vector{2, 3}); + + // On one side only: the segment ends under the modifier, outside the dead stretch. + const auto one_side = surface_extraction(perimeter, rectangle(10.5, 10.1, 11, 10.4)); + check_provenance(perimeter, one_side); + REQUIRE(one_side.segments.size() == 1); + CHECK(one_side.segments.front().polyline.points == Points{mm(11, 10), mm(10.5, 10)}); + + // Within the shift of both walls but clear of the surface: across the bridge, and across the tail + // of a shifted edge past the crossing. + CHECK(surface_extraction(perimeter, rectangle(10.02, 10.02, 10.15, 10.15)).segments.empty()); + CHECK(surface_extraction(perimeter, rectangle(10.05, 10.05, 10.15, 10.3)).segments.empty()); +} + +TEST_CASE("The surface of a hole lies inside the hole", "[PreciseSeam][SegmentExtraction]") +{ + const Polygon perimeter = rectangle(0, 0, 10, 10); + const Polygon inside_hole = rectangle(4, 0.1, 6, 1); + const auto hole = surface_extraction(perimeter, inside_hole, true); + check_provenance(perimeter, hole); + REQUIRE(hole.segments.size() == 1); + CHECK(hole.segments.front().polyline.points == Points{mm(4, 0), mm(6, 0)}); + // The same modifier is inside the body of a contour. + CHECK(surface_extraction(perimeter, inside_hole, false).segments.empty()); + // The corners of a hole are concave: covering the crossing (9.8, 0.2) covers the corner of the centerline. + const auto corner = surface_extraction(perimeter, rectangle(9.5, 0.1, 9.9, 0.5), true); + check_provenance(perimeter, corner); + REQUIRE(corner.segments.size() == 1); + CHECK(corner.segments.front().polyline.points == Points{mm(9.5, 0), mm(10, 0), mm(10, 0.5)}); +} + +TEST_CASE("A modifier touching the surface at one point has no effect", "[PreciseSeam][SegmentExtraction]") +{ + // Counter-clockwise diamond whose top vertex lies exactly on the surface. + const Polygon diamond(Points{mm(10, -0.2), mm(9.5, -0.7), mm(10, -1.2), mm(10.5, -0.7)}); + const auto result = surface_extraction(rectangle(0, 0, 20, 20), diamond); + CHECK(result.segments.empty()); + CHECK_FALSE(result.full_containment); +} + +TEST_CASE("A modifier face flush with the model surface stays clear of the reconstructed surface", "[PreciseSeam][SegmentExtraction]") +{ + // The model surface lies half a 0.4 mm line outside the centerline; the margin keeps the + // reconstructed surface inside it. + const coord_t shift = PreciseSeam::surface_shift(0.4, 0.); + REQUIRE(shift > 0); + REQUIRE(shift < surface_distance); + CHECK(surface_extraction(rectangle(0, 0, 20, 20), rectangle(8, -1, 12, -0.2), false, + ModelVolumeType::PRECISE_SEAM_CENTER, shift).segments.empty()); + + // Inclined wall x + y = 20, flush face 0.2 mm outside it. + const Polygon triangle(Points{mm(0, 0), mm(20, 0), mm(0, 20)}); + const Vec2d normal = Vec2d(1., 1.).normalized(); + const auto at = [](const Vec2d &p) { return mm(p.x(), p.y()); }; + const Vec2d a = Vec2d(11., 9.) + 0.2 * normal; + const Vec2d b = Vec2d(9., 11.) + 0.2 * normal; + Polygon flush(Points{at(a), at(a + 2. * normal), at(b + 2. * normal), at(b)}); + flush.make_counter_clockwise(); + CHECK(surface_extraction(triangle, flush, false, ModelVolumeType::PRECISE_SEAM_CENTER, shift).segments.empty()); + + // A tessellated cylinder inside a modifier whose hole is the model surface. + Polygon circle; + for (int i = 0; i < 360; ++i) + circle.points.push_back(mm(10. * std::cos(i * PI / 180.), 10. * std::sin(i * PI / 180.))); + const auto around = [&](double distance) { + Polygons model_surface = offset(circle, float(scale_(distance)), jtRound, 10.); + REQUIRE(model_surface.size() == 1); + ExPolygon region(rectangle(-20, -20, 20, 20)); + region.holes.push_back(model_surface.front()); + region.holes.back().make_clockwise(); + return surface_extraction(circle, ExPolygons{region}, false, ModelVolumeType::PRECISE_SEAM_CENTER, shift); + }; + const auto flush_ring = around(0.2); + CHECK(flush_ring.segments.empty()); + CHECK_FALSE(flush_ring.full_containment); + // 10 um deeper the modifier covers the whole surface. + CHECK(around(0.19).full_containment); +} + +TEST_CASE("The surface shift subtracts compensation and margin and drops within the snapping radius", "[PreciseSeam][SegmentExtraction]") +{ + // d = w/2 - c - margin, kept only above the snapping radius; the margin is 5000 units and the snapping radius + // 1000 units. The line width is 0.4 mm throughout. + const auto expected = [](double distance) { return coord_t(std::lround(scale_(distance))) - 5000; }; + // Positive compensation moves the wall towards air, closer to the model surface, so it shortens the shift. + CHECK(PreciseSeam::surface_shift(0.4, 0.) == expected(0.2)); + CHECK(PreciseSeam::surface_shift(0.4, 0.1) == expected(0.1)); + CHECK(PreciseSeam::surface_shift(0.4, -0.1) == expected(0.3)); + // Two units either side of the snapping radius. + CHECK(PreciseSeam::surface_shift(0.4, 0.2 - 6002 * SCALING_FACTOR) == 1002); + CHECK(PreciseSeam::surface_shift(0.4, 0.2 - 5998 * SCALING_FACTOR) == 0); + // Compensation beyond half the width would put the surface on the body side: no shift, not a negative one. + CHECK(PreciseSeam::surface_shift(0.4, 0.3) == 0); +} + +TEST_CASE("Full containment means the whole surface, not the whole centerline", "[PreciseSeam][SegmentExtraction]") +{ + const Polygon square = rectangle(0, 0, 20, 20); + CHECK(surface_extraction(square, rectangle(-1, -1, 21, 21)).full_containment); + // Covers the centerline all round but the surface only under the bump on the front face. + const ExPolygons partial = union_ex(Polygons{rectangle(-0.1, -0.1, 20.1, 20.1), rectangle(8, -1, 12, 0)}); + const auto result = surface_extraction(square, partial); + CHECK_FALSE(result.full_containment); + REQUIRE(result.segments.size() == 1); + CHECK(result.segments.front().polyline.points == Points{mm(8, 0), mm(12, 0)}); +} + +TEST_CASE("A concave fillet finer than the shift binds without failures", "[PreciseSeam][SegmentExtraction]") +{ + // The concave corner of the L shape rounded with radius 0.1 mm in 20 edges: none of them is resolved, so the + // surface line keeps their shifted edges and bridges, crossing near the corner. + Points points{mm(0, 0), mm(20, 0), mm(20, 10)}; + for (int i = 0; i <= 20; ++i) { + const double angle = 0.5 * PI * i / 20.; + points.push_back(mm(10.1 - 0.1 * std::sin(angle), 10.1 - 0.1 * std::cos(angle))); + } + points.insert(points.end(), {mm(10, 20), mm(0, 20)}); + const Polygon perimeter(points); + // A modifier covering the whole corner, tails and bridges of the surface line included. + const auto across = surface_extraction(perimeter, rectangle(9.9, 9.9, 10.4, 10.4)); + check_provenance(perimeter, across); + REQUIRE(across.segments.size() == 1); + CHECK(across.segments.front().polyline.points.front() == mm(10.4, 10)); + CHECK(across.segments.front().polyline.points.back() == mm(10, 10.4)); + // Every fillet vertex lies in the covered dead stretch. + for (size_t i = 3; i <= 23; ++i) + CHECK(contains_point(across.segments.front().polyline, perimeter.points[i])); + const auto one_side = surface_extraction(perimeter, rectangle(10.5, 10.1, 11, 10.4)); + check_provenance(perimeter, one_side); + REQUIRE(one_side.segments.size() == 1); + CHECK(one_side.segments.front().polyline.points == Points{mm(11, 10), mm(10.5, 10)}); +} + +TEST_CASE("Surface extraction does not depend on the contour origin or direction", "[PreciseSeam][SegmentExtraction]") +{ + const int origin = GENERATE(0, 1, 2, 3, 4, 5); + const bool reverse = GENERATE(false, true); + CAPTURE(origin, reverse); + Polygon perimeter = l_shape(); + std::rotate(perimeter.points.begin(), perimeter.points.begin() + origin, perimeter.points.end()); + if (reverse) + perimeter.reverse(); + // Across the concave corner, and around the convex corner (20, 0) as one segment through its vertex. + const struct { + Polygon region; + Point first; + Point last; + } cases[] = {{rectangle(10.1, 10.1, 10.4, 10.4), mm(10.4, 10), mm(10, 10.4)}, + {rectangle(19, -1, 21, 1), mm(19, 0), mm(20, 1)}}; + for (const auto &expected : cases) { + const auto result = surface_extraction(perimeter, expected.region); + check_provenance(perimeter, result); + REQUIRE(result.segments.size() == 1); + const Polyline &polyline = result.segments.front().polyline; + CHECK(polyline.points.front() == (reverse ? expected.last : expected.first)); + CHECK(polyline.points.back() == (reverse ? expected.first : expected.last)); + CHECK(polyline.size() == 3); + } +} + +namespace { +// Concave circular wall of `count` vertices per full turn with a vertex at `vertex`, its centre on the air side: +// a hole of the given radius, or a notch of that radius cut into the right side of an 80 mm square. +Polygon concave_wall(double radius, int count, bool hole, Point &vertex) +{ + Polygon polygon; + if (hole) { + for (int i = 0; i < count; ++i) + polygon.points.push_back(mm(radius * std::cos(2. * PI * i / count), radius * std::sin(2. * PI * i / count))); + vertex = mm(radius, 0); + return polygon; + } + polygon.points = {mm(-40, -40), mm(40, -40)}; + // The notch runs clockwise around its centre (40, 0), from angle -90 through 180 degrees to 90. + for (int j = 0; j <= count / 2; ++j) { + const double angle = -0.5 * PI - 2. * PI * j / count; + polygon.points.push_back(mm(40. + radius * std::cos(angle), radius * std::sin(angle))); + } + polygon.points.insert(polygon.points.end(), {mm(40, 40), mm(-40, 40)}); + vertex = mm(40. - radius, 0); + return polygon; +} +} // namespace + +TEST_CASE("A boundary swept across a shallow concave vertex moves the single segment end monotonically", "[PreciseSeam][SegmentExtraction]") +{ + const int count = GENERATE(120, 180, 360, 720); + const double radius = GENERATE(2., 10.); + const bool hole = GENERATE(true, false); + CAPTURE(count, radius, hole); + Point vertex; + const Polygon perimeter = concave_wall(radius, count, hole, vertex); + const PreciseSeam::PreparedPerimeter prepared(perimeter, surface_distance, hole); + const double x = unscale(vertex.x()); + // The wall runs up (+y) through the vertex in both cases; the crossing of the shifted edges lies at y = 0. + // The modifier's top face sweeps from 6 um below it to 6 um above in 0.2 um steps. + double previous = -1.; + for (int step = -30; step <= 30; ++step) { + CAPTURE(step); + const auto regions = PreciseSeam::prepare_modifier_regions({ExPolygon(rectangle(x - 0.5, -0.5, x + 0.5, step * 0.0002))}); + const auto result = PreciseSeam::extract_perimeter_segments(prepared, regions, ModelVolumeType::PRECISE_SEAM_CENTER); + CHECK(result.discarded_fragments == 0); + REQUIRE(result.segments.size() == 1); + // The segment starts at the fixed bottom face, so its length follows the top face along the wall. + const double length = result.segments.front().length; + CHECK(length >= previous - 2.); + previous = length; + if (step == 30) + CHECK(contains_point(result.segments.front().polyline, vertex)); + } +} + +TEST_CASE("Covering an arc and the end of the previous shifted edge ends the segment at the vertex", "[PreciseSeam][SegmentExtraction]") +{ + const Polygon square = rectangle(0, 0, 20, 20); + // The front shifted edge from x = 17 and the arc around (20, 0) up to about -33 degrees. + const auto result = surface_extraction(square, rectangle(17, -0.5, 20.17, -0.11)); + check_provenance(square, result); + REQUIRE(result.segments.size() == 1); + CHECK(result.segments.front().polyline.points == Points{mm(17, 0), mm(20, 0)}); + CHECK(result.segments.front().end.edge_index == 1); + CHECK(result.segments.front().end.parameter == 0.); +} + +TEST_CASE("A vertex point at vertex zero forms or closes a segment across the contour origin", "[PreciseSeam][SegmentExtraction]") +{ + const Polygon square = rectangle(0, 0, 20, 20); + // Only the arc around vertex zero (0, 0), at 225 degrees. + const auto point = surface_extraction(square, rectangle(-0.17, -0.17, -0.11, -0.11)); + REQUIRE(point.segments.size() == 1); + CHECK(point.segments.front().polyline.points == Points{mm(0, 0)}); + CHECK(point.segments.front().begin.edge_index == 0); + CHECK(point.segments.front().edge_indices.empty()); + CHECK_FALSE(point.full_containment); + // The left shifted edge down to the vertex and part of its arc: the vertex point heads the sorted intervals, + // and the tail on the closing edge joins it. + const auto joined = surface_extraction(square, rectangle(-0.5, -0.17, -0.11, 3)); + check_provenance(square, joined); + REQUIRE(joined.segments.size() == 1); + CHECK(joined.segments.front().polyline.points == Points{mm(0, 3), mm(0, 0)}); + CHECK(joined.segments.front().edge_indices == std::vector{3}); + CHECK(joined.segments.front().end.edge_index == 0); + CHECK(joined.segments.front().end.parameter == 0.); +} + +TEST_CASE("A vertex point on a hole does not depend on the contour origin or direction", "[PreciseSeam][SegmentExtraction]") +{ + const int origin = GENERATE(0, 1, 2, 3, 4, 5); + const bool reverse = GENERATE(false, true); + CAPTURE(origin, reverse); + Polygon perimeter = l_shape(); + std::rotate(perimeter.points.begin(), perimeter.points.begin() + origin, perimeter.points.end()); + if (reverse) + perimeter.reverse(); // A hole as the loop gives it, clockwise. + // As a hole, the L has air inside: its reflex vertex (10, 10) is convex from the air, wrapped by an arc + // of radius 0.2 mm into the hole. The modifier covers only that arc, around its point at 225 degrees. + const auto result = surface_extraction(perimeter, rectangle(9.83, 9.83, 9.89, 9.89), true); + REQUIRE(result.valid); + CHECK(result.discarded_fragments == 0); + CHECK_FALSE(result.full_containment); + REQUIRE(result.segments.size() == 1); + const auto &point = result.segments.front(); + CHECK(point.polyline.points == Points{mm(10, 10)}); + CHECK(point.edge_indices.empty()); + // The position is the vertex's outgoing edge, wherever the rotation and reversal moved it. + const size_t vertex = size_t(std::find(perimeter.points.begin(), perimeter.points.end(), mm(10, 10)) - perimeter.points.begin()); + REQUIRE(vertex < perimeter.size()); + CHECK(point.begin.edge_index == vertex); + CHECK(point.begin.parameter == 0.); + CHECK(point.end.edge_index == vertex); + CHECK(point.end.parameter == 0.); + REQUIRE(point.strong_target.has_value()); + CHECK(point.strong_target->point == mm(10, 10)); +} + +TEST_CASE("Leaving part of one arc uncovered is still full containment", "[PreciseSeam][SegmentExtraction]") +{ + const Polygon square = rectangle(0, 0, 20, 20); + // The modifier covers everything but a small hole on the arc around (20, 0), clear of both shifted edges. + ExPolygon region(rectangle(-1, -1, 21, 21)); + region.holes.push_back(rectangle(20.12, -0.16, 20.16, -0.12)); + region.holes.back().reverse(); + const auto result = surface_extraction(square, ExPolygons{region}); + CHECK(result.full_containment); + CHECK(result.discarded_fragments == 0); +} + +TEST_CASE("A reversal of direction is wrapped by a half-circle arc", "[PreciseSeam][SegmentExtraction]") +{ + // A needle from (20, 5) to the tip (26, 5) and back: the surface runs along both sides and round the tip. + const Polygon needle(Points{mm(0, 0), mm(20, 0), mm(20, 5), mm(26, 5), mm(20, 5), mm(20, 20), mm(0, 20)}); + const auto tip = surface_extraction(needle, rectangle(26.1, 4, 27, 6)); + CHECK(tip.discarded_fragments == 0); + REQUIRE(tip.segments.size() == 1); + CHECK(tip.segments.front().polyline.points == Points{mm(26, 5)}); + const auto around = surface_extraction(needle, rectangle(25, 4, 27, 6)); + check_provenance(needle, around); + REQUIRE(around.segments.size() == 1); + CHECK(around.segments.front().polyline.points == Points{mm(25, 5), mm(26, 5), mm(25, 5)}); +} + +TEST_CASE("Nearly collinear vertices whose rounded shifts differ by one unit bind without failures", "[PreciseSeam][SegmentExtraction]") +{ + // The second edge rises (or drops) 30 units over 10 mm: 0.6 units of its 0.2 mm shift point along x, so + // the rounded shifts of the two edges differ by one unit; the vertex is convex or concave. + const coord_t rise = GENERATE(30, -30); + CAPTURE(rise); + const Polygon perimeter(Points{mm(0, 0), mm(10, 0), Point(mm(20, 0).x(), rise), mm(20, 20), mm(0, 20)}); + const auto surface = PreciseSeam::detail::build_surface_line(perimeter, surface_distance, false); + CHECK(surface.shifts[0] != surface.shifts[1]); + const auto result = surface_extraction(perimeter, rectangle(9, -1, 11, -0.1)); + check_provenance(perimeter, result); + REQUIRE(result.segments.size() == 1); + CHECK(result.segments.front().polyline.points.front() == mm(9, 0)); + CHECK(contains_point(result.segments.front().polyline, mm(10, 0))); +} + +TEST_CASE("Covering the centerline between two positions never goes round the whole loop", "[PreciseSeam][SegmentExtraction]") +{ + using PreciseSeam::detail::CenterlinePoint; + const Polygon square = rectangle(0, 0, 20, 20); + std::vector intervals; + // Backwards on one edge: nothing. + PreciseSeam::detail::cover_centerline(square, CenterlinePoint{2, 0.6, mm(12, 20)}, CenterlinePoint{2, 0.3, mm(14, 20)}, intervals); + CHECK(intervals.empty()); + // Forwards on one edge, and across the closing edge to the next one. + PreciseSeam::detail::cover_centerline(square, CenterlinePoint{2, 0.3, mm(14, 20)}, CenterlinePoint{2, 0.6, mm(8, 20)}, intervals); + REQUIRE(intervals.size() == 1); + CHECK(intervals[0].begin == 0.3); + CHECK(intervals[0].end == 0.6); + intervals.clear(); + PreciseSeam::detail::cover_centerline(square, CenterlinePoint{3, 0.5, mm(0, 10)}, CenterlinePoint{1, 0.5, mm(20, 10)}, intervals); + REQUIRE(intervals.size() == 3); + CHECK(intervals[0].edge == 3); + CHECK(intervals[0].last == mm(0, 0)); + CHECK(intervals[1].edge == 0); + CHECK(intervals[2].edge == 1); + CHECK(intervals[2].end == 0.5); +} + +namespace { +// A profile with the given shift in mm at each vertex and no interior samples. +PreciseSeam::ShiftProfile vertex_profile(std::initializer_list shifts) +{ + PreciseSeam::ShiftProfile profile; + for (const double shift : shifts) + profile.vertices.push_back(coord_t(scale_(shift))); + return profile; +} + +bool within_unit(const Point &a, const Point &b) { return (a - b).cast().squaredNorm() <= 2.; } + +bool contains_near(const Polygon &polygon, const Point &point) +{ + return std::any_of(polygon.points.begin(), polygon.points.end(), [&point](const Point &p) { return within_unit(p, point); }); +} +} // namespace + +TEST_CASE("A variable shift moves every vertex by its own distance and keeps the line continuous", "[PreciseSeam][SegmentExtraction]") +{ + // The front edge goes from 0.1 mm below (0, 0) to 0.3 mm below (20, 0); the corner (20, 20) has no shift. + const Polygon square = rectangle(0, 0, 20, 20); + const auto surface = PreciseSeam::detail::build_surface_line(square, vertex_profile({0.1, 0.3, 0., 0.2}), false); + REQUIRE(surface.elements.size() == surface.polygon.size()); + CHECK(contains_near(surface.polygon, mm(0, -0.1))); + CHECK(contains_near(surface.polygon, mm(20, -0.3))); + CHECK(contains_near(surface.polygon, mm(20.3, 0))); + // Edges with different shifts at their ends are not translates; the right edge reaches the corner itself. + CHECK_FALSE(surface.translated[0]); + CHECK(contains_near(surface.polygon, mm(20, 20))); + // Every arc point lies at its vertex's shift from the vertex, so the shifted edges join the arcs without gaps. + const double shifts[] = {0.1, 0.3, 0., 0.2}; + for (size_t i = 0; i < surface.polygon.size(); ++i) { + const auto &element = surface.elements[i]; + if (!element.vertex) + continue; + CAPTURE(i, element.source); + const double distance = (surface.polygon.points[i] - square.points[element.source]).cast().norm(); + CHECK_THAT(distance, Catch::Matchers::WithinAbs(scale_(shifts[element.source]), 1.5)); + } + CHECK(surface.gaps.empty()); + + // A modifier on the front face finds the centerline under its sides, whatever the shift there. + const PreciseSeam::PreparedPerimeter prepared(square, vertex_profile({0.1, 0.3, 0., 0.2}), false); + REQUIRE(prepared.shift == coord_t(scale_(0.3))); + const auto result = PreciseSeam::extract_perimeter_segments(prepared, + PreciseSeam::prepare_modifier_regions({ExPolygon(rectangle(4, -1, 16, -0.25))}), ModelVolumeType::PRECISE_SEAM_CENTER); + check_provenance(square, result); + REQUIRE(result.segments.size() == 1); + // The surface runs y = -0.1 - 0.01 x: below y = -0.25 from x = 15. + CHECK(within_unit(result.segments.front().polyline.points.front(), mm(15, 0))); + CHECK(within_unit(result.segments.front().polyline.points.back(), mm(16, 0))); +} + +TEST_CASE("A concave corner with different shifts on its edges is resolved at their crossing", "[PreciseSeam][SegmentExtraction]") +{ + // Shifts 0.2 at (20, 10), 0.3 at the concave vertex (10, 10) and 0.1 at (10, 20): the shifted edges run + // y = 10.2 + 0.01 (20 - x) and x = 10.3 - 0.02 (y - 10), crossing at about (10.29406, 10.29706). + const Polygon perimeter = l_shape(); + const auto profile = vertex_profile({0.2, 0.2, 0.2, 0.3, 0.1, 0.2}); + const auto surface = PreciseSeam::detail::build_surface_line(perimeter, profile, false); + REQUIRE(surface.gaps.size() == 1); + const Vec2d crossing(10.3 - 0.02 * 0.297 / 0.9998, 10. + 0.297 / 0.9998); + CHECK((unscale(surface.gaps.front().end) - crossing).norm() < 0.001); + + // Covering the crossing covers the dead stretch: one segment through the vertex, its ends under the modifier. + const PreciseSeam::PreparedPerimeter prepared(perimeter, profile, false); + const auto result = PreciseSeam::extract_perimeter_segments(prepared, + PreciseSeam::prepare_modifier_regions({ExPolygon(rectangle(10.25, 10.25, 10.5, 10.5))}), ModelVolumeType::PRECISE_SEAM_CENTER); + check_provenance(perimeter, result); + REQUIRE(result.segments.size() == 1); + const Points &points = result.segments.front().polyline.points; + REQUIRE(points.size() == 3); + CHECK(within_unit(points[0], mm(10.5, 10))); + CHECK(points[1] == mm(10, 10)); + CHECK(within_unit(points[2], mm(10, 10.5))); +} + +TEST_CASE("A shift changing along a long edge splits its element and moves the segment end monotonically", "[PreciseSeam][SegmentExtraction]") +{ + // The front edge keeps 0.2 mm at its vertices and 0.3 mm in its middle: its surface bends at (10, -0.3). + const Polygon square = rectangle(0, 0, 20, 20); + auto profile = vertex_profile({0.2, 0.2, 0.2, 0.2}); + profile.interior.resize(4); + profile.interior[0].emplace_back(0.5, coord_t(scale_(0.3))); + const auto surface = PreciseSeam::detail::build_surface_line(square, profile, false); + std::vector> front; + for (const auto &element : surface.elements) + if (element.source == 0 && !element.vertex) + front.emplace_back(element.begin, element.end); + REQUIRE(front.size() == 2); + const std::pair expected[] = {{0., 0.5}, {0.5, 1.}}; + for (size_t i = 0; i < 2; ++i) { + CHECK_THAT(front[i].first, Catch::Matchers::WithinAbs(expected[i].first, 1e-12)); + CHECK_THAT(front[i].second, Catch::Matchers::WithinAbs(expected[i].second, 1e-12)); + } + CHECK(contains_near(surface.polygon, mm(10, -0.3))); + // The other edges keep a constant shift and stay translates. + CHECK(surface.translated[1]); + + // A side of the modifier swept across the bend: the segment end follows it along the centerline. + const PreciseSeam::PreparedPerimeter prepared(square, profile, false); + double previous = -1.; + for (int step = -20; step <= 20; ++step) { + CAPTURE(step); + const double x = 10. + step * 0.05; + const auto result = PreciseSeam::extract_perimeter_segments(prepared, + PreciseSeam::prepare_modifier_regions({ExPolygon(rectangle(2, -1, x, -0.1))}), ModelVolumeType::PRECISE_SEAM_CENTER); + REQUIRE(result.segments.size() == 1); + const Point &end = result.segments.front().polyline.points.back(); + CHECK(within_unit(end, mm(x, 0))); + CHECK(double(end.x()) >= previous); + previous = double(end.x()); + } +} + +TEST_CASE("A profile within the snapping radius keeps the centerline", "[PreciseSeam][SegmentExtraction]") +{ + const Polygon square = rectangle(0, 0, 20, 20); + PreciseSeam::ShiftProfile profile; + profile.vertices = {1000, 0, 500, 1000}; + const PreciseSeam::PreparedPerimeter prepared(square, profile, false); + CHECK(prepared.shift == 0); + CHECK(prepared.profile.empty()); + profile.vertices[1] = 1001; + CHECK(PreciseSeam::PreparedPerimeter(square, profile, false).shift == 1001); +} + +namespace { +// Measurement of a 0.4 mm line without compensation, accepting depths from 0.15 to 0.6 mm. +PreciseSeam::ShiftMeasurement measurement(const AABBTreeLines::LinesDistancer &outline, double compensation = 0., + double outline_compensation = 0.) +{ + return {outline, 0.4, compensation, outline_compensation, 0.15, 0.6}; +} + +coord_t shift_mm(double distance) { return coord_t(std::lround(scale_(distance))) - 5000; } +} // namespace + +TEST_CASE("A centerline at its nominal depth keeps the constant shift", "[PreciseSeam][SegmentExtraction]") +{ + const Polygon square = rectangle(0, 0, 20, 20); + const AABBTreeLines::LinesDistancer nominal(to_lines(ExPolygon(rectangle(-0.2, -0.2, 20.2, 20.2)))); + CHECK(PreciseSeam::measure_shift_profile(square, false, measurement(nominal)).empty()); + // Every depth outside the accepted range takes the nominal shift as well: the outline is not this wall's own. + const AABBTreeLines::LinesDistancer far(to_lines(ExPolygon(rectangle(-5, -5, 25, 25)))); + CHECK(PreciseSeam::measure_shift_profile(square, false, measurement(far)).empty()); + // XY compensation that the outline does not contain is in the nominal depth: still the constant shift. + const AABBTreeLines::LinesDistancer uncompensated(to_lines(ExPolygon(rectangle(-0.3, -0.3, 20.3, 20.3)))); + CHECK(PreciseSeam::measure_shift_profile(square, false, measurement(uncompensated, -0.1, 0.)).empty()); + // At the inner corner of an L the nearest outline point is the corner, about 0.28 mm away; the depth along the + // normals is still 0.2 mm. + const Polygons l_outline = offset(l_shape(), float(scale_(0.2)), jtMiter, 3.); + REQUIRE(l_outline.size() == 1); + const AABBTreeLines::LinesDistancer l_nominal(to_lines(ExPolygon(l_outline.front()))); + CHECK(PreciseSeam::measure_shift_profile(l_shape(), false, measurement(l_nominal)).empty()); + // The same for the corners of a hole, all of them inner corners seen from the material. + ExPolygon around_hole(rectangle(-10, -10, 30, 30)); + around_hole.holes.push_back(rectangle(0.2, 0.2, 19.8, 19.8)); + around_hole.holes.back().reverse(); + const AABBTreeLines::LinesDistancer hole_nominal(to_lines(around_hole)); + CHECK(PreciseSeam::measure_shift_profile(square, true, measurement(hole_nominal)).empty()); +} + +TEST_CASE("A centerline deeper than nominal takes its measured shift", "[PreciseSeam][SegmentExtraction]") +{ + const Polygon square = rectangle(0, 0, 20, 20); + // Elephant foot compensation of 0.15 mm all round: the outline lies 0.35 mm from the centerline. + const AABBTreeLines::LinesDistancer foot(to_lines(ExPolygon(rectangle(-0.35, -0.35, 20.35, 20.35)))); + const auto profile = PreciseSeam::measure_shift_profile(square, false, measurement(foot)); + REQUIRE(profile.vertices.size() == 4); + for (const coord_t value : profile.vertices) + CHECK(std::abs(value - shift_mm(0.35)) <= 1); + // Constant along every edge: no interior samples. + CHECK(profile.interior.empty()); + // A compensation the outline contains is subtracted; one it does not contain is not. + const auto compensated = PreciseSeam::measure_shift_profile(square, false, measurement(foot, 0.1, 0.1)); + REQUIRE(compensated.vertices.size() == 4); + CHECK(std::abs(compensated.vertices.front() - shift_mm(0.25)) <= 1); + const auto excluded = PreciseSeam::measure_shift_profile(square, false, measurement(foot, -0.1, 0.)); + REQUIRE(excluded.vertices.size() == 4); + CHECK(std::abs(excluded.vertices.front() - shift_mm(0.35)) <= 1); + // A depth within the margin would put the surface on the body side: zero, not negative. + const AABBTreeLines::LinesDistancer shallow(to_lines(ExPolygon(rectangle(-0.003, -0.003, 20.003, 20.003)))); + const auto clamped = PreciseSeam::measure_shift_profile(square, false, {shallow, 0.4, 0., 0., 0., 0.6}); + REQUIRE(clamped.vertices.size() == 4); + CHECK(clamped.vertices.front() == 0); +} + +TEST_CASE("A shift changing in the middle of a long edge is sampled along it", "[PreciseSeam][SegmentExtraction]") +{ + const Polygon square = rectangle(0, 0, 20, 20); + // The outline steps out to 0.3 mm below the front edge between x = 8 and 12 mm. + const Polygon stepped(Points{mm(-0.2, -0.2), mm(8, -0.2), mm(8, -0.3), mm(12, -0.3), mm(12, -0.2), mm(20.2, -0.2), + mm(20.2, 20.2), mm(-0.2, 20.2)}); + const AABBTreeLines::LinesDistancer outline(to_lines(ExPolygon(stepped))); + const auto profile = PreciseSeam::measure_shift_profile(square, false, measurement(outline)); + REQUIRE(profile.vertices.size() == 4); + CHECK(std::abs(profile.vertices.front() - shift_mm(0.2)) <= 1); + REQUIRE(profile.interior.size() == 4); + // Every 0.5 mm along the 20 mm edge; only the front edge changes. Next to the step its corner is nearer. + REQUIRE(profile.interior[0].size() == 39); + for (const auto &[parameter, value] : profile.interior[0]) { + CAPTURE(parameter); + const double x = 20. * parameter; + CHECK(std::abs(value - shift_mm(x > 8.2 && x < 11.8 ? 0.3 : 0.2)) <= 1); + } + for (size_t edge = 1; edge < 4; ++edge) + CHECK(profile.interior[edge].empty()); +} + +namespace { +// The edges of a noisy loop as Precise Seam indexes them. +AABBTreeLines::LinesDistancer noisy_lines(const Polygon &noisy) { return AABBTreeLines::LinesDistancer(noisy.lines()); } + +// A point within a unit of `expected`. +void check_point(const Point &point, const Point &expected) +{ + CAPTURE(point.x(), point.y(), expected.x(), expected.y()); + CHECK((point - expected).cast().norm() <= 1.5); +} +} // namespace + +TEST_CASE("A point moves onto the noisy edge that the line to its surface point crosses", "[PreciseSeam][Fuzzy]") +{ + // Smooth edge along y = 0; its surface point lies 0.195 mm towards air at y < 0. The noisy edge from (9, -0.1) to + // (11, 0.1) crosses x = 10 at (10, 0), halfway along. + const Polygon noisy(Points{mm(-0.1, -0.1), mm(9, -0.1), mm(11, 0.1), mm(20.1, -0.1), mm(20.1, 20.1), mm(-0.1, 20.1)}); + const auto moved = PreciseSeam::detail::transfer_point(noisy_lines(noisy), mm(10, 0), mm(10, -0.195), scale_(0.4)); + CHECK(moved.outcome == PreciseSeam::detail::TransferOutcome::Exact); + CHECK(moved.position.edge == 1); + CHECK_THAT(moved.position.parameter, Catch::Matchers::WithinAbs(0.5, 1e-9)); + check_point(moved.position.point, mm(10, 0)); +} + +TEST_CASE("Of several crossings the one nearest to the point is taken", "[PreciseSeam][Fuzzy]") +{ + // A fold of the noisy loop: x = 10 crosses it at y = 0.3, 0.175 and -0.05. + const Polygon noisy(Points{mm(0, 0.3), mm(11, 0.3), mm(9, 0.05), mm(11, -0.15), mm(20, -0.15), mm(20, 20), mm(0, 20)}); + const auto moved = PreciseSeam::detail::transfer_point(noisy_lines(noisy), mm(10, 0), mm(10, -0.195), scale_(0.4)); + CHECK(moved.outcome == PreciseSeam::detail::TransferOutcome::Exact); + CHECK(moved.position.edge == 2); + check_point(moved.position.point, mm(10, -0.05)); +} + +TEST_CASE("At an acute corner the point stays on its own side of the noisy loop", "[PreciseSeam][Fuzzy]") +{ + // A 20 degree wedge from the origin: one side along y = 0, the other along (cos 20, sin 20). The noisy loop lies + // 0.1 mm outside both. Across the first side at x = 1 the line also crosses the other side's noise, 0.47 mm away. + const double angle = 20. * PI / 180.; + const Vec2d along(std::cos(angle), std::sin(angle)); + const Vec2d outward(-std::sin(angle), std::cos(angle)); + const auto other = [&](double distance) { + const Vec2d point = distance * along + 0.1 * outward; + return mm(point.x(), point.y()); + }; + const Polygon noisy(Points{mm(-0.29, -0.1), mm(0.5, -0.1), mm(1.5, -0.1), mm(5, -0.1), other(5), other(1.5), other(0.5)}); + const auto moved = PreciseSeam::detail::transfer_point(noisy_lines(noisy), mm(1, 0), mm(1, -0.195), scale_(0.6)); + CHECK(moved.outcome == PreciseSeam::detail::TransferOutcome::Exact); + CHECK(moved.position.edge == 1); + check_point(moved.position.point, mm(1, -0.1)); +} + +TEST_CASE("A transfer is exact, approximate or fails", "[PreciseSeam][Fuzzy]") +{ + using Outcome = PreciseSeam::detail::TransferOutcome; + // The noisy edge near the point runs from (8, -0.1) to (9.9, -0.1): x = 10 misses it. + const Polygon noisy(Points{mm(0, -0.1), mm(8, -0.1), mm(9.9, -0.1), mm(9.9, 20), mm(0, 20)}); + const auto lines = noisy_lines(noisy); + // No crossing within the window: the nearest point of the loop, (9.9, 0) on the edge up from the corner. + const auto missed = PreciseSeam::detail::transfer_point(lines, mm(10, 0), mm(10, -0.195), scale_(0.4)); + CHECK(missed.outcome == Outcome::Approximate); + CHECK(missed.position.edge == 2); + check_point(missed.position.point, mm(9.9, 0)); + // A pair that coincides, as on the centerline path, has no line: the same nearest point. + const auto no_line = PreciseSeam::detail::transfer_point(lines, mm(10, 0), mm(10, 0), scale_(0.4)); + CHECK(no_line.outcome == Outcome::Approximate); + CHECK(no_line.position.edge == 2); + check_point(no_line.position.point, mm(9.9, 0)); + // Nothing within the window. + CHECK(PreciseSeam::detail::transfer_point(lines, mm(10, 0), mm(10, -0.195), scale_(0.05)).outcome == Outcome::Failed); + // An edge along the line gives its point nearest to the point: (9.9, 0) itself for a line along x = 9.9. + const auto collinear = PreciseSeam::detail::transfer_point(lines, mm(9.9, 0.05), mm(9.9, 0.2), scale_(0.4)); + CHECK(collinear.outcome == Outcome::Exact); + CHECK(collinear.position.edge == 2); + check_point(collinear.position.point, mm(9.9, 0.05)); +} + +namespace { +// Fuzzy skin settings of one region: classic noise, displacement mode, thickness and point distance in mm. +FuzzySkinConfig fuzzy_region(FuzzySkinType type, double thickness, double point_distance, int layer_id = 1, + bool first_layer = false) +{ + return {type, scaled(thickness), scaled(point_distance), first_layer, NoiseType::Classic, 1., 1, + 0.5, FuzzySkinMode::Displacement, 1, 0., 1, layer_id}; +} + +// The window of contours or holes: the sum of the noises' amplitudes, the largest point distance and 1 um rounding. +double window_of(const std::vector ®ions, bool contour) +{ + return PreciseSeam::detail::fuzzy_skin_window(regions, 0.2, false, contour); +} +} // namespace + +TEST_CASE("The fuzzy skin window counts only the regions that texture the kind of loop", "[PreciseSeam][Fuzzy]") +{ + using Catch::Matchers::WithinAbs; + // An outer-walls region texturing contours and a holes region with a thicker noise: each kind sees its own. + const std::vector split{fuzzy_region(FuzzySkinType::External, 0.2, 0.3), + fuzzy_region(FuzzySkinType::Hole, 0.8, 0.5)}; + CHECK_THAT(window_of(split, true), WithinAbs(0.2 + 0.3 + 0.001, 1e-9)); + CHECK_THAT(window_of(split, false), WithinAbs(0.8 + 0.5 + 0.001, 1e-9)); + // A region texturing all external walls adds its noise to the holes region's on holes only. + const std::vector all{fuzzy_region(FuzzySkinType::All, 0.2, 0.3), + fuzzy_region(FuzzySkinType::Hole, 0.6, 0.5)}; + CHECK_THAT(window_of(all, true), WithinAbs(0.2 + 0.3 + 0.001, 1e-9)); + CHECK_THAT(window_of(all, false), WithinAbs(0.2 + 0.6 + 0.5 + 0.001, 1e-9)); + // Regions differing only in which walls they texture make one noise. + const std::vector same{fuzzy_region(FuzzySkinType::External, 0.3, 0.4), + fuzzy_region(FuzzySkinType::All, 0.3, 0.4)}; + CHECK_THAT(window_of(same, true), WithinAbs(0.3 + 0.4 + 0.001, 1e-9)); + CHECK_THAT(window_of(same, false), WithinAbs(0.3 + 0.4 + 0.001, 1e-9)); + // No noise: fuzzy skin off or disabled, or the first layer without fuzzy skin there. + CHECK(window_of({fuzzy_region(FuzzySkinType::None, 0.3, 0.4), fuzzy_region(FuzzySkinType::Disabled_fuzzy, 0.3, 0.4)}, + true) == 0.); + CHECK(window_of({fuzzy_region(FuzzySkinType::External, 0.3, 0.4, 0)}, true) == 0.); + CHECK_THAT(window_of({fuzzy_region(FuzzySkinType::External, 0.3, 0.4, 0, true)}, true), + WithinAbs(0.3 + 0.4 + 0.001, 1e-9)); +} + +TEST_CASE("Segments keep the surface points their ends were carried from", "[PreciseSeam][Fuzzy]") +{ + const auto mode = GENERATE(ModelVolumeType::PRECISE_SEAM_LEFT, ModelVolumeType::PRECISE_SEAM_CENTER, + ModelVolumeType::PRECISE_SEAM_RIGHT); + const Polygon square = rectangle(0, 0, 20, 20); + const auto extracted = surface_extraction(square, rectangle(4, -1, 6, 0.1), false, mode); + REQUIRE(extracted.segments.size() == 1); + const auto &segment = extracted.segments.front(); + CHECK(segment.polyline.points.front() == mm(4, 0)); + CHECK(segment.polyline.points.back() == mm(6, 0)); + CHECK(segment.surface_first == Point(mm(4, 0).x(), -surface_distance)); + CHECK(segment.surface_last == Point(mm(6, 0).x(), -surface_distance)); + REQUIRE(segment.strong_target.has_value()); + // Center's pair is worked out only for a point carried onto a noisy loop. + if (mode == ModelVolumeType::PRECISE_SEAM_CENTER) + CHECK_FALSE(segment.strong_target->surface.has_value()); + else + CHECK(segment.strong_target->surface == (mode == ModelVolumeType::PRECISE_SEAM_LEFT ? segment.surface_first : segment.surface_last)); + // On the centerline path the ends are their own pairs. + const auto centerline = surface_extraction(square, rectangle(4, -1, 6, 0.1), false, mode, 0); + REQUIRE(centerline.segments.size() == 1); + CHECK(centerline.segments.front().surface_first == mm(4, 0)); + CHECK(centerline.segments.front().surface_last == mm(6, 0)); +} + +TEST_CASE("A piece of a convex corner's arc keeps both its ends", "[PreciseSeam][Fuzzy]") +{ + const Polygon square = rectangle(0, 0, 20, 20); + // Around the arc point at -45 degrees from (20, 0): one vertex point, two different surface points on the arc. + const auto arc = surface_extraction(square, rectangle(20.11, -0.17, 20.17, -0.11), false, ModelVolumeType::PRECISE_SEAM_ENFORCED); + REQUIRE(arc.segments.size() == 1); + const auto &segment = arc.segments.front(); + CHECK(segment.polyline.points == Points{mm(20, 0)}); + CHECK(segment.surface_first != segment.surface_last); + // Both on the arc of radius 0.2 mm around the vertex, within the sagitta of its chords; the first one nearer the + // bottom edge, where the arc starts. + for (const Point &point : {segment.surface_first, segment.surface_last}) + CHECK(std::abs((point - mm(20, 0)).cast().norm() - double(surface_distance)) <= 41.); + CHECK(segment.surface_first.y() < segment.surface_last.y()); +} + +TEST_CASE("Center pairs with the middle of its edge, arc or concave crossing when carried", "[PreciseSeam][Fuzzy]") +{ + // Any usable noisy loop: only the pairs worked out for carrying are checked here. + const auto center = [](const Polygon &perimeter, const Polygon ®ion) { + PreciseSeam::PreparedPerimeter prepared(perimeter, surface_distance, false); + prepared.set_target(perimeter, coord_t(scale_(0.5))); + auto extracted = PreciseSeam::extract_perimeter_segments(prepared, PreciseSeam::prepare_modifier_regions({ExPolygon(region)}), + ModelVolumeType::PRECISE_SEAM_CENTER); + REQUIRE(extracted.segments.size() == 1); + REQUIRE(extracted.segments.front().strong_target.has_value()); + REQUIRE(extracted.segments.front().strong_target->surface.has_value()); + return *extracted.segments.front().strong_target; + }; + const Polygon square = rectangle(0, 0, 20, 20); + const double half = double(surface_distance) / std::sqrt(2.); + // Inside an edge: the point of the shifted edge at the same parameter. + const auto edge = center(square, rectangle(4, -1, 6, 0.1)); + CHECK(edge.point == mm(5, 0)); + CHECK(*edge.surface == Point(mm(5, 0).x(), -surface_distance)); + // At a vertex the segment passes: the middle of the whole arc, at -45 degrees. + const auto vertex = center(square, rectangle(19, -1, 21, 1)); + CHECK(vertex.point == mm(20, 0)); + CHECK((*vertex.surface - Point(mm(20, 0).x() + coord_t(half), -coord_t(half))).cast().norm() <= 41.); + // A zero-length segment: the middle of its piece of arc, about -45 degrees too for this symmetric piece. + const auto piece = center(square, rectangle(20.11, -0.17, 20.17, -0.11)); + CHECK(piece.point == mm(20, 0)); + CHECK((*piece.surface - Point(mm(20, 0).x() + coord_t(half), -coord_t(half))).cast().norm() <= 41.); + // In the dead stretch of the concave corner (10, 10) of the L, at its vertex and beside it: the crossing (10.2, 10.2). + const auto at_corner = center(l_shape(), rectangle(10.1, 10.1, 10.4, 10.4)); + CHECK(at_corner.point == mm(10, 10)); + check_point(*at_corner.surface, mm(10.2, 10.2)); + const auto beside = center(l_shape(), rectangle(10.1, 10.1, 10.6, 10.4)); + check_point(beside.point, mm(10.1, 10)); + check_point(*beside.surface, mm(10.2, 10.2)); +} + +TEST_CASE("Center at a vertex between collinear edges pairs with the point where their shifted edges meet", "[PreciseSeam][Fuzzy]") +{ + // The smooth loop has the vertex (10, 0) between two collinear edges, without an arc; Center across x = 9..11 mm + // falls on it. Turned, the vertex is vertex zero. With a shift profile of 0.3 mm along the front and 0.2 mm on + // the other sides, the surface lies 0.3 mm below it. + const auto [turned, profiled] = GENERATE(table({{false, false}, {true, false}, {false, true}})); + CAPTURE(turned, profiled); + Points points{mm(0, 0), mm(10, 0), mm(20, 0), mm(20, 20), mm(0, 20)}; + if (turned) + std::rotate(points.begin(), points.begin() + 1, points.end()); + const Polygon smooth(points); + // The noisy edge near the vertex runs from (9, -0.1) to (11, 0.3) mm; the rest of the noisy loop lies over 1 mm + // away. The line x = 10 mm crosses that edge halfway, at (10, 0.1). + const Polygon noisy(Points{mm(-0.1, -0.1), mm(9, -0.1), mm(11, 0.3), mm(20.1, -0.1), mm(20.1, 20.1), mm(-0.1, 20.1)}); + PreciseSeam::ShiftProfile profile; + profile.vertices = {coord_t(scale_(0.3)), coord_t(scale_(0.3)), coord_t(scale_(0.3)), surface_distance, surface_distance}; + const auto prepared = profiled ? std::make_unique(smooth, profile, false) : + std::make_unique(smooth, surface_distance, false); + prepared->set_target(noisy, coord_t(scale_(0.5))); + REQUIRE(prepared->valid); + const auto extracted = PreciseSeam::extract_perimeter_segments( + *prepared, PreciseSeam::prepare_modifier_regions({ExPolygon(rectangle(9, -1, 11, 0.1))}), ModelVolumeType::PRECISE_SEAM_CENTER); + REQUIRE(extracted.segments.size() == 1); + REQUIRE(extracted.segments.front().strong_target.has_value()); + const auto &target = *extracted.segments.front().strong_target; + CHECK(target.point == mm(10, 0)); + REQUIRE(target.surface.has_value()); + check_point(*target.surface, mm(10, profiled ? -0.3 : -0.2)); + const auto moved = PreciseSeam::detail::transfer_point(noisy_lines(noisy), target.point, *target.surface, scale_(0.5)); + CHECK(moved.outcome == PreciseSeam::detail::TransferOutcome::Exact); + check_point(moved.position.point, mm(10, 0.1)); +} + +TEST_CASE("Separate pieces of one arc make one vertex point from the first piece's start to the last one's end", "[PreciseSeam][Fuzzy]") +{ + const Polygon square = rectangle(0, 0, 20, 20); + PreciseSeam::PreparedPerimeter prepared(square, surface_distance, false); + prepared.set_target(square, coord_t(scale_(0.5))); + // Two boxes on the arc of radius 0.2 mm around the corner (20, 0), which runs from -90 to 0 degrees: the first + // covers it from x = 20.0384 mm (about -79 degrees) to about -61 degrees, the second from about -29 degrees to + // y = -0.0384 mm (about -11 degrees). Neither touches the shifted edges. + const ExPolygons regions{ExPolygon(rectangle(20.0384, -0.2179, 20.0984, -0.1579)), + ExPolygon(rectangle(20.1579, -0.0984, 20.2179, -0.0384))}; + const auto extracted = PreciseSeam::extract_perimeter_segments(prepared, PreciseSeam::prepare_modifier_regions(regions), + ModelVolumeType::PRECISE_SEAM_ENFORCED); + REQUIRE(extracted.segments.size() == 1); + const auto &segment = extracted.segments.front(); + CHECK(segment.polyline.points == Points{mm(20, 0)}); + CAPTURE(segment.surface_first.x(), segment.surface_first.y(), segment.surface_last.x(), segment.surface_last.y()); + CHECK(std::abs(segment.surface_first.x() - mm(20.0384, 0).x()) <= 2); + CHECK(std::abs(segment.surface_last.y() - mm(0, -0.0384).y()) <= 2); + // On the arc, within the sagitta of its chords. + for (const Point &point : {segment.surface_first, segment.surface_last}) + CHECK(std::abs((point - mm(20, 0)).cast().norm() - double(surface_distance)) <= 41.); +} + +TEST_CASE("A segment across the start of the loop keeps the surface points of its outer ends", "[PreciseSeam][Fuzzy]") +{ + // The square starts at its corner (0, 0); the zone runs from y = 1 mm on the left side through the corner to + // x = 1 mm on the front, whose surface points lie 0.2 mm outside. + const Polygon square = rectangle(0, 0, 20, 20); + REQUIRE(square[0] == mm(0, 0)); + PreciseSeam::PreparedPerimeter prepared(square, surface_distance, false); + prepared.set_target(square, coord_t(scale_(0.5))); + const auto extracted = PreciseSeam::extract_perimeter_segments( + prepared, PreciseSeam::prepare_modifier_regions({ExPolygon(rectangle(-1, -1, 1, 1))}), ModelVolumeType::PRECISE_SEAM_ENFORCED); + REQUIRE(extracted.segments.size() == 1); + const auto &segment = extracted.segments.front(); + check_point(segment.polyline.points.front(), mm(0, 1)); + check_point(segment.polyline.points.back(), mm(1, 0)); + check_point(segment.surface_first, mm(-0.2, 1)); + check_point(segment.surface_last, mm(1, -0.2)); +} + +TEST_CASE("A loop keeps its untextured centerline when copied, reversed or turned", "[PreciseSeam][Fuzzy]") +{ + const Polygon square = rectangle(0, 0, 20, 20); + ExtrusionPath path(erExternalPerimeter); + path.polyline = Polyline3(square.split_at_first_point()); + ExtrusionLoop loop(std::move(path)); + const auto untextured = std::make_shared(square); + loop.untextured = untextured; + const ExtrusionLoop copy = loop; + CHECK(copy.untextured == untextured); + const std::unique_ptr clone(loop.clone()); + CHECK(static_cast(clone.get())->untextured == untextured); + loop.reverse(); + CHECK(loop.untextured == untextured); + loop.make_counter_clockwise(); + CHECK(loop.untextured == untextured); + CHECK(loop.split_at_vertex(mm(20, 0))); + CHECK(loop.untextured == untextured); + // The geometry it holds is never changed through the loop. + CHECK(untextured->points == square.points); +} diff --git a/tests/libslic3r/test_preset_bundle_loading.cpp b/tests/libslic3r/test_preset_bundle_loading.cpp index e9df05f1ec..bd53e876bd 100644 --- a/tests/libslic3r/test_preset_bundle_loading.cpp +++ b/tests/libslic3r/test_preset_bundle_loading.cpp @@ -392,6 +392,18 @@ TEST_CASE("Printer extruder count tolerates missing nozzle diameter", "[Preset][ CHECK(bundle.get_printer_extruder_count() == 2); } +TEST_CASE("A preset bundle builds its full config before its presets load", "[Preset][Bundle][Regression]") +{ + PresetBundle bundle; + REQUIRE(bundle.filament_presets.empty()); + bundle.filaments.get_edited_preset().config.set_key_value("filament_type", new ConfigOptionStrings({ "PETG" })); + + const DynamicPrintConfig config = bundle.full_config(); + + REQUIRE(config.has("filament_type")); + CHECK(config.option("filament_type")->values == std::vector{ "PETG" }); +} + // A per-variant key that no profile in the chain sets keeps the length of the one-nozzle root. The // inherited printer must still have a value for every variant in its own variant list. TEST_CASE("An inherited printer's per-variant values cover every variant it lists", "[Preset][Bundle][Regression]") @@ -1265,6 +1277,41 @@ TEST_CASE("A project filament storing one value for a per-variant key applies it check_double_vector(loaded->config.option("pressure_advance")->values, {0.016, 0.016}); } +TEST_CASE("A project's edited filament keeps the preset's compatible printers and processes", "[Preset][Bundle][Regression]") +{ + enum class Load { FirstSlotSelected, FirstSlotParentSelected, LaterSlotEmbedded, LaterSlotCopied }; + const Load load = GENERATE(Load::FirstSlotSelected, Load::FirstSlotParentSelected, Load::LaterSlotEmbedded, Load::LaterSlotCopied); + CAPTURE(load); + const bool first_slot = load == Load::FirstSlotSelected || load == Load::FirstSlotParentSelected; + // For FirstSlotParentSelected only the parent the project inherits from is loaded, so it is the one selected. + const std::string preset_name = load == Load::FirstSlotParentSelected ? "Parent PLA" : "My PLA"; + PresetCollection filaments(Preset::TYPE_FILAMENT, Preset::filament_options(), + static_cast(FullPrintConfig::defaults())); + Preset &user = add_inmemory_preset(filaments, preset_name); + user.is_project_embedded = load == Load::LaterSlotEmbedded; + user.config.option("compatible_printers", true)->values = {"My Printer"}; + user.config.option("compatible_prints", true)->values = {"My Process"}; + user.config.option("nozzle_temperature", true)->values = {210}; + + DynamicPrintConfig project(user.config); + project.option("compatible_printers")->values.clear(); + project.option("compatible_prints")->values.clear(); + project.option("nozzle_temperature")->values = {225}; + if (load == Load::FirstSlotParentSelected) + project.option(BBL_JSON_KEY_INHERITS)->value = preset_name; + + const Preset *loaded = filaments.load_external_preset("test.3mf", "test.3mf", "My PLA", project, {}, + first_slot ? PresetCollection::LoadAndSelect::Always : + PresetCollection::LoadAndSelect::OnlyIfModified).first; + REQUIRE(loaded != nullptr); + + const Preset &result = first_slot ? filaments.get_edited_preset() : *loaded; + REQUIRE(result.name == (load == Load::LaterSlotCopied ? "My PLA(test.3mf)" : preset_name)); + CHECK(result.config.option("nozzle_temperature")->values == std::vector{225}); + CHECK(result.config.option("compatible_printers")->values == std::vector{"My Printer"}); + CHECK(result.config.option("compatible_prints")->values == std::vector{"My Process"}); +} + TEST_CASE("Repeated loads of a user preset directory produce the same presets", "[Preset][Bundle]") { ScopedTemporaryDir temp_dir; @@ -5245,7 +5292,7 @@ TEST_CASE("Published 3MF relocates the receiver's mixed filament past the incomi REQUIRE(colour.size() == 5); CHECK(colour[4] == "#800080"); CHECK(colour[2] == "#FFFFFF"); - CHECK(pub.mixed_slot_relocations.at(2) == 4); + CHECK(pub.mixed_slot_relocations.empty()); bool relocated_reported = false; for (const std::string &message : pub.material_replacements) if (message.find("slot 2 -> slot 4") != std::string::npos && @@ -5293,6 +5340,11 @@ TEST_CASE("Published 3MF relocates the receiver's mixed filament past the incomi pub.published = true; pub.material_keys = { make_real_entry(0, "#FF0000"), make_real_entry(1, "#000000"), make_real_entry(2, "#0000FF"), mix }; + auto &process = bundle.prints.get_edited_preset().config; + process.set("inner_wall_filament_id", 3); + config.set("outer_wall_filament_id", 4); + config.set("bottom_surface_filament_id", 3); + pub.published_keys = {"outer_wall_filament_id", "bottom_surface_filament_id"}; Preset::normalize(config); bundle.load_config_model("test.3mf", std::move(config), Semver(), &pub); @@ -5308,8 +5360,10 @@ TEST_CASE("Published 3MF relocates the receiver's mixed filament past the incomi REQUIRE(components.size() == 5); CHECK(components[3] == "1,2"); CHECK(components[4] == "1,3"); - REQUIRE(pub.mixed_slot_relocations.size() == 2); - CHECK(pub.mixed_slot_relocations.at(2) == 3); + CHECK(process.opt_int("inner_wall_filament_id") == 4); // Receiver's mix + CHECK(process.opt_int("outer_wall_filament_id") == 5); // Author's mix + CHECK(process.opt_int("bottom_surface_filament_id") == 3); // Author's physical filament + REQUIRE(pub.mixed_slot_relocations.size() == 1); CHECK(pub.mixed_slot_relocations.at(3) == 4); CHECK(pub.skipped_keys.empty()); } @@ -5371,9 +5425,7 @@ TEST_CASE("Published 3MF rebalances several receiver mixed slots past the physic REQUIRE(components.size() == 5); CHECK(components[3] == "1,2"); CHECK(components[4] == "1,3"); - REQUIRE(pub.mixed_slot_relocations.size() == 2); - CHECK(pub.mixed_slot_relocations.at(1) == 3); - CHECK(pub.mixed_slot_relocations.at(2) == 4); + CHECK(pub.mixed_slot_relocations.empty()); CHECK(pub.skipped_keys.empty()); } @@ -6291,8 +6343,24 @@ TEST_CASE("remap_model_filament_slots repoints extruder configs and color painti // 1-based slot 4 lands on 5 and does NOT continue to 7. Model chained = make_model(); chained.objects[0]->volumes.front()->config.set_key_value("extruder", new ConfigOptionInt(4)); + auto &ranges = chained.objects[0]->layer_config_ranges; + auto &first_mix = ranges[{0., 2.}]; + auto &second_mix = ranges[{2., 4.}]; + auto &physical = ranges[{4., 6.}]; + auto &use_default = ranges[{6., 8.}]; + auto &height_only = ranges[{8., 10.}]; + first_mix.set("extruder", 4); + second_mix.set("extruder", 5); + physical.set("extruder", 2); + use_default.set("extruder", 0); + height_only.set("layer_height", 0.2); Slic3r::remap_model_filament_slots(chained, std::map{{3, 4}, {4, 6}}); CHECK(chained.objects[0]->volumes.front()->config.extruder() == 5); + CHECK(first_mix.extruder() == 5); + CHECK(second_mix.extruder() == 7); + CHECK(physical.extruder() == 2); + CHECK(use_default.extruder() == 0); + CHECK_FALSE(height_only.has("extruder")); // The chained model's paint follows its own single-step mapping: painted state 5 -> 7, // and nothing lands back on 5. CHECK(TriangleSelector::has_facets(chained.objects[0]->volumes.front()->mmu_segmentation_facets.get_data(), diff --git a/tests/slic3rutils/CMakeLists.txt b/tests/slic3rutils/CMakeLists.txt index bea0788a3e..1203a3a2d2 100644 --- a/tests/slic3rutils/CMakeLists.txt +++ b/tests/slic3rutils/CMakeLists.txt @@ -12,6 +12,7 @@ add_executable(${_TEST_NAME}_tests test_dev_mapping.cpp test_device_access.cpp test_moonraker_printer_agent.cpp + test_moonraker_filament_sources.cpp test_snapmaker_filament_match.cpp test_network_discovery.cpp test_filament_bitmap_utils.cpp diff --git a/tests/slic3rutils/test_device_manager_integration.cpp b/tests/slic3rutils/test_device_manager_integration.cpp index 8aa187480f..0df753ec07 100644 --- a/tests/slic3rutils/test_device_manager_integration.cpp +++ b/tests/slic3rutils/test_device_manager_integration.cpp @@ -22,6 +22,7 @@ #include #include #include +#include "catch2/catch_message.hpp" #include "slic3r/Utils/IPrinterAgent.hpp" #include "slic3r/Utils/CloudProvider.hpp" #include @@ -212,6 +213,99 @@ TEST_CASE("Device manager filters and rehomes devices by printer-agent ownership CHECK(manager.get_my_machine_list("integration-agent-b").count(machine.dev_id) == 1); } +TEST_CASE("A non-Bambu device without a model is not given Bambu's C11 model", "[DeviceManager][integration]") +{ + const std::string agent_id = GENERATE(std::string(MOONRAKER_PRINTER_AGENT_ID), + std::string(QIDI_PRINTER_AGENT_ID), + std::string(SNAPMAKER_PRINTER_AGENT_ID), + std::string(CREALITYPRINT_PRINTER_AGENT_ID), + std::string("integration-agent")); + CAPTURE(agent_id); + + ScopedAppConfig app_config; + auto agent = std::make_shared(agent_id); + NetworkAgent network(nullptr, agent); + DeviceManager manager(&network, false, &app_config.config); + + BBLocalMachine machine; + machine.dev_id = "moonraker-device"; + machine.dev_name = "Moonraker printer"; + machine.dev_ip = "192.0.2.20"; + + MachineObject* object = manager.insert_local_device(machine, "lan", "free", "", "access-code"); + REQUIRE(object != nullptr); + CHECK(object->printer_agent_id == agent_id); + CHECK(object->printer_type.empty()); +} + +TEST_CASE("A Bambu device without a model still gets the C11 fallback", "[DeviceManager][integration]") +{ + ScopedAppConfig app_config; + auto agent = std::make_shared(BBL_PRINTER_AGENT_ID); + NetworkAgent network(nullptr, agent); + DeviceManager manager(&network, false, &app_config.config); + + BBLocalMachine machine; + machine.dev_id = "bambu-device"; + machine.dev_name = "Bambu printer"; + machine.dev_ip = "192.0.2.21"; + + MachineObject* object = manager.insert_local_device(machine, "lan", "free", "", "access-code"); + REQUIRE(object != nullptr); + CHECK(object->printer_type == "C11"); +} + +TEST_CASE("A known model survives a non-Bambu rebind that does not name one", "[DeviceManager][integration]") +{ + const std::string agent_id = GENERATE(std::string(MOONRAKER_PRINTER_AGENT_ID), + std::string(QIDI_PRINTER_AGENT_ID), + std::string(SNAPMAKER_PRINTER_AGENT_ID), + std::string(CREALITYPRINT_PRINTER_AGENT_ID), + std::string("integration-agent")); + CAPTURE(agent_id); + + ScopedAppConfig app_config; + auto agent = std::make_shared(agent_id); + NetworkAgent network(nullptr, agent); + DeviceManager manager(&network, false, &app_config.config); + + BBLocalMachine machine; + machine.dev_id = "known-model-device"; + machine.dev_name = "Known model printer"; + machine.dev_ip = "192.0.2.22"; + machine.printer_type = "test_model"; + + MachineObject* object = manager.insert_local_device(machine, "lan", "free", "", "access-code"); + REQUIRE(object != nullptr); + REQUIRE(object->printer_type == "test_model"); + + machine.printer_type.clear(); + REQUIRE(manager.insert_local_device(machine, "lan", "free", "", "access-code") == object); + CHECK(object->printer_type == "test_model"); +} + +TEST_CASE("A Bambu rebind without a model keeps the C11 fallback", "[DeviceManager][integration]") +{ + ScopedAppConfig app_config; + auto agent = std::make_shared(BBL_PRINTER_AGENT_ID); + NetworkAgent network(nullptr, agent); + DeviceManager manager(&network, false, &app_config.config); + + BBLocalMachine machine; + machine.dev_id = "known-model-device"; + machine.dev_name = "Known model printer"; + machine.dev_ip = "192.0.2.22"; + machine.printer_type = "BL-P001"; + + MachineObject* object = manager.insert_local_device(machine, "lan", "free", "", "access-code"); + REQUIRE(object != nullptr); + REQUIRE(object->printer_type == "BL-P001"); + + machine.printer_type.clear(); + REQUIRE(manager.insert_local_device(machine, "lan", "free", "", "access-code") == object); + CHECK(object->printer_type == "C11"); +} + TEST_CASE("Device manager remembers the last selected machine per printer agent", "[DeviceManager][integration]") { ScopedAppConfig app_config; diff --git a/tests/slic3rutils/test_moonraker_filament_sources.cpp b/tests/slic3rutils/test_moonraker_filament_sources.cpp new file mode 100644 index 0000000000..55f4fd6de9 --- /dev/null +++ b/tests/slic3rutils/test_moonraker_filament_sources.cpp @@ -0,0 +1,122 @@ +#include +#include + +#include +#include + +#include "slic3r/Utils/MoonrakerFilamentSources.hpp" + +using namespace Slic3r; + +namespace { +struct Tray +{ + bool has_filament; + int slot_index; + std::string material; +}; + +struct Reader +{ + bool success = false; + std::vector result; + int max_index = 0; + int calls = 0; + bool operator()(std::vector& trays, int& max_lane_index) + { + ++calls; + trays = result; + max_lane_index = max_index; + return success; + } +}; + +struct Sources +{ + Reader lanes, hh, cfs; + std::vector trays; + int max_index = 0; + MoonrakerFilamentSource read() + { + return select_moonraker_filament_data( + trays, max_index, [&](auto& out, int& index) { return lanes(out, index); }, + [&](auto& out, int& index) { return hh(out, index); }, [&](auto& out, int& index) { return cfs(out, index); }); + } +}; +} // namespace + +TEST_CASE("Populated lane data keeps priority over Happy Hare and CFS", "[MoonrakerFilamentSources]") +{ + Sources sources; + sources.lanes = {true, {{false, 0, ""}, {true, 4, "PLA"}}, 7}; + sources.hh = {true, {{true, 2, "PETG"}}, 2}; + sources.cfs = {true, {{true, 1, "ABS"}}, 1}; + REQUIRE(sources.read() == MoonrakerFilamentSource::Lanes); + REQUIRE(sources.trays.size() == 2); + CHECK(sources.trays[1].material == "PLA"); + CHECK(sources.max_index == 7); + CHECK(sources.hh.calls == 0); + CHECK(sources.cfs.calls == 0); +} + +TEST_CASE("Empty lane data lets Happy Hare supply loaded gates and keeps the widest topology", "[MoonrakerFilamentSources][Regression]") +{ + Sources sources; + const int loaded_gate = GENERATE(2, 9); + sources.lanes = {true, {{false, 0, ""}, {false, 7, ""}}, 7}; + sources.hh = {true, {{true, loaded_gate, "PETG"}}, loaded_gate}; + REQUIRE(sources.read() == MoonrakerFilamentSource::HappyHare); + REQUIRE(sources.trays.size() == 1); + CHECK(sources.trays.front().has_filament); + CHECK(sources.trays.front().slot_index == loaded_gate); + CHECK(sources.trays.front().material == "PETG"); + CHECK(sources.max_index == (loaded_gate > 7 ? loaded_gate : 7)); + CHECK(sources.cfs.calls == 0); +} + +TEST_CASE("An empty lane topology survives an unavailable Happy Hare and CFS", "[MoonrakerFilamentSources][Regression]") +{ + Sources sources; + sources.lanes = {true, {{false, 0, ""}, {false, 7, ""}}, 7}; + sources.hh = {false, {{true, 19, "discard partial HH"}}, 19}; + sources.cfs = {false, {{true, 23, "discard partial CFS"}}, 23}; + REQUIRE(sources.read() == MoonrakerFilamentSource::EmptyLanes); + CHECK(sources.trays.empty()); + CHECK(sources.max_index == 7); + CHECK(sources.hh.calls == 1); + CHECK(sources.cfs.calls == 1); +} + +TEST_CASE("CFS stays reachable after empty lanes and failed Happy Hare", "[MoonrakerFilamentSources][Regression]") +{ + Sources sources; + sources.lanes = {true, {{false, 7, ""}}, 7}; + sources.hh = {false, {{true, 12, "discard partial HH"}}, 12}; + sources.cfs = {true, {{true, 1, "ABS"}}, 3}; + REQUIRE(sources.read() == MoonrakerFilamentSource::CrealityCfs); + REQUIRE(sources.trays.size() == 1); + CHECK(sources.trays.front().material == "ABS"); + CHECK(sources.max_index == 3); +} + +TEST_CASE("A missing lane namespace leaves the existing fallback sources available", "[MoonrakerFilamentSources]") +{ + Sources sources; + sources.lanes = {false, {{true, 27, "discard invalid lanes"}}, 27}; + sources.hh = {true, {{true, 4, "PETG"}}, 4}; + REQUIRE(sources.read() == MoonrakerFilamentSource::HappyHare); + REQUIRE(sources.trays.size() == 1); + CHECK(sources.max_index == 4); + CHECK(sources.cfs.calls == 0); +} + +TEST_CASE("No successful source leaves no filament system or partial reader data", "[MoonrakerFilamentSources]") +{ + Sources sources; + sources.lanes = {false, {{true, 27, "invalid lanes"}}, 27}; + sources.hh = {false, {{true, 19, "partial HH"}}, 19}; + sources.cfs = {false, {{true, 23, "partial CFS"}}, 23}; + CHECK(sources.read() == MoonrakerFilamentSource::None); + CHECK(sources.trays.empty()); + CHECK(sources.max_index == 0); +} diff --git a/tests/slic3rutils/test_moonraker_printer_agent.cpp b/tests/slic3rutils/test_moonraker_printer_agent.cpp index 1f6f80df0b..1e608f00d5 100644 --- a/tests/slic3rutils/test_moonraker_printer_agent.cpp +++ b/tests/slic3rutils/test_moonraker_printer_agent.cpp @@ -655,6 +655,67 @@ TEST_CASE("Moonraker discovery waits for a complete device identity", "[Moonrake REQUIRE(announcement.at("dev_name") == "Test model"); } +TEST_CASE("Binding another address does not reuse the connected printer's identity", "[MoonrakerPrinterAgent][Bind]") +{ + // The agent was last connected to .5; binding .23 must not return .5's cached identity. + DiscoveryAgent agent(""); + agent.device_info.dev_id = "192.168.1.5"; + agent.device_info.dev_ip = "192.168.1.5"; + agent.device_info.base_url = "http://192.168.1.5"; + agent.device_info.dev_name = "Qidi Q2 at .5"; + agent.device_info.model_id = "qidi_q2"; + agent.device_info.model_name = "Qidi Q2"; + agent.device_info.version = "01.02.03"; + + detectResult detect; + REQUIRE(agent.bind_detect("192.168.1.23", "secure", detect) == BAMBU_NETWORK_SUCCESS); + + CHECK(detect.dev_id == "192.168.1.23"); + CHECK(detect.dev_name == "192.168.1.23"); + CHECK(detect.model_id.empty()); + CHECK(detect.version.empty()); + CHECK(detect.connect_type == "lan"); + CHECK(detect.bind_state == "free"); +} + +TEST_CASE("A binding address is normalized like a preset's print host", "[MoonrakerPrinterAgent][Bind]") +{ + const auto [entered, expected] = GENERATE(table({ + {"192.168.1.23", "192.168.1.23"}, + {"192.168.1.23:7125", "192.168.1.23:7125"}, + {"http://192.168.1.23", "192.168.1.23"}, + {"https://192.168.1.23:7126", "192.168.1.23:7126"}, + {"http://192.168.1.23:7125/printer", "192.168.1.23:7125"}, + })); + CAPTURE(entered); + + DiscoveryAgent agent(""); + detectResult detect; + REQUIRE(agent.bind_detect(entered, "secure", detect) == BAMBU_NETWORK_SUCCESS); + CHECK(detect.dev_id == expected); +} + +TEST_CASE("Binding the connected address does not reuse cached metadata", "[MoonrakerPrinterAgent][Bind]") +{ + DiscoveryAgent agent(""); + agent.device_info.dev_id = "192.168.1.23:7125"; + agent.device_info.dev_ip = "192.168.1.23"; + agent.device_info.dev_name = "Qidi Q2"; + agent.device_info.model_id = "qidi_q2"; + agent.device_info.version = "01.02.03"; + + detectResult detect; + REQUIRE(agent.bind_detect("http://192.168.1.23:7125/printer", "secure", detect) == BAMBU_NETWORK_SUCCESS); + + CHECK(detect.dev_id == "192.168.1.23:7125"); + CHECK(detect.dev_name == "192.168.1.23:7125"); + CHECK(detect.model_id.empty()); + CHECK(detect.version.empty()); + CHECK(agent.device_info.dev_name == "Qidi Q2"); + CHECK(agent.device_info.model_id == "qidi_q2"); + CHECK(agent.device_info.version == "01.02.03"); +} + TEST_CASE("Stopping the status stream gives a silent printer no more than its timeouts", "[MoonrakerPrinterAgent][StatusStream]") { // An open websocket gets the 200 ms close timeout, and a stalled object list request up to 1 s of curl progress to see the stop. diff --git a/tests/slic3rutils/test_object_list.cpp b/tests/slic3rutils/test_object_list.cpp index c1ec5bb575..a25e54a08d 100644 --- a/tests/slic3rutils/test_object_list.cpp +++ b/tests/slic3rutils/test_object_list.cpp @@ -3,6 +3,7 @@ #include #include "slic3r/GUI/GUI_ObjectList.hpp" +#include "slic3r/GUI/ObjectDataViewModel.hpp" #include "slic3r/GUI/Operations/Outcome.hpp" #include @@ -308,3 +309,16 @@ TEST_CASE("A part that repeats the object's filament has no settings of its own" CHECK(object->has_individual_part_settings() == c.individual); CHECK(object->hides_imported_parts() == !c.individual); } + +TEST_CASE("An object row reads its model object only while the model still holds it", "[ObjectList]") +{ + Model model; + ModelObject* held = model.add_object(); + model.add_object(); + Model other; + const ModelObject* elsewhere = other.add_object(); + + CHECK(ObjectDataViewModel::live_model_object(held, model.objects) == held); + CHECK(ObjectDataViewModel::live_model_object(elsewhere, model.objects) == nullptr); + CHECK(ObjectDataViewModel::live_model_object(nullptr, model.objects) == nullptr); +} diff --git a/tests/slic3rutils/test_part_plate.cpp b/tests/slic3rutils/test_part_plate.cpp index bb8201559d..bc32b79ee2 100644 --- a/tests/slic3rutils/test_part_plate.cpp +++ b/tests/slic3rutils/test_part_plate.cpp @@ -14,11 +14,17 @@ #include #include +#include +#include #include #include #include "libslic3r/Config.hpp" +#include "libslic3r/Model.hpp" +#include "libslic3r/Point.hpp" #include "libslic3r/PrintConfig.hpp" +#include "libslic3r/TriangleMesh.hpp" +#include "libslic3r/TriangleSelector.hpp" #include "slic3r/GUI/PartPlate.hpp" using namespace Slic3r; @@ -35,6 +41,36 @@ DynamicPrintConfig nozzle_config(std::vector nozzle_diameters, config.set_key_value("physical_extruder_map", new ConfigOptionInts(std::move(physical_extruder_map))); return config; } + +// Print settings for three filaments with no print-wide feature filament, brim, support or raft. +DynamicPrintConfig config_with_object_filaments_only() +{ + DynamicPrintConfig config = DynamicPrintConfig::full_print_config(); + config.set_key_value("filament_colour", new ConfigOptionStrings(3, "#FFFFFF")); + for (const char* key : {"outer_wall_filament_id", "inner_wall_filament_id", "sparse_infill_filament_id", + "internal_solid_filament_id", "top_surface_filament_id", "bottom_surface_filament_id"}) + config.set(key, 0); + config.set("enable_support", false); + config.set("raft_layers", 0); + config.set_key_value("brim_type", new ConfigOptionEnum(btNoBrim)); + return config; +} + +struct ObjectOnPlate +{ + Model model; + PartPlate plate{nullptr, Vec3d::Zero(), 200, 200, 200., nullptr, &model, true, ptFFF}; + ModelObject* object{model.add_object()}; + ModelVolume* part{object->add_volume(make_cube(10., 10., 10.), ModelVolumeType::MODEL_PART, false)}; + + ObjectOnPlate() + { + object->config.set("extruder", 1); + object->add_instance()->set_offset(Vec3d(95., 95., 0.)); + plate.set_shape({{0., 0.}, {200., 0.}, {200., 200.}, {0., 200.}}, {}, {}, {}, Vec2d::Zero(), 0.f, 0.f); + plate.add_instance(0, 0, false); + } +}; } // namespace TEST_CASE("A multi-nozzle printer without its own physical extruder map puts each filament on its own nozzle", "[PartPlate]") @@ -67,3 +103,116 @@ TEST_CASE("A filament with no extruder to map to has no physical nozzle", "[Part CHECK(plate.get_physical_extruder_by_filament_id(config, 0) == -1); CHECK(plate.get_physical_extruder_by_filament_id(config, 3) == -1); } + +TEST_CASE("A feature filament a part or layer range sets is a filament the plate uses", "[PartPlate]") +{ + const std::string key = GENERATE("outer_wall_filament_id", "inner_wall_filament_id", "sparse_infill_filament_id", + "internal_solid_filament_id", "top_surface_filament_id", "bottom_surface_filament_id"); + const bool in_layer_range = GENERATE(false, true); + ObjectOnPlate on_plate; + if (in_layer_range) + on_plate.object->layer_config_ranges[{2., 5.}].set(key, 2); + else + on_plate.part->config.set(key, 2); + DynamicPrintConfig config = config_with_object_filaments_only(); + + CHECK(on_plate.plate.get_extruders(false, config, config) == std::vector{1, 2}); + CHECK(on_plate.plate.get_extruders_under_cli(false, config) == std::vector{1, 2}); +} + +TEST_CASE("The filament a layer range prints with is a filament the plate uses", "[PartPlate]") +{ + ObjectOnPlate on_plate; + on_plate.object->layer_config_ranges[{2., 5.}].set("extruder", 2); + DynamicPrintConfig config = config_with_object_filaments_only(); + + CHECK(on_plate.plate.get_extruders(false, config, config) == std::vector{1, 2}); + CHECK(on_plate.plate.get_extruders_under_cli(false, config) == std::vector{1, 2}); +} + +TEST_CASE("A filament an object, part or layer range sets past the last filament slot is filament 1 on the plate", "[PartPlate]") +{ + enum class Where { Object, Part, PaintedPart, LayerRange }; + const auto [where, key, expected] = GENERATE(table>({ + {Where::Object, "outer_wall_filament_id", {1, 2}}, + {Where::Part, "outer_wall_filament_id", {1, 2}}, + {Where::LayerRange, "outer_wall_filament_id", {1, 2}}, + {Where::Object, "extruder", {1}}, + {Where::Part, "extruder", {1}}, + {Where::PaintedPart, "extruder", {1, 3}}, + {Where::LayerRange, "extruder", {1, 2}}, + })); + ObjectOnPlate on_plate; + on_plate.object->config.set("extruder", 2); + if (where == Where::Object) + on_plate.object->config.set(key, 4); + else if (where == Where::LayerRange) + on_plate.object->layer_config_ranges[{2., 5.}].set(key, 4); + else + on_plate.part->config.set(key, 4); + if (where == Where::PaintedPart) { + TriangleSelector selector(on_plate.part->mesh()); + selector.set_facet(0, EnforcerBlockerType::Extruder3); + REQUIRE(on_plate.part->mmu_segmentation_facets.set(selector)); + } + DynamicPrintConfig config = config_with_object_filaments_only(); + DynamicPrintConfig print_config = config; + print_config.erase("filament_colour"); + + CHECK(on_plate.plate.get_extruders(false, print_config, config) == expected); + CHECK(on_plate.plate.get_extruders_under_cli(false, config) == expected); +} + +TEST_CASE("A print-wide filament past the last filament slot resolves as the app's preset reset or the slicer's clamp does", "[PartPlate]") +{ + const auto [key, reset_by_app, clamped_by_slicer] = GENERATE(table, std::vector>({ + {"outer_wall_filament_id", {2}, {1, 2}}, + {"support_filament", {2, 3}, {1, 2}}, + {"brim_filament_id", {2}, {2}}, + })); + ObjectOnPlate on_plate; + on_plate.object->config.set("extruder", 2); + DynamicPrintConfig config = config_with_object_filaments_only(); + config.set(key, 4); + config.set("enable_support", key == "support_filament"); + if (key == "brim_filament_id") + config.set_key_value("brim_type", new ConfigOptionEnum(btOuterOnly)); + DynamicPrintConfig print_config = config; + print_config.erase("filament_colour"); + + CHECK(on_plate.plate.get_extruders(false, print_config, config, true, true) == reset_by_app); + CHECK(on_plate.plate.get_extruders(false, config, config) == clamped_by_slicer); + CHECK(on_plate.plate.get_extruders_under_cli(false, config) == clamped_by_slicer); +} + +TEST_CASE("A volume's feature filament is a filament the plate uses only when the volume makes print regions", "[PartPlate]") +{ + const auto [type, expected] = GENERATE(table>({ + {ModelVolumeType::PARAMETER_MODIFIER, {1, 2}}, + {ModelVolumeType::PAINTED_MODIFIER, {1, 2}}, + {ModelVolumeType::NEGATIVE_VOLUME, {1}}, + {ModelVolumeType::SUPPORT_BLOCKER, {1}}, + {ModelVolumeType::SUPPORT_ENFORCER, {1}}, + {ModelVolumeType::PRECISE_SEAM_CENTER, {1}}, + })); + ObjectOnPlate on_plate; + on_plate.object->add_volume(make_cube(5., 5., 5.), type, false)->config.set("outer_wall_filament_id", 2); + DynamicPrintConfig config = config_with_object_filaments_only(); + + CHECK(on_plate.plate.get_extruders(false, config, config) == expected); + CHECK(on_plate.plate.get_extruders_under_cli(false, config) == expected); +} + +TEST_CASE("A mixed filament a part sets for its outer wall stands for its components on the plate", "[PartPlate]") +{ + ObjectOnPlate on_plate; + on_plate.part->config.set("outer_wall_filament_id", 3); + DynamicPrintConfig config = config_with_object_filaments_only(); + // Filament 3 mixes filaments 1 and 2. + config.set_key_value("filament_is_mixed", new ConfigOptionBools({false, false, true})); + config.set_key_value("filament_mixed_components", new ConfigOptionStrings({"", "", "1,2"})); + + CHECK(on_plate.plate.get_extruders(false, config, config) == std::vector{1, 2}); + CHECK(on_plate.plate.get_extruders(false, config, config, false) == std::vector{1, 3}); + CHECK(on_plate.plate.get_extruders_under_cli(false, config) == std::vector{1, 2}); +} diff --git a/tests/test_utils.hpp b/tests/test_utils.hpp index 71f403b86f..b452b7af24 100644 --- a/tests/test_utils.hpp +++ b/tests/test_utils.hpp @@ -266,4 +266,19 @@ struct CommaNumericLocale #endif }; +// Switches the process-wide numeric locale, which the GUI sets from its language, to one whose +// decimal separator is a comma, when the system has one installed. Restores it when destroyed. +struct ProcessCommaNumericLocale +{ + std::string previous { std::setlocale(LC_NUMERIC, nullptr) }; + bool apply() + { + for (const char* name : { "de_DE.UTF-8", "de_DE.utf8", "de_DE", "de-DE", "German_Germany.1252" }) + if (std::setlocale(LC_NUMERIC, name) != nullptr) + return true; + return false; + } + ~ProcessCommaNumericLocale() { std::setlocale(LC_NUMERIC, previous.c_str()); } +}; + #endif // SLIC3R_TEST_UTILS