<html>
<head>
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
</head>
<body text="#000000" bgcolor="#FFFFFF">
<div class="moz-cite-prefix">Goodwin,<br>
this is strange... I tried yesterday and I found it did not work
(I must have done something with my testing).<br>
I tested again, and this works.<br>
Great and thanks<br>
JD<br>
<br>
Le 20/12/2012 17:05, Goodwin Lawlor a écrit :<br>
</div>
<blockquote
cite="mid:CAEAdmCZg4jYVj-Nfq=pZtd9acCcVqCk7brzEGesFAq0__sOOJg@mail.gmail.com"
type="cite">
<div dir="ltr">JD,
<div><br>
</div>
<div>Pass the final polyline through vtkCleanPolyData with 0.0
tolerance (the default) and it should remove the coincident
points.</div>
<div><br>
</div>
<div>hth</div>
<div><br>
</div>
<div>Goodwin<br>
</div>
<br>
<div class="gmail_quote">On Thu, Dec 20, 2012 at 12:42 AM, pof <span
dir="ltr"><<a moz-do-not-send="true"
href="mailto:jd379252@gmail.com" target="_blank">jd379252@gmail.com</a>></span>
wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0
.8ex;border-left:1px #ccc solid;padding-left:1ex">
<div text="#000000" bgcolor="#FFFFFF">
<div>Goodwin,<br>
<br>
I tested the patch on the following simple case (5
segments)<br>
# vtk DataFile Version 3.0<br>
vtk output<br>
ASCII<br>
DATASET POLYDATA<br>
POINTS 6 float<br>
1.7 0.5 0 2 0 0 1.7 -0.5 0 <br>
1.6 -1 0 1.8 -0.2 0 1.6 1 0 <br>
LINES 5 15<br>
2 0 1 <br>
2 2 3 <br>
2 4 2 <br>
2 1 4 <br>
2 5 0 <br>
<br>
without the patch, 2 polylines are obtained from the
vtkStripper<br>
LINES 2 9<br>
5 0 1 4 2 3 <br>
2 5 0 <br>
<br>
whereas with the patch a single polyline is obained <br>
LINES 1 8<br>
7 5 0 0 1 4 2 3 <br>
<br>
Things are of course better, though a duplicate of one
point (point 0 in this case) is obtained, which should
obviously have been avoided.<br>
So it looks there's stil some space to improve the
patch.<br>
<br>
In any case, I thank you for sharing this information
with me.<br>
JD<br>
<br>
<br>
Le 19/12/2012 10:04, Goodwin Lawlor a écrit :<br>
</div>
<div>
<div class="h5">
<blockquote type="cite">
<div dir="ltr">I think vtkStripper was originally
written to quickly produce
vtkTriangleStrip/vtkPolyLine primitives that would
render faster, not a computational geometry type
class that would produce the longest possible
polylines... it is a visualization library after
all.
<div> <br>
</div>
<div>The seed point is arbitrary so you may not
get the outcome you were looking for.</div>
<div><br>
</div>
<div>See this 2002 post, that contains a patch
which may help: <a moz-do-not-send="true"
href="http://vtk.org/pipermail/vtkusers/2002-January/009372.html"
target="_blank">http://vtk.org/pipermail/vtkusers/2002-January/009372.html</a></div>
<div><br>
</div>
<div>There was a bug report too: <a
moz-do-not-send="true"
href="http://www.vtk.org/Bug/print_bug_page.php?bug_id=832"
target="_blank">http://www.vtk.org/Bug/print_bug_page.php?bug_id=832</a></div>
<div><br>
</div>
<div>hth</div>
<div><br>
</div>
<div> Goodwin</div>
<div><br>
<br>
<div class="gmail_quote">On Mon, Dec 10, 2012 at
2:51 AM, David Gobbi <span dir="ltr"><<a
moz-do-not-send="true"
href="mailto:david.gobbi@gmail.com"
target="_blank">david.gobbi@gmail.com</a>></span>
wrote:<br>
<blockquote class="gmail_quote"
style="margin:0 0 0 .8ex;border-left:1px
#ccc solid;padding-left:1ex"> Insert
vtkTriangleFilter before vtkStripper. This
will break any<br>
input polylines into line segments. I don't
know if it will help,<br>
but it might.<br>
<span><font color="#888888"><br>
- David<br>
</font></span>
<div>
<div><br>
On Sun, Dec 9, 2012 at 2:48 PM, pof <<a
moz-do-not-send="true"
href="mailto:jd379252@gmail.com"
target="_blank">jd379252@gmail.com</a>>
wrote:<br>
> yes this is the way LINES objects
are written on vtk files.<br>
> Ok, so I understand now the point
you were making about the "T", which was<br>
> uncorrect.<br>
><br>
> So back to the problem, why this
vtkStripper is not able to merge those 2<br>
> lines?<br>
><br>
> Le 09/12/2012 21:41, David Gobbi a
écrit :<br>
>><br>
>> Is it? Maybe it is. When you
wrote the numbers, I assumed that<br>
>><br>
>> all of the numbers that you
listed were just point indices.<br>
>><br>
>><br>
>> On Sun, Dec 9, 2012 at 1:37 PM,
pof <<a moz-do-not-send="true"
href="mailto:jd379252@gmail.com"
target="_blank">jd379252@gmail.com</a>>
wrote:<br>
>>><br>
>>> Hum I see.<br>
>>> (from what I understand),
the first integer of each line is simply
the<br>
>>> number of points of the
corresponding LINE<br>
>>><br>
>>> Le 09/12/2012 21:33, David
Gobbi a écrit :<br>
>>><br>
>>>> Then where would the
"9" go?<br>
>>>><br>
>>>> The stripper uses a
simple algorithm, it just chooses a
starting<br>
>>>> point, goes as far as
it can in each direction to create the
first<br>
>>>> polyline, and then
repeats this procedure until all the
line segments<br>
>>>> are accounted for. It
doesn't exhaustively search though all<br>
>>>> permutations to see
which one gives the smallest number of
output<br>
>>>> polylines... that would
cause the algorithm to run many times
slower.<br>
>>>><br>
>>>><br>
>>>><br>
>>>><br>
>>>> On Sun, Dec 9, 2012 at
1:12 PM, pof <<a
moz-do-not-send="true"
href="mailto:jd379252@gmail.com"
target="_blank">jd379252@gmail.com</a>>
wrote:<br>
>>>>><br>
>>>>> Hi David<br>
>>>>><br>
>>>>> the first polyline
being:<br>
>>>>><br>
>>>>> 9 0 1 2 3 4 5
19 6 7<br>
>>>>> and the third
polyline (actually it is a segment)
being:<br>
>>>>> 2 18 0<br>
>>>>> I don't see why
they shoud not merge together as (unless
I<br>
>>>>> misunderstand<br>
>>>>> something):<br>
>>>>> 10 18 0 1 2 3 4
5 19 6 7<br>
>>>>><br>
>>>>> Am I wrong?<br>
>>>>><br>
>>>>><br>
>>>>> Le 09/12/2012
21:05, David Gobbi a écrit :<br>
>>>>><br>
>>>>>> Hi JD,<br>
>>>>>><br>
>>>>>> It could only
merge those two lines if it joined them
with a "T".<br>
>>>>>> A polyline
cannot have any branches.<br>
>>>>>><br>
>>>>>> - David<br>
>>>>>><br>
>>>>>><br>
>>>>>> On Sun, Dec 9,
2012 at 12:16 PM, pof <<a
moz-do-not-send="true"
href="mailto:jd379252@gmail.com"
target="_blank">jd379252@gmail.com</a>>
wrote:<br>
>>>>>>><br>
>>>>>>> Hi all,<br>
>>>>>>><br>
>>>>>>> I get a
strange result (which may be a bug)
using vtk stripper, i.e.<br>
>>>>>>> it<br>
>>>>>>> does<br>
>>>>>>> not merge
LINES as polylines as it is expected to.<br>
>>>>>>> In this
example (see below an extract of the
polydata produced by<br>
>>>>>>>
vtkStripper), only 2 polylines should be
obtained, but vtkStripper<br>
>>>>>>> forgot<br>
>>>>>>> to<br>
>>>>>>> merge the
first and the third line together,
though they obviously<br>
>>>>>>> share<br>
>>>>>>> point with
Id=0 (btw, the fact that only Id 0
remains unmerged might<br>
>>>>>>> not<br>
>>>>>>> be<br>
>>>>>>> pure luck).<br>
>>>>>>><br>
>>>>>>> LINES 3 24<br>
>>>>>>> 9 0 1 2 3 4
5 19 6 7<br>
>>>>>>> 10 9 8 17
13 12 15 14 11 10 16<br>
>>>>>>> 2 18 0<br>
>>>>>>> Does
anybody have an idea or an explanation?<br>
>>>>>>> Thanks<br>
>>>>>>> JD<br>
>>>>>>><br>
>>>>>>> PS: Here
below is the complete source file that
generates these data<br>
>>>>>>> and<br>
>>>>>>> in<br>
>>>>>>> which
vtkStripper is used.<br>
>>>>>>><br>
>>>>>>>
//////////////////////////////////////////////////////<br>
>>>>>>> // Example
modified from
IntersectionPolyDataFilter.cxx<br>
>>>>>>>
//////////////////////////////////////////////////////<br>
>>>>>>> #include
<vtkActor.h><br>
>>>>>>> #include
<vtkIntersectionPolyDataFilter.h><br>
>>>>>>> #include
<vtkPolyDataMapper.h><br>
>>>>>>> #include
<vtkPolyDataWriter.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
<vtkCellArray.h><br>
>>>>>>> #include
<vtkStripper.h><br>
>>>>>>><br>
>>>>>>> int
main(int argc, char *argv[])<br>
>>>>>>> {<br>
>>>>>>>
vtkSmartPointer<vtkSphereSource>
sphereSource1 =<br>
>>>>>>>
vtkSmartPointer<vtkSphereSource>::New();<br>
>>>>>>>
sphereSource1->SetCenter(0.0, 0.0,
0.0);<br>
>>>>>>>
sphereSource1->SetRadius(2.0f);<br>
>>>>>>>
sphereSource1->SetPhiResolution(20);<br>
>>>>>>>
sphereSource1->SetThetaResolution(20);<br>
>>>>>>>
sphereSource1->Update();<br>
>>>>>>>
vtkSmartPointer<vtkPolyDataMapper>
sphere1Mapper =<br>
>>>>>>>
vtkSmartPointer<vtkPolyDataMapper>::New();<br>
>>>>>>>
sphere1Mapper->SetInputConnection(<br>
>>>>>>>
sphereSource1->GetOutputPort()<br>
>>>>>>> );<br>
>>>>>>>
sphere1Mapper->ScalarVisibilityOff();<br>
>>>>>>>
vtkSmartPointer<vtkActor>
sphere1Actor =<br>
>>>>>>>
vtkSmartPointer<vtkActor>::New();<br>
>>>>>>>
sphere1Actor->SetMapper(
sphere1Mapper );<br>
>>>>>>>
sphere1Actor->GetProperty()->SetOpacity(.3);<br>
>>>>>>>
sphere1Actor->GetProperty()->SetColor(1,0,0);<br>
>>>>>>><br>
>>>>>>>
/////////////////////////<br>
>>>>>>> //
BEGIN MODIFICATIONS //<br>
>>>>>>>
/////////////////////////<br>
>>>>>>> //
Create a planar object<br>
>>>>>>> //
Define 4 vertices<br>
>>>>>>>
vtkSmartPointer<vtkPoints>
PlanePoints =<br>
>>>>>>>
vtkSmartPointer<vtkPoints>::New();<br>
>>>>>>>
vtkSmartPointer<vtkCellArray>
PlaneCells =<br>
>>>>>>>
vtkSmartPointer<vtkCellArray>::New();<br>
>>>>>>>
PlanePoints->InsertNextPoint(-3, -1,
0);<br>
>>>>>>>
PlanePoints->InsertNextPoint(3, -1,
0);<br>
>>>>>>>
PlanePoints->InsertNextPoint(-3, 1,
0);<br>
>>>>>>>
PlanePoints->InsertNextPoint(3, 1,
0);<br>
>>>>>>> //
Create 2 trianglar faces<br>
>>>>>>>
PlaneCells->InsertNextCell(3);<br>
>>>>>>>
PlaneCells->InsertCellPoint(0);<br>
>>>>>>>
PlaneCells->InsertCellPoint(1);<br>
>>>>>>>
PlaneCells->InsertCellPoint(2);<br>
>>>>>>>
PlaneCells->InsertNextCell(3);<br>
>>>>>>>
PlaneCells->InsertCellPoint(1);<br>
>>>>>>>
PlaneCells->InsertCellPoint(3);<br>
>>>>>>>
PlaneCells->InsertCellPoint(2);<br>
>>>>>>> //
Create the polydata from points and
faces<br>
>>>>>>>
vtkSmartPointer<vtkPolyData>
ProtectionWall =<br>
>>>>>>>
vtkSmartPointer<vtkPolyData>::New();<br>
>>>>>>>
ProtectionWall->SetPoints(PlanePoints);<br>
>>>>>>>
ProtectionWall->SetPolys(PlaneCells);<br>
>>>>>>>
/////////////////////////<br>
>>>>>>> // END
MODIFICATIONS //<br>
>>>>>>>
/////////////////////////<br>
>>>>>>><br>
>>>>>>>
vtkSmartPointer<vtkPolyDataMapper>
planeMapper =<br>
>>>>>>>
vtkSmartPointer<vtkPolyDataMapper>::New();<br>
>>>>>>>
planeMapper->SetInputConnection(<br>
>>>>>>>
ProtectionWall->GetProducerPort()<br>
>>>>>>> );<br>
>>>>>>>
planeMapper->ScalarVisibilityOff();<br>
>>>>>>><br>
>>>>>>>
vtkSmartPointer<vtkActor>
planeActor =<br>
>>>>>>>
vtkSmartPointer<vtkActor>::New();<br>
>>>>>>>
planeActor->SetMapper( planeMapper
);<br>
>>>>>>>
planeActor->GetProperty()->SetOpacity(.3);<br>
>>>>>>>
planeActor->GetProperty()->SetColor(0,1,0);<br>
>>>>>>><br>
>>>>>>> // Get
intersection segments (LINES) using the<br>
>>>>>>>
vtkIntersectionPolyDataFilter<br>
>>>>>>>
vtkSmartPointer<vtkIntersectionPolyDataFilter><br>
>>>>>>>
intersectionPolyDataFilter<br>
>>>>>>> =
vtkSmartPointer<vtkIntersectionPolyDataFilter>::New();<br>
>>>>>>>
intersectionPolyDataFilter->SplitFirstOutputOff();<br>
>>>>>>>
intersectionPolyDataFilter->SplitSecondOutputOff();<br>
>>>>>>>
intersectionPolyDataFilter->SetInputConnection(
0,<br>
>>>>>>>
sphereSource1->GetOutputPort() );<br>
>>>>>>>
intersectionPolyDataFilter->SetInputConnection(
1,<br>
>>>>>>>
ProtectionWall->GetProducerPort() );<br>
>>>>>>>
intersectionPolyDataFilter->Update();<br>
>>>>>>><br>
>>>>>>>
/////////////////////////<br>
>>>>>>> //
BEGIN MODIFICATIONS //<br>
>>>>>>>
/////////////////////////<br>
>>>>>>> // Try
to get the polylines (there should be 2)
from the<br>
>>>>>>> segments<br>
>>>>>>> (LINES)<br>
>>>>>>>
vtkSmartPointer<vtkStripper>
stripper =<br>
>>>>>>>
vtkSmartPointer<vtkStripper>::New();<br>
>>>>>>><br>
>>>>>>><br>
>>>>>>><br>
>>>>>>>
stripper->SetInputConnection(intersectionPolyDataFilter->GetOutputPort());<br>
>>>>>>>
stripper->Update();<br>
>>>>>>> //
Save resulting polydata on a file, in
which we see that there<br>
>>>>>>> are 3<br>
>>>>>>> polylines
(actually the second polyline is ok,<br>
>>>>>>> // but
the first and third polylines should
have been further<br>
>>>>>>> merged<br>
>>>>>>>
vtkSmartPointer<vtkPolyDataWriter>
wr =<br>
>>>>>>>
vtkSmartPointer<vtkPolyDataWriter>::New();<br>
>>>>>>>
wr->SetFileName("polylines.txt");<br>
>>>>>>>
wr->SetInputConnection(stripper->GetOutputPort());<br>
>>>>>>>
wr->Write();<br>
>>>>>>>
///////////////////////<br>
>>>>>>> // END
MODIFICATIONS //<br>
>>>>>>>
///////////////////////<br>
>>>>>>><br>
>>>>>>>
vtkSmartPointer<vtkPolyDataMapper>
intersectionMapper =<br>
>>>>>>>
vtkSmartPointer<vtkPolyDataMapper>::New();<br>
>>>>>>>
intersectionMapper->SetInputConnection(<br>
>>>>>>>
stripper->GetOutputPort()<br>
>>>>>>> );<br>
>>>>>>>
intersectionMapper->ScalarVisibilityOff();<br>
>>>>>>><br>
>>>>>>>
vtkSmartPointer<vtkActor>
intersectionActor =<br>
>>>>>>>
vtkSmartPointer<vtkActor>::New();<br>
>>>>>>>
intersectionActor->SetMapper(
intersectionMapper );<br>
>>>>>>><br>
>>>>>>>
vtkSmartPointer<vtkRenderer>
renderer =<br>
>>>>>>>
vtkSmartPointer<vtkRenderer>::New();<br>
>>>>>>>
renderer->AddViewProp(sphere1Actor);<br>
>>>>>>>
renderer->AddViewProp(planeActor);<br>
>>>>>>>
renderer->AddViewProp(intersectionActor);<br>
>>>>>>><br>
>>>>>>>
vtkSmartPointer<vtkRenderWindow>
renderWindow =<br>
>>>>>>>
vtkSmartPointer<vtkRenderWindow>::New();<br>
>>>>>>>
renderWindow->AddRenderer( renderer
);<br>
>>>>>>><br>
>>>>>>>
vtkSmartPointer<vtkRenderWindowInteractor>
renWinInteractor =<br>
>>>>>>>
vtkSmartPointer<vtkRenderWindowInteractor>::New();<br>
>>>>>>>
renWinInteractor->SetRenderWindow(
renderWindow );<br>
>>>>>>><br>
>>>>>>>
renderWindow->Render();<br>
>>>>>>>
renderWindow->SetSize(600, 600);<br>
>>>>>>>
renderer->SetBackground(0.1, 0.2,
0.4);<br>
>>>>>>>
renWinInteractor->Start();<br>
>>>>>>><br>
>>>>>>> return
EXIT_SUCCESS;<br>
>>>>>>> }<br>
>>>>><br>
>>>>><br>
><br>
_______________________________________________<br>
Powered by <a moz-do-not-send="true"
href="http://www.kitware.com"
target="_blank">www.kitware.com</a><br>
<br>
Visit other Kitware open-source projects
at <a moz-do-not-send="true"
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
moz-do-not-send="true"
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 moz-do-not-send="true"
href="http://www.vtk.org/mailman/listinfo/vtkusers"
target="_blank">http://www.vtk.org/mailman/listinfo/vtkusers</a><br>
</div>
</div>
</blockquote>
</div>
<br>
</div>
</div>
</blockquote>
<br>
</div>
</div>
</div>
</blockquote>
</div>
<br>
</div>
</blockquote>
<br>
</body>
</html>