Skip to content

Commit 6cd5180

Browse files
committed
wip
1 parent 0f778b8 commit 6cd5180

File tree

3 files changed

+148
-3
lines changed

3 files changed

+148
-3
lines changed

.github/ISSUE_TEMPLATE.md

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
# Auto-rotate view when sketch and view planes are parallel during extrude
2+
3+
## Problem
4+
When extruding a sketch face, if the view plane is parallel (or nearly parallel) to the sketch plane, users cannot clearly see the extrusion direction, making it difficult to specify the extrusion distance by clicking and dragging.
5+
6+
## Solution
7+
Automatically rotate the view by 45 degrees when the sketch plane and view plane are detected to be parallel (within 5 degrees tolerance).
8+
9+
## Changes
10+
11+
### Auto-rotation for parallel planes
12+
**File**: `src/occt_view.cpp`
13+
**Function**: `sketch_face_extrude()` (lines 693-709)
14+
15+
Added logic to detect parallel planes and auto-rotate the view:
16+
17+
```cpp
18+
const gp_Ax1& a = m_to_extrude_pln.Axis();
19+
const gp_Ax1& b = m_curr_view_pln.Axis();
20+
21+
if (a.IsParallel(b, to_radians(5.0)))
22+
{
23+
// Rotate view by 45 degrees
24+
const double angle45 = 3.14159265358979323846 / 4.0;
25+
auto aa = gp_Vec(m_to_extrude_pln.XAxis().Direction()) + gp_Vec(m_to_extrude_pln.YAxis().Direction());
26+
aa.Normalize();
27+
aa *= angle45;
28+
m_view->Rotate(aa.X(), aa.Y(), aa.Z(), m_to_extrude_pt->X(), m_to_extrude_pt->Y(), m_to_extrude_pt->Z());
29+
m_view->Redraw();
30+
m_ctx->UpdateCurrentViewer();
31+
m_to_extrude_pt = std::nullopt;
32+
}
33+
```
34+
35+
### Simplified view plane calculation
36+
**File**: `src/occt_view.cpp`
37+
**Function**: `get_view_plane()` (lines 371-375)
38+
39+
Refactored to use `camera->Direction()` directly:
40+
41+
```cpp
42+
gp_Pln Occt_view::get_view_plane(const gp_Pnt& point_on_plane) const
43+
{
44+
Graphic3d_Camera_ptr camera = m_view->Camera();
45+
return gp_Pln(point_on_plane, camera->Direction());
46+
}
47+
```
48+
49+
## Notes
50+
- Tolerance set to 5 degrees for detecting parallel planes
51+
- Rotation axis calculated from sketch plane's X and Y axes
52+
- After rotation, `m_to_extrude_pt` is reset to trigger recalculation
53+
54+
## Cleanup Needed
55+
There's leftover debug code on line 708 that should be removed:
56+
```cpp
57+
int hi = 0; // TODO: Remove this debug code
58+
```
59+
60+
## Related
61+
- Related to: "Extrude should be in projection mode" (bug #5 in bugs.md)
62+
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
# This starter workflow is for a CMake project running on a single platform. There is a different starter workflow if you need cross-platform coverage.
2+
# See: https://github.com/actions/starter-workflows/blob/main/ci/cmake-multi-platform.yml
3+
name: CMake on a single platform
4+
5+
on:
6+
push:
7+
branches: [ "main" ]
8+
pull_request:
9+
branches: [ "main" ]
10+
11+
env:
12+
# Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.)
13+
BUILD_TYPE: Release
14+
15+
jobs:
16+
build:
17+
# The CMake configure and build commands are platform agnostic and should work equally well on Windows or Mac.
18+
# You can convert this to a matrix build if you need cross-platform coverage.
19+
# See: https://docs.github.com/en/free-pro-team@latest/actions/learn-github-actions/managing-complex-workflows#using-a-build-matrix
20+
runs-on: ubuntu-latest
21+
22+
steps:
23+
- uses: actions/checkout@v4
24+
25+
- name: Install dependencies
26+
run: |
27+
sudo apt-get update
28+
sudo apt-get install -y \
29+
libopencascade-dev \
30+
libboost-dev \
31+
libgl1-mesa-dev \
32+
libglfw3-dev \
33+
libglew-dev \
34+
libxinerama-dev \
35+
libxcursor-dev \
36+
libxi-dev \
37+
build-essential \
38+
cmake
39+
40+
- name: Find OpenCASCADE installation path
41+
id: find_occt
42+
run: |
43+
# Find OpenCASCADE CMake config file
44+
OCCT_CONFIG=$(find /usr -name "OpenCASCADEConfig.cmake" -o -name "opencascade-config.cmake" 2>/dev/null | head -1)
45+
if [ -n "$OCCT_CONFIG" ]; then
46+
OCCT_DIR=$(dirname "$OCCT_CONFIG")
47+
echo "OpenCASCADE_DIR=$OCCT_DIR" >> $GITHUB_ENV
48+
echo "Found OpenCASCADE at: $OCCT_DIR"
49+
else
50+
# Try common installation paths
51+
for path in "/usr/lib/x86_64-linux-gnu/cmake/opencascade" "/usr/lib/cmake/opencascade" "/usr/share/cmake/opencascade"; do
52+
if [ -d "$path" ]; then
53+
echo "OpenCASCADE_DIR=$path" >> $GITHUB_ENV
54+
echo "Found OpenCASCADE at: $path"
55+
exit 0
56+
fi
57+
done
58+
echo "ERROR: Could not find OpenCASCADE installation"
59+
echo "Searching for OpenCASCADE files..."
60+
find /usr -name "*OpenCASCADE*" -o -name "*opencascade*" 2>/dev/null | head -20
61+
exit 1
62+
fi
63+
64+
- name: Configure CMake
65+
# Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make.
66+
# See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type
67+
run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DOpenCASCADE_DIR=${{env.OpenCASCADE_DIR}}
68+
69+
- name: Build
70+
# Build your program with the given configuration
71+
run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}}
72+
73+
- name: Test
74+
working-directory: ${{github.workspace}}/build
75+
# Execute tests defined by the CMake configuration.
76+
# See https://cmake.org/cmake/help/latest/manual/ctest.1.html for more detail
77+
run: ctest -C ${{env.BUILD_TYPE}} --output-on-failure
78+

