Were the two isosurfaces generated by DiscreteMarchingCubes from the same segmented data? DiscreteMarchingCubes will generate coincident faces on two adjacent segmented surfaces.<br><br>What are you trying to accomplish? Are you trying to see the facves that lie in between two segmented surfaces?<br>
<br><div class="gmail_quote">On Mon, Sep 17, 2012 at 9:33 AM, Dr. Roman Grothausmann <span dir="ltr"><<a href="mailto:grothausmann.roman@mh-hannover.de" target="_blank">grothausmann.roman@mh-hannover.de</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Dear Alex, dear Jothy,<br>
<br>
<br>
Many thanks for Your hint to use vtkBooleanOperationPolyDataFil<u></u>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<u></u>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.<br>
Since I do not really need a boolean operation (including surface intersections) and since Cory Quammen's publication on vtkBooleanOperationPolyDataFil<u></u>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.)<br>
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.<br>
<br>
Do You have any ideas how to solve this problem?<br>
<br>
Thanks for Your help or hints.<br>
Roman<br>
<br>
/////find and extract coincident vertices and faces of two marching cubes meshes<br>
<br>
#include <vtkXMLPolyDataReader.h>//for vtp-files<br>
// #include <vtkPolyDataReader.h>//for vtk-files<br>
#include <<u></u>vtkBooleanOperationPolyDataFil<u></u>ter.h><br>
#include <vtkXMLPolyDataWriter.h>//for vtp-files<br>
<br>
int main(int argc, char* argv[]){<br>
if( argc <= 3 )<br>
{<br>
std::cerr << "Usage: " << argv[0];<br>
std::cerr << " inputMesh0";<br>
std::cerr << " inputMesh1";<br>
std::cerr << " outputMesh";<br>
std::cerr << std::endl;<br>
return EXIT_FAILURE;<br>
}<br>
<br>
if(!(strcasestr(argv[1],".vtp"<u></u>))) {<br>
std::cout << "The input should end with .vtp" << std::endl;<br>
return -1;<br>
}<br>
<br>
if(!(strcasestr(argv[2],".vtp"<u></u>))) {<br>
std::cout << "The input should end with .vtp" << std::endl;<br>
return -1;<br>
}<br>
<br>
//vtkPolyDataReader *reader = vtkPolyDataReader::New(); //*.vtk<br>
vtkXMLPolyDataReader *reader0 = vtkXMLPolyDataReader::New(); //*.vtp<br>
<br>
reader0->SetFileName(argv[1]);<br>
reader0->Update();<br>
<br>
vtkXMLPolyDataReader *reader1 = vtkXMLPolyDataReader::New(); //*.vtp<br>
<br>
reader1->SetFileName(argv[2]);<br>
reader1->Update();<br>
<br>
vtkBooleanOperationPolyDataFil<u></u>ter *boolean= vtkBooleanOperationPolyDataFil<u></u>ter::New();<br>
boolean->SetInputConnection(0, reader0->GetOutputPort());<br>
boolean->SetInputConnection(1, reader1->GetOutputPort());<br>
boolean-><u></u>SetOperationToIntersection();<br>
<br>
vtkXMLPolyDataWriter *Pwriter = vtkXMLPolyDataWriter::New();<br>
//vtkDataSetWriter *Pwriter = vtkDataSetWriter::New();<br>
<br>
Pwriter->SetFileName(argv[3]);<br>
Pwriter->SetInputConnection(<u></u>boolean->GetOutputPort(0));<br>
Pwriter->Update();<br>
<br>
<br>
return EXIT_SUCCESS;<br>
}<br>
<br>
______________________________<u></u>______________________________<u></u>_______<br>
<br>
<br>
/////find and extract coincident vertices and faces of two marching cubes meshes<br>
//// there can be coincident verts that do not belong to coincident faces!!!<br>
<br>
<br>
#include <vtkXMLPolyDataReader.h>//for vtp-files<br>
// #include <vtkPolyDataReader.h>//for vtk-files<br>
//#include <<u></u>vtkBooleanOperationPolyDataFil<u></u>ter.h><br>
#include <vtkDistancePolyDataFilter.h><br>
#include <vtkThreshold.h><br>
#include <vtkGeometryFilter.h><br>
#include <vtkXMLPolyDataWriter.h>//for vtp-files<br>
<br>
int main(int argc, char* argv[]){<br>
if( argc != 4 )<br>
{<br>
std::cerr << "Usage: " << argv[0];<br>
std::cerr << " inputMesh0";<br>
std::cerr << " inputMesh1";<br>
std::cerr << " outputMesh";<br>
std::cerr << std::endl;<br>
return EXIT_FAILURE;<br>
}<br>
<br>
if(!(strcasestr(argv[1],".vtp"<u></u>))) {<br>
std::cout << "The input should end with .vtp" << std::endl;<br>
return -1;<br>
}<br>
<br>
if(!(strcasestr(argv[2],".vtp"<u></u>))) {<br>
std::cout << "The input should end with .vtp" << std::endl;<br>
return -1;<br>
}<br>
<br>
if(!(strcasestr(argv[3],".vtp"<u></u>))) {<br>
std::cout << "The input should end with .vtp" << std::endl;<br>
return -1;<br>
}<br>
<br>
//vtkPolyDataReader *reader = vtkPolyDataReader::New(); //*.vtk<br>
vtkXMLPolyDataReader *reader0 = vtkXMLPolyDataReader::New(); //*.vtp<br>
<br>
reader0->SetFileName(argv[1]);<br>
reader0->Update();<br>
<br>
vtkXMLPolyDataReader *reader1 = vtkXMLPolyDataReader::New(); //*.vtp<br>
<br>
reader1->SetFileName(argv[2]);<br>
reader1->Update();<br>
<br>
vtkDistancePolyDataFilter *polydist= vtkDistancePolyDataFilter::<u></u>New();<br>
polydist->SetInputConnection(<u></u>0, reader0->GetOutputPort());<br>
polydist->SetInputConnection(<u></u>1, reader1->GetOutputPort());<br>
polydist->SignedDistanceOff();<br>
//polydist-><u></u>ComputeSecondDistanceOff(); //causes:<br>
/*<br>
ERROR: In /home/grothama/sda8/programme/<u></u>VTK/Filtering/vtkExecutive.<u></u>cxx, line 756<br>
vtkStreamingDemandDrivenPipeli<u></u>ne (0x1d2a800): Algorithm vtkDistancePolyDataFilter(<u></u>0x1d29890) returned failure for request: vtkInformation (0x1d4e040)<br>
Debug: Off<br>
Modified Time: 757<br>
Reference Count: 1<br>
Registered Events: (none)<br>
Request: REQUEST_DATA<br>
ALGORITHM_AFTER_FORWARD: 1<br>
FROM_OUTPUT_PORT: 0<br>
FORWARD_DIRECTION: 0<br>
*/<br>
polydist->Update();<br>
<br>
vtkThreshold *thresh= vtkThreshold::New();<br>
thresh->SetInputConnection(<u></u>polydist->GetOutputPort());<br>
//thresh-><u></u>SetInputArrayToProcess(0, 0, 0, vtkDataObject::FIELD_<u></u>ASSOCIATION_POINTS, "Distance"); // FIELD_ASSOCIATION_VERTICES<br>
//thresh-><u></u>SetInputArrayToProcess(0, 0, 0, vtkDataObject::FIELD_<u></u>ASSOCIATION_POINTS, vtkDataSetAttributes::SCALARS)<u></u>; // FIELD_ASSOCIATION_VERTICES<br>
thresh-><u></u>SetInputArrayToProcess(0, 0, 0, vtkDataObject::FIELD_<u></u>ASSOCIATION_CELLS, "Distance"); // FIELD_ASSOCIATION_VERTICES<br>
//thresh-><u></u>SetAttributeModeToUsePointData<u></u>();<br>
thresh->ThresholdBetween(0.0,<u></u>0.01);<br>
<br>
vtkGeometryFilter *usg2poly= vtkGeometryFilter::New();<br>
usg2poly->SetInputConnection(<u></u>thresh->GetOutputPort());<br>
<br>
vtkXMLPolyDataWriter *Pwriter = vtkXMLPolyDataWriter::New();<br>
//vtkDataSetWriter *Pwriter = vtkDataSetWriter::New();<br>
<br>
Pwriter->SetFileName(argv[3]);<br>
//Pwriter->SetInputConnection(<u></u>polydist->GetOutputPort());<br>
Pwriter->SetInputConnection(<u></u>usg2poly->GetOutputPort());<br>
Pwriter->Update();<br>
<br>
<br>
return EXIT_SUCCESS;<br>
}<br>
<br>
<br>
<br>
On 17/09/12 10:10, Roman Grothausmann wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="im">
<br>
<br>
<br>
-------- Original Message --------<br>
Subject: Re: [vtkusers] AND-filter for vtkPolyData (was<br>
extract/selectcoincident points/cells)<br></div><div><div class="h5">
Date: Wed, 5 Sep 2012 10:49:20 +0200<br>
From: Roman Grothausmann <<a href="mailto:roman.grothausmann@helmholtz-berlin.de" target="_blank">roman.grothausmann@helmholtz-<u></u>berlin.de</a>><br>
To: alex Dowson <<a href="mailto:alexdowson@hotmail.com" target="_blank">alexdowson@hotmail.com</a>>, VTK Mailing List<br>
<<a href="mailto:vtkusers@vtk.org" target="_blank">vtkusers@vtk.org</a>><br>
<br>
Hello Alex,<br>
<br>
<br>
Many thanks for the hint, I had not thought of boolean operation for<br>
this since the only overlap, ie the union, would consist only of a<br>
surface, not a volume. I'll give it a try and see if it results in what<br>
I need. It could work since for the meshes I look at I can rule out that<br>
they could also have volume unions.<br>
<br>
Thanks again for Your hint<br>
Roman<br>
<br>
On 05.09.2012 09:15, alex Dowson wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Hi<br>
<br>
Have you tried CSG Boolean filter in VTK ? Check this class<br>
<br>
<a href="http://www.vtk.org/doc/nightly/html/classvtkBooleanOperationPolyDataFilter.html" target="_blank">http://www.vtk.org/doc/<u></u>nightly/html/<u></u>classvtkBooleanOperationPolyDa<u></u>taFilter.html</a><br>
<br>
<br>
<br>
Also you can use implicit boolean operation filter for that.<br>
<br>
<br>
<br>
<br>
-----Original Message----- From: Roman Grothausmann<br>
Sent: Wednesday, September 05, 2012 12:42 PM<br>
To: VTK Mailing List<br>
Subject: [vtkusers] AND-filter for vtkPolyData (was<br>
extract/selectcoincident points/cells)<br>
<br>
Dear mailing list members,<br>
<br>
<br>
Is there a kind of AND-filter for vtkPolyData-meshes which I could use<br>
to extract/select coincident points/cells of two meshes?<br>
<br>
Thanks for any hints or help<br>
Roman<br>
<br>
On <a href="tel:31.08.2012%2014" value="+13108201214" target="_blank">31.08.2012 14</a>:53, Roman Grothausmann wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Dear mailing list members,<br>
<br>
<br>
There are many filters in VTK to clean/merge coincident points but I<br>
could not find a single filter that extracts/selects coincident<br>
points/cells.<br>
I would need it to extract the sub-mesh of two or more<br>
vtkPolyData-meshes where these meshes overlap, e.g. when a<br>
vtkDiscreteMarchingCubes surface is generated of two or more labels that<br>
directly touch each other in voxel space.<br>
Or is there a way to just generate a mesh of the area where both labels<br>
touch?<br>
<br>
Any help or hints are very much appreciated<br>
Roman<br>
<br>
</blockquote>
<br>
</blockquote>
<br>
</div></div></blockquote><span class="HOEnZb"><font color="#888888">
<br>
-- <br>
Dr. Roman Grothausmann<br>
<br>
Tomographie und Digitale Bildverarbeitung<br>
Tomography and Digital Image Analysis<br>
<br>
Institut für Funktionelle und Angewandte Anatomie, OE 4120<br>
Medizinische Hochschule Hannover<br>
Carl-Neuberg-Str. 1<br>
30625 Hannover<br>
<br>
Tel. <a href="tel:%2B49%20511%20532-9574" value="+495115329574" target="_blank">+49 511 532-9574</a><br>
</font></span><br>_______________________________________________<br>
Powered by <a href="http://www.kitware.com" target="_blank">www.kitware.com</a><br>
<br>
Visit other Kitware open-source projects at <a href="http://www.kitware.com/opensource/opensource.html" target="_blank">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" target="_blank">http://www.vtk.org/Wiki/VTK_FAQ</a><br>
<br>
Follow this link to subscribe/unsubscribe:<br>
<a href="http://www.vtk.org/mailman/listinfo/vtkusers" target="_blank">http://www.vtk.org/mailman/listinfo/vtkusers</a><br>
<br></blockquote></div><br><br clear="all"><br>-- <br>Unpaid intern in BillsBasement at noware dot com<br><br>