Python vtk.vtkTriangleFilter() Examples

The following are 10 code examples of vtk.vtkTriangleFilter(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module vtk , or try the search function .
Example #1
Source File: mesh.py    From OpenWARP with Apache License 2.0 6 votes vote down vote up
def volume_vtk(self):
        if self.VTK_installed is False:
            raise VTK_Exception('VTK must be installed to access the volume_vtk property')

        if self._volume_vtk is None:
            tri_converter = vtk.vtkTriangleFilter()
            tri_converter.SetInputDataObject(self.vtp_mesh)
            tri_converter.Update()
            tri_mesh = tri_converter.GetOutput()
            mass_props = vtk.vtkMassProperties()
            mass_props.SetInputDataObject(tri_mesh)
            self._volume_vtk = mass_props.GetVolume()

            print 'Calculated mesh volume using VTK library'

        return self._volume_vtk 
Example #2
Source File: mesh.py    From OpenWARP with Apache License 2.0 6 votes vote down vote up
def volume_vtk(self):
        if self.VTK_installed is False:
            raise VTK_Exception('VTK must be installed to access the volume_vtk property')

        if self._volume_vtk is None:
            tri_converter = vtk.vtkTriangleFilter()
            tri_converter.SetInputDataObject(self.vtp_mesh)
            tri_converter.Update()
            tri_mesh = tri_converter.GetOutput()
            mass_props = vtk.vtkMassProperties()
            mass_props.SetInputDataObject(tri_mesh)
            self._volume_vtk = mass_props.GetVolume()

            print 'Calculated mesh volume using VTK library'

        return self._volume_vtk 
Example #3
Source File: mesh.py    From OpenWARP with Apache License 2.0 6 votes vote down vote up
def volume_vtk(self):
        if self.VTK_installed is False:
            raise VTK_Exception('VTK must be installed to access the volume_vtk property')

        if self._volume_vtk is None:
            tri_converter = vtk.vtkTriangleFilter()
            tri_converter.SetInputDataObject(self.vtp_mesh)
            tri_converter.Update()
            tri_mesh = tri_converter.GetOutput()
            mass_props = vtk.vtkMassProperties()
            mass_props.SetInputDataObject(tri_mesh)
            self._volume_vtk = mass_props.GetVolume()

            print 'Calculated mesh volume using VTK library'

        return self._volume_vtk 
Example #4
Source File: mesh.py    From OpenWARP with Apache License 2.0 6 votes vote down vote up
def volume_vtk(self):
        if self.VTK_installed is False:
            raise VTK_Exception('VTK must be installed to access the volume_vtk property')

        if self._volume_vtk is None:
            tri_converter = vtk.vtkTriangleFilter()
            tri_converter.SetInputDataObject(self.vtp_mesh)
            tri_converter.Update()
            tri_mesh = tri_converter.GetOutput()
            mass_props = vtk.vtkMassProperties()
            mass_props.SetInputDataObject(tri_mesh)
            self._volume_vtk = mass_props.GetVolume()

            print 'Calculated mesh volume using VTK library'

        return self._volume_vtk 
Example #5
Source File: Delaunay3D.py    From pcloudpy with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def update(self):
        delaunay = vtkDelaunay3D()
        delaunay.SetInput(self.input_)
        delaunay.SetTolerance(self.tolerance)
        delaunay.SetAlpha(self.alpha)
        delaunay.Update()

        geom = vtkGeometryFilter()
        geom.SetInputConnection(delaunay.GetOutputPort() )

        triangle = vtkTriangleFilter()
        triangle.SetInputConnection(geom.GetOutputPort())
        triangle.Update()
        self.output_ = triangle.GetOutput() 
Example #6
Source File: geometric_objects.py    From pyvista with MIT License 5 votes vote down vote up
def Text3D(string, depth=0.5):
    """Create 3D text from a string."""
    vec_text = vtk.vtkVectorText()
    vec_text.SetText(string)

    extrude = vtk.vtkLinearExtrusionFilter()
    extrude.SetInputConnection(vec_text.GetOutputPort())
    extrude.SetExtrusionTypeToNormalExtrusion()
    extrude.SetVector(0, 0, 1)
    extrude.SetScaleFactor(depth)

    tri_filter = vtk.vtkTriangleFilter()
    tri_filter.SetInputConnection(extrude.GetOutputPort())
    tri_filter.Update()
    return pyvista.wrap(tri_filter.GetOutput()) 
Example #7
Source File: filters.py    From pyvista with MIT License 5 votes vote down vote up
def triangulate(poly_data, inplace=False):
        """Return an all triangle mesh.

        More complex polygons will be broken down into tetrahedrals.

        Parameters
        ----------
        inplace : bool, optional
            Updates mesh in-place while returning nothing.

        Return
        ------
        mesh : pyvista.PolyData
            Mesh containing only triangles.  None when inplace=True

        """
        trifilter = vtk.vtkTriangleFilter()
        trifilter.SetInputData(poly_data)
        trifilter.PassVertsOff()
        trifilter.PassLinesOff()
        trifilter.Update()

        mesh = _get_output(trifilter)
        if inplace:
            poly_data.overwrite(mesh)
        else:
            return mesh 
Example #8
Source File: mesh.py    From OpenWARP with Apache License 2.0 5 votes vote down vote up
def surface_area_vtk(self):
        if self.VTK_installed is False:
            raise VTK_Exception('VTK must be installed to access the surface_area_vtk property')
        if self._surface_area_vtk is None:
            tri_converter = vtk.vtkTriangleFilter()
            tri_converter.SetInputDataObject(self.vtp_mesh)
            tri_converter.Update()
            tri_mesh = tri_converter.GetOutput()
            mass_props = vtk.vtkMassProperties()
            mass_props.SetInputDataObject(tri_mesh)
            self._surface_area_vtk = mass_props.GetSurfaceArea()

            print 'Calculated mesh surface area using VTK Python bindings'

        return self._surface_area_vtk 
Example #9
Source File: mesh.py    From OpenWARP with Apache License 2.0 5 votes vote down vote up
def surface_area_vtk(self):
        if self.VTK_installed is False:
            raise VTK_Exception('VTK must be installed to access the surface_area_vtk property')
        if self._surface_area_vtk is None:
            tri_converter = vtk.vtkTriangleFilter()
            tri_converter.SetInputDataObject(self.vtp_mesh)
            tri_converter.Update()
            tri_mesh = tri_converter.GetOutput()
            mass_props = vtk.vtkMassProperties()
            mass_props.SetInputDataObject(tri_mesh)
            self._surface_area_vtk = mass_props.GetSurfaceArea()

            print 'Calculated mesh surface area using VTK Python bindings'

        return self._surface_area_vtk 
Example #10
Source File: mesh.py    From OpenWARP with Apache License 2.0 5 votes vote down vote up
def surface_area_vtk(self):
        if self.VTK_installed is False:
            raise VTK_Exception('VTK must be installed to access the surface_area_vtk property')
        if self._surface_area_vtk is None:
            tri_converter = vtk.vtkTriangleFilter()
            tri_converter.SetInputDataObject(self.vtp_mesh)
            tri_converter.Update()
            tri_mesh = tri_converter.GetOutput()
            mass_props = vtk.vtkMassProperties()
            mass_props.SetInputDataObject(tri_mesh)
            self._surface_area_vtk = mass_props.GetSurfaceArea()

            print 'Calculated mesh surface area using VTK Python bindings'

        return self._surface_area_vtk