def __init__(self, parent=None): if not has_pyside: raise ModuleNotFoundError("PySide was not found and is required.") super(View, self).__init__(parent) # Qt settings self.setBackgroundRole(QPalette.NoRole) self.setMouseTracking(True) # Values for mouse movement self._x0, self._y0 = 0., 0. # Some default settings self._white = Quantity_Color(Quantity_NOC_WHITE) self._black = Quantity_Color(Quantity_NOC_BLACK) # Get window handle self.window_handle = self.winId() # Display connection self.display_connect = Aspect_DisplayConnection() # Graphics driver self._graphics_driver = OpenGl_GraphicDriver(self.display_connect) # Create viewer and view self.my_viewer = V3d_Viewer(self._graphics_driver) self.my_view = self.my_viewer.CreateView() self.wind = Xw_Window(self.display_connect, self.window_handle) self.my_view.SetWindow(self.wind) # Map window if not self.wind.IsMapped(): self.wind.Map() # AIS interactive context self.my_context = AIS_InteractiveContext(self.my_viewer) self.my_context.SetAutomaticHilight(True) self.my_viewer.SetDefaultLights() self.my_viewer.SetLightOn() self.my_view.SetBackgroundColor(Quantity_TOC_RGB, 0.5, 0.5, 0.5) self.my_context.SetDisplayMode(AIS_Shaded, True) self.my_drawer = self.my_context.DefaultDrawer() self.my_drawer.SetFaceBoundaryDraw(True) self.my_view.TriedronDisplay(Aspect_TOTP_RIGHT_LOWER, self._black, 0.08) self.my_view.SetProj(V3d_TypeOfOrientation.V3d_XposYposZpos) # Mesh display mode self._mesh_mode = 1
def line(): # create a line p1 = gp_Pnt(2., 3., 4.) d1 = gp_Dir(4., 5., 6.) line1 = Geom_Line(p1, d1) ais_line1 = AIS_Line(line1) # if we need to edit color, we can simply use SetColor # ais_line1.SetColor(Quantity_NOC_RED) # but actually we need to edit more, not just color. Line width and style as well # To do that, we need to do use AIS_Drawer and apply it to ais_line1 drawer = Prs3d_Drawer() ais_line1.SetAttributes(drawer) display.Context.Display(ais_line1, False) # we can apply the same rule for other lines by just doing a for loop for i in range(1, 5): p2 = gp_Pnt(i, 2., 5.) d2 = gp_Dir(4 * i, 6., 9.) line2 = Geom_Line(p2, d2) ais_line2 = AIS_Line(line2) width = float(i) drawer = ais_line2.Attributes() # asp : first parameter color, second type, last width asp = Prs3d_LineAspect(Quantity_Color(9 * i), i, width) drawer.SetLineAspect(asp) ais_line2.SetAttributes(drawer) display.Context.Display(ais_line2, False) start_display()
def random_color(self): """ Set the color randomly. :return: None. """ r, g, b = rand(1, 3)[0] self._color = Quantity_Color(r, g, b, Quantity_TOC_RGB)
def _get_color(self, shape, color_tool): label = TDF_Label() color_tool.ShapeTool().Search(shape, label) if label.IsNull(): return None color = Quantity_Color() while True: if color_tool.GetColor(label, color): return Quantity_Color.ColorToHex_(color).ToCString() #elif color_tool.GetColor(label, XCAFDoc_ColorSurf, color): # return Quantity_Color.ColorToHex_(color) #elif color_tool.GetColor(label, XCAFDoc_ColorCurv, color): # return Quantity_Color.ColorToHex_(color) label = label.Father() if label.IsNull(): break print("Color not found") return None
def import_as_multiple_shapes(event=None): compound = read_step_file( os.path.join('..', 'assets', 'models', 'as1_pe_203.stp')) t = TopologyExplorer(compound) display.EraseAll() for solid in t.solids(): color = Quantity_Color(random.random(), random.random(), random.random(), Quantity_TOC_RGB) display.DisplayColoredShape(solid, color) display.FitAll()
def draw_lines(pnt_list, nr_of_points, display): """ rendering a large number of points through the usual way of: display.DisplayShape( make_vertex( gp_Pnt() ) ) is fine for TopoDS_Shapes but certainly not for large number of points. in comparison, drawing all the voxel samples takes 18sec using the approach above, but negigable when using this function its about 2 orders of Magnitude faster, so worth the extra hassle here we use a more close-to-the-metal approach of drawing directly in OpenGL see [1] for a more detailed / elegant way to perform this task [1] http://www.opencascade.org/org/forum/thread_21732/?forum=3 Parameters ---------- pnt_list: list of (x,y,z) tuples vertex list display: qtViewer3d """ a_presentation, group = create_ogl_group(display) black = Quantity_Color(Quantity_NOC_BLACK) asp = Graphic3d_AspectLine3d(black, Aspect_TOL_SOLID, 1) gg = Graphic3d_ArrayOfPolylines( nr_of_points * 2, nr_of_points * 2, 0, # maxEdges False, # hasVColors True) try: while 1: pnt = gp_Pnt(*next(pnt_list)) gg.AddVertex(pnt) pnt = gp_Pnt(*next(pnt_list)) gg.AddVertex(pnt) # create the line, with a random color gg.AddBound(2, random.random(), random.random(), random.random()) except StopIteration: pass group.SetPrimitivesAspect(asp) group.AddPrimitiveArray(gg) a_presentation.Display()
def set_color(self, r, g, b): """ Set color (0. <= r, g, b <= 1.). :param float r: Red. :param float g: Green. :param float b: Blue. :return: None. """ if r > 1.: r /= 255. if g > 1.: g /= 255. if b > 1.: b /= 255. self._color = Quantity_Color(r, g, b, Quantity_TOC_RGB)
def _init(self): """ Initialize the viewer. """ # Icon ico = wx.Icon(_icon, wx.BITMAP_TYPE_PNG) self.SetIcon(ico) # Store some defaults self._x0, self._y0 = 0., 0. self._black = Quantity_Color(Quantity_NOC_BLACK) # Display connection self.display_connect = Aspect_DisplayConnection() # Graphics driver graphics_driver = OpenGl_GraphicDriver(self.display_connect) # Create viewer and view self._my_viewer = V3d_Viewer(graphics_driver) self._my_view = self._my_viewer.CreateView() # AIS interactive context self._my_context = AIS_InteractiveContext(self._my_viewer) # Initial settings self._my_viewer.SetDefaultLights() self._my_viewer.SetLightOn() self._my_view.SetBackgroundColor(Quantity_TOC_RGB, 0.5, 0.5, 0.5) self._my_context.SetDisplayMode(AIS_Shaded, True) self._my_drawer = self._my_context.DefaultDrawer() self._my_drawer.SetFaceBoundaryDraw(True) self._my_view.TriedronDisplay(Aspect_TOTP_LEFT_LOWER, self._black, 0.08) self._my_view.SetProj(V3d_TypeOfOrientation.V3d_XposYposZpos) # Events self.Bind(wx.EVT_PAINT, self._evt_paint) self.Bind(wx.EVT_SIZE, self._evt_size) self.Bind(wx.EVT_CHAR, self._evt_char) self.Bind(wx.EVT_CLOSE, self._evt_close) self.Bind(wx.EVT_MOUSE_EVENTS, self._evt_mouse_events) self.Bind(wx.EVT_MOUSEWHEEL, self._evt_mousewheel)
def tabletop(event=None): pcd_file = open(os.path.join('..', 'assets', 'models', 'tabletop.pcd'), 'r').readlines()[11:] # create the point_cloud pc = Graphic3d_ArrayOfPoints(len(pcd_file), True) for line in pcd_file: x, y, z, rgb = map(float, line.split()) r, g, b = unpackRGB(rgb) color = Quantity_Color(r / float(255), g / float(255), b / float(255), Quantity_TOC_RGB) pc.AddVertex(gp_Pnt(x, y, z), color) # then build the point cloud point_cloud = AIS_PointCloud() point_cloud.SetPoints(pc) # display ais_context = display.GetContext() ais_context.Display(point_cloud, True) display.DisableAntiAliasing() display.View_Iso() display.FitAll()
def display_shape(self, shape, rgb=None, transparency=None, material=Graphic3d_NOM_DEFAULT): """ Display a shape. :param OCCT.TopoDS.TopoDS_Shape shape: The shape. :param rgb: The RGB color (r, g, b). :type rgb: collections.Sequence[float] or OCCT.Quantity.Quantity_Color :param float transparency: The transparency (0 to 1). :param OCCT.Graphic3d.Graphic3d_NameOfMaterial material: The material. :return: The AIS_Shape created for the part. :rtype: OCCT.AIS.AIS_Shape """ ais_shape = AIS_Shape(shape) if isinstance(rgb, (tuple, list)): r, g, b = rgb if r > 1.: r /= 255. if g > 1.: g /= 255. if b > 1.: b /= 255. color = Quantity_Color(r, g, b, Quantity_TOC_RGB) ais_shape.SetColor(color) elif isinstance(rgb, Quantity_Color): ais_shape.SetColor(rgb) if transparency is not None: ais_shape.SetTransparency(transparency) ma = Graphic3d_MaterialAspect(material) ais_shape.SetMaterial(ma) self.my_context.Display(ais_shape, True) return ais_shape
def color_to_quantity_color(color): """ Convert an enaml color to an Quantity_Color. The result is cached. Parameters ---------- color: enaml.colors.Color The color to convert Returns ------- result: (Quantity_Color, float or None) A tuple of the color and transparency """ result = OCC_COLOR_CACHE.get(color.argb) if result is None: transparency = None if color.alpha == 255 else 1-color.alpha/255.0 occ_color = Quantity_Color( color.red/255., color.green/255., color.blue/255., Quantity_TOC_RGB) result = (occ_color, transparency) OCC_COLOR_CACHE[color.argb] = result return result
def color(r, g, b): return Quantity_Color(r, g, b, Quantity_TOC_RGB)
##Copyright 2017 Thomas Paviot ([email protected]) ## ##This file is part of pythonOCC. ## ##pythonOCC is free software: you can redistribute it and/or modify ##it under the terms of the GNU Lesser General Public License as published by ##the Free Software Foundation, either version 3 of the License, or ##(at your option) any later version. ## ##pythonOCC is distributed in the hope that it will be useful, ##but WITHOUT ANY WARRANTY; without even the implied warranty of ##MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ##GNU Lesser General Public License for more details. ## ##You should have received a copy of the GNU Lesser General Public License ##along with pythonOCC. If not, see <http://www.gnu.org/licenses/>. from OCC.Display.SimpleGui import init_display from OCCT.BRepPrimAPI import BRepPrimAPI_MakeBox from OCCT.Quantity import Quantity_Color, Quantity_NOC_ALICEBLUE, Quantity_NOC_ANTIQUEWHITE display, start_display, add_menu, add_function_to_menu = init_display() my_box = BRepPrimAPI_MakeBox(10., 20., 30.).Shape() display.View.SetBgGradientColors(Quantity_Color(Quantity_NOC_ALICEBLUE), Quantity_Color(Quantity_NOC_ANTIQUEWHITE), 2, True) display.Repaint() display.DisplayShape(my_box, update=True) start_display()
"Olá mundo": "Arial", # Portuguese "Здравствулте мир": "Microsoft Yahei", # Russian "Hola mundo": "Arial" # Spanish } arialbold_brep_string = text_to_brep("hello from pythonocc !", "Arial", Font_FA_Regular, 12., True) # Then display the string display.DisplayShape(arialbold_brep_string) for hello_str in hello: rndm_size = random.uniform(10., 16.) font = hello[hello_str] brep_string = text_to_brep(hello_str, font, Font_FA_Regular, rndm_size, True) rndm_extrusion_depth = random.uniform(8., 16.) rndm_extrusion_direction = gp_Vec(random.random(), random.random(), random.random()) extruded_string = make_extrusion(brep_string, rndm_extrusion_depth, rndm_extrusion_direction) rndm_pos = gp_Vec(random.random() * 100 - 50, random.random() * 100 - 50, random.random() * 100 - 50) rndm_color = Quantity_Color(random.random(), random.random(), random.random(), Quantity_TOC_RGB) trs_shp = translate_shp(extruded_string, rndm_pos) display.DisplayColoredShape(trs_shp, rndm_color) display.FitAll() start_display()
from OCCT.Xw import Xw_Window V3d_Window = Xw_Window V3D_VIEW_MODES = { 'top': V3d.V3d_Zpos, 'bottom': V3d.V3d_Zneg, 'left': V3d.V3d_Xneg, 'right': V3d.V3d_Xpos, 'front': V3d.V3d_Yneg, 'back': V3d.V3d_Ypos, 'iso': V3d.V3d_XposYnegZpos } V3D_DISPLAY_MODES = {'shaded': AIS_Shaded, 'wireframe': AIS_WireFrame} BLACK = Quantity_Color(Quantity_NOC_BLACK) WHITE = Quantity_Color(Quantity_NOC_WHITE) class QtViewer3d(QOpenGLWidget): def __init__(self, *args, **kwargs): super(QtViewer3d, self).__init__(*args, **kwargs) self._lock_rotation = False self._lock_zoom = False self._drawbox = None self._zoom_area = False self._select_area = False self._inited = False self._leftisdown = False self._middleisdown = False self._rightisdown = False
# first create geometry from core_classic_occ_bottle import bottle table = translate_shp( BRepPrimAPI_MakeBox(100, 100, 10).Shape(), gp_Vec(-50, -50, -10)) glass_out = BRepPrimAPI_MakeCone(7, 9, 25).Shape() glass_in = translate_shp( BRepPrimAPI_MakeCone(7, 9, 25).Shape(), gp_Vec(0., 0., 0.2)) glass = BRepAlgoAPI_Cut(glass_out, glass_in).Shape() translated_glass = translate_shp(glass, gp_Vec(-30, -30, 0)) # then inits display display, start_display, add_menu, add_function_to_menu = init_display() # create one spotlight spot_light = V3d_SpotLight(display.Viewer, -100, -100, 100, V3d_XnegYnegZpos, Quantity_Color(Quantity_NOC_WHITE)) ## display the spotlight in rasterized mode display.Viewer.AddLight(spot_light) display.View.SetLightOn() display.DisplayShape(bottle, material=Graphic3d_NOM_ALUMINIUM) display.DisplayShape(table, material=Graphic3d_NOM_PLASTIC, color=Quantity_NOC_CORAL2) display.DisplayShape(translated_glass, material=Graphic3d_NOM_PLASTIC, color=Quantity_NOC_BROWN, transparency=0.6, update=True)
##(at your option) any later version. ## ##pythonOCC is distributed in the hope that it will be useful, ##but WITHOUT ANY WARRANTY; without even the implied warranty of ##MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ##GNU Lesser General Public License for more details. ## ##You should have received a copy of the GNU Lesser General Public License ##along with pythonOCC. If not, see <http://www.gnu.org/licenses/>. from OCC.Extend.DataExchange import read_step_file_with_names_colors from OCCT.Quantity import Quantity_Color, Quantity_TOC_RGB from OCC.Display.SimpleGui import init_display filename = '../assets/models/as1-oc-214.stp' #filename = '../assets/models/Personal_Computer.stp' #filename = '../assets/models/KR600_R2830-4.stp' #filename = '../assets/models/mod-mpu9150.step' shapes_labels_colors = read_step_file_with_names_colors(filename) # init graphic display display, start_display, add_menu, add_function_to_menu = init_display() for shpt_lbl_color in shapes_labels_colors: label, c = shapes_labels_colors[shpt_lbl_color] display.DisplayColoredShape(shpt_lbl_color, color=Quantity_Color(c.Red(), c.Green(), c.Blue(), Quantity_TOC_RGB)) start_display()
def display_mesh(self, mesh, mode=2, group=None, display_nodes=False, node_size=1, node_color=(1, 1, 1), display_edges=True, edge_size=1, edge_color=(0.5, 0.5, 0.5), beam_size=2, beam_color=(1, 1, 0), face_color=(0, 0, 0.5), back_face_color=None): """ Display a mesh. :param mesh: The mesh. :type mesh: OCCT.SMESH_SMESH_Mesh or OCCT.SMESH_SMESH_subMesh :param int mode: Display mode for mesh elements (1=wireframe, 2=solid). :param group: Option to display a group of mesh elements. :type group: None or OCCT.SMESH.SMESH_Group group :param bool display_nodes: Option to display mesh nodes or not. If a group of nodes is provided, then this option is turned on by default. :param float node_size: An option to scale the size of the node markers. :param node_color: The RGB values for the node markers between 0 and 1. :type node_color: tuple(float, float, float) :param bool display_edges: An option to display the edges of faces and beams. :param float edge_size: An option to scale the size of the edges. :param edge_color: The RGB values for the edges between 0 and 1. :type edge_color: tuple(float, float, float) :param float beam_size: An option to scale the size of the beams. :param beam_color: The RGB values for the beams between 0 and 1. :type beam_color: tuple(float, float, float) :param face_color: The RGB values for the faces between 0 and 1. :type face_color: tuple(float, float, float) :param back_face_color: The RGB values of the back side of the faces between 0 and 1. If not provided, then the back faces are colored the same as the faces. :type back_face_color: None or tuple(float, float, float) :return: The MeshVS_Mesh created for the mesh. :rtype: OCCT.MeshVS.MeshVS_Mesh """ if not HAS_SMESH: raise NotImplementedError( 'SMESH was not found to support mesh visualization.') # Create the link if group: vs_link = SMESH_MeshVSLink(mesh, group) else: vs_link = SMESH_MeshVSLink(mesh) # Initialize mesh_vs = MeshVS_Mesh() mesh_vs.SetDataSource(vs_link) prs_builder = MeshVS_MeshPrsBuilder(mesh_vs) mesh_vs.AddBuilder(prs_builder) mesh_vs_drawer = mesh_vs.GetDrawer() # Node settings r, g, b = node_color color = Quantity_Color(r, g, b, Quantity_TOC_RGB) mesh_vs_drawer.SetColor(MeshVS_DrawerAttribute.MeshVS_DA_MarkerColor, color) mesh_vs_drawer.SetDouble(MeshVS_DrawerAttribute.MeshVS_DA_MarkerScale, node_size) # Always display nodes for a group of nodes if not group: mesh_vs_drawer.SetBoolean( MeshVS_DrawerAttribute.MeshVS_DA_DisplayNodes, display_nodes) elif group.GetGroupDS().GetType() == SMDSAbs_Node: mesh_vs_drawer.SetBoolean( MeshVS_DrawerAttribute.MeshVS_DA_DisplayNodes, True) # Edge settings r, g, b = edge_color color = Quantity_Color(r, g, b, Quantity_TOC_RGB) mesh_vs_drawer.SetColor(MeshVS_DrawerAttribute.MeshVS_DA_EdgeColor, color) mesh_vs_drawer.SetDouble(MeshVS_DrawerAttribute.MeshVS_DA_EdgeWidth, edge_size) mesh_vs_drawer.SetBoolean(MeshVS_DrawerAttribute.MeshVS_DA_ShowEdges, display_edges) # Beam settings r, g, b = beam_color color = Quantity_Color(r, g, b, Quantity_TOC_RGB) mesh_vs_drawer.SetColor(MeshVS_DrawerAttribute.MeshVS_DA_BeamColor, color) mesh_vs_drawer.SetDouble(MeshVS_DrawerAttribute.MeshVS_DA_BeamWidth, beam_size) # Face settings r, g, b = face_color color = Quantity_Color(r, g, b, Quantity_TOC_RGB) mesh_vs_drawer.SetColor(MeshVS_DrawerAttribute.MeshVS_DA_InteriorColor, color) if back_face_color: r, g, b = back_face_color color = Quantity_Color(r, g, b, Quantity_TOC_RGB) mesh_vs_drawer.SetColor( MeshVS_DrawerAttribute.MeshVS_DA_BackInteriorColor, color) # Display mode mesh_vs.SetDisplayMode(mode) self.my_context.Display(mesh_vs, True) return mesh_vs
ais_shp = display.DisplayShape(cylinder_head) # clip plane number one, by default xOy clip_plane_1 = Graphic3d_ClipPlane() # set hatch on clip_plane_1.SetCapping(True) clip_plane_1.SetCappingHatch(True) # off by default, user will have to enable it clip_plane_1.SetOn(False) # set clip plane color aMat = clip_plane_1.CappingMaterial() aColor = Quantity_Color(0.5, 0.6, 0.7, Quantity_TOC_RGB) aMat.SetAmbientColor(aColor) aMat.SetDiffuseColor(aColor) clip_plane_1.SetCappingMaterial(aMat) ais_shp.AddClipPlane(clip_plane_1) def enable_clip_plane(event=None): clip_plane_1.SetOn(True) display.Context.UpdateCurrentViewer() def disable_clip_plane(event=None): clip_plane_1.SetOn(False) display.Context.UpdateCurrentViewer()
def __init__(self, parent=None): super(QOpenCascadeWidget, self).__init__(parent) # Qt settings self.setBackgroundRole(QPalette.NoRole) self.setMouseTracking(True) # Values for mouse movement self._x0, self._y0 = 0., 0. # Some default settings self._white = Quantity_Color(Quantity_NOC_WHITE) self._black = Quantity_Color(Quantity_NOC_BLACK) # Display connection self.display_connect = Aspect_DisplayConnection() # Graphics driver self._graphics_driver = OpenGl_GraphicDriver(self.display_connect) # Create viewer and view self.my_viewer = V3d_Viewer(self._graphics_driver) self.my_view = self.my_viewer.CreateView() hwnd = self.winId() if sys.platform.startswith('win'): import ctypes from OCCT.WNT import WNT_Window ctypes.pythonapi.PyCapsule_New.restype = ctypes.py_object ctypes.pythonapi.PyCapsule_New.argtypes = [ ctypes.c_int, ctypes.c_void_p, ctypes.c_void_p ] hwnd = ctypes.pythonapi.PyCapsule_New(hwnd, None, None) window = WNT_Window(hwnd) elif sys.platform.startswith('darwin'): from OCCT.Cocoa import Cocoa_Window window = Cocoa_Window(hwnd) elif sys.platform.startswith('linux'): from OCCT.Xw import Xw_Window window = Xw_Window(self.display_connection, hwnd) else: raise NotImplementedError( 'Support platform not found for visualization.') self.wind = window self.my_view.SetWindow(self.wind) # Map window if not self.wind.IsMapped(): self.wind.Map() # AIS interactive context self.my_context = AIS_InteractiveContext(self.my_viewer) self.my_context.SetAutomaticHilight(True) self.my_viewer.SetDefaultLights() self.my_viewer.SetLightOn() self.my_view.SetBackgroundColor(Quantity_TOC_RGB, 0.5, 0.5, 0.5) self.my_context.SetDisplayMode(AIS_Shaded, True) self.my_drawer = self.my_context.DefaultDrawer() self.my_drawer.SetFaceBoundaryDraw(True) self.my_view.TriedronDisplay(Aspect_TOTP_RIGHT_LOWER, self._black, 0.08) self.my_view.SetProj(V3d_TypeOfOrientation.V3d_XposYposZpos) # Mesh display mode self._mesh_mode = 1
def face(): p1 = gp_Pnt() p2 = gp_Pnt() p3 = gp_Pnt() p4 = gp_Pnt() p5 = gp_Pnt() p6 = gp_Pnt() # The white Face sphere = gp_Sphere(gp_Ax3(gp_Pnt(0, 0, 0), gp_Dir(1, 0, 0)), 150) green_face = BRepBuilderAPI_MakeFace(sphere, 0.1, 0.7, 0.2, 0.9) # The red face p1.SetCoord(-15, 200, 10) p2.SetCoord(5, 204, 0) p3.SetCoord(15, 200, 0) p4.SetCoord(-15, 20, 15) p5.SetCoord(-5, 20, 0) p6.SetCoord(15, 20, 35) array = TColgp_Array2OfPnt(1, 3, 1, 2) array.SetValue(1, 1, p1) array.SetValue(2, 1, p2) array.SetValue(3, 1, p3) array.SetValue(1, 2, p4) array.SetValue(2, 2, p5) array.SetValue(3, 2, p6) curve = GeomAPI_PointsToBSplineSurface(array, 3, 8, GeomAbs_C2, 0.001).Surface() red_face = BRepBuilderAPI_MakeFace(curve, 1e-6) #The brown face circle = gp_Circ(gp_Ax2(gp_Pnt(0, 0, 0), gp_Dir(1, 0, 0)), 80) Edge1 = BRepBuilderAPI_MakeEdge(circle, 0, math.pi) Edge2 = BRepBuilderAPI_MakeEdge(gp_Pnt(0, 0, -80), gp_Pnt(0, -10, 40)) Edge3 = BRepBuilderAPI_MakeEdge(gp_Pnt(0, -10, 40), gp_Pnt(0, 0, 80)) ##TopoDS_Wire YellowWire MW1 = BRepBuilderAPI_MakeWire(Edge1.Edge(), Edge2.Edge(), Edge3.Edge()) if not MW1.IsDone(): raise AssertionError("MW1 is not done.") yellow_wire = MW1.Wire() brown_face = BRepBuilderAPI_MakeFace(yellow_wire) #The pink face p1.SetCoord(35, -200, 40) p2.SetCoord(50, -204, 30) p3.SetCoord(65, -200, 30) p4.SetCoord(35, -20, 45) p5.SetCoord(45, -20, 30) p6.SetCoord(65, -20, 65) array2 = TColgp_Array2OfPnt(1, 3, 1, 2) array2.SetValue(1, 1, p1) array2.SetValue(2, 1, p2) array2.SetValue(3, 1, p3) array2.SetValue(1, 2, p4) array2.SetValue(2, 2, p5) array2.SetValue(3, 2, p6) BSplineSurf = GeomAPI_PointsToBSplineSurface(array2, 3, 8, GeomAbs_C2, 0.001) aFace = BRepBuilderAPI_MakeFace(BSplineSurf.Surface(), 1e-6).Face() ## ##//2d lines P12d = gp_Pnt2d(0.9, 0.1) P22d = gp_Pnt2d(0.2, 0.7) P32d = gp_Pnt2d(0.02, 0.1) ## line1 = Geom2d_Line(P12d, gp_Dir2d((0.2 - 0.9), (0.7 - 0.1))) line2 = Geom2d_Line(P22d, gp_Dir2d((0.02 - 0.2), (0.1 - 0.7))) line3 = Geom2d_Line(P32d, gp_Dir2d((0.9 - 0.02), (0.1 - 0.1))) ## ##//Edges are on the BSpline surface Edge1 = BRepBuilderAPI_MakeEdge(line1, BSplineSurf.Surface(), 0, P12d.Distance(P22d)).Edge() Edge2 = BRepBuilderAPI_MakeEdge(line2, BSplineSurf.Surface(), 0, P22d.Distance(P32d)).Edge() Edge3 = BRepBuilderAPI_MakeEdge(line3, BSplineSurf.Surface(), 0, P32d.Distance(P12d)).Edge() ## Wire1 = BRepBuilderAPI_MakeWire(Edge1, Edge2, Edge3).Wire() Wire1.Reverse() pink_face = BRepBuilderAPI_MakeFace(aFace, Wire1).Face() breplib_BuildCurves3d(pink_face) display.DisplayColoredShape(green_face.Face(), 'GREEN') display.DisplayColoredShape(red_face.Face(), 'RED') display.DisplayColoredShape(pink_face, Quantity_Color(Quantity_NOC_PINK)) display.DisplayColoredShape(brown_face.Face(), 'BLUE') display.DisplayColoredShape(yellow_wire, 'YELLOW', update=True)