GeezerVison is showing github.com — Merge pull request #9 from tpaviot/refactor-transparent-handles · hovedguy/pythonocc-demos@6c4de27
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 clipboardExpand all lines: examples/core_classic_occ_bottle.py +10-10Lines changed: 10 additions & 10 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 22 | 22 | from OCC.Core.gp import gp_Pnt, gp_OX, gp_Vec, gp_Trsf, gp_DZ, gp_Ax2, gp_Ax3, gp_Pnt2d, gp_Dir2d, gp_Ax2d | 23 | 23 | from OCC.Core.GC import GC_MakeArcOfCircle, GC_MakeSegment | 24 | 24 | from OCC.Core.GCE2d import GCE2d_MakeSegment | 25 | | -from OCC.Core.Geom import Geom_Plane, Geom_CylindricalSurface, Handle_Geom_Plane, Handle_Geom_Surface | 26 | | -from OCC.Core.Geom2d import Geom2d_Ellipse, Geom2d_TrimmedCurve, Handle_Geom2d_Ellipse, Handle_Geom2d_Curve | | 25 | +from OCC.Core.Geom import Geom_Plane, Geom_CylindricalSurface, Geom_Plane, Geom_Surface | | 26 | +from OCC.Core.Geom2d import Geom2d_Ellipse, Geom2d_TrimmedCurve, Geom2d_Ellipse, Geom2d_Curve | 27 | 27 | from OCC.Core.BRepBuilderAPI import BRepBuilderAPI_MakeEdge, BRepBuilderAPI_MakeWire, BRepBuilderAPI_MakeFace, \ | 28 | 28 | BRepBuilderAPI_Transform | 29 | 29 | from OCC.Core.BRepPrimAPI import BRepPrimAPI_MakePrism, BRepPrimAPI_MakeCylinder | @@ -42,7 +42,7 @@ def face_is_plane(face): | 42 | 42 | Returns True if the TopoDS_Shape is a plane, False otherwise | 43 | 43 | """ | 44 | 44 | hs = BRep_Tool_Surface(face) | 45 | | - downcast_result = Handle_Geom_Plane.DownCast(hs) | | 45 | + downcast_result = Geom_Plane.DownCast(hs) | 46 | 46 | # The handle is null if downcast failed or is not possible, that is to say the face is not a plane | 47 | 47 | if downcast_result.IsNull(): | 48 | 48 | return False | @@ -54,7 +54,7 @@ def geom_plane_from_face(aFace): | 54 | 54 | """ | 55 | 55 | Returns the geometric plane entity from a planar surface | 56 | 56 | """ | 57 | | - return Handle_Geom_Plane.DownCast(BRep_Tool_Surface(aFace)).GetObject() | | 57 | + return Geom_Plane.DownCast(BRep_Tool_Surface(aFace)) | 58 | 58 |
| 59 | 59 |
| 60 | 60 | height = 70 | @@ -176,19 +176,19 @@ def geom_plane_from_face(aFace): | 176 | 176 | anEllipse1 = Geom2d_Ellipse(anAx2d, aMajor, aMinor) | 177 | 177 | anEllipse2 = Geom2d_Ellipse(anAx2d, aMajor, aMinor / 4.0) | 178 | 178 |
| 179 | | -anArc1 = Geom2d_TrimmedCurve(Handle_Geom2d_Ellipse(anEllipse1), 0, math.pi) | 180 | | -anArc2 = Geom2d_TrimmedCurve(Handle_Geom2d_Ellipse(anEllipse2), 0, math.pi) | | 179 | +anArc1 = Geom2d_TrimmedCurve(Geom2d_Ellipse(anEllipse1), 0, math.pi) | | 180 | +anArc2 = Geom2d_TrimmedCurve(Geom2d_Ellipse(anEllipse2), 0, math.pi) | 181 | 181 |
| 182 | 182 | anEllipsePnt1 = anEllipse1.Value(0) | 183 | 183 | anEllipsePnt2 = anEllipse1.Value(math.pi) | 184 | 184 |
| 185 | 185 | aSegment = GCE2d_MakeSegment(anEllipsePnt1, anEllipsePnt2) | 186 | 186 |
| 187 | 187 | # Build edges and wires for threading | 188 | | -anEdge1OnSurf1 = BRepBuilderAPI_MakeEdge(Handle_Geom2d_Curve(anArc1), Handle_Geom_Surface(aCyl1)) | 189 | | -anEdge2OnSurf1 = BRepBuilderAPI_MakeEdge(aSegment.Value(), Handle_Geom_Surface(aCyl1)) | 190 | | -anEdge1OnSurf2 = BRepBuilderAPI_MakeEdge(Handle_Geom2d_Curve(anArc2), Handle_Geom_Surface(aCyl2)) | 191 | | -anEdge2OnSurf2 = BRepBuilderAPI_MakeEdge(aSegment.Value(), Handle_Geom_Surface(aCyl2)) | | 188 | +anEdge1OnSurf1 = BRepBuilderAPI_MakeEdge(Geom2d_Curve(anArc1), Geom_Surface(aCyl1)) | | 189 | +anEdge2OnSurf1 = BRepBuilderAPI_MakeEdge(aSegment.Value(), Geom_Surface(aCyl1)) | | 190 | +anEdge1OnSurf2 = BRepBuilderAPI_MakeEdge(Geom2d_Curve(anArc2), Geom_Surface(aCyl2)) | | 191 | +anEdge2OnSurf2 = BRepBuilderAPI_MakeEdge(aSegment.Value(), Geom_Surface(aCyl2)) | 192 | 192 |
| 193 | 193 | threadingWire1 = BRepBuilderAPI_MakeWire(anEdge1OnSurf1.Edge(), anEdge2OnSurf1.Edge()) | 194 | 194 | threadingWire2 = BRepBuilderAPI_MakeWire(anEdge1OnSurf2.Edge(), anEdge2OnSurf2.Edge()) | |
Collapse file Copy file name to clipboardExpand all lines: examples/core_dimensions.py +2-2Lines changed: 2 additions & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 27 | 27 | c = gp_Circ(gp_Ax2(gp_Pnt(200., 200., 0.), gp_Dir(0., 0., 1.)), 80) | 28 | 28 | ec = BRepBuilderAPI_MakeEdge(c).Edge() | 29 | 29 | ais_shp = AIS_Shape(ec) | 30 | | -display.Context.Display(ais_shp.GetHandle()) | | 30 | +display.Context.Display(ais_shp) | 31 | 31 |
| 32 | 32 |
| 33 | 33 | rd = AIS_RadiusDimension(ec) | 34 | 34 | #rd.SetArrowSize(12) | 35 | | -display.Context.Display(rd.GetHandle()) | | 35 | +display.Context.Display(rd) | 36 | 36 | display.FitAll() | 37 | 37 | start_display() |
Collapse file Copy file name to clipboardExpand all lines: examples/core_display_clip_planes.py +2-4Lines changed: 2 additions & 4 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 17 | 17 | ##You should have received a copy of the GNU Lesser General Public License | 18 | 18 | ##along with pythonOCC. If not, see <http://www.gnu.org/licenses/>. | 19 | 19 |
| 20 | | -from __future__ import print_function | 21 | | - | 22 | 20 | import sys | 23 | 21 |
| 24 | 22 | from OCC.Core.gp import gp_Vec | | 36 | 34 | builder = BRep_Builder() | 37 | 35 | breptools_Read(cylinder_head, '../assets/models/cylinder_head.brep', builder) | 38 | 36 |
| 39 | | -ais_shp = display.DisplayShape(cylinder_head).GetObject() | | 37 | +ais_shp = display.DisplayShape(cylinder_head) | 40 | 38 |
| 41 | 39 | # clip plane number one, by default xOy | 42 | 40 | clip_plane_1 = Graphic3d_ClipPlane() | | 54 | 52 | aMat.SetAmbientColor(aColor) | 55 | 53 | aMat.SetDiffuseColor(aColor) | 56 | 54 | clip_plane_1.SetCappingMaterial(aMat) | 57 | | -ais_shp.AddClipPlane(clip_plane_1.GetHandle()) | | 55 | +ais_shp.AddClipPlane(clip_plane_1) | 58 | 56 |
| 59 | 57 |
| 60 | 58 | def enable_clip_plane(event=None): | |
Collapse file Copy file name to clipboardExpand all lines: examples/core_display_customize_linewidth.py +2-2Lines changed: 2 additions & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 38 | 38 | # Get context and display shape | 39 | 39 | # | 40 | 40 | # Get Context | 41 | | -ais_context = display.GetContext().GetObject() | 42 | | -ais_context.Display(ais_shp.GetHandle()) | | 41 | +ais_context = display.GetContext() | | 42 | +ais_context.Display(ais_shp) | 43 | 43 |
| 44 | 44 | display.View_Iso() | 45 | 45 | display.FitAll() | |
Collapse file Copy file name to clipboardExpand all lines: examples/core_display_customize_prs3d.py +6-6Lines changed: 6 additions & 6 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 24 | 24 |
| 25 | 25 | from OCC.Core.BRepPrimAPI import BRepPrimAPI_MakeCylinder | 26 | 26 | from OCC.Display.SimpleGui import init_display | | 27 | + | 27 | 28 | display, start_display, add_menu, add_function_to_menu = init_display() | 28 | 29 | display.SetModeHLR() | 29 | 30 | # | 30 | 31 | # Get Context | 31 | 32 | # | 32 | | -ais_context = display.GetContext().GetObject() | | 33 | +ais_context = display.GetContext() | 33 | 34 | # | 34 | 35 | # Get Prs3d_drawer from previous context | 35 | 36 | # | 36 | | -drawer_handle = ais_context.DefaultDrawer() | 37 | | -drawer = drawer_handle.GetObject() | | 37 | +drawer = ais_context.DefaultDrawer() | 38 | 38 | drawer.SetIsoOnPlane(True) | 39 | 39 |
| 40 | | -la = drawer.LineAspect().GetObject() | | 40 | +la = drawer.LineAspect() | 41 | 41 | la.SetWidth(4) | 42 | 42 | # increase line width in the current viewer | 43 | 43 | # This is only viewed in the HLR mode (hit 'e' key for instance) | 44 | | -line_aspect = drawer.SeenLineAspect().GetObject() | | 44 | +line_aspect = drawer.SeenLineAspect() | 45 | 45 | drawer.EnableDrawHiddenLine() | 46 | 46 | line_aspect.SetWidth(4) | 47 | 47 | # | 48 | | -drawer.SetWireAspect(line_aspect.GetHandle()) | | 48 | +drawer.SetWireAspect(line_aspect) | 49 | 49 | # | 50 | 50 | # Displays a cylinder | 51 | 51 | # | |
Collapse file Copy file name to clipboardExpand all lines: examples/core_display_export_to_EF.py +5-5Lines changed: 5 additions & 5 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 18 | 18 | from OCC.Display.SimpleGui import init_display | 19 | 19 | from OCC.Core.BRepPrimAPI import BRepPrimAPI_MakeTorus | 20 | 20 | from OCC.Core.Graphic3d import (Graphic3d_EF_PDF, | 21 | | - Graphic3d_EF_SVG, | 22 | | - Graphic3d_EF_TEX, | 23 | | - Graphic3d_EF_PostScript, | 24 | | - Graphic3d_EF_EnhPostScript) | | 21 | + Graphic3d_EF_SVG, | | 22 | + Graphic3d_EF_TEX, | | 23 | + Graphic3d_EF_PostScript, | | 24 | + Graphic3d_EF_EnhPostScript) | 25 | 25 |
| 26 | 26 | display, start_display, add_menu, add_function_to_menu = init_display() | 27 | 27 | my_box = BRepPrimAPI_MakeTorus(40., 20.).Shape() | 28 | 28 |
| 29 | 29 | display.DisplayShape(my_box, update=True) | 30 | | -f = display.View.View().GetObject() | | 30 | +f = display.View.View() | 31 | 31 |
| 32 | 32 | #------------------------------------------------------------------------------- | 33 | 33 | # for this example to work, pythonocc / OCE needs to be built with the gl2ps lib | |
Collapse file Copy file name to clipboardExpand all lines: examples/core_display_line_properties.py +8-8Lines changed: 8 additions & 8 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -36,7 +36,7 @@ def line(): | 36 | 36 | d1 = gp_Dir(4., 5., 6.) | 37 | 37 | line1 = Geom_Line(p1, d1) | 38 | 38 |
| 39 | | - ais_line1 = AIS_Line(line1.GetHandle()) | | 39 | + ais_line1 = AIS_Line(line1) | 40 | 40 |
| 41 | 41 | # if we need to edit color, we can simply use SetColor | 42 | 42 | # ais_line1.SetColor(Quantity_NOC_RED) | @@ -45,25 +45,25 @@ def line(): | 45 | 45 | # To do that, we need to do use AIS_Drawer and apply it to ais_line1 | 46 | 46 | width = 1.0 | 47 | 47 | drawer = Prs3d_Drawer() | 48 | | - ais_line1.SetAttributes(drawer.GetHandle()) | | 48 | + ais_line1.SetAttributes(drawer) | 49 | 49 |
| 50 | | - display.Context.Display(ais_line1.GetHandle(), False) | | 50 | + display.Context.Display(ais_line1, False) | 51 | 51 | # we can apply the same rule for other lines by just doing a for loop | 52 | 52 | for i in range(1, 5): | 53 | 53 | p2 = gp_Pnt(i, 2., 5.) | 54 | 54 | d2 = gp_Dir(4*i, 6., 9.) | 55 | 55 | line2 = Geom_Line(p2, d2) | 56 | 56 |
| 57 | | - ais_line2 = AIS_Line(line2.GetHandle()) | | 57 | + ais_line2 = AIS_Line(line2) | 58 | 58 |
| 59 | 59 | width = float(i) | 60 | | - drawer = ais_line2.Attributes().GetObject() | | 60 | + drawer = ais_line2.Attributes() | 61 | 61 | # asp : first parameter color, second type, last width | 62 | 62 | asp = Prs3d_LineAspect(9*i, i, width) | 63 | | - drawer.SetLineAspect(asp.GetHandle()) | 64 | | - ais_line2.SetAttributes(drawer.GetHandle()) | | 63 | + drawer.SetLineAspect(asp) | | 64 | + ais_line2.SetAttributes(drawer) | 65 | 65 |
| 66 | | - display.Context.Display(ais_line2.GetHandle(), False) | | 66 | + display.Context.Display(ais_line2, False) | 67 | 67 | start_display() | 68 | 68 |
| 69 | 69 |
| |
Collapse file Copy file name to clipboardExpand all lines: examples/core_display_overlayered_image.py +2-2Lines changed: 2 additions & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 30 | 30 | def absolute_position(event=None): | 31 | 31 | # create a texture | 32 | 32 | aTextureItem = TextureItem(TCollection_AsciiString("../assets/images/carre-200.png"), | 33 | | - display.GetView().GetObject(), | | 33 | + display.GetView(), | 34 | 34 | display.GetOverLayer()) | 35 | 35 | aTextureItem.SetAbsolutePosition(50, 50) | 36 | 36 | display.register_overlay_item(aTextureItem) | @@ -39,7 +39,7 @@ def absolute_position(event=None): | 39 | 39 | def relative_position(event=None): | 40 | 40 | # create a texture | 41 | 41 | aTextureItem = TextureItem(TCollection_AsciiString("../assets/images/carre-200.png"), | 42 | | - display.GetView().GetObject(), | | 42 | + display.GetView(), | 43 | 43 | display.GetOverLayer()) | 44 | 44 | aTextureItem.SetRelativePosition(30, 60) # 30% width, 60% width | 45 | 45 | display.register_overlay_item(aTextureItem) | |
Collapse file Copy file name to clipboardExpand all lines: examples/core_display_point_cloud.py +9-9Lines changed: 9 additions & 9 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -42,11 +42,11 @@ def random_points(event=None): | 42 | 42 |
| 43 | 43 | # then build the point cloud | 44 | 44 | point_cloud = AIS_PointCloud() | 45 | | - point_cloud.SetPoints(points_3d.GetHandle()) | | 45 | + point_cloud.SetPoints(points_3d) | 46 | 46 |
| 47 | 47 | # display | 48 | | - ais_context = display.GetContext().GetObject() | 49 | | - ais_context.Display(point_cloud.GetHandle()) | | 48 | + ais_context = display.GetContext() | | 49 | + ais_context.Display(point_cloud) | 50 | 50 | display.View_Iso() | 51 | 51 | display.FitAll() | 52 | 52 |
| @@ -58,9 +58,9 @@ def bunny(event=None): | 58 | 58 | x, y, z = map(float, line.split()) | 59 | 59 | pc.AddVertex(x, y, z) | 60 | 60 | point_cloud = AIS_PointCloud() | 61 | | - point_cloud.SetPoints(pc.GetHandle()) | 62 | | - ais_context = display.GetContext().GetObject() | 63 | | - ais_context.Display(point_cloud.GetHandle()) | | 61 | + point_cloud.SetPoints(pc) | | 62 | + ais_context = display.GetContext() | | 63 | + ais_context.Display(point_cloud) | 64 | 64 | display.View_Iso() | 65 | 65 | display.FitAll() | 66 | 66 |
| @@ -76,10 +76,10 @@ def tabletop(event=None): | 76 | 76 |
| 77 | 77 | # then build the point cloud | 78 | 78 | point_cloud = AIS_PointCloud() | 79 | | - point_cloud.SetPoints(pc.GetHandle()) | | 79 | + point_cloud.SetPoints(pc) | 80 | 80 | # display | 81 | | - ais_context = display.GetContext().GetObject() | 82 | | - ais_context.Display(point_cloud.GetHandle()) | | 81 | + ais_context = display.GetContext() | | 82 | + ais_context.Display(point_cloud) | 83 | 83 | display.DisableAntiAliasing() | 84 | 84 | display.View_Iso() | 85 | 85 | display.FitAll() | |
Collapse file Copy file name to clipboardExpand all lines: examples/core_display_quality.py +1-1Lines changed: 1 addition & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
| 30 | 30 | # | 31 | 31 | # Get Context | 32 | 32 | # | 33 | | -ais_context = display.GetContext().GetObject() | | 33 | +ais_context = display.GetContext() | 34 | 34 | # | 35 | 35 | # Display current quality | 36 | 36 | dc = ais_context.DeviationCoefficient() | |
|