Exemple #1
0
    def display_shape(self, shape, rgb=None, transparency=None, material=None):
        """
        Display a shape.
        :param OCC.Core.TopoDS.TopoDS_Shape shape: The shape.
        :param rgb: The RGB color (r, g, b).
        :type rgb: collections.Sequence(float) or OCC.Core.Quantity.Quantity_Color
        :param float transparency: The transparency (0 to 1).
        :param OCC.Core.Graphic3d.Graphic3d_NameOfMaterial material: The material.
        :return: The AIS_Shape created for the part.
        :rtype: OCC.Core.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)

        if material is not None:
            ma = Graphic3d_MaterialAspect(material)
            ais_shape.SetMaterial(ma)

        self._my_context.Display(ais_shape, True)
        return ais_shape
Exemple #2
0
 def renderShapeObj(self, shape, transforms, styleName):
     color, transparency, materialName = self.getStyle(styleName)
     trsf = gp_Trsf()
     for tr in transforms:
         trsf *= tr.getTrsf()
     shape =  BRepBuilderAPI_Transform(shape, trsf).Shape()
     ais = AIS_Shape(shape)
     r,g,b = color
     aisColor =  Quantity_Color(r/256, g/256, b/256, Quantity_TypeOfColor(Quantity_TypeOfColor.Quantity_TOC_RGB))
     ais.SetColor(aisColor)
     ais.SetTransparency(transparency/100)
     aspect = Graphic3d_MaterialAspect(getMaterialNameConst(materialName))
     ais.SetMaterial(aspect)
     self.display.Context.Display(ais, False)
Exemple #3
0
 def _renderShapeObj(self, aShape):
     shapeTr = BRepBuilderAPI_Transform(aShape,
                                        self.aMove.getTrsf()).Shape()
     ais = AIS_Shape(shapeTr)
     r, g, b = self.aStyle.getNormedColor()
     aisColor = Quantity_Color(
         r, g, b,
         Quantity_TypeOfColor(Quantity_TypeOfColor.Quantity_TOC_RGB))
     ais.SetColor(aisColor)
     ais.SetTransparency(self.aStyle.getNormedTransparency())
     aspect = Graphic3d_MaterialAspect(
         MATERIAL_CONSTS[self.aStyle.getMaterial()])
     ais.SetMaterial(aspect)
     self.display.Context.Display(ais, False)
Exemple #4
0
 def Display(self, context, material=Graphic3d_NOM_ALUMINIUM, color=None):
     print("display-Part")
     for name, component in self.items():
         ais = AIS_Shape(component)
         ais.SetMaterial(material)
         if color:
             try:
                 from OCC.Display.OCCViewer import get_color_from_name
                 color = get_color_from_name(color)
             except:
                 pass
             ais.SetColor(color)
         try:
             context.Context.Display(ais)
             #context.register_select_callback(print_xy_click)
         except:
             context.DisplayShape(component)