GeezerVison is showing github.com — Added core_webgl* examples · hovedguy/pythonocc-demos@35b0523
File treeExpand file treeCollapse file tree Open diff view settings Expand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboard Collapse file Copy file name to clipboard +31Lines changed: 31 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
| | 1 | +#!/usr/bin/env python | | 2 | + | | 3 | + | | 4 | +## | | 5 | +##This file is part of pythonOCC. | | 6 | +## | | 7 | +##pythonOCC is free software: you can redistribute it and/or modify | | 8 | +##it under the terms of the GNU Lesser General Public License as published by | | 9 | +##the Free Software Foundation, either version 3 of the License, or | | 10 | +##(at your option) any later version. | | 11 | +## | | 12 | +##pythonOCC is distributed in the hope that it will be useful, | | 13 | +##but WITHOUT ANY WARRANTY; without even the implied warranty of | | 14 | +##MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | | 15 | +##GNU Lesser General Public License for more details. | | 16 | +## | | 17 | +##You should have received a copy of the GNU Lesser General Public License | | 18 | +##along with pythonOCC. If not, see <http://www.gnu.org/licenses/>. | | 19 | + | | 20 | +import os | | 21 | + | | 22 | +from OCC.Core.BRepPrimAPI import BRepPrimAPI_MakeTorus | | 23 | + | | 24 | +from OCC.Extend.DataExchange import read_step_file | | 25 | +from OCC.Display.WebGl import threejs_renderer | | 26 | + | | 27 | +big_shp = read_step_file(os.path.join('..', 'assets', 'models', 'RC_Buggy_2_front_suspension.stp')) | | 28 | + | | 29 | +my_renderer = threejs_renderer.ThreejsRenderer() | | 30 | +my_renderer.DisplayShape(big_shp) | | 31 | +my_renderer.render() |
Collapse file Copy file name to clipboard +38Lines changed: 38 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
| | 1 | +#!/usr/bin/env python | | 2 | + | | 3 | + | | 4 | +## | | 5 | +##This file is part of pythonOCC. | | 6 | +## | | 7 | +##pythonOCC is free software: you can redistribute it and/or modify | | 8 | +##it under the terms of the GNU Lesser General Public License as published by | | 9 | +##the Free Software Foundation, either version 3 of the License, or | | 10 | +##(at your option) any later version. | | 11 | +## | | 12 | +##pythonOCC is distributed in the hope that it will be useful, | | 13 | +##but WITHOUT ANY WARRANTY; without even the implied warranty of | | 14 | +##MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | | 15 | +##GNU Lesser General Public License for more details. | | 16 | +## | | 17 | +##You should have received a copy of the GNU Lesser General Public License | | 18 | +##along with pythonOCC. If not, see <http://www.gnu.org/licenses/>. | | 19 | + | | 20 | +import os | | 21 | + | | 22 | +from OCC.Core.BRepPrimAPI import BRepPrimAPI_MakeTorus | | 23 | + | | 24 | +from OCC.Extend.DataExchange import read_step_file | | 25 | +from OCC.Extend.TopologyUtils import TopologyExplorer | | 26 | +from OCC.Display.WebGl import threejs_renderer | | 27 | + | | 28 | +# opens a big step file | | 29 | +# render each part of the assembly as a shape | | 30 | +big_shp = read_step_file(os.path.join('..', 'assets', 'models', '3864470050F1.stp')) | | 31 | + | | 32 | +all_subshapes = TopologyExplorer(big_shp).solids() | | 33 | + | | 34 | +my_renderer = threejs_renderer.ThreejsRenderer() | | 35 | +for single_shape in all_subshapes: | | 36 | + my_renderer.DisplayShape(single_shape) | | 37 | +# then call the renderer | | 38 | +my_renderer.render() |
Collapse file Copy file name to clipboard +33Lines changed: 33 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
| | 1 | +#!/usr/bin/env python | | 2 | + | | 3 | + | | 4 | +## | | 5 | +##This file is part of pythonOCC. | | 6 | +## | | 7 | +##pythonOCC is free software: you can redistribute it and/or modify | | 8 | +##it under the terms of the GNU Lesser General Public License as published by | | 9 | +##the Free Software Foundation, either version 3 of the License, or | | 10 | +##(at your option) any later version. | | 11 | +## | | 12 | +##pythonOCC is distributed in the hope that it will be useful, | | 13 | +##but WITHOUT ANY WARRANTY; without even the implied warranty of | | 14 | +##MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | | 15 | +##GNU Lesser General Public License for more details. | | 16 | +## | | 17 | +##You should have received a copy of the GNU Lesser General Public License | | 18 | +##along with pythonOCC. If not, see <http://www.gnu.org/licenses/>. | | 19 | + | | 20 | +import os | | 21 | + | | 22 | +from OCC.Core.BRepPrimAPI import BRepPrimAPI_MakeTorus | | 23 | + | | 24 | +from OCC.Extend.DataExchange import read_step_file | | 25 | +from OCC.Display.WebGl import threejs_renderer | | 26 | + | | 27 | +# opens a big step file | | 28 | +# render the whole assembly as a single shape | | 29 | +big_shp = read_step_file(os.path.join('..', 'assets', 'models', 'RC_Buggy_2_front_suspension.stp')) | | 30 | + | | 31 | +my_renderer = threejs_renderer.ThreejsRenderer() | | 32 | +my_renderer.DisplayShape(big_shp) | | 33 | +my_renderer.render() |
Collapse file Copy file name to clipboard +39Lines changed: 39 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
| | 1 | +#!/usr/bin/env python | | 2 | + | | 3 | + | | 4 | +## | | 5 | +##This file is part of pythonOCC. | | 6 | +## | | 7 | +##pythonOCC is free software: you can redistribute it and/or modify | | 8 | +##it under the terms of the GNU Lesser General Public License as published by | | 9 | +##the Free Software Foundation, either version 3 of the License, or | | 10 | +##(at your option) any later version. | | 11 | +## | | 12 | +##pythonOCC is distributed in the hope that it will be useful, | | 13 | +##but WITHOUT ANY WARRANTY; without even the implied warranty of | | 14 | +##MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | | 15 | +##GNU Lesser General Public License for more details. | | 16 | +## | | 17 | +##You should have received a copy of the GNU Lesser General Public License | | 18 | +##along with pythonOCC. If not, see <http://www.gnu.org/licenses/>. | | 19 | + | | 20 | +from OCC.Display.WebGl import threejs_renderer | | 21 | +from OCC.Core.BRep import BRep_Builder | | 22 | +from OCC.Core.TopoDS import TopoDS_Shape | | 23 | +from OCC.Core.BRepTools import breptools_Read | | 24 | + | | 25 | +from OCC.Extend.TopologyUtils import TopologyExplorer | | 26 | + | | 27 | +# loads brep shape | | 28 | +cylinder_head = TopoDS_Shape() | | 29 | +builder = BRep_Builder() | | 30 | +breptools_Read(cylinder_head, '../assets/models/cylinder_head.brep', builder) | | 31 | + | | 32 | +# render cylinder head in x3dom | | 33 | +my_renderer = threejs_renderer.ThreejsRenderer() | | 34 | + | | 35 | +all_faces = TopologyExplorer(cylinder_head).faces() | | 36 | +# display each face | | 37 | +for face in all_faces: | | 38 | + my_renderer.DisplayShape(face) | | 39 | +my_renderer.render() |
Collapse file Copy file name to clipboard +39Lines changed: 39 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
| | 1 | +#!/usr/bin/env python | | 2 | + | | 3 | + | | 4 | +## | | 5 | +##This file is part of pythonOCC. | | 6 | +## | | 7 | +##pythonOCC is free software: you can redistribute it and/or modify | | 8 | +##it under the terms of the GNU Lesser General Public License as published by | | 9 | +##the Free Software Foundation, either version 3 of the License, or | | 10 | +##(at your option) any later version. | | 11 | +## | | 12 | +##pythonOCC is distributed in the hope that it will be useful, | | 13 | +##but WITHOUT ANY WARRANTY; without even the implied warranty of | | 14 | +##MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | | 15 | +##GNU Lesser General Public License for more details. | | 16 | +## | | 17 | +##You should have received a copy of the GNU Lesser General Public License | | 18 | +##along with pythonOCC. If not, see <http://www.gnu.org/licenses/>. | | 19 | + | | 20 | +import os | | 21 | + | | 22 | +from OCC.Core.BRepPrimAPI import BRepPrimAPI_MakeTorus | | 23 | + | | 24 | +from OCC.Extend.DataExchange import read_step_file | | 25 | +from OCC.Extend.TopologyUtils import TopologyExplorer | | 26 | +from OCC.Display.WebGl import x3dom_renderer | | 27 | + | | 28 | +# opens a big step file | | 29 | +# render each part of the assembly as a shape | | 30 | +# The file is from https://grabcad.com/library/briggs-stratton-vangaurd-23-hp-engine-1 | | 31 | +big_shp = read_step_file(os.path.join('..', 'assets', 'models', '3864470050F1.stp')) | | 32 | + | | 33 | +all_subshapes = TopologyExplorer(big_shp).solids() | | 34 | + | | 35 | +my_renderer = x3dom_renderer.X3DomRenderer() | | 36 | +for single_shape in all_subshapes: | | 37 | + my_renderer.DisplayShape(single_shape) | | 38 | +# then call the renderer | | 39 | +my_renderer.render() |
|