<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-2022-jp">
<style type="text/css" style="display:none;"><!-- P {margin-top:0;margin-bottom:0;} --></style>
</head>
<body dir="ltr">
<div id="divtagdefaultwrapper" style="font-size:12pt;color:#000000;font-family:Calibri,Helvetica,sans-serif;" dir="ltr">
<p style="margin-top:0;margin-bottom:0"></p>
<div><br>
</div>
<div>Hi,</div>
<div>I tested using the values below with fran_cut.vtk but I failed to get the area.</div>
<div>Please advice. Thank you so much!</div>
<div><br>
</div>
<div>vtkSmartPointer<vtkTransform> transform =</div>
<div><span style="white-space:pre"></span>vtkSmartPointer<vtkTransform>::New();</div>
<div><span style="white-space:pre"></span>transform->PreMultiply();</div>
<div><span style="white-space:pre"></span>transform->RotateZ(0.0);</div>
<div><span style="white-space:pre"></span>transform->RotateY(0.0);</div>
<div><span style="white-space:pre"></span>transform->RotateX(0.0);</div>
<div><span style="white-space:pre"></span>transform->Translate(0.5, -10.0, -590.0);</div>
<div><span style="white-space:pre"></span>transform->Scale(0.5, 0.2, 0.6);</div>
<div><span style="white-space:pre"></span>vtkSmartPointer<vtkBox> box =</div>
<div><span style="white-space:pre"></span>vtkSmartPointer<vtkBox>::New();</div>
<div><span style="white-space:pre"></span>box->SetBounds(-1.0, 1.0, -1.0, 1.0, -0.6, 0.6);</div>
<div><span style="white-space:pre"></span>box->SetTransform(transform);</div>
<br>
<p></p>
<br>
<br>
<div style="color: rgb(0, 0, 0);">
<hr style="display:inline-block;width:98%" tabindex="-1">
<div id="divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" style="font-size:11pt" color="#000000"><b>From:</b> kenichiro yoshimi <rccm.kyoshimi@gmail.com><br>
<b>Sent:</b> Saturday, August 11, 2018 11:08 AM<br>
<b>To:</b> polly_sukting@hotmail.com<br>
<b>Cc:</b> vtkusers<br>
<b>Subject:</b> Re: [vtkusers] How to extract a region using a box?</font>
<div> </div>
</div>
<div class="BodyFragment"><font size="2"><span style="font-size:11pt;">
<div class="PlainText">Hi,<br>
<br>
The Filter>Extract Cells By Region in ParaView uses vtkExtractGeometry<br>
class internally. So the following example may be helpful to automate<br>
polygon extractions with a specified box.<br>
<br>
--- ExtractGeometry.cxx ---<br>
#include <vtkBox.h><br>
#include <vtkCamera.h><br>
#include <vtkDataSetMapper.h><br>
#include <vtkExtractGeometry.h><br>
#include <vtkProperty.h><br>
#include <vtkRenderer.h><br>
#include <vtkRenderWindow.h><br>
#include <vtkRenderWindowInteractor.h><br>
#include <vtkSmartPointer.h><br>
#include <vtkSphereSource.h><br>
#include <vtkTransform.h><br>
<br>
int main (int, char *[])<br>
{<br>
  vtkSmartPointer<vtkSphereSource> sphere =<br>
    vtkSmartPointer<vtkSphereSource>::New();<br>
  sphere->SetRadius(0.5);<br>
  sphere->SetPhiResolution(50);<br>
  sphere->SetThetaResolution(50);<br>
  sphere->Update();<br>
<br>
  vtkSmartPointer<vtkTransform> transform =<br>
    vtkSmartPointer<vtkTransform>::New();<br>
  transform->PreMultiply();<br>
  transform->RotateZ(30.0);<br>
  transform->Translate(0.5, 0.0, 0.0);<br>
<br>
  vtkSmartPointer<vtkBox> box =<br>
    vtkSmartPointer<vtkBox>::New();<br>
  box->SetBounds(-0.5, 0.5, -0.5, 0.5, -0.5, 0.5);<br>
  box->SetTransform(transform);<br>
<br>
  vtkSmartPointer<vtkExtractGeometry> extractGeometry =<br>
    vtkSmartPointer<vtkExtractGeometry>::New();<br>
  extractGeometry->SetInputData(sphere->GetOutput());<br>
  extractGeometry->SetImplicitFunction(box);<br>
  extractGeometry->ExtractInsideOn();<br>
  extractGeometry->ExtractBoundaryCellsOn();<br>
<br>
  vtkSmartPointer<vtkDataSetMapper> mapper =<br>
    vtkSmartPointer<vtkDataSetMapper>::New();<br>
  mapper->SetInputConnection(extractGeometry->GetOutputPort());<br>
<br>
  vtkSmartPointer<vtkActor> actor =<br>
    vtkSmartPointer<vtkActor>::New();<br>
  actor->SetMapper(mapper);<br>
  actor->GetProperty()->SetColor(0.8900, 0.8100, 0.3400);<br>
<br>
  // Create graphics stuff<br>
  //<br>
  vtkSmartPointer<vtkRenderer> ren =<br>
    vtkSmartPointer<vtkRenderer>::New();<br>
  ren->SetBackground(.3, .4, .6);<br>
<br>
  vtkSmartPointer<vtkRenderWindow> renWin =<br>
    vtkSmartPointer<vtkRenderWindow>::New();<br>
  renWin->AddRenderer(ren);<br>
  renWin->SetSize(512,512);<br>
<br>
  vtkSmartPointer<vtkRenderWindowInteractor> iren =<br>
    vtkSmartPointer<vtkRenderWindowInteractor>::New();<br>
  iren->SetRenderWindow(renWin);<br>
<br>
  // Add the actors to the renderer, set the background and size<br>
  //<br>
  ren->AddActor(actor);<br>
<br>
  // Generate an interesting view<br>
  //<br>
  ren->ResetCamera();<br>
  ren->GetActiveCamera()->Azimuth(120);<br>
  ren->GetActiveCamera()->Elevation(30);<br>
  ren->GetActiveCamera()->Dolly(1.0);<br>
  ren->ResetCameraClippingRange();<br>
<br>
  iren->Initialize();<br>
  iren->Start();<br>
<br>
  return EXIT_SUCCESS;<br>
}<br>
<br>
--- CMakeLists.txt ---<br>
cmake_minimum_required(VERSION 2.8)<br>
<br>
PROJECT(ExtractGeometry)<br>
<br>
find_package(VTK REQUIRED)<br>
include(${VTK_USE_FILE})<br>
<br>
add_executable(ExtractGeometry MACOSX_BUNDLE ExtractGeometry.cxx )<br>
<br>
target_link_libraries(ExtractGeometry ${VTK_LIBRARIES})<br>
---<br>
<br>
Regards<br>
2018年8月9日(木) 16:51 Polly Pui <polly_sukting@hotmail.com>:<br>
><br>
> Hi,<br>
><br>
> Can anyone please tell me how can I do extract a region by providing a box (which we can set the size of it) on a polydata?<br>
><br>
> I could do it manually in Paraview by selecting the Filter>Extract Cells By Region.<br>
><br>
> However, I have more than 1000 dataset. It is time consuming if I apply it manually for each dataset.<br>
><br>
><br>
> Thanks!<br>
><br>
><br>
> Best,<br>
><br>
> Polly<br>
><br>
> _______________________________________________<br>
> Powered by <a href="http://www.kitware.com" id="LPlnk701953" class="OWAAutoLink" previewremoved="true">
www.kitware.com</a><br>
><br>
> Visit other Kitware open-source projects at <a href="http://www.kitware.com/opensource/opensource.html" id="LPlnk370086" class="OWAAutoLink" previewremoved="true">
http://www.kitware.com/opensource/opensource.html</a><br>
><br>
> Please keep messages on-topic and check the VTK FAQ at: <a href="http://www.vtk.org/Wiki/VTK_FAQ" id="LPlnk863598" class="OWAAutoLink" previewremoved="true">
http://www.vtk.org/Wiki/VTK_FAQ</a><br>
><br>
> Search the list archives at: <a href="http://markmail.org/search/?q=vtkusers" id="LPlnk411184" class="OWAAutoLink" previewremoved="true">
http://markmail.org/search/?q=vtkusers</a><br>
><br>
> Follow this link to subscribe/unsubscribe:<br>
> <a href="https://public.kitware.com/mailman/listinfo/vtkusers" id="LPlnk650581" class="OWAAutoLink" previewremoved="true">
https://public.kitware.com/mailman/listinfo/vtkusers</a><br>
</div>
</span></font></div>
</div>
</div>
</body>
</html>