CMakeLists.txt

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,16 @@ if(MSVC_VERSION)
3939
execute_process(COMMAND ${NUGET} install glfw -Version ${GLFW_VERSION} -o thirdParty)
4040
execute_process(COMMAND ${NUGET} install unofficial-flayan-glew -Version ${GLEW_VERSION} -o thirdParty)
4141
execute_process(COMMAND ${NUGET} install boost -Version ${BOOST_VERSION} -o thirdParty)
42+
# Include Boost from NuGet installation on Windows
43+
INCLUDE_DIRECTORIES(${PROJECT_NAME} ${BINARY_DIR}/thirdParty/boost.${BOOST_VERSION}/lib/native/include)
44+
else()
45+
# On Linux, use system Boost installation
46+
find_package(Boost REQUIRED)
47+
if(Boost_FOUND)
48+
INCLUDE_DIRECTORIES(${PROJECT_NAME} ${Boost_INCLUDE_DIRS})
49+
endif()
4250
endif()
4351

44-
45-
INCLUDE_DIRECTORIES(${PROJECT_NAME} ${BINARY_DIR}/thirdParty/boost.${BOOST_VERSION}/lib/native/include)
46-
4752
file(GLOB imguiSrc
4853
"third_party/imgui/imgui_impl_glfw.cpp"
4954
"third_party/imgui/imgui_impl_opengl3.cpp"

0 commit comments

Comments
 (0)