CFD Online Discussion Forums

CFD Online Discussion Forums (http://www.cfd-online.com/Forums/)
-   OpenFOAM Native Meshers: snappyHexMesh and Others (http://www.cfd-online.com/Forums/openfoam-meshing-snappyhexmesh/)
-   -   GUI for surfaceFeatureExtract (http://www.cfd-online.com/Forums/openfoam-meshing-snappyhexmesh/109178-gui-surfacefeatureextract.html)

elvis November 11, 2012 10:34

GUI for surfaceFeatureExtract
 
5 Attachment(s)
Hi,

I am experimenting with a GUI (pyvtk) to get a feeling which "-includedAngle" would make sense.

PHP Code:

#!/usr/bin/env python
import vtk

def callback
(objevent):
    global 
featureedges
    sliValue 
obj.GetValue()
    
featureedges.SetFeatureAngle(mathslider.Round(sliValue))

reader vtk.vtkOBJReader()
#reader.SetFileName("/home/opencfd/pyscript/propellerTip.obj")
reader.SetFileName("/home/opencfd/pyscript/motorBike.obj")

#reader = vtk.vtkSTLReader()
#reader.SetFileName("/home/opencfd/pyscript/bullet.stl")
reader.Update()

mapper1 vtk.vtkPolyDataMapper()
mapper1.SetInputConnection(reader.GetOutputPort())#just visualizing without FeatureEdges stuff
actor1 vtk.vtkActor()
actor1.SetMapper(mapper1)
actor1.GetProperty().SetOpacity(0.1)# better slider

featureedges vtk.vtkFeatureEdges()
featureedges.SetInputConnection(reader.GetOutputPort())
#featureedges.SetFeatureAngle(130) ###slider (default is 30) 
featureedges.BoundaryEdgesOff()
featureedges.ManifoldEdgesOff()
featureedges.NonManifoldEdgesOff()

mapper vtk.vtkPolyDataMapper()
mapper.SetInputConnection(featureedges.GetOutputPort())
actor vtk.vtkActor()
actor.SetMapper(mapper)

ren vtk.vtkRenderer()
renWin vtk.vtkRenderWindow()
renWin.AddRenderer(ren)
iren vtk.vtkRenderWindowInteractor()
iren.SetRenderWindow(renWin)

mathslider vtk.vtkMath()#mathslider.Round(sliderRep.GetValue())

#sliderRep
sliderRep vtk.vtkSliderRepresentation2D()
sliderRep.SetTitleText("FeatureAngle")
sliderRep.GetTitleProperty().SetColor(0,1,0)
sliderRep.GetTitleProperty().ShadowOff()
sliderRep.GetSliderProperty().SetColor(0,0,1)
sliderRep.GetTubeProperty().SetColor(1,0,0)
sliderRep.GetCapProperty().SetColor(1,1,.5)
sliderRep.GetPoint1Coordinate().SetCoordinateSystemToNormalizedDisplay() 
sliderRep.GetPoint1Coordinate().SetValue(0.20.1)
sliderRep.GetPoint2Coordinate().SetCoordinateSystemToNormalizedDisplay() 
sliderRep.GetPoint2Coordinate().SetValue(0.80.1)
sliderRep.SetLabelFormat("%4.0lf")
#sliderRep.SetMinimumValue(0.5)
sliderRep.SetMaximumValue(180)#155
sliderRep.SetValue(1)

#sliderWidget
sliderWidget vtk.vtkCenteredSliderWidget()
#sliderWidget = vtk.vtkSliderWidget()
sliderWidget.SetInteractor(iren)
sliderWidget.SetRepresentation(sliderRep#passt
#sliderWidget.KeyPressActivationOff() #
#sliderWidget.SetAnimationModeToAnimate()#ob das gut ist
sliderWidget.AddObserver("InteractionEvent"callback)
#sliderWidget.On()
#featureedges.SetFeatureAngle(sliderRep.GetValue())#mathslider.Round(sliderRep.GetValue())

ren.AddActor(actor)
ren.AddActor(actor1)
ren.SetBackground(.2.2.2)
renWin.SetSize(500500)
iren.Initialize()
renWin.Render()
sliderWidget.On()
iren.Start() 

you need "python-vtk" to get it run, hope someone finds it useful! I hoped "vtkSliderWidget()" would work for the script, unfortunatly only "vtkCenteredSliderWidget()" works partually

misklach November 29, 2012 08:12

Hi, I tried your script and it is very useful! Thank you very much for sharing!!


All times are GMT -4. The time now is 17:35.