Ejemplo n.º 1
0
    def draw_color_image(self, with_vertex_colors=True, with_texture_on=True):
        self._call_on_changed()
        gl = self.glf
        gl.Clear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

        if with_texture_on:
            self.texture_mapping_on(gl, with_vertex_colors)
            gl.TexCoordPointerf(2,0, self.mesh_tex_coords.ravel())
        else:
            self.texture_mapping_off(gl)

        colors = None
        if with_vertex_colors:
            colors = self.vc.r.reshape((-1,3))[self.f.ravel()]
        draw_colored_primitives(self.glf, self.v.r.reshape((-1,3)), self.f, colors)

        self.texture_mapping_off(gl)
        result =  np.asarray(deepcopy(gl.getImage()), np.float64)

        if hasattr(self, 'background_image'):
            bg_px = np.tile(np.atleast_3d(self.visibility_image) == 4294967295, (1,1,3))
            fg_px = 1 - bg_px
            result = bg_px * self.background_image + fg_px * result

        return result
Ejemplo n.º 2
0
    def draw_color_image(self, with_vertex_colors=True, with_texture_on=True):
        self._call_on_changed()
        gl = self.glf
        gl.Clear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)

        if with_texture_on:
            self.texture_mapping_on(gl, with_vertex_colors)
            gl.TexCoordPointerf(2, 0, self.mesh_tex_coords.ravel())
        else:
            self.texture_mapping_off(gl)

        colors = None
        if with_vertex_colors:
            colors = self.vc.r.reshape((-1, 3))[self.f.ravel()]
        draw_colored_primitives(self.glf, self.v.r.reshape((-1, 3)), self.f,
                                colors)

        self.texture_mapping_off(gl)
        result = np.asarray(deepcopy(gl.getImage()), np.float64)

        if hasattr(self, 'background_image'):
            bg_px = np.tile(
                np.atleast_3d(self.visibility_image) == 4294967295, (1, 1, 3))
            fg_px = 1 - bg_px
            result = bg_px * self.background_image + fg_px * result

        return result
Ejemplo n.º 3
0
 def boundarycolor_image(self):
     self._call_on_changed()
     gl = self.glf
     colors = self.vc.r.reshape((-1,3))[self.vpe.ravel()]
     gl.Clear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
     draw_colored_primitives(gl, self.v.r.reshape((-1,3)), self.vpe, colors)
     return np.asarray(deepcopy(gl.getImage()), np.float64)
Ejemplo n.º 4
0
 def boundarycolor_image(self):
     self._call_on_changed()
     gl = self.glf
     colors = self.vc.r.reshape((-1,3))[self.vpe.ravel()]
     gl.Clear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
     draw_colored_primitives(gl, self.v.r.reshape((-1,3)), self.vpe, colors)
     return np.asarray(deepcopy(gl.getImage()), np.float64)
Ejemplo n.º 5
0
 def boundarycolor_image(self):
     self._call_on_changed()
     gl = self.glf
     colors = self.vc.r.reshape((-1,3))[self.vpe.ravel()]
     gl.Clear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
     self.texture_mapping_on(gl, with_vertex_colors=False if colors is None else True)
     gl.TexCoordPointerf(2,0, self.wireframe_tex_coords.ravel())
     draw_colored_primitives(self.glf, self.v.r.reshape((-1,3)), self.vpe, colors)
     self.texture_mapping_off(gl)
     return np.asarray(deepcopy(gl.getImage()), np.float64)
Ejemplo n.º 6
0
 def boundarycolor_image(self):
     self._call_on_changed()
     gl = self.glf
     colors = self.vc.r.reshape((-1,3))[self.vpe.ravel()]
     gl.Clear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
     self.texture_mapping_on(gl, with_vertex_colors=False if colors is None else True)
     gl.TexCoordPointerf(2,0, self.wireframe_tex_coords.ravel())
     draw_colored_primitives(self.glf, self.v.r.reshape((-1,3)), self.vpe, colors)
     self.texture_mapping_off(gl)
     return np.asarray(deepcopy(gl.getImage()), np.float64)
Ejemplo n.º 7
0
def draw_edge_visibility(gl, v, e, f, hidden_wireframe=True):
    """Assumes camera is set up correctly in gl context."""
    gl.Clear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)

    ec = np.arange(1, len(e) + 1)
    ec = np.tile(col(ec), (1, 3))
    ec[:, 0] = ec[:, 0] & 255
    ec[:, 1] = (ec[:, 1] >> 8) & 255
    ec[:, 2] = (ec[:, 2] >> 16) & 255
    ec = np.asarray(ec, dtype=np.uint8)

    draw_colored_primitives(gl, v, e, ec)

    if hidden_wireframe:
        gl.Enable(GL_POLYGON_OFFSET_FILL)
        gl.PolygonOffset(10.0, 1.0)
        draw_colored_primitives(gl, v, f, fc=np.zeros(f.shape))
        gl.Disable(GL_POLYGON_OFFSET_FILL)

    raw = np.asarray(gl.getImage(), np.uint32)
    raw = raw[:, :, 0] + raw[:, :, 1] * 256 + raw[:, :, 2] * 256 * 256 - 1
    return raw
Ejemplo n.º 8
0
def draw_edge_visibility(gl, v, e, f, hidden_wireframe=True):
    """Assumes camera is set up correctly in gl context."""
    gl.Clear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

    ec = np.arange(1, len(e)+1)
    ec = np.tile(col(ec), (1, 3))
    ec[:, 0] = ec[:, 0] & 255
    ec[:, 1] = (ec[:, 1] >> 8 ) & 255
    ec[:, 2] = (ec[:, 2] >> 16 ) & 255
    ec = np.asarray(ec, dtype=np.uint8)
    
    draw_colored_primitives(gl, v, e, ec)
    
    if hidden_wireframe:
        gl.Enable(GL_POLYGON_OFFSET_FILL)
        gl.PolygonOffset(10.0, 1.0)
        draw_colored_primitives(gl, v, f, fc=np.zeros(f.shape))
        gl.Disable(GL_POLYGON_OFFSET_FILL)
    
    raw = np.asarray(gl.getImage(), np.uint32)
    raw = raw[:,:,0] + raw[:,:,1]*256 + raw[:,:,2]*256*256 - 1
    return raw