protected override void CalculateFilter() { outputType = VTK.DataType.PolyData; vtkPlane plane = vtkPlane.New(); plane.SetOrigin(originX, originY, originZ); plane.SetNormal(normalX, normalY, normalZ); if (node.parent.filter.outputType == VTK.DataType.PolyData) { vtkFilter = vtkClipPolyData.New(); vtkFilter.SetInputConnection(node.parent.filter.vtkFilter.GetOutputPort()); ((vtkClipPolyData)vtkFilter).SetClipFunction(plane); } if (node.parent.filter.outputType == VTK.DataType.UnstructuredGrid) { vtkFilter = vtkClipDataSet.New(); vtkFilter.SetInputConnection(node.parent.filter.vtkFilter.GetOutputPort()); ((vtkClipDataSet)vtkFilter).SetClipFunction(plane); } vtkFilter.Update(); }
private vtkActor DiskSector(double innerRadius, double radius, double clip1X, double clip1Y, double clip2X, double clip2Y, Color color) { vtkProperty arcColor = vtkProperty.New(); arcColor.SetColor(color.r, color.g, color.b); vtkDiskSource outerDisk = vtkDiskSource.New(); outerDisk.SetCircumferentialResolution(50); outerDisk.SetRadialResolution(50); outerDisk.SetInnerRadius(innerRadius); outerDisk.SetOuterRadius(innerRadius + radius); // Define a clipping plane vtkPlane clipPlane = vtkPlane.New(); clipPlane.SetNormal(clip1X, clip1Y, 0); clipPlane.SetOrigin(0.0, 0.0, 0.0); // Define a clipping plane vtkPlane clipPlane2 = vtkPlane.New(); clipPlane2.SetNormal(clip2X, clip2Y, 0); clipPlane2.SetOrigin(0, 0, 0); vtkClipPolyData clipper = vtkClipPolyData.New(); clipper.SetInputConnection(outerDisk.GetOutputPort()); clipper.SetClipFunction(clipPlane); vtkClipPolyData clipper2 = vtkClipPolyData.New(); clipper2.SetInputConnection(clipper.GetOutputPort()); clipper2.SetClipFunction(clipPlane2); // Visualize vtkPolyDataMapper mapper = vtkPolyDataMapper.New(); mapper.SetInputConnection(clipper2.GetOutputPort()); vtkActor actor = vtkActor.New(); actor.SetMapper(mapper); actor.SetProperty(arcColor); return(actor); }
private void SolidClip() { // Create a superquadric vtkSuperquadricSource superquadricSource = vtkSuperquadricSource.New(); superquadricSource.SetPhiRoundness(3.1); superquadricSource.SetThetaRoundness(2.2); // Define a clipping plane vtkPlane clipPlane = vtkPlane.New(); clipPlane.SetNormal(1.0, -1.0, -1.0); clipPlane.SetOrigin(0.0, 0.0, 0.0); // Clip the source with the plane vtkClipPolyData clipper = vtkClipPolyData.New(); #if VTK_MAJOR_VERSION_5 clipper.SetInputConnection(superquadricSource.GetOutputPort()); #else clipper.SetInputData(superquadricSource); #endif clipper.SetClipFunction(clipPlane); //Create a mapper and actor vtkPolyDataMapper superquadricMapper = vtkPolyDataMapper.New(); #if VTK_MAJOR_VERSION_5 superquadricMapper.SetInputConnection(clipper.GetOutputPort()); #else superquadricMapper.SetInputData(clipper); #endif vtkActor superquadricActor = vtkActor.New(); superquadricActor.SetMapper(superquadricMapper); // Create a property to be used for the back faces. Turn off all // shading by specifying 0 weights for specular and diffuse. Max the // ambient. vtkProperty backFaces = vtkProperty.New(); backFaces.SetSpecular(0.0); backFaces.SetDiffuse(0.0); backFaces.SetAmbient(1.0); backFaces.SetAmbientColor(1.0000, 0.3882, 0.2784); superquadricActor.SetBackfaceProperty(backFaces); // get a reference to the renderwindow of our renderWindowControl1 vtkRenderWindow renderWindow = renderWindowControl1.RenderWindow; // renderer vtkRenderer renderer = renderWindow.GetRenderers().GetFirstRenderer(); // add our actor to the renderer renderer.AddActor(superquadricActor); }
static public vtkAlgorithmOutput genFrustumCone(double total_dis, double end_radius, double distance, bool is_reverse) { vtkConeSource cone = vtkConeSource.New(); cone.SetHeight(total_dis * 1.2); cone.SetRadius(end_radius * 1.2); cone.SetCenter(0, 0, total_dis * 0.4); cone.SetResolution(80); cone.SetDirection(0, 0, 1); cone.Update(); vtkPlane plane = vtkPlane.New(); plane.SetOrigin(0, 0, 0); plane.SetNormal(0, 0, 1); vtkClipPolyData clipPolyData = vtkClipPolyData.New(); clipPolyData.SetInputConnection(cone.GetOutputPort()); clipPolyData.SetClipFunction(plane); clipPolyData.GenerateClippedOutputOn(); clipPolyData.Update(); vtkPlane plane2 = vtkPlane.New(); plane2.SetOrigin(0, 0, distance); plane2.SetNormal(0, 0, -1); vtkClipPolyData clipPolyData2 = vtkClipPolyData.New(); clipPolyData2.SetInputConnection(clipPolyData.GetOutputPort()); clipPolyData2.SetClipFunction(plane2); clipPolyData2.GenerateClippedOutputOn(); clipPolyData2.Update(); if (is_reverse) { vtkTransform transform = vtkTransform.New(); transform.RotateWXYZ(180, 0, 1, 0); transform.Translate(0, 0, -distance); vtkTransformPolyDataFilter transFilter = vtkTransformPolyDataFilter.New(); transFilter.SetInputConnection(clipPolyData2.GetOutputPort()); transFilter.SetTransform(transform); //use vtkTransform (or maybe vtkLinearTransform) transFilter.Update(); return(transFilter.GetOutputPort()); } return(clipPolyData2.GetOutputPort()); }
/// <summary> /// Clip this part - Set Mapper input to Clipper /// </summary> public void ClipPart(vtkPlane ClipPlane, bool clip) { if (clip == true) { Clipper = vtkTableBasedClipDataSet.New(); Clipper.SetClipFunction(ClipPlane); Clipper.SetInputConnection(Grid.GetProducerPort()); Clipper.Update(); Mapper.SetInputConnection(Clipper.GetOutputPort()); Mapper.Update(); // Update Feature Filter -> will update Edges and Faces Filter.SetInput(Clipper.GetOutput()); Filter.Update(); // ------- Alternative without Clip Surface Extraction -------------- //vtkPlaneCollection planes = vtkPlaneCollection.New(); //planes.AddItem(ClipPlane); //Edges.GetMapper().SetClippingPlanes(planes); //Edges.GetMapper().Update(); //vtkPlaneCollection Planes = vtkPlaneCollection.New(); //Planes.AddItem(ClipPlane); //Mapper.SetClippingPlanes(Planes); //Mapper.Update(); } else { Mapper.SetInput(Grid); Mapper.Update(); // Update Feature Filter -> will update Edges and Faces Filter.SetInput(Grid); Filter.Update(); // ------- Alternative without Clip Surface Extraction -------------- // Edges //vtkPlaneCollection planes = vtkPlaneCollection.New(); //Edges.GetMapper().SetClippingPlanes(planes); //Edges.GetMapper().Update(); //vtkPlaneCollection Planes = vtkPlaneCollection.New(); //Mapper.SetClippingPlanes(Planes); //Mapper.Update(); } }
/// <summary> /// Sets initial planes' positions. /// </summary> /// <param name="planeCollection"></param> private void InitPlaneCollection(vtkPlaneCollection planeCollection) { var planeX1 = new vtkPlane(); planeX1.SetNormal(1, 0, 0); planeX1.SetOrigin(0, 0, 0); planeCollection.AddItem(planeX1); var planeX2 = new vtkPlane(); planeX2.SetNormal(-1, 0, 0); planeX2.SetOrigin(_xSize, 0, 0); planeCollection.AddItem(planeX2); var planeY1 = new vtkPlane(); planeY1.SetNormal(0, 1, 0); planeY1.SetOrigin(0, 0, 0); planeCollection.AddItem(planeY1); var planeY2 = new vtkPlane(); planeY2.SetNormal(0, -1, 0); planeY2.SetOrigin(0, _ySize, 0); planeCollection.AddItem(planeY2); var planeZ1 = new vtkPlane(); planeZ1.SetNormal(0, 0, 1); planeZ1.SetOrigin(0, 0, 0); planeCollection.AddItem(planeZ1); var planeZ2 = new vtkPlane(); planeZ2.SetNormal(0, 0, -1); planeZ2.SetOrigin(0, 0, _zSize); planeCollection.AddItem(planeZ2); }
public void ClipBC(vtkPlane ClipPlane, bool clip) { if (clip == true) { ClipperX = vtkTableBasedClipDataSet.New(); ClipperX.SetClipFunction(ClipPlane); ClipperX.SetInputConnection(GlyphX.GetOutputPort()); ClipperX.Update(); MapperX.SetInputConnection(ClipperX.GetOutputPort()); MapperX.Update(); ClipperY = vtkTableBasedClipDataSet.New(); ClipperY.SetClipFunction(ClipPlane); ClipperY.SetInputConnection(GlyphY.GetOutputPort()); ClipperY.Update(); MapperY.SetInputConnection(ClipperY.GetOutputPort()); MapperY.Update(); ClipperZ = vtkTableBasedClipDataSet.New(); ClipperZ.SetClipFunction(ClipPlane); ClipperZ.SetInputConnection(GlyphZ.GetOutputPort()); ClipperZ.Update(); MapperZ.SetInputConnection(ClipperZ.GetOutputPort()); MapperZ.Update(); } else { // Add Glyphs to Mapper MapperX.SetInputConnection(GlyphX.GetOutputPort()); MapperY.SetInputConnection(GlyphY.GetOutputPort()); MapperZ.SetInputConnection(GlyphZ.GetOutputPort()); MapperX.Update(); MapperY.Update(); MapperZ.Update(); } }
private void CapClip(string filePath) { // PolyData to process vtkPolyData polyData; if (filePath != null) { vtkXMLPolyDataReader reader = vtkXMLPolyDataReader.New(); reader.SetFileName(filePath); reader.Update(); polyData = reader.GetOutput(); } else { // Create a sphere vtkSphereSource sphereSource = vtkSphereSource.New(); sphereSource.SetThetaResolution(20); sphereSource.SetPhiResolution(11); vtkPlane plane = vtkPlane.New(); plane.SetOrigin(0, 0, 0); plane.SetNormal(1.0, -1.0, -1.0); vtkClipPolyData clipper = vtkClipPolyData.New(); clipper.SetInputConnection(sphereSource.GetOutputPort()); clipper.SetClipFunction(plane); clipper.SetValue(0); clipper.Update(); polyData = clipper.GetOutput(); } vtkDataSetMapper clipMapper = vtkDataSetMapper.New(); #if VTK_MAJOR_VERSION_5 clipMapper.SetInput(polyData); #else clipMapper.SetInputData(polyData); #endif vtkActor clipActor = vtkActor.New(); clipActor.SetMapper(clipMapper); clipActor.GetProperty().SetColor(1.0000, 0.3882, 0.2784); clipActor.GetProperty().SetInterpolationToFlat(); // Now extract feature edges vtkFeatureEdges boundaryEdges = vtkFeatureEdges.New(); #if VTK_MAJOR_VERSION_5 boundaryEdges.SetInput(polyData); #else boundaryEdges.SetInputData(polyData); #endif boundaryEdges.BoundaryEdgesOn(); boundaryEdges.FeatureEdgesOff(); boundaryEdges.NonManifoldEdgesOff(); boundaryEdges.ManifoldEdgesOff(); vtkStripper boundaryStrips = vtkStripper.New(); boundaryStrips.SetInputConnection(boundaryEdges.GetOutputPort()); boundaryStrips.Update(); // Change the polylines into polygons vtkPolyData boundaryPoly = vtkPolyData.New(); boundaryPoly.SetPoints(boundaryStrips.GetOutput().GetPoints()); boundaryPoly.SetPolys(boundaryStrips.GetOutput().GetLines()); vtkPolyDataMapper boundaryMapper = vtkPolyDataMapper.New(); #if VTK_MAJOR_VERSION_5 boundaryMapper.SetInput(boundaryPoly); #else boundaryMapper.SetInputData(boundaryPoly); #endif vtkActor boundaryActor = vtkActor.New(); boundaryActor.SetMapper(boundaryMapper); boundaryActor.GetProperty().SetColor(0.8900, 0.8100, 0.3400); // get a reference to the renderwindow of our renderWindowControl1 vtkRenderWindow renderWindow = renderWindowControl1.RenderWindow; // renderer vtkRenderer renderer = renderWindow.GetRenderers().GetFirstRenderer(); // set background color renderer.SetBackground(.2, .3, .4); // add our actor to the renderer renderer.AddActor(clipActor); renderer.AddActor(boundaryActor); // Generate an interesting view // renderer.ResetCamera(); renderer.GetActiveCamera().Azimuth(30); renderer.GetActiveCamera().Elevation(30); renderer.GetActiveCamera().Dolly(1.2); renderer.ResetCameraClippingRange(); }
///<summary> A Set Method for Static Variables </summary> public static void SetcutPlane(vtkPlane toSet) { cutPlane = toSet; }
/// <summary> /// The main entry method called by the CSharp driver /// </summary> /// <param name="argv"></param> public static void AVprobe(String [] argv) { //Prefix Content is: "" // Create the RenderWindow, Renderer and both Actors[] //[] ren1 = vtkRenderer.New(); renWin = vtkRenderWindow.New(); renWin.AddRenderer((vtkRenderer)ren1); iren = new vtkRenderWindowInteractor(); iren.SetRenderWindow((vtkRenderWindow)renWin); // cut data[] pl3d = new vtkPLOT3DReader(); pl3d.SetXYZFileName((string)"" + (VTK_DATA_ROOT.ToString()) + "/Data/combxyz.bin"); pl3d.SetQFileName((string)"" + (VTK_DATA_ROOT.ToString()) + "/Data/combq.bin"); pl3d.SetScalarFunctionNumber((int)100); pl3d.SetVectorFunctionNumber((int)202); pl3d.Update(); plane = new vtkPlane(); plane.SetOrigin(pl3d.GetOutput().GetCenter()[0],pl3d.GetOutput().GetCenter()[1],pl3d.GetOutput().GetCenter()[2]); plane.SetNormal((double)-0.287,(double)0,(double)0.9579); planeCut = new vtkCutter(); planeCut.SetInputConnection((vtkAlgorithmOutput)pl3d.GetOutputPort()); planeCut.SetCutFunction((vtkImplicitFunction)plane); probe = new vtkProbeFilter(); probe.SetInputConnection((vtkAlgorithmOutput)planeCut.GetOutputPort()); probe.SetSourceConnection((vtkAlgorithmOutput)pl3d.GetOutputPort()); cutMapper = new vtkDataSetMapper(); cutMapper.SetInputConnection((vtkAlgorithmOutput)probe.GetOutputPort()); cutMapper.SetScalarRange((double)((vtkStructuredGrid)pl3d.GetOutput()).GetPointData().GetScalars().GetRange()[0], (double)((vtkStructuredGrid)pl3d.GetOutput()).GetPointData().GetScalars().GetRange()[1]); cutActor = new vtkActor(); cutActor.SetMapper((vtkMapper)cutMapper); //extract plane[] compPlane = new vtkStructuredGridGeometryFilter(); compPlane.SetInputConnection((vtkAlgorithmOutput)pl3d.GetOutputPort()); compPlane.SetExtent((int)0,(int)100,(int)0,(int)100,(int)9,(int)9); planeMapper = vtkPolyDataMapper.New(); planeMapper.SetInputConnection((vtkAlgorithmOutput)compPlane.GetOutputPort()); planeMapper.ScalarVisibilityOff(); planeActor = new vtkActor(); planeActor.SetMapper((vtkMapper)planeMapper); planeActor.GetProperty().SetRepresentationToWireframe(); planeActor.GetProperty().SetColor((double)0,(double)0,(double)0); //outline[] outline = new vtkStructuredGridOutlineFilter(); outline.SetInputConnection((vtkAlgorithmOutput)pl3d.GetOutputPort()); outlineMapper = vtkPolyDataMapper.New(); outlineMapper.SetInputConnection((vtkAlgorithmOutput)outline.GetOutputPort()); outlineActor = new vtkActor(); outlineActor.SetMapper((vtkMapper)outlineMapper); outlineProp = outlineActor.GetProperty(); outlineProp.SetColor((double)0,(double)0,(double)0); // Add the actors to the renderer, set the background and size[] //[] ren1.AddActor((vtkProp)outlineActor); ren1.AddActor((vtkProp)planeActor); ren1.AddActor((vtkProp)cutActor); ren1.SetBackground((double)1,(double)1,(double)1); renWin.SetSize((int)400,(int)300); cam1 = ren1.GetActiveCamera(); cam1.SetClippingRange((double)11.1034,(double)59.5328); cam1.SetFocalPoint((double)9.71821,(double)0.458166,(double)29.3999); cam1.SetPosition((double)-2.95748,(double)-26.7271,(double)44.5309); cam1.SetViewUp((double)0.0184785,(double)0.479657,(double)0.877262); iren.Initialize(); // render the image[] //[] // prevent the tk window from showing up then start the event loop[] //deleteAllVTKObjects(); }
///<summary> A Set Method for Static Variables </summary> public static void Setplane(vtkPlane toSet) { plane = toSet; }
/// <summary> /// The main entry method called by the CSharp driver /// </summary> /// <param name="argv"></param> public static void AVrectGrid(String [] argv) { //Prefix Content is: "" VTK_VARY_RADIUS_BY_VECTOR = 2; // create pipeline[] //[] reader = new vtkDataSetReader(); reader.SetFileName((string)"" + (VTK_DATA_ROOT.ToString()) + "/Data/RectGrid2.vtk"); reader.Update(); toRectilinearGrid = new vtkCastToConcrete(); toRectilinearGrid.SetInputConnection((vtkAlgorithmOutput)reader.GetOutputPort()); toRectilinearGrid.Update(); plane = new vtkRectilinearGridGeometryFilter(); plane.SetInputData((vtkDataObject)toRectilinearGrid.GetRectilinearGridOutput()); plane.SetExtent((int)0, (int)100, (int)0, (int)100, (int)15, (int)15); warper = new vtkWarpVector(); warper.SetInputConnection((vtkAlgorithmOutput)plane.GetOutputPort()); warper.SetScaleFactor((double)0.05); planeMapper = new vtkDataSetMapper(); planeMapper.SetInputConnection((vtkAlgorithmOutput)warper.GetOutputPort()); planeMapper.SetScalarRange((double)0.197813, (double)0.710419); planeActor = new vtkActor(); planeActor.SetMapper((vtkMapper)planeMapper); cutPlane = new vtkPlane(); cutPlane.SetOrigin(reader.GetOutput().GetCenter()[0], reader.GetOutput().GetCenter()[1], reader.GetOutput().GetCenter()[2]); cutPlane.SetNormal((double)1, (double)0, (double)0); planeCut = new vtkCutter(); planeCut.SetInputData((vtkDataObject)toRectilinearGrid.GetRectilinearGridOutput()); planeCut.SetCutFunction((vtkImplicitFunction)cutPlane); cutMapper = new vtkDataSetMapper(); cutMapper.SetInputConnection((vtkAlgorithmOutput)planeCut.GetOutputPort()); cutMapper.SetScalarRange((double)((vtkDataSet)reader.GetOutput()).GetPointData().GetScalars().GetRange()[0], (double)((vtkDataSet)reader.GetOutput()).GetPointData().GetScalars().GetRange()[1]); cutActor = new vtkActor(); cutActor.SetMapper((vtkMapper)cutMapper); iso = new vtkContourFilter(); iso.SetInputData((vtkDataObject)toRectilinearGrid.GetRectilinearGridOutput()); iso.SetValue((int)0, (double)0.7); normals = new vtkPolyDataNormals(); normals.SetInputConnection((vtkAlgorithmOutput)iso.GetOutputPort()); normals.SetFeatureAngle((double)45); isoMapper = vtkPolyDataMapper.New(); isoMapper.SetInputConnection((vtkAlgorithmOutput)normals.GetOutputPort()); isoMapper.ScalarVisibilityOff(); isoActor = new vtkActor(); isoActor.SetMapper((vtkMapper)isoMapper); isoActor.GetProperty().SetColor((double)1.0000, 0.8941, 0.7686); isoActor.GetProperty().SetRepresentationToWireframe(); streamer = new vtkStreamLine(); streamer.SetInputConnection((vtkAlgorithmOutput)reader.GetOutputPort()); streamer.SetStartPosition((double)-1.2, (double)-0.1, (double)1.3); streamer.SetMaximumPropagationTime((double)500); streamer.SetStepLength((double)0.05); streamer.SetIntegrationStepLength((double)0.05); streamer.SetIntegrationDirectionToIntegrateBothDirections(); streamTube = new vtkTubeFilter(); streamTube.SetInputConnection((vtkAlgorithmOutput)streamer.GetOutputPort()); streamTube.SetRadius((double)0.025); streamTube.SetNumberOfSides((int)6); streamTube.SetVaryRadius((int)VTK_VARY_RADIUS_BY_VECTOR); mapStreamTube = vtkPolyDataMapper.New(); mapStreamTube.SetInputConnection((vtkAlgorithmOutput)streamTube.GetOutputPort()); mapStreamTube.SetScalarRange((double)((vtkDataSet)reader.GetOutput()).GetPointData().GetScalars().GetRange()[0], (double)((vtkDataSet)reader.GetOutput()).GetPointData().GetScalars().GetRange()[1]); streamTubeActor = new vtkActor(); streamTubeActor.SetMapper((vtkMapper)mapStreamTube); streamTubeActor.GetProperty().BackfaceCullingOn(); outline = new vtkOutlineFilter(); outline.SetInputData((vtkDataObject)toRectilinearGrid.GetRectilinearGridOutput()); outlineMapper = vtkPolyDataMapper.New(); outlineMapper.SetInputConnection((vtkAlgorithmOutput)outline.GetOutputPort()); outlineActor = new vtkActor(); outlineActor.SetMapper((vtkMapper)outlineMapper); outlineActor.GetProperty().SetColor((double)0.0000, 0.0000, 0.0000); // Graphics stuff[] // Create the RenderWindow, Renderer and both Actors[] //[] ren1 = vtkRenderer.New(); renWin = vtkRenderWindow.New(); renWin.SetMultiSamples(0); renWin.AddRenderer((vtkRenderer)ren1); iren = new vtkRenderWindowInteractor(); iren.SetRenderWindow((vtkRenderWindow)renWin); // Add the actors to the renderer, set the background and size[] //[] ren1.AddActor((vtkProp)outlineActor); ren1.AddActor((vtkProp)planeActor); ren1.AddActor((vtkProp)cutActor); ren1.AddActor((vtkProp)isoActor); ren1.AddActor((vtkProp)streamTubeActor); ren1.SetBackground((double)1, (double)1, (double)1); renWin.SetSize((int)400, (int)400); cam1 = ren1.GetActiveCamera(); cam1.SetClippingRange((double)3.76213, (double)10.712); cam1.SetFocalPoint((double)-0.0842503, (double)-0.136905, (double)0.610234); cam1.SetPosition((double)2.53813, (double)2.2678, (double)-5.22172); cam1.SetViewUp((double)-0.241047, (double)0.930635, (double)0.275343); iren.Initialize(); // render the image[] //[] // prevent the tk window from showing up then start the event loop[] //deleteAllVTKObjects(); }
protected override void Initialize() { base.Initialize(); if (Algorithm == null) Algorithm = vtkClipDataSet.New(); Flip = _flip; if (_plane == null) _plane = vtkPlane.New(); PlanePosition = _planePosition; PlaneAxis = _planeAxis; var clip = (vtkClipDataSet) Algorithm; clip.GenerateClipScalarsOn(); clip.SetClipFunction(_plane); Name = "ClipDataSet"; InputDataType = DataType.vtkUnstructuredGrid; OutputDataDataType = (DataType)Enum.Parse(typeof(DataType), Algorithm.GetOutputPortInformation(0).Get(vtkDataObject.DATA_TYPE_NAME())); InitializeFinish(); }
/// <summary> /// The main entry method called by the CSharp driver /// </summary> /// <param name="argv"></param> public static void AVfieldToRGrid(String [] argv) { //Prefix Content is: "" //# Generate a rectilinear grid from a field.[] //#[] // get the interactor ui[] // Create a reader and write out the field[] reader = new vtkDataSetReader(); reader.SetFileName((string)"" + (VTK_DATA_ROOT.ToString()) + "/Data/RectGrid2.vtk"); ds2do = new vtkDataSetToDataObjectFilter(); ds2do.SetInputConnection((vtkAlgorithmOutput)reader.GetOutputPort()); try { channel = new StreamWriter("RGridField.vtk"); tryCatchError = "NOERROR"; } catch(Exception) {tryCatchError = "ERROR";} if(tryCatchError.Equals("NOERROR")) { channel.Close(); writer = new vtkDataObjectWriter(); writer.SetInputConnection((vtkAlgorithmOutput)ds2do.GetOutputPort()); writer.SetFileName((string)"RGridField.vtk"); writer.Write(); // Read the field[] //[] dor = new vtkDataObjectReader(); dor.SetFileName((string)"RGridField.vtk"); do2ds = new vtkDataObjectToDataSetFilter(); do2ds.SetInputConnection((vtkAlgorithmOutput)dor.GetOutputPort()); do2ds.SetDataSetTypeToRectilinearGrid(); do2ds.SetDimensionsComponent((string)"Dimensions",(int)0); do2ds.SetPointComponent((int)0,(string)"XCoordinates",(int)0); do2ds.SetPointComponent((int)1,(string)"YCoordinates",(int)0); do2ds.SetPointComponent((int)2,(string)"ZCoordinates",(int)0); fd2ad = new vtkFieldDataToAttributeDataFilter(); fd2ad.SetInput((vtkDataObject)do2ds.GetRectilinearGridOutput()); fd2ad.SetInputFieldToDataObjectField(); fd2ad.SetOutputAttributeDataToPointData(); fd2ad.SetVectorComponent((int)0,(string)"vectors",(int)0); fd2ad.SetVectorComponent((int)1,(string)"vectors",(int)1); fd2ad.SetVectorComponent((int)2,(string)"vectors",(int)2); fd2ad.SetScalarComponent((int)0,(string)"scalars",(int)0); fd2ad.Update(); // create pipeline[] //[] plane = new vtkRectilinearGridGeometryFilter(); plane.SetInput((vtkDataObject)fd2ad.GetRectilinearGridOutput()); plane.SetExtent((int)0,(int)100,(int)0,(int)100,(int)15,(int)15); warper = new vtkWarpVector(); warper.SetInputConnection((vtkAlgorithmOutput)plane.GetOutputPort()); warper.SetScaleFactor((double)0.05); planeMapper = new vtkDataSetMapper(); planeMapper.SetInputConnection((vtkAlgorithmOutput)warper.GetOutputPort()); planeMapper.SetScalarRange((double)0.197813,(double)0.710419); planeActor = new vtkActor(); planeActor.SetMapper((vtkMapper)planeMapper); cutPlane = new vtkPlane(); cutPlane.SetOrigin(fd2ad.GetOutput().GetCenter()[0],fd2ad.GetOutput().GetCenter()[1],fd2ad.GetOutput().GetCenter()[2]); cutPlane.SetNormal((double)1,(double)0,(double)0); planeCut = new vtkCutter(); planeCut.SetInput((vtkDataObject)fd2ad.GetRectilinearGridOutput()); planeCut.SetCutFunction((vtkImplicitFunction)cutPlane); cutMapper = new vtkDataSetMapper(); cutMapper.SetInputConnection((vtkAlgorithmOutput)planeCut.GetOutputPort()); cutMapper.SetScalarRange( (double)((vtkDataSet)fd2ad.GetOutput()).GetPointData().GetScalars().GetRange()[0], (double)((vtkDataSet)fd2ad.GetOutput()).GetPointData().GetScalars().GetRange()[1]); cutActor = new vtkActor(); cutActor.SetMapper((vtkMapper)cutMapper); iso = new vtkContourFilter(); iso.SetInput((vtkDataObject)fd2ad.GetRectilinearGridOutput()); iso.SetValue((int)0,(double)0.7); normals = new vtkPolyDataNormals(); normals.SetInputConnection((vtkAlgorithmOutput)iso.GetOutputPort()); normals.SetFeatureAngle((double)45); isoMapper = vtkPolyDataMapper.New(); isoMapper.SetInputConnection((vtkAlgorithmOutput)normals.GetOutputPort()); isoMapper.ScalarVisibilityOff(); isoActor = new vtkActor(); isoActor.SetMapper((vtkMapper)isoMapper); isoActor.GetProperty().SetColor((double) 1.0000, 0.8941, 0.7686 ); isoActor.GetProperty().SetRepresentationToWireframe(); streamer = new vtkStreamLine(); streamer.SetInputConnection((vtkAlgorithmOutput)fd2ad.GetOutputPort()); streamer.SetStartPosition((double)-1.2,(double)-0.1,(double)1.3); streamer.SetMaximumPropagationTime((double)500); streamer.SetStepLength((double)0.05); streamer.SetIntegrationStepLength((double)0.05); streamer.SetIntegrationDirectionToIntegrateBothDirections(); streamTube = new vtkTubeFilter(); streamTube.SetInputConnection((vtkAlgorithmOutput)streamer.GetOutputPort()); streamTube.SetRadius((double)0.025); streamTube.SetNumberOfSides((int)6); streamTube.SetVaryRadiusToVaryRadiusByVector(); mapStreamTube = vtkPolyDataMapper.New(); mapStreamTube.SetInputConnection((vtkAlgorithmOutput)streamTube.GetOutputPort()); mapStreamTube.SetScalarRange( (double)((vtkDataSet)fd2ad.GetOutput()).GetPointData().GetScalars().GetRange()[0], (double)((vtkDataSet)fd2ad.GetOutput()).GetPointData().GetScalars().GetRange()[1]); streamTubeActor = new vtkActor(); streamTubeActor.SetMapper((vtkMapper)mapStreamTube); streamTubeActor.GetProperty().BackfaceCullingOn(); outline = new vtkOutlineFilter(); outline.SetInput((vtkDataObject)fd2ad.GetRectilinearGridOutput()); outlineMapper = vtkPolyDataMapper.New(); outlineMapper.SetInputConnection((vtkAlgorithmOutput)outline.GetOutputPort()); outlineActor = new vtkActor(); outlineActor.SetMapper((vtkMapper)outlineMapper); outlineActor.GetProperty().SetColor((double) 0.0000, 0.0000, 0.0000 ); // Graphics stuff[] // Create the RenderWindow, Renderer and both Actors[] //[] ren1 = vtkRenderer.New(); renWin = vtkRenderWindow.New(); renWin.AddRenderer((vtkRenderer)ren1); iren = new vtkRenderWindowInteractor(); iren.SetRenderWindow((vtkRenderWindow)renWin); // Add the actors to the renderer, set the background and size[] //[] ren1.AddActor((vtkProp)outlineActor); ren1.AddActor((vtkProp)planeActor); ren1.AddActor((vtkProp)cutActor); ren1.AddActor((vtkProp)isoActor); ren1.AddActor((vtkProp)streamTubeActor); ren1.SetBackground((double)1,(double)1,(double)1); renWin.SetSize((int)300,(int)300); ren1.GetActiveCamera().SetPosition((double)0.0390893,(double)0.184813,(double)-3.94026); ren1.GetActiveCamera().SetFocalPoint((double)-0.00578326,(double)0,(double)0.701967); ren1.GetActiveCamera().SetViewAngle((double)30); ren1.GetActiveCamera().SetViewUp((double)0.00850257,(double)0.999169,(double)0.0398605); ren1.GetActiveCamera().SetClippingRange((double)3.08127,(double)6.62716); iren.Initialize(); // render the image[] //[] File.Delete("RGridField.vtk"); } // prevent the tk window from showing up then start the event loop[] //deleteAllVTKObjects(); }
private void CreateClipPlane() { // Clip Plane ClipPlane = vtkPlane.New(); vtkPoints ClipPoints = vtkPoints.New(); ClipPlaneSize = 1; for (int i = 0; i < 10; i++) { for (int j = 0; j < 10; j++) { double y = j * ClipPlaneSize / 9 - ClipPlaneSize / 2; double z = i * ClipPlaneSize / 9 - ClipPlaneSize / 2; ClipPoints.InsertNextPoint(0, y, z); } } vtkUnstructuredGrid ClipGrid = vtkUnstructuredGrid.New(); ClipGrid.SetPoints(ClipPoints); for (int i = 0; i < 9; i++) { for (int j = 0; j < 9; j++) { vtkQuad quad = vtkQuad.New(); quad.GetPointIds().SetId(0, i * 10 + j); quad.GetPointIds().SetId(1, i * 10 + j + 1); quad.GetPointIds().SetId(2, (i + 1) * 10 + j + 1); quad.GetPointIds().SetId(3, (i + 1) * 10 + j); ClipGrid.InsertNextCell(quad.GetCellType(), quad.GetPointIds()); } } vtkDataSetMapper ClipMapper = vtkDataSetMapper.New(); ClipMapper.SetInput(ClipGrid); ClipPlaneActor = vtkActor.New(); ClipPlaneActor.SetMapper(ClipMapper); ClipPlaneActor.GetProperty().EdgeVisibilityOn(); ClipPlaneActor.GetProperty().SetColor(195.0 / 255.0, 195.0 / 255.0, 195.0 / 255.0); ClipPlaneActor.GetProperty().SetOpacity(0.1); ClipPlaneActor.VisibilityOff(); Viewport.AddActor(ClipPlaneActor); // ------------- Clip Plane Buttons -------------------------------------------- Grid = CreateClipButton("Grid OFF", new double[2] { 0.875, 0.39 }, 8); Grid.StartInteractionEvt += new vtkObject.vtkObjectEventHandler(ShowGrid); Reverse = CreateClipButton("Reverse", new double[2] { 0.875, 0.34 }, 8); Reverse.StartInteractionEvt += new vtkObject.vtkObjectEventHandler(ReverseClipPlaneNormal); ClipX = CreateClipButton("Clip X", new double[2] { 0.88, 0.29 }, 8); ClipX.StartInteractionEvt += new vtkObject.vtkObjectEventHandler(SetClipPlaneNormal); ClipY = CreateClipButton("Clip Y", new double[2] { 0.88, 0.24 }, 8); ClipY.StartInteractionEvt += new vtkObject.vtkObjectEventHandler(SetClipPlaneNormal); ClipZ = CreateClipButton("Clip Z", new double[2] { 0.88, 0.19 }, 8); ClipZ.StartInteractionEvt += new vtkObject.vtkObjectEventHandler(SetClipPlaneNormal); }
public void SetClippingPlane(vtkPlane clippingPlane) { _mapper.RemoveAllClippingPlanes(); _mapper.AddClippingPlane(clippingPlane); _mapper.Modified(); }
private void InitPlaneCollection(vtkPlaneCollection planeCollection) { var planeX1 = new vtkPlane(); planeX1.SetNormal(1, 0, 0); planeX1.SetOrigin(0, 0, 0); planeCollection.AddItem(planeX1); var planeX2 = new vtkPlane(); planeX2.SetNormal(-1, 0, 0); planeX2.SetOrigin(_xSize, 0, 0); planeCollection.AddItem(planeX2); var planeY1 = new vtkPlane(); planeY1.SetNormal(0, 1, 0); planeY1.SetOrigin(0, 0, 0); planeCollection.AddItem(planeY1); var planeY2 = new vtkPlane(); planeY2.SetNormal(0, -1, 0); planeY2.SetOrigin(0, _ySize, 0); planeCollection.AddItem(planeY2); var planeZ1 = new vtkPlane(); planeZ1.SetNormal(0, 0, 1); planeZ1.SetOrigin(0, 0, 0); planeCollection.AddItem(planeZ1); var planeZ2 = new vtkPlane(); planeZ2.SetNormal(0, 0, -1); planeZ2.SetOrigin(0, 0, _zSize); planeCollection.AddItem(planeZ2); }
public void SetClippingPlane(vtkPlane clippingPlane) { RemoveAllClippingPlanes(); _polyDataMapper.AddClippingPlane(clippingPlane); }
/// <summary> /// The main entry method called by the CSharp driver /// </summary> /// <param name="argv"></param> public static void AVfieldToRGrid(String [] argv) { //Prefix Content is: "" //# Generate a rectilinear grid from a field.[] //#[] // get the interactor ui[] // Create a reader and write out the field[] reader = new vtkDataSetReader(); reader.SetFileName((string)"" + (VTK_DATA_ROOT.ToString()) + "/Data/RectGrid2.vtk"); ds2do = new vtkDataSetToDataObjectFilter(); ds2do.SetInputConnection((vtkAlgorithmOutput)reader.GetOutputPort()); try { channel = new StreamWriter("RGridField.vtk"); tryCatchError = "NOERROR"; } catch (Exception) { tryCatchError = "ERROR"; } if (tryCatchError.Equals("NOERROR")) { channel.Close(); writer = new vtkDataObjectWriter(); writer.SetInputConnection((vtkAlgorithmOutput)ds2do.GetOutputPort()); writer.SetFileName((string)"RGridField.vtk"); writer.Write(); // Read the field[] //[] dor = new vtkDataObjectReader(); dor.SetFileName((string)"RGridField.vtk"); do2ds = new vtkDataObjectToDataSetFilter(); do2ds.SetInputConnection((vtkAlgorithmOutput)dor.GetOutputPort()); do2ds.SetDataSetTypeToRectilinearGrid(); do2ds.SetDimensionsComponent((string)"Dimensions", (int)0); do2ds.SetPointComponent((int)0, (string)"XCoordinates", (int)0); do2ds.SetPointComponent((int)1, (string)"YCoordinates", (int)0); do2ds.SetPointComponent((int)2, (string)"ZCoordinates", (int)0); do2ds.Update(); fd2ad = new vtkFieldDataToAttributeDataFilter(); fd2ad.SetInputData((vtkDataObject)do2ds.GetRectilinearGridOutput()); fd2ad.SetInputFieldToDataObjectField(); fd2ad.SetOutputAttributeDataToPointData(); fd2ad.SetVectorComponent((int)0, (string)"vectors", (int)0); fd2ad.SetVectorComponent((int)1, (string)"vectors", (int)1); fd2ad.SetVectorComponent((int)2, (string)"vectors", (int)2); fd2ad.SetScalarComponent((int)0, (string)"scalars", (int)0); fd2ad.Update(); // create pipeline[] //[] plane = new vtkRectilinearGridGeometryFilter(); plane.SetInputData((vtkDataObject)fd2ad.GetRectilinearGridOutput()); plane.SetExtent((int)0, (int)100, (int)0, (int)100, (int)15, (int)15); warper = new vtkWarpVector(); warper.SetInputConnection((vtkAlgorithmOutput)plane.GetOutputPort()); warper.SetScaleFactor((double)0.05); planeMapper = new vtkDataSetMapper(); planeMapper.SetInputConnection((vtkAlgorithmOutput)warper.GetOutputPort()); planeMapper.SetScalarRange((double)0.197813, (double)0.710419); planeActor = new vtkActor(); planeActor.SetMapper((vtkMapper)planeMapper); cutPlane = new vtkPlane(); cutPlane.SetOrigin(fd2ad.GetOutput().GetCenter()[0], fd2ad.GetOutput().GetCenter()[1], fd2ad.GetOutput().GetCenter()[2]); cutPlane.SetNormal((double)1, (double)0, (double)0); planeCut = new vtkCutter(); planeCut.SetInputData((vtkDataObject)fd2ad.GetRectilinearGridOutput()); planeCut.SetCutFunction((vtkImplicitFunction)cutPlane); cutMapper = new vtkDataSetMapper(); cutMapper.SetInputConnection((vtkAlgorithmOutput)planeCut.GetOutputPort()); cutMapper.SetScalarRange( (double)((vtkDataSet)fd2ad.GetOutput()).GetPointData().GetScalars().GetRange()[0], (double)((vtkDataSet)fd2ad.GetOutput()).GetPointData().GetScalars().GetRange()[1]); cutActor = new vtkActor(); cutActor.SetMapper((vtkMapper)cutMapper); iso = new vtkContourFilter(); iso.SetInputData((vtkDataObject)fd2ad.GetRectilinearGridOutput()); iso.SetValue((int)0, (double)0.7); normals = new vtkPolyDataNormals(); normals.SetInputConnection((vtkAlgorithmOutput)iso.GetOutputPort()); normals.SetFeatureAngle((double)45); isoMapper = vtkPolyDataMapper.New(); isoMapper.SetInputConnection((vtkAlgorithmOutput)normals.GetOutputPort()); isoMapper.ScalarVisibilityOff(); isoActor = new vtkActor(); isoActor.SetMapper((vtkMapper)isoMapper); isoActor.GetProperty().SetColor((double)1.0000, 0.8941, 0.7686); isoActor.GetProperty().SetRepresentationToWireframe(); streamer = new vtkStreamLine(); streamer.SetInputConnection((vtkAlgorithmOutput)fd2ad.GetOutputPort()); streamer.SetStartPosition((double)-1.2, (double)-0.1, (double)1.3); streamer.SetMaximumPropagationTime((double)500); streamer.SetStepLength((double)0.05); streamer.SetIntegrationStepLength((double)0.05); streamer.SetIntegrationDirectionToIntegrateBothDirections(); streamTube = new vtkTubeFilter(); streamTube.SetInputConnection((vtkAlgorithmOutput)streamer.GetOutputPort()); streamTube.SetRadius((double)0.025); streamTube.SetNumberOfSides((int)6); streamTube.SetVaryRadiusToVaryRadiusByVector(); mapStreamTube = vtkPolyDataMapper.New(); mapStreamTube.SetInputConnection((vtkAlgorithmOutput)streamTube.GetOutputPort()); mapStreamTube.SetScalarRange( (double)((vtkDataSet)fd2ad.GetOutput()).GetPointData().GetScalars().GetRange()[0], (double)((vtkDataSet)fd2ad.GetOutput()).GetPointData().GetScalars().GetRange()[1]); streamTubeActor = new vtkActor(); streamTubeActor.SetMapper((vtkMapper)mapStreamTube); streamTubeActor.GetProperty().BackfaceCullingOn(); outline = new vtkOutlineFilter(); outline.SetInputData((vtkDataObject)fd2ad.GetRectilinearGridOutput()); outlineMapper = vtkPolyDataMapper.New(); outlineMapper.SetInputConnection((vtkAlgorithmOutput)outline.GetOutputPort()); outlineActor = new vtkActor(); outlineActor.SetMapper((vtkMapper)outlineMapper); outlineActor.GetProperty().SetColor((double)0.0000, 0.0000, 0.0000); // Graphics stuff[] // Create the RenderWindow, Renderer and both Actors[] //[] ren1 = vtkRenderer.New(); renWin = vtkRenderWindow.New(); renWin.SetMultiSamples(0); renWin.AddRenderer((vtkRenderer)ren1); iren = new vtkRenderWindowInteractor(); iren.SetRenderWindow((vtkRenderWindow)renWin); // Add the actors to the renderer, set the background and size[] //[] ren1.AddActor((vtkProp)outlineActor); ren1.AddActor((vtkProp)planeActor); ren1.AddActor((vtkProp)cutActor); ren1.AddActor((vtkProp)isoActor); ren1.AddActor((vtkProp)streamTubeActor); ren1.SetBackground((double)1, (double)1, (double)1); renWin.SetSize((int)300, (int)300); ren1.GetActiveCamera().SetPosition((double)0.0390893, (double)0.184813, (double)-3.94026); ren1.GetActiveCamera().SetFocalPoint((double)-0.00578326, (double)0, (double)0.701967); ren1.GetActiveCamera().SetViewAngle((double)30); ren1.GetActiveCamera().SetViewUp((double)0.00850257, (double)0.999169, (double)0.0398605); ren1.GetActiveCamera().SetClippingRange((double)3.08127, (double)6.62716); iren.Initialize(); // render the image[] //[] File.Delete("RGridField.vtk"); } // prevent the tk window from showing up then start the event loop[] //deleteAllVTKObjects(); }
private void ContoursFromPolyData(string filePath) { vtkPolyData inputPolyData; if (filePath != null) { vtkXMLPolyDataReader reader = vtkXMLPolyDataReader.New(); reader.SetFileName(filePath); reader.Update(); inputPolyData = reader.GetOutput(); } else { vtkSphereSource sphereSource = vtkSphereSource.New(); sphereSource.SetThetaResolution(30); sphereSource.SetPhiResolution(15); sphereSource.Update(); inputPolyData = sphereSource.GetOutput(); } vtkPolyDataMapper inputMapper = vtkPolyDataMapper.New(); #if VTK_MAJOR_VERSION_5 inputMapper.SetInput(inputPolyData); #else inputMapper.SetInputData(inputPolyData); #endif // Create a plane to cut vtkPlane plane = vtkPlane.New(); double[] center = inputPolyData.GetCenter(); double[] bounds = inputPolyData.GetBounds(); plane.SetOrigin(center[0], center[1], center[2]); plane.SetNormal(1, 1, 1); float[] centerf = new float[] { (float)center[0], (float)center[1], (float)center[2] }; float[] minBoundf = new float[] { (float)bounds[0], (float)bounds[2], (float)bounds[4] }; float[] maxBoundf = new float[] { (float)bounds[1], (float)bounds[3], (float)bounds[5] }; IntPtr pCenter = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(float)) * 3); IntPtr pMinBound = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(float)) * 3); IntPtr pMaxBound = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(float)) * 3); Marshal.Copy(centerf, 0, pCenter, 3); Marshal.Copy(minBoundf, 0, pMinBound, 3); Marshal.Copy(maxBoundf, 0, pMaxBound, 3); // vtkMath.Distance2BetweenPoints accepts floats only double distanceMin = Math.Sqrt(vtkMath.Distance2BetweenPoints(pMinBound, pCenter)); double distanceMax = Math.Sqrt(vtkMath.Distance2BetweenPoints(pMaxBound, pCenter)); Marshal.FreeHGlobal(pCenter); Marshal.FreeHGlobal(pMinBound); Marshal.FreeHGlobal(pMaxBound); // Create cutter vtkCutter cutter = vtkCutter.New(); cutter.SetCutFunction(plane); #if VTK_MAJOR_VERSION_5 cutter.SetInput(inputPolyData); #else cutter.SetInputData(inputPolyData); #endif cutter.GenerateValues(20, -distanceMin, distanceMax); vtkPolyDataMapper cutterMapper = vtkPolyDataMapper.New(); cutterMapper.SetInputConnection(cutter.GetOutputPort()); cutterMapper.ScalarVisibilityOff(); // Create plane actor vtkActor planeActor = vtkActor.New(); planeActor.GetProperty().SetColor(1.0, 0.0, 0.0); planeActor.GetProperty().SetLineWidth(3); planeActor.SetMapper(cutterMapper); // Create input actor vtkActor inputActor = vtkActor.New(); inputActor.GetProperty().SetColor(1.0, 0.8941, 0.7686); // bisque inputActor.SetMapper(inputMapper); // get a reference to the renderwindow of our renderWindowControl1 vtkRenderWindow renderWindow = renderWindowControl1.RenderWindow; // renderer vtkRenderer renderer = renderWindow.GetRenderers().GetFirstRenderer(); // set background color renderer.SetBackground(.2, .3, .4); renderer.AddActor(inputActor); renderer.AddActor(planeActor); //display the contour lines }
/// <summary> /// The main entry method called by the CSharp driver /// </summary> /// <param name="argv"></param> public static void AVEnSightRectGridASCII(String [] argv) { //Prefix Content is: "" VTK_VARY_RADIUS_BY_VECTOR = 2; // create pipeline[] //[] reader = new vtkGenericEnSightReader(); // Make sure all algorithms use the composite data pipeline[] cdp = new vtkCompositeDataPipeline(); vtkGenericEnSightReader.SetDefaultExecutivePrototype((vtkExecutive)cdp); reader.SetCaseFileName((string)"" + (VTK_DATA_ROOT.ToString()) + "/Data/EnSight/RectGrid_ascii.case"); reader.Update(); toRectilinearGrid = new vtkCastToConcrete(); // toRectilinearGrid SetInputConnection [reader GetOutputPort] [] toRectilinearGrid.SetInput((vtkDataObject)reader.GetOutput().GetBlock((uint)0)); plane = new vtkRectilinearGridGeometryFilter(); plane.SetInput((vtkDataObject)toRectilinearGrid.GetRectilinearGridOutput()); plane.SetExtent((int)0,(int)100,(int)0,(int)100,(int)15,(int)15); tri = new vtkTriangleFilter(); tri.SetInputConnection((vtkAlgorithmOutput)plane.GetOutputPort()); warper = new vtkWarpVector(); warper.SetInputConnection((vtkAlgorithmOutput)tri.GetOutputPort()); warper.SetScaleFactor((double)0.05); planeMapper = new vtkDataSetMapper(); planeMapper.SetInputConnection((vtkAlgorithmOutput)warper.GetOutputPort()); planeMapper.SetScalarRange((double)0.197813,(double)0.710419); planeActor = new vtkActor(); planeActor.SetMapper((vtkMapper)planeMapper); cutPlane = new vtkPlane(); // eval cutPlane SetOrigin [[reader GetOutput] GetCenter][] cutPlane.SetOrigin((double)((vtkDataSet)reader.GetOutput().GetBlock((uint)0)).GetCenter()[0], (double)((vtkDataSet)reader.GetOutput().GetBlock((uint)0)).GetCenter()[1], (double)((vtkDataSet)reader.GetOutput().GetBlock((uint)0)).GetCenter()[2]); cutPlane.SetNormal((double)1,(double)0,(double)0); planeCut = new vtkCutter(); planeCut.SetInput((vtkDataObject)toRectilinearGrid.GetRectilinearGridOutput()); planeCut.SetCutFunction((vtkImplicitFunction)cutPlane); cutMapper = new vtkDataSetMapper(); cutMapper.SetInputConnection((vtkAlgorithmOutput)planeCut.GetOutputPort()); cutMapper.SetScalarRange((double)((vtkDataSet)((vtkMultiBlockDataSet)reader.GetOutput()).GetBlock((uint)0)).GetPointData().GetScalars().GetRange()[0], (double)((vtkDataSet)((vtkMultiBlockDataSet)reader.GetOutput()).GetBlock((uint)0)).GetPointData().GetScalars().GetRange()[1]); cutActor = new vtkActor(); cutActor.SetMapper((vtkMapper)cutMapper); iso = new vtkContourFilter(); iso.SetInput((vtkDataObject)toRectilinearGrid.GetRectilinearGridOutput()); iso.SetValue((int)0,(double)0.7); normals = new vtkPolyDataNormals(); normals.SetInputConnection((vtkAlgorithmOutput)iso.GetOutputPort()); normals.SetFeatureAngle((double)45); isoMapper = vtkPolyDataMapper.New(); isoMapper.SetInputConnection((vtkAlgorithmOutput)normals.GetOutputPort()); isoMapper.ScalarVisibilityOff(); isoActor = new vtkActor(); isoActor.SetMapper((vtkMapper)isoMapper); isoActor.GetProperty().SetColor((double) 1.0000, 0.8941, 0.7686 ); isoActor.GetProperty().SetRepresentationToWireframe(); streamer = new vtkStreamLine(); // streamer SetInputConnection [reader GetOutputPort][] streamer.SetInput((vtkDataObject)reader.GetOutput().GetBlock((uint)0)); streamer.SetStartPosition((double)-1.2,(double)-0.1,(double)1.3); streamer.SetMaximumPropagationTime((double)500); streamer.SetStepLength((double)0.05); streamer.SetIntegrationStepLength((double)0.05); streamer.SetIntegrationDirectionToIntegrateBothDirections(); streamTube = new vtkTubeFilter(); streamTube.SetInputConnection((vtkAlgorithmOutput)streamer.GetOutputPort()); streamTube.SetRadius((double)0.025); streamTube.SetNumberOfSides((int)6); streamTube.SetVaryRadius((int)VTK_VARY_RADIUS_BY_VECTOR); mapStreamTube = vtkPolyDataMapper.New(); mapStreamTube.SetInputConnection((vtkAlgorithmOutput)streamTube.GetOutputPort()); mapStreamTube.SetScalarRange((double)((vtkDataSet)reader.GetOutput().GetBlock((uint)0)).GetPointData().GetScalars().GetRange()[0], (double)((vtkDataSet)reader.GetOutput().GetBlock((uint)0)).GetPointData().GetScalars().GetRange()[1]); // [[[[reader GetOutput] GetPointData] GetScalars] GetRange][] streamTubeActor = new vtkActor(); streamTubeActor.SetMapper((vtkMapper)mapStreamTube); streamTubeActor.GetProperty().BackfaceCullingOn(); outline = new vtkOutlineFilter(); outline.SetInput((vtkDataObject)toRectilinearGrid.GetRectilinearGridOutput()); outlineMapper = vtkPolyDataMapper.New(); outlineMapper.SetInputConnection((vtkAlgorithmOutput)outline.GetOutputPort()); outlineActor = new vtkActor(); outlineActor.SetMapper((vtkMapper)outlineMapper); outlineActor.GetProperty().SetColor((double) 0.0000, 0.0000, 0.0000 ); // Graphics stuff[] // Create the RenderWindow, Renderer and both Actors[] //[] ren1 = vtkRenderer.New(); renWin = vtkRenderWindow.New(); renWin.AddRenderer((vtkRenderer)ren1); iren = new vtkRenderWindowInteractor(); iren.SetRenderWindow((vtkRenderWindow)renWin); // Add the actors to the renderer, set the background and size[] //[] ren1.AddActor((vtkProp)outlineActor); ren1.AddActor((vtkProp)planeActor); ren1.AddActor((vtkProp)cutActor); ren1.AddActor((vtkProp)isoActor); ren1.AddActor((vtkProp)streamTubeActor); ren1.SetBackground((double)1,(double)1,(double)1); renWin.SetSize((int)400,(int)400); cam1 = ren1.GetActiveCamera(); cam1.SetClippingRange((double)3.76213,(double)10.712); cam1.SetFocalPoint((double)-0.0842503,(double)-0.136905,(double)0.610234); cam1.SetPosition((double)2.53813,(double)2.2678,(double)-5.22172); cam1.SetViewUp((double)-0.241047,(double)0.930635,(double)0.275343); iren.Initialize(); // render the image[] //[] // prevent the tk window from showing up then start the event loop[] vtkGenericEnSightReader.SetDefaultExecutivePrototype(null); //deleteAllVTKObjects(); }
private void DrawTest() { vtkProp3D prop3D; vtkActor actor = vtkActor.New(); vtkActor2D actor2D = vtkActor2D.New(); vtkLODActor lODActor = vtkLODActor.New(); vtkLODProp3D lodProp3d = vtkLODProp3D.New(); vtkCamera camera = vtkCamera.New(); vtkCameraActor cameraActor = vtkCameraActor.New(); vtkLight light = vtkLight.New(); vtkLightActor lightActor = vtkLightActor.New(); vtkPicker picker = vtkPicker.New(); vtkPointPicker pointPicker = vtkPointPicker.New(); vtkCellPicker cellPicker = vtkCellPicker.New(); vtkAreaPicker areaPicker = vtkAreaPicker.New(); vtkAssembly assembly = vtkAssembly.New(); vtkConeSource coneSource = vtkConeSource.New(); vtkCone cone = vtkCone.New(); vtkArcSource arcSource = vtkArcSource.New(); vtkLineSource lineSource = vtkLineSource.New(); vtkPointSource pointSource = vtkPointSource.New(); vtkPolyData polyData = vtkPolyData.New(); vtkArrayReader arrayReader = vtkArrayReader.New(); vtkArrayDataReader arrayDataReader = vtkArrayDataReader.New(); vtkArrayWriter arrayWriter = vtkArrayWriter.New(); vtkRenderWindowInteractor renderWindowInteractor = vtkRenderWindowInteractor.New(); vtkRenderWindowInteractor3D renderWindowInteractor3D = vtkRenderWindowInteractor3D.New(); vtkInteractorStyle interactorStyle = vtkInteractorStyle.New(); vtkInteractorStyle3D interactorStyle3D = vtkInteractorStyle3D.New(); vtkInteractorStyleFlight interactorStyleFlight = vtkInteractorStyleFlight.New(); vtkInteractorStyleTrackball interactorStyleTrackball = vtkInteractorStyleTrackball.New(); vtkVolume volume = vtkVolume.New(); vtkVolumeMapper volumeMapper; vtkSmartVolumeMapper smartVolumeMapper = vtkSmartVolumeMapper.New(); vtkUnstructuredGridVolumeMapper unstructuredGridVolumeMapper; vtkUnstructuredGridVolumeRayCastMapper unstructuredGridVolumeRayCastMapper = vtkUnstructuredGridVolumeRayCastMapper.New(); vtkGPUVolumeRayCastMapper gPUVolumeRayCastMapper = vtkGPUVolumeRayCastMapper.New(); vtkVolumeRayCastMapper volumeRayCastMapper = vtkVolumeRayCastMapper.New(); vtkFixedPointVolumeRayCastMapper pointVolumeRayCastMapper = vtkFixedPointVolumeRayCastMapper.New(); vtkOpenGLGPUVolumeRayCastMapper openGLGPUVolumeRayCastMapper = vtkOpenGLGPUVolumeRayCastMapper.New(); vtkVolumeProperty volumeProperty = vtkVolumeProperty.New(); vtkTexture texture = vtkTexture.New(); vtkCoordinate coordinate = vtkCoordinate.New(); vtkImageData vtkImage = vtkImageData.New(); vtkBMPReader bMPReader = vtkBMPReader.New(); vtkJPEGReader jPEGReader = vtkJPEGReader.New(); vtkPNGReader pNGReader = vtkPNGReader.New(); vtkTIFFReader tIFFReader = vtkTIFFReader.New(); vtkOBJReader oBJReader = vtkOBJReader.New(); vtkContourFilter contourFilter = vtkContourFilter.New(); vtkSynchronizedTemplates2D synchronizedTemplates2D = vtkSynchronizedTemplates2D.New(); vtkSynchronizedTemplates3D synchronizedTemplates3D = vtkSynchronizedTemplates3D.New(); vtkSynchronizedTemplatesCutter3D synchronizedTemplatesCutter3D = vtkSynchronizedTemplatesCutter3D.New(); vtkImageMapper imageMapper = vtkImageMapper.New(); vtkImageSliceMapper imageSliceMapper = vtkImageSliceMapper.New(); vtkImageResliceMapper imageResliceMapper = vtkImageResliceMapper.New(); vtkStructuredGridReader structuredGridReader = vtkStructuredGridReader.New(); vtkRungeKutta4 integ = vtkRungeKutta4.New(); vtkStreamTracer streamer = vtkStreamTracer.New(); vtkTubeFilter streamTube = vtkTubeFilter.New(); vtkRuledSurfaceFilter ruledSurfaceFilter = vtkRuledSurfaceFilter.New(); vtkPlane plane = vtkPlane.New(); vtkCutter cutter = new vtkCutter(); vtkMergeFilter mergeFilter = vtkMergeFilter.New(); vtkImageLuminance imageLuminance = vtkImageLuminance.New(); vtkImageDataGeometryFilter imageDataGeometryFilter = vtkImageDataGeometryFilter.New(); vtkWarpScalar warpScalar = vtkWarpScalar.New(); vtkWarpVector warpVector = vtkWarpVector.New(); }