Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6699479
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T06:42:00+00:00 2026-05-26T06:42:00+00:00

I want to display a surface which is textured. I want the triangles boundaries

  • 0

I want to display a surface which is textured. I want the triangles boundaries to be visible over the surface in a different color (lets say red). I have found the following code from the vtk code samples but it does not display the triangle boundaries but the filled triangles.

   import vtk

   # create a rendering window and renderer
   ren = vtk.vtkRenderer()
   renWin = vtk.vtkRenderWindow()
   renWin.AddRenderer(ren)

   # create a renderwindowinteractor
   iren = vtk.vtkRenderWindowInteractor()
   iren.SetRenderWindow(renWin)

   # create points
   points = vtk.vtkPoints()
   points.InsertNextPoint(1.0,0.0,0.0)
   points.InsertNextPoint(0.0,0.0,0.0)
   points.InsertNextPoint(0.0,1.0,0.0)

   triangle = vtk.vtkTriangle()
   triangle.GetPointIds().SetId(0,0)
   triangle.GetPointIds().SetId(1,1)
   triangle.GetPointIds().SetId(2,2)

   triangles = vtk.vtkCellArray()
   triangles.InsertNextCell(triangle)

   # polydata object
   trianglePolyData = vtk.vtkPolyData()
   trianglePolyData.SetPoints( points )
   trianglePolyData.SetPolys( triangles )

   # mapper
   mapper = vtk.vtkPolyDataMapper()
   mapper.SetInput(trianglePolyData)

   # actor
   actor = vtk.vtkActor()
   actor.SetMapper(mapper)

   # assign actor to the renderer
   ren.AddActor(actor)

   # enable user interface interactor
   iren.Initialize()
   renWin.Render()
   iren.Start()

Can anybody please let me know that how to display triangle only with the boundaries with a specific color.

I ideally i want to display triangles on a textured surface. My data consist of triangles. It might also be possible that the vertices of the triangles which are given to vtk can be made visible.

I am coding in python.

Thanks a lot

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T06:42:00+00:00Added an answer on May 26, 2026 at 6:42 am

    You need to extract the edges from your vtkPolyData object:

    edges = vtk.vtkExtractEdges()
    edges.SetInput(trianglePolyData)
    edge_mapper = vtk.vtkPolyDataMapper()
    edge_mapper.SetInput(edges.GetOutput())
    
    edge_actor = vtk.vtkActor()
    edge_actor.SetMapper(edge_mapper)
    edge_actor.GetProperty().SetColor(1,0,0)
    
    ren.AddActor(edge_actor)
    
    vtk.vtkPolyDataMapper().SetResolveCoincidentTopologyToPolygonOffset()
    

    First you must extract the edges via a vtkExtractEdges filter. You map the results of that filter to a vtkPolyData object and construct an actor for that data. We then set the color of the mesh to red by modifying the actor directly.

    The call to vtk.vtkPolyDataMapper().SetResolveCoincidentTopologyToPolygonOffset() prevents the edges from fighting with the surfaces (the two geometric objects are coincident and tear through each other due to z-buffer precision issues).

    For completeness sake, here’s the whole code:

    import vtk
    
    # create a rendering window and renderer
    ren = vtk.vtkRenderer()
    renWin = vtk.vtkRenderWindow()
    renWin.AddRenderer(ren)
    
    # create a renderwindowinteractor
    iren = vtk.vtkRenderWindowInteractor()
    iren.SetRenderWindow(renWin)
    
    # create points
    points = vtk.vtkPoints()
    points.InsertNextPoint(1.0,0.0,0.0)
    points.InsertNextPoint(0.0,0.0,0.0)
    points.InsertNextPoint(0.0,1.0,0.0)
    
    triangle = vtk.vtkTriangle()
    triangle.GetPointIds().SetId(0,0)
    triangle.GetPointIds().SetId(1,1)
    triangle.GetPointIds().SetId(2,2)
    
    triangles = vtk.vtkCellArray()
    triangles.InsertNextCell(triangle)
    
    # polydata object
    trianglePolyData = vtk.vtkPolyData()
    trianglePolyData.SetPoints( points )
    trianglePolyData.SetPolys( triangles )
    
    # mapper
    mapper = vtk.vtkPolyDataMapper()
    mapper.SetInput(trianglePolyData)
    
    # actor
    actor = vtk.vtkActor()
    actor.SetMapper(mapper)
    
    # assign actor to the renderer
    ren.AddActor(actor)
    
    #++++++++++++++++++++++++++++++++++++++++++++++++
    # Get the edges from the mesh
    edges = vtk.vtkExtractEdges()
    edges.SetInput(trianglePolyData)
    edge_mapper = vtk.vtkPolyDataMapper()
    edge_mapper.SetInput(edges.GetOutput())
    
    # Make an actor for those edges    
    edge_actor = vtk.vtkActor()
    edge_actor.SetMapper(edge_mapper)
    
    # Make the actor red (there are other ways of doing this also)
    edge_actor.GetProperty().SetColor(1,0,0)
    
    ren.AddActor(edge_actor)
    
    # Avoid z-buffer fighting
    vtk.vtkPolyDataMapper().SetResolveCoincidentTopologyToPolygonOffset()
    #------------------------------------------------
    
    # enable user interface interactor
    iren.Initialize()
    renWin.Render()
    iren.Start()
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have one SurfaceView for which I want to display a border of 20dp
I have this XML i want display all fields on the uiview which comes
I have a simple quiz application and I want display a nice timer /
I have db with this table (TableToDo): http://goo.gl/NlTEk I want display all records in
I want to display the number say 1 to 100 by selecting a item
I want to display three different values allocated to two different headers, in other
I have rails 3.2.1 and to test JQuery UI, i want display a DatePicker.
I have a problem with my datatable, I want display the information of a
Description I have an activity which displays the camera preview on a surface view.
I have two surface Views 1> MediaRecorder display surfaceview. 2> MediaPlayer SurfaceView displaying the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.