def BuildBackdrop(minX, maxX, minY, maxY, minZ, maxZ, thickness): global basePlane global baseMapper global base global backPlane global backMapper global back global left global leftPlane global leftMapper if not basePlane: basePlane = svtk.svtkCubeSource() basePlane.SetCenter((maxX + minX) / 2.0, minY, (maxZ + minZ) / 2.0) basePlane.SetXLength(maxX - minX) basePlane.SetYLength(thickness) basePlane.SetZLength(maxZ - minZ) if not baseMapper: baseMapper = svtk.svtkPolyDataMapper() baseMapper.SetInputConnection(basePlane.GetOutputPort()) if not base: base = svtk.svtkActor() base.SetMapper(baseMapper) if not backPlane: backPlane = svtk.svtkCubeSource() backPlane.SetCenter((maxX + minX) / 2.0, (maxY + minY) / 2.0, minZ) backPlane.SetXLength(maxX - minX) backPlane.SetYLength(maxY - minY) backPlane.SetZLength(thickness) if not backMapper: backMapper = svtk.svtkPolyDataMapper() backMapper.SetInputConnection(backPlane.GetOutputPort()) if not back: back = svtk.svtkActor() back.SetMapper(backMapper) if not leftPlane: leftPlane = svtk.svtkCubeSource() leftPlane.SetCenter(minX, (maxY + minY) / 2.0, (maxZ + minZ) / 2.0) leftPlane.SetXLength(thickness) leftPlane.SetYLength(maxY - minY) leftPlane.SetZLength(maxZ - minZ) if not leftMapper: leftMapper = svtk.svtkPolyDataMapper() leftMapper.SetInputConnection(leftPlane.GetOutputPort()) if not left: left = svtk.svtkActor() left.SetMapper(leftMapper) return [base, back, left]
# Mappers mapper = svtk.svtkDataSetMapper() mapper.SetInputConnection(shrink.GetOutputPort()) shrink.Update() dataRange = shrink.GetOutput().GetCellData().GetArray('scalar').GetRange() print('DataRange (after shrink): ', dataRange) mapper.SetLookupTable(lut) mapper.SetColorModeToMapScalars() mapper.SetScalarModeToUseCellFieldData() mapper.SelectColorArray('scalar') mapper.SetScalarRange(dataRange[0], dataRange[1]) # Actors actor = svtk.svtkActor() actor.SetMapper(mapper) # Camera bd = htg.GetBounds() camera = svtk.svtkCamera() camera.SetClippingRange(1., 100.) focal = [] for i in range(3): focal.append(bd[ 2 * i ] + (bd[ 2 * i + 1 ] - bd[ 2 * i]) / 2.) camera.SetFocalPoint(focal) camera.SetPosition(focal[0], focal[1], focal[2] + 4.) # Renderer renderer = svtk.svtkRenderer() renderer.SetActiveCamera(camera)
t1.SetInput(m1) m1.SetElement(0, 0, 1.127631) m1.SetElement(0, 1, 0.205212) m1.SetElement(0, 2, -0.355438) m1.SetElement(1, 0, 0.000000) m1.SetElement(1, 1, 0.692820) m1.SetElement(1, 2, 0.400000) m1.SetElement(2, 0, 0.200000) m1.SetElement(2, 1, -0.469846) m1.SetElement(2, 2, 0.813798) f11 = svtk.svtkTransformPolyDataFilter() f11.SetInputConnection(ap.GetOutputPort()) f11.SetTransform(t1) m11 = svtk.svtkDataSetMapper() m11.SetInputConnection(f11.GetOutputPort()) a11 = svtk.svtkActor() a11.SetMapper(m11) a11.GetProperty().SetColor(1, 0, 0) a11.GetProperty().SetRepresentationToWireframe() ren11 = svtk.svtkRenderer() ren11.SetViewport(0.0, 0.5, 0.25, 1.0) ren11.ResetCamera(-0.5, 0.5, -0.5, 0.5, -1, 1) ren11.AddActor(a11) renWin.AddRenderer(ren11) # inverse identity transform f12 = svtk.svtkTransformPolyDataFilter() f12.SetInputConnection(ap.GetOutputPort()) f12.SetTransform(t1.GetInverse()) m12 = svtk.svtkDataSetMapper() m12.SetInputConnection(f12.GetOutputPort()) a12 = svtk.svtkActor()
points.InsertPoint(11, 0, 0.5, 0) points.InsertPoint(12, 0.5, 0.5, 0) i = 0 while i < 13: aConvex.GetPointIds().InsertId(i, i) i += 1 aConvexGrid = svtk.svtkUnstructuredGrid() aConvexGrid.Allocate(1, 1) aConvexGrid.InsertNextCell(aConvex.GetCellType(), aConvex.GetPointIds()) aConvexGrid.SetPoints(points) # Display the cell dsm = svtk.svtkDataSetMapper() dsm.SetInputData(aConvexGrid) a = svtk.svtkActor() a.SetMapper(dsm) a.GetProperty().SetColor(0, 1, 0) # Contour and clip the cell with elevation scalars ele = svtk.svtkElevationFilter() ele.SetInputData(aConvexGrid) ele.SetLowPoint(-1, -1, -1) ele.SetHighPoint(1, 1, 1) ele.SetScalarRange(-1, 1) # Clip # clip = svtk.svtkClipDataSet() clip.SetInputConnection(ele.GetOutputPort()) clip.SetValue(0.5)
lut.UsingLogScale() lut.Build() # Mappers mapper = svtk.svtkDataSetMapper() mapper.SetInputConnection(geometry.GetOutputPort()) mapper.SetLookupTable(lut) mapper.SetColorModeToMapScalars() mapper.SetScalarModeToUseCellFieldData() mapper.SelectColorArray('scalar') dataRange = [1, 53] # Forced for compare with 3DMask mapper.SetScalarRange(dataRange[0], dataRange[1]) # Actors actor1 = svtk.svtkActor() actor1.SetMapper(mapper) actor2 = svtk.svtkActor() actor2.SetMapper(mapper) actor2.GetProperty().SetColor(0, 0, 0) actor2.GetProperty().SetRepresentationToWireframe() # Camera bd = htg.GetBounds() camera = svtk.svtkCamera() camera.SetClippingRange(1., 100.) focal = [] for i in range(3): focal.append(bd[2 * i] + (bd[2 * i + 1] - bd[2 * i]) / 2.) camera.SetFocalPoint(focal)
sphere = svtk.svtkSphereSource() sphere.SetRadius(1.0) sphere.Update() glyphs = svtk.svtkGlyph3D() glyphs.ScalingOn() glyphs.SetColorModeToColorByScalar() glyphs.SetScaleModeToScaleByScalar() glyphs.SetScaleFactor(1) glyphs.SetInputData(aPolyVertexGrid) glyphs.SetSourceConnection(sphere.GetOutputPort()) glyphs.SetInputArrayToProcess(0, 0, 0, 0, "Sizes") glyphs.SetInputArrayToProcess(3, 0, 0, 0, "Colors") #puts [ glyphs GetScaleModeAsString] glyphsMapper = svtk.svtkDataSetMapper() glyphsMapper.SetInputConnection(glyphs.GetOutputPort()) glyphsActor = svtk.svtkActor() glyphsActor.SetMapper(glyphsMapper) glyphsActor.GetProperty().BackfaceCullingOn() ren1.SetBackground(.1, .2, .4) ren1.AddActor(glyphsActor) glyphsActor.GetProperty().SetDiffuseColor(1, 1, 1) ren1.ResetCamera() ren1.GetActiveCamera().Azimuth(30) ren1.GetActiveCamera().Elevation(20) ren1.GetActiveCamera().Dolly(1.25) ren1.ResetCameraClippingRange() renWin.Render() # render the image # iren.Initialize() # --- end of script --
selectionPoints.InsertPoint(4, 0.5722, 0.5848, 0.5927) selectionPoints.InsertPoint(5, 0.4305, 0.8138, 0.4189) loop = svtk.svtkImplicitSelectionLoop() loop.SetLoop(selectionPoints) extract = svtk.svtkExtractGeometry() extract.SetInputConnection(sphere.GetOutputPort()) extract.SetImplicitFunction(loop) connect = svtk.svtkConnectivityFilter() connect.SetInputConnection(extract.GetOutputPort()) connect.SetExtractionModeToClosestPointRegion() connect.SetClosestPoint(selectionPoints.GetPoint(0)) clipMapper = svtk.svtkDataSetMapper() clipMapper.SetInputConnection(connect.GetOutputPort()) backProp = svtk.svtkProperty() backProp.SetDiffuseColor(GetRGBColor('tomato')) clipActor = svtk.svtkActor() clipActor.SetMapper(clipMapper) clipActor.GetProperty().SetColor(GetRGBColor('peacock')) clipActor.SetBackfaceProperty(backProp) # Create graphics stuff # ren1 = svtk.svtkRenderer() renWin = svtk.svtkRenderWindow() renWin.AddRenderer(ren1) iren = svtk.svtkRenderWindowInteractor() iren.SetRenderWindow(renWin) # Add the actors to the renderer, set the background and size # ren1.AddActor(clipActor)
edgeScalars.InsertValue(0, 0.0) edgeScalars.InsertValue(1, 0.0) edgeScalars.InsertValue(2, 0.9) aEdge = svtk.svtkQuadraticEdge() aEdge.GetPointIds().SetId(0, 0) aEdge.GetPointIds().SetId(1, 1) aEdge.GetPointIds().SetId(2, 2) aEdgeGrid = svtk.svtkUnstructuredGrid() aEdgeGrid.Allocate(1, 1) aEdgeGrid.InsertNextCell(aEdge.GetCellType(), aEdge.GetPointIds()) aEdgeGrid.SetPoints(edgePoints) aEdgeGrid.GetPointData().SetScalars(edgeScalars) aEdgeMapper = svtk.svtkDataSetMapper() aEdgeMapper.SetInputData(aEdgeGrid) aEdgeMapper.ScalarVisibilityOff() aEdgeActor = svtk.svtkActor() aEdgeActor.SetMapper(aEdgeMapper) aEdgeActor.GetProperty().SetRepresentationToWireframe() aEdgeActor.GetProperty().SetAmbient(1.0) # Quadratic triangle triPoints = svtk.svtkPoints() triPoints.SetNumberOfPoints(6) triPoints.InsertPoint(0, 0.0, 0.0, 0.0) triPoints.InsertPoint(1, 1.0, 0.0, 0.0) triPoints.InsertPoint(2, 0.5, 0.8, 0.0) triPoints.InsertPoint(3, 0.5, 0.0, 0.0) triPoints.InsertPoint(4, 0.75, 0.4, 0.0) triPoints.InsertPoint(5, 0.25, 0.4, 0.0) triScalars = svtk.svtkFloatArray() triScalars.SetNumberOfTuples(6)
iso = svtk.svtkMarchingCubes() iso.SetInputConnection(v16.GetOutputPort()) iso.SetValue(0, 1150) iso.ComputeGradientsOn() iso.ComputeScalarsOff() iso.SetLocator(locator) gradient = svtk.svtkVectorNorm() gradient.SetInputConnection(iso.GetOutputPort()) isoMapper = svtk.svtkDataSetMapper() isoMapper.SetInputConnection(gradient.GetOutputPort()) isoMapper.ScalarVisibilityOn() isoMapper.SetScalarRange(0, 1200) isoActor = svtk.svtkActor() isoActor.SetMapper(isoMapper) isoProp = isoActor.GetProperty() isoProp.SetColor(GetRGBColor('antique_white')) outline = svtk.svtkOutlineFilter() outline.SetInputConnection(v16.GetOutputPort()) outlineMapper = svtk.svtkPolyDataMapper() outlineMapper.SetInputConnection(outline.GetOutputPort()) outlineActor = svtk.svtkActor() outlineActor.SetMapper(outlineMapper) outlineProp = outlineActor.GetProperty()
boxC = svtk.svtkCubeSource() boxC.SetBounds(-0.5, 0.5, -0.5, 0.5, -0.5, 0.5) boxR = svtk.svtkCubeSource() boxR.SetBounds(1.5, 2.5, -0.5, 0.5, -0.5, 0.5) mapperL = svtk.svtkPolyDataMapper() mapperL.SetInputConnection(boxL.GetOutputPort()) mapperC = svtk.svtkPolyDataMapper() mapperC.SetInputConnection(boxC.GetOutputPort()) mapperR = svtk.svtkPolyDataMapper() mapperR.SetInputConnection(boxR.GetOutputPort()) actorL = svtk.svtkActor() actorL.SetMapper(mapperL) actorL.GetProperty().SetRepresentationToWireframe() actorL.GetProperty().SetAmbient(1) actorC = svtk.svtkActor() actorC.SetMapper(mapperC) actorC.GetProperty().SetRepresentationToWireframe() actorC.GetProperty().SetAmbient(1) actorR = svtk.svtkActor() actorR.SetMapper(mapperR) actorR.GetProperty().SetRepresentationToWireframe() actorR.GetProperty().SetAmbient(1) ren.AddActor(actorL)
conn = svtk.svtkConnectivityFilter() conn.SetInputConnection(sample.GetOutputPort()) conn.ScalarConnectivityOn() conn.SetScalarRange(0.6,0.6) conn.SetExtractionModeToCellSeededRegions() conn.AddSeed(105) # Create a surface contours = svtk.svtkContourFilter() contours.SetInputConnection(conn.GetOutputPort()) # contours SetInputConnection [sample GetOutputPort] contours.GenerateValues(5,0.0,1.2) contMapper = svtk.svtkDataSetMapper() # contMapper SetInputConnection [contours GetOutputPort] contMapper.SetInputConnection(conn.GetOutputPort()) contMapper.SetScalarRange(0.0,1.2) contActor = svtk.svtkActor() contActor.SetMapper(contMapper) # Create outline outline = svtk.svtkOutlineFilter() outline.SetInputConnection(sample.GetOutputPort()) outlineMapper = svtk.svtkPolyDataMapper() outlineMapper.SetInputConnection(outline.GetOutputPort()) outlineActor = svtk.svtkActor() outlineActor.SetMapper(outlineMapper) outlineActor.GetProperty().SetColor(0,0,0) # Graphics # create a window to render into ren1 = svtk.svtkRenderer() renWin = svtk.svtkRenderWindow() renWin.SetMultiSamples(0) renWin.AddRenderer(ren1)
except: print("Cannot import svtk") sys.exit(1) try: print(dir(svtk)) except: print("Cannot print(dir(svtk)") sys.exit(1) try: try: try: o = svtk.svtkLineWidget() print("Using Hybrid") except: o = svtk.svtkActor() print("Using Rendering") except: o = svtk.svtkObject() print("Using Common") except: print("Cannot create svtkObject") sys.exit(1) try: print(o) print("Reference count: %d" % o.GetReferenceCount()) print("Class name: %s" % o.GetClassName()) except: print("Cannot print object") sys.exit(1)
def DisplayGraph(graph): ''' Display the graph. ''' theme = svtk.svtkViewTheme() theme.SetBackgroundColor(0, 0, .1) theme.SetBackgroundColor2(0, 0, .5) # Layout the graph # Pick a strategy you like. # strategy = svtk.svtkCircularLayoutStrategy() strategy = svtk.svtkSimple2DLayoutStrategy() # strategy = svtk.svtkRandomLayoutStrategy() layout = svtk.svtkGraphLayout() layout.SetLayoutStrategy(strategy) layout.SetInputData(graph) view = svtk.svtkGraphLayoutView() view.AddRepresentationFromInputConnection(layout.GetOutputPort()) # Tell the view to use the vertex layout we provide. view.SetLayoutStrategyToPassThrough() view.SetEdgeLabelVisibility(True) view.SetVertexLabelArrayName("Labels") view.SetVertexLabelVisibility(True) view.ApplyViewTheme(theme) # Manually create an actor containing the glyphed arrows. # Get the edge geometry edgeGeom = svtk.svtkGraphToPolyData() edgeGeom.SetInputConnection(layout.GetOutputPort()) edgeGeom.EdgeGlyphOutputOn() # Set the position (0: edge start, 1: edge end) where # the edge arrows should go. # edgeGeom.SetEdgeGlyphPosition(0.8) edgeGeom.SetEdgeGlyphPosition(0.85) # Make a simple edge arrow for glyphing. # arrowSource = svtk.svtkGlyphSource2D() # arrowSource.SetGlyphTypeToEdgeArrow() # arrowSource.SetScale(0.075) # Or use a cone. coneSource = svtk.svtkConeSource() coneSource.SetRadius(0.025) coneSource.SetHeight(0.1) coneSource.SetResolution(12) # Use Glyph3D to repeat the glyph on all edges. arrowGlyph = svtk.svtkGlyph3D() arrowGlyph.SetInputConnection(0, edgeGeom.GetOutputPort(1)) # arrowGlyph.SetInputConnection(1, arrowSource.GetOutputPort()) arrowGlyph.SetInputConnection(1, coneSource.GetOutputPort()) # Add the edge arrow actor to the view. arrowMapper = svtk.svtkPolyDataMapper() arrowMapper.SetInputConnection(arrowGlyph.GetOutputPort()) arrowActor = svtk.svtkActor() arrowActor.SetMapper(arrowMapper) view.GetRenderer().AddActor(arrowActor) view.ResetCamera() view.Render() view.SetInteractionModeTo3D() view.GetInteractor().Initialize() view.GetInteractor().Start()
# 0D ZeroDPts = svtk.svtkPoints() ZeroDPts.SetNumberOfPoints(1) ZeroDPts.SetPoint(0, 0, 0, 0) ZeroDGrid = svtk.svtkStructuredGrid() ZeroDGrid.SetDimensions(1, 1, 1) ZeroDGrid.SetPoints(ZeroDPts) ZeroDGrid.GetCell(0) ZeroDGrid.GetCell(0, cell) ZeroDGrid.GetCellPoints(0, ptIds) ZeroDGeom = svtk.svtkStructuredGridGeometryFilter() ZeroDGeom.SetInputData(ZeroDGrid) ZeroDGeom.SetExtent(0, 2, 0, 2, 0, 2) ZeroDMapper = svtk.svtkPolyDataMapper() ZeroDMapper.SetInputConnection(ZeroDGeom.GetOutputPort()) ZeroDActor = svtk.svtkActor() ZeroDActor.SetMapper(ZeroDMapper) ZeroDActor.SetPosition(0, 0, 0) ren1.AddActor(ZeroDActor) # 1D - X XPts = svtk.svtkPoints() XPts.SetNumberOfPoints(2) XPts.SetPoint(0, 0, 0, 0) XPts.SetPoint(1, 1, 0, 0) XGrid = svtk.svtkStructuredGrid() XGrid.SetDimensions(2, 1, 1) XGrid.SetPoints(XPts) XGrid.GetCell(0) XGrid.GetCell(0, cell) XGrid.GetCellPoints(0, ptIds) XGeom = svtk.svtkStructuredGridGeometryFilter()
def testQuadricCut(self): solidTexture = (255, 255) clearTexture = (255, 0) edgeTexture = (0, 255) def makeBooleanTexture(caseNumber, resolution, thickness): #global solidTexture, clearTexture, edgeTexture booleanTexturecaseNumber = svtk.svtkBooleanTexture() booleanTexturecaseNumber.SetXSize(resolution) booleanTexturecaseNumber.SetYSize(resolution) booleanTexturecaseNumber.SetThickness(thickness) if caseNumber == 0: booleanTexturecaseNumber.SetInIn(solidTexture) booleanTexturecaseNumber.SetOutIn(solidTexture) booleanTexturecaseNumber.SetInOut(solidTexture) booleanTexturecaseNumber.SetOutOut(solidTexture) booleanTexturecaseNumber.SetOnOn(solidTexture) booleanTexturecaseNumber.SetOnIn(solidTexture) booleanTexturecaseNumber.SetOnOut(solidTexture) booleanTexturecaseNumber.SetInOn(solidTexture) booleanTexturecaseNumber.SetOutOn(solidTexture) elif caseNumber == 1: booleanTexturecaseNumber.SetInIn(clearTexture) booleanTexturecaseNumber.SetOutIn(solidTexture) booleanTexturecaseNumber.SetInOut(solidTexture) booleanTexturecaseNumber.SetOutOut(solidTexture) booleanTexturecaseNumber.SetOnOn(edgeTexture) booleanTexturecaseNumber.SetOnIn(edgeTexture) booleanTexturecaseNumber.SetOnOut(solidTexture) booleanTexturecaseNumber.SetInOn(edgeTexture) elif caseNumber == 2: booleanTexturecaseNumber.SetInIn(solidTexture) booleanTexturecaseNumber.SetOutIn(clearTexture) booleanTexturecaseNumber.SetInOut(solidTexture) booleanTexturecaseNumber.SetOutOut(solidTexture) booleanTexturecaseNumber.SetOnOn(edgeTexture) booleanTexturecaseNumber.SetOnIn(edgeTexture) booleanTexturecaseNumber.SetOnOut(solidTexture) booleanTexturecaseNumber.SetInOn(solidTexture) booleanTexturecaseNumber.SetOutOn(edgeTexture) elif caseNumber == 3: booleanTexturecaseNumber.SetInIn(clearTexture) booleanTexturecaseNumber.SetOutIn(clearTexture) booleanTexturecaseNumber.SetInOut(solidTexture) booleanTexturecaseNumber.SetOutOut(solidTexture) booleanTexturecaseNumber.SetOnOn(edgeTexture) booleanTexturecaseNumber.SetOnIn(clearTexture) booleanTexturecaseNumber.SetOnOut(solidTexture) booleanTexturecaseNumber.SetInOn(edgeTexture) booleanTexturecaseNumber.SetOutOn(edgeTexture) elif caseNumber == 4: booleanTexturecaseNumber.SetInIn(solidTexture) booleanTexturecaseNumber.SetOutIn(solidTexture) booleanTexturecaseNumber.SetInOut(clearTexture) booleanTexturecaseNumber.SetOutOut(solidTexture) booleanTexturecaseNumber.SetOnOn(edgeTexture) booleanTexturecaseNumber.SetOnIn(solidTexture) booleanTexturecaseNumber.SetOnOut(edgeTexture) booleanTexturecaseNumber.SetInOn(edgeTexture) booleanTexturecaseNumber.SetOutOn(solidTexture) elif caseNumber == 5: booleanTexturecaseNumber.SetInIn(clearTexture) booleanTexturecaseNumber.SetOutIn(solidTexture) booleanTexturecaseNumber.SetInOut(clearTexture) booleanTexturecaseNumber.SetOutOut(solidTexture) booleanTexturecaseNumber.SetOnOn(edgeTexture) booleanTexturecaseNumber.SetOnIn(edgeTexture) booleanTexturecaseNumber.SetOnOut(edgeTexture) booleanTexturecaseNumber.SetInOn(clearTexture) booleanTexturecaseNumber.SetOutOn(solidTexture) elif caseNumber == 6: booleanTexturecaseNumber.SetInIn(solidTexture) booleanTexturecaseNumber.SetOutIn(clearTexture) booleanTexturecaseNumber.SetInOut(clearTexture) booleanTexturecaseNumber.SetOutOut(solidTexture) booleanTexturecaseNumber.SetOnOn(edgeTexture) booleanTexturecaseNumber.SetOnIn(edgeTexture) booleanTexturecaseNumber.SetOnOut(edgeTexture) booleanTexturecaseNumber.SetInOn(edgeTexture) booleanTexturecaseNumber.SetOutOn(edgeTexture) elif caseNumber == 7: booleanTexturecaseNumber.SetInIn(clearTexture) booleanTexturecaseNumber.SetOutIn(clearTexture) booleanTexturecaseNumber.SetInOut(clearTexture) booleanTexturecaseNumber.SetOutOut(solidTexture) booleanTexturecaseNumber.SetOnOn(edgeTexture) booleanTexturecaseNumber.SetOnIn(clearTexture) booleanTexturecaseNumber.SetOnOut(edgeTexture) booleanTexturecaseNumber.SetInOn(clearTexture) booleanTexturecaseNumber.SetOutOn(edgeTexture) elif caseNumber == 8: booleanTexturecaseNumber.SetInIn(solidTexture) booleanTexturecaseNumber.SetOutIn(solidTexture) booleanTexturecaseNumber.SetInOut(solidTexture) booleanTexturecaseNumber.SetOutOut(clearTexture) booleanTexturecaseNumber.SetOnOn(edgeTexture) booleanTexturecaseNumber.SetOnIn(solidTexture) booleanTexturecaseNumber.SetOnOut(edgeTexture) booleanTexturecaseNumber.SetInOn(solidTexture) booleanTexturecaseNumber.SetOutOn(edgeTexture) elif caseNumber == 9: booleanTexturecaseNumber.SetInIn(clearTexture) booleanTexturecaseNumber.SetInOut(solidTexture) booleanTexturecaseNumber.SetOutIn(solidTexture) booleanTexturecaseNumber.SetOutOut(clearTexture) booleanTexturecaseNumber.SetOnOn(edgeTexture) booleanTexturecaseNumber.SetOnIn(edgeTexture) booleanTexturecaseNumber.SetOnOut(edgeTexture) booleanTexturecaseNumber.SetInOn(edgeTexture) booleanTexturecaseNumber.SetOutOn(edgeTexture) elif caseNumber == 10: booleanTexturecaseNumber.SetInIn(solidTexture) booleanTexturecaseNumber.SetInOut(solidTexture) booleanTexturecaseNumber.SetOutIn(clearTexture) booleanTexturecaseNumber.SetOutOut(clearTexture) booleanTexturecaseNumber.SetOnOn(edgeTexture) booleanTexturecaseNumber.SetOnIn(edgeTexture) booleanTexturecaseNumber.SetOnOut(edgeTexture) booleanTexturecaseNumber.SetInOn(solidTexture) booleanTexturecaseNumber.SetOutOn(clearTexture) elif caseNumber == 11: booleanTexturecaseNumber.SetInIn(clearTexture) booleanTexturecaseNumber.SetInOut(solidTexture) booleanTexturecaseNumber.SetOutIn(clearTexture) booleanTexturecaseNumber.SetOutOut(clearTexture) booleanTexturecaseNumber.SetOnOn(edgeTexture) booleanTexturecaseNumber.SetOnIn(clearTexture) booleanTexturecaseNumber.SetOnOut(edgeTexture) booleanTexturecaseNumber.SetInOn(edgeTexture) booleanTexturecaseNumber.SetOutOn(clearTexture) elif caseNumber == 12: booleanTexturecaseNumber.SetInIn(solidTexture) booleanTexturecaseNumber.SetInOut(clearTexture) booleanTexturecaseNumber.SetOutIn(solidTexture) booleanTexturecaseNumber.SetOutOut(clearTexture) booleanTexturecaseNumber.SetOnOn(edgeTexture) booleanTexturecaseNumber.SetOnIn(solidTexture) booleanTexturecaseNumber.SetOnOut(clearTexture) booleanTexturecaseNumber.SetInOn(edgeTexture) booleanTexturecaseNumber.SetOutOn(edgeTexture) elif caseNumber == 13: booleanTexturecaseNumber.SetInIn(clearTexture) booleanTexturecaseNumber.SetInOut(clearTexture) booleanTexturecaseNumber.SetOutIn(solidTexture) booleanTexturecaseNumber.SetOutOut(clearTexture) booleanTexturecaseNumber.SetOnOn(edgeTexture) booleanTexturecaseNumber.SetOnIn(edgeTexture) booleanTexturecaseNumber.SetOnOut(clearTexture) booleanTexturecaseNumber.SetInOn(clearTexture) booleanTexturecaseNumber.SetOutOn(edgeTexture) elif caseNumber == 14: booleanTexturecaseNumber.SetInIn(solidTexture) booleanTexturecaseNumber.SetInOut(clearTexture) booleanTexturecaseNumber.SetOutIn(clearTexture) booleanTexturecaseNumber.SetOutOut(clearTexture) booleanTexturecaseNumber.SetOnOn(edgeTexture) booleanTexturecaseNumber.SetOnIn(edgeTexture) booleanTexturecaseNumber.SetOnOut(clearTexture) booleanTexturecaseNumber.SetInOn(edgeTexture) booleanTexturecaseNumber.SetOutOn(clearTexture) elif caseNumber == 15: booleanTexturecaseNumber.SetInIn(clearTexture) booleanTexturecaseNumber.SetInOut(clearTexture) booleanTexturecaseNumber.SetOutIn(clearTexture) booleanTexturecaseNumber.SetOutOut(clearTexture) booleanTexturecaseNumber.SetOnOn(clearTexture) booleanTexturecaseNumber.SetOnIn(clearTexture) booleanTexturecaseNumber.SetOnOut(clearTexture) booleanTexturecaseNumber.SetInOn(clearTexture) booleanTexturecaseNumber.SetOutOn(clearTexture) booleanTexturecaseNumber.Update() return booleanTexturecaseNumber # A list of positions positions = [] positions.append((-4, 4, 0)) positions.append((-2, 4, 0)) positions.append((0, 4, 0)) positions.append((2, 4, 0)) positions.append((-4, 2, 0)) positions.append((-2, 2, 0)) positions.append((0, 2, 0)) positions.append((2, 2, 0)) positions.append((-4, 0, 0)) positions.append((-2, 0, 0)) positions.append((0, 0, 0)) positions.append((2, 0, 0)) positions.append((-4, -2, 0)) positions.append((-2, -2, 0)) positions.append((0, -2, 0)) positions.append((2, -2, 0)) ren = svtk.svtkRenderer() renWin = svtk.svtkRenderWindow() renWin.AddRenderer(ren) # define two elliptical cylinders quadric1 = svtk.svtkQuadric() quadric1.SetCoefficients(1, 2, 0, 0, 0, 0, 0, 0, 0, -.07) quadric2 = svtk.svtkQuadric() quadric2.SetCoefficients(2, 1, 0, 0, 0, 0, 0, 0, 0, -.07) # create a sphere for all to use aSphere = svtk.svtkSphereSource() aSphere.SetPhiResolution(50) aSphere.SetThetaResolution(50) # create texture coordinates for all tcoords = svtk.svtkImplicitTextureCoords() tcoords.SetInputConnection(aSphere.GetOutputPort()) tcoords.SetRFunction(quadric1) tcoords.SetSFunction(quadric2) aMapper = svtk.svtkDataSetMapper() aMapper.SetInputConnection(tcoords.GetOutputPort()) # create a mapper, sphere and texture map for each case aTexture = [] anActor = [] for i in range(0, 16): aTexture.append(svtk.svtkTexture()) aTexture[i].SetInputData(makeBooleanTexture(i, 256, 1).GetOutput()) aTexture[i].InterpolateOff() aTexture[i].RepeatOff() anActor.append(svtk.svtkActor()) anActor[i].SetMapper(aMapper) anActor[i].SetTexture(aTexture[i]) anActor[i].SetPosition(positions[i]) anActor[i].SetScale(2.0, 2.0, 2.0) ren.AddActor(anActor[i]) ren.SetBackground(0.4392, 0.5020, 0.5647) ren.ResetCamera() ren.GetActiveCamera().Zoom(1.4) renWin.SetSize(500, 500) # render and interact with data iRen = svtk.svtkRenderWindowInteractor() iRen.SetRenderWindow(renWin) renWin.Render() img_file = "quadricCut.png" svtk.test.Testing.compareImage( iRen.GetRenderWindow(), svtk.test.Testing.getAbsImagePath(img_file), threshold=25) svtk.test.Testing.interact()
tpoly.SetTransform(transform) tpoly2 = svtk.svtkTransformPolyDataFilter() tpoly2.SetInputConnection(tpoly.GetOutputPort()) tpoly2.SetTransform(transform.GetInverse()) # also cover the inverse transformation by going back and forth tpoly3 = svtk.svtkTransformPolyDataFilter() tpoly3.SetInputConnection(tpoly2.GetOutputPort()) tpoly3.SetTransform(transform) mapper = svtk.svtkDataSetMapper() mapper.SetInputConnection(tpoly3.GetOutputPort()) earth = svtk.svtkPNMReader() earth.SetFileName("" + str(SVTK_DATA_ROOT) + "/Data/earth.ppm") texture = svtk.svtkTexture() texture.SetInputConnection(earth.GetOutputPort()) texture.InterpolateOn() world = svtk.svtkActor() world.SetMapper(mapper) world.SetTexture(texture) # Add the actors to the renderer, set the background and size # ren1.AddActor(world) ren1.SetBackground(0.1, 0.2, 0.4) renWin.SetSize(300, 300) ren1.GetActiveCamera().SetPosition(8, -10, 6) ren1.GetActiveCamera().SetFocalPoint(0, 0, 0) ren1.GetActiveCamera().SetViewAngle(15) ren1.GetActiveCamera().SetViewUp(0.0, 0.0, 1.0) # render the image # cam1 = ren1.GetActiveCamera() cam1.Zoom(1.4)