[vtkusers] Fwd: Re: AND-filter for vtkPolyData (was extract/select coincident points/cells)
Dr. Roman Grothausmann
grothausmann.roman at mh-hannover.de
Tue Sep 18 05:45:31 EDT 2012
Dear Bill,
Thank You very much for Your reply.
On 17/09/12 21:42, Bill Lorensen wrote:
> Were the two isosurfaces generated by DiscreteMarchingCubes from the
> same segmented data?
Yes, DiscreteMarchingCubes was used to generate meshes of (possibly
adjacent) labels in the voxel dataset.
> DiscreteMarchingCubes will generate coincident
> faces on two adjacent segmented surfaces.
That's what my analysis is relying on.
> What are you trying to accomplish? Are you trying to see the facves that
> lie in between two segmented surfaces?
I'm trying to extract a sub-mesh that consists only of the coincident
faces of two (or more) adjacent labels.
In the end I want to measure the surface of these sub-meshes, if
possible after smoothing them (to reduce the voxel-discretization
effects) without moving the boundary vertices of the now open meshes.
I'm planning to use vtkWindowedSincPolyDataFilter
with BoundarySmoothingOff and NonManifoldSmoothingOff, or would there be
a better alternative?
Many thanks for looking into this
Roman
On 17/09/12 21:42, Bill Lorensen wrote:
> Were the two isosurfaces generated by DiscreteMarchingCubes from the
> same segmented data? DiscreteMarchingCubes will generate coincident
> faces on two adjacent segmented surfaces.
>
> What are you trying to accomplish? Are you trying to see the facves that
> lie in between two segmented surfaces?
>
> On Mon, Sep 17, 2012 at 9:33 AM, Dr. Roman Grothausmann
> <grothausmann.roman at mh-hannover.de
> <mailto:grothausmann.roman at mh-hannover.de>> wrote:
>
> Dear Alex, dear Jothy,
>
>
> Many thanks for Your hint to use vtkBooleanOperationPolyDataFil__ter
> for this. It basically works but it seems not completely exact. I've
> attached an image that shows two touching blobs (raw meshes
> generated by discreteMarchingCubes, in attached tbz), one is
> rendered yellow, the other as wire frame. The intersection result
> (code below) of vtkBooleanOperationPolyDataFil__ter is rendered in
> blue, therefore it looks grey where it overlaps with the yellow
> faces. As you can see, one triangle is blue nonetheless. It exists
> on the blob rendered as wire frame but has no counter part on the
> yellow one, therefore does not belong to the set of coincident faces
> nor does the one corner point belong to the set of coincident vertices.
> Since I do not really need a boolean operation (including surface
> intersections) and since Cory Quammen's publication on
> vtkBooleanOperationPolyDataFil__ter mentions that coplanar face are
> problematic and not treated specially, I thought that
> vtkDistancePolyDataFilter combined with a ThresholdBetween(0.0,0.0)
> on the point-data "Distance" would do the trick. However, I realized
> from a test, that there can be coincident vertices that do not
> belong to coincident faces. Now, I would need a method to find all
> faces in the second mesh which are made up completely by all the
> vertices from the first mesh with "Distance"==0. (Using
> GetPointCells for all verts with "Distance"==0 seems not to help
> here, since this way "border" cells/triangles incorporating only one
> ore two of the verts are selected as well.)
> Using "Distance"==0 for the cell-data, does not work either because
> it contains cell-to-point distance (not cell-to-cell distance).
> Therefore, it needs a ThresholdBetween(0.0, t) where t is slightly
> greater than 0 (I used t=0.01 in the code below). As the two meshes
> originate from marching-cubes, I guess an upper limit for t could be
> deduced from the theory which would still grantee that only
> coincident faces are selected this way, but I do not know for sure
> how to deduce this upper limit for t.
>
> Do You have any ideas how to solve this problem?
>
> Thanks for Your help or hints.
> Roman
>
> /////find and extract coincident vertices and faces of two marching
> cubes meshes
>
> #include <vtkXMLPolyDataReader.h>//for vtp-files
> // #include <vtkPolyDataReader.h>//for vtk-files
> #include <__vtkBooleanOperationPolyDataFil__ter.h>
> #include <vtkXMLPolyDataWriter.h>//for vtp-files
>
> int main(int argc, char* argv[]){
> if( argc <= 3 )
> {
> std::cerr << "Usage: " << argv[0];
> std::cerr << " inputMesh0";
> std::cerr << " inputMesh1";
> std::cerr << " outputMesh";
> std::cerr << std::endl;
> return EXIT_FAILURE;
> }
>
> if(!(strcasestr(argv[1],".vtp"__))) {
> std::cout << "The input should end with .vtp" << std::endl;
> return -1;
> }
>
> if(!(strcasestr(argv[2],".vtp"__))) {
> std::cout << "The input should end with .vtp" << std::endl;
> return -1;
> }
>
> //vtkPolyDataReader *reader = vtkPolyDataReader::New(); //*.vtk
> vtkXMLPolyDataReader *reader0 = vtkXMLPolyDataReader::New();
> //*.vtp
>
> reader0->SetFileName(argv[1]);
> reader0->Update();
>
> vtkXMLPolyDataReader *reader1 = vtkXMLPolyDataReader::New();
> //*.vtp
>
> reader1->SetFileName(argv[2]);
> reader1->Update();
>
> vtkBooleanOperationPolyDataFil__ter *boolean=
> vtkBooleanOperationPolyDataFil__ter::New();
> boolean->SetInputConnection(0, reader0->GetOutputPort());
> boolean->SetInputConnection(1, reader1->GetOutputPort());
> boolean->__SetOperationToIntersection();
>
> vtkXMLPolyDataWriter *Pwriter = vtkXMLPolyDataWriter::New();
> //vtkDataSetWriter *Pwriter = vtkDataSetWriter::New();
>
> Pwriter->SetFileName(argv[3]);
> Pwriter->SetInputConnection(__boolean->GetOutputPort(0));
> Pwriter->Update();
>
>
> return EXIT_SUCCESS;
> }
>
> _______________________________________________________________________
>
>
> /////find and extract coincident vertices and faces of two marching
> cubes meshes
> //// there can be coincident verts that do not belong to coincident
> faces!!!
>
>
> #include <vtkXMLPolyDataReader.h>//for vtp-files
> // #include <vtkPolyDataReader.h>//for vtk-files
> //#include <__vtkBooleanOperationPolyDataFil__ter.h>
> #include <vtkDistancePolyDataFilter.h>
> #include <vtkThreshold.h>
> #include <vtkGeometryFilter.h>
> #include <vtkXMLPolyDataWriter.h>//for vtp-files
>
> int main(int argc, char* argv[]){
> if( argc != 4 )
> {
> std::cerr << "Usage: " << argv[0];
> std::cerr << " inputMesh0";
> std::cerr << " inputMesh1";
> std::cerr << " outputMesh";
> std::cerr << std::endl;
> return EXIT_FAILURE;
> }
>
> if(!(strcasestr(argv[1],".vtp"__))) {
> std::cout << "The input should end with .vtp" << std::endl;
> return -1;
> }
>
> if(!(strcasestr(argv[2],".vtp"__))) {
> std::cout << "The input should end with .vtp" << std::endl;
> return -1;
> }
>
> if(!(strcasestr(argv[3],".vtp"__))) {
> std::cout << "The input should end with .vtp" << std::endl;
> return -1;
> }
>
> //vtkPolyDataReader *reader = vtkPolyDataReader::New(); //*.vtk
> vtkXMLPolyDataReader *reader0 = vtkXMLPolyDataReader::New();
> //*.vtp
>
> reader0->SetFileName(argv[1]);
> reader0->Update();
>
> vtkXMLPolyDataReader *reader1 = vtkXMLPolyDataReader::New();
> //*.vtp
>
> reader1->SetFileName(argv[2]);
> reader1->Update();
>
> vtkDistancePolyDataFilter *polydist=
> vtkDistancePolyDataFilter::__New();
> polydist->SetInputConnection(__0, reader0->GetOutputPort());
> polydist->SetInputConnection(__1, reader1->GetOutputPort());
> polydist->SignedDistanceOff();
> //polydist->__ComputeSecondDistanceOff(); //causes:
> /*
> ERROR: In
> /home/grothama/sda8/programme/__VTK/Filtering/vtkExecutive.__cxx,
> line 756
> vtkStreamingDemandDrivenPipeli__ne (0x1d2a800): Algorithm
> vtkDistancePolyDataFilter(__0x1d29890) returned failure for request:
> vtkInformation (0x1d4e040)
> Debug: Off
> Modified Time: 757
> Reference Count: 1
> Registered Events: (none)
> Request: REQUEST_DATA
> ALGORITHM_AFTER_FORWARD: 1
> FROM_OUTPUT_PORT: 0
> FORWARD_DIRECTION: 0
> */
> polydist->Update();
>
> vtkThreshold *thresh= vtkThreshold::New();
> thresh->SetInputConnection(__polydist->GetOutputPort());
> //thresh->__SetInputArrayToProcess(0, 0, 0,
> vtkDataObject::FIELD___ASSOCIATION_POINTS, "Distance"); //
> FIELD_ASSOCIATION_VERTICES
> //thresh->__SetInputArrayToProcess(0, 0, 0,
> vtkDataObject::FIELD___ASSOCIATION_POINTS,
> vtkDataSetAttributes::SCALARS)__; // FIELD_ASSOCIATION_VERTICES
> thresh->__SetInputArrayToProcess(0, 0, 0,
> vtkDataObject::FIELD___ASSOCIATION_CELLS, "Distance"); //
> FIELD_ASSOCIATION_VERTICES
> //thresh->__SetAttributeModeToUsePointData__();
> thresh->ThresholdBetween(0.0,__0.01);
>
> vtkGeometryFilter *usg2poly= vtkGeometryFilter::New();
> usg2poly->SetInputConnection(__thresh->GetOutputPort());
>
> vtkXMLPolyDataWriter *Pwriter = vtkXMLPolyDataWriter::New();
> //vtkDataSetWriter *Pwriter = vtkDataSetWriter::New();
>
> Pwriter->SetFileName(argv[3]);
> //Pwriter->SetInputConnection(__polydist->GetOutputPort());
> Pwriter->SetInputConnection(__usg2poly->GetOutputPort());
> Pwriter->Update();
>
>
> return EXIT_SUCCESS;
> }
>
>
>
> On 17/09/12 10:10, Roman Grothausmann wrote:
>
>
>
>
> -------- Original Message --------
> Subject: Re: [vtkusers] AND-filter for vtkPolyData (was
> extract/selectcoincident points/cells)
> Date: Wed, 5 Sep 2012 10:49:20 +0200
> From: Roman Grothausmann
> <roman.grothausmann at helmholtz-__berlin.de
> <mailto:roman.grothausmann at helmholtz-berlin.de>>
> To: alex Dowson <alexdowson at hotmail.com
> <mailto:alexdowson at hotmail.com>>, VTK Mailing List
> <vtkusers at vtk.org <mailto:vtkusers at vtk.org>>
>
> Hello Alex,
>
>
> Many thanks for the hint, I had not thought of boolean operation for
> this since the only overlap, ie the union, would consist only of a
> surface, not a volume. I'll give it a try and see if it results
> in what
> I need. It could work since for the meshes I look at I can rule
> out that
> they could also have volume unions.
>
> Thanks again for Your hint
> Roman
>
> On 05.09.2012 09:15, alex Dowson wrote:
>
> Hi
>
> Have you tried CSG Boolean filter in VTK ? Check this class
>
> http://www.vtk.org/doc/__nightly/html/__classvtkBooleanOperationPolyDa__taFilter.html
> <http://www.vtk.org/doc/nightly/html/classvtkBooleanOperationPolyDataFilter.html>
>
>
>
> Also you can use implicit boolean operation filter for that.
>
>
>
>
> -----Original Message----- From: Roman Grothausmann
> Sent: Wednesday, September 05, 2012 12:42 PM
> To: VTK Mailing List
> Subject: [vtkusers] AND-filter for vtkPolyData (was
> extract/selectcoincident points/cells)
>
> Dear mailing list members,
>
>
> Is there a kind of AND-filter for vtkPolyData-meshes which I
> could use
> to extract/select coincident points/cells of two meshes?
>
> Thanks for any hints or help
> Roman
>
> On 31.08.2012 14 <tel:31.08.2012%2014>:53, Roman
> Grothausmann wrote:
>
> Dear mailing list members,
>
>
> There are many filters in VTK to clean/merge coincident
> points but I
> could not find a single filter that extracts/selects
> coincident
> points/cells.
> I would need it to extract the sub-mesh of two or more
> vtkPolyData-meshes where these meshes overlap, e.g. when a
> vtkDiscreteMarchingCubes surface is generated of two or
> more labels that
> directly touch each other in voxel space.
> Or is there a way to just generate a mesh of the area
> where both labels
> touch?
>
> Any help or hints are very much appreciated
> Roman
>
>
>
>
> --
> Dr. Roman Grothausmann
>
> Tomographie und Digitale Bildverarbeitung
> Tomography and Digital Image Analysis
>
> Institut für Funktionelle und Angewandte Anatomie, OE 4120
> Medizinische Hochschule Hannover
> Carl-Neuberg-Str. 1
> 30625 Hannover
>
> Tel. +49 511 532-9574 <tel:%2B49%20511%20532-9574>
>
> _______________________________________________
> Powered by www.kitware.com <http://www.kitware.com>
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Please keep messages on-topic and check the VTK FAQ at:
> http://www.vtk.org/Wiki/VTK_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://www.vtk.org/mailman/listinfo/vtkusers
>
>
>
>
> --
> Unpaid intern in BillsBasement at noware dot com
>
--
Dr. Roman Grothausmann
Tomographie und Digitale Bildverarbeitung
Tomography and Digital Image Analysis
Institut für Funktionelle und Angewandte Anatomie, OE 4120
Medizinische Hochschule Hannover
Carl-Neuberg-Str. 1
30625 Hannover
Tel. +49 511 532-9574
More information about the vtkusers
mailing list