Skip to content

Commit b7241a6

Browse files
committed
Add first draft for a mesh data source example
1 parent e5738e2 commit b7241a6

File tree

1 file changed

+41
-0
lines changed

1 file changed

+41
-0
lines changed

examples/core_mesh_data_source.py

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
##Copyright 2021 Thomas Paviot ([email protected])
2+
##
3+
##This file is part of pythonOCC.
4+
##
5+
##pythonOCC is free software: you can redistribute it and/or modify
6+
##it under the terms of the GNU Lesser General Public License as published by
7+
##the Free Software Foundation, either version 3 of the License, or
8+
##(at your option) any later version.
9+
##
10+
##pythonOCC is distributed in the hope that it will be useful,
11+
##but WITHOUT ANY WARRANTY; without even the implied warranty of
12+
##MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13+
##GNU Lesser General Public License for more details.
14+
##
15+
##You should have received a copy of the GNU Lesser General Public License
16+
##along with pythonOCC. If not, see <http://www.gnu.org/licenses/>.
17+
18+
import os
19+
20+
from OCC.Core.MeshDataSource import Mesh_DataSource
21+
from OCC.Core.RWStl import rwstl_ReadFile
22+
from OCC.Core.MeshVS import *
23+
24+
from OCC.Display.SimpleGui import init_display
25+
26+
stl_filename = os.path.join('..', 'assets', 'models', 'fan.stl')
27+
28+
a_stl_mesh = rwstl_ReadFile(stl_filename)
29+
30+
a_data_source = Mesh_DataSource(a_stl_mesh)
31+
32+
a_mesh_prs = MeshVS_Mesh()
33+
a_mesh_prs.SetDataSource(a_data_source)
34+
a_builder = MeshVS_MeshPrsBuilder(a_mesh_prs)
35+
36+
a_mesh_prs.AddBuilder (a_builder, True)
37+
38+
display, start_display, add_menu, add_function_to_menu = init_display()
39+
40+
display.Context.Display(a_mesh_prs, True)
41+
start_display()

0 commit comments

Comments
 (0)