Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
VTK
VTK
Commits
4fc9dc3f
Commit
4fc9dc3f
authored
Feb 03, 2012
by
Yuanxin Liu
Committed by
Code Review
Feb 03, 2012
Browse files
Options
Browse Files
Download
Plain Diff
Merge topic 'fix-reflection-filter-bug-0012734' into master
9596c0b1
fix bug 0012734
parents
9122889f
9596c0b1
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
109 additions
and
0 deletions
+109
-0
Graphics/Testing/Cxx/CMakeLists.txt
Graphics/Testing/Cxx/CMakeLists.txt
+1
-0
Graphics/Testing/Cxx/TestReflectionFilter.cxx
Graphics/Testing/Cxx/TestReflectionFilter.cxx
+83
-0
Graphics/vtkReflectionFilter.cxx
Graphics/vtkReflectionFilter.cxx
+25
-0
No files found.
Graphics/Testing/Cxx/CMakeLists.txt
View file @
4fc9dc3f
...
...
@@ -48,6 +48,7 @@ IF (VTK_USE_RENDERING AND VTK_USE_DISPLAY)
TestQuadRotationalExtrusion.cxx
TestQuadRotationalExtrusionMultiBlock.cxx
TestRectilinearGridToPointSet.cxx
TestReflectionFilter.cxx
TestRotationalExtrusion.cxx
TestSelectEnclosedPoints.cxx
TestTessellatedBoxSource.cxx
...
...
Graphics/Testing/Cxx/TestReflectionFilter.cxx
0 → 100644
View file @
4fc9dc3f
/*=========================================================================
Program: Visualization Toolkit
Module: TestReflectionFilter.cxx
Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
All rights reserved.
See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notice for more information.
=========================================================================*/
// This tests vtkReflectionFilter
#include <vtkSmartPointer.h>
#include <vtkNew.h>
#include <vtkUnstructuredGrid.h>
#include <vtkCellType.h>
#include <vtkIdList.h>
#include <vtkReflectionFilter.h>
#include <iostream>
#include <assert.h>
#define AssertMacro(b) if(!(b)){std::cerr <<"Failed to reflect pyramid"<<std::endl;return EXIT_FAILURE;}
int
TestReflectionFilter
(
int
,
char
*
[])
{
vtkSmartPointer
<
vtkUnstructuredGrid
>
pyramid
=
vtkSmartPointer
<
vtkUnstructuredGrid
>::
New
();
{
vtkSmartPointer
<
vtkPoints
>
points
=
vtkSmartPointer
<
vtkPoints
>::
New
();
points
->
InsertNextPoint
(
-
1
,
-
1
,
-
1
);
points
->
InsertNextPoint
(
1
,
-
1
,
-
1
);
points
->
InsertNextPoint
(
1
,
1
,
-
1
);
points
->
InsertNextPoint
(
-
1
,
1
,
-
1
);
points
->
InsertNextPoint
(
0
,
0
,
1
);
pyramid
->
SetPoints
(
points
);
}
vtkNew
<
vtkIdList
>
verts
;
verts
->
InsertNextId
(
0
);
verts
->
InsertNextId
(
1
);
verts
->
InsertNextId
(
2
);
verts
->
InsertNextId
(
3
);
verts
->
InsertNextId
(
4
);
pyramid
->
InsertNextCell
(
VTK_PYRAMID
,
verts
.
GetPointer
());
for
(
int
i
=
0
;
i
<
2
;
i
++
)
{
vtkSmartPointer
<
vtkReflectionFilter
>
reflectionFilter
=
vtkSmartPointer
<
vtkReflectionFilter
>::
New
();
reflectionFilter
->
SetInput
(
pyramid
.
GetPointer
());
i
==
0
?
reflectionFilter
->
CopyInputOff
()
:
reflectionFilter
->
CopyInputOn
();
reflectionFilter
->
SetPlaneToZMin
();
reflectionFilter
->
Update
();
vtkUnstructuredGrid
*
pyramid1
=
vtkUnstructuredGrid
::
SafeDownCast
(
reflectionFilter
->
GetOutput
());
vtkNew
<
vtkIdList
>
cellIds
;
if
(
i
==
0
)
{
AssertMacro
(
pyramid1
->
GetNumberOfCells
()
==
1
);
}
else
{
AssertMacro
(
pyramid1
->
GetNumberOfCells
()
==
2
);
}
pyramid1
->
GetCellPoints
(
i
,
cellIds
.
GetPointer
());
int
apex
=
cellIds
->
GetId
(
4
);
int
offset
=
i
==
0
?
0
:
5
;
AssertMacro
(
apex
==
4
+
offset
);
for
(
int
j
=
0
;
j
<
4
;
j
++
)
{
int
next
=
cellIds
->
GetId
((
j
+
1
)
%
4
);
int
nextExpected
=
(
cellIds
->
GetId
(
j
)
-
offset
+
3
)
%
4
+
offset
;
AssertMacro
(
next
==
nextExpected
);
}
}
return
EXIT_SUCCESS
;
}
Graphics/vtkReflectionFilter.cxx
View file @
4fc9dc3f
...
...
@@ -344,6 +344,31 @@ int vtkReflectionFilter::RequestDataInternal(
cellId
=
output
->
InsertNextCell
(
cellType
,
cellPts
);
cellPts
->
Delete
();
}
else
if
(
cellType
==
VTK_PYRAMID
&&
vtkUnstructuredGrid
::
SafeDownCast
(
input
))
{
if
(
numCellPts
!=
5
)
{
vtkErrorMacro
(
"Pyramid cell must have exactly 5 points"
)
}
int
four
=
numCellPts
-
1
;
cellPts
=
cell
->
GetPointIds
();
newCellPts
=
new
vtkIdType
[
numCellPts
];
for
(
j
=
four
-
1
;
j
>=
0
;
j
--
)
{
newCellPts
[
four
-
1
-
j
]
=
cellPts
->
GetId
(
j
);
if
(
this
->
CopyInput
)
{
newCellPts
[
four
-
1
-
j
]
+=
numPts
;
}
}
newCellPts
[
four
]
=
cellPts
->
GetId
(
four
);
if
(
this
->
CopyInput
)
{
newCellPts
[
four
]
+=
numPts
;
}
cellId
=
output
->
InsertNextCell
(
cellType
,
numCellPts
,
newCellPts
);
delete
[]
newCellPts
;
}
else
{
cellPts
=
cell
->
GetPointIds
();
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment