mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2026-01-31 21:30:51 -07:00
Merge branch 'SoftFever:main' into Nozzle_Size_E5Pro
This commit is contained in:
commit
af28d30c17
224 changed files with 22328 additions and 10121 deletions
3
.github/workflows/build_all.yml
vendored
3
.github/workflows/build_all.yml
vendored
|
|
@ -52,4 +52,5 @@ jobs:
|
|||
with:
|
||||
os: ${{ matrix.os }}
|
||||
arch: ${{ matrix.arch }}
|
||||
build-deps-only: ${{ inputs.build-deps-only || false }}
|
||||
build-deps-only: ${{ inputs.build-deps-only || false }}
|
||||
secrets: inherit
|
||||
3
.github/workflows/build_check_cache.yml
vendored
3
.github/workflows/build_check_cache.yml
vendored
|
|
@ -54,4 +54,5 @@ jobs:
|
|||
valid-cache: ${{ needs.check_cache.outputs.valid-cache == 'true' }}
|
||||
os: ${{ inputs.os }}
|
||||
arch: ${{ inputs.arch }}
|
||||
build-deps-only: ${{ inputs.build-deps-only }}
|
||||
build-deps-only: ${{ inputs.build-deps-only }}
|
||||
secrets: inherit
|
||||
|
|
|
|||
1
.github/workflows/build_deps.yml
vendored
1
.github/workflows/build_deps.yml
vendored
|
|
@ -127,4 +127,5 @@ jobs:
|
|||
cache-path: ${{ inputs.cache-path }}
|
||||
os: ${{ inputs.os }}
|
||||
arch: ${{ inputs.arch }}
|
||||
secrets: inherit
|
||||
|
||||
|
|
|
|||
2
.github/workflows/build_orca.yml
vendored
2
.github/workflows/build_orca.yml
vendored
|
|
@ -157,7 +157,7 @@ jobs:
|
|||
path: ${{ github.workspace }}/build/OrcaSlicer*.exe
|
||||
|
||||
- name: Upload artifacts Win PDB
|
||||
if: matrix.os == 'windows-latest'
|
||||
if: inputs.os == 'windows-latest'
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: PDB
|
||||
|
|
|
|||
4
.github/workflows/orca_bot.yml
vendored
4
.github/workflows/orca_bot.yml
vendored
|
|
@ -13,12 +13,12 @@ jobs:
|
|||
- uses: actions/stale@v5
|
||||
with:
|
||||
days-before-issue-stale: 90
|
||||
days-before-issue-close: 14
|
||||
days-before-issue-close: 7
|
||||
operations-per-run: 1000
|
||||
stale-issue-label: "stale"
|
||||
ascending: true
|
||||
stale-issue-message: "GitHub bot: this issue is stale because it has been open for 90 days with no activity."
|
||||
close-issue-message: "GitHub bot: This issue was closed because it has been inactive for 14 days since being marked as stale."
|
||||
close-issue-message: "GitHub bot: This issue was closed because it has been inactive for 7 days since being marked as stale."
|
||||
days-before-pr-stale: -1
|
||||
days-before-pr-close: -1
|
||||
remove-issue-stale-when-updated: true
|
||||
|
|
|
|||
2
deps/OpenSSL/OpenSSL.cmake
vendored
2
deps/OpenSSL/OpenSSL.cmake
vendored
|
|
@ -19,7 +19,7 @@ if(WIN32)
|
|||
set(_install_cmd nmake install_sw )
|
||||
else()
|
||||
if(APPLE)
|
||||
set(_conf_cmd ./Configure )
|
||||
set(_conf_cmd export MACOSX_DEPLOYMENT_TARGET=${CMAKE_OSX_DEPLOYMENT_TARGET} && ./Configure )
|
||||
else()
|
||||
set(_conf_cmd "./config")
|
||||
endif()
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ msgstr ""
|
|||
"Project-Id-Version: Orca Slicer\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2023-11-10 14:54+0800\n"
|
||||
"PO-Revision-Date: 2023-11-14 11:26+0900\n"
|
||||
"PO-Revision-Date: 2023-11-19 11:26+0900\n"
|
||||
"Last-Translator: Hotsolidinfill <138652683+Hotsolidinfill@users.noreply."
|
||||
"github.com>, crwusiz <crwusiz@naver.com>\n"
|
||||
"Language-Team: \n"
|
||||
|
|
@ -857,16 +857,16 @@ msgid "Load..."
|
|||
msgstr "불러오기..."
|
||||
|
||||
msgid "Orca Cube"
|
||||
msgstr "Orca Cube"
|
||||
msgstr "Orca 큐브"
|
||||
|
||||
msgid "3DBenchy"
|
||||
msgstr "3DBenchy"
|
||||
msgstr "3D 벤치"
|
||||
|
||||
msgid "Autodesk FDM Test"
|
||||
msgstr "Autodesk FDM Test"
|
||||
msgstr "Autodesk FDM 테스트"
|
||||
|
||||
msgid "Voron Cube"
|
||||
msgstr "Voron Cube"
|
||||
msgstr "Voron 큐브"
|
||||
|
||||
msgid "Cube"
|
||||
msgstr "정육면체"
|
||||
|
|
@ -1355,7 +1355,7 @@ msgid "Infill density(%)"
|
|||
msgstr "내부 채움 밀도(%)"
|
||||
|
||||
msgid "Auto Brim"
|
||||
msgstr "자동 챙(브림)"
|
||||
msgstr "자동 브림"
|
||||
|
||||
msgid "Auto"
|
||||
msgstr "자동"
|
||||
|
|
@ -1364,16 +1364,16 @@ msgid "Mouse ear"
|
|||
msgstr "생쥐 귀"
|
||||
|
||||
msgid "Outer brim only"
|
||||
msgstr "외부 챙만"
|
||||
msgstr "외부 브림만"
|
||||
|
||||
msgid "Inner brim only"
|
||||
msgstr "내부 챙만"
|
||||
msgstr "내부 브림만"
|
||||
|
||||
msgid "Outer and inner brim"
|
||||
msgstr "내부와 외부 챙"
|
||||
msgstr "내부와 외부 브림"
|
||||
|
||||
msgid "No-brim"
|
||||
msgstr "챙 비활성화"
|
||||
msgstr "브림 비활성화"
|
||||
|
||||
msgid "Outer wall speed"
|
||||
msgstr "외벽 속도"
|
||||
|
|
@ -1382,7 +1382,7 @@ msgid "Plate"
|
|||
msgstr "플레이트"
|
||||
|
||||
msgid "Brim"
|
||||
msgstr "챙(브림)"
|
||||
msgstr "브림"
|
||||
|
||||
msgid "Object/Part Setting"
|
||||
msgstr "개체/부품 설정"
|
||||
|
|
@ -1952,10 +1952,10 @@ msgid "PA Profile"
|
|||
msgstr "PA 프로필"
|
||||
|
||||
msgid "Factor K"
|
||||
msgstr "Factor K"
|
||||
msgstr "K 계수"
|
||||
|
||||
msgid "Factor N"
|
||||
msgstr "Factor N"
|
||||
msgstr "N 계수"
|
||||
|
||||
msgid "Setting Virtual slot information while printing is not supported"
|
||||
msgstr "출력 중에는 가상 슬롯 정보 설정이 지원되지 않습니다"
|
||||
|
|
@ -2025,7 +2025,7 @@ msgid ""
|
|||
"factor K input box."
|
||||
msgstr ""
|
||||
"교정이 완료되었습니다. 당신의 고온 베드에서 아래 사진과 같이 가장 균일한 압"
|
||||
"출 선을 찾아 왼쪽에 있는 값을 입력 상자의 Factor K에 채워주세요."
|
||||
"출 선을 찾아 왼쪽에 있는 값을 입력 상자의 K 계수에 채워주세요."
|
||||
|
||||
msgid "Save"
|
||||
msgstr "저장"
|
||||
|
|
@ -2549,7 +2549,7 @@ msgid "Auto bed leveling"
|
|||
msgstr "자동 베드 레벨링"
|
||||
|
||||
msgid "Heatbed preheating"
|
||||
msgstr "고온 베드 예열"
|
||||
msgstr "베드 예열"
|
||||
|
||||
msgid "Sweeping XY mech mode"
|
||||
msgstr "스위핑 XY 기계 모드"
|
||||
|
|
@ -2612,7 +2612,7 @@ msgid "Filament unloading"
|
|||
msgstr "필라멘트 빼는 중"
|
||||
|
||||
msgid "Skip step pause"
|
||||
msgstr "단계 일시정지 건너뛰기"
|
||||
msgstr "단계 건너뛰기 일시중지"
|
||||
|
||||
msgid "Filament loading"
|
||||
msgstr "필라멘트 넣는 중"
|
||||
|
|
@ -2696,7 +2696,7 @@ msgid ""
|
|||
"automatically be set to 0℃."
|
||||
msgstr ""
|
||||
"챔버 온도를 40℃ 이하로 설정하면 챔버 온도 제어가 활성화되지 않습니다. 그리고 "
|
||||
"목표 챔버 온도는 자동으로 0℃로 설정됩니다."
|
||||
"목표 챔버 온도는 자동으로 0℃ 로 설정됩니다."
|
||||
|
||||
msgid "Failed to start printing job"
|
||||
msgstr "출력 작업을 시작하지 못했습니다"
|
||||
|
|
@ -2898,7 +2898,7 @@ msgid "Retract"
|
|||
msgstr "퇴출"
|
||||
|
||||
msgid "Unretract"
|
||||
msgstr "비퇴출(언리트렉트)"
|
||||
msgstr "비퇴출"
|
||||
|
||||
msgid "Filament Changes"
|
||||
msgstr "필라멘트 변경"
|
||||
|
|
@ -3045,7 +3045,7 @@ msgid "Avoid extrusion calibration region"
|
|||
msgstr "압출 교정 영역을 피하십시오"
|
||||
|
||||
msgid "Align to Y axis"
|
||||
msgstr "Y축으로 정렬"
|
||||
msgstr "Y축에 정렬"
|
||||
|
||||
msgid "Add"
|
||||
msgstr "추가"
|
||||
|
|
@ -3245,7 +3245,7 @@ msgid "will be closed before creating a new model. Do you want to continue?"
|
|||
msgstr "새 모델을 생성하기 전에 닫힙니다. 계속하시겠습니까?"
|
||||
|
||||
msgid "Slice plate"
|
||||
msgstr "슬라이스 플레이트"
|
||||
msgstr "플레이트 슬라이스"
|
||||
|
||||
msgid "Print plate"
|
||||
msgstr "플레이트 출력"
|
||||
|
|
@ -3392,7 +3392,7 @@ msgid "Export all objects as STL"
|
|||
msgstr "모든 개체를 STL로 내보내기"
|
||||
|
||||
msgid "Export Generic 3MF"
|
||||
msgstr "Generic 3MF 내보내기"
|
||||
msgstr "일반 3MF 내보내기"
|
||||
|
||||
msgid "Export 3mf file without using some 3mf-extensions"
|
||||
msgstr "3mf-extensions을 사용하지 않고 3mf 파일 내보내기"
|
||||
|
|
@ -3485,10 +3485,10 @@ msgid "Show object labels in 3D scene"
|
|||
msgstr "3D 화면에 개체 이름표 표시"
|
||||
|
||||
msgid "Show &Overhang"
|
||||
msgstr "돌출부 &보기"
|
||||
msgstr "돌출부 보기"
|
||||
|
||||
msgid "Show object overhang highlight in 3D scene"
|
||||
msgstr "3D 장면에서 객체 오버행 하이라이트 표시"
|
||||
msgstr "3D 장면에서 개체 오버행 하이라이트 표시"
|
||||
|
||||
msgid "Preferences"
|
||||
msgstr "기본 설정"
|
||||
|
|
@ -4018,7 +4018,7 @@ msgid "Silent"
|
|||
msgstr "조용한"
|
||||
|
||||
msgid "Standard"
|
||||
msgstr "스탠다드"
|
||||
msgstr "표준"
|
||||
|
||||
msgid "Sport"
|
||||
msgstr "스포츠"
|
||||
|
|
@ -4510,7 +4510,7 @@ msgid ""
|
|||
"clogged when printing this filament in a closed enclosure. Please open the "
|
||||
"front door and/or remove the upper glass."
|
||||
msgstr ""
|
||||
"현재의 고온 베드 온도가 상대적으로 높습니다. 닫힌 공간에서 이 필라멘트를 출력"
|
||||
"현재 베드 온도가 상대적으로 높습니다. 닫힌 공간에서 이 필라멘트를 출력"
|
||||
"할 때 노즐이 막힐 수 있습니다. 전면 도어를 열거나 상단 유리를 제거하세요."
|
||||
|
||||
msgid ""
|
||||
|
|
@ -4690,13 +4690,13 @@ msgid "Message"
|
|||
msgstr "메시지"
|
||||
|
||||
msgid "Reload from:"
|
||||
msgstr "다음에서 다시 로드:"
|
||||
msgstr "다음에서 새로고침:"
|
||||
|
||||
msgid "Unable to reload:"
|
||||
msgstr "다시 로드할 수 없음:"
|
||||
msgstr "새로고침할 수 없음:"
|
||||
|
||||
msgid "Error during reload"
|
||||
msgstr "다시 로드 중 오류 발생"
|
||||
msgstr "새로고침 중 오류가 발생했습니다."
|
||||
|
||||
msgid "Slicing"
|
||||
msgstr "슬라이싱"
|
||||
|
|
@ -5620,7 +5620,7 @@ msgid ""
|
|||
"Caution to use! Flow calibration on Textured PEI Plate may fail due to the "
|
||||
"scattered surface."
|
||||
msgstr ""
|
||||
"사용상의 주의! Textured PEI 플레이트의 유량 교정은 표면이 분산되어 실패할 수 "
|
||||
"사용상의 주의! 텍스처 PEI 플레이트의 유량 교정은 표면이 분산되어 실패할 수 "
|
||||
"있습니다."
|
||||
|
||||
msgid "Automatic flow calibration using Micro Lidar"
|
||||
|
|
@ -5874,7 +5874,7 @@ msgid "Set speed for external and internal bridges"
|
|||
msgstr "외부 및 내부 다리 속도 설정"
|
||||
|
||||
msgid "Travel speed"
|
||||
msgstr "이동 속도(트레블)"
|
||||
msgstr "이동 속도"
|
||||
|
||||
msgid "Acceleration"
|
||||
msgstr "가속도"
|
||||
|
|
@ -5927,7 +5927,7 @@ msgid "Reserved keywords found"
|
|||
msgstr "예약어를 찾았습니다"
|
||||
|
||||
msgid "Setting Overrides"
|
||||
msgstr "설정 재정의(덮어쓰기)"
|
||||
msgstr "설정 덮어쓰기"
|
||||
|
||||
msgid "Retraction"
|
||||
msgstr "퇴출"
|
||||
|
|
@ -6724,7 +6724,7 @@ msgid "A new Network plug-in(%s) available, Do you want to install it?"
|
|||
msgstr "새 네트워크 플러그인(%s)을 사용할 수 있습니다. 설치하시겠습니까?"
|
||||
|
||||
msgid "New version of Orca Slicer"
|
||||
msgstr "뱀부 스튜디오의 새 버전"
|
||||
msgstr "Orca Slicer의 새 버전"
|
||||
|
||||
msgid "Don't remind me of this version again"
|
||||
msgstr "이 버전을 다시 알리지 않음"
|
||||
|
|
@ -6924,13 +6924,13 @@ msgid "Outer wall"
|
|||
msgstr "외벽"
|
||||
|
||||
msgid "Overhang wall"
|
||||
msgstr "돌출벽(오버행)"
|
||||
msgstr "돌출벽"
|
||||
|
||||
msgid "Sparse infill"
|
||||
msgstr "드문 내부 채움"
|
||||
|
||||
msgid "Internal solid infill"
|
||||
msgstr "내부 꽉찬 내부 채움"
|
||||
msgstr "꽉찬 내부 채움"
|
||||
|
||||
msgid "Top surface"
|
||||
msgstr "상단 표면"
|
||||
|
|
@ -6972,7 +6972,7 @@ msgid "undefined error"
|
|||
msgstr "정의되지 않은 오류"
|
||||
|
||||
msgid "too many files"
|
||||
msgstr "너무 많은 파일"
|
||||
msgstr "파일이 너무 많습니다"
|
||||
|
||||
msgid "file too large"
|
||||
msgstr "파일이 너무 큽니다"
|
||||
|
|
@ -6990,7 +6990,7 @@ msgid "failed finding central directory"
|
|||
msgstr "중앙 디렉토리를 찾지 못했습니다"
|
||||
|
||||
msgid "not a ZIP archive"
|
||||
msgstr "zip 아카이브가 아님"
|
||||
msgstr "zip형식의 압축파일이 아님"
|
||||
|
||||
msgid "invalid header or corrupted"
|
||||
msgstr "잘못된 헤더이거나 손상됨"
|
||||
|
|
@ -7053,7 +7053,7 @@ msgid "file not found"
|
|||
msgstr "파일을 찾을 수 없습니다"
|
||||
|
||||
msgid "archive too large"
|
||||
msgstr "아카이브가 너무 큼"
|
||||
msgstr "압축파일이 너무 큽니다"
|
||||
|
||||
msgid "validation failed"
|
||||
msgstr "검증에 실패했습니다"
|
||||
|
|
@ -7107,7 +7107,7 @@ msgid ""
|
|||
"Smooth mode of timelapse is not supported when \"by object\" sequence is "
|
||||
"enabled."
|
||||
msgstr ""
|
||||
"타임랩스의 유연 모드는 \"개체별\" 출력순서가 활성화된 경우 지원되지 않습니다."
|
||||
"타임랩스의 유연 모드는 \"개체별\" 출력순서가 활성화된 경우 지원되지 않습니다."
|
||||
|
||||
msgid ""
|
||||
"Please select \"By object\" print sequence to print multiple objects in "
|
||||
|
|
@ -7238,7 +7238,7 @@ msgid "Plate %d: %s does not support filament %s"
|
|||
msgstr "%d: %s 플레이트는 %s 필라멘트를 지원하지 않습니다"
|
||||
|
||||
msgid "Generating skirt & brim"
|
||||
msgstr "스커트 & 챙(브림) 생성 중"
|
||||
msgstr "스커트 & 브림 생성 중"
|
||||
|
||||
msgid "Exporting G-code"
|
||||
msgstr "G코드 내보내는 중"
|
||||
|
|
@ -7247,7 +7247,7 @@ msgid "Generating G-code"
|
|||
msgstr "G코드 생성 중"
|
||||
|
||||
msgid "Failed processing of the filename_format template."
|
||||
msgstr "파일 이름 형식(filename_format) 템플릿 처리에 실패했습니다."
|
||||
msgstr "파일 이름 형식 템플릿 처리에 실패했습니다."
|
||||
|
||||
msgid "Printable area"
|
||||
msgstr "출력 가능 영역"
|
||||
|
|
@ -7394,7 +7394,7 @@ msgstr "벽 가로지름 방지"
|
|||
|
||||
msgid "Detour and avoid to travel across wall which may cause blob on surface"
|
||||
msgstr ""
|
||||
"벽을 가로질러 이동하지 않고 우회하여 표면에 방울(Blob) 발생을 방지합니다"
|
||||
"벽을 가로질러 이동하지 않고 우회하여 표면에 방울 발생을 방지합니다"
|
||||
|
||||
msgid "Avoid crossing wall - Max detour length"
|
||||
msgstr "벽 가로지름 방지 - 최대 우회 길이"
|
||||
|
|
@ -7450,7 +7450,7 @@ msgid "Initial layer"
|
|||
msgstr "초기 레이어"
|
||||
|
||||
msgid "Initial layer bed temperature"
|
||||
msgstr "초기 레이어 베드(Bed) 온도"
|
||||
msgstr "초기 레이어 베드 온도"
|
||||
|
||||
msgid ""
|
||||
"Bed temperature of the initial layer. Value 0 means the filament does not "
|
||||
|
|
@ -7734,51 +7734,51 @@ msgstr ""
|
|||
"로 계산됩니다. 기본값은 150%입니다."
|
||||
|
||||
msgid "Brim width"
|
||||
msgstr "챙(브림) 너비"
|
||||
msgstr "브림 너비"
|
||||
|
||||
msgid "Distance from model to the outermost brim line"
|
||||
msgstr "모델과 가장 바깥쪽 챙(브림) 선까지의 거리"
|
||||
msgstr "모델과 가장 바깥쪽 브림 선까지의 거리"
|
||||
|
||||
msgid "Brim type"
|
||||
msgstr "챙(브림) 유형"
|
||||
msgstr "브림 유형"
|
||||
|
||||
msgid ""
|
||||
"This controls the generation of the brim at outer and/or inner side of "
|
||||
"models. Auto means the brim width is analysed and calculated automatically."
|
||||
msgstr ""
|
||||
"모델의 외부 그리고/또는 내부에서 챙(브림)의 생성을 제어합니다. 자동은 챙(브"
|
||||
"림) 너비가 자동으로 분석 및 계산됨을 의미합니다."
|
||||
"모델의 외부 그리고/또는 내부에서 브림의 생성을 제어합니다. 자동은 브림"
|
||||
"너비가 자동으로 분석 및 계산됨을 의미합니다."
|
||||
|
||||
msgid "Brim-object gap"
|
||||
msgstr "챙(브림)-개체 간격"
|
||||
msgstr "브림-개체 간격"
|
||||
|
||||
msgid ""
|
||||
"A gap between innermost brim line and object can make brim be removed more "
|
||||
"easily"
|
||||
msgstr ""
|
||||
"가장 안쪽 챙(브림) 라인과 개체 사이에 간격을 주어 쉽게 챙(브림)을 제거 할 수 "
|
||||
"가장 안쪽 브림 라인과 개체 사이에 간격을 주어 쉽게 브림을 제거 할 수 "
|
||||
"있게 합니다"
|
||||
|
||||
msgid "Brim ears"
|
||||
msgstr "챙(브림) 귀"
|
||||
msgstr "브림 귀"
|
||||
|
||||
msgid "Only draw brim over the sharp edges of the model."
|
||||
msgstr "모델의 날카로운 가장자리에만 챙을 그립니다."
|
||||
msgstr "모델의 날카로운 가장자리에만 브림을 그립니다."
|
||||
|
||||
msgid "Brim ear max angle"
|
||||
msgstr "챙(브림) 귀 최대 각도"
|
||||
msgstr "브림 귀 최대 각도"
|
||||
|
||||
msgid ""
|
||||
"Maximum angle to let a brim ear appear. \n"
|
||||
"If set to 0, no brim will be created. \n"
|
||||
"If set to ~180, brim will be created on everything but straight sections."
|
||||
msgstr ""
|
||||
"챙 귀가 나타날 수 있는 최대 각도.\n"
|
||||
"0으로 설정하면 챙이 생성되지 않습니다.\n"
|
||||
"~180으로 설정하면 직선 부분을 제외한 모든 부분에 챙이 생성됩니다."
|
||||
"브림 귀가 나타날 수 있는 최대 각도.\n"
|
||||
"0으로 설정하면 브림이 생성되지 않습니다.\n"
|
||||
"~180으로 설정하면 직선 부분을 제외한 모든 부분에 브림이 생성됩니다."
|
||||
|
||||
msgid "Brim ear detection radius"
|
||||
msgstr "챙 귀 감지 반경"
|
||||
msgstr "브림 귀 감지 반경"
|
||||
|
||||
msgid ""
|
||||
"The geometry will be decimated before dectecting sharp angles. This "
|
||||
|
|
@ -7912,13 +7912,13 @@ msgstr ""
|
|||
"로 설정하고 다리에 지지대를 생성하지 않으려면 매우 큰 값으로 설정합니다."
|
||||
|
||||
msgid "End G-code"
|
||||
msgstr "End G-code"
|
||||
msgstr "종료 G코드"
|
||||
|
||||
msgid "End G-code when finish the whole printing"
|
||||
msgstr "전체 출력이 끝날때의 End G-code"
|
||||
msgstr "전체 출력이 끝날때의 종료 G코드"
|
||||
|
||||
msgid "End G-code when finish the printing of this filament"
|
||||
msgstr "이 필라멘트의 출력이 끝날때의 End G-code"
|
||||
msgstr "이 필라멘트의 출력이 끝날때의 종료 G코드"
|
||||
|
||||
msgid "Ensure vertical shell thickness"
|
||||
msgstr "수직 쉘 두께 확보"
|
||||
|
|
@ -8335,7 +8335,7 @@ msgstr "가용성 재료"
|
|||
msgid ""
|
||||
"Soluble material is commonly used to print support and support interface"
|
||||
msgstr ""
|
||||
"가용성 재료는 일반적으로 지지대 및 지지대 접점(Interface)을 출력하는 데 사용"
|
||||
"가용성 재료는 일반적으로 지지대 및 지지대 접점을 출력하는 데 사용"
|
||||
"됩니다"
|
||||
|
||||
msgid "Support material"
|
||||
|
|
@ -8344,7 +8344,7 @@ msgstr "지지대 재료"
|
|||
msgid ""
|
||||
"Support material is commonly used to print support and support interface"
|
||||
msgstr ""
|
||||
"지원 재료는 일반적으로 지지대 및 지지대 접점(Interface)을 출력하는 데 사용됩"
|
||||
"지원 재료는 일반적으로 지지대 및 지지대 접점을 출력하는 데 사용됩"
|
||||
"니다"
|
||||
|
||||
msgid "Softening temperature"
|
||||
|
|
@ -8451,10 +8451,10 @@ msgstr ""
|
|||
"정합니다."
|
||||
|
||||
msgid "0 (no open anchors)"
|
||||
msgstr "0(개방형 고정점 없음)"
|
||||
msgstr "0 (개방형 고정점 없음)"
|
||||
|
||||
msgid "1000 (unlimited)"
|
||||
msgstr "1000(무제한)"
|
||||
msgstr "1000 (무제한)"
|
||||
|
||||
msgid "Maximum length of the infill anchor"
|
||||
msgstr "내부 채움 고정점 최대 길이"
|
||||
|
|
@ -8480,7 +8480,7 @@ msgstr ""
|
|||
"결과가 생성됩니다."
|
||||
|
||||
msgid "0 (Simple connect)"
|
||||
msgstr "0(단순 연결)"
|
||||
msgstr "0 (단순 연결)"
|
||||
|
||||
msgid "Acceleration of outer walls"
|
||||
msgstr "외벽의 가속도"
|
||||
|
|
@ -8630,7 +8630,7 @@ msgstr ""
|
|||
"\"close_fan_the_first_x_layers\" + 1 에서 최대 허용 속도로 가도됩니다."
|
||||
|
||||
msgid "Support interface fan speed"
|
||||
msgstr "지지대 접점(Interface) 팬 속도"
|
||||
msgstr "지지대 접점 팬 속도"
|
||||
|
||||
msgid ""
|
||||
"This fan speed is enforced during all support interfaces, to be able to "
|
||||
|
|
@ -8733,16 +8733,16 @@ msgstr ""
|
|||
"수 있는지를 결정합니다"
|
||||
|
||||
msgid "Undefine"
|
||||
msgstr "Undefine"
|
||||
msgstr "알수없음"
|
||||
|
||||
msgid "Hardened steel"
|
||||
msgstr "Hardened steel"
|
||||
msgstr "경화강 노즐"
|
||||
|
||||
msgid "Stainless steel"
|
||||
msgstr "Stainless steel"
|
||||
msgstr "스테인레스강 노즐"
|
||||
|
||||
msgid "Brass"
|
||||
msgstr "Brass"
|
||||
msgstr "동 노즐"
|
||||
|
||||
msgid "Nozzle HRC"
|
||||
msgstr "노즐 록웰 경도(HRC)"
|
||||
|
|
@ -8835,7 +8835,7 @@ msgid "The printer cost per hour"
|
|||
msgstr "시간당 프린터 비용"
|
||||
|
||||
msgid "money/h"
|
||||
msgstr "원/h"
|
||||
msgstr "비용/시간"
|
||||
|
||||
msgid "Support control chamber temperature"
|
||||
msgstr "챔버 온도 제어 지원"
|
||||
|
|
@ -8858,7 +8858,7 @@ msgstr ""
|
|||
"G코드 명령: M106 P3 S(0-255)"
|
||||
|
||||
msgid "G-code flavor"
|
||||
msgstr "G코드 호환(Flavor)"
|
||||
msgstr "G코드 유형"
|
||||
|
||||
msgid "What kind of gcode the printer is compatible with"
|
||||
msgstr "프린터와 호환되는 G코드 종류"
|
||||
|
|
@ -9180,7 +9180,7 @@ msgstr ""
|
|||
"도/더 작은 너비) 압출로 또는 그 반대로 출력할 때 발생하는 급격한 압출 속도 변"
|
||||
"화를 완화합니다.\n"
|
||||
"\n"
|
||||
"이는 압출된 체적 유량(mm3/sec)이 시간에 따라 변할 수 있는 최대 속도를 정의합"
|
||||
"이는 압출된 체적 유량(mm3/초)이 시간에 따라 변할 수 있는 최대 속도를 정의합"
|
||||
"니다. 값이 높을수록 더 높은 압출 속도 변경이 허용되어 속도 전환이 더 빨라진다"
|
||||
"는 의미입니다.\n"
|
||||
"\n"
|
||||
|
|
@ -9190,10 +9190,10 @@ msgstr ""
|
|||
"값이 필요하지 않습니다. 그러나 기능 속도가 크게 달라지는 특정 경우에는 약간"
|
||||
"의 이점을 제공할 수 있습니다. 예를 들어 돌출부로 인해 급격하게 감속이 발생하"
|
||||
"는 경우입니다. 이러한 경우 약 300-350mm3/s2의 높은 값이 권장됩니다. 이렇게 하"
|
||||
"면 프레셔 어드밴스(Pressure advance)가 더 부드러운 유량 전환을 달성하는 데 도"
|
||||
"면 프레셔 어드밴스가 더 부드러운 유량 전환을 달성하는 데 도"
|
||||
"움이 될 만큼 충분히 매끄러워질 수 있기 때문입니다.\n"
|
||||
"\n"
|
||||
"프레셔 어드밴스(Pressure advance) 기능이 없는 느린 프린터의 경우 값을 훨씬 낮"
|
||||
"프레셔 어드밴스 기능이 없는 느린 프린터의 경우 값을 훨씬 낮"
|
||||
"게 설정해야 합니다. 10-15mm3/s2 값은 직접 구동 압출기의 좋은 시작점이고 보우"
|
||||
"덴 스타일의 경우 5-10mm3/s2입니다.\n"
|
||||
"\n"
|
||||
|
|
@ -9401,7 +9401,7 @@ msgid "mm²"
|
|||
msgstr "mm²"
|
||||
|
||||
msgid "Detect overhang wall"
|
||||
msgstr "돌출벽(오버행 벽) 감지"
|
||||
msgstr "돌출벽 감지"
|
||||
|
||||
#, c-format, boost-format
|
||||
msgid ""
|
||||
|
|
@ -9499,7 +9499,7 @@ msgid ""
|
|||
msgstr ""
|
||||
"퇴출 길이에 비례한 닦기 전 퇴출량(닦기를 시작하기 전에 일부 필라멘트를 퇴출시"
|
||||
"키면 노즐 끝에 녹아있는 소량의 필라멘트만 남게되어 추가 누수 위험이 줄어들 "
|
||||
"수 있습니다_by MMT)"
|
||||
"수 있습니다)"
|
||||
|
||||
msgid "Retract when change layer"
|
||||
msgstr "레이어 변경 시 퇴출"
|
||||
|
|
@ -9597,7 +9597,7 @@ msgid ""
|
|||
"When the retraction is compensated after changing tool, the extruder will "
|
||||
"push this additional amount of filament."
|
||||
msgstr ""
|
||||
"툴(Tool) 교체 후 퇴출이 보정되면 압출기가 보정된 양 만큼의 추가 필라멘트를 밀"
|
||||
"툴 교체 후 퇴출이 보정되면 압출기가 보정된 양 만큼의 추가 필라멘트를 밀"
|
||||
"어냅니다."
|
||||
|
||||
msgid "Retraction Speed"
|
||||
|
|
@ -9607,7 +9607,7 @@ msgid "Speed of retractions"
|
|||
msgstr "퇴출 속도"
|
||||
|
||||
msgid "Deretraction Speed"
|
||||
msgstr "퇴출 복귀(디-리트렉션) 속도"
|
||||
msgstr "퇴출 복귀 속도"
|
||||
|
||||
msgid ""
|
||||
"Speed for reloading filament into extruder. Zero means same speed with "
|
||||
|
|
@ -9705,10 +9705,10 @@ msgstr ""
|
|||
"은 80%입니다"
|
||||
|
||||
msgid "Skirt distance"
|
||||
msgstr "스커트-챙(브림)/개체 거리"
|
||||
msgstr "스커트 거리"
|
||||
|
||||
msgid "Distance from skirt to brim or object"
|
||||
msgstr "스커트와 챙(브림) 또는 개체와의 거리"
|
||||
msgstr "스커트와 브림 또는 개체와의 거리"
|
||||
|
||||
msgid "Skirt height"
|
||||
msgstr "스커트 높이"
|
||||
|
|
@ -9763,7 +9763,7 @@ msgid ""
|
|||
"generated model has no seam"
|
||||
msgstr ""
|
||||
"나선화는 외부 윤곽선의 z 이동을 부드럽게 합니다. 그리고 개체를 꽉찬 하단 레이"
|
||||
"어(Solid bottom layers)가 있는 단일 벽으로 출력합니다. 최종 생성된 출력물에"
|
||||
"어가 있는 단일 벽으로 출력합니다. 최종 생성된 출력물에"
|
||||
"는 솔기가 없습니다"
|
||||
|
||||
msgid ""
|
||||
|
|
@ -9907,7 +9907,7 @@ msgid ""
|
|||
"normal(manual) or tree(manual) is selected, only support enforcers are "
|
||||
"generated"
|
||||
msgstr ""
|
||||
"일반(자동) 및 나무(자동)는 지지대를 자동으로 생성합니다. 일반(수동) 또는 나무"
|
||||
"일반(자동) 및 나무(자동)은 지지대를 자동으로 생성합니다. 일반(수동) 또는 나무"
|
||||
"(수동) 선택시에는 강제된 지지대만 생성됩니다"
|
||||
|
||||
msgid "normal(auto)"
|
||||
|
|
@ -10175,18 +10175,18 @@ msgstr ""
|
|||
"으로 계산됩니다 "
|
||||
|
||||
msgid "Auto brim width"
|
||||
msgstr "나무 지지대 자동 챙(브림) 너비"
|
||||
msgstr "나무 지지대 자동 브림 너비"
|
||||
|
||||
msgid ""
|
||||
"Enabling this option means the width of the brim for tree support will be "
|
||||
"automatically calculated"
|
||||
msgstr "옵션을 활성화하면 나무 지지대의 챙(브림) 너비가 자동으로 계산됩니다"
|
||||
msgstr "옵션을 활성화하면 나무 지지대의 브림 너비가 자동으로 계산됩니다"
|
||||
|
||||
msgid "Tree support brim width"
|
||||
msgstr "나무 지지대 챙(브림) 너비"
|
||||
msgstr "나무 지지대 브림 너비"
|
||||
|
||||
msgid "Distance from tree branch to the outermost brim line"
|
||||
msgstr "나무 지지대 가지에서 가장 바깥쪽 챙(브림)까지의 거리"
|
||||
msgstr "나무 지지대 가지에서 가장 바깥쪽 브림까지의 거리"
|
||||
|
||||
msgid "Tip Diameter"
|
||||
msgstr "끝 직경"
|
||||
|
|
@ -10527,7 +10527,7 @@ msgid "Rotate the polyhole every layer."
|
|||
msgstr "레이어마다 폴리홀을 회전시킵니다."
|
||||
|
||||
msgid "G-code thumbnails"
|
||||
msgstr "G코드 미리보기(썸네일)"
|
||||
msgstr "G코드 미리보기"
|
||||
|
||||
msgid ""
|
||||
"Picture sizes to be stored into a .gcode and .sl1 / .sl1s files, in the "
|
||||
|
|
@ -10778,13 +10778,13 @@ msgid "Export Settings"
|
|||
msgstr "설정 내보내기"
|
||||
|
||||
msgid "Export settings to a file."
|
||||
msgstr "설정을 파일로 내보냅니다."
|
||||
msgstr "설정을 파일로 내보내기."
|
||||
|
||||
msgid "Send progress to pipe"
|
||||
msgstr "Send progress to pipe"
|
||||
msgstr "진행 상황을 파이프로 보내기"
|
||||
|
||||
msgid "Send progress to pipe."
|
||||
msgstr "Send progress to pipe."
|
||||
msgstr "진행 상황을 파이프로 보내기."
|
||||
|
||||
msgid "Arrange Options"
|
||||
msgstr "정렬 옵션"
|
||||
|
|
@ -10799,7 +10799,7 @@ msgid "Repetions count of the whole model"
|
|||
msgstr "전체 모델의 반복 횟수"
|
||||
|
||||
msgid "Ensure on bed"
|
||||
msgstr "Ensure on bed"
|
||||
msgstr "베드에서 확인"
|
||||
|
||||
msgid ""
|
||||
"Lift the object above the bed when it is partially below. Disabled by default"
|
||||
|
|
@ -11645,10 +11645,10 @@ msgid "PA Calibration"
|
|||
msgstr "PA 교정"
|
||||
|
||||
msgid "DDE"
|
||||
msgstr "다이렉트 드라이브(DDE)"
|
||||
msgstr "다이렉트"
|
||||
|
||||
msgid "Bowden"
|
||||
msgstr "보우덴(Bowden)"
|
||||
msgstr "보우덴"
|
||||
|
||||
msgid "Extruder type"
|
||||
msgstr "압출기 타입"
|
||||
|
|
@ -12064,8 +12064,8 @@ msgid ""
|
|||
"Did you know that when printing models have a small contact interface with "
|
||||
"the printing surface, it's recommended to use a brim?"
|
||||
msgstr ""
|
||||
"더 나은 안착을 위한 챙(브림)\n"
|
||||
"출력 모델이 베드 표면과의 접촉면이 작을 때 챙(브림)를 사용하는 것이 좋다는 사"
|
||||
"더 나은 안착을 위한 브림\n"
|
||||
"출력 모델이 베드 표면과의 접촉면이 작을 때 브림를 사용하는 것이 좋다는 사"
|
||||
"실을 알고 있습니까?"
|
||||
|
||||
#: resources/data/hints.ini: [hint:Set parameters for multiple objects]
|
||||
|
|
|
|||
37
resources/images/copy_menu.svg
Normal file
37
resources/images/copy_menu.svg
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- Generator: Adobe Illustrator 23.0.3, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
|
||||
<svg version="1.0" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
|
||||
viewBox="0 0 128 128" enable-background="new 0 0 128 128" xml:space="preserve">
|
||||
<g id="copy">
|
||||
<g>
|
||||
<path fill="#009688" d="M115.76,51.2l-8.06-8.06c-2.47-2.47-6.97-4.34-10.47-4.34h-50.8c-4.2,0-7.62,3.42-7.62,7.62v66.04
|
||||
c0,4.2,3.42,7.62,7.62,7.62h66.04c4.2,0,7.62-3.42,7.62-7.62v-50.8C120.09,58.17,118.23,53.67,115.76,51.2z M111.42,54.04h-6.57
|
||||
v-6.57L111.42,54.04z M115.01,112.47c0,1.4-1.14,2.54-2.54,2.54H46.43c-1.4,0-2.54-1.14-2.54-2.54V46.42
|
||||
c0-1.4,1.14-2.54,2.54-2.54h50.8c0.74,0,1.63,0.18,2.54,0.46v12.24c0,1.4,1.14,2.54,2.54,2.54h12.24c0.28,0.91,0.46,1.8,0.46,2.54
|
||||
V112.47z"/>
|
||||
<path fill="#009688" d="M53.97,59.13h35.72c1.4,0,2.54-1.14,2.54-2.54s-1.14-2.54-2.54-2.54H53.97c-1.4,0-2.54,1.14-2.54,2.54
|
||||
S52.56,59.13,53.97,59.13z"/>
|
||||
<path fill="#009688" d="M104.93,69.29H53.97c-1.4,0-2.54,1.14-2.54,2.54s1.14,2.54,2.54,2.54h50.96c1.4,0,2.54-1.14,2.54-2.54
|
||||
S106.33,69.29,104.93,69.29z"/>
|
||||
<path fill="#009688" d="M104.93,84.53H53.97c-1.4,0-2.54,1.14-2.54,2.54s1.14,2.54,2.54,2.54h50.96c1.4,0,2.54-1.14,2.54-2.54
|
||||
S106.33,84.53,104.93,84.53z"/>
|
||||
<path fill="#009688" d="M104.93,99.77H53.97c-1.4,0-2.54,1.14-2.54,2.54s1.14,2.54,2.54,2.54h50.96c1.4,0,2.54-1.14,2.54-2.54
|
||||
S106.33,99.77,104.93,99.77z"/>
|
||||
</g>
|
||||
<g>
|
||||
<path fill="#262E30" d="M85.27,20.71l-8.06-8.06c-2.47-2.47-6.97-4.34-10.47-4.34h-50.8c-4.2,0-7.62,3.42-7.62,7.62v66.04
|
||||
c0,4.2,3.42,7.62,7.62,7.62h17.78c1.4,0,2.54-1.14,2.54-2.54s-1.14-2.54-2.54-2.54H15.94c-1.4,0-2.54-1.14-2.54-2.54V15.94
|
||||
c0-1.4,1.14-2.54,2.54-2.54h50.8c0.74,0,1.63,0.18,2.54,0.46V26.1c0,1.4,1.14,2.54,2.54,2.54h12.45c0.16,0.49,0.25,0.93,0.25,1.27
|
||||
v3.81c0,1.4,1.14,2.54,2.54,2.54c1.4,0,2.54-1.14,2.54-2.54v-3.81C89.61,27.14,87.75,23.19,85.27,20.71z M74.37,16.99l6.57,6.57
|
||||
h-6.57V16.99z"/>
|
||||
<path fill="#262E30" d="M59.21,23.56H23.48c-1.4,0-2.54,1.14-2.54,2.54s1.14,2.54,2.54,2.54h35.72c1.4,0,2.54-1.14,2.54-2.54
|
||||
S60.61,23.56,59.21,23.56z"/>
|
||||
<path fill="#262E30" d="M28.73,38.8h-5.24c-1.4,0-2.54,1.14-2.54,2.54s1.14,2.54,2.54,2.54h5.24c1.4,0,2.54-1.14,2.54-2.54
|
||||
S30.13,38.8,28.73,38.8z"/>
|
||||
<path fill="#262E30" d="M28.73,54.04h-5.24c-1.4,0-2.54,1.14-2.54,2.54s1.14,2.54,2.54,2.54h5.24c1.4,0,2.54-1.14,2.54-2.54
|
||||
S30.13,54.04,28.73,54.04z"/>
|
||||
<path fill="#262E30" d="M28.73,69.29h-5.24c-1.4,0-2.54,1.14-2.54,2.54s1.14,2.54,2.54,2.54h5.24c1.4,0,2.54-1.14,2.54-2.54
|
||||
S30.13,69.29,28.73,69.29z"/>
|
||||
</g>
|
||||
</g>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 2.6 KiB |
37
resources/images/copy_menu_dark.svg
Normal file
37
resources/images/copy_menu_dark.svg
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- Generator: Adobe Illustrator 23.0.3, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
|
||||
<svg version="1.0" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
|
||||
viewBox="0 0 128 128" enable-background="new 0 0 128 128" xml:space="preserve">
|
||||
<g id="copy">
|
||||
<g>
|
||||
<path fill="#009688" d="M115.76,51.2l-8.06-8.06c-2.47-2.47-6.97-4.34-10.47-4.34h-50.8c-4.2,0-7.62,3.42-7.62,7.62v66.04
|
||||
c0,4.2,3.42,7.62,7.62,7.62h66.04c4.2,0,7.62-3.42,7.62-7.62v-50.8C120.09,58.17,118.23,53.67,115.76,51.2z M111.42,54.04h-6.57
|
||||
v-6.57L111.42,54.04z M115.01,112.47c0,1.4-1.14,2.54-2.54,2.54H46.43c-1.4,0-2.54-1.14-2.54-2.54V46.42
|
||||
c0-1.4,1.14-2.54,2.54-2.54h50.8c0.74,0,1.63,0.18,2.54,0.46v12.24c0,1.4,1.14,2.54,2.54,2.54h12.24c0.28,0.91,0.46,1.8,0.46,2.54
|
||||
V112.47z"/>
|
||||
<path fill="#009688" d="M53.97,59.13h35.72c1.4,0,2.54-1.14,2.54-2.54s-1.14-2.54-2.54-2.54H53.97c-1.4,0-2.54,1.14-2.54,2.54
|
||||
S52.56,59.13,53.97,59.13z"/>
|
||||
<path fill="#009688" d="M104.93,69.29H53.97c-1.4,0-2.54,1.14-2.54,2.54s1.14,2.54,2.54,2.54h50.96c1.4,0,2.54-1.14,2.54-2.54
|
||||
S106.33,69.29,104.93,69.29z"/>
|
||||
<path fill="#009688" d="M104.93,84.53H53.97c-1.4,0-2.54,1.14-2.54,2.54s1.14,2.54,2.54,2.54h50.96c1.4,0,2.54-1.14,2.54-2.54
|
||||
S106.33,84.53,104.93,84.53z"/>
|
||||
<path fill="#009688" d="M104.93,99.77H53.97c-1.4,0-2.54,1.14-2.54,2.54s1.14,2.54,2.54,2.54h50.96c1.4,0,2.54-1.14,2.54-2.54
|
||||
S106.33,99.77,104.93,99.77z"/>
|
||||
</g>
|
||||
<g>
|
||||
<path fill="#B6B6B6" d="M85.27,20.71l-8.06-8.06c-2.47-2.47-6.97-4.34-10.47-4.34h-50.8c-4.2,0-7.62,3.42-7.62,7.62v66.04
|
||||
c0,4.2,3.42,7.62,7.62,7.62h17.78c1.4,0,2.54-1.14,2.54-2.54s-1.14-2.54-2.54-2.54H15.94c-1.4,0-2.54-1.14-2.54-2.54V15.94
|
||||
c0-1.4,1.14-2.54,2.54-2.54h50.8c0.74,0,1.63,0.18,2.54,0.46V26.1c0,1.4,1.14,2.54,2.54,2.54h12.45c0.16,0.49,0.25,0.93,0.25,1.27
|
||||
v3.81c0,1.4,1.14,2.54,2.54,2.54c1.4,0,2.54-1.14,2.54-2.54v-3.81C89.61,27.14,87.75,23.19,85.27,20.71z M74.37,16.99l6.57,6.57
|
||||
h-6.57V16.99z"/>
|
||||
<path fill="#B6B6B6" d="M59.21,23.56H23.48c-1.4,0-2.54,1.14-2.54,2.54s1.14,2.54,2.54,2.54h35.72c1.4,0,2.54-1.14,2.54-2.54
|
||||
S60.61,23.56,59.21,23.56z"/>
|
||||
<path fill="#B6B6B6" d="M28.73,38.8h-5.24c-1.4,0-2.54,1.14-2.54,2.54s1.14,2.54,2.54,2.54h5.24c1.4,0,2.54-1.14,2.54-2.54
|
||||
S30.13,38.8,28.73,38.8z"/>
|
||||
<path fill="#B6B6B6" d="M28.73,54.04h-5.24c-1.4,0-2.54,1.14-2.54,2.54s1.14,2.54,2.54,2.54h5.24c1.4,0,2.54-1.14,2.54-2.54
|
||||
S30.13,54.04,28.73,54.04z"/>
|
||||
<path fill="#B6B6B6" d="M28.73,69.29h-5.24c-1.4,0-2.54,1.14-2.54,2.54s1.14,2.54,2.54,2.54h5.24c1.4,0,2.54-1.14,2.54-2.54
|
||||
S30.13,69.29,28.73,69.29z"/>
|
||||
</g>
|
||||
</g>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 2.6 KiB |
93
resources/images/toolbar_measure.svg
Normal file
93
resources/images/toolbar_measure.svg
Normal file
|
|
@ -0,0 +1,93 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<!-- Generator: Adobe Illustrator 23.0.2, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
|
||||
|
||||
<svg
|
||||
version="1.0"
|
||||
id="Layer_1"
|
||||
x="0px"
|
||||
y="0px"
|
||||
viewBox="0 0 128 128"
|
||||
enable-background="new 0 0 128 128"
|
||||
xml:space="preserve"
|
||||
sodipodi:docname="measure2.svg"
|
||||
inkscape:version="1.1 (c68e22c387, 2021-05-23)"
|
||||
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
|
||||
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
xmlns:svg="http://www.w3.org/2000/svg"><defs
|
||||
id="defs976">
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</defs><sodipodi:namedview
|
||||
id="namedview974"
|
||||
pagecolor="#505050"
|
||||
bordercolor="#eeeeee"
|
||||
borderopacity="1"
|
||||
inkscape:pageshadow="0"
|
||||
inkscape:pageopacity="0"
|
||||
inkscape:pagecheckerboard="0"
|
||||
showgrid="false"
|
||||
inkscape:zoom="6.34375"
|
||||
inkscape:cx="63.921182"
|
||||
inkscape:cy="64.078818"
|
||||
inkscape:window-width="1920"
|
||||
inkscape:window-height="1001"
|
||||
inkscape:window-x="3191"
|
||||
inkscape:window-y="-9"
|
||||
inkscape:window-maximized="1"
|
||||
inkscape:current-layer="Layer_1" />
|
||||
<g
|
||||
id="g1872"><path
|
||||
fill="#009688"
|
||||
d="m 26.966044,54.457929 0.07558,-9.999714 c 0.0063,-0.829976 0.681318,-1.494893 1.511294,-1.48862 0.829976,0.0063 1.494893,0.681318 1.48862,1.511294 l -0.07558,9.999714 c -0.0063,0.829977 -0.681318,1.494894 -1.511294,1.48862 -0.829976,-0.0063 -1.494893,-0.681317 -1.48862,-1.511294 z"
|
||||
id="path958-8"
|
||||
style="fill:#009688;fill-opacity:1;paint-order:stroke fill markers"
|
||||
sodipodi:nodetypes="sccsccs" /><path
|
||||
fill="#009688"
|
||||
d="m 36.966044,54.458378 0.07558,-9.999714 c 0.0063,-0.829976 0.681318,-1.494893 1.511294,-1.48862 0.829976,0.0063 1.494893,0.681318 1.48862,1.511294 l -0.07558,9.999714 c -0.0063,0.829977 -0.681318,1.494894 -1.511294,1.48862 -0.829976,-0.0063 -1.494893,-0.681317 -1.48862,-1.511294 z"
|
||||
id="path958-8-1"
|
||||
style="fill:#009688;fill-opacity:1;paint-order:stroke fill markers"
|
||||
sodipodi:nodetypes="sccsccs" /><path
|
||||
fill="#009688"
|
||||
d="m 46.966202,60.202938 0.07558,-14.999888 c 0.0063,-1.244993 0.681318,-2.242399 1.511294,-2.232988 0.829976,0.0087 1.494893,1.021998 1.48862,2.266999 l -0.07558,14.999887 c -0.0063,1.244995 -0.681318,2.242401 -1.511294,2.232988 -0.829976,-0.0087 -1.494893,-1.021997 -1.48862,-2.266998 z"
|
||||
id="path958-8-9"
|
||||
style="fill:#009688;fill-opacity:1;stroke-width:1.22476;paint-order:stroke fill markers"
|
||||
sodipodi:nodetypes="sccsccs" /><path
|
||||
fill="#009688"
|
||||
d="m 56.966044,54.458378 0.07558,-9.999714 c 0.0063,-0.829976 0.681318,-1.494893 1.511294,-1.48862 0.829976,0.0063 1.494893,0.681318 1.48862,1.511294 l -0.07558,9.999714 c -0.0063,0.829977 -0.681318,1.494894 -1.511294,1.48862 -0.829976,-0.0063 -1.494893,-0.681317 -1.48862,-1.511294 z"
|
||||
id="path958-8-9-3"
|
||||
style="fill:#009688;fill-opacity:1;paint-order:stroke fill markers"
|
||||
sodipodi:nodetypes="sccsccs" /><path
|
||||
fill="#009688"
|
||||
d="m 66.966044,54.458378 0.07558,-9.999714 c 0.0063,-0.829976 0.681318,-1.494893 1.511294,-1.48862 0.829976,0.0063 1.494893,0.681318 1.48862,1.511294 l -0.07558,9.999714 c -0.0063,0.829977 -0.681318,1.494894 -1.511294,1.48862 -0.829976,-0.0063 -1.494893,-0.681317 -1.48862,-1.511294 z"
|
||||
id="path958-8-9-3-0"
|
||||
style="fill:#009688;fill-opacity:1;paint-order:stroke fill markers"
|
||||
sodipodi:nodetypes="sccsccs" /><path
|
||||
fill="#009688"
|
||||
d="m 76.966202,60.202932 0.07558,-14.999881 c 0.0063,-1.244994 0.681318,-2.2424 1.511294,-2.23299 0.829976,0.0085 1.494893,1.021998 1.48862,2.266999 l -0.07558,14.999882 c -0.0063,1.244995 -0.681318,2.2424 -1.511294,2.232987 -0.829976,-0.0085 -1.494893,-1.021996 -1.48862,-2.266997 z"
|
||||
id="path958-8-9-3-1"
|
||||
style="fill:#009688;fill-opacity:1;stroke-width:1.22474;paint-order:stroke fill markers"
|
||||
sodipodi:nodetypes="sccsccs" /><path
|
||||
fill="#009688"
|
||||
d="m 86.966044,54.458378 0.07558,-9.999714 c 0.0063,-0.829976 0.681318,-1.494893 1.511294,-1.48862 0.829976,0.0063 1.494893,0.681318 1.48862,1.511294 l -0.07558,9.999714 c -0.0063,0.829977 -0.681318,1.494894 -1.511294,1.48862 -0.829976,-0.0063 -1.494893,-0.681317 -1.48862,-1.511294 z"
|
||||
id="path958-8-9-3-1-4"
|
||||
style="fill:#009688;fill-opacity:1;paint-order:stroke fill markers"
|
||||
sodipodi:nodetypes="sccsccs" /><path
|
||||
fill="#009688"
|
||||
d="m 96.966044,54.458378 0.07558,-9.999714 c 0.0063,-0.829976 0.681318,-1.494893 1.511294,-1.48862 0.829976,0.0063 1.494892,0.681318 1.488622,1.511294 l -0.07558,9.999714 c -0.0063,0.829977 -0.681318,1.494894 -1.511294,1.48862 -0.829976,-0.0063 -1.494893,-0.681317 -1.48862,-1.511294 z"
|
||||
id="path958-8-9-3-1-4-2"
|
||||
style="fill:#009688;fill-opacity:1;paint-order:stroke fill markers"
|
||||
sodipodi:nodetypes="sccsccs" /></g><g
|
||||
id="g964"
|
||||
transform="translate(0,34.9)">
|
||||
<path
|
||||
fill="#262E30"
|
||||
d="M 108.79,51.6 H 19.21 c -1.93,0 -3.5,-1.57 -3.5,-3.5 V 10.12 c 0,-1.93 1.57,-3.5 3.5,-3.5 h 89.57 c 1.93,0 3.5,1.57 3.5,3.5 V 48.1 c 0.01,1.93 -1.57,3.5 -3.49,3.5 z M 19.21,9.62 c -0.27,0 -0.5,0.23 -0.5,0.5 V 48.1 c 0,0.27 0.23,0.5 0.5,0.5 h 89.57 c 0.27,0 0.5,-0.23 0.5,-0.5 V 10.12 c 0,-0.27 -0.23,-0.5 -0.5,-0.5 z"
|
||||
id="path962" />
|
||||
</g>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 5.1 KiB |
93
resources/images/toolbar_measure_dark.svg
Normal file
93
resources/images/toolbar_measure_dark.svg
Normal file
|
|
@ -0,0 +1,93 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<!-- Generator: Adobe Illustrator 23.0.2, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
|
||||
|
||||
<svg
|
||||
version="1.0"
|
||||
id="Layer_1"
|
||||
x="0px"
|
||||
y="0px"
|
||||
viewBox="0 0 128 128"
|
||||
enable-background="new 0 0 128 128"
|
||||
xml:space="preserve"
|
||||
sodipodi:docname="measure2.svg"
|
||||
inkscape:version="1.1 (c68e22c387, 2021-05-23)"
|
||||
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
|
||||
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
xmlns:svg="http://www.w3.org/2000/svg"><defs
|
||||
id="defs976">
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</defs><sodipodi:namedview
|
||||
id="namedview974"
|
||||
pagecolor="#505050"
|
||||
bordercolor="#eeeeee"
|
||||
borderopacity="1"
|
||||
inkscape:pageshadow="0"
|
||||
inkscape:pageopacity="0"
|
||||
inkscape:pagecheckerboard="0"
|
||||
showgrid="false"
|
||||
inkscape:zoom="6.34375"
|
||||
inkscape:cx="63.921182"
|
||||
inkscape:cy="64.078818"
|
||||
inkscape:window-width="1920"
|
||||
inkscape:window-height="1001"
|
||||
inkscape:window-x="3191"
|
||||
inkscape:window-y="-9"
|
||||
inkscape:window-maximized="1"
|
||||
inkscape:current-layer="Layer_1" />
|
||||
<g
|
||||
id="g1872"><path
|
||||
fill="#009688"
|
||||
d="m 26.966044,54.457929 0.07558,-9.999714 c 0.0063,-0.829976 0.681318,-1.494893 1.511294,-1.48862 0.829976,0.0063 1.494893,0.681318 1.48862,1.511294 l -0.07558,9.999714 c -0.0063,0.829977 -0.681318,1.494894 -1.511294,1.48862 -0.829976,-0.0063 -1.494893,-0.681317 -1.48862,-1.511294 z"
|
||||
id="path958-8"
|
||||
style="fill:#009688;fill-opacity:1;paint-order:stroke fill markers"
|
||||
sodipodi:nodetypes="sccsccs" /><path
|
||||
fill="#009688"
|
||||
d="m 36.966044,54.458378 0.07558,-9.999714 c 0.0063,-0.829976 0.681318,-1.494893 1.511294,-1.48862 0.829976,0.0063 1.494893,0.681318 1.48862,1.511294 l -0.07558,9.999714 c -0.0063,0.829977 -0.681318,1.494894 -1.511294,1.48862 -0.829976,-0.0063 -1.494893,-0.681317 -1.48862,-1.511294 z"
|
||||
id="path958-8-1"
|
||||
style="fill:#009688;fill-opacity:1;paint-order:stroke fill markers"
|
||||
sodipodi:nodetypes="sccsccs" /><path
|
||||
fill="#009688"
|
||||
d="m 46.966202,60.202938 0.07558,-14.999888 c 0.0063,-1.244993 0.681318,-2.242399 1.511294,-2.232988 0.829976,0.0087 1.494893,1.021998 1.48862,2.266999 l -0.07558,14.999887 c -0.0063,1.244995 -0.681318,2.242401 -1.511294,2.232988 -0.829976,-0.0087 -1.494893,-1.021997 -1.48862,-2.266998 z"
|
||||
id="path958-8-9"
|
||||
style="fill:#009688;fill-opacity:1;stroke-width:1.22476;paint-order:stroke fill markers"
|
||||
sodipodi:nodetypes="sccsccs" /><path
|
||||
fill="#009688"
|
||||
d="m 56.966044,54.458378 0.07558,-9.999714 c 0.0063,-0.829976 0.681318,-1.494893 1.511294,-1.48862 0.829976,0.0063 1.494893,0.681318 1.48862,1.511294 l -0.07558,9.999714 c -0.0063,0.829977 -0.681318,1.494894 -1.511294,1.48862 -0.829976,-0.0063 -1.494893,-0.681317 -1.48862,-1.511294 z"
|
||||
id="path958-8-9-3"
|
||||
style="fill:#009688;fill-opacity:1;paint-order:stroke fill markers"
|
||||
sodipodi:nodetypes="sccsccs" /><path
|
||||
fill="#009688"
|
||||
d="m 66.966044,54.458378 0.07558,-9.999714 c 0.0063,-0.829976 0.681318,-1.494893 1.511294,-1.48862 0.829976,0.0063 1.494893,0.681318 1.48862,1.511294 l -0.07558,9.999714 c -0.0063,0.829977 -0.681318,1.494894 -1.511294,1.48862 -0.829976,-0.0063 -1.494893,-0.681317 -1.48862,-1.511294 z"
|
||||
id="path958-8-9-3-0"
|
||||
style="fill:#009688;fill-opacity:1;paint-order:stroke fill markers"
|
||||
sodipodi:nodetypes="sccsccs" /><path
|
||||
fill="#009688"
|
||||
d="m 76.966202,60.202932 0.07558,-14.999881 c 0.0063,-1.244994 0.681318,-2.2424 1.511294,-2.23299 0.829976,0.0085 1.494893,1.021998 1.48862,2.266999 l -0.07558,14.999882 c -0.0063,1.244995 -0.681318,2.2424 -1.511294,2.232987 -0.829976,-0.0085 -1.494893,-1.021996 -1.48862,-2.266997 z"
|
||||
id="path958-8-9-3-1"
|
||||
style="fill:#009688;fill-opacity:1;stroke-width:1.22474;paint-order:stroke fill markers"
|
||||
sodipodi:nodetypes="sccsccs" /><path
|
||||
fill="#009688"
|
||||
d="m 86.966044,54.458378 0.07558,-9.999714 c 0.0063,-0.829976 0.681318,-1.494893 1.511294,-1.48862 0.829976,0.0063 1.494893,0.681318 1.48862,1.511294 l -0.07558,9.999714 c -0.0063,0.829977 -0.681318,1.494894 -1.511294,1.48862 -0.829976,-0.0063 -1.494893,-0.681317 -1.48862,-1.511294 z"
|
||||
id="path958-8-9-3-1-4"
|
||||
style="fill:#009688;fill-opacity:1;paint-order:stroke fill markers"
|
||||
sodipodi:nodetypes="sccsccs" /><path
|
||||
fill="#009688"
|
||||
d="m 96.966044,54.458378 0.07558,-9.999714 c 0.0063,-0.829976 0.681318,-1.494893 1.511294,-1.48862 0.829976,0.0063 1.494892,0.681318 1.488622,1.511294 l -0.07558,9.999714 c -0.0063,0.829977 -0.681318,1.494894 -1.511294,1.48862 -0.829976,-0.0063 -1.494893,-0.681317 -1.48862,-1.511294 z"
|
||||
id="path958-8-9-3-1-4-2"
|
||||
style="fill:#009688;fill-opacity:1;paint-order:stroke fill markers"
|
||||
sodipodi:nodetypes="sccsccs" /></g><g
|
||||
id="g964"
|
||||
transform="translate(0,34.9)">
|
||||
<path
|
||||
fill="#B6B6B6"
|
||||
d="M 108.79,51.6 H 19.21 c -1.93,0 -3.5,-1.57 -3.5,-3.5 V 10.12 c 0,-1.93 1.57,-3.5 3.5,-3.5 h 89.57 c 1.93,0 3.5,1.57 3.5,3.5 V 48.1 c 0.01,1.93 -1.57,3.5 -3.49,3.5 z M 19.21,9.62 c -0.27,0 -0.5,0.23 -0.5,0.5 V 48.1 c 0,0.27 0.23,0.5 0.5,0.5 h 89.57 c 0.27,0 0.5,-0.23 0.5,-0.5 V 10.12 c 0,-0.27 -0.23,-0.5 -0.5,-0.5 z"
|
||||
id="path962" />
|
||||
</g>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 5.1 KiB |
11
resources/shaders/110/background.fs
Normal file
11
resources/shaders/110/background.fs
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
#version 110
|
||||
|
||||
uniform vec4 top_color;
|
||||
uniform vec4 bottom_color;
|
||||
|
||||
varying vec2 tex_coord;
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_FragColor = mix(bottom_color, top_color, tex_coord.y);
|
||||
}
|
||||
12
resources/shaders/110/background.vs
Normal file
12
resources/shaders/110/background.vs
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
#version 110
|
||||
|
||||
attribute vec3 v_position;
|
||||
attribute vec2 v_tex_coord;
|
||||
|
||||
varying vec2 tex_coord;
|
||||
|
||||
void main()
|
||||
{
|
||||
tex_coord = v_tex_coord;
|
||||
gl_Position = vec4(v_position, 1.0);
|
||||
}
|
||||
11
resources/shaders/110/flat.vs
Normal file
11
resources/shaders/110/flat.vs
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
#version 110
|
||||
|
||||
uniform mat4 view_model_matrix;
|
||||
uniform mat4 projection_matrix;
|
||||
|
||||
attribute vec3 v_position;
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_Position = projection_matrix * view_model_matrix * vec4(v_position, 1.0);
|
||||
}
|
||||
15
resources/shaders/110/flat_clip.fs
Normal file
15
resources/shaders/110/flat_clip.fs
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
#version 110
|
||||
|
||||
const vec3 ZERO = vec3(0.0, 0.0, 0.0);
|
||||
|
||||
uniform vec4 uniform_color;
|
||||
|
||||
varying vec3 clipping_planes_dots;
|
||||
|
||||
void main()
|
||||
{
|
||||
if (any(lessThan(clipping_planes_dots, ZERO)))
|
||||
discard;
|
||||
|
||||
gl_FragColor = uniform_color;
|
||||
}
|
||||
23
resources/shaders/110/flat_clip.vs
Normal file
23
resources/shaders/110/flat_clip.vs
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
#version 110
|
||||
|
||||
uniform mat4 view_model_matrix;
|
||||
uniform mat4 projection_matrix;
|
||||
uniform mat4 volume_world_matrix;
|
||||
|
||||
// Clipping plane, x = min z, y = max z. Used by the FFF and SLA previews to clip with a top / bottom plane.
|
||||
uniform vec2 z_range;
|
||||
// Clipping plane - general orientation. Used by the SLA gizmo.
|
||||
uniform vec4 clipping_plane;
|
||||
|
||||
attribute vec3 v_position;
|
||||
|
||||
varying vec3 clipping_planes_dots;
|
||||
|
||||
void main()
|
||||
{
|
||||
// Fill in the scalars for fragment shader clipping. Fragments with any of these components lower than zero are discarded.
|
||||
vec4 world_pos = volume_world_matrix * vec4(v_position, 1.0);
|
||||
clipping_planes_dots = vec3(dot(world_pos, clipping_plane), world_pos.z - z_range.x, z_range.y - world_pos.z);
|
||||
|
||||
gl_Position = projection_matrix * view_model_matrix * vec4(v_position, 1.0);
|
||||
}
|
||||
10
resources/shaders/110/flat_texture.fs
Normal file
10
resources/shaders/110/flat_texture.fs
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
#version 110
|
||||
|
||||
uniform sampler2D uniform_texture;
|
||||
|
||||
varying vec2 tex_coord;
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_FragColor = texture2D(uniform_texture, tex_coord);
|
||||
}
|
||||
15
resources/shaders/110/flat_texture.vs
Normal file
15
resources/shaders/110/flat_texture.vs
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
#version 110
|
||||
|
||||
uniform mat4 view_model_matrix;
|
||||
uniform mat4 projection_matrix;
|
||||
|
||||
attribute vec3 v_position;
|
||||
attribute vec2 v_tex_coord;
|
||||
|
||||
varying vec2 tex_coord;
|
||||
|
||||
void main()
|
||||
{
|
||||
tex_coord = v_tex_coord;
|
||||
gl_Position = projection_matrix * view_model_matrix * vec4(v_position, 1.0);
|
||||
}
|
||||
107
resources/shaders/110/gouraud.fs
Normal file
107
resources/shaders/110/gouraud.fs
Normal file
|
|
@ -0,0 +1,107 @@
|
|||
#version 110
|
||||
|
||||
const vec3 ZERO = vec3(0.0, 0.0, 0.0);
|
||||
//BBS: add grey and orange
|
||||
//const vec3 GREY = vec3(0.9, 0.9, 0.9);
|
||||
const vec3 ORANGE = vec3(0.8, 0.4, 0.0);
|
||||
const vec3 LightRed = vec3(0.78, 0.0, 0.0);
|
||||
const vec3 LightBlue = vec3(0.73, 1.0, 1.0);
|
||||
const float EPSILON = 0.0001;
|
||||
|
||||
struct PrintVolumeDetection
|
||||
{
|
||||
// 0 = rectangle, 1 = circle, 2 = custom, 3 = invalid
|
||||
int type;
|
||||
// type = 0 (rectangle):
|
||||
// x = min.x, y = min.y, z = max.x, w = max.y
|
||||
// type = 1 (circle):
|
||||
// x = center.x, y = center.y, z = radius
|
||||
vec4 xy_data;
|
||||
// x = min z, y = max z
|
||||
vec2 z_data;
|
||||
};
|
||||
|
||||
struct SlopeDetection
|
||||
{
|
||||
bool actived;
|
||||
float normal_z;
|
||||
mat3 volume_world_normal_matrix;
|
||||
};
|
||||
|
||||
uniform vec4 uniform_color;
|
||||
uniform bool use_color_clip_plane;
|
||||
uniform vec4 uniform_color_clip_plane_1;
|
||||
uniform vec4 uniform_color_clip_plane_2;
|
||||
uniform SlopeDetection slope;
|
||||
|
||||
//BBS: add outline_color
|
||||
uniform bool is_outline;
|
||||
|
||||
#ifdef ENABLE_ENVIRONMENT_MAP
|
||||
uniform sampler2D environment_tex;
|
||||
uniform bool use_environment_tex;
|
||||
#endif // ENABLE_ENVIRONMENT_MAP
|
||||
|
||||
uniform PrintVolumeDetection print_volume;
|
||||
|
||||
varying vec3 clipping_planes_dots;
|
||||
varying float color_clip_plane_dot;
|
||||
|
||||
// x = diffuse, y = specular;
|
||||
varying vec2 intensity;
|
||||
|
||||
varying vec4 world_pos;
|
||||
varying float world_normal_z;
|
||||
varying vec3 eye_normal;
|
||||
|
||||
void main()
|
||||
{
|
||||
if (any(lessThan(clipping_planes_dots, ZERO)))
|
||||
discard;
|
||||
|
||||
vec4 color;
|
||||
if (use_color_clip_plane) {
|
||||
color.rgb = (color_clip_plane_dot < 0.0) ? uniform_color_clip_plane_1.rgb : uniform_color_clip_plane_2.rgb;
|
||||
color.a = uniform_color.a;
|
||||
}
|
||||
else
|
||||
color = uniform_color;
|
||||
|
||||
if (slope.actived) {
|
||||
if(world_pos.z<0.1&&world_pos.z>-0.1)
|
||||
{
|
||||
color.rgb = LightBlue;
|
||||
color.a = 0.8;
|
||||
}
|
||||
else if( world_normal_z < slope.normal_z - EPSILON)
|
||||
{
|
||||
color.rgb = color.rgb * 0.5 + LightRed * 0.5;
|
||||
color.a = 0.8;
|
||||
}
|
||||
}
|
||||
// if the fragment is outside the print volume -> use darker color
|
||||
vec3 pv_check_min = ZERO;
|
||||
vec3 pv_check_max = ZERO;
|
||||
if (print_volume.type == 0) {
|
||||
// rectangle
|
||||
pv_check_min = world_pos.xyz - vec3(print_volume.xy_data.x, print_volume.xy_data.y, print_volume.z_data.x);
|
||||
pv_check_max = world_pos.xyz - vec3(print_volume.xy_data.z, print_volume.xy_data.w, print_volume.z_data.y);
|
||||
}
|
||||
else if (print_volume.type == 1) {
|
||||
// circle
|
||||
float delta_radius = print_volume.xy_data.z - distance(world_pos.xy, print_volume.xy_data.xy);
|
||||
pv_check_min = vec3(delta_radius, 0.0, world_pos.z - print_volume.z_data.x);
|
||||
pv_check_max = vec3(0.0, 0.0, world_pos.z - print_volume.z_data.y);
|
||||
}
|
||||
color.rgb = (any(lessThan(pv_check_min, ZERO)) || any(greaterThan(pv_check_max, ZERO))) ? mix(color.rgb, ZERO, 0.3333) : color.rgb;
|
||||
|
||||
//BBS: add outline_color
|
||||
if (is_outline)
|
||||
gl_FragColor = uniform_color;
|
||||
#ifdef ENABLE_ENVIRONMENT_MAP
|
||||
else if (use_environment_tex)
|
||||
gl_FragColor = vec4(0.45 * texture(environment_tex, normalize(eye_normal).xy * 0.5 + 0.5).xyz + 0.8 * color.rgb * intensity.x, color.a);
|
||||
#endif
|
||||
else
|
||||
gl_FragColor = vec4(vec3(intensity.y) + color.rgb * intensity.x, color.a);
|
||||
}
|
||||
81
resources/shaders/110/gouraud.vs
Normal file
81
resources/shaders/110/gouraud.vs
Normal file
|
|
@ -0,0 +1,81 @@
|
|||
#version 110
|
||||
|
||||
#define INTENSITY_CORRECTION 0.6
|
||||
|
||||
// normalized values for (-0.6/1.31, 0.6/1.31, 1./1.31)
|
||||
const vec3 LIGHT_TOP_DIR = vec3(-0.4574957, 0.4574957, 0.7624929);
|
||||
#define LIGHT_TOP_DIFFUSE (0.8 * INTENSITY_CORRECTION)
|
||||
#define LIGHT_TOP_SPECULAR (0.125 * INTENSITY_CORRECTION)
|
||||
#define LIGHT_TOP_SHININESS 20.0
|
||||
|
||||
// normalized values for (1./1.43, 0.2/1.43, 1./1.43)
|
||||
const vec3 LIGHT_FRONT_DIR = vec3(0.6985074, 0.1397015, 0.6985074);
|
||||
#define LIGHT_FRONT_DIFFUSE (0.3 * INTENSITY_CORRECTION)
|
||||
//#define LIGHT_FRONT_SPECULAR (0.0 * INTENSITY_CORRECTION)
|
||||
//#define LIGHT_FRONT_SHININESS 5.0
|
||||
|
||||
#define INTENSITY_AMBIENT 0.3
|
||||
|
||||
const vec3 ZERO = vec3(0.0, 0.0, 0.0);
|
||||
|
||||
struct SlopeDetection
|
||||
{
|
||||
bool actived;
|
||||
float normal_z;
|
||||
mat3 volume_world_normal_matrix;
|
||||
};
|
||||
|
||||
uniform mat4 view_model_matrix;
|
||||
uniform mat4 projection_matrix;
|
||||
uniform mat3 view_normal_matrix;
|
||||
uniform mat4 volume_world_matrix;
|
||||
uniform SlopeDetection slope;
|
||||
|
||||
// Clipping plane, x = min z, y = max z. Used by the FFF and SLA previews to clip with a top / bottom plane.
|
||||
uniform vec2 z_range;
|
||||
// Clipping plane - general orientation. Used by the SLA gizmo.
|
||||
uniform vec4 clipping_plane;
|
||||
// Color clip plane - general orientation. Used by the cut gizmo.
|
||||
uniform vec4 color_clip_plane;
|
||||
|
||||
attribute vec3 v_position;
|
||||
attribute vec3 v_normal;
|
||||
|
||||
// x = diffuse, y = specular;
|
||||
varying vec2 intensity;
|
||||
|
||||
varying vec3 clipping_planes_dots;
|
||||
varying float color_clip_plane_dot;
|
||||
|
||||
varying vec4 world_pos;
|
||||
varying float world_normal_z;
|
||||
varying vec3 eye_normal;
|
||||
|
||||
void main()
|
||||
{
|
||||
// First transform the normal into camera space and normalize the result.
|
||||
eye_normal = normalize(view_normal_matrix * v_normal);
|
||||
|
||||
// Compute the cos of the angle between the normal and lights direction. The light is directional so the direction is constant for every vertex.
|
||||
// Since these two are normalized the cosine is the dot product. We also need to clamp the result to the [0,1] range.
|
||||
float NdotL = max(dot(eye_normal, LIGHT_TOP_DIR), 0.0);
|
||||
|
||||
intensity.x = INTENSITY_AMBIENT + NdotL * LIGHT_TOP_DIFFUSE;
|
||||
vec4 position = view_model_matrix * vec4(v_position, 1.0);
|
||||
intensity.y = LIGHT_TOP_SPECULAR * pow(max(dot(-normalize(position.xyz), reflect(-LIGHT_TOP_DIR, eye_normal)), 0.0), LIGHT_TOP_SHININESS);
|
||||
|
||||
// Perform the same lighting calculation for the 2nd light source (no specular applied).
|
||||
NdotL = max(dot(eye_normal, LIGHT_FRONT_DIR), 0.0);
|
||||
intensity.x += NdotL * LIGHT_FRONT_DIFFUSE;
|
||||
|
||||
// Point in homogenous coordinates.
|
||||
world_pos = volume_world_matrix * vec4(v_position, 1.0);
|
||||
|
||||
// z component of normal vector in world coordinate used for slope shading
|
||||
world_normal_z = slope.actived ? (normalize(slope.volume_world_normal_matrix * v_normal)).z : 0.0;
|
||||
|
||||
gl_Position = projection_matrix * position;
|
||||
// Fill in the scalars for fragment shader clipping. Fragments with any of these components lower than zero are discarded.
|
||||
clipping_planes_dots = vec3(dot(world_pos, clipping_plane), world_pos.z - z_range.x, z_range.y - world_pos.z);
|
||||
color_clip_plane_dot = dot(world_pos, color_clip_plane);
|
||||
}
|
||||
12
resources/shaders/110/gouraud_light.fs
Normal file
12
resources/shaders/110/gouraud_light.fs
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
#version 110
|
||||
|
||||
uniform vec4 uniform_color;
|
||||
uniform float emission_factor;
|
||||
|
||||
// x = tainted, y = specular;
|
||||
varying vec2 intensity;
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_FragColor = vec4(vec3(intensity.y) + uniform_color.rgb * (intensity.x + emission_factor), uniform_color.a);
|
||||
}
|
||||
45
resources/shaders/110/gouraud_light.vs
Normal file
45
resources/shaders/110/gouraud_light.vs
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
#version 110
|
||||
|
||||
#define INTENSITY_CORRECTION 0.6
|
||||
|
||||
// normalized values for (-0.6/1.31, 0.6/1.31, 1./1.31)
|
||||
const vec3 LIGHT_TOP_DIR = vec3(-0.4574957, 0.4574957, 0.7624929);
|
||||
#define LIGHT_TOP_DIFFUSE (0.8 * INTENSITY_CORRECTION)
|
||||
#define LIGHT_TOP_SPECULAR (0.125 * INTENSITY_CORRECTION)
|
||||
#define LIGHT_TOP_SHININESS 20.0
|
||||
|
||||
// normalized values for (1./1.43, 0.2/1.43, 1./1.43)
|
||||
const vec3 LIGHT_FRONT_DIR = vec3(0.6985074, 0.1397015, 0.6985074);
|
||||
#define LIGHT_FRONT_DIFFUSE (0.3 * INTENSITY_CORRECTION)
|
||||
|
||||
#define INTENSITY_AMBIENT 0.3
|
||||
|
||||
uniform mat4 view_model_matrix;
|
||||
uniform mat4 projection_matrix;
|
||||
uniform mat3 view_normal_matrix;
|
||||
|
||||
attribute vec3 v_position;
|
||||
attribute vec3 v_normal;
|
||||
|
||||
// x = tainted, y = specular;
|
||||
varying vec2 intensity;
|
||||
|
||||
void main()
|
||||
{
|
||||
// First transform the normal into camera space and normalize the result.
|
||||
vec3 normal = normalize(view_normal_matrix * v_normal);
|
||||
|
||||
// Compute the cos of the angle between the normal and lights direction. The light is directional so the direction is constant for every vertex.
|
||||
// Since these two are normalized the cosine is the dot product. We also need to clamp the result to the [0,1] range.
|
||||
float NdotL = max(dot(normal, LIGHT_TOP_DIR), 0.0);
|
||||
|
||||
intensity.x = INTENSITY_AMBIENT + NdotL * LIGHT_TOP_DIFFUSE;
|
||||
vec4 position = view_model_matrix * vec4(v_position, 1.0);
|
||||
intensity.y = LIGHT_TOP_SPECULAR * pow(max(dot(-normalize(position.xyz), reflect(-LIGHT_TOP_DIR, normal)), 0.0), LIGHT_TOP_SHININESS);
|
||||
|
||||
// Perform the same lighting calculation for the 2nd light source (no specular applied).
|
||||
NdotL = max(dot(normal, LIGHT_FRONT_DIR), 0.0);
|
||||
intensity.x += NdotL * LIGHT_FRONT_DIFFUSE;
|
||||
|
||||
gl_Position = projection_matrix * position;
|
||||
}
|
||||
12
resources/shaders/110/gouraud_light_instanced.fs
Normal file
12
resources/shaders/110/gouraud_light_instanced.fs
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
#version 110
|
||||
|
||||
uniform vec4 uniform_color;
|
||||
uniform float emission_factor;
|
||||
|
||||
// x = tainted, y = specular;
|
||||
varying vec2 intensity;
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_FragColor = vec4(vec3(intensity.y) + uniform_color.rgb * (intensity.x + emission_factor), uniform_color.a);
|
||||
}
|
||||
50
resources/shaders/110/gouraud_light_instanced.vs
Normal file
50
resources/shaders/110/gouraud_light_instanced.vs
Normal file
|
|
@ -0,0 +1,50 @@
|
|||
#version 110
|
||||
|
||||
#define INTENSITY_CORRECTION 0.6
|
||||
|
||||
// normalized values for (-0.6/1.31, 0.6/1.31, 1./1.31)
|
||||
const vec3 LIGHT_TOP_DIR = vec3(-0.4574957, 0.4574957, 0.7624929);
|
||||
#define LIGHT_TOP_DIFFUSE (0.8 * INTENSITY_CORRECTION)
|
||||
#define LIGHT_TOP_SPECULAR (0.125 * INTENSITY_CORRECTION)
|
||||
#define LIGHT_TOP_SHININESS 20.0
|
||||
|
||||
// normalized values for (1./1.43, 0.2/1.43, 1./1.43)
|
||||
const vec3 LIGHT_FRONT_DIR = vec3(0.6985074, 0.1397015, 0.6985074);
|
||||
#define LIGHT_FRONT_DIFFUSE (0.3 * INTENSITY_CORRECTION)
|
||||
|
||||
#define INTENSITY_AMBIENT 0.3
|
||||
|
||||
uniform mat4 view_model_matrix;
|
||||
uniform mat4 projection_matrix;
|
||||
uniform mat3 view_normal_matrix;
|
||||
|
||||
// vertex attributes
|
||||
attribute vec3 v_position;
|
||||
attribute vec3 v_normal;
|
||||
// instance attributes
|
||||
attribute vec3 i_offset;
|
||||
attribute vec2 i_scales;
|
||||
|
||||
// x = tainted, y = specular;
|
||||
varying vec2 intensity;
|
||||
|
||||
void main()
|
||||
{
|
||||
// First transform the normal into camera space and normalize the result.
|
||||
vec3 eye_normal = normalize(view_normal_matrix * v_normal);
|
||||
|
||||
// Compute the cos of the angle between the normal and lights direction. The light is directional so the direction is constant for every vertex.
|
||||
// Since these two are normalized the cosine is the dot product. We also need to clamp the result to the [0,1] range.
|
||||
float NdotL = max(dot(eye_normal, LIGHT_TOP_DIR), 0.0);
|
||||
|
||||
intensity.x = INTENSITY_AMBIENT + NdotL * LIGHT_TOP_DIFFUSE;
|
||||
vec4 world_position = vec4(v_position * vec3(vec2(1.5 * i_scales.x), 1.5 * i_scales.y) + i_offset - vec3(0.0, 0.0, 0.5 * i_scales.y), 1.0);
|
||||
vec4 eye_position = view_model_matrix * world_position;
|
||||
intensity.y = LIGHT_TOP_SPECULAR * pow(max(dot(-normalize(eye_position.xyz), reflect(-LIGHT_TOP_DIR, eye_normal)), 0.0), LIGHT_TOP_SHININESS);
|
||||
|
||||
// Perform the same lighting calculation for the 2nd light source (no specular applied).
|
||||
NdotL = max(dot(eye_normal, LIGHT_FRONT_DIR), 0.0);
|
||||
intensity.x += NdotL * LIGHT_FRONT_DIFFUSE;
|
||||
|
||||
gl_Position = projection_matrix * eye_position;
|
||||
}
|
||||
11
resources/shaders/110/imgui.fs
Normal file
11
resources/shaders/110/imgui.fs
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
#version 110
|
||||
|
||||
uniform sampler2D Texture;
|
||||
|
||||
varying vec2 Frag_UV;
|
||||
varying vec4 Frag_Color;
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_FragColor = Frag_Color * texture2D(Texture, Frag_UV.st);
|
||||
}
|
||||
17
resources/shaders/110/imgui.vs
Normal file
17
resources/shaders/110/imgui.vs
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
#version 110
|
||||
|
||||
uniform mat4 ProjMtx;
|
||||
|
||||
attribute vec2 Position;
|
||||
attribute vec2 UV;
|
||||
attribute vec4 Color;
|
||||
|
||||
varying vec2 Frag_UV;
|
||||
varying vec4 Frag_Color;
|
||||
|
||||
void main()
|
||||
{
|
||||
Frag_UV = UV;
|
||||
Frag_Color = Color;
|
||||
gl_Position = ProjMtx * vec4(Position.xy, 0.0, 1.0);
|
||||
}
|
||||
15
resources/shaders/110/mm_contour.vs
Normal file
15
resources/shaders/110/mm_contour.vs
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
#version 110
|
||||
|
||||
uniform mat4 view_model_matrix;
|
||||
uniform mat4 projection_matrix;
|
||||
uniform float offset;
|
||||
|
||||
attribute vec3 v_position;
|
||||
|
||||
void main()
|
||||
{
|
||||
// Add small epsilon to z to solve z-fighting between painted triangles and contour lines.
|
||||
vec4 clip_position = projection_matrix * view_model_matrix * vec4(v_position, 1.0);
|
||||
clip_position.z -= offset * abs(clip_position.w);
|
||||
gl_Position = clip_position;
|
||||
}
|
||||
90
resources/shaders/110/mm_gouraud.fs
Normal file
90
resources/shaders/110/mm_gouraud.fs
Normal file
|
|
@ -0,0 +1,90 @@
|
|||
#version 110
|
||||
|
||||
#define INTENSITY_CORRECTION 0.6
|
||||
|
||||
// normalized values for (-0.6/1.31, 0.6/1.31, 1./1.31)
|
||||
const vec3 LIGHT_TOP_DIR = vec3(-0.4574957, 0.4574957, 0.7624929);
|
||||
#define LIGHT_TOP_DIFFUSE (0.8 * INTENSITY_CORRECTION)
|
||||
#define LIGHT_TOP_SPECULAR (0.125 * INTENSITY_CORRECTION)
|
||||
#define LIGHT_TOP_SHININESS 20.0
|
||||
|
||||
// normalized values for (1./1.43, 0.2/1.43, 1./1.43)
|
||||
const vec3 LIGHT_FRONT_DIR = vec3(0.6985074, 0.1397015, 0.6985074);
|
||||
#define LIGHT_FRONT_DIFFUSE (0.3 * INTENSITY_CORRECTION)
|
||||
|
||||
#define INTENSITY_AMBIENT 0.3
|
||||
|
||||
const vec3 ZERO = vec3(0.0, 0.0, 0.0);
|
||||
const float EPSILON = 0.0001;
|
||||
//BBS: add grey and orange
|
||||
//const vec3 GREY = vec3(0.9, 0.9, 0.9);
|
||||
const vec3 ORANGE = vec3(0.8, 0.4, 0.0);
|
||||
const vec3 LightRed = vec3(0.78, 0.0, 0.0);
|
||||
const vec3 LightBlue = vec3(0.73, 1.0, 1.0);
|
||||
uniform vec4 uniform_color;
|
||||
|
||||
uniform bool volume_mirrored;
|
||||
|
||||
uniform mat4 view_model_matrix;
|
||||
uniform mat3 view_normal_matrix;
|
||||
|
||||
varying vec3 clipping_planes_dots;
|
||||
varying vec4 model_pos;
|
||||
varying vec4 world_pos;
|
||||
|
||||
struct SlopeDetection
|
||||
{
|
||||
bool actived;
|
||||
float normal_z;
|
||||
mat3 volume_world_normal_matrix;
|
||||
};
|
||||
uniform SlopeDetection slope;
|
||||
|
||||
void main()
|
||||
{
|
||||
if (any(lessThan(clipping_planes_dots, ZERO)))
|
||||
discard;
|
||||
vec3 color = uniform_color.rgb;
|
||||
float alpha = uniform_color.a;
|
||||
|
||||
vec3 triangle_normal = normalize(cross(dFdx(model_pos.xyz), dFdy(model_pos.xyz)));
|
||||
#ifdef FLIP_TRIANGLE_NORMALS
|
||||
triangle_normal = -triangle_normal;
|
||||
#endif
|
||||
|
||||
if (volume_mirrored)
|
||||
triangle_normal = -triangle_normal;
|
||||
|
||||
vec3 transformed_normal = normalize(slope.volume_world_normal_matrix * triangle_normal);
|
||||
|
||||
if (slope.actived) {
|
||||
if(world_pos.z<0.1&&world_pos.z>-0.1)
|
||||
{
|
||||
color = LightBlue;
|
||||
alpha = 1.0;
|
||||
}
|
||||
else if( transformed_normal.z < slope.normal_z - EPSILON)
|
||||
{
|
||||
color = color * 0.5 + LightRed * 0.5;
|
||||
alpha = 1.0;
|
||||
}
|
||||
}
|
||||
// First transform the normal into camera space and normalize the result.
|
||||
vec3 eye_normal = normalize(view_normal_matrix * triangle_normal);
|
||||
|
||||
// Compute the cos of the angle between the normal and lights direction. The light is directional so the direction is constant for every vertex.
|
||||
// Since these two are normalized the cosine is the dot product. We also need to clamp the result to the [0,1] range.
|
||||
float NdotL = max(dot(eye_normal, LIGHT_TOP_DIR), 0.0);
|
||||
|
||||
// x = diffuse, y = specular;
|
||||
vec2 intensity = vec2(0.0);
|
||||
intensity.x = INTENSITY_AMBIENT + NdotL * LIGHT_TOP_DIFFUSE;
|
||||
vec3 position = (view_model_matrix * model_pos).xyz;
|
||||
intensity.y = LIGHT_TOP_SPECULAR * pow(max(dot(-normalize(position), reflect(-LIGHT_TOP_DIR, eye_normal)), 0.0), LIGHT_TOP_SHININESS);
|
||||
|
||||
// Perform the same lighting calculation for the 2nd light source (no specular applied).
|
||||
NdotL = max(dot(eye_normal, LIGHT_FRONT_DIR), 0.0);
|
||||
intensity.x += NdotL * LIGHT_FRONT_DIFFUSE;
|
||||
|
||||
gl_FragColor = vec4(vec3(intensity.y) + color * intensity.x, alpha);
|
||||
}
|
||||
35
resources/shaders/110/mm_gouraud.vs
Normal file
35
resources/shaders/110/mm_gouraud.vs
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
#version 110
|
||||
|
||||
const vec3 ZERO = vec3(0.0, 0.0, 0.0);
|
||||
|
||||
uniform mat4 view_model_matrix;
|
||||
uniform mat4 projection_matrix;
|
||||
|
||||
uniform mat4 volume_world_matrix;
|
||||
// Clipping plane, x = min z, y = max z. Used by the FFF and SLA previews to clip with a top / bottom plane.
|
||||
uniform vec2 z_range;
|
||||
// Clipping plane - general orientation. Used by the SLA gizmo.
|
||||
uniform vec4 clipping_plane;
|
||||
|
||||
attribute vec3 v_position;
|
||||
|
||||
varying vec3 clipping_planes_dots;
|
||||
varying vec4 model_pos;
|
||||
varying vec4 world_pos;
|
||||
struct SlopeDetection
|
||||
{
|
||||
bool actived;
|
||||
float normal_z;
|
||||
mat3 volume_world_normal_matrix;
|
||||
};
|
||||
uniform SlopeDetection slope;
|
||||
void main()
|
||||
{
|
||||
model_pos = vec4(v_position, 1.0);
|
||||
// Point in homogenous coordinates.
|
||||
world_pos = volume_world_matrix * model_pos;
|
||||
|
||||
gl_Position = projection_matrix * view_model_matrix * model_pos;
|
||||
// Fill in the scalars for fragment shader clipping. Fragments with any of these components lower than zero are discarded.
|
||||
clipping_planes_dots = vec3(dot(world_pos, clipping_plane), world_pos.z - z_range.x, z_range.y - world_pos.z);
|
||||
}
|
||||
34
resources/shaders/110/printbed.fs
Normal file
34
resources/shaders/110/printbed.fs
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
#version 110
|
||||
|
||||
const vec3 back_color_dark = vec3(0.235, 0.235, 0.235);
|
||||
const vec3 back_color_light = vec3(0.365, 0.365, 0.365);
|
||||
|
||||
uniform sampler2D texture;
|
||||
uniform bool transparent_background;
|
||||
uniform bool svg_source;
|
||||
|
||||
varying vec2 tex_coord;
|
||||
|
||||
vec4 svg_color()
|
||||
{
|
||||
// takes foreground from texture
|
||||
vec4 fore_color = texture2D(texture, tex_coord);
|
||||
|
||||
// calculates radial gradient
|
||||
vec3 back_color = vec3(mix(back_color_light, back_color_dark, smoothstep(0.0, 0.5, length(abs(tex_coord.xy) - vec2(0.5)))));
|
||||
|
||||
// blends foreground with background
|
||||
return vec4(mix(back_color, fore_color.rgb, fore_color.a), transparent_background ? fore_color.a : 1.0);
|
||||
}
|
||||
|
||||
vec4 non_svg_color()
|
||||
{
|
||||
// takes foreground from texture
|
||||
vec4 color = texture2D(texture, tex_coord);
|
||||
return vec4(color.rgb, transparent_background ? color.a * 0.25 : color.a);
|
||||
}
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_FragColor = svg_source ? svg_color() : non_svg_color();
|
||||
}
|
||||
15
resources/shaders/110/printbed.vs
Normal file
15
resources/shaders/110/printbed.vs
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
#version 110
|
||||
|
||||
uniform mat4 view_model_matrix;
|
||||
uniform mat4 projection_matrix;
|
||||
|
||||
attribute vec3 v_position;
|
||||
attribute vec2 v_tex_coord;
|
||||
|
||||
varying vec2 tex_coord;
|
||||
|
||||
void main()
|
||||
{
|
||||
tex_coord = v_tex_coord;
|
||||
gl_Position = projection_matrix * view_model_matrix * vec4(v_position, 1.0);
|
||||
}
|
||||
16
resources/shaders/110/thumbnail.fs
Normal file
16
resources/shaders/110/thumbnail.fs
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
#version 110
|
||||
|
||||
uniform vec4 uniform_color;
|
||||
uniform float emission_factor;
|
||||
|
||||
// x = tainted, y = specular;
|
||||
varying vec2 intensity;
|
||||
//varying float drop;
|
||||
varying vec4 world_pos;
|
||||
|
||||
void main()
|
||||
{
|
||||
if (world_pos.z < 0.0)
|
||||
discard;
|
||||
gl_FragColor = vec4(vec3(intensity.y) + uniform_color.rgb * (intensity.x + emission_factor), uniform_color.a);
|
||||
}
|
||||
50
resources/shaders/110/thumbnail.vs
Normal file
50
resources/shaders/110/thumbnail.vs
Normal file
|
|
@ -0,0 +1,50 @@
|
|||
#version 110
|
||||
|
||||
#define INTENSITY_CORRECTION 0.6
|
||||
|
||||
// normalized values for (-0.6/1.31, 0.6/1.31, 1./1.31)
|
||||
const vec3 LIGHT_TOP_DIR = vec3(-0.4574957, 0.4574957, 0.7624929);
|
||||
#define LIGHT_TOP_DIFFUSE (0.8 * INTENSITY_CORRECTION)
|
||||
#define LIGHT_TOP_SPECULAR (0.125 * INTENSITY_CORRECTION)
|
||||
#define LIGHT_TOP_SHININESS 20.0
|
||||
|
||||
// normalized values for (1./1.43, 0.2/1.43, 1./1.43)
|
||||
const vec3 LIGHT_FRONT_DIR = vec3(0.6985074, 0.1397015, 0.6985074);
|
||||
#define LIGHT_FRONT_DIFFUSE (0.3 * INTENSITY_CORRECTION)
|
||||
|
||||
#define INTENSITY_AMBIENT 0.3
|
||||
|
||||
uniform mat4 view_model_matrix;
|
||||
uniform mat4 projection_matrix;
|
||||
uniform mat3 view_normal_matrix;
|
||||
uniform mat4 volume_world_matrix;
|
||||
|
||||
attribute vec3 v_position;
|
||||
attribute vec3 v_normal;
|
||||
|
||||
// x = tainted, y = specular;
|
||||
varying vec2 intensity;
|
||||
varying vec4 world_pos;
|
||||
|
||||
void main()
|
||||
{
|
||||
// First transform the normal into camera space and normalize the result.
|
||||
vec3 normal = normalize(view_normal_matrix * v_normal);
|
||||
|
||||
// Compute the cos of the angle between the normal and lights direction. The light is directional so the direction is constant for every vertex.
|
||||
// Since these two are normalized the cosine is the dot product. We also need to clamp the result to the [0,1] range.
|
||||
float NdotL = max(dot(normal, LIGHT_TOP_DIR), 0.0);
|
||||
|
||||
intensity.x = INTENSITY_AMBIENT + NdotL * LIGHT_TOP_DIFFUSE;
|
||||
vec4 position = view_model_matrix * vec4(v_position, 1.0);
|
||||
intensity.y = LIGHT_TOP_SPECULAR * pow(max(dot(-normalize(position.xyz), reflect(-LIGHT_TOP_DIR, normal)), 0.0), LIGHT_TOP_SHININESS);
|
||||
|
||||
// Perform the same lighting calculation for the 2nd light source (no specular applied).
|
||||
NdotL = max(dot(normal, LIGHT_FRONT_DIR), 0.0);
|
||||
intensity.x += NdotL * LIGHT_FRONT_DIFFUSE;
|
||||
|
||||
// Point in homogenous coordinates.
|
||||
world_pos = volume_world_matrix * vec4(v_position, 1.0);
|
||||
|
||||
gl_Position = projection_matrix * position;
|
||||
}
|
||||
41
resources/shaders/110/variable_layer_height.fs
Normal file
41
resources/shaders/110/variable_layer_height.fs
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
#version 110
|
||||
|
||||
#define M_PI 3.1415926535897932384626433832795
|
||||
|
||||
// 2D texture (1D texture split by the rows) of color along the object Z axis.
|
||||
uniform sampler2D z_texture;
|
||||
// Scaling from the Z texture rows coordinate to the normalized texture row coordinate.
|
||||
uniform float z_to_texture_row;
|
||||
uniform float z_texture_row_to_normalized;
|
||||
uniform float z_cursor;
|
||||
uniform float z_cursor_band_width;
|
||||
|
||||
// x = tainted, y = specular;
|
||||
varying vec2 intensity;
|
||||
|
||||
varying float object_z;
|
||||
|
||||
void main()
|
||||
{
|
||||
float object_z_row = z_to_texture_row * object_z;
|
||||
// Index of the row in the texture.
|
||||
float z_texture_row = floor(object_z_row);
|
||||
// Normalized coordinate from 0. to 1.
|
||||
float z_texture_col = object_z_row - z_texture_row;
|
||||
float z_blend = 0.25 * cos(min(M_PI, abs(M_PI * (object_z - z_cursor) * 1.8 / z_cursor_band_width))) + 0.25;
|
||||
// Calculate level of detail from the object Z coordinate.
|
||||
// This makes the slowly sloping surfaces to be shown with high detail (with stripes),
|
||||
// and the vertical surfaces to be shown with low detail (no stripes)
|
||||
float z_in_cells = object_z_row * 190.;
|
||||
// Gradient of Z projected on the screen.
|
||||
float dx_vtc = dFdx(z_in_cells);
|
||||
float dy_vtc = dFdy(z_in_cells);
|
||||
float lod = clamp(0.5 * log2(max(dx_vtc * dx_vtc, dy_vtc * dy_vtc)), 0., 1.);
|
||||
// Sample the Z texture. Texture coordinates are normalized to <0, 1>.
|
||||
vec4 color = vec4(0.25, 0.25, 0.25, 1.0);
|
||||
if (z_texture_row >= 0.0)
|
||||
color = mix(texture2D(z_texture, vec2(z_texture_col, z_texture_row_to_normalized * (z_texture_row + 0.5 )), -10000.),
|
||||
texture2D(z_texture, vec2(z_texture_col, z_texture_row_to_normalized * (z_texture_row * 2. + 1.)), 10000.), lod);
|
||||
// Mix the final color.
|
||||
gl_FragColor = vec4(vec3(intensity.y), 1.0) + intensity.x * mix(color, vec4(1.0, 1.0, 0.0, 1.0), z_blend);
|
||||
}
|
||||
60
resources/shaders/110/variable_layer_height.vs
Normal file
60
resources/shaders/110/variable_layer_height.vs
Normal file
|
|
@ -0,0 +1,60 @@
|
|||
#version 110
|
||||
|
||||
#define INTENSITY_CORRECTION 0.6
|
||||
|
||||
const vec3 LIGHT_TOP_DIR = vec3(-0.4574957, 0.4574957, 0.7624929);
|
||||
#define LIGHT_TOP_DIFFUSE (0.8 * INTENSITY_CORRECTION)
|
||||
#define LIGHT_TOP_SPECULAR (0.125 * INTENSITY_CORRECTION)
|
||||
#define LIGHT_TOP_SHININESS 20.0
|
||||
|
||||
const vec3 LIGHT_FRONT_DIR = vec3(0.6985074, 0.1397015, 0.6985074);
|
||||
#define LIGHT_FRONT_DIFFUSE (0.3 * INTENSITY_CORRECTION)
|
||||
//#define LIGHT_FRONT_SPECULAR (0.0 * INTENSITY_CORRECTION)
|
||||
//#define LIGHT_FRONT_SHININESS 5.0
|
||||
|
||||
#define INTENSITY_AMBIENT 0.3
|
||||
|
||||
uniform mat4 view_model_matrix;
|
||||
uniform mat4 projection_matrix;
|
||||
uniform mat3 view_normal_matrix;
|
||||
uniform mat4 volume_world_matrix;
|
||||
uniform float object_max_z;
|
||||
|
||||
attribute vec3 v_position;
|
||||
attribute vec3 v_normal;
|
||||
attribute vec2 v_tex_coord;
|
||||
|
||||
// x = tainted, y = specular;
|
||||
varying vec2 intensity;
|
||||
|
||||
varying float object_z;
|
||||
|
||||
void main()
|
||||
{
|
||||
// =====================================================
|
||||
// NOTE:
|
||||
// when object_max_z > 0.0 we are rendering the overlay
|
||||
// when object_max_z == 0.0 we are rendering the volumes
|
||||
// =====================================================
|
||||
|
||||
// First transform the normal into camera space and normalize the result.
|
||||
vec3 normal = (object_max_z > 0.0) ? vec3(0.0, 0.0, 1.0) : normalize(view_normal_matrix * v_normal);
|
||||
|
||||
// Compute the cos of the angle between the normal and lights direction. The light is directional so the direction is constant for every vertex.
|
||||
// Since these two are normalized the cosine is the dot product. We also need to clamp the result to the [0,1] range.
|
||||
float NdotL = max(dot(normal, LIGHT_TOP_DIR), 0.0);
|
||||
|
||||
intensity.x = INTENSITY_AMBIENT + NdotL * LIGHT_TOP_DIFFUSE;
|
||||
vec4 position = view_model_matrix * vec4(v_position, 1.0);
|
||||
intensity.y = LIGHT_TOP_SPECULAR * pow(max(dot(-normalize(position.xyz), reflect(-LIGHT_TOP_DIR, normal)), 0.0), LIGHT_TOP_SHININESS);
|
||||
|
||||
// Perform the same lighting calculation for the 2nd light source (no specular)
|
||||
NdotL = max(dot(normal, LIGHT_FRONT_DIR), 0.0);
|
||||
|
||||
intensity.x += NdotL * LIGHT_FRONT_DIFFUSE;
|
||||
|
||||
// Scaled to widths of the Z texture.
|
||||
object_z = (object_max_z > 0.0) ? object_max_z * v_tex_coord.y : (volume_world_matrix * vec4(v_position, 1.0)).z;
|
||||
|
||||
gl_Position = projection_matrix * position;
|
||||
}
|
||||
11
resources/shaders/140/background.fs
Normal file
11
resources/shaders/140/background.fs
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
#version 140
|
||||
|
||||
uniform vec4 top_color;
|
||||
uniform vec4 bottom_color;
|
||||
|
||||
in vec2 tex_coord;
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_FragColor = mix(bottom_color, top_color, tex_coord.y);
|
||||
}
|
||||
12
resources/shaders/140/background.vs
Normal file
12
resources/shaders/140/background.vs
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
#version 140
|
||||
|
||||
in vec3 v_position;
|
||||
in vec2 v_tex_coord;
|
||||
|
||||
out vec2 tex_coord;
|
||||
|
||||
void main()
|
||||
{
|
||||
tex_coord = v_tex_coord;
|
||||
gl_Position = vec4(v_position, 1.0);
|
||||
}
|
||||
8
resources/shaders/140/flat.fs
Normal file
8
resources/shaders/140/flat.fs
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
#version 140
|
||||
|
||||
uniform vec4 uniform_color;
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_FragColor = uniform_color;
|
||||
}
|
||||
11
resources/shaders/140/flat.vs
Normal file
11
resources/shaders/140/flat.vs
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
#version 140
|
||||
|
||||
uniform mat4 view_model_matrix;
|
||||
uniform mat4 projection_matrix;
|
||||
|
||||
in vec3 v_position;
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_Position = projection_matrix * view_model_matrix * vec4(v_position, 1.0);
|
||||
}
|
||||
17
resources/shaders/140/flat_clip.fs
Normal file
17
resources/shaders/140/flat_clip.fs
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
#version 140
|
||||
|
||||
const vec3 ZERO = vec3(0.0, 0.0, 0.0);
|
||||
|
||||
uniform vec4 uniform_color;
|
||||
|
||||
in vec3 clipping_planes_dots;
|
||||
|
||||
out vec4 out_color;
|
||||
|
||||
void main()
|
||||
{
|
||||
if (any(lessThan(clipping_planes_dots, ZERO)))
|
||||
discard;
|
||||
|
||||
out_color = uniform_color;
|
||||
}
|
||||
23
resources/shaders/140/flat_clip.vs
Normal file
23
resources/shaders/140/flat_clip.vs
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
#version 140
|
||||
|
||||
uniform mat4 view_model_matrix;
|
||||
uniform mat4 projection_matrix;
|
||||
uniform mat4 volume_world_matrix;
|
||||
|
||||
// Clipping plane, x = min z, y = max z. Used by the FFF and SLA previews to clip with a top / bottom plane.
|
||||
uniform vec2 z_range;
|
||||
// Clipping plane - general orientation. Used by the SLA gizmo.
|
||||
uniform vec4 clipping_plane;
|
||||
|
||||
in vec3 v_position;
|
||||
|
||||
out vec3 clipping_planes_dots;
|
||||
|
||||
void main()
|
||||
{
|
||||
// Fill in the scalars for fragment shader clipping. Fragments with any of these components lower than zero are discarded.
|
||||
vec4 world_pos = volume_world_matrix * vec4(v_position, 1.0);
|
||||
clipping_planes_dots = vec3(dot(world_pos, clipping_plane), world_pos.z - z_range.x, z_range.y - world_pos.z);
|
||||
|
||||
gl_Position = projection_matrix * view_model_matrix * vec4(v_position, 1.0);
|
||||
}
|
||||
10
resources/shaders/140/flat_texture.fs
Normal file
10
resources/shaders/140/flat_texture.fs
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
#version 140
|
||||
|
||||
uniform sampler2D uniform_texture;
|
||||
|
||||
in vec2 tex_coord;
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_FragColor = texture(uniform_texture, tex_coord);
|
||||
}
|
||||
15
resources/shaders/140/flat_texture.vs
Normal file
15
resources/shaders/140/flat_texture.vs
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
#version 140
|
||||
|
||||
uniform mat4 view_model_matrix;
|
||||
uniform mat4 projection_matrix;
|
||||
|
||||
in vec3 v_position;
|
||||
in vec2 v_tex_coord;
|
||||
|
||||
out vec2 tex_coord;
|
||||
|
||||
void main()
|
||||
{
|
||||
tex_coord = v_tex_coord;
|
||||
gl_Position = projection_matrix * view_model_matrix * vec4(v_position, 1.0);
|
||||
}
|
||||
109
resources/shaders/140/gouraud.fs
Normal file
109
resources/shaders/140/gouraud.fs
Normal file
|
|
@ -0,0 +1,109 @@
|
|||
#version 140
|
||||
|
||||
const vec3 ZERO = vec3(0.0, 0.0, 0.0);
|
||||
//BBS: add grey and orange
|
||||
//const vec3 GREY = vec3(0.9, 0.9, 0.9);
|
||||
const vec3 ORANGE = vec3(0.8, 0.4, 0.0);
|
||||
const vec3 LightRed = vec3(0.78, 0.0, 0.0);
|
||||
const vec3 LightBlue = vec3(0.73, 1.0, 1.0);
|
||||
const float EPSILON = 0.0001;
|
||||
|
||||
struct PrintVolumeDetection
|
||||
{
|
||||
// 0 = rectangle, 1 = circle, 2 = custom, 3 = invalid
|
||||
int type;
|
||||
// type = 0 (rectangle):
|
||||
// x = min.x, y = min.y, z = max.x, w = max.y
|
||||
// type = 1 (circle):
|
||||
// x = center.x, y = center.y, z = radius
|
||||
vec4 xy_data;
|
||||
// x = min z, y = max z
|
||||
vec2 z_data;
|
||||
};
|
||||
|
||||
struct SlopeDetection
|
||||
{
|
||||
bool actived;
|
||||
float normal_z;
|
||||
mat3 volume_world_normal_matrix;
|
||||
};
|
||||
|
||||
uniform vec4 uniform_color;
|
||||
uniform bool use_color_clip_plane;
|
||||
uniform vec4 uniform_color_clip_plane_1;
|
||||
uniform vec4 uniform_color_clip_plane_2;
|
||||
uniform SlopeDetection slope;
|
||||
|
||||
//BBS: add outline_color
|
||||
uniform bool is_outline;
|
||||
|
||||
#ifdef ENABLE_ENVIRONMENT_MAP
|
||||
uniform sampler2D environment_tex;
|
||||
uniform bool use_environment_tex;
|
||||
#endif // ENABLE_ENVIRONMENT_MAP
|
||||
|
||||
uniform PrintVolumeDetection print_volume;
|
||||
|
||||
in vec3 clipping_planes_dots;
|
||||
in float color_clip_plane_dot;
|
||||
|
||||
// x = diffuse, y = specular;
|
||||
in vec2 intensity;
|
||||
|
||||
in vec4 world_pos;
|
||||
in float world_normal_z;
|
||||
in vec3 eye_normal;
|
||||
|
||||
out vec4 out_color;
|
||||
|
||||
void main()
|
||||
{
|
||||
if (any(lessThan(clipping_planes_dots, ZERO)))
|
||||
discard;
|
||||
|
||||
vec4 color;
|
||||
if (use_color_clip_plane) {
|
||||
color.rgb = (color_clip_plane_dot < 0.0) ? uniform_color_clip_plane_1.rgb : uniform_color_clip_plane_2.rgb;
|
||||
color.a = uniform_color.a;
|
||||
}
|
||||
else
|
||||
color = uniform_color;
|
||||
|
||||
if (slope.actived) {
|
||||
if(world_pos.z<0.1&&world_pos.z>-0.1)
|
||||
{
|
||||
color.rgb = LightBlue;
|
||||
color.a = 0.8;
|
||||
}
|
||||
else if( world_normal_z < slope.normal_z - EPSILON)
|
||||
{
|
||||
color.rgb = color.rgb * 0.5 + LightRed * 0.5;
|
||||
color.a = 0.8;
|
||||
}
|
||||
}
|
||||
// if the fragment is outside the print volume -> use darker color
|
||||
vec3 pv_check_min = ZERO;
|
||||
vec3 pv_check_max = ZERO;
|
||||
if (print_volume.type == 0) {
|
||||
// rectangle
|
||||
pv_check_min = world_pos.xyz - vec3(print_volume.xy_data.x, print_volume.xy_data.y, print_volume.z_data.x);
|
||||
pv_check_max = world_pos.xyz - vec3(print_volume.xy_data.z, print_volume.xy_data.w, print_volume.z_data.y);
|
||||
}
|
||||
else if (print_volume.type == 1) {
|
||||
// circle
|
||||
float delta_radius = print_volume.xy_data.z - distance(world_pos.xy, print_volume.xy_data.xy);
|
||||
pv_check_min = vec3(delta_radius, 0.0, world_pos.z - print_volume.z_data.x);
|
||||
pv_check_max = vec3(0.0, 0.0, world_pos.z - print_volume.z_data.y);
|
||||
}
|
||||
color.rgb = (any(lessThan(pv_check_min, ZERO)) || any(greaterThan(pv_check_max, ZERO))) ? mix(color.rgb, ZERO, 0.3333) : color.rgb;
|
||||
|
||||
//BBS: add outline_color
|
||||
if (is_outline)
|
||||
out_color = uniform_color;
|
||||
#ifdef ENABLE_ENVIRONMENT_MAP
|
||||
else if (use_environment_tex)
|
||||
out_color = vec4(0.45 * texture(environment_tex, normalize(eye_normal).xy * 0.5 + 0.5).xyz + 0.8 * color.rgb * intensity.x, color.a);
|
||||
#endif
|
||||
else
|
||||
out_color = vec4(vec3(intensity.y) + color.rgb * intensity.x, color.a);
|
||||
}
|
||||
81
resources/shaders/140/gouraud.vs
Normal file
81
resources/shaders/140/gouraud.vs
Normal file
|
|
@ -0,0 +1,81 @@
|
|||
#version 140
|
||||
|
||||
#define INTENSITY_CORRECTION 0.6
|
||||
|
||||
// normalized values for (-0.6/1.31, 0.6/1.31, 1./1.31)
|
||||
const vec3 LIGHT_TOP_DIR = vec3(-0.4574957, 0.4574957, 0.7624929);
|
||||
#define LIGHT_TOP_DIFFUSE (0.8 * INTENSITY_CORRECTION)
|
||||
#define LIGHT_TOP_SPECULAR (0.125 * INTENSITY_CORRECTION)
|
||||
#define LIGHT_TOP_SHININESS 20.0
|
||||
|
||||
// normalized values for (1./1.43, 0.2/1.43, 1./1.43)
|
||||
const vec3 LIGHT_FRONT_DIR = vec3(0.6985074, 0.1397015, 0.6985074);
|
||||
#define LIGHT_FRONT_DIFFUSE (0.3 * INTENSITY_CORRECTION)
|
||||
//#define LIGHT_FRONT_SPECULAR (0.0 * INTENSITY_CORRECTION)
|
||||
//#define LIGHT_FRONT_SHININESS 5.0
|
||||
|
||||
#define INTENSITY_AMBIENT 0.3
|
||||
|
||||
const vec3 ZERO = vec3(0.0, 0.0, 0.0);
|
||||
|
||||
struct SlopeDetection
|
||||
{
|
||||
bool actived;
|
||||
float normal_z;
|
||||
mat3 volume_world_normal_matrix;
|
||||
};
|
||||
|
||||
uniform mat4 view_model_matrix;
|
||||
uniform mat4 projection_matrix;
|
||||
uniform mat3 view_normal_matrix;
|
||||
uniform mat4 volume_world_matrix;
|
||||
uniform SlopeDetection slope;
|
||||
|
||||
// Clipping plane, x = min z, y = max z. Used by the FFF and SLA previews to clip with a top / bottom plane.
|
||||
uniform vec2 z_range;
|
||||
// Clipping plane - general orientation. Used by the SLA gizmo.
|
||||
uniform vec4 clipping_plane;
|
||||
// Color clip plane - general orientation. Used by the cut gizmo.
|
||||
uniform vec4 color_clip_plane;
|
||||
|
||||
in vec3 v_position;
|
||||
in vec3 v_normal;
|
||||
|
||||
// x = diffuse, y = specular;
|
||||
out vec2 intensity;
|
||||
|
||||
out vec3 clipping_planes_dots;
|
||||
out float color_clip_plane_dot;
|
||||
|
||||
out vec4 world_pos;
|
||||
out float world_normal_z;
|
||||
out vec3 eye_normal;
|
||||
|
||||
void main()
|
||||
{
|
||||
// First transform the normal into camera space and normalize the result.
|
||||
eye_normal = normalize(view_normal_matrix * v_normal);
|
||||
|
||||
// Compute the cos of the angle between the normal and lights direction. The light is directional so the direction is constant for every vertex.
|
||||
// Since these two are normalized the cosine is the dot product. We also need to clamp the result to the [0,1] range.
|
||||
float NdotL = max(dot(eye_normal, LIGHT_TOP_DIR), 0.0);
|
||||
|
||||
intensity.x = INTENSITY_AMBIENT + NdotL * LIGHT_TOP_DIFFUSE;
|
||||
vec4 position = view_model_matrix * vec4(v_position, 1.0);
|
||||
intensity.y = LIGHT_TOP_SPECULAR * pow(max(dot(-normalize(position.xyz), reflect(-LIGHT_TOP_DIR, eye_normal)), 0.0), LIGHT_TOP_SHININESS);
|
||||
|
||||
// Perform the same lighting calculation for the 2nd light source (no specular applied).
|
||||
NdotL = max(dot(eye_normal, LIGHT_FRONT_DIR), 0.0);
|
||||
intensity.x += NdotL * LIGHT_FRONT_DIFFUSE;
|
||||
|
||||
// Point in homogenous coordinates.
|
||||
world_pos = volume_world_matrix * vec4(v_position, 1.0);
|
||||
|
||||
// z component of normal vector in world coordinate used for slope shading
|
||||
world_normal_z = slope.actived ? (normalize(slope.volume_world_normal_matrix * v_normal)).z : 0.0;
|
||||
|
||||
gl_Position = projection_matrix * position;
|
||||
// Fill in the scalars for fragment shader clipping. Fragments with any of these components lower than zero are discarded.
|
||||
clipping_planes_dots = vec3(dot(world_pos, clipping_plane), world_pos.z - z_range.x, z_range.y - world_pos.z);
|
||||
color_clip_plane_dot = dot(world_pos, color_clip_plane);
|
||||
}
|
||||
12
resources/shaders/140/gouraud_light.fs
Normal file
12
resources/shaders/140/gouraud_light.fs
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
#version 140
|
||||
|
||||
uniform vec4 uniform_color;
|
||||
uniform float emission_factor;
|
||||
|
||||
// x = tainted, y = specular;
|
||||
in vec2 intensity;
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_FragColor = vec4(vec3(intensity.y) + uniform_color.rgb * (intensity.x + emission_factor), uniform_color.a);
|
||||
}
|
||||
45
resources/shaders/140/gouraud_light.vs
Normal file
45
resources/shaders/140/gouraud_light.vs
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
#version 140
|
||||
|
||||
#define INTENSITY_CORRECTION 0.6
|
||||
|
||||
// normalized values for (-0.6/1.31, 0.6/1.31, 1./1.31)
|
||||
const vec3 LIGHT_TOP_DIR = vec3(-0.4574957, 0.4574957, 0.7624929);
|
||||
#define LIGHT_TOP_DIFFUSE (0.8 * INTENSITY_CORRECTION)
|
||||
#define LIGHT_TOP_SPECULAR (0.125 * INTENSITY_CORRECTION)
|
||||
#define LIGHT_TOP_SHININESS 20.0
|
||||
|
||||
// normalized values for (1./1.43, 0.2/1.43, 1./1.43)
|
||||
const vec3 LIGHT_FRONT_DIR = vec3(0.6985074, 0.1397015, 0.6985074);
|
||||
#define LIGHT_FRONT_DIFFUSE (0.3 * INTENSITY_CORRECTION)
|
||||
|
||||
#define INTENSITY_AMBIENT 0.3
|
||||
|
||||
uniform mat4 view_model_matrix;
|
||||
uniform mat4 projection_matrix;
|
||||
uniform mat3 view_normal_matrix;
|
||||
|
||||
in vec3 v_position;
|
||||
in vec3 v_normal;
|
||||
|
||||
// x = tainted, y = specular;
|
||||
out vec2 intensity;
|
||||
|
||||
void main()
|
||||
{
|
||||
// First transform the normal into camera space and normalize the result.
|
||||
vec3 normal = normalize(view_normal_matrix * v_normal);
|
||||
|
||||
// Compute the cos of the angle between the normal and lights direction. The light is directional so the direction is constant for every vertex.
|
||||
// Since these two are normalized the cosine is the dot product. We also need to clamp the result to the [0,1] range.
|
||||
float NdotL = max(dot(normal, LIGHT_TOP_DIR), 0.0);
|
||||
|
||||
intensity.x = INTENSITY_AMBIENT + NdotL * LIGHT_TOP_DIFFUSE;
|
||||
vec4 position = view_model_matrix * vec4(v_position, 1.0);
|
||||
intensity.y = LIGHT_TOP_SPECULAR * pow(max(dot(-normalize(position.xyz), reflect(-LIGHT_TOP_DIR, normal)), 0.0), LIGHT_TOP_SHININESS);
|
||||
|
||||
// Perform the same lighting calculation for the 2nd light source (no specular applied).
|
||||
NdotL = max(dot(normal, LIGHT_FRONT_DIR), 0.0);
|
||||
intensity.x += NdotL * LIGHT_FRONT_DIFFUSE;
|
||||
|
||||
gl_Position = projection_matrix * position;
|
||||
}
|
||||
12
resources/shaders/140/gouraud_light_instanced.fs
Normal file
12
resources/shaders/140/gouraud_light_instanced.fs
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
#version 140
|
||||
|
||||
uniform vec4 uniform_color;
|
||||
uniform float emission_factor;
|
||||
|
||||
// x = tainted, y = specular;
|
||||
in vec2 intensity;
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_FragColor = vec4(vec3(intensity.y) + uniform_color.rgb * (intensity.x + emission_factor), uniform_color.a);
|
||||
}
|
||||
50
resources/shaders/140/gouraud_light_instanced.vs
Normal file
50
resources/shaders/140/gouraud_light_instanced.vs
Normal file
|
|
@ -0,0 +1,50 @@
|
|||
#version 140
|
||||
|
||||
#define INTENSITY_CORRECTION 0.6
|
||||
|
||||
// normalized values for (-0.6/1.31, 0.6/1.31, 1./1.31)
|
||||
const vec3 LIGHT_TOP_DIR = vec3(-0.4574957, 0.4574957, 0.7624929);
|
||||
#define LIGHT_TOP_DIFFUSE (0.8 * INTENSITY_CORRECTION)
|
||||
#define LIGHT_TOP_SPECULAR (0.125 * INTENSITY_CORRECTION)
|
||||
#define LIGHT_TOP_SHININESS 20.0
|
||||
|
||||
// normalized values for (1./1.43, 0.2/1.43, 1./1.43)
|
||||
const vec3 LIGHT_FRONT_DIR = vec3(0.6985074, 0.1397015, 0.6985074);
|
||||
#define LIGHT_FRONT_DIFFUSE (0.3 * INTENSITY_CORRECTION)
|
||||
|
||||
#define INTENSITY_AMBIENT 0.3
|
||||
|
||||
uniform mat4 view_model_matrix;
|
||||
uniform mat4 projection_matrix;
|
||||
uniform mat3 view_normal_matrix;
|
||||
|
||||
// vertex attributes
|
||||
in vec3 v_position;
|
||||
in vec3 v_normal;
|
||||
// instance attributes
|
||||
in vec3 i_offset;
|
||||
in vec2 i_scales;
|
||||
|
||||
// x = tainted, y = specular;
|
||||
out vec2 intensity;
|
||||
|
||||
void main()
|
||||
{
|
||||
// First transform the normal into camera space and normalize the result.
|
||||
vec3 eye_normal = normalize(view_normal_matrix * v_normal);
|
||||
|
||||
// Compute the cos of the angle between the normal and lights direction. The light is directional so the direction is constant for every vertex.
|
||||
// Since these two are normalized the cosine is the dot product. We also need to clamp the result to the [0,1] range.
|
||||
float NdotL = max(dot(eye_normal, LIGHT_TOP_DIR), 0.0);
|
||||
|
||||
intensity.x = INTENSITY_AMBIENT + NdotL * LIGHT_TOP_DIFFUSE;
|
||||
vec4 world_position = vec4(v_position * vec3(vec2(1.5 * i_scales.x), 1.5 * i_scales.y) + i_offset - vec3(0.0, 0.0, 0.5 * i_scales.y), 1.0);
|
||||
vec4 eye_position = view_model_matrix * world_position;
|
||||
intensity.y = LIGHT_TOP_SPECULAR * pow(max(dot(-normalize(eye_position.xyz), reflect(-LIGHT_TOP_DIR, eye_normal)), 0.0), LIGHT_TOP_SHININESS);
|
||||
|
||||
// Perform the same lighting calculation for the 2nd light source (no specular applied).
|
||||
NdotL = max(dot(eye_normal, LIGHT_FRONT_DIR), 0.0);
|
||||
intensity.x += NdotL * LIGHT_FRONT_DIFFUSE;
|
||||
|
||||
gl_Position = projection_matrix * eye_position;
|
||||
}
|
||||
11
resources/shaders/140/imgui.fs
Normal file
11
resources/shaders/140/imgui.fs
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
#version 140
|
||||
|
||||
uniform sampler2D Texture;
|
||||
|
||||
in vec2 Frag_UV;
|
||||
in vec4 Frag_Color;
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_FragColor = Frag_Color * texture(Texture, Frag_UV.st);
|
||||
}
|
||||
17
resources/shaders/140/imgui.vs
Normal file
17
resources/shaders/140/imgui.vs
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
#version 140
|
||||
|
||||
uniform mat4 ProjMtx;
|
||||
|
||||
in vec2 Position;
|
||||
in vec2 UV;
|
||||
in vec4 Color;
|
||||
|
||||
out vec2 Frag_UV;
|
||||
out vec4 Frag_Color;
|
||||
|
||||
void main()
|
||||
{
|
||||
Frag_UV = UV;
|
||||
Frag_Color = Color;
|
||||
gl_Position = ProjMtx * vec4(Position.xy, 0.0, 1.0);
|
||||
}
|
||||
8
resources/shaders/140/mm_contour.fs
Normal file
8
resources/shaders/140/mm_contour.fs
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
#version 140
|
||||
|
||||
uniform vec4 uniform_color;
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_FragColor = uniform_color;
|
||||
}
|
||||
15
resources/shaders/140/mm_contour.vs
Normal file
15
resources/shaders/140/mm_contour.vs
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
#version 140
|
||||
|
||||
uniform mat4 view_model_matrix;
|
||||
uniform mat4 projection_matrix;
|
||||
uniform float offset;
|
||||
|
||||
in vec3 v_position;
|
||||
|
||||
void main()
|
||||
{
|
||||
// Add small epsilon to z to solve z-fighting between painted triangles and contour lines.
|
||||
vec4 clip_position = projection_matrix * view_model_matrix * vec4(v_position, 1.0);
|
||||
clip_position.z -= offset * abs(clip_position.w);
|
||||
gl_Position = clip_position;
|
||||
}
|
||||
90
resources/shaders/140/mm_gouraud.fs
Normal file
90
resources/shaders/140/mm_gouraud.fs
Normal file
|
|
@ -0,0 +1,90 @@
|
|||
#version 140
|
||||
|
||||
#define INTENSITY_CORRECTION 0.6
|
||||
|
||||
// normalized values for (-0.6/1.31, 0.6/1.31, 1./1.31)
|
||||
const vec3 LIGHT_TOP_DIR = vec3(-0.4574957, 0.4574957, 0.7624929);
|
||||
#define LIGHT_TOP_DIFFUSE (0.8 * INTENSITY_CORRECTION)
|
||||
#define LIGHT_TOP_SPECULAR (0.125 * INTENSITY_CORRECTION)
|
||||
#define LIGHT_TOP_SHININESS 20.0
|
||||
|
||||
// normalized values for (1./1.43, 0.2/1.43, 1./1.43)
|
||||
const vec3 LIGHT_FRONT_DIR = vec3(0.6985074, 0.1397015, 0.6985074);
|
||||
#define LIGHT_FRONT_DIFFUSE (0.3 * INTENSITY_CORRECTION)
|
||||
|
||||
#define INTENSITY_AMBIENT 0.3
|
||||
|
||||
const vec3 ZERO = vec3(0.0, 0.0, 0.0);
|
||||
const float EPSILON = 0.0001;
|
||||
//BBS: add grey and orange
|
||||
//const vec3 GREY = vec3(0.9, 0.9, 0.9);
|
||||
const vec3 ORANGE = vec3(0.8, 0.4, 0.0);
|
||||
const vec3 LightRed = vec3(0.78, 0.0, 0.0);
|
||||
const vec3 LightBlue = vec3(0.73, 1.0, 1.0);
|
||||
uniform vec4 uniform_color;
|
||||
|
||||
uniform bool volume_mirrored;
|
||||
|
||||
uniform mat4 view_model_matrix;
|
||||
uniform mat3 view_normal_matrix;
|
||||
|
||||
in vec3 clipping_planes_dots;
|
||||
in vec4 model_pos;
|
||||
in vec4 world_pos;
|
||||
|
||||
struct SlopeDetection
|
||||
{
|
||||
bool actived;
|
||||
float normal_z;
|
||||
mat3 volume_world_normal_matrix;
|
||||
};
|
||||
uniform SlopeDetection slope;
|
||||
|
||||
void main()
|
||||
{
|
||||
if (any(lessThan(clipping_planes_dots, ZERO)))
|
||||
discard;
|
||||
vec3 color = uniform_color.rgb;
|
||||
float alpha = uniform_color.a;
|
||||
|
||||
vec3 triangle_normal = normalize(cross(dFdx(model_pos.xyz), dFdy(model_pos.xyz)));
|
||||
#ifdef FLIP_TRIANGLE_NORMALS
|
||||
triangle_normal = -triangle_normal;
|
||||
#endif
|
||||
|
||||
if (volume_mirrored)
|
||||
triangle_normal = -triangle_normal;
|
||||
|
||||
vec3 transformed_normal = normalize(slope.volume_world_normal_matrix * triangle_normal);
|
||||
|
||||
if (slope.actived) {
|
||||
if(world_pos.z<0.1&&world_pos.z>-0.1)
|
||||
{
|
||||
color = LightBlue;
|
||||
alpha = 1.0;
|
||||
}
|
||||
else if( transformed_normal.z < slope.normal_z - EPSILON)
|
||||
{
|
||||
color = color * 0.5 + LightRed * 0.5;
|
||||
alpha = 1.0;
|
||||
}
|
||||
}
|
||||
// First transform the normal into camera space and normalize the result.
|
||||
vec3 eye_normal = normalize(view_normal_matrix * triangle_normal);
|
||||
|
||||
// Compute the cos of the angle between the normal and lights direction. The light is directional so the direction is constant for every vertex.
|
||||
// Since these two are normalized the cosine is the dot product. We also need to clamp the result to the [0,1] range.
|
||||
float NdotL = max(dot(eye_normal, LIGHT_TOP_DIR), 0.0);
|
||||
|
||||
// x = diffuse, y = specular;
|
||||
vec2 intensity = vec2(0.0);
|
||||
intensity.x = INTENSITY_AMBIENT + NdotL * LIGHT_TOP_DIFFUSE;
|
||||
vec3 position = (view_model_matrix * model_pos).xyz;
|
||||
intensity.y = LIGHT_TOP_SPECULAR * pow(max(dot(-normalize(position), reflect(-LIGHT_TOP_DIR, eye_normal)), 0.0), LIGHT_TOP_SHININESS);
|
||||
|
||||
// Perform the same lighting calculation for the 2nd light source (no specular applied).
|
||||
NdotL = max(dot(eye_normal, LIGHT_FRONT_DIR), 0.0);
|
||||
intensity.x += NdotL * LIGHT_FRONT_DIFFUSE;
|
||||
|
||||
gl_FragColor = vec4(vec3(intensity.y) + color * intensity.x, alpha);
|
||||
}
|
||||
35
resources/shaders/140/mm_gouraud.vs
Normal file
35
resources/shaders/140/mm_gouraud.vs
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
#version 140
|
||||
|
||||
const vec3 ZERO = vec3(0.0, 0.0, 0.0);
|
||||
|
||||
uniform mat4 view_model_matrix;
|
||||
uniform mat4 projection_matrix;
|
||||
|
||||
uniform mat4 volume_world_matrix;
|
||||
// Clipping plane, x = min z, y = max z. Used by the FFF and SLA previews to clip with a top / bottom plane.
|
||||
uniform vec2 z_range;
|
||||
// Clipping plane - general orientation. Used by the SLA gizmo.
|
||||
uniform vec4 clipping_plane;
|
||||
|
||||
in vec3 v_position;
|
||||
|
||||
out vec3 clipping_planes_dots;
|
||||
out vec4 model_pos;
|
||||
out vec4 world_pos;
|
||||
struct SlopeDetection
|
||||
{
|
||||
bool actived;
|
||||
float normal_z;
|
||||
mat3 volume_world_normal_matrix;
|
||||
};
|
||||
uniform SlopeDetection slope;
|
||||
void main()
|
||||
{
|
||||
model_pos = vec4(v_position, 1.0);
|
||||
// Point in homogenous coordinates.
|
||||
world_pos = volume_world_matrix * model_pos;
|
||||
|
||||
gl_Position = projection_matrix * view_model_matrix * model_pos;
|
||||
// Fill in the scalars for fragment shader clipping. Fragments with any of these components lower than zero are discarded.
|
||||
clipping_planes_dots = vec3(dot(world_pos, clipping_plane), world_pos.z - z_range.x, z_range.y - world_pos.z);
|
||||
}
|
||||
35
resources/shaders/140/printbed.fs
Normal file
35
resources/shaders/140/printbed.fs
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
#version 140
|
||||
|
||||
const vec3 back_color_dark = vec3(0.235, 0.235, 0.235);
|
||||
const vec3 back_color_light = vec3(0.365, 0.365, 0.365);
|
||||
|
||||
uniform sampler2D in_texture;
|
||||
uniform bool transparent_background;
|
||||
uniform bool svg_source;
|
||||
|
||||
in vec2 tex_coord;
|
||||
out vec4 frag_color;
|
||||
|
||||
vec4 svg_color()
|
||||
{
|
||||
// takes foreground from texture
|
||||
vec4 fore_color = texture(in_texture, tex_coord);
|
||||
|
||||
// calculates radial gradient
|
||||
vec3 back_color = vec3(mix(back_color_light, back_color_dark, smoothstep(0.0, 0.5, length(abs(tex_coord.xy) - vec2(0.5)))));
|
||||
|
||||
// blends foreground with background
|
||||
return vec4(mix(back_color, fore_color.rgb, fore_color.a), transparent_background ? fore_color.a : 1.0);
|
||||
}
|
||||
|
||||
vec4 non_svg_color()
|
||||
{
|
||||
// takes foreground from texture
|
||||
vec4 color = texture(in_texture, tex_coord);
|
||||
return vec4(color.rgb, transparent_background ? color.a * 0.25 : color.a);
|
||||
}
|
||||
|
||||
void main()
|
||||
{
|
||||
frag_color = svg_source ? svg_color() : non_svg_color();
|
||||
}
|
||||
15
resources/shaders/140/printbed.vs
Normal file
15
resources/shaders/140/printbed.vs
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
#version 140
|
||||
|
||||
uniform mat4 view_model_matrix;
|
||||
uniform mat4 projection_matrix;
|
||||
|
||||
in vec3 v_position;
|
||||
in vec2 v_tex_coord;
|
||||
|
||||
out vec2 tex_coord;
|
||||
|
||||
void main()
|
||||
{
|
||||
tex_coord = v_tex_coord;
|
||||
gl_Position = projection_matrix * view_model_matrix * vec4(v_position, 1.0);
|
||||
}
|
||||
16
resources/shaders/140/thumbnail.fs
Normal file
16
resources/shaders/140/thumbnail.fs
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
#version 140
|
||||
|
||||
uniform vec4 uniform_color;
|
||||
uniform float emission_factor;
|
||||
|
||||
// x = tainted, y = specular;
|
||||
in vec2 intensity;
|
||||
//varying float drop;
|
||||
in vec4 world_pos;
|
||||
|
||||
void main()
|
||||
{
|
||||
if (world_pos.z < 0.0)
|
||||
discard;
|
||||
gl_FragColor = vec4(vec3(intensity.y) + uniform_color.rgb * (intensity.x + emission_factor), uniform_color.a);
|
||||
}
|
||||
50
resources/shaders/140/thumbnail.vs
Normal file
50
resources/shaders/140/thumbnail.vs
Normal file
|
|
@ -0,0 +1,50 @@
|
|||
#version 140
|
||||
|
||||
#define INTENSITY_CORRECTION 0.6
|
||||
|
||||
// normalized values for (-0.6/1.31, 0.6/1.31, 1./1.31)
|
||||
const vec3 LIGHT_TOP_DIR = vec3(-0.4574957, 0.4574957, 0.7624929);
|
||||
#define LIGHT_TOP_DIFFUSE (0.8 * INTENSITY_CORRECTION)
|
||||
#define LIGHT_TOP_SPECULAR (0.125 * INTENSITY_CORRECTION)
|
||||
#define LIGHT_TOP_SHININESS 20.0
|
||||
|
||||
// normalized values for (1./1.43, 0.2/1.43, 1./1.43)
|
||||
const vec3 LIGHT_FRONT_DIR = vec3(0.6985074, 0.1397015, 0.6985074);
|
||||
#define LIGHT_FRONT_DIFFUSE (0.3 * INTENSITY_CORRECTION)
|
||||
|
||||
#define INTENSITY_AMBIENT 0.3
|
||||
|
||||
uniform mat4 view_model_matrix;
|
||||
uniform mat4 projection_matrix;
|
||||
uniform mat3 view_normal_matrix;
|
||||
uniform mat4 volume_world_matrix;
|
||||
|
||||
in vec3 v_position;
|
||||
in vec3 v_normal;
|
||||
|
||||
// x = tainted, y = specular;
|
||||
out vec2 intensity;
|
||||
out vec4 world_pos;
|
||||
|
||||
void main()
|
||||
{
|
||||
// First transform the normal into camera space and normalize the result.
|
||||
vec3 normal = normalize(view_normal_matrix * v_normal);
|
||||
|
||||
// Compute the cos of the angle between the normal and lights direction. The light is directional so the direction is constant for every vertex.
|
||||
// Since these two are normalized the cosine is the dot product. We also need to clamp the result to the [0,1] range.
|
||||
float NdotL = max(dot(normal, LIGHT_TOP_DIR), 0.0);
|
||||
|
||||
intensity.x = INTENSITY_AMBIENT + NdotL * LIGHT_TOP_DIFFUSE;
|
||||
vec4 position = view_model_matrix * vec4(v_position, 1.0);
|
||||
intensity.y = LIGHT_TOP_SPECULAR * pow(max(dot(-normalize(position.xyz), reflect(-LIGHT_TOP_DIR, normal)), 0.0), LIGHT_TOP_SHININESS);
|
||||
|
||||
// Perform the same lighting calculation for the 2nd light source (no specular applied).
|
||||
NdotL = max(dot(normal, LIGHT_FRONT_DIR), 0.0);
|
||||
intensity.x += NdotL * LIGHT_FRONT_DIFFUSE;
|
||||
|
||||
// Point in homogenous coordinates.
|
||||
world_pos = volume_world_matrix * vec4(v_position, 1.0);
|
||||
|
||||
gl_Position = projection_matrix * position;
|
||||
}
|
||||
41
resources/shaders/140/variable_layer_height.fs
Normal file
41
resources/shaders/140/variable_layer_height.fs
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
#version 140
|
||||
|
||||
#define M_PI 3.1415926535897932384626433832795
|
||||
|
||||
// 2D texture (1D texture split by the rows) of color along the object Z axis.
|
||||
uniform sampler2D z_texture;
|
||||
// Scaling from the Z texture rows coordinate to the normalized texture row coordinate.
|
||||
uniform float z_to_texture_row;
|
||||
uniform float z_texture_row_to_normalized;
|
||||
uniform float z_cursor;
|
||||
uniform float z_cursor_band_width;
|
||||
|
||||
// x = tainted, y = specular;
|
||||
in vec2 intensity;
|
||||
|
||||
in float object_z;
|
||||
|
||||
void main()
|
||||
{
|
||||
float object_z_row = z_to_texture_row * object_z;
|
||||
// Index of the row in the texture.
|
||||
float z_texture_row = floor(object_z_row);
|
||||
// Normalized coordinate from 0. to 1.
|
||||
float z_texture_col = object_z_row - z_texture_row;
|
||||
float z_blend = 0.25 * cos(min(M_PI, abs(M_PI * (object_z - z_cursor) * 1.8 / z_cursor_band_width))) + 0.25;
|
||||
// Calculate level of detail from the object Z coordinate.
|
||||
// This makes the slowly sloping surfaces to be shown with high detail (with stripes),
|
||||
// and the vertical surfaces to be shown with low detail (no stripes)
|
||||
float z_in_cells = object_z_row * 190.;
|
||||
// Gradient of Z projected on the screen.
|
||||
float dx_vtc = dFdx(z_in_cells);
|
||||
float dy_vtc = dFdy(z_in_cells);
|
||||
float lod = clamp(0.5 * log2(max(dx_vtc * dx_vtc, dy_vtc * dy_vtc)), 0., 1.);
|
||||
// Sample the Z texture. Texture coordinates are normalized to <0, 1>.
|
||||
vec4 color = vec4(0.25, 0.25, 0.25, 1.0);
|
||||
if (z_texture_row >= 0.0)
|
||||
color = mix(texture(z_texture, vec2(z_texture_col, z_texture_row_to_normalized * (z_texture_row + 0.5 )), -10000.),
|
||||
texture(z_texture, vec2(z_texture_col, z_texture_row_to_normalized * (z_texture_row * 2. + 1.)), 10000.), lod);
|
||||
// Mix the final color.
|
||||
gl_FragColor = vec4(vec3(intensity.y), 1.0) + intensity.x * mix(color, vec4(1.0, 1.0, 0.0, 1.0), z_blend);
|
||||
}
|
||||
60
resources/shaders/140/variable_layer_height.vs
Normal file
60
resources/shaders/140/variable_layer_height.vs
Normal file
|
|
@ -0,0 +1,60 @@
|
|||
#version 140
|
||||
|
||||
#define INTENSITY_CORRECTION 0.6
|
||||
|
||||
const vec3 LIGHT_TOP_DIR = vec3(-0.4574957, 0.4574957, 0.7624929);
|
||||
#define LIGHT_TOP_DIFFUSE (0.8 * INTENSITY_CORRECTION)
|
||||
#define LIGHT_TOP_SPECULAR (0.125 * INTENSITY_CORRECTION)
|
||||
#define LIGHT_TOP_SHININESS 20.0
|
||||
|
||||
const vec3 LIGHT_FRONT_DIR = vec3(0.6985074, 0.1397015, 0.6985074);
|
||||
#define LIGHT_FRONT_DIFFUSE (0.3 * INTENSITY_CORRECTION)
|
||||
//#define LIGHT_FRONT_SPECULAR (0.0 * INTENSITY_CORRECTION)
|
||||
//#define LIGHT_FRONT_SHININESS 5.0
|
||||
|
||||
#define INTENSITY_AMBIENT 0.3
|
||||
|
||||
uniform mat4 view_model_matrix;
|
||||
uniform mat4 projection_matrix;
|
||||
uniform mat3 view_normal_matrix;
|
||||
uniform mat4 volume_world_matrix;
|
||||
uniform float object_max_z;
|
||||
|
||||
in vec3 v_position;
|
||||
in vec3 v_normal;
|
||||
in vec2 v_tex_coord;
|
||||
|
||||
// x = tainted, y = specular;
|
||||
out vec2 intensity;
|
||||
|
||||
out float object_z;
|
||||
|
||||
void main()
|
||||
{
|
||||
// =====================================================
|
||||
// NOTE:
|
||||
// when object_max_z > 0.0 we are rendering the overlay
|
||||
// when object_max_z == 0.0 we are rendering the volumes
|
||||
// =====================================================
|
||||
|
||||
// First transform the normal into camera space and normalize the result.
|
||||
vec3 normal = (object_max_z > 0.0) ? vec3(0.0, 0.0, 1.0) : normalize(view_normal_matrix * v_normal);
|
||||
|
||||
// Compute the cos of the angle between the normal and lights direction. The light is directional so the direction is constant for every vertex.
|
||||
// Since these two are normalized the cosine is the dot product. We also need to clamp the result to the [0,1] range.
|
||||
float NdotL = max(dot(normal, LIGHT_TOP_DIR), 0.0);
|
||||
|
||||
intensity.x = INTENSITY_AMBIENT + NdotL * LIGHT_TOP_DIFFUSE;
|
||||
vec4 position = view_model_matrix * vec4(v_position, 1.0);
|
||||
intensity.y = LIGHT_TOP_SPECULAR * pow(max(dot(-normalize(position.xyz), reflect(-LIGHT_TOP_DIR, normal)), 0.0), LIGHT_TOP_SHININESS);
|
||||
|
||||
// Perform the same lighting calculation for the 2nd light source (no specular)
|
||||
NdotL = max(dot(normal, LIGHT_FRONT_DIR), 0.0);
|
||||
|
||||
intensity.x += NdotL * LIGHT_FRONT_DIFFUSE;
|
||||
|
||||
// Scaled to widths of the Z texture.
|
||||
object_z = (object_max_z > 0.0) ? object_max_z * v_tex_coord.y : (volume_world_matrix * vec4(v_position, 1.0)).z;
|
||||
|
||||
gl_Position = projection_matrix * position;
|
||||
}
|
||||
11
resources/shaders/background.fs
Normal file
11
resources/shaders/background.fs
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
#version 110
|
||||
|
||||
uniform vec4 top_color;
|
||||
uniform vec4 bottom_color;
|
||||
|
||||
varying vec2 tex_coord;
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_FragColor = mix(bottom_color, top_color, tex_coord.y);
|
||||
}
|
||||
9
resources/shaders/background.vs
Normal file
9
resources/shaders/background.vs
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
#version 110
|
||||
|
||||
varying vec2 tex_coord;
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_Position = gl_Vertex;
|
||||
tex_coord = gl_MultiTexCoord0.xy;
|
||||
}
|
||||
8
resources/shaders/flat.fs
Normal file
8
resources/shaders/flat.fs
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
#version 110
|
||||
|
||||
uniform vec4 uniform_color;
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_FragColor = uniform_color;
|
||||
}
|
||||
10
resources/shaders/flat_texture.fs
Normal file
10
resources/shaders/flat_texture.fs
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
#version 110
|
||||
|
||||
uniform sampler2D uniform_texture;
|
||||
|
||||
varying vec2 tex_coord;
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_FragColor = texture2D(uniform_texture, tex_coord);
|
||||
}
|
||||
9
resources/shaders/flat_texture.vs
Normal file
9
resources/shaders/flat_texture.vs
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
#version 110
|
||||
|
||||
varying vec2 tex_coord;
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_Position = ftransform();
|
||||
tex_coord = gl_MultiTexCoord0.xy;
|
||||
}
|
||||
|
|
@ -48,7 +48,6 @@ varying vec2 intensity;
|
|||
|
||||
uniform PrintVolumeDetection print_volume;
|
||||
|
||||
varying vec4 model_pos;
|
||||
varying vec4 world_pos;
|
||||
varying float world_normal_z;
|
||||
varying vec3 eye_normal;
|
||||
|
|
|
|||
|
|
@ -38,7 +38,6 @@ varying vec2 intensity;
|
|||
|
||||
varying vec3 clipping_planes_dots;
|
||||
|
||||
varying vec4 model_pos;
|
||||
varying vec4 world_pos;
|
||||
varying float world_normal_z;
|
||||
varying vec3 eye_normal;
|
||||
|
|
@ -60,7 +59,6 @@ void main()
|
|||
NdotL = max(dot(eye_normal, LIGHT_FRONT_DIR), 0.0);
|
||||
intensity.x += NdotL * LIGHT_FRONT_DIFFUSE;
|
||||
|
||||
model_pos = gl_Vertex;
|
||||
// Point in homogenous coordinates.
|
||||
world_pos = volume_world_matrix * gl_Vertex;
|
||||
|
||||
|
|
|
|||
|
|
@ -1,22 +0,0 @@
|
|||
#version 110
|
||||
|
||||
uniform bool use_fixed_screen_size;
|
||||
uniform float zoom;
|
||||
uniform float point_size;
|
||||
uniform float near_plane_height;
|
||||
|
||||
float fixed_screen_size()
|
||||
{
|
||||
return point_size;
|
||||
}
|
||||
|
||||
float fixed_world_size()
|
||||
{
|
||||
return (gl_Position.w == 1.0) ? zoom * near_plane_height * point_size : near_plane_height * point_size / gl_Position.w;
|
||||
}
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_Position = ftransform();
|
||||
gl_PointSize = use_fixed_screen_size ? fixed_screen_size() : fixed_world_size();
|
||||
}
|
||||
|
|
@ -1,22 +0,0 @@
|
|||
// version 120 is needed for gl_PointCoord
|
||||
#version 120
|
||||
|
||||
uniform vec4 uniform_color;
|
||||
uniform float percent_outline_radius;
|
||||
uniform float percent_center_radius;
|
||||
|
||||
vec4 calc_color(float radius, vec4 color)
|
||||
{
|
||||
return ((radius < percent_center_radius) || (radius > 1.0 - percent_outline_radius)) ?
|
||||
vec4(0.5 * color.rgb, color.a) : color;
|
||||
}
|
||||
|
||||
void main()
|
||||
{
|
||||
vec2 pos = (gl_PointCoord - 0.5) * 2.0;
|
||||
float radius = length(pos);
|
||||
if (radius > 1.0)
|
||||
discard;
|
||||
|
||||
gl_FragColor = calc_color(radius, uniform_color);
|
||||
}
|
||||
|
|
@ -1,22 +0,0 @@
|
|||
#version 120
|
||||
|
||||
uniform bool use_fixed_screen_size;
|
||||
uniform float zoom;
|
||||
uniform float point_size;
|
||||
uniform float near_plane_height;
|
||||
|
||||
float fixed_screen_size()
|
||||
{
|
||||
return point_size;
|
||||
}
|
||||
|
||||
float fixed_world_size()
|
||||
{
|
||||
return (gl_Position.w == 1.0) ? zoom * near_plane_height * point_size : near_plane_height * point_size / gl_Position.w;
|
||||
}
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_Position = ftransform();
|
||||
gl_PointSize = use_fixed_screen_size ? fixed_screen_size() : fixed_world_size();
|
||||
}
|
||||
|
|
@ -1,21 +1,21 @@
|
|||
#version 110
|
||||
|
||||
const vec3 back_color_dark = vec3(0.235, 0.235, 0.235);
|
||||
const vec3 back_color_dark = vec3(0.235, 0.235, 0.235);
|
||||
const vec3 back_color_light = vec3(0.365, 0.365, 0.365);
|
||||
|
||||
uniform sampler2D texture;
|
||||
uniform bool transparent_background;
|
||||
uniform bool svg_source;
|
||||
|
||||
varying vec2 tex_coords;
|
||||
varying vec2 tex_coord;
|
||||
|
||||
vec4 svg_color()
|
||||
{
|
||||
// takes foreground from texture
|
||||
vec4 fore_color = texture2D(texture, tex_coords);
|
||||
vec4 fore_color = texture2D(texture, tex_coord);
|
||||
|
||||
// calculates radial gradient
|
||||
vec3 back_color = vec3(mix(back_color_light, back_color_dark, smoothstep(0.0, 0.5, length(abs(tex_coords.xy) - vec2(0.5)))));
|
||||
vec3 back_color = vec3(mix(back_color_light, back_color_dark, smoothstep(0.0, 0.5, length(abs(tex_coord.xy) - vec2(0.5)))));
|
||||
|
||||
// blends foreground with background
|
||||
return vec4(mix(back_color, fore_color.rgb, fore_color.a), transparent_background ? fore_color.a : 1.0);
|
||||
|
|
@ -24,7 +24,7 @@ vec4 svg_color()
|
|||
vec4 non_svg_color()
|
||||
{
|
||||
// takes foreground from texture
|
||||
vec4 color = texture2D(texture, tex_coords);
|
||||
vec4 color = texture2D(texture, tex_coord);
|
||||
return vec4(color.rgb, transparent_background ? color.a * 0.25 : color.a);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,14 +1,9 @@
|
|||
#version 110
|
||||
|
||||
attribute vec3 v_position;
|
||||
attribute vec2 v_tex_coords;
|
||||
|
||||
varying vec2 tex_coords;
|
||||
varying vec2 tex_coord;
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_Position = gl_ModelViewProjectionMatrix * vec4(v_position.x, v_position.y, v_position.z, 1.0);
|
||||
// the following line leads to crash on some Intel graphics card
|
||||
//gl_Position = gl_ModelViewProjectionMatrix * vec4(v_position, 1.0);
|
||||
tex_coords = v_tex_coords;
|
||||
gl_Position = ftransform();
|
||||
tex_coord = gl_MultiTexCoord0.xy;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1553,23 +1553,11 @@ int CLI::run(int argc, char **argv)
|
|||
o->cut(Z, m_config.opt_float("cut"), &out);
|
||||
}
|
||||
#else
|
||||
ModelObject* object = model.objects.front();
|
||||
const BoundingBoxf3& box = object->bounding_box();
|
||||
const float Margin = 20.0;
|
||||
const float max_x = box.size()(0) / 2.0 + Margin;
|
||||
const float min_x = -max_x;
|
||||
const float max_y = box.size()(1) / 2.0 + Margin;
|
||||
const float min_y = -max_y;
|
||||
|
||||
std::array<Vec3d, 4> plane_points;
|
||||
plane_points[0] = { min_x, min_y, 0 };
|
||||
plane_points[1] = { max_x, min_y, 0 };
|
||||
plane_points[2] = { max_x, max_y, 0 };
|
||||
plane_points[3] = { min_x, max_y, 0 };
|
||||
for (Vec3d& point : plane_points) {
|
||||
point += box.center();
|
||||
}
|
||||
model.objects.front()->cut(0, plane_points, ModelObjectCutAttribute::KeepUpper | ModelObjectCutAttribute::KeepLower);
|
||||
Cut cut(model.objects.front(), 0, Geometry::translation_transform(m_config.opt_float("cut") * Vec3d::UnitZ()),
|
||||
ModelObjectCutAttribute::KeepLower | ModelObjectCutAttribute::KeepUpper | ModelObjectCutAttribute::PlaceOnCutUpper);
|
||||
auto cut_objects = cut.perform_with_plane();
|
||||
for (ModelObject* obj : cut_objects)
|
||||
model.add_object(*obj);
|
||||
#endif
|
||||
model.delete_object(size_t(0));
|
||||
}
|
||||
|
|
@ -2279,12 +2267,12 @@ int CLI::run(int argc, char **argv)
|
|||
else
|
||||
colors.push_back("#FFFFFF");
|
||||
|
||||
std::vector<std::array<float, 4>> colors_out(colors.size());
|
||||
unsigned char rgb_color[3] = {};
|
||||
std::vector<ColorRGBA> colors_out(colors.size());
|
||||
ColorRGBA rgb_color;
|
||||
for (const std::string& color : colors) {
|
||||
Slic3r::GUI::BitmapCache::parse_color(color, rgb_color);
|
||||
Slic3r::decode_color(color, rgb_color);
|
||||
size_t color_idx = &color - &colors.front();
|
||||
colors_out[color_idx] = { float(rgb_color[0]) / 255.f, float(rgb_color[1]) / 255.f, float(rgb_color[2]) / 255.f, 1.f };
|
||||
colors_out[color_idx] = rgb_color;
|
||||
}
|
||||
|
||||
int gl_major, gl_minor, gl_verbos;
|
||||
|
|
@ -2353,19 +2341,16 @@ int CLI::run(int argc, char **argv)
|
|||
// continue;
|
||||
for (int instance_idx = 0; instance_idx < (int)model_object.instances.size(); ++ instance_idx) {
|
||||
const ModelInstance &model_instance = *model_object.instances[instance_idx];
|
||||
glvolume_collection.load_object_volume(&model_object, obj_idx, volume_idx, instance_idx, "volume", true, false, true);
|
||||
glvolume_collection.load_object_volume(&model_object, obj_idx, volume_idx, instance_idx, false, true);
|
||||
//glvolume_collection.volumes.back()->geometry_id = key.geometry_id;
|
||||
std::string color = filament_color?filament_color->get_at(extruder_id - 1):"#00FF00";
|
||||
|
||||
unsigned char rgb_color[3] = {};
|
||||
Slic3r::GUI::BitmapCache::parse_color(color, rgb_color);
|
||||
glvolume_collection.volumes.back()->set_render_color( float(rgb_color[0]) / 255.f, float(rgb_color[1]) / 255.f, float(rgb_color[2]) / 255.f, 1.f);
|
||||
ColorRGBA rgb_color;
|
||||
Slic3r::decode_color(color, rgb_color);
|
||||
glvolume_collection.volumes.back()->set_render_color(rgb_color);
|
||||
|
||||
std::array<float, 4> new_color;
|
||||
new_color[0] = float(rgb_color[0]) / 255.f;
|
||||
new_color[1] = float(rgb_color[1]) / 255.f;
|
||||
new_color[2] = float(rgb_color[2]) / 255.f;
|
||||
new_color[3] = 1.f;
|
||||
ColorRGBA new_color;
|
||||
new_color = rgb_color;
|
||||
glvolume_collection.volumes.back()->set_color(new_color);
|
||||
glvolume_collection.volumes.back()->printable = model_instance.printable;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -161,6 +161,7 @@ namespace ImGui
|
|||
const wchar_t ClippyMarker = 0x0802;
|
||||
const wchar_t InfoMarker = 0x0803;
|
||||
const wchar_t SliderFloatEditBtnIcon = 0x0804;
|
||||
const wchar_t ClipboardBtnIcon = 0x0805;
|
||||
|
||||
// BBS
|
||||
const wchar_t CircleButtonIcon = 0x0810;
|
||||
|
|
@ -196,6 +197,7 @@ namespace ImGui
|
|||
const wchar_t CloseBlockNotifButton = 0x0833;
|
||||
const wchar_t CloseBlockNotifHoverButton = 0x0834;
|
||||
const wchar_t BlockNotifErrorIcon = 0x0835;
|
||||
const wchar_t ClipboardBtnDarkIcon = 0x0836;
|
||||
|
||||
// void MyFunction(const char* name, const MyMatrix44& v);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6046,8 +6046,18 @@ bool ImGui::Begin(const char* name, bool* p_open, ImGuiWindowFlags flags)
|
|||
window->Pos = FindBestWindowPosForPopup(window);
|
||||
else if ((flags & ImGuiWindowFlags_Popup) != 0 && !window_pos_set_by_api && window_just_appearing_after_hidden_for_resize)
|
||||
window->Pos = FindBestWindowPosForPopup(window);
|
||||
else if ((flags & ImGuiWindowFlags_Tooltip) != 0 && !window_pos_set_by_api && !window_is_child_tooltip)
|
||||
window->Pos = FindBestWindowPosForPopup(window);
|
||||
// Orca: Allow fixed tooltip pos while still being clamped inside the render area
|
||||
else if ((flags & ImGuiWindowFlags_Tooltip) != 0 && !window_is_child_tooltip) {
|
||||
if (window_pos_set_by_api) {
|
||||
// Hack: add ImGuiWindowFlags_Popup so it does not follow cursor
|
||||
ImGuiWindowFlags old_flags = window->Flags;
|
||||
window->Flags |= ImGuiWindowFlags_Popup;
|
||||
window->Pos = FindBestWindowPosForPopup(window);
|
||||
window->Flags = old_flags;
|
||||
} else {
|
||||
window->Pos = FindBestWindowPosForPopup(window);
|
||||
}
|
||||
}
|
||||
|
||||
// Calculate the range of allowed position for that window (to be movable and visible past safe area padding)
|
||||
// When clamping to stay visible, we will enforce that window->Pos stays inside of visibility_rect.
|
||||
|
|
|
|||
|
|
@ -93,6 +93,9 @@ public:
|
|||
// Called on initial G-code preview on OpenGL vertex buffer interleaved normals and vertices.
|
||||
bool all_paths_inside_vertices_and_normals_interleaved(const std::vector<float>& paths, const Eigen::AlignedBox<float, 3>& bbox, bool ignore_bottom = true) const;
|
||||
|
||||
const std::pair<std::vector<Vec2d>, std::vector<Vec2d>>& top_bottom_convex_hull_decomposition_scene() const { return m_top_bottom_convex_hull_decomposition_scene; }
|
||||
const std::pair<std::vector<Vec2d>, std::vector<Vec2d>>& top_bottom_convex_hull_decomposition_bed() const { return m_top_bottom_convex_hull_decomposition_bed; }
|
||||
|
||||
private:
|
||||
// Source definition of the print bed geometry (PrintConfig::printable_area)
|
||||
std::vector<Vec2d> m_bed_shape;
|
||||
|
|
|
|||
|
|
@ -56,6 +56,8 @@ set(lisbslic3r_sources
|
|||
Clipper2Utils.cpp
|
||||
Clipper2Utils.hpp
|
||||
ClipperZUtils.hpp
|
||||
Color.cpp
|
||||
Color.hpp
|
||||
Config.cpp
|
||||
Config.hpp
|
||||
CurveAnalyzer.cpp
|
||||
|
|
@ -200,12 +202,17 @@ set(lisbslic3r_sources
|
|||
BlacklistedLibraryCheck.hpp
|
||||
LocalesUtils.cpp
|
||||
LocalesUtils.hpp
|
||||
CutUtils.cpp
|
||||
CutUtils.hpp
|
||||
Model.cpp
|
||||
Model.hpp
|
||||
ModelArrange.hpp
|
||||
ModelArrange.cpp
|
||||
MultiMaterialSegmentation.cpp
|
||||
MultiMaterialSegmentation.hpp
|
||||
Measure.hpp
|
||||
Measure.cpp
|
||||
MeasureUtils.hpp
|
||||
CustomGCode.cpp
|
||||
CustomGCode.hpp
|
||||
Arrange.hpp
|
||||
|
|
@ -305,6 +312,7 @@ set(lisbslic3r_sources
|
|||
Surface.hpp
|
||||
SurfaceCollection.cpp
|
||||
SurfaceCollection.hpp
|
||||
SurfaceMesh.hpp
|
||||
SVG.cpp
|
||||
SVG.hpp
|
||||
Technologies.hpp
|
||||
|
|
|
|||
420
src/libslic3r/Color.cpp
Normal file
420
src/libslic3r/Color.cpp
Normal file
|
|
@ -0,0 +1,420 @@
|
|||
#include "libslic3r.h"
|
||||
#include "Color.hpp"
|
||||
|
||||
#include <random>
|
||||
|
||||
static const float INV_255 = 1.0f / 255.0f;
|
||||
|
||||
namespace Slic3r {
|
||||
|
||||
// Conversion from RGB to HSV color space
|
||||
// The input RGB values are in the range [0, 1]
|
||||
// The output HSV values are in the ranges h = [0, 360], and s, v = [0, 1]
|
||||
static void RGBtoHSV(float r, float g, float b, float& h, float& s, float& v)
|
||||
{
|
||||
assert(0.0f <= r && r <= 1.0f);
|
||||
assert(0.0f <= g && g <= 1.0f);
|
||||
assert(0.0f <= b && b <= 1.0f);
|
||||
|
||||
const float max_comp = std::max(std::max(r, g), b);
|
||||
const float min_comp = std::min(std::min(r, g), b);
|
||||
const float delta = max_comp - min_comp;
|
||||
|
||||
if (delta > 0.0f) {
|
||||
if (max_comp == r)
|
||||
h = 60.0f * (std::fmod(((g - b) / delta), 6.0f));
|
||||
else if (max_comp == g)
|
||||
h = 60.0f * (((b - r) / delta) + 2.0f);
|
||||
else if (max_comp == b)
|
||||
h = 60.0f * (((r - g) / delta) + 4.0f);
|
||||
|
||||
s = (max_comp > 0.0f) ? delta / max_comp : 0.0f;
|
||||
}
|
||||
else {
|
||||
h = 0.0f;
|
||||
s = 0.0f;
|
||||
}
|
||||
v = max_comp;
|
||||
|
||||
while (h < 0.0f) { h += 360.0f; }
|
||||
while (h > 360.0f) { h -= 360.0f; }
|
||||
|
||||
assert(0.0f <= s && s <= 1.0f);
|
||||
assert(0.0f <= v && v <= 1.0f);
|
||||
assert(0.0f <= h && h <= 360.0f);
|
||||
}
|
||||
|
||||
// Conversion from HSV to RGB color space
|
||||
// The input HSV values are in the ranges h = [0, 360], and s, v = [0, 1]
|
||||
// The output RGB values are in the range [0, 1]
|
||||
static void HSVtoRGB(float h, float s, float v, float& r, float& g, float& b)
|
||||
{
|
||||
assert(0.0f <= s && s <= 1.0f);
|
||||
assert(0.0f <= v && v <= 1.0f);
|
||||
assert(0.0f <= h && h <= 360.0f);
|
||||
|
||||
const float chroma = v * s;
|
||||
const float h_prime = std::fmod(h / 60.0f, 6.0f);
|
||||
const float x = chroma * (1.0f - std::abs(std::fmod(h_prime, 2.0f) - 1.0f));
|
||||
const float m = v - chroma;
|
||||
|
||||
if (0.0f <= h_prime && h_prime < 1.0f) {
|
||||
r = chroma;
|
||||
g = x;
|
||||
b = 0.0f;
|
||||
}
|
||||
else if (1.0f <= h_prime && h_prime < 2.0f) {
|
||||
r = x;
|
||||
g = chroma;
|
||||
b = 0.0f;
|
||||
}
|
||||
else if (2.0f <= h_prime && h_prime < 3.0f) {
|
||||
r = 0.0f;
|
||||
g = chroma;
|
||||
b = x;
|
||||
}
|
||||
else if (3.0f <= h_prime && h_prime < 4.0f) {
|
||||
r = 0.0f;
|
||||
g = x;
|
||||
b = chroma;
|
||||
}
|
||||
else if (4.0f <= h_prime && h_prime < 5.0f) {
|
||||
r = x;
|
||||
g = 0.0f;
|
||||
b = chroma;
|
||||
}
|
||||
else if (5.0f <= h_prime && h_prime < 6.0f) {
|
||||
r = chroma;
|
||||
g = 0.0f;
|
||||
b = x;
|
||||
}
|
||||
else {
|
||||
r = 0.0f;
|
||||
g = 0.0f;
|
||||
b = 0.0f;
|
||||
}
|
||||
|
||||
r += m;
|
||||
g += m;
|
||||
b += m;
|
||||
|
||||
assert(0.0f <= r && r <= 1.0f);
|
||||
assert(0.0f <= g && g <= 1.0f);
|
||||
assert(0.0f <= b && b <= 1.0f);
|
||||
}
|
||||
|
||||
class Randomizer
|
||||
{
|
||||
std::random_device m_rd;
|
||||
|
||||
public:
|
||||
float random_float(float min, float max) {
|
||||
std::mt19937 rand_generator(m_rd());
|
||||
std::uniform_real_distribution<float> distrib(min, max);
|
||||
return distrib(rand_generator);
|
||||
}
|
||||
};
|
||||
|
||||
ColorRGB::ColorRGB(float r, float g, float b)
|
||||
: m_data({ std::clamp(r, 0.0f, 1.0f), std::clamp(g, 0.0f, 1.0f), std::clamp(b, 0.0f, 1.0f) })
|
||||
{
|
||||
}
|
||||
|
||||
ColorRGB::ColorRGB(unsigned char r, unsigned char g, unsigned char b)
|
||||
: m_data({ std::clamp(r * INV_255, 0.0f, 1.0f), std::clamp(g * INV_255, 0.0f, 1.0f), std::clamp(b * INV_255, 0.0f, 1.0f) })
|
||||
{
|
||||
}
|
||||
|
||||
bool ColorRGB::operator < (const ColorRGB& other) const
|
||||
{
|
||||
for (size_t i = 0; i < 3; ++i) {
|
||||
if (m_data[i] < other.m_data[i])
|
||||
return true;
|
||||
else if (m_data[i] > other.m_data[i])
|
||||
return false;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool ColorRGB::operator > (const ColorRGB& other) const
|
||||
{
|
||||
for (size_t i = 0; i < 3; ++i) {
|
||||
if (m_data[i] > other.m_data[i])
|
||||
return true;
|
||||
else if (m_data[i] < other.m_data[i])
|
||||
return false;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
ColorRGB ColorRGB::operator + (const ColorRGB& other) const
|
||||
{
|
||||
ColorRGB ret;
|
||||
for (size_t i = 0; i < 3; ++i) {
|
||||
ret.m_data[i] = std::clamp(m_data[i] + other.m_data[i], 0.0f, 1.0f);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
ColorRGB ColorRGB::operator * (float value) const
|
||||
{
|
||||
assert(value >= 0.0f);
|
||||
ColorRGB ret;
|
||||
for (size_t i = 0; i < 3; ++i) {
|
||||
ret.m_data[i] = std::clamp(value * m_data[i], 0.0f, 1.0f);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
ColorRGBA::ColorRGBA(float r, float g, float b, float a)
|
||||
: m_data({ std::clamp(r, 0.0f, 1.0f), std::clamp(g, 0.0f, 1.0f), std::clamp(b, 0.0f, 1.0f), std::clamp(a, 0.0f, 1.0f) })
|
||||
{
|
||||
}
|
||||
|
||||
ColorRGBA::ColorRGBA(unsigned char r, unsigned char g, unsigned char b, unsigned char a)
|
||||
: m_data({ std::clamp(r * INV_255, 0.0f, 1.0f), std::clamp(g * INV_255, 0.0f, 1.0f), std::clamp(b * INV_255, 0.0f, 1.0f), std::clamp(a * INV_255, 0.0f, 1.0f) })
|
||||
{
|
||||
}
|
||||
|
||||
bool ColorRGBA::operator < (const ColorRGBA& other) const
|
||||
{
|
||||
for (size_t i = 0; i < 3; ++i) {
|
||||
if (m_data[i] < other.m_data[i])
|
||||
return true;
|
||||
else if (m_data[i] > other.m_data[i])
|
||||
return false;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool ColorRGBA::operator > (const ColorRGBA& other) const
|
||||
{
|
||||
for (size_t i = 0; i < 3; ++i) {
|
||||
if (m_data[i] > other.m_data[i])
|
||||
return true;
|
||||
else if (m_data[i] < other.m_data[i])
|
||||
return false;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
ColorRGBA ColorRGBA::operator + (const ColorRGBA& other) const
|
||||
{
|
||||
ColorRGBA ret;
|
||||
for (size_t i = 0; i < 3; ++i) {
|
||||
ret.m_data[i] = std::clamp(m_data[i] + other.m_data[i], 0.0f, 1.0f);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
ColorRGBA ColorRGBA::operator * (float value) const
|
||||
{
|
||||
assert(value >= 0.0f);
|
||||
ColorRGBA ret;
|
||||
for (size_t i = 0; i < 3; ++i) {
|
||||
ret.m_data[i] = std::clamp(value * m_data[i], 0.0f, 1.0f);
|
||||
}
|
||||
ret.m_data[3] = this->m_data[3];
|
||||
return ret;
|
||||
}
|
||||
|
||||
ColorRGB operator * (float value, const ColorRGB& other) { return other * value; }
|
||||
ColorRGBA operator * (float value, const ColorRGBA& other) { return other * value; }
|
||||
|
||||
ColorRGB lerp(const ColorRGB& a, const ColorRGB& b, float t)
|
||||
{
|
||||
assert(0.0f <= t && t <= 1.0f);
|
||||
return (1.0f - t) * a + t * b;
|
||||
}
|
||||
|
||||
ColorRGBA lerp(const ColorRGBA& a, const ColorRGBA& b, float t)
|
||||
{
|
||||
assert(0.0f <= t && t <= 1.0f);
|
||||
return (1.0f - t) * a + t * b;
|
||||
}
|
||||
|
||||
ColorRGB complementary(const ColorRGB& color)
|
||||
{
|
||||
return { 1.0f - color.r(), 1.0f - color.g(), 1.0f - color.b() };
|
||||
}
|
||||
|
||||
ColorRGBA complementary(const ColorRGBA& color)
|
||||
{
|
||||
return { 1.0f - color.r(), 1.0f - color.g(), 1.0f - color.b(), color.a() };
|
||||
}
|
||||
|
||||
ColorRGB saturate(const ColorRGB& color, float factor)
|
||||
{
|
||||
float h, s, v;
|
||||
RGBtoHSV(color.r(), color.g(), color.b(), h, s, v);
|
||||
s = std::clamp(s * factor, 0.0f, 1.0f);
|
||||
float r, g, b;
|
||||
HSVtoRGB(h, s, v, r, g, b);
|
||||
return { r, g, b };
|
||||
}
|
||||
|
||||
ColorRGBA saturate(const ColorRGBA& color, float factor)
|
||||
{
|
||||
return to_rgba(saturate(to_rgb(color), factor), color.a());
|
||||
}
|
||||
|
||||
ColorRGB opposite(const ColorRGB& color)
|
||||
{
|
||||
float h, s, v;
|
||||
RGBtoHSV(color.r(), color.g(), color.b(), h, s, v);
|
||||
|
||||
h += 65.0f; // 65 instead 60 to avoid circle values
|
||||
if (h > 360.0f)
|
||||
h -= 360.0f;
|
||||
|
||||
Randomizer rnd;
|
||||
s = rnd.random_float(0.65f, 1.0f);
|
||||
v = rnd.random_float(0.65f, 1.0f);
|
||||
|
||||
float r, g, b;
|
||||
HSVtoRGB(h, s, v, r, g, b);
|
||||
return { r, g, b };
|
||||
}
|
||||
|
||||
ColorRGB opposite(const ColorRGB& a, const ColorRGB& b)
|
||||
{
|
||||
float ha, sa, va;
|
||||
RGBtoHSV(a.r(), a.g(), a.b(), ha, sa, va);
|
||||
float hb, sb, vb;
|
||||
RGBtoHSV(b.r(), b.g(), b.b(), hb, sb, vb);
|
||||
|
||||
float delta_h = std::abs(ha - hb);
|
||||
float start_h = (delta_h > 180.0f) ? std::min(ha, hb) : std::max(ha, hb);
|
||||
|
||||
start_h += 5.0f; // to avoid circle change of colors for 120 deg
|
||||
if (delta_h < 180.0f)
|
||||
delta_h = 360.0f - delta_h;
|
||||
|
||||
Randomizer rnd;
|
||||
float out_h = start_h + 0.5f * delta_h;
|
||||
if (out_h > 360.0f)
|
||||
out_h -= 360.0f;
|
||||
float out_s = rnd.random_float(0.65f, 1.0f);
|
||||
float out_v = rnd.random_float(0.65f, 1.0f);
|
||||
|
||||
float out_r, out_g, out_b;
|
||||
HSVtoRGB(out_h, out_s, out_v, out_r, out_g, out_b);
|
||||
return { out_r, out_g, out_b };
|
||||
}
|
||||
|
||||
bool can_decode_color(const std::string &color)
|
||||
{
|
||||
return (color.size() == 7 && color.front() == '#') || (color.size() == 9 && color.front() == '#');
|
||||
}
|
||||
|
||||
bool decode_color(const std::string& color_in, ColorRGB& color_out)
|
||||
{
|
||||
ColorRGBA rgba;
|
||||
if (!decode_color(color_in, rgba))
|
||||
return false;
|
||||
|
||||
color_out = to_rgb(rgba);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool decode_color(const std::string& color_in, ColorRGBA& color_out)
|
||||
{
|
||||
auto hex_digit_to_int = [](const char c) {
|
||||
return
|
||||
(c >= '0' && c <= '9') ? int(c - '0') :
|
||||
(c >= 'A' && c <= 'F') ? int(c - 'A') + 10 :
|
||||
(c >= 'a' && c <= 'f') ? int(c - 'a') + 10 : -1;
|
||||
};
|
||||
|
||||
color_out = ColorRGBA::BLACK();
|
||||
if (can_decode_color(color_in)) {
|
||||
const char *c = color_in.data() + 1;
|
||||
if (color_in.size() == 7) {
|
||||
for (unsigned int i = 0; i < 3; ++i) {
|
||||
const int digit1 = hex_digit_to_int(*c++);
|
||||
const int digit2 = hex_digit_to_int(*c++);
|
||||
if (digit1 != -1 && digit2 != -1)
|
||||
color_out.set(i, float(digit1 * 16 + digit2) * INV_255);
|
||||
}
|
||||
} else {
|
||||
for (unsigned int i = 0; i < 4; ++i) {
|
||||
const int digit1 = hex_digit_to_int(*c++);
|
||||
const int digit2 = hex_digit_to_int(*c++);
|
||||
if (digit1 != -1 && digit2 != -1)
|
||||
color_out.set(i, float(digit1 * 16 + digit2) * INV_255);
|
||||
}
|
||||
}
|
||||
} else
|
||||
return false;
|
||||
|
||||
assert(0.0f <= color_out.r() && color_out.r() <= 1.0f);
|
||||
assert(0.0f <= color_out.g() && color_out.g() <= 1.0f);
|
||||
assert(0.0f <= color_out.b() && color_out.b() <= 1.0f);
|
||||
assert(0.0f <= color_out.a() && color_out.a() <= 1.0f);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool decode_colors(const std::vector<std::string>& colors_in, std::vector<ColorRGB>& colors_out)
|
||||
{
|
||||
colors_out = std::vector<ColorRGB>(colors_in.size(), ColorRGB::BLACK());
|
||||
for (size_t i = 0; i < colors_in.size(); ++i) {
|
||||
if (!decode_color(colors_in[i], colors_out[i]))
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool decode_colors(const std::vector<std::string>& colors_in, std::vector<ColorRGBA>& colors_out)
|
||||
{
|
||||
colors_out = std::vector<ColorRGBA>(colors_in.size(), ColorRGBA::BLACK());
|
||||
for (size_t i = 0; i < colors_in.size(); ++i) {
|
||||
if (!decode_color(colors_in[i], colors_out[i]))
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
std::string encode_color(const ColorRGB& color)
|
||||
{
|
||||
char buffer[64];
|
||||
::sprintf(buffer, "#%02X%02X%02X", color.r_uchar(), color.g_uchar(), color.b_uchar());
|
||||
return std::string(buffer);
|
||||
}
|
||||
|
||||
std::string encode_color(const ColorRGBA& color) { return encode_color(to_rgb(color)); }
|
||||
|
||||
ColorRGB to_rgb(const ColorRGBA& other_rgba) { return { other_rgba.r(), other_rgba.g(), other_rgba.b() }; }
|
||||
ColorRGBA to_rgba(const ColorRGB& other_rgb) { return { other_rgb.r(), other_rgb.g(), other_rgb.b(), 1.0f }; }
|
||||
ColorRGBA to_rgba(const ColorRGB& other_rgb, float alpha) { return { other_rgb.r(), other_rgb.g(), other_rgb.b(), alpha }; }
|
||||
|
||||
ColorRGBA picking_decode(unsigned int id)
|
||||
{
|
||||
return {
|
||||
float((id >> 0) & 0xff) * INV_255, // red
|
||||
float((id >> 8) & 0xff) * INV_255, // green
|
||||
float((id >> 16) & 0xff) * INV_255, // blue
|
||||
float(picking_checksum_alpha_channel(id & 0xff, (id >> 8) & 0xff, (id >> 16) & 0xff)) * INV_255 // checksum for validating against unwanted alpha blending and multi sampling
|
||||
};
|
||||
}
|
||||
|
||||
unsigned int picking_encode(unsigned char r, unsigned char g, unsigned char b) { return r + (g << 8) + (b << 16); }
|
||||
|
||||
unsigned char picking_checksum_alpha_channel(unsigned char red, unsigned char green, unsigned char blue)
|
||||
{
|
||||
// 8 bit hash for the color
|
||||
unsigned char b = ((((37 * red) + green) & 0x0ff) * 37 + blue) & 0x0ff;
|
||||
// Increase enthropy by a bit reversal
|
||||
b = (b & 0xF0) >> 4 | (b & 0x0F) << 4;
|
||||
b = (b & 0xCC) >> 2 | (b & 0x33) << 2;
|
||||
b = (b & 0xAA) >> 1 | (b & 0x55) << 1;
|
||||
// Flip every second bit to increase the enthropy even more.
|
||||
b ^= 0x55;
|
||||
return b;
|
||||
}
|
||||
|
||||
} // namespace Slic3r
|
||||
|
||||
175
src/libslic3r/Color.hpp
Normal file
175
src/libslic3r/Color.hpp
Normal file
|
|
@ -0,0 +1,175 @@
|
|||
#ifndef slic3r_Color_hpp_
|
||||
#define slic3r_Color_hpp_
|
||||
|
||||
#include <array>
|
||||
#include <algorithm>
|
||||
|
||||
namespace Slic3r {
|
||||
|
||||
class ColorRGB
|
||||
{
|
||||
std::array<float, 3> m_data{1.0f, 1.0f, 1.0f};
|
||||
|
||||
public:
|
||||
ColorRGB() = default;
|
||||
ColorRGB(float r, float g, float b);
|
||||
ColorRGB(unsigned char r, unsigned char g, unsigned char b);
|
||||
ColorRGB(const ColorRGB& other) = default;
|
||||
|
||||
ColorRGB& operator = (const ColorRGB& other) { m_data = other.m_data; return *this; }
|
||||
|
||||
bool operator == (const ColorRGB& other) const { return m_data == other.m_data; }
|
||||
bool operator != (const ColorRGB& other) const { return !operator==(other); }
|
||||
bool operator < (const ColorRGB& other) const;
|
||||
bool operator > (const ColorRGB& other) const;
|
||||
|
||||
ColorRGB operator + (const ColorRGB& other) const;
|
||||
ColorRGB operator * (float value) const;
|
||||
|
||||
const float* const data() const { return m_data.data(); }
|
||||
|
||||
float r() const { return m_data[0]; }
|
||||
float g() const { return m_data[1]; }
|
||||
float b() const { return m_data[2]; }
|
||||
|
||||
void r(float r) { m_data[0] = std::clamp(r, 0.0f, 1.0f); }
|
||||
void g(float g) { m_data[1] = std::clamp(g, 0.0f, 1.0f); }
|
||||
void b(float b) { m_data[2] = std::clamp(b, 0.0f, 1.0f); }
|
||||
|
||||
void set(unsigned int comp, float value) {
|
||||
assert(0 <= comp && comp <= 2);
|
||||
m_data[comp] = std::clamp(value, 0.0f, 1.0f);
|
||||
}
|
||||
|
||||
unsigned char r_uchar() const { return static_cast<unsigned char>(m_data[0] * 255.0f); }
|
||||
unsigned char g_uchar() const { return static_cast<unsigned char>(m_data[1] * 255.0f); }
|
||||
unsigned char b_uchar() const { return static_cast<unsigned char>(m_data[2] * 255.0f); }
|
||||
|
||||
static const ColorRGB BLACK() { return { 0.0f, 0.0f, 0.0f }; }
|
||||
static const ColorRGB BLUE() { return { 0.0f, 0.0f, 1.0f }; }
|
||||
static const ColorRGB BLUEISH() { return { 0.5f, 0.5f, 1.0f }; }
|
||||
static const ColorRGB CYAN() { return { 0.0f, 1.0f, 1.0f }; }
|
||||
static const ColorRGB DARK_GRAY() { return { 0.25f, 0.25f, 0.25f }; }
|
||||
static const ColorRGB DARK_YELLOW() { return { 0.5f, 0.5f, 0.0f }; }
|
||||
static const ColorRGB GRAY() { return { 0.5f, 0.5f, 0.5f }; }
|
||||
static const ColorRGB GREEN() { return { 0.0f, 1.0f, 0.0f }; }
|
||||
static const ColorRGB GREENISH() { return { 0.5f, 1.0f, 0.5f }; }
|
||||
static const ColorRGB LIGHT_GRAY() { return { 0.75f, 0.75f, 0.75f }; }
|
||||
static const ColorRGB MAGENTA() { return { 1.0f, 0.0f, 1.0f }; }
|
||||
static const ColorRGB ORANGE() { return { 0.92f, 0.50f, 0.26f }; }
|
||||
static const ColorRGB RED() { return { 1.0f, 0.0f, 0.0f }; }
|
||||
static const ColorRGB REDISH() { return { 1.0f, 0.5f, 0.5f }; }
|
||||
static const ColorRGB YELLOW() { return { 1.0f, 1.0f, 0.0f }; }
|
||||
static const ColorRGB WHITE() { return { 1.0f, 1.0f, 1.0f }; }
|
||||
|
||||
static const ColorRGB X() { return { 0.75f, 0.0f, 0.0f }; }
|
||||
static const ColorRGB Y() { return { 0.0f, 0.75f, 0.0f }; }
|
||||
static const ColorRGB Z() { return { 0.0f, 0.0f, 0.75f }; }
|
||||
};
|
||||
|
||||
class ColorRGBA
|
||||
{
|
||||
std::array<float, 4> m_data{ 1.0f, 1.0f, 1.0f, 1.0f };
|
||||
|
||||
public:
|
||||
ColorRGBA() = default;
|
||||
ColorRGBA(float r, float g, float b, float a);
|
||||
ColorRGBA(unsigned char r, unsigned char g, unsigned char b, unsigned char a);
|
||||
ColorRGBA(const ColorRGBA& other) = default;
|
||||
|
||||
ColorRGBA& operator = (const ColorRGBA& other) { m_data = other.m_data; return *this; }
|
||||
|
||||
bool operator == (const ColorRGBA& other) const { return m_data == other.m_data; }
|
||||
bool operator != (const ColorRGBA& other) const { return !operator==(other); }
|
||||
bool operator < (const ColorRGBA& other) const;
|
||||
bool operator > (const ColorRGBA& other) const;
|
||||
|
||||
ColorRGBA operator + (const ColorRGBA& other) const;
|
||||
ColorRGBA operator * (float value) const;
|
||||
|
||||
const float* const data() const { return m_data.data(); }
|
||||
|
||||
float r() const { return m_data[0]; }
|
||||
float g() const { return m_data[1]; }
|
||||
float b() const { return m_data[2]; }
|
||||
float a() const { return m_data[3]; }
|
||||
|
||||
void r(float r) { m_data[0] = std::clamp(r, 0.0f, 1.0f); }
|
||||
void g(float g) { m_data[1] = std::clamp(g, 0.0f, 1.0f); }
|
||||
void b(float b) { m_data[2] = std::clamp(b, 0.0f, 1.0f); }
|
||||
void a(float a) { m_data[3] = std::clamp(a, 0.0f, 1.0f); }
|
||||
|
||||
void set(unsigned int comp, float value) {
|
||||
assert(0 <= comp && comp <= 3);
|
||||
m_data[comp] = std::clamp(value, 0.0f, 1.0f);
|
||||
}
|
||||
|
||||
unsigned char r_uchar() const { return static_cast<unsigned char>(m_data[0] * 255.0f); }
|
||||
unsigned char g_uchar() const { return static_cast<unsigned char>(m_data[1] * 255.0f); }
|
||||
unsigned char b_uchar() const { return static_cast<unsigned char>(m_data[2] * 255.0f); }
|
||||
unsigned char a_uchar() const { return static_cast<unsigned char>(m_data[3] * 255.0f); }
|
||||
|
||||
bool is_transparent() const { return m_data[3] < 1.0f; }
|
||||
|
||||
static const ColorRGBA BLACK() { return { 0.0f, 0.0f, 0.0f, 1.0f }; }
|
||||
static const ColorRGBA BLUE() { return { 0.0f, 0.0f, 1.0f, 1.0f }; }
|
||||
static const ColorRGBA BLUEISH() { return { 0.5f, 0.5f, 1.0f, 1.0f }; }
|
||||
static const ColorRGBA CYAN() { return { 0.0f, 1.0f, 1.0f, 1.0f }; }
|
||||
static const ColorRGBA DARK_GRAY() { return { 0.25f, 0.25f, 0.25f, 1.0f }; }
|
||||
static const ColorRGBA DARK_YELLOW() { return { 0.5f, 0.5f, 0.0f, 1.0f }; }
|
||||
static const ColorRGBA GRAY() { return { 0.5f, 0.5f, 0.5f, 1.0f }; }
|
||||
static const ColorRGBA GREEN() { return { 0.0f, 1.0f, 0.0f, 1.0f }; }
|
||||
static const ColorRGBA GREENISH() { return { 0.5f, 1.0f, 0.5f, 1.0f }; }
|
||||
static const ColorRGBA LIGHT_GRAY() { return { 0.75f, 0.75f, 0.75f, 1.0f }; }
|
||||
static const ColorRGBA MAGENTA() { return { 1.0f, 0.0f, 1.0f, 1.0f }; }
|
||||
static const ColorRGBA ORANGE() { return { 0.923f, 0.504f, 0.264f, 1.0f }; }
|
||||
static const ColorRGBA RED() { return { 1.0f, 0.0f, 0.0f, 1.0f }; }
|
||||
static const ColorRGBA REDISH() { return { 1.0f, 0.5f, 0.5f, 1.0f }; }
|
||||
static const ColorRGBA YELLOW() { return { 1.0f, 1.0f, 0.0f, 1.0f }; }
|
||||
static const ColorRGBA WHITE() { return { 1.0f, 1.0f, 1.0f, 1.0f }; }
|
||||
static const ColorRGBA ORCA() { return {0.0f, 150.f / 255.0f, 136.0f / 255, 1.0f}; }
|
||||
|
||||
static const ColorRGBA X() { return { 0.75f, 0.0f, 0.0f, 1.0f }; }
|
||||
static const ColorRGBA Y() { return { 0.0f, 0.75f, 0.0f, 1.0f }; }
|
||||
static const ColorRGBA Z() { return { 0.0f, 0.0f, 0.75f, 1.0f }; }
|
||||
};
|
||||
|
||||
ColorRGB operator * (float value, const ColorRGB& other);
|
||||
ColorRGBA operator * (float value, const ColorRGBA& other);
|
||||
|
||||
ColorRGB lerp(const ColorRGB& a, const ColorRGB& b, float t);
|
||||
ColorRGBA lerp(const ColorRGBA& a, const ColorRGBA& b, float t);
|
||||
|
||||
ColorRGB complementary(const ColorRGB& color);
|
||||
ColorRGBA complementary(const ColorRGBA& color);
|
||||
|
||||
ColorRGB saturate(const ColorRGB& color, float factor);
|
||||
ColorRGBA saturate(const ColorRGBA& color, float factor);
|
||||
|
||||
ColorRGB opposite(const ColorRGB& color);
|
||||
ColorRGB opposite(const ColorRGB& a, const ColorRGB& b);
|
||||
|
||||
bool can_decode_color(const std::string& color);
|
||||
|
||||
bool decode_color(const std::string& color_in, ColorRGB& color_out);
|
||||
bool decode_color(const std::string& color_in, ColorRGBA& color_out);
|
||||
|
||||
bool decode_colors(const std::vector<std::string>& colors_in, std::vector<ColorRGB>& colors_out);
|
||||
bool decode_colors(const std::vector<std::string>& colors_in, std::vector<ColorRGBA>& colors_out);
|
||||
|
||||
std::string encode_color(const ColorRGB& color);
|
||||
std::string encode_color(const ColorRGBA& color);
|
||||
|
||||
ColorRGB to_rgb(const ColorRGBA& other_rgba);
|
||||
ColorRGBA to_rgba(const ColorRGB& other_rgb);
|
||||
ColorRGBA to_rgba(const ColorRGB& other_rgb, float alpha);
|
||||
|
||||
ColorRGBA picking_decode(unsigned int id);
|
||||
unsigned int picking_encode(unsigned char r, unsigned char g, unsigned char b);
|
||||
// Produce an alpha channel checksum for the red green blue components. The alpha channel may then be used to verify, whether the rgb components
|
||||
// were not interpolated by alpha blending or multi sampling.
|
||||
unsigned char picking_checksum_alpha_channel(unsigned char red, unsigned char green, unsigned char blue);
|
||||
|
||||
} // namespace Slic3r
|
||||
|
||||
#endif /* slic3r_Color_hpp_ */
|
||||
662
src/libslic3r/CutUtils.cpp
Normal file
662
src/libslic3r/CutUtils.cpp
Normal file
|
|
@ -0,0 +1,662 @@
|
|||
///|/ Copyright (c) Prusa Research 2023 Oleksandra Iushchenko @YuSanka
|
||||
///|/
|
||||
///|/ PrusaSlicer is released under the terms of the AGPLv3 or higher
|
||||
///|/
|
||||
|
||||
#include "CutUtils.hpp"
|
||||
#include "Geometry.hpp"
|
||||
#include "libslic3r.h"
|
||||
#include "Model.hpp"
|
||||
#include "TriangleMeshSlicer.hpp"
|
||||
#include "TriangleSelector.hpp"
|
||||
#include "ObjectID.hpp"
|
||||
|
||||
#include <boost/log/trivial.hpp>
|
||||
|
||||
namespace Slic3r {
|
||||
|
||||
using namespace Geometry;
|
||||
|
||||
static void apply_tolerance(ModelVolume* vol)
|
||||
{
|
||||
ModelVolume::CutInfo& cut_info = vol->cut_info;
|
||||
|
||||
assert(cut_info.is_connector);
|
||||
if (!cut_info.is_processed)
|
||||
return;
|
||||
|
||||
Vec3d sf = vol->get_scaling_factor();
|
||||
|
||||
// make a "hole" wider
|
||||
sf[X] += double(cut_info.radius_tolerance);
|
||||
sf[Y] += double(cut_info.radius_tolerance);
|
||||
|
||||
// make a "hole" dipper
|
||||
sf[Z] += double(cut_info.height_tolerance);
|
||||
|
||||
vol->set_scaling_factor(sf);
|
||||
|
||||
// correct offset in respect to the new depth
|
||||
Vec3d rot_norm = rotation_transform(vol->get_rotation()) * Vec3d::UnitZ();
|
||||
if (rot_norm.norm() != 0.0)
|
||||
rot_norm.normalize();
|
||||
|
||||
double z_offset = 0.5 * static_cast<double>(cut_info.height_tolerance);
|
||||
if (cut_info.connector_type == CutConnectorType::Plug ||
|
||||
cut_info.connector_type == CutConnectorType::Snap)
|
||||
z_offset -= 0.05; // add small Z offset to better preview
|
||||
|
||||
vol->set_offset(vol->get_offset() + rot_norm * z_offset);
|
||||
}
|
||||
|
||||
static void add_cut_volume(TriangleMesh& mesh, ModelObject* object, const ModelVolume* src_volume, const Transform3d& cut_matrix, const std::string& suffix = {}, ModelVolumeType type = ModelVolumeType::MODEL_PART)
|
||||
{
|
||||
if (mesh.empty())
|
||||
return;
|
||||
|
||||
mesh.transform(cut_matrix);
|
||||
ModelVolume* vol = object->add_volume(mesh);
|
||||
vol->set_type(type);
|
||||
|
||||
vol->name = src_volume->name + suffix;
|
||||
// Don't copy the config's ID.
|
||||
vol->config.assign_config(src_volume->config);
|
||||
assert(vol->config.id().valid());
|
||||
assert(vol->config.id() != src_volume->config.id());
|
||||
vol->set_material(src_volume->material_id(), *src_volume->material());
|
||||
vol->cut_info = src_volume->cut_info;
|
||||
}
|
||||
|
||||
static void process_volume_cut( ModelVolume* volume, const Transform3d& instance_matrix, const Transform3d& cut_matrix,
|
||||
ModelObjectCutAttributes attributes, TriangleMesh& upper_mesh, TriangleMesh& lower_mesh)
|
||||
{
|
||||
const auto volume_matrix = volume->get_matrix();
|
||||
|
||||
const Transformation cut_transformation = Transformation(cut_matrix);
|
||||
const Transform3d invert_cut_matrix = cut_transformation.get_rotation_matrix().inverse() * translation_transform(-1 * cut_transformation.get_offset());
|
||||
|
||||
// Transform the mesh by the combined transformation matrix.
|
||||
// Flip the triangles in case the composite transformation is left handed.
|
||||
TriangleMesh mesh(volume->mesh());
|
||||
mesh.transform(invert_cut_matrix * instance_matrix * volume_matrix, true);
|
||||
|
||||
indexed_triangle_set upper_its, lower_its;
|
||||
cut_mesh(mesh.its, 0.0f, &upper_its, &lower_its);
|
||||
if (attributes.has(ModelObjectCutAttribute::KeepUpper))
|
||||
upper_mesh = TriangleMesh(upper_its);
|
||||
if (attributes.has(ModelObjectCutAttribute::KeepLower))
|
||||
lower_mesh = TriangleMesh(lower_its);
|
||||
}
|
||||
|
||||
static void process_connector_cut( ModelVolume* volume, const Transform3d& instance_matrix, const Transform3d& cut_matrix,
|
||||
ModelObjectCutAttributes attributes, ModelObject* upper, ModelObject* lower,
|
||||
std::vector<ModelObject*>& dowels)
|
||||
{
|
||||
assert(volume->cut_info.is_connector);
|
||||
volume->cut_info.set_processed();
|
||||
|
||||
const auto volume_matrix = volume->get_matrix();
|
||||
|
||||
// ! Don't apply instance transformation for the conntectors.
|
||||
// This transformation is already there
|
||||
if (volume->cut_info.connector_type != CutConnectorType::Dowel) {
|
||||
if (attributes.has(ModelObjectCutAttribute::KeepUpper)) {
|
||||
ModelVolume* vol = nullptr;
|
||||
if (volume->cut_info.connector_type == CutConnectorType::Snap) {
|
||||
TriangleMesh mesh = TriangleMesh(its_make_cylinder(1.0, 1.0, PI / 180.));
|
||||
|
||||
vol = upper->add_volume(std::move(mesh));
|
||||
vol->set_transformation(volume->get_transformation());
|
||||
vol->set_type(ModelVolumeType::NEGATIVE_VOLUME);
|
||||
|
||||
vol->cut_info = volume->cut_info;
|
||||
vol->name = volume->name;
|
||||
}
|
||||
else
|
||||
vol = upper->add_volume(*volume);
|
||||
|
||||
vol->set_transformation(volume_matrix);
|
||||
apply_tolerance(vol);
|
||||
}
|
||||
if (attributes.has(ModelObjectCutAttribute::KeepLower)) {
|
||||
ModelVolume* vol = lower->add_volume(*volume);
|
||||
vol->set_transformation(volume_matrix);
|
||||
// for lower part change type of connector from NEGATIVE_VOLUME to MODEL_PART if this connector is a plug
|
||||
vol->set_type(ModelVolumeType::MODEL_PART);
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (attributes.has(ModelObjectCutAttribute::CreateDowels)) {
|
||||
ModelObject* dowel{ nullptr };
|
||||
// Clone the object to duplicate instances, materials etc.
|
||||
volume->get_object()->clone_for_cut(&dowel);
|
||||
|
||||
// add one more solid part same as connector if this connector is a dowel
|
||||
ModelVolume* vol = dowel->add_volume(*volume);
|
||||
vol->set_type(ModelVolumeType::MODEL_PART);
|
||||
|
||||
// But discard rotation and Z-offset for this volume
|
||||
vol->set_rotation(Vec3d::Zero());
|
||||
vol->set_offset(Z, 0.0);
|
||||
|
||||
dowels.push_back(dowel);
|
||||
}
|
||||
|
||||
// Cut the dowel
|
||||
apply_tolerance(volume);
|
||||
|
||||
// Perform cut
|
||||
TriangleMesh upper_mesh, lower_mesh;
|
||||
process_volume_cut(volume, Transform3d::Identity(), cut_matrix, attributes, upper_mesh, lower_mesh);
|
||||
|
||||
// add small Z offset to better preview
|
||||
upper_mesh.translate((-0.05 * Vec3d::UnitZ()).cast<float>());
|
||||
lower_mesh.translate((0.05 * Vec3d::UnitZ()).cast<float>());
|
||||
|
||||
// Add cut parts to the related objects
|
||||
add_cut_volume(upper_mesh, upper, volume, cut_matrix, "_A", volume->type());
|
||||
add_cut_volume(lower_mesh, lower, volume, cut_matrix, "_B", volume->type());
|
||||
}
|
||||
}
|
||||
|
||||
static void process_modifier_cut(ModelVolume* volume, const Transform3d& instance_matrix, const Transform3d& inverse_cut_matrix,
|
||||
ModelObjectCutAttributes attributes, ModelObject* upper, ModelObject* lower)
|
||||
{
|
||||
const auto volume_matrix = instance_matrix * volume->get_matrix();
|
||||
|
||||
// Modifiers are not cut, but we still need to add the instance transformation
|
||||
// to the modifier volume transformation to preserve their shape properly.
|
||||
volume->set_transformation(Transformation(volume_matrix));
|
||||
|
||||
if (attributes.has(ModelObjectCutAttribute::KeepAsParts)) {
|
||||
upper->add_volume(*volume);
|
||||
return;
|
||||
}
|
||||
|
||||
// Some logic for the negative volumes/connectors. Add only needed modifiers
|
||||
auto bb = volume->mesh().transformed_bounding_box(inverse_cut_matrix * volume_matrix);
|
||||
bool is_crossed_by_cut = bb.min[Z] <= 0 && bb.max[Z] >= 0;
|
||||
if (attributes.has(ModelObjectCutAttribute::KeepUpper) && (bb.min[Z] >= 0 || is_crossed_by_cut))
|
||||
upper->add_volume(*volume);
|
||||
if (attributes.has(ModelObjectCutAttribute::KeepLower) && (bb.max[Z] <= 0 || is_crossed_by_cut))
|
||||
lower->add_volume(*volume);
|
||||
}
|
||||
|
||||
static void process_solid_part_cut(ModelVolume* volume, const Transform3d& instance_matrix, const Transform3d& cut_matrix,
|
||||
ModelObjectCutAttributes attributes, ModelObject* upper, ModelObject* lower)
|
||||
{
|
||||
// Perform cut
|
||||
TriangleMesh upper_mesh, lower_mesh;
|
||||
process_volume_cut(volume, instance_matrix, cut_matrix, attributes, upper_mesh, lower_mesh);
|
||||
|
||||
// Add required cut parts to the objects
|
||||
|
||||
if (attributes.has(ModelObjectCutAttribute::KeepAsParts)) {
|
||||
add_cut_volume(upper_mesh, upper, volume, cut_matrix, "_A");
|
||||
if (!lower_mesh.empty()) {
|
||||
add_cut_volume(lower_mesh, upper, volume, cut_matrix, "_B");
|
||||
upper->volumes.back()->cut_info.is_from_upper = false;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (attributes.has(ModelObjectCutAttribute::KeepUpper))
|
||||
add_cut_volume(upper_mesh, upper, volume, cut_matrix);
|
||||
|
||||
if (attributes.has(ModelObjectCutAttribute::KeepLower) && !lower_mesh.empty())
|
||||
add_cut_volume(lower_mesh, lower, volume, cut_matrix);
|
||||
}
|
||||
|
||||
static void reset_instance_transformation(ModelObject* object, size_t src_instance_idx,
|
||||
const Transform3d& cut_matrix = Transform3d::Identity(),
|
||||
bool place_on_cut = false, bool flip = false)
|
||||
{
|
||||
// Reset instance transformation except offset and Z-rotation
|
||||
|
||||
for (size_t i = 0; i < object->instances.size(); ++i) {
|
||||
auto& obj_instance = object->instances[i];
|
||||
const double rot_z = obj_instance->get_rotation().z();
|
||||
|
||||
Transformation inst_trafo = Transformation(obj_instance->get_transformation().get_matrix(false, false, true));
|
||||
// add respect to mirroring
|
||||
if (obj_instance->is_left_handed())
|
||||
inst_trafo = inst_trafo * Transformation(scale_transform(Vec3d(-1, 1, 1)));
|
||||
|
||||
obj_instance->set_transformation(inst_trafo);
|
||||
|
||||
Vec3d rotation = Vec3d::Zero();
|
||||
if (!flip && !place_on_cut) {
|
||||
if ( i != src_instance_idx)
|
||||
rotation[Z] = rot_z;
|
||||
}
|
||||
else {
|
||||
Transform3d rotation_matrix = Transform3d::Identity();
|
||||
if (flip)
|
||||
rotation_matrix = rotation_transform(PI * Vec3d::UnitX());
|
||||
|
||||
if (place_on_cut)
|
||||
rotation_matrix = rotation_matrix * Transformation(cut_matrix).get_rotation_matrix().inverse();
|
||||
|
||||
if (i != src_instance_idx)
|
||||
rotation_matrix = rotation_transform(rot_z * Vec3d::UnitZ()) * rotation_matrix;
|
||||
|
||||
rotation = Transformation(rotation_matrix).get_rotation();
|
||||
}
|
||||
|
||||
obj_instance->set_rotation(rotation);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Cut::Cut(const ModelObject* object, int instance, const Transform3d& cut_matrix,
|
||||
ModelObjectCutAttributes attributes/*= ModelObjectCutAttribute::KeepUpper | ModelObjectCutAttribute::KeepLower | ModelObjectCutAttribute::KeepAsParts*/)
|
||||
: m_instance(instance), m_cut_matrix(cut_matrix), m_attributes(attributes)
|
||||
{
|
||||
m_model = Model();
|
||||
if (object)
|
||||
m_model.add_object(*object);
|
||||
}
|
||||
|
||||
void Cut::post_process(ModelObject* object, ModelObjectPtrs& cut_object_ptrs, bool keep, bool place_on_cut, bool flip)
|
||||
{
|
||||
if (!object) return;
|
||||
|
||||
if (keep && !object->volumes.empty()) {
|
||||
reset_instance_transformation(object, m_instance, m_cut_matrix, place_on_cut, flip);
|
||||
cut_object_ptrs.push_back(object);
|
||||
}
|
||||
else
|
||||
m_model.objects.push_back(object); // will be deleted in m_model.clear_objects();
|
||||
}
|
||||
|
||||
void Cut::post_process(ModelObject* upper, ModelObject* lower, ModelObjectPtrs& cut_object_ptrs)
|
||||
{
|
||||
post_process(upper, cut_object_ptrs,
|
||||
m_attributes.has(ModelObjectCutAttribute::KeepUpper),
|
||||
m_attributes.has(ModelObjectCutAttribute::PlaceOnCutUpper),
|
||||
m_attributes.has(ModelObjectCutAttribute::FlipUpper));
|
||||
|
||||
post_process(lower, cut_object_ptrs,
|
||||
m_attributes.has(ModelObjectCutAttribute::KeepLower),
|
||||
m_attributes.has(ModelObjectCutAttribute::PlaceOnCutLower),
|
||||
m_attributes.has(ModelObjectCutAttribute::PlaceOnCutLower) || m_attributes.has(ModelObjectCutAttribute::FlipLower));
|
||||
}
|
||||
|
||||
|
||||
void Cut::finalize(const ModelObjectPtrs& objects)
|
||||
{
|
||||
//clear model from temporarry objects
|
||||
m_model.clear_objects();
|
||||
|
||||
// add to model result objects
|
||||
m_model.objects = objects;
|
||||
}
|
||||
|
||||
|
||||
const ModelObjectPtrs& Cut::perform_with_plane()
|
||||
{
|
||||
if (!m_attributes.has(ModelObjectCutAttribute::KeepUpper) && !m_attributes.has(ModelObjectCutAttribute::KeepLower)) {
|
||||
m_model.clear_objects();
|
||||
return m_model.objects;
|
||||
}
|
||||
|
||||
ModelObject* mo = m_model.objects.front();
|
||||
|
||||
BOOST_LOG_TRIVIAL(trace) << "ModelObject::cut - start";
|
||||
|
||||
// Clone the object to duplicate instances, materials etc.
|
||||
ModelObject* upper{ nullptr };
|
||||
if (m_attributes.has(ModelObjectCutAttribute::KeepUpper))
|
||||
mo->clone_for_cut(&upper);
|
||||
|
||||
ModelObject* lower{ nullptr };
|
||||
if (m_attributes.has(ModelObjectCutAttribute::KeepLower) && !m_attributes.has(ModelObjectCutAttribute::KeepAsParts))
|
||||
mo->clone_for_cut(&lower);
|
||||
|
||||
std::vector<ModelObject*> dowels;
|
||||
|
||||
// Because transformations are going to be applied to meshes directly,
|
||||
// we reset transformation of all instances and volumes,
|
||||
// except for translation and Z-rotation on instances, which are preserved
|
||||
// in the transformation matrix and not applied to the mesh transform.
|
||||
|
||||
const auto instance_matrix = mo->instances[m_instance]->get_transformation().get_matrix(true);
|
||||
const Transformation cut_transformation = Transformation(m_cut_matrix);
|
||||
const Transform3d inverse_cut_matrix = cut_transformation.get_rotation_matrix().inverse() * translation_transform(-1. * cut_transformation.get_offset());
|
||||
|
||||
for (ModelVolume* volume : mo->volumes) {
|
||||
volume->reset_extra_facets();
|
||||
|
||||
if (!volume->is_model_part()) {
|
||||
if (volume->cut_info.is_processed)
|
||||
process_modifier_cut(volume, instance_matrix, inverse_cut_matrix, m_attributes, upper, lower);
|
||||
else
|
||||
process_connector_cut(volume, instance_matrix, m_cut_matrix, m_attributes, upper, lower, dowels);
|
||||
}
|
||||
else if (!volume->mesh().empty())
|
||||
process_solid_part_cut(volume, instance_matrix, m_cut_matrix, m_attributes, upper, lower);
|
||||
}
|
||||
|
||||
// Post-process cut parts
|
||||
|
||||
if (m_attributes.has(ModelObjectCutAttribute::KeepAsParts) && upper->volumes.empty()) {
|
||||
m_model = Model();
|
||||
m_model.objects.push_back(upper);
|
||||
return m_model.objects;
|
||||
}
|
||||
|
||||
ModelObjectPtrs cut_object_ptrs;
|
||||
|
||||
if (m_attributes.has(ModelObjectCutAttribute::KeepAsParts) && !upper->volumes.empty()) {
|
||||
reset_instance_transformation(upper, m_instance, m_cut_matrix);
|
||||
cut_object_ptrs.push_back(upper);
|
||||
}
|
||||
else {
|
||||
// Delete all modifiers which are not intersecting with solid parts bounding box
|
||||
auto delete_extra_modifiers = [this](ModelObject* mo) {
|
||||
if (!mo) return;
|
||||
const BoundingBoxf3 obj_bb = mo->instance_bounding_box(m_instance);
|
||||
const Transform3d inst_matrix = mo->instances[m_instance]->get_transformation().get_matrix();
|
||||
|
||||
for (int i = int(mo->volumes.size()) - 1; i >= 0; --i)
|
||||
if (const ModelVolume* vol = mo->volumes[i];
|
||||
!vol->is_model_part() && !vol->is_cut_connector()) {
|
||||
auto bb = vol->mesh().transformed_bounding_box(inst_matrix * vol->get_matrix());
|
||||
if (!obj_bb.intersects(bb))
|
||||
mo->delete_volume(i);
|
||||
}
|
||||
};
|
||||
|
||||
post_process(upper, lower, cut_object_ptrs);
|
||||
delete_extra_modifiers(upper);
|
||||
delete_extra_modifiers(lower);
|
||||
|
||||
if (m_attributes.has(ModelObjectCutAttribute::CreateDowels) && !dowels.empty()) {
|
||||
for (auto dowel : dowels) {
|
||||
reset_instance_transformation(dowel, m_instance);
|
||||
dowel->name += "-Dowel-" + dowel->volumes[0]->name;
|
||||
cut_object_ptrs.push_back(dowel);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
BOOST_LOG_TRIVIAL(trace) << "ModelObject::cut - end";
|
||||
|
||||
finalize(cut_object_ptrs);
|
||||
|
||||
return m_model.objects;
|
||||
}
|
||||
|
||||
static void distribute_modifiers_from_object(ModelObject* from_obj, const int instance_idx, ModelObject* to_obj1, ModelObject* to_obj2)
|
||||
{
|
||||
auto obj1_bb = to_obj1 ? to_obj1->instance_bounding_box(instance_idx) : BoundingBoxf3();
|
||||
auto obj2_bb = to_obj2 ? to_obj2->instance_bounding_box(instance_idx) : BoundingBoxf3();
|
||||
const Transform3d inst_matrix = from_obj->instances[instance_idx]->get_transformation().get_matrix();
|
||||
|
||||
for (ModelVolume* vol : from_obj->volumes)
|
||||
if (!vol->is_model_part()) {
|
||||
// Don't add modifiers which are processed connectors
|
||||
if (vol->cut_info.is_connector && !vol->cut_info.is_processed)
|
||||
continue;
|
||||
auto bb = vol->mesh().transformed_bounding_box(inst_matrix * vol->get_matrix());
|
||||
// Don't add modifiers which are not intersecting with solid parts
|
||||
if (obj1_bb.intersects(bb))
|
||||
to_obj1->add_volume(*vol);
|
||||
if (obj2_bb.intersects(bb))
|
||||
to_obj2->add_volume(*vol);
|
||||
}
|
||||
}
|
||||
|
||||
static void merge_solid_parts_inside_object(ModelObjectPtrs& objects)
|
||||
{
|
||||
for (ModelObject* mo : objects) {
|
||||
TriangleMesh mesh;
|
||||
// Merge all SolidPart but not Connectors
|
||||
for (const ModelVolume* mv : mo->volumes) {
|
||||
if (mv->is_model_part() && !mv->is_cut_connector()) {
|
||||
TriangleMesh m = mv->mesh();
|
||||
m.transform(mv->get_matrix());
|
||||
mesh.merge(m);
|
||||
}
|
||||
}
|
||||
if (!mesh.empty()) {
|
||||
ModelVolume* new_volume = mo->add_volume(mesh);
|
||||
new_volume->name = mo->name;
|
||||
// Delete all merged SolidPart but not Connectors
|
||||
for (int i = int(mo->volumes.size()) - 2; i >= 0; --i) {
|
||||
const ModelVolume* mv = mo->volumes[i];
|
||||
if (mv->is_model_part() && !mv->is_cut_connector())
|
||||
mo->delete_volume(i);
|
||||
}
|
||||
// Ensuring that volumes start with solid parts for proper slicing
|
||||
mo->sort_volumes(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
const ModelObjectPtrs& Cut::perform_by_contour(std::vector<Part> parts, int dowels_count)
|
||||
{
|
||||
ModelObject* cut_mo = m_model.objects.front();
|
||||
|
||||
// Clone the object to duplicate instances, materials etc.
|
||||
ModelObject* upper{ nullptr };
|
||||
if (m_attributes.has(ModelObjectCutAttribute::KeepUpper)) cut_mo->clone_for_cut(&upper);
|
||||
ModelObject* lower{ nullptr };
|
||||
if (m_attributes.has(ModelObjectCutAttribute::KeepLower)) cut_mo->clone_for_cut(&lower);
|
||||
|
||||
const size_t cut_parts_cnt = parts.size();
|
||||
bool has_modifiers = false;
|
||||
|
||||
// Distribute SolidParts to the Upper/Lower object
|
||||
for (size_t id = 0; id < cut_parts_cnt; ++id) {
|
||||
if (parts[id].is_modifier)
|
||||
has_modifiers = true; // modifiers will be added later to the related parts
|
||||
else if (ModelObject* obj = (parts[id].selected ? upper : lower))
|
||||
obj->add_volume(*(cut_mo->volumes[id]));
|
||||
}
|
||||
|
||||
if (has_modifiers) {
|
||||
// Distribute Modifiers to the Upper/Lower object
|
||||
distribute_modifiers_from_object(cut_mo, m_instance, upper, lower);
|
||||
}
|
||||
|
||||
ModelObjectPtrs cut_object_ptrs;
|
||||
|
||||
ModelVolumePtrs& volumes = cut_mo->volumes;
|
||||
if (volumes.size() == cut_parts_cnt) {
|
||||
// Means that object is cut without connectors
|
||||
|
||||
// Just add Upper and Lower objects to cut_object_ptrs
|
||||
post_process(upper, lower, cut_object_ptrs);
|
||||
|
||||
// Now merge all model parts together:
|
||||
merge_solid_parts_inside_object(cut_object_ptrs);
|
||||
|
||||
// replace initial objects in model with cut object
|
||||
finalize(cut_object_ptrs);
|
||||
}
|
||||
else if (volumes.size() > cut_parts_cnt) {
|
||||
// Means that object is cut with connectors
|
||||
|
||||
// All volumes are distributed to Upper / Lower object,
|
||||
// So we don’t need them anymore
|
||||
for (size_t id = 0; id < cut_parts_cnt; id++)
|
||||
delete* (volumes.begin() + id);
|
||||
volumes.erase(volumes.begin(), volumes.begin() + cut_parts_cnt);
|
||||
|
||||
// Perform cut just to get connectors
|
||||
Cut cut(cut_mo, m_instance, m_cut_matrix, m_attributes);
|
||||
const ModelObjectPtrs& cut_connectors_obj = cut.perform_with_plane();
|
||||
assert(dowels_count > 0 ? cut_connectors_obj.size() >= 3 : cut_connectors_obj.size() == 2);
|
||||
|
||||
// Connectors from upper object
|
||||
for (const ModelVolume* volume : cut_connectors_obj[0]->volumes)
|
||||
upper->add_volume(*volume, volume->type());
|
||||
|
||||
// Connectors from lower object
|
||||
for (const ModelVolume* volume : cut_connectors_obj[1]->volumes)
|
||||
lower->add_volume(*volume, volume->type());
|
||||
|
||||
// Add Upper and Lower objects to cut_object_ptrs
|
||||
post_process(upper, lower, cut_object_ptrs);
|
||||
|
||||
// Now merge all model parts together:
|
||||
merge_solid_parts_inside_object(cut_object_ptrs);
|
||||
|
||||
// replace initial objects in model with cut object
|
||||
finalize(cut_object_ptrs);
|
||||
|
||||
// Add Dowel-connectors as separate objects to model
|
||||
if (cut_connectors_obj.size() >= 3)
|
||||
for (size_t id = 2; id < cut_connectors_obj.size(); id++)
|
||||
m_model.add_object(*cut_connectors_obj[id]);
|
||||
}
|
||||
|
||||
return m_model.objects;
|
||||
}
|
||||
|
||||
|
||||
const ModelObjectPtrs& Cut::perform_with_groove(const Groove& groove, const Transform3d& rotation_m, bool keep_as_parts/* = false*/)
|
||||
{
|
||||
ModelObject* cut_mo = m_model.objects.front();
|
||||
|
||||
// Clone the object to duplicate instances, materials etc.
|
||||
ModelObject* upper{ nullptr };
|
||||
cut_mo->clone_for_cut(&upper);
|
||||
ModelObject* lower{ nullptr };
|
||||
cut_mo->clone_for_cut(&lower);
|
||||
|
||||
const double groove_half_depth = 0.5 * double(groove.depth);
|
||||
|
||||
Model tmp_model_for_cut = Model();
|
||||
|
||||
Model tmp_model = Model();
|
||||
tmp_model.add_object(*cut_mo);
|
||||
ModelObject* tmp_object = tmp_model.objects.front();
|
||||
|
||||
auto add_volumes_from_cut = [](ModelObject* object, const ModelObjectCutAttribute attribute, const Model& tmp_model_for_cut) {
|
||||
const auto& volumes = tmp_model_for_cut.objects.front()->volumes;
|
||||
for (const ModelVolume* volume : volumes)
|
||||
if (volume->is_model_part()) {
|
||||
if ((attribute == ModelObjectCutAttribute::KeepUpper && volume->is_from_upper()) ||
|
||||
(attribute != ModelObjectCutAttribute::KeepUpper && !volume->is_from_upper())) {
|
||||
ModelVolume* new_vol = object->add_volume(*volume);
|
||||
new_vol->reset_from_upper();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
auto cut = [this, add_volumes_from_cut]
|
||||
(ModelObject* object, const Transform3d& cut_matrix, const ModelObjectCutAttribute add_volumes_attribute, Model& tmp_model_for_cut) {
|
||||
Cut cut(object, m_instance, cut_matrix);
|
||||
|
||||
tmp_model_for_cut = Model();
|
||||
tmp_model_for_cut.add_object(*cut.perform_with_plane().front());
|
||||
assert(!tmp_model_for_cut.objects.empty());
|
||||
|
||||
object->clear_volumes();
|
||||
add_volumes_from_cut(object, add_volumes_attribute, tmp_model_for_cut);
|
||||
reset_instance_transformation(object, m_instance);
|
||||
};
|
||||
|
||||
// cut by upper plane
|
||||
|
||||
const Transform3d cut_matrix_upper = translation_transform(rotation_m * (groove_half_depth * Vec3d::UnitZ())) * m_cut_matrix;
|
||||
{
|
||||
cut(tmp_object, cut_matrix_upper, ModelObjectCutAttribute::KeepLower, tmp_model_for_cut);
|
||||
add_volumes_from_cut(upper, ModelObjectCutAttribute::KeepUpper, tmp_model_for_cut);
|
||||
}
|
||||
|
||||
// cut by lower plane
|
||||
|
||||
const Transform3d cut_matrix_lower = translation_transform(rotation_m * (-groove_half_depth * Vec3d::UnitZ())) * m_cut_matrix;
|
||||
{
|
||||
cut(tmp_object, cut_matrix_lower, ModelObjectCutAttribute::KeepUpper, tmp_model_for_cut);
|
||||
add_volumes_from_cut(lower, ModelObjectCutAttribute::KeepLower, tmp_model_for_cut);
|
||||
}
|
||||
|
||||
// cut middle part with 2 angles and add parts to related upper/lower objects
|
||||
|
||||
const double h_side_shift = 0.5 * double(groove.width + groove.depth / tan(groove.flaps_angle));
|
||||
|
||||
// cut by angle1 plane
|
||||
{
|
||||
const Transform3d cut_matrix_angle1 = translation_transform(rotation_m * (-h_side_shift * Vec3d::UnitX())) * m_cut_matrix * rotation_transform(Vec3d(0, -groove.flaps_angle, -groove.angle));
|
||||
|
||||
cut(tmp_object, cut_matrix_angle1, ModelObjectCutAttribute::KeepLower, tmp_model_for_cut);
|
||||
add_volumes_from_cut(lower, ModelObjectCutAttribute::KeepUpper, tmp_model_for_cut);
|
||||
}
|
||||
|
||||
// cut by angle2 plane
|
||||
{
|
||||
const Transform3d cut_matrix_angle2 = translation_transform(rotation_m * (h_side_shift * Vec3d::UnitX())) * m_cut_matrix * rotation_transform(Vec3d(0, groove.flaps_angle, groove.angle));
|
||||
|
||||
cut(tmp_object, cut_matrix_angle2, ModelObjectCutAttribute::KeepLower, tmp_model_for_cut);
|
||||
add_volumes_from_cut(lower, ModelObjectCutAttribute::KeepUpper, tmp_model_for_cut);
|
||||
}
|
||||
|
||||
// apply tolerance to the middle part
|
||||
{
|
||||
const double h_groove_shift_tolerance = groove_half_depth - (double)groove.depth_tolerance;
|
||||
|
||||
const Transform3d cut_matrix_lower_tolerance = translation_transform(rotation_m * (-h_groove_shift_tolerance * Vec3d::UnitZ())) * m_cut_matrix;
|
||||
cut(tmp_object, cut_matrix_lower_tolerance, ModelObjectCutAttribute::KeepUpper, tmp_model_for_cut);
|
||||
|
||||
const double h_side_shift_tolerance = h_side_shift - 0.5 * double(groove.width_tolerance);
|
||||
|
||||
const Transform3d cut_matrix_angle1_tolerance = translation_transform(rotation_m * (-h_side_shift_tolerance * Vec3d::UnitX())) * m_cut_matrix * rotation_transform(Vec3d(0, -groove.flaps_angle, -groove.angle));
|
||||
cut(tmp_object, cut_matrix_angle1_tolerance, ModelObjectCutAttribute::KeepLower, tmp_model_for_cut);
|
||||
|
||||
const Transform3d cut_matrix_angle2_tolerance = translation_transform(rotation_m * (h_side_shift_tolerance * Vec3d::UnitX())) * m_cut_matrix * rotation_transform(Vec3d(0, groove.flaps_angle, groove.angle));
|
||||
cut(tmp_object, cut_matrix_angle2_tolerance, ModelObjectCutAttribute::KeepUpper, tmp_model_for_cut);
|
||||
}
|
||||
|
||||
// this part can be added to the upper object now
|
||||
add_volumes_from_cut(upper, ModelObjectCutAttribute::KeepLower, tmp_model_for_cut);
|
||||
|
||||
ModelObjectPtrs cut_object_ptrs;
|
||||
|
||||
if (keep_as_parts) {
|
||||
// add volumes from lower object to the upper, but mark them as a lower
|
||||
const auto& volumes = lower->volumes;
|
||||
for (const ModelVolume* volume : volumes) {
|
||||
ModelVolume* new_vol = upper->add_volume(*volume);
|
||||
new_vol->cut_info.is_from_upper = false;
|
||||
}
|
||||
|
||||
// add modifiers
|
||||
for (const ModelVolume* volume : cut_mo->volumes)
|
||||
if (!volume->is_model_part())
|
||||
upper->add_volume(*volume);
|
||||
|
||||
cut_object_ptrs.push_back(upper);
|
||||
|
||||
// add lower object to the cut_object_ptrs just to correct delete it from the Model destructor and avoid memory leaks
|
||||
cut_object_ptrs.push_back(lower);
|
||||
}
|
||||
else {
|
||||
// add modifiers if object has any
|
||||
for (const ModelVolume* volume : cut_mo->volumes)
|
||||
if (!volume->is_model_part()) {
|
||||
distribute_modifiers_from_object(cut_mo, m_instance, upper, lower);
|
||||
break;
|
||||
}
|
||||
|
||||
assert(!upper->volumes.empty() && !lower->volumes.empty());
|
||||
|
||||
// Add Upper and Lower parts to cut_object_ptrs
|
||||
|
||||
post_process(upper, lower, cut_object_ptrs);
|
||||
|
||||
// Now merge all model parts together:
|
||||
merge_solid_parts_inside_object(cut_object_ptrs);
|
||||
}
|
||||
|
||||
finalize(cut_object_ptrs);
|
||||
|
||||
return m_model.objects;
|
||||
}
|
||||
|
||||
} // namespace Slic3r
|
||||
|
||||
70
src/libslic3r/CutUtils.hpp
Normal file
70
src/libslic3r/CutUtils.hpp
Normal file
|
|
@ -0,0 +1,70 @@
|
|||
///|/ Copyright (c) Prusa Research 2023 Oleksandra Iushchenko @YuSanka
|
||||
///|/
|
||||
///|/ PrusaSlicer is released under the terms of the AGPLv3 or higher
|
||||
///|/
|
||||
#ifndef slic3r_CutUtils_hpp_
|
||||
#define slic3r_CutUtils_hpp_
|
||||
|
||||
#include "enum_bitmask.hpp"
|
||||
#include "Point.hpp"
|
||||
#include "Model.hpp"
|
||||
|
||||
#include <vector>
|
||||
|
||||
namespace Slic3r {
|
||||
|
||||
using ModelObjectPtrs = std::vector<ModelObject*>;
|
||||
|
||||
enum class ModelObjectCutAttribute : int { KeepUpper, KeepLower, KeepAsParts, FlipUpper, FlipLower, PlaceOnCutUpper, PlaceOnCutLower, CreateDowels, InvalidateCutInfo };
|
||||
using ModelObjectCutAttributes = enum_bitmask<ModelObjectCutAttribute>;
|
||||
ENABLE_ENUM_BITMASK_OPERATORS(ModelObjectCutAttribute);
|
||||
|
||||
|
||||
class Cut {
|
||||
|
||||
Model m_model;
|
||||
int m_instance;
|
||||
const Transform3d m_cut_matrix;
|
||||
ModelObjectCutAttributes m_attributes;
|
||||
|
||||
void post_process(ModelObject* object, ModelObjectPtrs& objects, bool keep, bool place_on_cut, bool flip);
|
||||
void post_process(ModelObject* upper_object, ModelObject* lower_object, ModelObjectPtrs& objects);
|
||||
void finalize(const ModelObjectPtrs& objects);
|
||||
|
||||
public:
|
||||
|
||||
Cut(const ModelObject* object, int instance, const Transform3d& cut_matrix,
|
||||
ModelObjectCutAttributes attributes = ModelObjectCutAttribute::KeepUpper |
|
||||
ModelObjectCutAttribute::KeepLower |
|
||||
ModelObjectCutAttribute::KeepAsParts );
|
||||
~Cut() { m_model.clear_objects(); }
|
||||
|
||||
struct Groove
|
||||
{
|
||||
float depth{ 0.f };
|
||||
float width{ 0.f };
|
||||
float flaps_angle{ 0.f };
|
||||
float angle{ 0.f };
|
||||
float depth_init{ 0.f };
|
||||
float width_init{ 0.f };
|
||||
float flaps_angle_init{ 0.f };
|
||||
float angle_init{ 0.f };
|
||||
float depth_tolerance{ 0.1f };
|
||||
float width_tolerance{ 0.1f };
|
||||
};
|
||||
|
||||
struct Part
|
||||
{
|
||||
bool selected;
|
||||
bool is_modifier;
|
||||
};
|
||||
|
||||
const ModelObjectPtrs& perform_with_plane();
|
||||
const ModelObjectPtrs& perform_by_contour(std::vector<Part> parts, int dowels_count);
|
||||
const ModelObjectPtrs& perform_with_groove(const Groove& groove, const Transform3d& rotation_m, bool keep_as_parts = false);
|
||||
|
||||
}; // namespace Cut
|
||||
|
||||
} // namespace Slic3r
|
||||
|
||||
#endif /* slic3r_CutUtils_hpp_ */
|
||||
|
|
@ -56,12 +56,9 @@ ExtrusionEntityCollection::operator ExtrusionPaths() const
|
|||
return paths;
|
||||
}
|
||||
|
||||
ExtrusionEntity* ExtrusionEntityCollection::clone() const
|
||||
ExtrusionEntity *ExtrusionEntityCollection::clone() const
|
||||
{
|
||||
ExtrusionEntityCollection* coll = new ExtrusionEntityCollection(*this);
|
||||
for (size_t i = 0; i < coll->entities.size(); ++i)
|
||||
coll->entities[i] = this->entities[i]->clone();
|
||||
return coll;
|
||||
return new ExtrusionEntityCollection(*this);
|
||||
}
|
||||
|
||||
void ExtrusionEntityCollection::reverse()
|
||||
|
|
|
|||
|
|
@ -1,3 +1,8 @@
|
|||
///|/ Copyright (c) Prusa Research 2018 - 2023 Oleksandra Iushchenko @YuSanka, David Kocík @kocikdav, Enrico Turri @enricoturri1966, Lukáš Matěna @lukasmatena, Lukáš Hejl @hejllukas, Filip Sykala @Jony01, Vojtěch Bubník @bubnikv, Tomáš Mészáros @tamasmeszaros
|
||||
///|/ Copyright (c) 2020 Henner Zeller
|
||||
///|/
|
||||
///|/ PrusaSlicer is released under the terms of the AGPLv3 or higher
|
||||
///|/
|
||||
#include "../libslic3r.h"
|
||||
#include "../Exception.hpp"
|
||||
#include "../Model.hpp"
|
||||
|
|
@ -741,8 +746,6 @@ void PlateData::parse_filament_info(GCodeProcessorResult *result)
|
|||
{
|
||||
int volume_id;
|
||||
int type;
|
||||
float radius;
|
||||
float height;
|
||||
float r_tolerance;
|
||||
float h_tolerance;
|
||||
};
|
||||
|
|
@ -758,10 +761,10 @@ void PlateData::parse_filament_info(GCodeProcessorResult *result)
|
|||
//typedef std::map<Id, ComponentsList> IdToAliasesMap;
|
||||
typedef std::vector<Instance> InstancesList;
|
||||
typedef std::map<int, ObjectMetadata> IdToMetadataMap;
|
||||
typedef std::map<int, CutObjectInfo> IdToCutObjectInfoMap;
|
||||
//typedef std::map<Id, Geometry> IdToGeometryMap;
|
||||
typedef std::map<int, std::vector<coordf_t>> IdToLayerHeightsProfileMap;
|
||||
typedef std::map<int, t_layer_config_ranges> IdToLayerConfigRangesMap;
|
||||
typedef std::map<int, CutObjectInfo> IdToCutObjectInfoMap;
|
||||
/*typedef std::map<int, std::vector<sla::SupportPoint>> IdToSlaSupportPointsMap;
|
||||
typedef std::map<int, std::vector<sla::DrainHole>> IdToSlaDrainHolesMap;*/
|
||||
|
||||
|
|
@ -951,7 +954,7 @@ void PlateData::parse_filament_info(GCodeProcessorResult *result)
|
|||
//IdToGeometryMap m_orig_geometries; // backup & restore
|
||||
CurrentConfig m_curr_config;
|
||||
IdToMetadataMap m_objects_metadata;
|
||||
IdToCutObjectInfoMap m_cut_object_infos;
|
||||
IdToCutObjectInfoMap m_cut_object_infos;
|
||||
IdToLayerHeightsProfileMap m_layer_heights_profiles;
|
||||
IdToLayerConfigRangesMap m_layer_config_ranges;
|
||||
/*IdToSlaSupportPointsMap m_sla_support_points;
|
||||
|
|
@ -1013,7 +1016,7 @@ void PlateData::parse_filament_info(GCodeProcessorResult *result)
|
|||
bool _extract_xml_from_archive(mz_zip_archive& archive, std::string const & path, XML_StartElementHandler start_handler, XML_EndElementHandler end_handler);
|
||||
bool _extract_xml_from_archive(mz_zip_archive& archive, const mz_zip_archive_file_stat& stat, XML_StartElementHandler start_handler, XML_EndElementHandler end_handler);
|
||||
bool _extract_model_from_archive(mz_zip_archive& archive, const mz_zip_archive_file_stat& stat);
|
||||
void _extract_cut_information_from_archive(mz_zip_archive &archive, const mz_zip_archive_file_stat &stat, ConfigSubstitutionContext &config_substitutions);
|
||||
void _extract_cut_information_from_archive(mz_zip_archive& archive, const mz_zip_archive_file_stat& stat, ConfigSubstitutionContext& config_substitutions);
|
||||
void _extract_layer_heights_profile_config_from_archive(mz_zip_archive& archive, const mz_zip_archive_file_stat& stat);
|
||||
void _extract_layer_config_ranges_from_archive(mz_zip_archive& archive, const mz_zip_archive_file_stat& stat, ConfigSubstitutionContext& config_substitutions);
|
||||
void _extract_sla_support_points_from_archive(mz_zip_archive& archive, const mz_zip_archive_file_stat& stat);
|
||||
|
|
@ -1955,11 +1958,14 @@ void PlateData::parse_filament_info(GCodeProcessorResult *result)
|
|||
IdToCutObjectInfoMap::iterator cut_object_info = m_cut_object_infos.find(object.second + 1);
|
||||
if (cut_object_info != m_cut_object_infos.end()) {
|
||||
model_object->cut_id = cut_object_info->second.id;
|
||||
|
||||
int vol_cnt = int(model_object->volumes.size());
|
||||
for (auto connector : cut_object_info->second.connectors) {
|
||||
assert(0 <= connector.volume_id && connector.volume_id <= int(model_object->volumes.size()));
|
||||
model_object->volumes[connector.volume_id]->cut_info =
|
||||
ModelVolume::CutInfo(CutConnectorType(connector.type), connector.radius, connector.height, connector.r_tolerance, connector.h_tolerance, true);
|
||||
if (connector.volume_id < 0 || connector.volume_id >= vol_cnt) {
|
||||
add_error("Invalid connector is found");
|
||||
continue;
|
||||
}
|
||||
model_object->volumes[connector.volume_id]->cut_info =
|
||||
ModelVolume::CutInfo(CutConnectorType(connector.type), connector.r_tolerance, connector.h_tolerance, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -2324,7 +2330,7 @@ void PlateData::parse_filament_info(GCodeProcessorResult *result)
|
|||
void _BBS_3MF_Importer::_extract_cut_information_from_archive(mz_zip_archive &archive, const mz_zip_archive_file_stat &stat, ConfigSubstitutionContext &config_substitutions)
|
||||
{
|
||||
if (stat.m_uncomp_size > 0) {
|
||||
std::string buffer((size_t) stat.m_uncomp_size, 0);
|
||||
std::string buffer((size_t)stat.m_uncomp_size, 0);
|
||||
mz_bool res = mz_zip_reader_extract_file_to_mem(&archive, stat.m_filename, (void *) buffer.data(), (size_t) stat.m_uncomp_size, 0);
|
||||
if (res == 0) {
|
||||
add_error("Error while reading cut information data to buffer");
|
||||
|
|
@ -2332,12 +2338,12 @@ void PlateData::parse_filament_info(GCodeProcessorResult *result)
|
|||
}
|
||||
|
||||
std::istringstream iss(buffer); // wrap returned xml to istringstream
|
||||
pt::ptree objects_tree;
|
||||
pt::ptree objects_tree;
|
||||
pt::read_xml(iss, objects_tree);
|
||||
|
||||
for (const auto &object : objects_tree.get_child("objects")) {
|
||||
for (const auto& object : objects_tree.get_child("objects")) {
|
||||
pt::ptree object_tree = object.second;
|
||||
int obj_idx = object_tree.get<int>("<xmlattr>.id", -1);
|
||||
int obj_idx = object_tree.get<int>("<xmlattr>.id", -1);
|
||||
if (obj_idx <= 0) {
|
||||
add_error("Found invalid object id");
|
||||
continue;
|
||||
|
|
@ -2349,30 +2355,33 @@ void PlateData::parse_filament_info(GCodeProcessorResult *result)
|
|||
continue;
|
||||
}
|
||||
|
||||
CutObjectBase cut_id;
|
||||
std::vector<CutObjectInfo::Connector> connectors;
|
||||
CutObjectBase cut_id;
|
||||
std::vector<CutObjectInfo::Connector> connectors;
|
||||
|
||||
for (const auto &obj_cut_info : object_tree) {
|
||||
for (const auto& obj_cut_info : object_tree) {
|
||||
if (obj_cut_info.first == "cut_id") {
|
||||
pt::ptree cut_id_tree = obj_cut_info.second;
|
||||
cut_id = CutObjectBase(ObjectID(cut_id_tree.get<size_t>("<xmlattr>.id")), cut_id_tree.get<size_t>("<xmlattr>.check_sum"),
|
||||
cut_id_tree.get<size_t>("<xmlattr>.connectors_cnt"));
|
||||
cut_id = CutObjectBase(ObjectID( cut_id_tree.get<size_t>("<xmlattr>.id")),
|
||||
cut_id_tree.get<size_t>("<xmlattr>.check_sum"),
|
||||
cut_id_tree.get<size_t>("<xmlattr>.connectors_cnt"));
|
||||
}
|
||||
if (obj_cut_info.first == "connectors") {
|
||||
pt::ptree cut_connectors_tree = obj_cut_info.second;
|
||||
for (const auto &cut_connector : cut_connectors_tree) {
|
||||
if (cut_connector.first != "connector") continue;
|
||||
pt::ptree connector_tree = cut_connector.second;
|
||||
CutObjectInfo::Connector connector = {connector_tree.get<int>("<xmlattr>.volume_id"), connector_tree.get<int>("<xmlattr>.type"),
|
||||
connector_tree.get<float>("<xmlattr>.radius", 0.f), connector_tree.get<float>("<xmlattr>.height", 0.f),
|
||||
connector_tree.get<float>("<xmlattr>.r_tolerance"), connector_tree.get<float>("<xmlattr>.h_tolerance")};
|
||||
for (const auto& cut_connector : cut_connectors_tree) {
|
||||
if (cut_connector.first != "connector")
|
||||
continue;
|
||||
pt::ptree connector_tree = cut_connector.second;
|
||||
CutObjectInfo::Connector connector = {connector_tree.get<int>("<xmlattr>.volume_id"),
|
||||
connector_tree.get<int>("<xmlattr>.type"),
|
||||
connector_tree.get<float>("<xmlattr>.r_tolerance"),
|
||||
connector_tree.get<float>("<xmlattr>.h_tolerance")};
|
||||
connectors.emplace_back(connector);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
CutObjectInfo cut_info{cut_id, connectors};
|
||||
m_cut_object_infos.insert({obj_idx, cut_info});
|
||||
CutObjectInfo cut_info {cut_id, connectors};
|
||||
m_cut_object_infos.insert({ obj_idx, cut_info });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -5260,6 +5269,7 @@ void PlateData::parse_filament_info(GCodeProcessorResult *result)
|
|||
//BBS: change volume to seperate objects
|
||||
bool _add_mesh_to_object_stream(std::function<bool(std::string &, bool)> const &flush, ObjectData const &object_data) const;
|
||||
bool _add_build_to_model_stream(std::stringstream& stream, const BuildItemsList& build_items) const;
|
||||
bool _add_cut_information_file_to_archive(mz_zip_archive& archive, Model& model);
|
||||
bool _add_layer_height_profile_file_to_archive(mz_zip_archive& archive, Model& model);
|
||||
bool _add_layer_config_ranges_file_to_archive(mz_zip_archive& archive, Model& model);
|
||||
bool _add_sla_support_points_file_to_archive(mz_zip_archive& archive, Model& model);
|
||||
|
|
@ -5270,7 +5280,6 @@ void PlateData::parse_filament_info(GCodeProcessorResult *result)
|
|||
//BBS: add project embedded preset files
|
||||
bool _add_project_embedded_presets_to_archive(mz_zip_archive& archive, Model& model, std::vector<Preset*> project_presets);
|
||||
bool _add_model_config_file_to_archive(mz_zip_archive& archive, const Model& model, PlateDataPtrs& plate_data_list, const ObjectToObjectDataMap &objects_data, int export_plate_idx = -1, bool save_gcode = true, bool use_loaded_id = false);
|
||||
bool _add_cut_information_file_to_archive(mz_zip_archive &archive, Model &model);
|
||||
bool _add_slice_info_config_file_to_archive(mz_zip_archive &archive, const Model &model, PlateDataPtrs &plate_data_list, const ObjectToObjectDataMap &objects_data, const DynamicPrintConfig& config);
|
||||
bool _add_gcode_file_to_archive(mz_zip_archive& archive, const Model& model, PlateDataPtrs& plate_data_list, Export3mfProgressFn proFn = nullptr);
|
||||
bool _add_custom_gcode_per_print_z_file_to_archive(mz_zip_archive& archive, Model& model, const DynamicPrintConfig* config);
|
||||
|
|
@ -6233,7 +6242,7 @@ void PlateData::parse_filament_info(GCodeProcessorResult *result)
|
|||
continue;
|
||||
volume_count++;
|
||||
if (m_share_mesh) {
|
||||
auto iter = m_shared_meshes.find(volume->mesh_ptr());
|
||||
auto iter = m_shared_meshes.find(volume->mesh_ptr().get());
|
||||
if (iter != m_shared_meshes.end())
|
||||
{
|
||||
const ModelVolume* shared_volume = iter->second.second;
|
||||
|
|
@ -6248,7 +6257,7 @@ void PlateData::parse_filament_info(GCodeProcessorResult *result)
|
|||
continue;
|
||||
}
|
||||
}
|
||||
const_cast<_BBS_3MF_Exporter *>(this)->m_shared_meshes.insert({volume->mesh_ptr(), {&object_data, volume}});
|
||||
const_cast<_BBS_3MF_Exporter *>(this)->m_shared_meshes.insert({volume->mesh_ptr().get(), {&object_data, volume}});
|
||||
}
|
||||
if (m_from_backup_save)
|
||||
volume_id = (volume_count << 16 | backup_id);
|
||||
|
|
@ -6704,6 +6713,69 @@ void PlateData::parse_filament_info(GCodeProcessorResult *result)
|
|||
return true;
|
||||
}
|
||||
|
||||
bool _BBS_3MF_Exporter::_add_cut_information_file_to_archive(mz_zip_archive &archive, Model &model)
|
||||
{
|
||||
std::string out = "";
|
||||
pt::ptree tree;
|
||||
|
||||
unsigned int object_cnt = 0;
|
||||
for (const ModelObject* object : model.objects) {
|
||||
object_cnt++;
|
||||
if (!object->is_cut())
|
||||
continue;
|
||||
pt::ptree& obj_tree = tree.add("objects.object", "");
|
||||
|
||||
obj_tree.put("<xmlattr>.id", object_cnt);
|
||||
|
||||
// Store info for cut_id
|
||||
pt::ptree& cut_id_tree = obj_tree.add("cut_id", "");
|
||||
|
||||
// store cut_id atributes
|
||||
cut_id_tree.put("<xmlattr>.id", object->cut_id.id().id);
|
||||
cut_id_tree.put("<xmlattr>.check_sum", object->cut_id.check_sum());
|
||||
cut_id_tree.put("<xmlattr>.connectors_cnt", object->cut_id.connectors_cnt());
|
||||
|
||||
int volume_idx = -1;
|
||||
for (const ModelVolume* volume : object->volumes) {
|
||||
++volume_idx;
|
||||
if (volume->is_cut_connector()) {
|
||||
pt::ptree& connectors_tree = obj_tree.add("connectors.connector", "");
|
||||
connectors_tree.put("<xmlattr>.volume_id", volume_idx);
|
||||
connectors_tree.put("<xmlattr>.type", int(volume->cut_info.connector_type));
|
||||
connectors_tree.put("<xmlattr>.r_tolerance", volume->cut_info.radius_tolerance);
|
||||
connectors_tree.put("<xmlattr>.h_tolerance", volume->cut_info.height_tolerance);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!tree.empty()) {
|
||||
std::ostringstream oss;
|
||||
pt::write_xml(oss, tree);
|
||||
out = oss.str();
|
||||
|
||||
// Post processing("beautification") of the output string for a better preview
|
||||
boost::replace_all(out, "><object", ">\n <object");
|
||||
boost::replace_all(out, "><cut_id", ">\n <cut_id");
|
||||
boost::replace_all(out, "></cut_id>", ">\n </cut_id>");
|
||||
boost::replace_all(out, "><connectors", ">\n <connectors");
|
||||
boost::replace_all(out, "></connectors>", ">\n </connectors>");
|
||||
boost::replace_all(out, "><connector", ">\n <connector");
|
||||
boost::replace_all(out, "></connector>", ">\n </connector>");
|
||||
boost::replace_all(out, "></object>", ">\n </object>");
|
||||
// OR just
|
||||
boost::replace_all(out, "><", ">\n<");
|
||||
}
|
||||
|
||||
if (!out.empty()) {
|
||||
if (!mz_zip_writer_add_mem(&archive, CUT_INFORMATION_FILE.c_str(), (const void*)out.data(), out.length(), MZ_DEFAULT_COMPRESSION)) {
|
||||
add_error("Unable to add cut information file to archive");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool _BBS_3MF_Exporter::_add_layer_height_profile_file_to_archive(mz_zip_archive& archive, Model& model)
|
||||
{
|
||||
assert(is_decimal_separator_point());
|
||||
|
|
@ -7266,69 +7338,6 @@ void PlateData::parse_filament_info(GCodeProcessorResult *result)
|
|||
return true;
|
||||
}
|
||||
|
||||
bool _BBS_3MF_Exporter::_add_cut_information_file_to_archive(mz_zip_archive &archive, Model &model)
|
||||
{
|
||||
std::string out = "";
|
||||
pt::ptree tree;
|
||||
|
||||
unsigned int object_cnt = 0;
|
||||
for (const ModelObject *object : model.objects) {
|
||||
object_cnt++;
|
||||
pt::ptree &obj_tree = tree.add("objects.object", "");
|
||||
|
||||
obj_tree.put("<xmlattr>.id", object_cnt);
|
||||
|
||||
// Store info for cut_id
|
||||
pt::ptree &cut_id_tree = obj_tree.add("cut_id", "");
|
||||
|
||||
// store cut_id atributes
|
||||
cut_id_tree.put("<xmlattr>.id", object->cut_id.id().id);
|
||||
cut_id_tree.put("<xmlattr>.check_sum", object->cut_id.check_sum());
|
||||
cut_id_tree.put("<xmlattr>.connectors_cnt", object->cut_id.connectors_cnt());
|
||||
|
||||
int volume_idx = -1;
|
||||
for (const ModelVolume *volume : object->volumes) {
|
||||
++volume_idx;
|
||||
if (volume->is_cut_connector()) {
|
||||
pt::ptree &connectors_tree = obj_tree.add("connectors.connector", "");
|
||||
connectors_tree.put("<xmlattr>.volume_id", volume_idx);
|
||||
connectors_tree.put("<xmlattr>.type", int(volume->cut_info.connector_type));
|
||||
connectors_tree.put("<xmlattr>.radius", volume->cut_info.radius);
|
||||
connectors_tree.put("<xmlattr>.height", volume->cut_info.height);
|
||||
connectors_tree.put("<xmlattr>.r_tolerance", volume->cut_info.radius_tolerance);
|
||||
connectors_tree.put("<xmlattr>.h_tolerance", volume->cut_info.height_tolerance);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!tree.empty()) {
|
||||
std::ostringstream oss;
|
||||
pt::write_xml(oss, tree);
|
||||
out = oss.str();
|
||||
|
||||
// Post processing("beautification") of the output string for a better preview
|
||||
boost::replace_all(out, "><object", ">\n <object");
|
||||
boost::replace_all(out, "><cut_id", ">\n <cut_id");
|
||||
boost::replace_all(out, "></cut_id>", ">\n </cut_id>");
|
||||
boost::replace_all(out, "><connectors", ">\n <connectors");
|
||||
boost::replace_all(out, "></connectors>", ">\n </connectors>");
|
||||
boost::replace_all(out, "><connector", ">\n <connector");
|
||||
boost::replace_all(out, "></connector>", ">\n </connector>");
|
||||
boost::replace_all(out, "></object>", ">\n </object>");
|
||||
// OR just
|
||||
boost::replace_all(out, "><", ">\n<");
|
||||
}
|
||||
|
||||
if (!out.empty()) {
|
||||
if (!mz_zip_writer_add_mem(&archive, CUT_INFORMATION_FILE.c_str(), (const void *) out.data(), out.length(), MZ_DEFAULT_COMPRESSION)) {
|
||||
add_error("Unable to add cut information file to archive");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool _BBS_3MF_Exporter::_add_slice_info_config_file_to_archive(mz_zip_archive& archive, const Model& model, PlateDataPtrs& plate_data_list, const ObjectToObjectDataMap &objects_data, const DynamicPrintConfig& config)
|
||||
{
|
||||
std::stringstream stream;
|
||||
|
|
|
|||
|
|
@ -1,3 +1,17 @@
|
|||
///|/ Copyright (c) Prusa Research 2016 - 2023 Vojtěch Bubník @bubnikv, Enrico Turri @enricoturri1966, Lukáš Matěna @lukasmatena, Filip Sykala @Jony01, Tomáš Mészáros @tamasmeszaros
|
||||
///|/ Copyright (c) Slic3r 2013 - 2016 Alessandro Ranellucci @alranel
|
||||
///|/
|
||||
///|/ ported from lib/Slic3r/Geometry.pm:
|
||||
///|/ Copyright (c) Prusa Research 2017 - 2022 Vojtěch Bubník @bubnikv
|
||||
///|/ Copyright (c) Slic3r 2011 - 2015 Alessandro Ranellucci @alranel
|
||||
///|/ Copyright (c) 2013 Jose Luis Perez Diez
|
||||
///|/ Copyright (c) 2013 Anders Sundman
|
||||
///|/ Copyright (c) 2013 Jesse Vincent
|
||||
///|/ Copyright (c) 2012 Mike Sheldrake @mesheldrake
|
||||
///|/ Copyright (c) 2012 Mark Hindess
|
||||
///|/
|
||||
///|/ PrusaSlicer is released under the terms of the AGPLv3 or higher
|
||||
///|/
|
||||
#include "libslic3r.h"
|
||||
#include "Exception.hpp"
|
||||
#include "Geometry.hpp"
|
||||
|
|
@ -320,46 +334,103 @@ Transform3d assemble_transform(const Vec3d& translation, const Vec3d& rotation,
|
|||
return transform;
|
||||
}
|
||||
|
||||
void assemble_transform(Transform3d& transform, const Transform3d& translation, const Transform3d& rotation, const Transform3d& scale, const Transform3d& mirror)
|
||||
{
|
||||
transform = translation * rotation * scale * mirror;
|
||||
}
|
||||
|
||||
Transform3d assemble_transform(const Transform3d& translation, const Transform3d& rotation, const Transform3d& scale, const Transform3d& mirror)
|
||||
{
|
||||
Transform3d transform;
|
||||
assemble_transform(transform, translation, rotation, scale, mirror);
|
||||
return transform;
|
||||
}
|
||||
|
||||
void translation_transform(Transform3d& transform, const Vec3d& translation)
|
||||
{
|
||||
transform = Transform3d::Identity();
|
||||
transform.translate(translation);
|
||||
}
|
||||
|
||||
Transform3d translation_transform(const Vec3d& translation)
|
||||
{
|
||||
Transform3d transform;
|
||||
translation_transform(transform, translation);
|
||||
return transform;
|
||||
}
|
||||
|
||||
void rotation_transform(Transform3d& transform, const Vec3d& rotation)
|
||||
{
|
||||
transform = Transform3d::Identity();
|
||||
transform.rotate(Eigen::AngleAxisd(rotation.z(), Vec3d::UnitZ()) * Eigen::AngleAxisd(rotation.y(), Vec3d::UnitY()) * Eigen::AngleAxisd(rotation.x(), Vec3d::UnitX()));
|
||||
}
|
||||
|
||||
Transform3d rotation_transform(const Vec3d& rotation)
|
||||
{
|
||||
Transform3d transform;
|
||||
rotation_transform(transform, rotation);
|
||||
return transform;
|
||||
}
|
||||
|
||||
void scale_transform(Transform3d& transform, double scale)
|
||||
{
|
||||
return scale_transform(transform, scale * Vec3d::Ones());
|
||||
}
|
||||
|
||||
void scale_transform(Transform3d& transform, const Vec3d& scale)
|
||||
{
|
||||
transform = Transform3d::Identity();
|
||||
transform.scale(scale);
|
||||
}
|
||||
|
||||
Transform3d scale_transform(double scale)
|
||||
{
|
||||
return scale_transform(scale * Vec3d::Ones());
|
||||
}
|
||||
|
||||
Transform3d scale_transform(const Vec3d& scale)
|
||||
{
|
||||
Transform3d transform;
|
||||
scale_transform(transform, scale);
|
||||
return transform;
|
||||
}
|
||||
|
||||
Vec3d extract_euler_angles(const Eigen::Matrix<double, 3, 3, Eigen::DontAlign>& rotation_matrix)
|
||||
{
|
||||
// reference: http://www.gregslabaugh.net/publications/euler.pdf
|
||||
Vec3d angles1 = Vec3d::Zero();
|
||||
Vec3d angles2 = Vec3d::Zero();
|
||||
// BBS: rotation_matrix(2, 0) may be slighterly larger than 1 due to numerical accuracy
|
||||
if (std::abs(std::abs(rotation_matrix(2, 0)) - 1.0) < 1e-5 || std::abs(rotation_matrix(2, 0))>1)
|
||||
{
|
||||
angles1(2) = 0.0;
|
||||
if (rotation_matrix(2, 0) < 0.0) // == -1.0
|
||||
{
|
||||
angles1(1) = 0.5 * (double)PI;
|
||||
angles1(0) = angles1(2) + ::atan2(rotation_matrix(0, 1), rotation_matrix(0, 2));
|
||||
if (std::abs(std::abs(rotation_matrix(2, 0)) - 1.0) < 1e-5 || std::abs(rotation_matrix(2, 0))>1) {
|
||||
angles1.z() = 0.0;
|
||||
if (rotation_matrix(2, 0) < 0.0) { // == -1.0
|
||||
angles1.y() = 0.5 * double(PI);
|
||||
angles1.x() = angles1.z() + ::atan2(rotation_matrix(0, 1), rotation_matrix(0, 2));
|
||||
}
|
||||
else // == 1.0
|
||||
{
|
||||
angles1(1) = - 0.5 * (double)PI;
|
||||
angles1(0) = - angles1(2) + ::atan2(- rotation_matrix(0, 1), - rotation_matrix(0, 2));
|
||||
else { // == 1.0
|
||||
angles1.y() = - 0.5 * double(PI);
|
||||
angles1.x() = - angles1.y() + ::atan2(- rotation_matrix(0, 1), - rotation_matrix(0, 2));
|
||||
}
|
||||
angles2 = angles1;
|
||||
}
|
||||
else
|
||||
{
|
||||
angles1(1) = -::asin(rotation_matrix(2, 0));
|
||||
double inv_cos1 = 1.0 / ::cos(angles1(1));
|
||||
angles1(0) = ::atan2(rotation_matrix(2, 1) * inv_cos1, rotation_matrix(2, 2) * inv_cos1);
|
||||
angles1(2) = ::atan2(rotation_matrix(1, 0) * inv_cos1, rotation_matrix(0, 0) * inv_cos1);
|
||||
else {
|
||||
angles1.y() = -::asin(rotation_matrix(2, 0));
|
||||
const double inv_cos1 = 1.0 / ::cos(angles1.y());
|
||||
angles1.x() = ::atan2(rotation_matrix(2, 1) * inv_cos1, rotation_matrix(2, 2) * inv_cos1);
|
||||
angles1.z() = ::atan2(rotation_matrix(1, 0) * inv_cos1, rotation_matrix(0, 0) * inv_cos1);
|
||||
|
||||
angles2(1) = (double)PI - angles1(1);
|
||||
double inv_cos2 = 1.0 / ::cos(angles2(1));
|
||||
angles2(0) = ::atan2(rotation_matrix(2, 1) * inv_cos2, rotation_matrix(2, 2) * inv_cos2);
|
||||
angles2(2) = ::atan2(rotation_matrix(1, 0) * inv_cos2, rotation_matrix(0, 0) * inv_cos2);
|
||||
angles2.y() = double(PI) - angles1.y();
|
||||
const double inv_cos2 = 1.0 / ::cos(angles2.y());
|
||||
angles2.x() = ::atan2(rotation_matrix(2, 1) * inv_cos2, rotation_matrix(2, 2) * inv_cos2);
|
||||
angles2.z() = ::atan2(rotation_matrix(1, 0) * inv_cos2, rotation_matrix(0, 0) * inv_cos2);
|
||||
}
|
||||
|
||||
// The following euristic is the best found up to now (in the sense that it works fine with the greatest number of edge use-cases)
|
||||
// but there are other use-cases were it does not
|
||||
// We need to improve it
|
||||
double min_1 = angles1.cwiseAbs().minCoeff();
|
||||
double min_2 = angles2.cwiseAbs().minCoeff();
|
||||
bool use_1 = (min_1 < min_2) || (is_approx(min_1, min_2) && (angles1.norm() <= angles2.norm()));
|
||||
const double min_1 = angles1.cwiseAbs().minCoeff();
|
||||
const double min_2 = angles2.cwiseAbs().minCoeff();
|
||||
const bool use_1 = (min_1 < min_2) || (is_approx(min_1, min_2) && (angles1.norm() <= angles2.norm()));
|
||||
|
||||
return use_1 ? angles1 : angles2;
|
||||
}
|
||||
|
|
@ -375,6 +446,14 @@ Vec3d extract_euler_angles(const Transform3d& transform)
|
|||
return extract_euler_angles(m);
|
||||
}
|
||||
|
||||
static Transform3d extract_rotation_matrix(const Transform3d& trafo)
|
||||
{
|
||||
Matrix3d rotation;
|
||||
Matrix3d scale;
|
||||
trafo.computeRotationScaling(&rotation, &scale);
|
||||
return Transform3d(rotation);
|
||||
}
|
||||
|
||||
void rotation_from_two_vectors(Vec3d from, Vec3d to, Vec3d& rotation_axis, double& phi, Matrix3d* rotation_matrix)
|
||||
{
|
||||
double epsilon = 1e-5;
|
||||
|
|
@ -409,28 +488,6 @@ void rotation_from_two_vectors(Vec3d from, Vec3d to, Vec3d& rotation_axis, doubl
|
|||
}
|
||||
}
|
||||
|
||||
Transform3d translation_transform(const Vec3d &translation)
|
||||
{
|
||||
Transform3d transform = Transform3d::Identity();
|
||||
transform.translate(translation);
|
||||
return transform;
|
||||
}
|
||||
|
||||
Transform3d rotation_transform(const Vec3d& rotation)
|
||||
{
|
||||
Transform3d transform = Transform3d::Identity();
|
||||
transform.rotate(Eigen::AngleAxisd(rotation.z(), Vec3d::UnitZ()) * Eigen::AngleAxisd(rotation.y(), Vec3d::UnitY()) * Eigen::AngleAxisd(rotation.x(), Vec3d::UnitX()));
|
||||
return transform;
|
||||
}
|
||||
|
||||
Transformation::Flags::Flags()
|
||||
: dont_translate(true)
|
||||
, dont_rotate(true)
|
||||
, dont_scale(true)
|
||||
, dont_mirror(true)
|
||||
{
|
||||
}
|
||||
|
||||
bool Transformation::Flags::needs_update(bool dont_translate, bool dont_rotate, bool dont_scale, bool dont_mirror) const
|
||||
{
|
||||
return (this->dont_translate != dont_translate) || (this->dont_rotate != dont_rotate) || (this->dont_scale != dont_scale) || (this->dont_mirror != dont_mirror);
|
||||
|
|
@ -456,35 +513,38 @@ Transformation::Transformation(const Transform3d& transform)
|
|||
|
||||
void Transformation::set_offset(const Vec3d& offset)
|
||||
{
|
||||
set_offset(X, offset(0));
|
||||
set_offset(Y, offset(1));
|
||||
set_offset(Z, offset(2));
|
||||
set_offset(X, offset.x());
|
||||
set_offset(Y, offset.y());
|
||||
set_offset(Z, offset.z());
|
||||
}
|
||||
|
||||
void Transformation::set_offset(Axis axis, double offset)
|
||||
{
|
||||
if (m_offset(axis) != offset)
|
||||
{
|
||||
if (m_offset(axis) != offset) {
|
||||
m_offset(axis) = offset;
|
||||
m_dirty = true;
|
||||
}
|
||||
}
|
||||
|
||||
Transform3d Transformation::get_rotation_matrix() const
|
||||
{
|
||||
return extract_rotation_matrix(m_matrix);
|
||||
}
|
||||
|
||||
void Transformation::set_rotation(const Vec3d& rotation)
|
||||
{
|
||||
set_rotation(X, rotation(0));
|
||||
set_rotation(Y, rotation(1));
|
||||
set_rotation(Z, rotation(2));
|
||||
set_rotation(X, rotation.x());
|
||||
set_rotation(Y, rotation.y());
|
||||
set_rotation(Z, rotation.z());
|
||||
}
|
||||
|
||||
void Transformation::set_rotation(Axis axis, double rotation)
|
||||
{
|
||||
rotation = angle_to_0_2PI(rotation);
|
||||
if (is_approx(std::abs(rotation), 2.0 * (double)PI))
|
||||
if (is_approx(std::abs(rotation), 2.0 * double(PI)))
|
||||
rotation = 0.0;
|
||||
|
||||
if (m_rotation(axis) != rotation)
|
||||
{
|
||||
if (m_rotation(axis) != rotation) {
|
||||
m_rotation(axis) = rotation;
|
||||
m_dirty = true;
|
||||
}
|
||||
|
|
@ -492,15 +552,14 @@ void Transformation::set_rotation(Axis axis, double rotation)
|
|||
|
||||
void Transformation::set_scaling_factor(const Vec3d& scaling_factor)
|
||||
{
|
||||
set_scaling_factor(X, scaling_factor(0));
|
||||
set_scaling_factor(Y, scaling_factor(1));
|
||||
set_scaling_factor(Z, scaling_factor(2));
|
||||
set_scaling_factor(X, scaling_factor.x());
|
||||
set_scaling_factor(Y, scaling_factor.y());
|
||||
set_scaling_factor(Z, scaling_factor.z());
|
||||
}
|
||||
|
||||
void Transformation::set_scaling_factor(Axis axis, double scaling_factor)
|
||||
{
|
||||
if (m_scaling_factor(axis) != std::abs(scaling_factor))
|
||||
{
|
||||
if (m_scaling_factor(axis) != std::abs(scaling_factor)) {
|
||||
m_scaling_factor(axis) = std::abs(scaling_factor);
|
||||
m_dirty = true;
|
||||
}
|
||||
|
|
@ -508,9 +567,9 @@ void Transformation::set_scaling_factor(Axis axis, double scaling_factor)
|
|||
|
||||
void Transformation::set_mirror(const Vec3d& mirror)
|
||||
{
|
||||
set_mirror(X, mirror(0));
|
||||
set_mirror(Y, mirror(1));
|
||||
set_mirror(Z, mirror(2));
|
||||
set_mirror(X, mirror.x());
|
||||
set_mirror(Y, mirror.y());
|
||||
set_mirror(Z, mirror.z());
|
||||
}
|
||||
|
||||
void Transformation::set_mirror(Axis axis, double mirror)
|
||||
|
|
@ -521,8 +580,7 @@ void Transformation::set_mirror(Axis axis, double mirror)
|
|||
else if (abs_mirror != 1.0)
|
||||
mirror /= abs_mirror;
|
||||
|
||||
if (m_mirror(axis) != mirror)
|
||||
{
|
||||
if (m_mirror(axis) != mirror) {
|
||||
m_mirror(axis) = mirror;
|
||||
m_dirty = true;
|
||||
}
|
||||
|
|
@ -540,9 +598,8 @@ void Transformation::set_from_transform(const Transform3d& transform)
|
|||
// we can only detect if the matrix contains a left handed reference system
|
||||
// in which case we reorient it back to right handed by mirroring the x axis
|
||||
Vec3d mirror = Vec3d::Ones();
|
||||
if (m3x3.col(0).dot(m3x3.col(1).cross(m3x3.col(2))) < 0.0)
|
||||
{
|
||||
mirror(0) = -1.0;
|
||||
if (m3x3.col(0).dot(m3x3.col(1).cross(m3x3.col(2))) < 0.0) {
|
||||
mirror.x() = -1.0;
|
||||
// remove mirror
|
||||
m3x3.col(0) *= -1.0;
|
||||
}
|
||||
|
|
@ -579,8 +636,7 @@ void Transformation::reset()
|
|||
|
||||
const Transform3d& Transformation::get_matrix(bool dont_translate, bool dont_rotate, bool dont_scale, bool dont_mirror) const
|
||||
{
|
||||
if (m_dirty || m_flags.needs_update(dont_translate, dont_rotate, dont_scale, dont_mirror))
|
||||
{
|
||||
if (m_dirty || m_flags.needs_update(dont_translate, dont_rotate, dont_scale, dont_mirror)) {
|
||||
m_matrix = Geometry::assemble_transform(
|
||||
dont_translate ? Vec3d::Zero() : m_offset,
|
||||
dont_rotate ? Vec3d::Zero() : m_rotation,
|
||||
|
|
@ -609,8 +665,7 @@ Transformation Transformation::volume_to_bed_transformation(const Transformation
|
|||
// Just set the inverse.
|
||||
out.set_from_transform(instance_transformation.get_matrix(true).inverse());
|
||||
}
|
||||
else if (is_rotation_ninety_degrees(instance_transformation.get_rotation()))
|
||||
{
|
||||
else if (is_rotation_ninety_degrees(instance_transformation.get_rotation())) {
|
||||
// Anisotropic scaling, rotation by multiples of ninety degrees.
|
||||
Eigen::Matrix3d instance_rotation_trafo =
|
||||
(Eigen::AngleAxisd(instance_transformation.get_rotation().z(), Vec3d::UnitZ()) *
|
||||
|
|
@ -643,8 +698,8 @@ Transformation Transformation::volume_to_bed_transformation(const Transformation
|
|||
scale(i) = pts.col(i).dot(qs.col(i)) / pts.col(i).dot(pts.col(i));
|
||||
|
||||
out.set_rotation(Geometry::extract_euler_angles(volume_rotation_trafo));
|
||||
out.set_scaling_factor(Vec3d(std::abs(scale(0)), std::abs(scale(1)), std::abs(scale(2))));
|
||||
out.set_mirror(Vec3d(scale(0) > 0 ? 1. : -1, scale(1) > 0 ? 1. : -1, scale(2) > 0 ? 1. : -1));
|
||||
out.set_scaling_factor(Vec3d(std::abs(scale.x()), std::abs(scale.y()), std::abs(scale.z())));
|
||||
out.set_mirror(Vec3d(scale.x() > 0 ? 1. : -1, scale.y() > 0 ? 1. : -1, scale.z() > 0 ? 1. : -1));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -663,19 +718,15 @@ Transform3d transform3d_from_string(const std::string& transform_str)
|
|||
assert(is_decimal_separator_point()); // for atof
|
||||
Transform3d transform = Transform3d::Identity();
|
||||
|
||||
if (!transform_str.empty())
|
||||
{
|
||||
if (!transform_str.empty()) {
|
||||
std::vector<std::string> mat_elements_str;
|
||||
boost::split(mat_elements_str, transform_str, boost::is_any_of(" "), boost::token_compress_on);
|
||||
|
||||
unsigned int size = (unsigned int)mat_elements_str.size();
|
||||
if (size == 16)
|
||||
{
|
||||
const unsigned int size = (unsigned int)mat_elements_str.size();
|
||||
if (size == 16) {
|
||||
unsigned int i = 0;
|
||||
for (unsigned int r = 0; r < 4; ++r)
|
||||
{
|
||||
for (unsigned int c = 0; c < 4; ++c)
|
||||
{
|
||||
for (unsigned int r = 0; r < 4; ++r) {
|
||||
for (unsigned int c = 0; c < 4; ++c) {
|
||||
transform(r, c) = ::atof(mat_elements_str[i++].c_str());
|
||||
}
|
||||
}
|
||||
|
|
@ -689,17 +740,17 @@ Eigen::Quaterniond rotation_xyz_diff(const Vec3d &rot_xyz_from, const Vec3d &rot
|
|||
{
|
||||
return
|
||||
// From the current coordinate system to world.
|
||||
Eigen::AngleAxisd(rot_xyz_to(2), Vec3d::UnitZ()) * Eigen::AngleAxisd(rot_xyz_to(1), Vec3d::UnitY()) * Eigen::AngleAxisd(rot_xyz_to(0), Vec3d::UnitX()) *
|
||||
Eigen::AngleAxisd(rot_xyz_to.z(), Vec3d::UnitZ()) * Eigen::AngleAxisd(rot_xyz_to.y(), Vec3d::UnitY()) * Eigen::AngleAxisd(rot_xyz_to.x(), Vec3d::UnitX()) *
|
||||
// From world to the initial coordinate system.
|
||||
Eigen::AngleAxisd(-rot_xyz_from(0), Vec3d::UnitX()) * Eigen::AngleAxisd(-rot_xyz_from(1), Vec3d::UnitY()) * Eigen::AngleAxisd(-rot_xyz_from(2), Vec3d::UnitZ());
|
||||
Eigen::AngleAxisd(-rot_xyz_from.x(), Vec3d::UnitX()) * Eigen::AngleAxisd(-rot_xyz_from.y(), Vec3d::UnitY()) * Eigen::AngleAxisd(-rot_xyz_from.z(), Vec3d::UnitZ());
|
||||
}
|
||||
|
||||
// This should only be called if it is known, that the two rotations only differ in rotation around the Z axis.
|
||||
double rotation_diff_z(const Vec3d &rot_xyz_from, const Vec3d &rot_xyz_to)
|
||||
{
|
||||
Eigen::AngleAxisd angle_axis(rotation_xyz_diff(rot_xyz_from, rot_xyz_to));
|
||||
Vec3d axis = angle_axis.axis();
|
||||
double angle = angle_axis.angle();
|
||||
const Eigen::AngleAxisd angle_axis(rotation_xyz_diff(rot_xyz_from, rot_xyz_to));
|
||||
const Vec3d axis = angle_axis.axis();
|
||||
const double angle = angle_axis.angle();
|
||||
#ifndef NDEBUG
|
||||
if (std::abs(angle) > 1e-8) {
|
||||
assert(std::abs(axis.x()) < 1e-8);
|
||||
|
|
|
|||
|
|
@ -1,3 +1,18 @@
|
|||
///|/ Copyright (c) Prusa Research 2016 - 2023 Vojtěch Bubník @bubnikv, Enrico Turri @enricoturri1966, Tomáš Mészáros @tamasmeszaros, Lukáš Matěna @lukasmatena, Filip Sykala @Jony01, Lukáš Hejl @hejllukas
|
||||
///|/ Copyright (c) 2017 Eyal Soha @eyal0
|
||||
///|/ Copyright (c) Slic3r 2013 - 2016 Alessandro Ranellucci @alranel
|
||||
///|/
|
||||
///|/ ported from lib/Slic3r/Geometry.pm:
|
||||
///|/ Copyright (c) Prusa Research 2017 - 2022 Vojtěch Bubník @bubnikv
|
||||
///|/ Copyright (c) Slic3r 2011 - 2015 Alessandro Ranellucci @alranel
|
||||
///|/ Copyright (c) 2013 Jose Luis Perez Diez
|
||||
///|/ Copyright (c) 2013 Anders Sundman
|
||||
///|/ Copyright (c) 2013 Jesse Vincent
|
||||
///|/ Copyright (c) 2012 Mike Sheldrake @mesheldrake
|
||||
///|/ Copyright (c) 2012 Mark Hindess
|
||||
///|/
|
||||
///|/ PrusaSlicer is released under the terms of the AGPLv3 or higher
|
||||
///|/
|
||||
#ifndef slic3r_Geometry_hpp_
|
||||
#define slic3r_Geometry_hpp_
|
||||
|
||||
|
|
@ -324,7 +339,8 @@ bool arrange(
|
|||
// 4) rotate Y
|
||||
// 5) rotate Z
|
||||
// 6) translate
|
||||
void assemble_transform(Transform3d& transform, const Vec3d& translation = Vec3d::Zero(), const Vec3d& rotation = Vec3d::Zero(), const Vec3d& scale = Vec3d::Ones(), const Vec3d& mirror = Vec3d::Ones());
|
||||
void assemble_transform(Transform3d& transform, const Vec3d& translation = Vec3d::Zero(), const Vec3d& rotation = Vec3d::Zero(),
|
||||
const Vec3d& scale = Vec3d::Ones(), const Vec3d& mirror = Vec3d::Ones());
|
||||
|
||||
// Returns the transform obtained by assembling the given transformations in the following order:
|
||||
// 1) mirror
|
||||
|
|
@ -333,7 +349,45 @@ void assemble_transform(Transform3d& transform, const Vec3d& translation = Vec3d
|
|||
// 4) rotate Y
|
||||
// 5) rotate Z
|
||||
// 6) translate
|
||||
Transform3d assemble_transform(const Vec3d& translation = Vec3d::Zero(), const Vec3d& rotation = Vec3d::Zero(), const Vec3d& scale = Vec3d::Ones(), const Vec3d& mirror = Vec3d::Ones());
|
||||
Transform3d assemble_transform(const Vec3d& translation = Vec3d::Zero(), const Vec3d& rotation = Vec3d::Zero(),
|
||||
const Vec3d& scale = Vec3d::Ones(), const Vec3d& mirror = Vec3d::Ones());
|
||||
|
||||
// Sets the given transform by multiplying the given transformations in the following order:
|
||||
// T = translation * rotation * scale * mirror
|
||||
void assemble_transform(Transform3d& transform, const Transform3d& translation = Transform3d::Identity(),
|
||||
const Transform3d& rotation = Transform3d::Identity(), const Transform3d& scale = Transform3d::Identity(),
|
||||
const Transform3d& mirror = Transform3d::Identity());
|
||||
|
||||
// Returns the transform obtained by multiplying the given transformations in the following order:
|
||||
// T = translation * rotation * scale * mirror
|
||||
Transform3d assemble_transform(const Transform3d& translation = Transform3d::Identity(), const Transform3d& rotation = Transform3d::Identity(),
|
||||
const Transform3d& scale = Transform3d::Identity(), const Transform3d& mirror = Transform3d::Identity());
|
||||
|
||||
// Sets the given transform by assembling the given translation
|
||||
void translation_transform(Transform3d& transform, const Vec3d& translation);
|
||||
|
||||
// Returns the transform obtained by assembling the given translation
|
||||
Transform3d translation_transform(const Vec3d& translation);
|
||||
|
||||
// Sets the given transform by assembling the given rotations in the following order:
|
||||
// 1) rotate X
|
||||
// 2) rotate Y
|
||||
// 3) rotate Z
|
||||
void rotation_transform(Transform3d& transform, const Vec3d& rotation);
|
||||
|
||||
// Returns the transform obtained by assembling the given rotations in the following order:
|
||||
// 1) rotate X
|
||||
// 2) rotate Y
|
||||
// 3) rotate Z
|
||||
Transform3d rotation_transform(const Vec3d& rotation);
|
||||
|
||||
// Sets the given transform by assembling the given scale factors
|
||||
void scale_transform(Transform3d& transform, double scale);
|
||||
void scale_transform(Transform3d& transform, const Vec3d& scale);
|
||||
|
||||
// Returns the transform obtained by assembling the given scale factors
|
||||
Transform3d scale_transform(double scale);
|
||||
Transform3d scale_transform(const Vec3d& scale);
|
||||
|
||||
// Returns the euler angles extracted from the given rotation matrix
|
||||
// Warning -> The matrix should not contain any scale or shear !!!
|
||||
|
|
@ -346,40 +400,29 @@ Vec3d extract_euler_angles(const Transform3d& transform);
|
|||
// get rotation from two vectors.
|
||||
// Default output is axis-angle. If rotation_matrix pointer is provided, also output rotation matrix
|
||||
// Euler angles can be obtained by extract_euler_angles()
|
||||
void rotation_from_two_vectors(Vec3d from, Vec3d to, Vec3d& rotation_axis, double& phi, Matrix3d* rotation_matrix = nullptr);
|
||||
|
||||
// Returns the transform obtained by assembling the given translation
|
||||
Transform3d translation_transform(const Vec3d &translation);
|
||||
|
||||
// Returns the transform obtained by assembling the given rotations in the following order:
|
||||
// 1) rotate X
|
||||
// 2) rotate Y
|
||||
// 3) rotate Z
|
||||
Transform3d rotation_transform(const Vec3d &rotation);
|
||||
void rotation_from_two_vectors(Vec3d from, Vec3d to, Vec3d &rotation_axis, double &phi, Matrix3d *rotation_matrix = nullptr);
|
||||
|
||||
class Transformation
|
||||
{
|
||||
struct Flags
|
||||
{
|
||||
bool dont_translate;
|
||||
bool dont_rotate;
|
||||
bool dont_scale;
|
||||
bool dont_mirror;
|
||||
|
||||
Flags();
|
||||
bool dont_translate{ true };
|
||||
bool dont_rotate{ true };
|
||||
bool dont_scale{ true };
|
||||
bool dont_mirror{ true };
|
||||
|
||||
bool needs_update(bool dont_translate, bool dont_rotate, bool dont_scale, bool dont_mirror) const;
|
||||
void set(bool dont_translate, bool dont_rotate, bool dont_scale, bool dont_mirror);
|
||||
};
|
||||
|
||||
Vec3d m_offset; // In unscaled coordinates
|
||||
Vec3d m_rotation; // Rotation around the three axes, in radians around mesh center point
|
||||
Vec3d m_scaling_factor; // Scaling factors along the three axes
|
||||
Vec3d m_mirror; // Mirroring along the three axes
|
||||
Vec3d m_offset{ Vec3d::Zero() }; // In unscaled coordinates
|
||||
Vec3d m_rotation{ Vec3d::Zero() }; // Rotation around the three axes, in radians around mesh center point
|
||||
Vec3d m_scaling_factor{ Vec3d::Ones() }; // Scaling factors along the three axes
|
||||
Vec3d m_mirror{ Vec3d::Ones() }; // Mirroring along the three axes
|
||||
|
||||
mutable Transform3d m_matrix;
|
||||
mutable Transform3d m_matrix{ Transform3d::Identity() };
|
||||
mutable Flags m_flags;
|
||||
mutable bool m_dirty;
|
||||
mutable bool m_dirty{ false };
|
||||
|
||||
public:
|
||||
Transformation();
|
||||
|
|
@ -397,6 +440,8 @@ public:
|
|||
const Vec3d& get_rotation() const { return m_rotation; }
|
||||
double get_rotation(Axis axis) const { return m_rotation(axis); }
|
||||
|
||||
Transform3d get_rotation_matrix() const;
|
||||
|
||||
void set_rotation(const Vec3d& rotation);
|
||||
void set_rotation(Axis axis, double rotation);
|
||||
|
||||
|
|
@ -457,7 +502,7 @@ extern double rotation_diff_z(const Vec3d &rot_xyz_from, const Vec3d &rot_xyz_to
|
|||
// Is the angle close to a multiple of 90 degrees?
|
||||
inline bool is_rotation_ninety_degrees(double a)
|
||||
{
|
||||
a = fmod(std::abs(a), 0.5 * M_PI);
|
||||
a = fmod(std::abs(a), 0.5 * PI);
|
||||
if (a > 0.25 * PI)
|
||||
a = 0.5 * PI - a;
|
||||
return a < 0.001;
|
||||
|
|
|
|||
|
|
@ -1,3 +1,7 @@
|
|||
///|/ Copyright (c) Prusa Research 2021 - 2022 Lukáš Matěna @lukasmatena, Filip Sykala @Jony01, Vojtěch Bubník @bubnikv
|
||||
///|/
|
||||
///|/ PrusaSlicer is released under the terms of the AGPLv3 or higher
|
||||
///|/
|
||||
#include "Circle.hpp"
|
||||
|
||||
#include "../Polygon.hpp"
|
||||
|
|
@ -108,7 +112,7 @@ Circled circle_taubin_newton(const Vec2ds& input, size_t cycles)
|
|||
return out;
|
||||
}
|
||||
|
||||
Circled circle_ransac(const Vec2ds& input, size_t iterations)
|
||||
Circled circle_ransac(const Vec2ds& input, size_t iterations, double* min_error)
|
||||
{
|
||||
if (input.size() < 3)
|
||||
return Circled::make_invalid();
|
||||
|
|
@ -132,6 +136,8 @@ Circled circle_ransac(const Vec2ds& input, size_t iterations)
|
|||
circle_best = c;
|
||||
}
|
||||
}
|
||||
if (min_error)
|
||||
*min_error = err_min;
|
||||
return circle_best;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,3 +1,7 @@
|
|||
///|/ Copyright (c) Prusa Research 2021 - 2022 Lukáš Matěna @lukasmatena, Filip Sykala @Jony01, Vojtěch Bubník @bubnikv, Enrico Turri @enricoturri1966
|
||||
///|/
|
||||
///|/ PrusaSlicer is released under the terms of the AGPLv3 or higher
|
||||
///|/
|
||||
#ifndef slic3r_Geometry_Circle_hpp_
|
||||
#define slic3r_Geometry_Circle_hpp_
|
||||
|
||||
|
|
@ -102,7 +106,7 @@ inline Vec2d circle_center_taubin_newton(const Vec2ds& input, size_t cycles = 20
|
|||
Circled circle_taubin_newton(const Vec2ds& input, size_t cycles = 20);
|
||||
|
||||
// Find circle using RANSAC randomized algorithm.
|
||||
Circled circle_ransac(const Vec2ds& input, size_t iterations = 20);
|
||||
Circled circle_ransac(const Vec2ds& input, size_t iterations = 20, double* min_error = nullptr);
|
||||
|
||||
// Randomized algorithm by Emo Welzl, working with squared radii for efficiency. The returned circle radius is inflated by epsilon.
|
||||
template<typename Vector, typename Points>
|
||||
|
|
|
|||
1255
src/libslic3r/Measure.cpp
Normal file
1255
src/libslic3r/Measure.cpp
Normal file
File diff suppressed because it is too large
Load diff
200
src/libslic3r/Measure.hpp
Normal file
200
src/libslic3r/Measure.hpp
Normal file
|
|
@ -0,0 +1,200 @@
|
|||
///|/ Copyright (c) Prusa Research 2022 - 2023 Lukáš Matěna @lukasmatena, Enrico Turri @enricoturri1966, Vojtěch Bubník @bubnikv
|
||||
///|/
|
||||
///|/ PrusaSlicer is released under the terms of the AGPLv3 or higher
|
||||
///|/
|
||||
#ifndef Slic3r_Measure_hpp_
|
||||
#define Slic3r_Measure_hpp_
|
||||
|
||||
#include <optional>
|
||||
#include <memory>
|
||||
|
||||
#include "Point.hpp"
|
||||
|
||||
|
||||
struct indexed_triangle_set;
|
||||
|
||||
|
||||
|
||||
namespace Slic3r {
|
||||
|
||||
class TriangleMesh;
|
||||
|
||||
namespace Measure {
|
||||
|
||||
|
||||
enum class SurfaceFeatureType : int {
|
||||
Undef = 0,
|
||||
Point = 1 << 0,
|
||||
Edge = 1 << 1,
|
||||
Circle = 1 << 2,
|
||||
Plane = 1 << 3
|
||||
};
|
||||
|
||||
class SurfaceFeature {
|
||||
public:
|
||||
SurfaceFeature(SurfaceFeatureType type, const Vec3d& pt1, const Vec3d& pt2, std::optional<Vec3d> pt3 = std::nullopt, double value = 0.0)
|
||||
: m_type(type), m_pt1(pt1), m_pt2(pt2), m_pt3(pt3), m_value(value) {}
|
||||
|
||||
explicit SurfaceFeature(const Vec3d& pt)
|
||||
: m_type{SurfaceFeatureType::Point}, m_pt1{pt} {}
|
||||
|
||||
// Get type of this feature.
|
||||
SurfaceFeatureType get_type() const { return m_type; }
|
||||
|
||||
// For points, return the point.
|
||||
Vec3d get_point() const { assert(m_type == SurfaceFeatureType::Point); return m_pt1; }
|
||||
|
||||
// For edges, return start and end.
|
||||
std::pair<Vec3d, Vec3d> get_edge() const { assert(m_type == SurfaceFeatureType::Edge); return std::make_pair(m_pt1, m_pt2); }
|
||||
|
||||
// For circles, return center, radius and normal.
|
||||
std::tuple<Vec3d, double, Vec3d> get_circle() const { assert(m_type == SurfaceFeatureType::Circle); return std::make_tuple(m_pt1, m_value, m_pt2); }
|
||||
|
||||
// For planes, return index into vector provided by Measuring::get_plane_triangle_indices, normal and point.
|
||||
std::tuple<int, Vec3d, Vec3d> get_plane() const { assert(m_type == SurfaceFeatureType::Plane); return std::make_tuple(int(m_value), m_pt1, m_pt2); }
|
||||
|
||||
// For anything, return an extra point that should also be considered a part of this.
|
||||
std::optional<Vec3d> get_extra_point() const { assert(m_type != SurfaceFeatureType::Undef); return m_pt3; }
|
||||
|
||||
bool operator == (const SurfaceFeature& other) const {
|
||||
if (this->m_type != other.m_type) return false;
|
||||
switch (this->m_type)
|
||||
{
|
||||
case SurfaceFeatureType::Undef: { break; }
|
||||
case SurfaceFeatureType::Point: { return (this->m_pt1.isApprox(other.m_pt1)); }
|
||||
case SurfaceFeatureType::Edge: {
|
||||
return (this->m_pt1.isApprox(other.m_pt1) && this->m_pt2.isApprox(other.m_pt2)) ||
|
||||
(this->m_pt1.isApprox(other.m_pt2) && this->m_pt2.isApprox(other.m_pt1));
|
||||
}
|
||||
case SurfaceFeatureType::Plane:
|
||||
case SurfaceFeatureType::Circle: {
|
||||
return (this->m_pt1.isApprox(other.m_pt1) && this->m_pt2.isApprox(other.m_pt2) && std::abs(this->m_value - other.m_value) < EPSILON);
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool operator != (const SurfaceFeature& other) const {
|
||||
return !operator == (other);
|
||||
}
|
||||
|
||||
private:
|
||||
SurfaceFeatureType m_type{ SurfaceFeatureType::Undef };
|
||||
Vec3d m_pt1{ Vec3d::Zero() };
|
||||
Vec3d m_pt2{ Vec3d::Zero() };
|
||||
std::optional<Vec3d> m_pt3;
|
||||
double m_value{ 0.0 };
|
||||
};
|
||||
|
||||
|
||||
|
||||
class MeasuringImpl;
|
||||
|
||||
|
||||
class Measuring {
|
||||
public:
|
||||
// Construct the measurement object on a given its.
|
||||
explicit Measuring(const indexed_triangle_set& its);
|
||||
~Measuring();
|
||||
|
||||
|
||||
// Given a face_idx where the mouse cursor points, return a feature that
|
||||
// should be highlighted (if any).
|
||||
std::optional<SurfaceFeature> get_feature(size_t face_idx, const Vec3d& point) const;
|
||||
|
||||
// Return total number of planes.
|
||||
int get_num_of_planes() const;
|
||||
|
||||
// Returns a list of triangle indices for given plane.
|
||||
const std::vector<int>& get_plane_triangle_indices(int idx) const;
|
||||
|
||||
// Returns the surface features of the plane with the given index
|
||||
const std::vector<SurfaceFeature>& get_plane_features(unsigned int plane_id) const;
|
||||
|
||||
// Returns the mesh used for measuring
|
||||
const indexed_triangle_set& get_its() const;
|
||||
|
||||
private:
|
||||
std::unique_ptr<MeasuringImpl> priv;
|
||||
};
|
||||
|
||||
|
||||
struct DistAndPoints {
|
||||
DistAndPoints(double dist_, Vec3d from_, Vec3d to_) : dist(dist_), from(from_), to(to_) {}
|
||||
double dist;
|
||||
Vec3d from;
|
||||
Vec3d to;
|
||||
};
|
||||
|
||||
struct AngleAndEdges {
|
||||
AngleAndEdges(double angle_, const Vec3d& center_, const std::pair<Vec3d, Vec3d>& e1_, const std::pair<Vec3d, Vec3d>& e2_, double radius_, bool coplanar_)
|
||||
: angle(angle_), center(center_), e1(e1_), e2(e2_), radius(radius_), coplanar(coplanar_) {}
|
||||
double angle;
|
||||
Vec3d center;
|
||||
std::pair<Vec3d, Vec3d> e1;
|
||||
std::pair<Vec3d, Vec3d> e2;
|
||||
double radius;
|
||||
bool coplanar;
|
||||
|
||||
static const AngleAndEdges Dummy;
|
||||
};
|
||||
|
||||
struct MeasurementResult {
|
||||
std::optional<AngleAndEdges> angle;
|
||||
std::optional<DistAndPoints> distance_infinite;
|
||||
std::optional<DistAndPoints> distance_strict;
|
||||
std::optional<Vec3d> distance_xyz;
|
||||
|
||||
bool has_distance_data() const {
|
||||
return distance_infinite.has_value() || distance_strict.has_value();
|
||||
}
|
||||
|
||||
bool has_any_data() const {
|
||||
return angle.has_value() || distance_infinite.has_value() || distance_strict.has_value() || distance_xyz.has_value();
|
||||
}
|
||||
};
|
||||
|
||||
// Returns distance/angle between two SurfaceFeatures.
|
||||
MeasurementResult get_measurement(const SurfaceFeature& a, const SurfaceFeature& b, const Measuring* measuring = nullptr);
|
||||
|
||||
inline Vec3d edge_direction(const Vec3d& from, const Vec3d& to) { return (to - from).normalized(); }
|
||||
inline Vec3d edge_direction(const std::pair<Vec3d, Vec3d>& e) { return edge_direction(e.first, e.second); }
|
||||
inline Vec3d edge_direction(const SurfaceFeature& edge) {
|
||||
assert(edge.get_type() == SurfaceFeatureType::Edge);
|
||||
return edge_direction(edge.get_edge());
|
||||
}
|
||||
|
||||
inline Vec3d plane_normal(const SurfaceFeature& plane) {
|
||||
assert(plane.get_type() == SurfaceFeatureType::Plane);
|
||||
return std::get<1>(plane.get_plane());
|
||||
}
|
||||
|
||||
inline bool are_parallel(const Vec3d& v1, const Vec3d& v2) { return std::abs(std::abs(v1.dot(v2)) - 1.0) < EPSILON; }
|
||||
inline bool are_perpendicular(const Vec3d& v1, const Vec3d& v2) { return std::abs(v1.dot(v2)) < EPSILON; }
|
||||
|
||||
inline bool are_parallel(const std::pair<Vec3d, Vec3d>& e1, const std::pair<Vec3d, Vec3d>& e2) {
|
||||
return are_parallel(e1.second - e1.first, e2.second - e2.first);
|
||||
}
|
||||
inline bool are_parallel(const SurfaceFeature& f1, const SurfaceFeature& f2) {
|
||||
if (f1.get_type() == SurfaceFeatureType::Edge && f2.get_type() == SurfaceFeatureType::Edge)
|
||||
return are_parallel(edge_direction(f1), edge_direction(f2));
|
||||
else if (f1.get_type() == SurfaceFeatureType::Edge && f2.get_type() == SurfaceFeatureType::Plane)
|
||||
return are_perpendicular(edge_direction(f1), plane_normal(f2));
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
inline bool are_perpendicular(const SurfaceFeature& f1, const SurfaceFeature& f2) {
|
||||
if (f1.get_type() == SurfaceFeatureType::Edge && f2.get_type() == SurfaceFeatureType::Edge)
|
||||
return are_perpendicular(edge_direction(f1), edge_direction(f2));
|
||||
else if (f1.get_type() == SurfaceFeatureType::Edge && f2.get_type() == SurfaceFeatureType::Plane)
|
||||
return are_parallel(edge_direction(f1), plane_normal(f2));
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
} // namespace Measure
|
||||
} // namespace Slic3r
|
||||
|
||||
#endif // Slic3r_Measure_hpp_
|
||||
390
src/libslic3r/MeasureUtils.hpp
Normal file
390
src/libslic3r/MeasureUtils.hpp
Normal file
|
|
@ -0,0 +1,390 @@
|
|||
///|/ Copyright (c) Prusa Research 2022 Enrico Turri @enricoturri1966
|
||||
///|/
|
||||
///|/ PrusaSlicer is released under the terms of the AGPLv3 or higher
|
||||
///|/
|
||||
#ifndef Slic3r_MeasureUtils_hpp_
|
||||
#define Slic3r_MeasureUtils_hpp_
|
||||
|
||||
#include <initializer_list>
|
||||
|
||||
namespace Slic3r {
|
||||
namespace Measure {
|
||||
|
||||
// Utility class used to calculate distance circle-circle
|
||||
// Adaptation of code found in:
|
||||
// https://github.com/davideberly/GeometricTools/blob/master/GTE/Mathematics/Polynomial1.h
|
||||
|
||||
class Polynomial1
|
||||
{
|
||||
public:
|
||||
Polynomial1(std::initializer_list<double> values)
|
||||
{
|
||||
// C++ 11 will call the default constructor for
|
||||
// Polynomial1<Real> p{}, so it is guaranteed that
|
||||
// values.size() > 0.
|
||||
m_coefficient.resize(values.size());
|
||||
std::copy(values.begin(), values.end(), m_coefficient.begin());
|
||||
EliminateLeadingZeros();
|
||||
}
|
||||
|
||||
// Construction and destruction. The first constructor creates a
|
||||
// polynomial of the specified degree but sets all coefficients to
|
||||
// zero (to ensure initialization). You are responsible for setting
|
||||
// the coefficients, presumably with the degree-term set to a nonzero
|
||||
// number. In the second constructor, the degree is the number of
|
||||
// initializers plus 1, but then adjusted so that coefficient[degree]
|
||||
// is not zero (unless all initializer values are zero).
|
||||
explicit Polynomial1(uint32_t degree)
|
||||
: m_coefficient(static_cast<size_t>(degree) + 1, 0.0)
|
||||
{}
|
||||
|
||||
// Eliminate any leading zeros in the polynomial, except in the case
|
||||
// the degree is 0 and the coefficient is 0. The elimination is
|
||||
// necessary when arithmetic operations cause a decrease in the degree
|
||||
// of the result. For example, (1 + x + x^2) + (1 + 2*x - x^2) =
|
||||
// (2 + 3*x). The inputs both have degree 2, so the result is created
|
||||
// with degree 2. After the addition we find that the degree is in
|
||||
// fact 1 and resize the array of coefficients. This function is
|
||||
// called internally by the arithmetic operators, but it is exposed in
|
||||
// the public interface in case you need it for your own purposes.
|
||||
void EliminateLeadingZeros()
|
||||
{
|
||||
const size_t size = m_coefficient.size();
|
||||
if (size > 1) {
|
||||
const double zero = 0.0;
|
||||
int32_t leading;
|
||||
for (leading = static_cast<int32_t>(size) - 1; leading > 0; --leading) {
|
||||
if (m_coefficient[leading] != zero)
|
||||
break;
|
||||
}
|
||||
|
||||
m_coefficient.resize(++leading);
|
||||
}
|
||||
}
|
||||
|
||||
// Set all coefficients to the specified value.
|
||||
void SetCoefficients(double value)
|
||||
{
|
||||
std::fill(m_coefficient.begin(), m_coefficient.end(), value);
|
||||
}
|
||||
|
||||
inline uint32_t GetDegree() const
|
||||
{
|
||||
// By design, m_coefficient.size() > 0.
|
||||
return static_cast<uint32_t>(m_coefficient.size() - 1);
|
||||
}
|
||||
|
||||
inline const double& operator[](uint32_t i) const { return m_coefficient[i]; }
|
||||
inline double& operator[](uint32_t i) { return m_coefficient[i]; }
|
||||
|
||||
// Evaluate the polynomial. If the polynomial is invalid, the
|
||||
// function returns zero.
|
||||
double operator()(double t) const
|
||||
{
|
||||
int32_t i = static_cast<int32_t>(m_coefficient.size());
|
||||
double result = m_coefficient[--i];
|
||||
for (--i; i >= 0; --i) {
|
||||
result *= t;
|
||||
result += m_coefficient[i];
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
protected:
|
||||
// The class is designed so that m_coefficient.size() >= 1.
|
||||
std::vector<double> m_coefficient;
|
||||
};
|
||||
|
||||
inline Polynomial1 operator * (const Polynomial1& p0, const Polynomial1& p1)
|
||||
{
|
||||
const uint32_t p0Degree = p0.GetDegree();
|
||||
const uint32_t p1Degree = p1.GetDegree();
|
||||
Polynomial1 result(p0Degree + p1Degree);
|
||||
result.SetCoefficients(0.0);
|
||||
for (uint32_t i0 = 0; i0 <= p0Degree; ++i0) {
|
||||
for (uint32_t i1 = 0; i1 <= p1Degree; ++i1) {
|
||||
result[i0 + i1] += p0[i0] * p1[i1];
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
inline Polynomial1 operator + (const Polynomial1& p0, const Polynomial1& p1)
|
||||
{
|
||||
const uint32_t p0Degree = p0.GetDegree();
|
||||
const uint32_t p1Degree = p1.GetDegree();
|
||||
uint32_t i;
|
||||
if (p0Degree >= p1Degree) {
|
||||
Polynomial1 result(p0Degree);
|
||||
for (i = 0; i <= p1Degree; ++i) {
|
||||
result[i] = p0[i] + p1[i];
|
||||
}
|
||||
for (/**/; i <= p0Degree; ++i) {
|
||||
result[i] = p0[i];
|
||||
}
|
||||
result.EliminateLeadingZeros();
|
||||
return result;
|
||||
}
|
||||
else {
|
||||
Polynomial1 result(p1Degree);
|
||||
for (i = 0; i <= p0Degree; ++i) {
|
||||
result[i] = p0[i] + p1[i];
|
||||
}
|
||||
for (/**/; i <= p1Degree; ++i) {
|
||||
result[i] = p1[i];
|
||||
}
|
||||
result.EliminateLeadingZeros();
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
inline Polynomial1 operator - (const Polynomial1& p0, const Polynomial1& p1)
|
||||
{
|
||||
const uint32_t p0Degree = p0.GetDegree();
|
||||
const uint32_t p1Degree = p1.GetDegree();
|
||||
uint32_t i;
|
||||
if (p0Degree >= p1Degree) {
|
||||
Polynomial1 result(p0Degree);
|
||||
for (i = 0; i <= p1Degree; ++i) {
|
||||
result[i] = p0[i] - p1[i];
|
||||
}
|
||||
for (/**/; i <= p0Degree; ++i) {
|
||||
result[i] = p0[i];
|
||||
}
|
||||
result.EliminateLeadingZeros();
|
||||
return result;
|
||||
}
|
||||
else {
|
||||
Polynomial1 result(p1Degree);
|
||||
for (i = 0; i <= p0Degree; ++i) {
|
||||
result[i] = p0[i] - p1[i];
|
||||
}
|
||||
for (/**/; i <= p1Degree; ++i) {
|
||||
result[i] = -p1[i];
|
||||
}
|
||||
result.EliminateLeadingZeros();
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
inline Polynomial1 operator * (double scalar, const Polynomial1& p)
|
||||
{
|
||||
const uint32_t degree = p.GetDegree();
|
||||
Polynomial1 result(degree);
|
||||
for (uint32_t i = 0; i <= degree; ++i) {
|
||||
result[i] = scalar * p[i];
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
// Utility class used to calculate distance circle-circle
|
||||
// Adaptation of code found in:
|
||||
// https://github.com/davideberly/GeometricTools/blob/master/GTE/Mathematics/RootsPolynomial.h
|
||||
|
||||
class RootsPolynomial
|
||||
{
|
||||
public:
|
||||
// General equations: sum_{i=0}^{d} c(i)*t^i = 0. The input array 'c'
|
||||
// must have at least d+1 elements and the output array 'root' must
|
||||
// have at least d elements.
|
||||
|
||||
// Find the roots on (-infinity,+infinity).
|
||||
static int32_t Find(int32_t degree, const double* c, uint32_t maxIterations, double* roots)
|
||||
{
|
||||
if (degree >= 0 && c != nullptr) {
|
||||
const double zero = 0.0;
|
||||
while (degree >= 0 && c[degree] == zero) {
|
||||
--degree;
|
||||
}
|
||||
|
||||
if (degree > 0) {
|
||||
// Compute the Cauchy bound.
|
||||
const double one = 1.0;
|
||||
const double invLeading = one / c[degree];
|
||||
double maxValue = zero;
|
||||
for (int32_t i = 0; i < degree; ++i) {
|
||||
const double value = std::fabs(c[i] * invLeading);
|
||||
if (value > maxValue)
|
||||
maxValue = value;
|
||||
}
|
||||
const double bound = one + maxValue;
|
||||
|
||||
return FindRecursive(degree, c, -bound, bound, maxIterations, roots);
|
||||
}
|
||||
else if (degree == 0)
|
||||
// The polynomial is a nonzero constant.
|
||||
return 0;
|
||||
else {
|
||||
// The polynomial is identically zero.
|
||||
roots[0] = zero;
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
else
|
||||
// Invalid degree or c.
|
||||
return 0;
|
||||
}
|
||||
|
||||
// If you know that p(tmin) * p(tmax) <= 0, then there must be at
|
||||
// least one root in [tmin, tmax]. Compute it using bisection.
|
||||
static bool Find(int32_t degree, const double* c, double tmin, double tmax, uint32_t maxIterations, double& root)
|
||||
{
|
||||
const double zero = 0.0;
|
||||
double pmin = Evaluate(degree, c, tmin);
|
||||
if (pmin == zero) {
|
||||
root = tmin;
|
||||
return true;
|
||||
}
|
||||
double pmax = Evaluate(degree, c, tmax);
|
||||
if (pmax == zero) {
|
||||
root = tmax;
|
||||
return true;
|
||||
}
|
||||
|
||||
if (pmin * pmax > zero)
|
||||
// It is not known whether the interval bounds a root.
|
||||
return false;
|
||||
|
||||
if (tmin >= tmax)
|
||||
// Invalid ordering of interval endpoitns.
|
||||
return false;
|
||||
|
||||
for (uint32_t i = 1; i <= maxIterations; ++i) {
|
||||
root = 0.5 * (tmin + tmax);
|
||||
|
||||
// This test is designed for 'float' or 'double' when tmin
|
||||
// and tmax are consecutive floating-point numbers.
|
||||
if (root == tmin || root == tmax)
|
||||
break;
|
||||
|
||||
const double p = Evaluate(degree, c, root);
|
||||
const double product = p * pmin;
|
||||
if (product < zero) {
|
||||
tmax = root;
|
||||
pmax = p;
|
||||
}
|
||||
else if (product > zero) {
|
||||
tmin = root;
|
||||
pmin = p;
|
||||
}
|
||||
else
|
||||
break;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// Support for the Find functions.
|
||||
static int32_t FindRecursive(int32_t degree, double const* c, double tmin, double tmax, uint32_t maxIterations, double* roots)
|
||||
{
|
||||
// The base of the recursion.
|
||||
const double zero = 0.0;
|
||||
double root = zero;
|
||||
if (degree == 1) {
|
||||
int32_t numRoots;
|
||||
if (c[1] != zero) {
|
||||
root = -c[0] / c[1];
|
||||
numRoots = 1;
|
||||
}
|
||||
else if (c[0] == zero) {
|
||||
root = zero;
|
||||
numRoots = 1;
|
||||
}
|
||||
else
|
||||
numRoots = 0;
|
||||
|
||||
if (numRoots > 0 && tmin <= root && root <= tmax) {
|
||||
roots[0] = root;
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Find the roots of the derivative polynomial scaled by 1/degree.
|
||||
// The scaling avoids the factorial growth in the coefficients;
|
||||
// for example, without the scaling, the high-order term x^d
|
||||
// becomes (d!)*x through multiple differentiations. With the
|
||||
// scaling we instead get x. This leads to better numerical
|
||||
// behavior of the root finder.
|
||||
const int32_t derivDegree = degree - 1;
|
||||
std::vector<double> derivCoeff(static_cast<size_t>(derivDegree) + 1);
|
||||
std::vector<double> derivRoots(derivDegree);
|
||||
for (int32_t i = 0, ip1 = 1; i <= derivDegree; ++i, ++ip1) {
|
||||
derivCoeff[i] = c[ip1] * (double)(ip1) / (double)degree;
|
||||
}
|
||||
const int32_t numDerivRoots = FindRecursive(degree - 1, &derivCoeff[0], tmin, tmax, maxIterations, &derivRoots[0]);
|
||||
|
||||
int32_t numRoots = 0;
|
||||
if (numDerivRoots > 0) {
|
||||
// Find root on [tmin,derivRoots[0]].
|
||||
if (Find(degree, c, tmin, derivRoots[0], maxIterations, root))
|
||||
roots[numRoots++] = root;
|
||||
|
||||
// Find root on [derivRoots[i],derivRoots[i+1]].
|
||||
for (int32_t i = 0, ip1 = 1; i <= numDerivRoots - 2; ++i, ++ip1) {
|
||||
if (Find(degree, c, derivRoots[i], derivRoots[ip1], maxIterations, root))
|
||||
roots[numRoots++] = root;
|
||||
}
|
||||
|
||||
// Find root on [derivRoots[numDerivRoots-1],tmax].
|
||||
if (Find(degree, c, derivRoots[static_cast<size_t>(numDerivRoots) - 1], tmax, maxIterations, root))
|
||||
roots[numRoots++] = root;
|
||||
}
|
||||
else {
|
||||
// The polynomial is monotone on [tmin,tmax], so has at most one root.
|
||||
if (Find(degree, c, tmin, tmax, maxIterations, root))
|
||||
roots[numRoots++] = root;
|
||||
}
|
||||
return numRoots;
|
||||
}
|
||||
|
||||
static double Evaluate(int32_t degree, const double* c, double t)
|
||||
{
|
||||
int32_t i = degree;
|
||||
double result = c[i];
|
||||
while (--i >= 0) {
|
||||
result = t * result + c[i];
|
||||
}
|
||||
return result;
|
||||
}
|
||||
};
|
||||
|
||||
// Adaptation of code found in:
|
||||
// https://github.com/davideberly/GeometricTools/blob/master/GTE/Mathematics/Vector.h
|
||||
|
||||
// Construct a single vector orthogonal to the nonzero input vector. If
|
||||
// the maximum absolute component occurs at index i, then the orthogonal
|
||||
// vector U has u[i] = v[i+1], u[i+1] = -v[i], and all other components
|
||||
// zero. The index addition i+1 is computed modulo N.
|
||||
inline Vec3d get_orthogonal(const Vec3d& v, bool unitLength)
|
||||
{
|
||||
double cmax = std::fabs(v[0]);
|
||||
int32_t imax = 0;
|
||||
for (int32_t i = 1; i < 3; ++i) {
|
||||
double c = std::fabs(v[i]);
|
||||
if (c > cmax) {
|
||||
cmax = c;
|
||||
imax = i;
|
||||
}
|
||||
}
|
||||
|
||||
Vec3d result = Vec3d::Zero();
|
||||
int32_t inext = imax + 1;
|
||||
if (inext == 3)
|
||||
inext = 0;
|
||||
|
||||
result[imax] = v[inext];
|
||||
result[inext] = -v[imax];
|
||||
if (unitLength) {
|
||||
const double sqrDistance = result[imax] * result[imax] + result[inext] * result[inext];
|
||||
const double invLength = 1.0 / std::sqrt(sqrDistance);
|
||||
result[imax] *= invLength;
|
||||
result[inext] *= invLength;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
} // namespace Slic3r
|
||||
} // namespace Measure
|
||||
|
||||
#endif // Slic3r_MeasureUtils_hpp_
|
||||
|
|
@ -1,3 +1,16 @@
|
|||
///|/ Copyright (c) Prusa Research 2016 - 2023 Tomáš Mészáros @tamasmeszaros, Oleksandra Iushchenko @YuSanka, David Kocík @kocikdav, Enrico Turri @enricoturri1966, Lukáš Matěna @lukasmatena, Vojtěch Bubník @bubnikv, Lukáš Hejl @hejllukas, Filip Sykala @Jony01, Vojtěch Král @vojtechkral
|
||||
///|/ Copyright (c) 2021 Boleslaw Ciesielski
|
||||
///|/ Copyright (c) 2019 John Drake @foxox
|
||||
///|/ Copyright (c) 2019 Sijmen Schoon
|
||||
///|/ Copyright (c) Slic3r 2014 - 2016 Alessandro Ranellucci @alranel
|
||||
///|/ Copyright (c) 2015 Maksim Derbasov @ntfshard
|
||||
///|/
|
||||
///|/ ported from lib/Slic3r/Model.pm:
|
||||
///|/ Copyright (c) Prusa Research 2016 - 2022 Vojtěch Bubník @bubnikv, Enrico Turri @enricoturri1966
|
||||
///|/ Copyright (c) Slic3r 2012 - 2016 Alessandro Ranellucci @alranel
|
||||
///|/
|
||||
///|/ PrusaSlicer is released under the terms of the AGPLv3 or higher
|
||||
///|/
|
||||
#include "Model.hpp"
|
||||
#include "libslic3r.h"
|
||||
#include "BuildVolume.hpp"
|
||||
|
|
@ -1693,68 +1706,6 @@ bool ModelObject::has_connectors() const
|
|||
return false;
|
||||
}
|
||||
|
||||
indexed_triangle_set ModelObject::get_connector_mesh(CutConnectorAttributes connector_attributes)
|
||||
{
|
||||
indexed_triangle_set connector_mesh;
|
||||
|
||||
int sectorCount {1};
|
||||
switch (CutConnectorShape(connector_attributes.shape)) {
|
||||
case CutConnectorShape::Triangle:
|
||||
sectorCount = 3;
|
||||
break;
|
||||
case CutConnectorShape::Square:
|
||||
sectorCount = 4;
|
||||
break;
|
||||
case CutConnectorShape::Circle:
|
||||
sectorCount = 360;
|
||||
break;
|
||||
case CutConnectorShape::Hexagon:
|
||||
sectorCount = 6;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
if (connector_attributes.style == CutConnectorStyle::Prizm)
|
||||
connector_mesh = its_make_cylinder(1.0, 1.0, (2 * PI / sectorCount));
|
||||
else if (connector_attributes.type == CutConnectorType::Plug)
|
||||
connector_mesh = its_make_cone(1.0, 1.0, (2 * PI / sectorCount));
|
||||
else
|
||||
connector_mesh = its_make_frustum_dowel(1.0, 1.0, sectorCount);
|
||||
|
||||
return connector_mesh;
|
||||
}
|
||||
|
||||
void ModelObject::apply_cut_connectors(const std::string &name)
|
||||
{
|
||||
if (cut_connectors.empty())
|
||||
return;
|
||||
|
||||
using namespace Geometry;
|
||||
|
||||
size_t connector_id = cut_id.connectors_cnt();
|
||||
for (const CutConnector &connector : cut_connectors) {
|
||||
TriangleMesh mesh = TriangleMesh(get_connector_mesh(connector.attribs));
|
||||
// Mesh will be centered when loading.
|
||||
ModelVolume *new_volume = add_volume(std::move(mesh), ModelVolumeType::NEGATIVE_VOLUME);
|
||||
|
||||
Transform3d translate_transform = Transform3d::Identity();
|
||||
translate_transform.translate(connector.pos);
|
||||
Transform3d scale_transform = Transform3d::Identity();
|
||||
scale_transform.scale(Vec3f(connector.radius, connector.radius, connector.height).cast<double>());
|
||||
|
||||
// Transform the new modifier to be aligned inside the instance
|
||||
new_volume->set_transformation(translate_transform * connector.rotation_m * scale_transform);
|
||||
|
||||
new_volume->cut_info = {connector.attribs.type, connector.radius, connector.height, connector.radius_tolerance, connector.height_tolerance};
|
||||
new_volume->name = name + "-" + std::to_string(++connector_id);
|
||||
}
|
||||
cut_id.increase_connectors_cnt(cut_connectors.size());
|
||||
|
||||
// delete all connectors
|
||||
cut_connectors.clear();
|
||||
}
|
||||
|
||||
void ModelObject::invalidate_cut()
|
||||
{
|
||||
this->cut_id.invalidate();
|
||||
|
|
@ -1770,43 +1721,10 @@ void ModelObject::delete_connectors()
|
|||
}
|
||||
}
|
||||
|
||||
void ModelObject::synchronize_model_after_cut()
|
||||
{
|
||||
for (ModelObject *obj : m_model->objects) {
|
||||
if (obj == this || obj->cut_id.is_equal(this->cut_id)) continue;
|
||||
if (obj->is_cut() && obj->cut_id.has_same_id(this->cut_id))
|
||||
obj->cut_id.copy(this->cut_id);
|
||||
}
|
||||
}
|
||||
|
||||
void ModelObject::apply_cut_attributes(ModelObjectCutAttributes attributes)
|
||||
{
|
||||
// we don't save cut information, if result will not contains all parts of initial object
|
||||
if (!attributes.has(ModelObjectCutAttribute::KeepUpper) ||
|
||||
!attributes.has(ModelObjectCutAttribute::KeepLower) ||
|
||||
attributes.has(ModelObjectCutAttribute::InvalidateCutInfo))
|
||||
return;
|
||||
|
||||
if (cut_id.id().invalid())
|
||||
cut_id.init();
|
||||
|
||||
{
|
||||
int cut_obj_cnt = -1;
|
||||
if (attributes.has(ModelObjectCutAttribute::KeepUpper))
|
||||
cut_obj_cnt++;
|
||||
if (attributes.has(ModelObjectCutAttribute::KeepLower))
|
||||
cut_obj_cnt++;
|
||||
if (attributes.has(ModelObjectCutAttribute::CreateDowels))
|
||||
cut_obj_cnt++;
|
||||
if (cut_obj_cnt > 0)
|
||||
cut_id.increase_check_sum(size_t(cut_obj_cnt));
|
||||
}
|
||||
}
|
||||
|
||||
void ModelObject::clone_for_cut(ModelObject **obj)
|
||||
{
|
||||
(*obj) = ModelObject::new_clone(*this);
|
||||
(*obj)->set_model(nullptr);
|
||||
(*obj)->set_model(this->get_model());
|
||||
(*obj)->sla_support_points.clear();
|
||||
(*obj)->sla_drain_holes.clear();
|
||||
(*obj)->sla_points_status = sla::PointsStatus::NoPoints;
|
||||
|
|
@ -1814,189 +1732,11 @@ void ModelObject::clone_for_cut(ModelObject **obj)
|
|||
(*obj)->input_file.clear();
|
||||
}
|
||||
|
||||
Transform3d ModelObject::calculate_cut_plane_inverse_matrix(const std::array<Vec3d, 4>& plane_points)
|
||||
void ModelVolume::reset_extra_facets()
|
||||
{
|
||||
Vec3d mid_point = {0.0, 0.0, 0.0};
|
||||
for (auto pt : plane_points)
|
||||
mid_point += pt;
|
||||
mid_point /= (double) plane_points.size();
|
||||
|
||||
Vec3d movement = -mid_point;
|
||||
|
||||
Vec3d v01 = plane_points[1] - plane_points[0];
|
||||
Vec3d v12 = plane_points[2] - plane_points[1];
|
||||
|
||||
Vec3d plane_normal = v01.cross(v12);
|
||||
plane_normal.normalize();
|
||||
|
||||
Vec3d axis = {0.0, 0.0, 0.0};
|
||||
double phi = 0.0;
|
||||
Matrix3d matrix;
|
||||
matrix.setIdentity();
|
||||
Geometry::rotation_from_two_vectors(plane_normal, {0.0, 0.0, 1.0}, axis, phi, &matrix);
|
||||
Vec3d angles = Geometry::extract_euler_angles(matrix);
|
||||
|
||||
movement = matrix * movement;
|
||||
Transform3d transfo;
|
||||
transfo.setIdentity();
|
||||
transfo.translate(movement);
|
||||
transfo.rotate(Eigen::AngleAxisd(angles(2), Vec3d::UnitZ()) * Eigen::AngleAxisd(angles(1), Vec3d::UnitY()) * Eigen::AngleAxisd(angles(0), Vec3d::UnitX()));
|
||||
return transfo;
|
||||
}
|
||||
|
||||
void ModelObject::process_connector_cut(
|
||||
ModelVolume *volume,
|
||||
const Transform3d & instance_matrix,
|
||||
const Transform3d& cut_matrix,
|
||||
ModelObjectCutAttributes attributes,
|
||||
ModelObject *upper, ModelObject *lower,
|
||||
std::vector<ModelObject *> &dowels,
|
||||
Vec3d &local_dowels_displace)
|
||||
{
|
||||
assert(volume->cut_info.is_connector);
|
||||
volume->cut_info.set_processed();
|
||||
|
||||
const auto volume_matrix = volume->get_matrix();
|
||||
|
||||
// ! Don't apply instance transformation for the conntectors.
|
||||
// This transformation is already there
|
||||
if (volume->cut_info.connector_type != CutConnectorType::Dowel) {
|
||||
if (attributes.has(ModelObjectCutAttribute::KeepUpper)) {
|
||||
ModelVolume *vol = upper->add_volume(*volume);
|
||||
vol->set_transformation(volume_matrix);
|
||||
vol->apply_tolerance();
|
||||
}
|
||||
if (attributes.has(ModelObjectCutAttribute::KeepLower)) {
|
||||
ModelVolume *vol = lower->add_volume(*volume);
|
||||
vol->set_transformation(volume_matrix);
|
||||
// for lower part change type of connector from NEGATIVE_VOLUME to MODEL_PART if this connector is a plug
|
||||
vol->set_type(ModelVolumeType::MODEL_PART);
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (attributes.has(ModelObjectCutAttribute::CreateDowels)) {
|
||||
ModelObject *dowel{nullptr};
|
||||
// Clone the object to duplicate instances, materials etc.
|
||||
clone_for_cut(&dowel);
|
||||
|
||||
// add one more solid part same as connector if this connector is a dowel
|
||||
ModelVolume *vol = dowel->add_volume(*volume);
|
||||
vol->set_type(ModelVolumeType::MODEL_PART);
|
||||
|
||||
// But discard rotation and Z-offset for this volume
|
||||
vol->set_rotation(Vec3d::Zero());
|
||||
vol->set_offset(Z, 0.0);
|
||||
|
||||
// Compute the displacement (in instance coordinates) to be applied to place the dowels
|
||||
local_dowels_displace = lower->full_raw_mesh_bounding_box().size().cwiseProduct(Vec3d(1.0, 1.0, 0.0));
|
||||
|
||||
dowels.push_back(dowel);
|
||||
}
|
||||
|
||||
// Cut the dowel
|
||||
volume->apply_tolerance();
|
||||
|
||||
// Perform cut
|
||||
TriangleMesh upper_mesh, lower_mesh;
|
||||
process_volume_cut(volume, Transform3d::Identity(), cut_matrix, attributes, upper_mesh, lower_mesh);
|
||||
|
||||
// add small Z offset to better preview
|
||||
upper_mesh.translate((-0.05 * Vec3d::UnitZ()).cast<float>());
|
||||
lower_mesh.translate((0.05 * Vec3d::UnitZ()).cast<float>());
|
||||
|
||||
// Add cut parts to the related objects
|
||||
add_cut_volume(upper_mesh, upper, volume, cut_matrix, "_A", volume->type());
|
||||
add_cut_volume(lower_mesh, lower, volume, cut_matrix, "_B", volume->type());
|
||||
}
|
||||
}
|
||||
|
||||
void ModelObject::process_modifier_cut(
|
||||
ModelVolume *volume,
|
||||
const Transform3d &instance_matrix,
|
||||
const Transform3d &inverse_cut_matrix,
|
||||
ModelObjectCutAttributes attributes,
|
||||
ModelObject *upper,
|
||||
ModelObject *lower)
|
||||
{
|
||||
const auto volume_matrix = instance_matrix * volume->get_matrix();
|
||||
|
||||
// Modifiers are not cut, but we still need to add the instance transformation
|
||||
// to the modifier volume transformation to preserve their shape properly.
|
||||
volume->set_transformation(Geometry::Transformation(volume_matrix));
|
||||
|
||||
if (attributes.has(ModelObjectCutAttribute::CutToParts)) {
|
||||
upper->add_volume(*volume);
|
||||
return;
|
||||
}
|
||||
|
||||
// Some logic for the negative volumes/connectors. Add only needed modifiers
|
||||
auto bb = volume->mesh().transformed_bounding_box(inverse_cut_matrix * volume_matrix);
|
||||
bool is_crossed_by_cut = bb.min[Z] <= 0 && bb.max[Z] >= 0;
|
||||
if (attributes.has(ModelObjectCutAttribute::KeepUpper) && (bb.min[Z] >= 0 || is_crossed_by_cut))
|
||||
upper->add_volume(*volume);
|
||||
if (attributes.has(ModelObjectCutAttribute::KeepLower) && (bb.max[Z] <= 0 || is_crossed_by_cut))
|
||||
lower->add_volume(*volume);
|
||||
}
|
||||
|
||||
void ModelObject::process_volume_cut(ModelVolume * volume,
|
||||
const Transform3d & instance_matrix,
|
||||
const Transform3d & cut_matrix,
|
||||
ModelObjectCutAttributes attributes,
|
||||
TriangleMesh & upper_mesh,
|
||||
TriangleMesh & lower_mesh)
|
||||
{
|
||||
const auto volume_matrix = volume->get_matrix();
|
||||
|
||||
using namespace Geometry;
|
||||
|
||||
const Geometry::Transformation cut_transformation = Geometry::Transformation(cut_matrix);
|
||||
const Transform3d invert_cut_matrix = cut_transformation.get_matrix(true, false, true, true).inverse()
|
||||
* translation_transform(-1 * cut_transformation.get_offset());
|
||||
|
||||
// Transform the mesh by the combined transformation matrix.
|
||||
// Flip the triangles in case the composite transformation is left handed.
|
||||
TriangleMesh mesh(volume->mesh());
|
||||
mesh.transform(invert_cut_matrix * instance_matrix * volume_matrix, true);
|
||||
|
||||
indexed_triangle_set upper_its, lower_its;
|
||||
cut_mesh(mesh.its, 0.0f, &upper_its, &lower_its);
|
||||
if (attributes.has(ModelObjectCutAttribute::KeepUpper))
|
||||
upper_mesh = TriangleMesh(upper_its);
|
||||
if (attributes.has(ModelObjectCutAttribute::KeepLower))
|
||||
lower_mesh = TriangleMesh(lower_its);
|
||||
}
|
||||
|
||||
void ModelObject::process_solid_part_cut(ModelVolume * volume,
|
||||
const Transform3d & instance_matrix,
|
||||
const Transform3d & cut_matrix,
|
||||
const std::array<Vec3d, 4> &plane_points,
|
||||
ModelObjectCutAttributes attributes,
|
||||
ModelObject * upper,
|
||||
ModelObject * lower,
|
||||
Vec3d & local_displace)
|
||||
{
|
||||
// Perform cut
|
||||
TriangleMesh upper_mesh, lower_mesh;
|
||||
process_volume_cut(volume, instance_matrix, cut_matrix, attributes, upper_mesh, lower_mesh);
|
||||
|
||||
// Add required cut parts to the objects
|
||||
if (attributes.has(ModelObjectCutAttribute::CutToParts)) {
|
||||
add_cut_volume(upper_mesh, upper, volume, cut_matrix, "_A");
|
||||
add_cut_volume(lower_mesh, upper, volume, cut_matrix, "_B");
|
||||
return;
|
||||
}
|
||||
|
||||
if (attributes.has(ModelObjectCutAttribute::KeepUpper))
|
||||
add_cut_volume(upper_mesh, upper, volume, cut_matrix);
|
||||
|
||||
if (attributes.has(ModelObjectCutAttribute::KeepLower) && !lower_mesh.empty()) {
|
||||
add_cut_volume(lower_mesh, lower, volume, cut_matrix);
|
||||
|
||||
// Compute the displacement (in instance coordinates) to be applied to place the upper parts
|
||||
// The upper part displacement is set to half of the lower part bounding box
|
||||
// this is done in hope at least a part of the upper part will always be visible and draggable
|
||||
local_displace = lower->full_raw_mesh_bounding_box().size().cwiseProduct(Vec3d(-0.5, -0.5, 0.0));
|
||||
}
|
||||
this->supported_facets.reset();
|
||||
this->seam_facets.reset();
|
||||
this->mmu_segmentation_facets.reset();
|
||||
}
|
||||
|
||||
static void invalidate_translations(ModelObject* object, const ModelInstance* src_instance)
|
||||
|
|
@ -2073,215 +1813,6 @@ static void reset_instance_transformation(ModelObject* object, size_t src_instan
|
|||
}
|
||||
}
|
||||
|
||||
// BBS: replace z with plane_points
|
||||
ModelObjectPtrs ModelObject::cut(size_t instance, std::array<Vec3d, 4> plane_points, ModelObjectCutAttributes attributes)
|
||||
{
|
||||
if (! attributes.has(ModelObjectCutAttribute::KeepUpper) && ! attributes.has(ModelObjectCutAttribute::KeepLower))
|
||||
return {};
|
||||
|
||||
BOOST_LOG_TRIVIAL(trace) << "ModelObject::cut - start";
|
||||
|
||||
// apply cut attributes for object
|
||||
apply_cut_attributes(attributes);
|
||||
|
||||
ModelObject* upper{ nullptr };
|
||||
if (attributes.has(ModelObjectCutAttribute::KeepUpper))
|
||||
clone_for_cut(&upper);
|
||||
|
||||
ModelObject* lower{ nullptr };
|
||||
if (attributes.has(ModelObjectCutAttribute::KeepLower) && !attributes.has(ModelObjectCutAttribute::CutToParts))
|
||||
clone_for_cut(&lower);
|
||||
|
||||
// Because transformations are going to be applied to meshes directly,
|
||||
// we reset transformation of all instances and volumes,
|
||||
// except for translation and Z-rotation on instances, which are preserved
|
||||
// in the transformation matrix and not applied to the mesh transform.
|
||||
|
||||
// const auto instance_matrix = instances[instance]->get_matrix(true);
|
||||
const auto instance_matrix = Geometry::assemble_transform(
|
||||
Vec3d::Zero(), // don't apply offset
|
||||
instances[instance]->get_rotation().cwiseProduct(Vec3d(1.0, 1.0, 1.0)), // BBS: do apply Z-rotation
|
||||
instances[instance]->get_scaling_factor(),
|
||||
instances[instance]->get_mirror()
|
||||
);
|
||||
|
||||
// BBS
|
||||
//z -= instances[instance]->get_offset().z();
|
||||
for (Vec3d& point : plane_points) {
|
||||
point -= instances[instance]->get_offset();
|
||||
}
|
||||
Transform3d inverse_cut_matrix = calculate_cut_plane_inverse_matrix(plane_points);
|
||||
Transform3d cut_matrix = inverse_cut_matrix.inverse();
|
||||
|
||||
std::vector<ModelObject *> dowels;
|
||||
// Displacement (in instance coordinates) to be applied to place the upper parts
|
||||
Vec3d local_displace = Vec3d::Zero();
|
||||
Vec3d local_dowels_displace = Vec3d::Zero();
|
||||
|
||||
for (ModelVolume *volume : volumes) {
|
||||
const auto volume_matrix = volume->get_matrix();
|
||||
|
||||
volume->supported_facets.reset();
|
||||
volume->seam_facets.reset();
|
||||
volume->mmu_segmentation_facets.reset();
|
||||
|
||||
if (! volume->is_model_part()) {
|
||||
if (volume->cut_info.is_processed) {
|
||||
// Modifiers are not cut, but we still need to add the instance transformation
|
||||
// to the modifier volume transformation to preserve their shape properly.
|
||||
//Transform3d inverse_cut_matrix = calculate_cut_plane_inverse_matrix(plane_points);
|
||||
process_modifier_cut(volume, instance_matrix, inverse_cut_matrix, attributes, upper, lower);
|
||||
}
|
||||
else {
|
||||
process_connector_cut(volume, instance_matrix, cut_matrix, attributes, upper, lower, dowels, local_dowels_displace);
|
||||
}
|
||||
}
|
||||
else if (! volume->mesh().empty()) {
|
||||
process_solid_part_cut(volume, instance_matrix, cut_matrix, plane_points, attributes, upper, lower, local_displace);
|
||||
}
|
||||
}
|
||||
|
||||
ModelObjectPtrs res;
|
||||
|
||||
if (attributes.has(ModelObjectCutAttribute::CutToParts) && !upper->volumes.empty()) {
|
||||
reset_instance_transformation(upper, instance, cut_matrix);
|
||||
res.push_back(upper);
|
||||
}
|
||||
else {
|
||||
if (attributes.has(ModelObjectCutAttribute::KeepUpper) && upper->volumes.size() > 0) {
|
||||
reset_instance_transformation(upper, instance, cut_matrix, attributes.has(ModelObjectCutAttribute::PlaceOnCutUpper),
|
||||
attributes.has(ModelObjectCutAttribute::FlipUpper), local_displace);
|
||||
|
||||
res.push_back(upper);
|
||||
}
|
||||
if (attributes.has(ModelObjectCutAttribute::KeepLower) && lower->volumes.size() > 0) {
|
||||
reset_instance_transformation(lower, instance, cut_matrix, attributes.has(ModelObjectCutAttribute::PlaceOnCutLower),
|
||||
attributes.has(ModelObjectCutAttribute::PlaceOnCutLower) ? true : attributes.has(ModelObjectCutAttribute::FlipLower));
|
||||
|
||||
res.push_back(lower);
|
||||
}
|
||||
|
||||
if (attributes.has(ModelObjectCutAttribute::CreateDowels) && !dowels.empty()) {
|
||||
for (auto dowel : dowels) {
|
||||
reset_instance_transformation(dowel, instance, Transform3d::Identity(), false, false, local_dowels_displace);
|
||||
|
||||
local_dowels_displace += dowel->full_raw_mesh_bounding_box().size().cwiseProduct(Vec3d(-1.5, -1.5, 0.0));
|
||||
dowel->name += "-Dowel-" + dowel->volumes[0]->name;
|
||||
res.push_back(dowel);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
BOOST_LOG_TRIVIAL(trace) << "ModelObject::cut - end";
|
||||
|
||||
synchronize_model_after_cut();
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
// BBS
|
||||
ModelObjectPtrs ModelObject::segment(size_t instance, unsigned int max_extruders, double smoothing_alpha, int segment_number)
|
||||
{
|
||||
BOOST_LOG_TRIVIAL(trace) << "ModelObject::segment - start";
|
||||
|
||||
// Clone the object to duplicate instances, materials etc.
|
||||
ModelObject* upper = ModelObject::new_clone(*this);
|
||||
|
||||
upper->set_model(nullptr);
|
||||
upper->sla_support_points.clear();
|
||||
upper->sla_drain_holes.clear();
|
||||
upper->sla_points_status = sla::PointsStatus::NoPoints;
|
||||
upper->clear_volumes();
|
||||
upper->input_file.clear();
|
||||
|
||||
// Because transformations are going to be applied to meshes directly,
|
||||
// we reset transformation of all instances and volumes,
|
||||
// except for translation and Z-rotation on instances, which are preserved
|
||||
// in the transformation matrix and not applied to the mesh transform.
|
||||
|
||||
// const auto instance_matrix = instances[instance]->get_matrix(true);
|
||||
const auto instance_matrix = Geometry::assemble_transform(
|
||||
Vec3d::Zero(), // don't apply offset
|
||||
instances[instance]->get_rotation(), // BBS: keep Z-rotation
|
||||
instances[instance]->get_scaling_factor(),
|
||||
instances[instance]->get_mirror()
|
||||
);
|
||||
|
||||
for (ModelVolume* volume : volumes) {
|
||||
const auto volume_matrix = volume->get_matrix();
|
||||
|
||||
volume->supported_facets.reset();
|
||||
volume->seam_facets.reset();
|
||||
|
||||
if (!volume->is_model_part()) {
|
||||
// Modifiers are not cut, but we still need to add the instance transformation
|
||||
// to the modifier volume transformation to preserve their shape properly.
|
||||
volume->set_transformation(Geometry::Transformation(instance_matrix * volume_matrix));
|
||||
upper->add_volume(*volume);
|
||||
}
|
||||
else if (!volume->mesh().empty()) {
|
||||
// Transform the mesh by the combined transformation matrix.
|
||||
// Flip the triangles in case the composite transformation is left handed.
|
||||
TriangleMesh mesh(volume->mesh());
|
||||
mesh.transform(instance_matrix * volume_matrix, true);
|
||||
volume->reset_mesh();
|
||||
|
||||
auto mesh_segments = MeshBoolean::cgal::segment(mesh, smoothing_alpha, segment_number);
|
||||
|
||||
|
||||
// Reset volume transformation except for offset
|
||||
const Vec3d offset = volume->get_offset();
|
||||
volume->set_transformation(Geometry::Transformation());
|
||||
volume->set_offset(offset);
|
||||
|
||||
unsigned int extruder_counter = 0;
|
||||
for (int idx=0;idx<mesh_segments.size();idx++)
|
||||
{
|
||||
auto& mesh_segment = mesh_segments[idx];
|
||||
|
||||
if (mesh_segment.facets_count() > 0) {
|
||||
ModelVolume* vol = upper->add_volume(mesh_segment);
|
||||
vol->name = volume->name.substr(0, volume->name.find_last_of('.')) + "_" + std::to_string(idx);
|
||||
// Don't copy the config's ID.
|
||||
vol->config.assign_config(volume->config);
|
||||
#if 0
|
||||
assert(vol->config.id().valid());
|
||||
assert(vol->config.id() != volume->config.id());
|
||||
vol->set_material(volume->material_id(), *volume->material());
|
||||
#else
|
||||
vol->config.set("extruder", auto_extruder_id(max_extruders, extruder_counter));
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ModelObjectPtrs res;
|
||||
|
||||
if (upper->volumes.size() > 0) {
|
||||
upper->invalidate_bounding_box();
|
||||
|
||||
// Reset instance transformation except offset and Z-rotation
|
||||
for (size_t i = 0; i < instances.size(); i++) {
|
||||
auto& instance = upper->instances[i];
|
||||
const Vec3d offset = instance->get_offset();
|
||||
// BBS
|
||||
//const double rot_z = instance->get_rotation()(2);
|
||||
|
||||
instance->set_transformation(Geometry::Transformation());
|
||||
instance->set_offset(offset);
|
||||
// BBS
|
||||
//instance->set_rotation(Vec3d(0.0, 0.0, rot_z));
|
||||
}
|
||||
|
||||
res.push_back(upper);
|
||||
}
|
||||
|
||||
BOOST_LOG_TRIVIAL(trace) << "ModelObject::segment - end";
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
void ModelObject::split(ModelObjectPtrs* new_objects)
|
||||
{
|
||||
std::vector<TriangleMesh> all_meshes;
|
||||
|
|
@ -2758,6 +2289,14 @@ int ModelObject::get_repaired_errors_count(const int vol_idx /*= -1*/) const
|
|||
stats.facets_reversed + stats.backwards_edges;
|
||||
}
|
||||
|
||||
bool ModelObject::has_solid_mesh() const
|
||||
{
|
||||
for (const ModelVolume* volume : volumes)
|
||||
if (volume->is_model_part())
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
void ModelVolume::set_material_id(t_model_material_id material_id)
|
||||
{
|
||||
m_material_id = material_id;
|
||||
|
|
@ -2801,35 +2340,6 @@ bool ModelVolume::is_splittable() const
|
|||
return m_is_splittable == 1;
|
||||
}
|
||||
|
||||
void ModelVolume::apply_tolerance()
|
||||
{
|
||||
assert(cut_info.is_connector);
|
||||
if (!cut_info.is_processed)
|
||||
return;
|
||||
|
||||
Vec3d sf = get_scaling_factor();
|
||||
// make a "hole" wider
|
||||
double size_scale = 1.f;
|
||||
if (abs(cut_info.radius - 0) < EPSILON) // For compatibility with old files
|
||||
size_scale = 1.f + double(cut_info.radius_tolerance);
|
||||
else
|
||||
size_scale = (double(cut_info.radius) + double(cut_info.radius_tolerance)) / double(cut_info.radius);
|
||||
|
||||
sf[X] *= size_scale;
|
||||
sf[Y] *= size_scale;
|
||||
|
||||
// make a "hole" dipper
|
||||
double height_scale = 1.f;
|
||||
if (abs(cut_info.height - 0) < EPSILON) // For compatibility with old files
|
||||
height_scale = 1.f + double(cut_info.height_tolerance);
|
||||
else
|
||||
height_scale = (double(cut_info.height) + double(cut_info.height_tolerance)) / double(cut_info.height);
|
||||
|
||||
sf[Z] *= height_scale;
|
||||
|
||||
set_scaling_factor(sf);
|
||||
}
|
||||
|
||||
// BBS
|
||||
std::vector<int> ModelVolume::get_extruders() const
|
||||
{
|
||||
|
|
|
|||
|
|
@ -246,79 +246,92 @@ private:
|
|||
};
|
||||
|
||||
enum class CutConnectorType : int {
|
||||
Plug,
|
||||
Dowel,
|
||||
Undef
|
||||
Plug
|
||||
, Dowel
|
||||
, Snap
|
||||
, Undef
|
||||
};
|
||||
|
||||
enum class CutConnectorStyle : int {
|
||||
Prizm,
|
||||
Frustum,
|
||||
Undef
|
||||
Prism
|
||||
, Frustum
|
||||
, Undef
|
||||
//,Claw
|
||||
};
|
||||
|
||||
enum class CutConnectorShape : int {
|
||||
Triangle,
|
||||
Square,
|
||||
Hexagon,
|
||||
Circle,
|
||||
Undef
|
||||
Triangle
|
||||
, Square
|
||||
, Hexagon
|
||||
, Circle
|
||||
, Undef
|
||||
//,D-shape
|
||||
};
|
||||
|
||||
struct CutConnectorAttributes
|
||||
{
|
||||
CutConnectorType type{CutConnectorType::Plug};
|
||||
CutConnectorStyle style{CutConnectorStyle::Prizm};
|
||||
CutConnectorShape shape{CutConnectorShape::Circle};
|
||||
CutConnectorType type{ CutConnectorType::Plug };
|
||||
CutConnectorStyle style{ CutConnectorStyle::Prism };
|
||||
CutConnectorShape shape{ CutConnectorShape::Circle };
|
||||
|
||||
CutConnectorAttributes() {}
|
||||
|
||||
CutConnectorAttributes(CutConnectorType t, CutConnectorStyle st, CutConnectorShape sh) : type(t), style(st), shape(sh) {}
|
||||
CutConnectorAttributes(CutConnectorType t, CutConnectorStyle st, CutConnectorShape sh)
|
||||
: type(t), style(st), shape(sh)
|
||||
{}
|
||||
|
||||
CutConnectorAttributes(const CutConnectorAttributes &rhs) : CutConnectorAttributes(rhs.type, rhs.style, rhs.shape) {}
|
||||
CutConnectorAttributes(const CutConnectorAttributes& rhs) :
|
||||
CutConnectorAttributes(rhs.type, rhs.style, rhs.shape) {}
|
||||
|
||||
bool operator==(const CutConnectorAttributes &other) const;
|
||||
bool operator==(const CutConnectorAttributes& other) const;
|
||||
|
||||
bool operator!=(const CutConnectorAttributes &other) const { return !(other == (*this)); }
|
||||
bool operator!=(const CutConnectorAttributes& other) const { return !(other == (*this)); }
|
||||
|
||||
bool operator<(const CutConnectorAttributes &other) const
|
||||
{
|
||||
return this->type < other.type || (this->type == other.type && this->style < other.style) ||
|
||||
(this->type == other.type && this->style == other.style && this->shape < other.shape);
|
||||
bool operator<(const CutConnectorAttributes& other) const {
|
||||
return this->type < other.type ||
|
||||
(this->type == other.type && this->style < other.style) ||
|
||||
(this->type == other.type && this->style == other.style && this->shape < other.shape);
|
||||
}
|
||||
|
||||
template<class Archive> inline void serialize(Archive &ar) { ar(type, style, shape); }
|
||||
template<class Archive> inline void serialize(Archive& ar) {
|
||||
ar(type, style, shape);
|
||||
}
|
||||
};
|
||||
|
||||
struct CutConnector
|
||||
{
|
||||
Vec3d pos;
|
||||
Transform3d rotation_m;
|
||||
float radius;
|
||||
float height;
|
||||
float radius_tolerance; // [0.f : 1.f]
|
||||
float height_tolerance; // [0.f : 1.f]
|
||||
Vec3d pos;
|
||||
Transform3d rotation_m;
|
||||
float radius;
|
||||
float height;
|
||||
float radius_tolerance;// [0.f : 1.f]
|
||||
float height_tolerance;// [0.f : 1.f]
|
||||
float z_angle {0.f};
|
||||
CutConnectorAttributes attribs;
|
||||
|
||||
CutConnector() : pos(Vec3d::Zero()), rotation_m(Transform3d::Identity()), radius(5.f), height(10.f), radius_tolerance(0.f), height_tolerance(0.1f) {}
|
||||
|
||||
CutConnector(Vec3d p, Transform3d rot, float r, float h, float rt, float ht, CutConnectorAttributes attributes)
|
||||
: pos(p), rotation_m(rot), radius(r), height(h), radius_tolerance(rt), height_tolerance(ht), attribs(attributes)
|
||||
CutConnector()
|
||||
: pos(Vec3d::Zero()), rotation_m(Transform3d::Identity()), radius(5.f), height(10.f), radius_tolerance(0.f), height_tolerance(0.1f), z_angle(0.f)
|
||||
{}
|
||||
|
||||
CutConnector(const CutConnector &rhs) : CutConnector(rhs.pos, rhs.rotation_m, rhs.radius, rhs.height, rhs.radius_tolerance, rhs.height_tolerance, rhs.attribs) {}
|
||||
CutConnector(Vec3d p, Transform3d rot, float r, float h, float rt, float ht, float za, CutConnectorAttributes attributes)
|
||||
: pos(p), rotation_m(rot), radius(r), height(h), radius_tolerance(rt), height_tolerance(ht), z_angle(za), attribs(attributes)
|
||||
{}
|
||||
|
||||
bool operator==(const CutConnector &other) const;
|
||||
CutConnector(const CutConnector& rhs) :
|
||||
CutConnector(rhs.pos, rhs.rotation_m, rhs.radius, rhs.height, rhs.radius_tolerance, rhs.height_tolerance, rhs.z_angle, rhs.attribs) {}
|
||||
|
||||
bool operator!=(const CutConnector &other) const { return !(other == (*this)); }
|
||||
bool operator==(const CutConnector& other) const;
|
||||
|
||||
template<class Archive> inline void serialize(Archive &ar) { ar(pos, rotation_m, radius, height, radius_tolerance, height_tolerance, attribs); }
|
||||
bool operator!=(const CutConnector& other) const { return !(other == (*this)); }
|
||||
|
||||
template<class Archive> inline void serialize(Archive& ar) {
|
||||
ar(pos, rotation_m, radius, height, radius_tolerance, height_tolerance, z_angle, attribs);
|
||||
}
|
||||
};
|
||||
|
||||
using CutConnectors = std::vector<CutConnector>;
|
||||
|
||||
|
||||
// Declared outside of ModelVolume, so it could be forward declared.
|
||||
enum class ModelVolumeType : int {
|
||||
INVALID = -1,
|
||||
|
|
@ -326,13 +339,9 @@ enum class ModelVolumeType : int {
|
|||
NEGATIVE_VOLUME,
|
||||
PARAMETER_MODIFIER,
|
||||
SUPPORT_BLOCKER,
|
||||
SUPPORT_ENFORCER
|
||||
SUPPORT_ENFORCER,
|
||||
};
|
||||
|
||||
enum class ModelObjectCutAttribute : int { KeepUpper, KeepLower, FlipUpper, FlipLower, PlaceOnCutUpper, PlaceOnCutLower, CreateDowels, CutToParts, InvalidateCutInfo };
|
||||
using ModelObjectCutAttributes = enum_bitmask<ModelObjectCutAttribute>;
|
||||
ENABLE_ENUM_BITMASK_OPERATORS(ModelObjectCutAttribute);
|
||||
|
||||
// A printable object, possibly having multiple print volumes (each with its own set of parameters and materials),
|
||||
// and possibly having multiple modifier volumes, each modifier volume with its set of parameters and materials.
|
||||
// Each ModelObject may be instantiated mutliple times, each instance having different placement on the print bed,
|
||||
|
|
@ -371,6 +380,10 @@ public:
|
|||
// Holes to be drilled into the object so resin can flow out
|
||||
sla::DrainHoles sla_drain_holes;
|
||||
|
||||
// Connectors to be added into the object before cut and are used to create a solid/negative volumes during a cut perform
|
||||
CutConnectors cut_connectors;
|
||||
CutObjectBase cut_id;
|
||||
|
||||
/* This vector accumulates the total translation applied to the object by the
|
||||
center_around_origin() method. Callers might want to apply the same translation
|
||||
to new volumes before adding them to this object in order to preserve alignment
|
||||
|
|
@ -380,10 +393,6 @@ public:
|
|||
// BBS: save for compare with new load volumes
|
||||
std::vector<ObjectID> volume_ids;
|
||||
|
||||
// Connectors to be added into the object before cut and are used to create a solid/negative volumes during a cut perform
|
||||
CutConnectors cut_connectors;
|
||||
CutObjectBase cut_id;
|
||||
|
||||
Model* get_model() { return m_model; }
|
||||
const Model* get_model() const { return m_model; }
|
||||
// BBS: production extension
|
||||
|
|
@ -480,52 +489,13 @@ public:
|
|||
size_t materials_count() const;
|
||||
size_t facets_count() const;
|
||||
size_t parts_count() const;
|
||||
|
||||
bool is_cut() const { return cut_id.id().valid(); }
|
||||
bool has_connectors() const;
|
||||
static indexed_triangle_set get_connector_mesh(CutConnectorAttributes connector_attributes);
|
||||
void apply_cut_connectors(const std::string &name);
|
||||
// invalidate cut state for this object and its connectors/volumes
|
||||
void invalidate_cut();
|
||||
// delete volumes which are marked as connector for this object
|
||||
void delete_connectors();
|
||||
void synchronize_model_after_cut();
|
||||
void apply_cut_attributes(ModelObjectCutAttributes attributes);
|
||||
void clone_for_cut(ModelObject **obj);
|
||||
Transform3d calculate_cut_plane_inverse_matrix(const std::array<Vec3d, 4> &plane_points);
|
||||
void process_connector_cut(ModelVolume *volume,
|
||||
const Transform3d & instance_matrix,
|
||||
const Transform3d& cut_matrix,
|
||||
ModelObjectCutAttributes attributes,
|
||||
ModelObject *upper, ModelObject *lower,
|
||||
std::vector<ModelObject *> &dowels,
|
||||
Vec3d &local_dowels_displace);
|
||||
void process_modifier_cut(ModelVolume * volume,
|
||||
const Transform3d & instance_matrix,
|
||||
const Transform3d & inverse_cut_matrix,
|
||||
ModelObjectCutAttributes attributes,
|
||||
ModelObject * upper,
|
||||
ModelObject * lower);
|
||||
void process_volume_cut(ModelVolume * volume,
|
||||
const Transform3d & instance_matrix,
|
||||
const Transform3d & cut_matrix,
|
||||
ModelObjectCutAttributes attributes,
|
||||
TriangleMesh & upper_mesh,
|
||||
TriangleMesh & lower_mesh);
|
||||
void process_solid_part_cut(ModelVolume * volume,
|
||||
const Transform3d & instance_matrix,
|
||||
const Transform3d & cut_matrix,
|
||||
const std::array<Vec3d, 4> &plane_points,
|
||||
ModelObjectCutAttributes attributes,
|
||||
ModelObject * upper,
|
||||
ModelObject * lower,
|
||||
Vec3d & local_displace);
|
||||
|
||||
// BBS: replace z with plane_points
|
||||
ModelObjectPtrs cut(size_t instance, std::array<Vec3d, 4> plane_points, ModelObjectCutAttributes attributes);
|
||||
// BBS
|
||||
ModelObjectPtrs segment(size_t instance, unsigned int max_extruders, double smoothing_alpha = 0.5, int segment_number = 5);
|
||||
void split(ModelObjectPtrs* new_objects);
|
||||
void split(ModelObjectPtrs*new_objects);
|
||||
void merge();
|
||||
|
||||
// BBS: Boolean opts - Musang King
|
||||
|
|
@ -553,6 +523,10 @@ public:
|
|||
// Get count of errors in the mesh( or all object's meshes, if volume index isn't defined)
|
||||
int get_repaired_errors_count(const int vol_idx = -1) const;
|
||||
|
||||
// Detect if object has at least one solid mash
|
||||
bool has_solid_mesh() const;
|
||||
bool is_cut() const { return cut_id.id().valid(); }
|
||||
bool has_connectors() const;
|
||||
private:
|
||||
friend class Model;
|
||||
// This constructor assigns new ID to this ModelObject and its config.
|
||||
|
|
@ -853,37 +827,45 @@ public:
|
|||
};
|
||||
Source source;
|
||||
|
||||
// struct used by cut command
|
||||
// struct used by cut command
|
||||
// It contains information about connetors
|
||||
struct CutInfo
|
||||
{
|
||||
bool is_connector{false};
|
||||
bool is_processed{true};
|
||||
CutConnectorType connector_type{CutConnectorType::Plug};
|
||||
float radius{0.f};
|
||||
float height{0.f};
|
||||
float radius_tolerance{0.f}; // [0.f : 1.f]
|
||||
float height_tolerance{0.f}; // [0.f : 1.f]
|
||||
bool is_from_upper{ true };
|
||||
bool is_connector{ false };
|
||||
bool is_processed{ true };
|
||||
CutConnectorType connector_type{ CutConnectorType::Plug };
|
||||
float radius_tolerance{ 0.f };// [0.f : 1.f]
|
||||
float height_tolerance{ 0.f };// [0.f : 1.f]
|
||||
|
||||
CutInfo() = default;
|
||||
CutInfo(CutConnectorType type, float radius_, float height_, float rad_tolerance, float h_tolerance, bool processed = false)
|
||||
: is_connector(true), is_processed(processed), connector_type(type)
|
||||
, radius(radius_), height(height_), radius_tolerance(rad_tolerance), height_tolerance(h_tolerance)
|
||||
CutInfo(CutConnectorType type, float rad_tolerance, float h_tolerance, bool processed = false) :
|
||||
is_connector(true),
|
||||
is_processed(processed),
|
||||
connector_type(type),
|
||||
radius_tolerance(rad_tolerance),
|
||||
height_tolerance(h_tolerance)
|
||||
{}
|
||||
|
||||
void set_processed() { is_processed = true; }
|
||||
void invalidate() { is_connector = false; }
|
||||
void invalidate() { is_connector = false; }
|
||||
void reset_from_upper() { is_from_upper = true; }
|
||||
|
||||
template<class Archive> inline void serialize(Archive &ar) { ar(is_connector, is_processed, connector_type, radius_tolerance, height_tolerance); }
|
||||
template<class Archive> inline void serialize(Archive& ar) {
|
||||
ar(is_connector, is_processed, connector_type, radius_tolerance, height_tolerance);
|
||||
}
|
||||
};
|
||||
CutInfo cut_info;
|
||||
CutInfo cut_info;
|
||||
|
||||
bool is_cut_connector() const { return cut_info.is_processed && cut_info.is_connector; }
|
||||
void invalidate_cut_info() { cut_info.invalidate(); }
|
||||
bool is_from_upper() const { return cut_info.is_from_upper; }
|
||||
void reset_from_upper() { cut_info.reset_from_upper(); }
|
||||
|
||||
bool is_cut_connector() const { return cut_info.is_processed && cut_info.is_connector; }
|
||||
void invalidate_cut_info() { cut_info.invalidate(); }
|
||||
|
||||
// The triangular model.
|
||||
const TriangleMesh& mesh() const { return *m_mesh.get(); }
|
||||
const TriangleMesh* mesh_ptr() const { return m_mesh.get(); }
|
||||
std::shared_ptr<const TriangleMesh> mesh_ptr() const { return m_mesh; }
|
||||
void set_mesh(const TriangleMesh &mesh) { m_mesh = std::make_shared<const TriangleMesh>(mesh); }
|
||||
void set_mesh(TriangleMesh &&mesh) { m_mesh = std::make_shared<const TriangleMesh>(std::move(mesh)); }
|
||||
void set_mesh(const indexed_triangle_set &mesh) { m_mesh = std::make_shared<const TriangleMesh>(mesh); }
|
||||
|
|
@ -922,6 +904,7 @@ public:
|
|||
bool is_support_blocker() const { return m_type == ModelVolumeType::SUPPORT_BLOCKER; }
|
||||
bool is_support_modifier() const { return m_type == ModelVolumeType::SUPPORT_BLOCKER || m_type == ModelVolumeType::SUPPORT_ENFORCER; }
|
||||
t_model_material_id material_id() const { return m_material_id; }
|
||||
void reset_extra_facets();
|
||||
void set_material_id(t_model_material_id material_id);
|
||||
ModelMaterial* material() const;
|
||||
void set_material(t_model_material_id material_id, const ModelMaterial &material);
|
||||
|
|
@ -931,8 +914,6 @@ public:
|
|||
|
||||
bool is_splittable() const;
|
||||
|
||||
void apply_tolerance();
|
||||
|
||||
// BBS
|
||||
std::vector<int> get_extruders() const;
|
||||
void update_extruder_count(size_t extruder_count);
|
||||
|
|
|
|||
|
|
@ -1404,7 +1404,7 @@ void PerimeterGenerator::apply_extra_perimeters(ExPolygons &infill_area)
|
|||
}
|
||||
|
||||
// Reorient loop direction
|
||||
static void reorient_perimeters(ExtrusionEntityCollection &entities, bool steep_overhang_contour, bool steep_overhang_hole)
|
||||
static void reorient_perimeters(ExtrusionEntityCollection &entities, bool steep_overhang_contour, bool steep_overhang_hole, bool reverse_internal_only)
|
||||
{
|
||||
if (steep_overhang_hole || steep_overhang_contour) {
|
||||
for (auto entity : entities) {
|
||||
|
|
@ -1412,7 +1412,18 @@ static void reorient_perimeters(ExtrusionEntityCollection &entities, bool steep_
|
|||
ExtrusionLoop *eloop = static_cast<ExtrusionLoop *>(entity);
|
||||
// Only reverse when needed
|
||||
bool need_reverse = ((eloop->loop_role() & elrHole) == elrHole) ? steep_overhang_hole : steep_overhang_contour;
|
||||
if (need_reverse) {
|
||||
|
||||
bool isExternal = false;
|
||||
if(reverse_internal_only){
|
||||
for(auto path : eloop->paths){
|
||||
if(path.role() == erExternalPerimeter){
|
||||
isExternal = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (need_reverse && !isExternal) {
|
||||
eloop->make_clockwise();
|
||||
}
|
||||
}
|
||||
|
|
@ -1710,7 +1721,7 @@ void PerimeterGenerator::process_classic()
|
|||
bool steep_overhang_contour = false;
|
||||
bool steep_overhang_hole = false;
|
||||
ExtrusionEntityCollection entities = traverse_loops(*this, contours.front(), thin_walls, steep_overhang_contour, steep_overhang_hole);
|
||||
reorient_perimeters(entities, steep_overhang_contour, steep_overhang_hole);
|
||||
reorient_perimeters(entities, steep_overhang_contour, steep_overhang_hole, this->config->overhang_reverse_internal_only);
|
||||
|
||||
// if brim will be printed, reverse the order of perimeters so that
|
||||
// we continue inwards after having finished the brim
|
||||
|
|
@ -2232,7 +2243,7 @@ void PerimeterGenerator::process_arachne()
|
|||
bool steep_overhang_contour = false;
|
||||
bool steep_overhang_hole = false;
|
||||
if (ExtrusionEntityCollection extrusion_coll = traverse_extrusions(*this, ordered_extrusions, steep_overhang_contour, steep_overhang_hole); !extrusion_coll.empty()) {
|
||||
reorient_perimeters(extrusion_coll, steep_overhang_contour, steep_overhang_hole);
|
||||
reorient_perimeters(extrusion_coll, steep_overhang_contour, steep_overhang_hole, this->config->overhang_reverse_internal_only);
|
||||
this->loops->append(extrusion_coll);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -55,7 +55,7 @@ using Vec2f = Eigen::Matrix<float, 2, 1, Eigen::DontAlign>;
|
|||
using Vec3f = Eigen::Matrix<float, 3, 1, Eigen::DontAlign>;
|
||||
using Vec2d = Eigen::Matrix<double, 2, 1, Eigen::DontAlign>;
|
||||
using Vec3d = Eigen::Matrix<double, 3, 1, Eigen::DontAlign>;
|
||||
// BBS
|
||||
using Vec4f = Eigen::Matrix<float, 4, 1, Eigen::DontAlign>;
|
||||
using Vec4d = Eigen::Matrix<double, 4, 1, Eigen::DontAlign>;
|
||||
|
||||
using Points = std::vector<Point>;
|
||||
|
|
|
|||
|
|
@ -726,7 +726,7 @@ bool Preset::has_cali_lines(PresetBundle* preset_bundle)
|
|||
static std::vector<std::string> s_Preset_print_options {
|
||||
"layer_height", "initial_layer_print_height", "wall_loops", "slice_closing_radius", "spiral_mode", "slicing_mode",
|
||||
"top_shell_layers", "top_shell_thickness", "bottom_shell_layers", "bottom_shell_thickness",
|
||||
"extra_perimeters_on_overhangs", "ensure_vertical_shell_thickness", "reduce_crossing_wall", "detect_thin_wall", "detect_overhang_wall", "overhang_reverse", "overhang_reverse_threshold",
|
||||
"extra_perimeters_on_overhangs", "ensure_vertical_shell_thickness", "reduce_crossing_wall", "detect_thin_wall", "detect_overhang_wall", "overhang_reverse", "overhang_reverse_threshold","overhang_reverse_internal_only",
|
||||
"seam_position", "staggered_inner_seams", "wall_infill_order", "sparse_infill_density", "sparse_infill_pattern", "top_surface_pattern", "bottom_surface_pattern",
|
||||
"infill_direction",
|
||||
"minimum_sparse_infill_area", "reduce_infill_retraction","internal_solid_infill_pattern",
|
||||
|
|
|
|||
|
|
@ -840,7 +840,15 @@ void PrintConfigDef::init_fff_params()
|
|||
def->label = L("Reverse on odd");
|
||||
def->full_label = L("Overhang reversal");
|
||||
def->category = L("Quality");
|
||||
def->tooltip = L("Extrude perimeters that have a part over an overhang in the reverse direction on odd layers. This alternating pattern can drastically improve steep overhang.");
|
||||
def->tooltip = L("Extrude perimeters that have a part over an overhang in the reverse direction on odd layers. This alternating pattern can drastically improve steep overhangs.\n\nThis setting can also help reduce part warping due to the reduction of stresses in the part walls.");
|
||||
def->mode = comAdvanced;
|
||||
def->set_default_value(new ConfigOptionBool(false));
|
||||
|
||||
def = this->add("overhang_reverse_internal_only", coBool);
|
||||
def->label = L("Reverse only internal perimeters");
|
||||
def->full_label = L("Reverse only internal perimeters");
|
||||
def->category = L("Quality");
|
||||
def->tooltip = L("Apply the reverse perimeters logic only on internal perimeters. \n\nThis setting greatly reduces part stresses as they are now distributed in alternating directions. This should reduce part warping while also maintaining external wall quality. This feature can be very useful for warp prone material, like ABS/ASA, and also for elastic filaments, like TPU and Silk PLA. It can also help reduce warping on floating regions over supports.\n\nFor this setting to be the most effective, it is recomended to set the Reverse Threshold to 0 so that all internal walls print in alternating directions on odd layers irrespective of their overhang degree.");
|
||||
def->mode = comAdvanced;
|
||||
def->set_default_value(new ConfigOptionBool(false));
|
||||
|
||||
|
|
|
|||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue