Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
VTK
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Sean McBride
VTK
Commits
7b1a6829
Commit
7b1a6829
authored
2 months ago
by
Jean Fechter
Browse files
Options
Downloads
Patches
Plain Diff
Fix AxisAlignedReflectionFilter composite dataset with null input
parent
993e8f34
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
Filters/General/vtkAxisAlignedReflectionFilter.cxx
+81
-79
81 additions, 79 deletions
Filters/General/vtkAxisAlignedReflectionFilter.cxx
Filters/General/vtkAxisAlignedReflectionFilter.h
+14
-5
14 additions, 5 deletions
Filters/General/vtkAxisAlignedReflectionFilter.h
with
95 additions
and
84 deletions
Filters/General/vtkAxisAlignedReflectionFilter.cxx
+
81
−
79
View file @
7b1a6829
...
...
@@ -35,6 +35,18 @@ VTK_ABI_NAMESPACE_BEGIN
//------------------------------------------------------------------------------
vtkObjectFactoryNewMacro
(
vtkAxisAlignedReflectionFilter
);
namespace
{
//------------------------------------------------------------------------------
vtkSmartPointer
<
vtkPartitionedDataSet
>
CreatePartitionedDataSet
(
vtkDataObject
*
dataObject
)
{
vtkNew
<
vtkPartitionedDataSet
>
parts
;
parts
->
SetNumberOfPartitions
(
1
);
parts
->
SetPartition
(
0
,
dataObject
);
return
parts
;
}
}
// anonymous namespace
//------------------------------------------------------------------------------
void
vtkAxisAlignedReflectionFilter
::
ComputeBounds
(
vtkDataObject
*
input
,
double
bounds
[
6
])
{
...
...
@@ -52,19 +64,44 @@ void vtkAxisAlignedReflectionFilter::ComputeBounds(vtkDataObject* input, double
}
//------------------------------------------------------------------------------
vtkSmartPointer
<
vtkPartitionedDataSet
>
CreatePartitionedDataSet
(
vtkDataObject
*
dataObject
)
void
vtkAxisAlignedReflectionFilter
::
AddPartitionedDataSet
(
vtkPartitionedDataSetCollection
*
outputPDSC
,
vtkDataObject
*
dObj
,
vtkInformation
*
inputMetadata
,
const
int
nodeId
,
const
bool
isParentMultiblock
,
const
bool
isInputCopy
)
{
vtkNew
<
vtkPartitionedDataSet
>
parts
;
parts
->
SetNumberOfPartitions
(
1
);
parts
->
SetPartition
(
0
,
dataObject
);
return
parts
;
vtkDataAssembly
*
outputHierarchy
=
outputPDSC
->
GetDataAssembly
();
outputPDSC
->
SetPartitionedDataSet
(
this
->
PartitionIndex
,
::
CreatePartitionedDataSet
(
dObj
));
std
::
string
nodeName
;
int
&
count
=
isInputCopy
?
this
->
InputCount
:
this
->
ReflectionCount
;
const
std
::
string
nodeNamePrefix
=
isInputCopy
?
"Input_"
:
"Reflection_"
;
const
std
::
string
nodeNamePrefixMeta
=
isInputCopy
?
""
:
"Reflection_"
;
if
(
inputMetadata
&&
inputMetadata
->
Has
(
vtkCompositeDataSet
::
NAME
()))
{
nodeName
=
nodeNamePrefixMeta
+
outputHierarchy
->
MakeValidNodeName
(
inputMetadata
->
Get
(
vtkCompositeDataSet
::
NAME
()));
}
else
{
nodeName
=
nodeNamePrefix
+
std
::
to_string
(
count
++
);
}
outputPDSC
->
GetMetaData
(
this
->
PartitionIndex
)
->
Set
(
vtkCompositeDataSet
::
NAME
(),
nodeName
.
c_str
());
if
(
isParentMultiblock
)
{
int
dsNodeId
=
outputHierarchy
->
AddNode
(
nodeName
.
c_str
(),
nodeId
);
outputHierarchy
->
AddDataSetIndex
(
dsNodeId
,
this
->
PartitionIndex
);
}
else
{
outputHierarchy
->
AddDataSetIndex
(
nodeId
,
this
->
PartitionIndex
);
}
this
->
PartitionIndex
++
;
}
//------------------------------------------------------------------------------
bool
vtkAxisAlignedReflectionFilter
::
ProcessComposite
(
vtkPartitionedDataSetCollection
*
outputPDSC
,
vtkCompositeDataSet
*
inputCD
,
double
bounds
[
6
],
int
inputNodeId
,
int
reflectionNodeId
,
vtkDataAssembly
*
outputHierarchy
,
int
&
partitionIndex
,
int
&
inputCount
,
int
&
reflectionCount
)
vtkCompositeDataSet
*
inputCD
,
double
bounds
[
6
],
int
inputNodeId
,
int
reflectionNodeId
)
{
vtkDataObjectTree
*
inputTree
=
vtkDataObjectTree
::
SafeDownCast
(
inputCD
);
if
(
!
inputTree
)
{
...
...
@@ -78,6 +115,8 @@ bool vtkAxisAlignedReflectionFilter::ProcessComposite(vtkPartitionedDataSetColle
iter
.
TakeReference
(
inputTree
->
NewTreeIterator
());
iter
->
SetVisitOnlyLeaves
(
false
);
iter
->
SetTraverseSubTree
(
false
);
iter
->
SetSkipEmptyNodes
(
false
);
for
(
iter
->
InitTraversal
();
!
iter
->
IsDoneWithTraversal
();
iter
->
GoToNextItem
())
{
if
(
this
->
CheckAbort
())
...
...
@@ -85,15 +124,18 @@ bool vtkAxisAlignedReflectionFilter::ProcessComposite(vtkPartitionedDataSetColle
break
;
}
vtkInformation
*
inputMetadata
=
inputTree
->
HasMetaData
(
iter
)
?
inputTree
->
GetMetaData
(
iter
)
:
nullptr
;
vtkCompositeDataSet
*
cds
=
vtkCompositeDataSet
::
SafeDownCast
(
iter
->
GetCurrentDataObject
());
if
(
cds
)
{
vtkDataAssembly
*
outputHierarchy
=
outputPDSC
->
GetDataAssembly
();
std
::
string
compositeNodeName
=
"Composite"
;
if
(
inputTree
->
HasMetaData
(
iter
)
&&
inputTree
->
GetMetaData
(
iter
)
->
Has
(
vtkCompositeDataSet
::
NAME
()))
if
(
inputMetadata
&&
inputMetadata
->
Has
(
vtkCompositeDataSet
::
NAME
()))
{
compositeNodeName
=
outputHierarchy
->
MakeValidNodeName
(
inputTree
->
Ge
tMeta
D
ata
(
iter
)
->
Get
(
vtkCompositeDataSet
::
NAME
()));
compositeNodeName
=
outputHierarchy
->
MakeValidNodeName
(
inpu
tMeta
d
ata
->
Get
(
vtkCompositeDataSet
::
NAME
()));
}
int
compositeInputNodeId
=
-
1
;
...
...
@@ -104,9 +146,8 @@ bool vtkAxisAlignedReflectionFilter::ProcessComposite(vtkPartitionedDataSetColle
int
compositeReflectionNodeId
=
outputHierarchy
->
AddNode
(
compositeNodeName
.
c_str
(),
reflectionNodeId
);
if
(
!
ProcessComposite
(
outputPDSC
,
cds
,
bounds
,
compositeInputNodeId
,
compositeReflectionNodeId
,
outputHierarchy
,
partitionIndex
,
inputCount
,
reflectionCount
))
if
(
!
ProcessComposite
(
outputPDSC
,
cds
,
bounds
,
compositeInputNodeId
,
compositeReflectionNodeId
))
{
vtkErrorMacro
(
"Failed to process composite dataset "
<<
cds
->
GetClassName
());
return
false
;
...
...
@@ -114,6 +155,19 @@ bool vtkAxisAlignedReflectionFilter::ProcessComposite(vtkPartitionedDataSetColle
continue
;
}
// Handle empty nodes
if
(
iter
->
GetCurrentDataObject
()
==
nullptr
)
{
if
(
this
->
CopyInput
)
{
this
->
AddPartitionedDataSet
(
outputPDSC
,
nullptr
,
inputMetadata
,
inputNodeId
,
mb
!=
nullptr
,
true
);
}
this
->
AddPartitionedDataSet
(
outputPDSC
,
nullptr
,
inputMetadata
,
reflectionNodeId
,
mb
!=
nullptr
,
false
);
continue
;
}
vtkDataSet
*
ds
=
vtkDataSet
::
SafeDownCast
(
iter
->
GetCurrentDataObject
());
vtkHyperTreeGrid
*
htg
=
vtkHyperTreeGrid
::
SafeDownCast
(
iter
->
GetCurrentDataObject
());
if
(
!
ds
&&
!
htg
)
...
...
@@ -129,31 +183,9 @@ bool vtkAxisAlignedReflectionFilter::ProcessComposite(vtkPartitionedDataSetColle
{
vtkSmartPointer
<
vtkDataObject
>
inputCopy
=
dObj
->
NewInstance
();
inputCopy
->
ShallowCopy
(
dObj
);
outputPDSC
->
SetPartitionedDataSet
(
partitionIndex
,
CreatePartitionedDataSet
(
inputCopy
));
std
::
string
nodeName
;
if
(
inputTree
->
HasMetaData
(
iter
)
&&
inputTree
->
GetMetaData
(
iter
)
->
Has
(
vtkCompositeDataSet
::
NAME
()))
{
nodeName
=
"Input_"
+
outputHierarchy
->
MakeValidNodeName
(
inputTree
->
GetMetaData
(
iter
)
->
Get
(
vtkCompositeDataSet
::
NAME
()));
}
else
{
nodeName
=
"Input_"
+
std
::
to_string
(
inputCount
++
);
}
outputPDSC
->
GetMetaData
(
partitionIndex
)
->
Set
(
vtkCompositeDataSet
::
NAME
(),
nodeName
.
c_str
());
if
(
mb
)
{
int
dsNodeId
=
outputHierarchy
->
AddNode
(
nodeName
.
c_str
(),
inputNodeId
);
outputHierarchy
->
AddDataSetIndex
(
dsNodeId
,
partitionIndex
);
}
else
{
outputHierarchy
->
AddDataSetIndex
(
inputNodeId
,
partitionIndex
);
}
this
->
AddPartitionedDataSet
(
outputPDSC
,
inputCopy
,
inputMetadata
,
inputNodeId
,
mb
!=
nullptr
,
true
);
inputCopy
->
Delete
();
partitionIndex
++
;
}
if
(
!
this
->
ProcessLeaf
(
dObj
,
outputObj
,
bounds
))
...
...
@@ -163,31 +195,8 @@ bool vtkAxisAlignedReflectionFilter::ProcessComposite(vtkPartitionedDataSetColle
return
false
;
}
outputPDSC
->
SetPartitionedDataSet
(
partitionIndex
,
CreatePartitionedDataSet
(
outputObj
));
std
::
string
nodeName
;
if
(
inputTree
->
HasMetaData
(
iter
)
&&
inputTree
->
GetMetaData
(
iter
)
->
Has
(
vtkCompositeDataSet
::
NAME
()))
{
nodeName
=
outputHierarchy
->
MakeValidNodeName
(
inputTree
->
GetMetaData
(
iter
)
->
Get
(
vtkCompositeDataSet
::
NAME
()));
}
else
{
nodeName
=
"Reflection_"
+
std
::
to_string
(
reflectionCount
++
);
}
outputPDSC
->
GetMetaData
(
partitionIndex
)
->
Set
(
vtkCompositeDataSet
::
NAME
(),
nodeName
.
c_str
());
if
(
mb
)
{
int
dsNodeId
=
outputHierarchy
->
AddNode
(
nodeName
.
c_str
(),
reflectionNodeId
);
outputHierarchy
->
AddDataSetIndex
(
dsNodeId
,
partitionIndex
);
}
else
{
outputHierarchy
->
AddDataSetIndex
(
reflectionNodeId
,
partitionIndex
);
}
partitionIndex
++
;
this
->
AddPartitionedDataSet
(
outputPDSC
,
outputObj
,
inputMetadata
,
reflectionNodeId
,
mb
!=
nullptr
,
false
);
outputObj
->
Delete
();
}
return
true
;
...
...
@@ -244,16 +253,16 @@ int vtkAxisAlignedReflectionFilter::RequestData(vtkInformation* vtkNotUsed(reque
if
(
inputDS
||
inputHtg
)
{
vtkDataObject
*
inputDO
=
vtkDataObject
::
GetData
(
inputVector
[
0
],
0
);
int
partitionIndex
=
0
;
if
(
this
->
CopyInput
)
{
vtkSmartPointer
<
vtkDataObject
>
inputCopy
=
inputDO
->
NewInstance
();
inputCopy
->
ShallowCopy
(
inputDO
);
outputPDSC
->
SetPartitionedDataSet
(
partitionIndex
,
CreatePartitionedDataSet
(
inputCopy
));
outputPDSC
->
GetMetaData
(
partitionIndex
)
->
Set
(
vtkCompositeDataSet
::
NAME
(),
"Input"
);
outputHierarchy
->
AddDataSetIndex
(
inputNodeId
,
partitionIndex
);
outputPDSC
->
SetPartitionedDataSet
(
this
->
PartitionIndex
,
::
CreatePartitionedDataSet
(
inputCopy
));
outputPDSC
->
GetMetaData
(
this
->
PartitionIndex
)
->
Set
(
vtkCompositeDataSet
::
NAME
(),
"Input"
);
outputHierarchy
->
AddDataSetIndex
(
inputNodeId
,
this
->
PartitionIndex
);
inputCopy
->
Delete
();
p
artitionIndex
++
;
this
->
P
artitionIndex
++
;
}
double
bounds
[
6
];
...
...
@@ -261,9 +270,9 @@ int vtkAxisAlignedReflectionFilter::RequestData(vtkInformation* vtkNotUsed(reque
vtkSmartPointer
<
vtkDataObject
>
outputDO
=
inputDO
->
NewInstance
();
if
(
this
->
ProcessLeaf
(
inputDO
,
outputDO
,
bounds
))
{
outputPDSC
->
SetPartitionedDataSet
(
p
artitionIndex
,
CreatePartitionedDataSet
(
outputDO
));
outputPDSC
->
GetMetaData
(
p
artitionIndex
)
->
Set
(
vtkCompositeDataSet
::
NAME
(),
"Reflection"
);
outputHierarchy
->
AddDataSetIndex
(
reflectionNodeId
,
p
artitionIndex
);
outputPDSC
->
SetPartitionedDataSet
(
this
->
P
artitionIndex
,
::
CreatePartitionedDataSet
(
outputDO
));
outputPDSC
->
GetMetaData
(
this
->
P
artitionIndex
)
->
Set
(
vtkCompositeDataSet
::
NAME
(),
"Reflection"
);
outputHierarchy
->
AddDataSetIndex
(
reflectionNodeId
,
this
->
P
artitionIndex
);
outputDO
->
Delete
();
}
else
...
...
@@ -278,14 +287,7 @@ int vtkAxisAlignedReflectionFilter::RequestData(vtkInformation* vtkNotUsed(reque
double
bounds
[
6
];
this
->
ComputeBounds
(
inputCD
,
bounds
);
int
partitionIndex
=
0
;
// For naming purposes
int
inputCount
=
0
;
int
reflectionCount
=
0
;
if
(
!
ProcessComposite
(
outputPDSC
,
inputCD
,
bounds
,
inputNodeId
,
reflectionNodeId
,
outputHierarchy
,
partitionIndex
,
inputCount
,
reflectionCount
))
if
(
!
ProcessComposite
(
outputPDSC
,
inputCD
,
bounds
,
inputNodeId
,
reflectionNodeId
))
{
vtkErrorMacro
(
"Failed to process composite dataset "
<<
inputCD
->
GetClassName
());
return
0
;
...
...
This diff is collapsed.
Click to expand it.
Filters/General/vtkAxisAlignedReflectionFilter.h
+
14
−
5
View file @
7b1a6829
...
...
@@ -29,7 +29,6 @@
#include
"vtkSmartPointer.h"
// for smart pointer
VTK_ABI_NAMESPACE_BEGIN
class
vtkDataAssembly
;
class
vtkDataSet
;
class
vtkDataSetAttributes
;
class
vtkExplicitStructuredGrid
;
...
...
@@ -39,7 +38,6 @@ class vtkPartitionedDataSetCollection;
class
vtkPolyData
;
class
vtkRectilinearGrid
;
class
vtkStructuredGrid
;
class
vtkUnstructuredGrid
;
class
VTKFILTERSGENERAL_EXPORT
vtkAxisAlignedReflectionFilter
:
public
vtkCompositeDataSetAlgorithm
{
...
...
@@ -122,7 +120,7 @@ public:
/**
* Get the last modified time of this filter.
* This time also depends on the
the
modified
* This time also depends on the modified
* time of the internal ReflectionFunction instance.
*/
vtkMTimeType
GetMTime
()
override
;
...
...
@@ -152,6 +150,12 @@ private:
void
FindAndReflectArrays
(
vtkDataSet
*
input
,
vtkDataSet
*
output
,
int
mirrorDir
[
3
],
int
mirrorSymmetricTensorDir
[
6
],
int
mirrorTensorDir
[
9
]);
/**
* Add `dObj` as a new partitioned dataset of `outputPDSC` and update the assembly.
*/
void
AddPartitionedDataSet
(
vtkPartitionedDataSetCollection
*
outputPDSC
,
vtkDataObject
*
dObj
,
vtkInformation
*
inputMetadata
,
int
nodeId
,
bool
isParentMultiblock
,
bool
isInputCopy
);
/**
* Process composite inputs.
* A "Composite" node is added as child of reflectionNodeId, and for each child of the composite
...
...
@@ -160,8 +164,7 @@ private:
* name.
*/
bool
ProcessComposite
(
vtkPartitionedDataSetCollection
*
outputPDSC
,
vtkCompositeDataSet
*
inputCD
,
double
bounds
[
6
],
int
inputNodeId
,
int
reflectionNodeId
,
vtkDataAssembly
*
outputHierarchy
,
int
&
partitionIndex
,
int
&
inputCount
,
int
&
reflectionCount
);
double
bounds
[
6
],
int
inputNodeId
,
int
reflectionNodeId
);
/**
* Process non-composite inputs (datasets and hyper tree grids).
*/
...
...
@@ -194,6 +197,12 @@ private:
PlaneAxis
PlaneAxisInternal
=
X_PLANE
;
double
PlaneOriginInternal
[
3
]
=
{
0.0
,
0.0
,
0.0
};
// For naming purposes
int
InputCount
=
0
;
int
ReflectionCount
=
0
;
int
PartitionIndex
=
0
;
};
VTK_ABI_NAMESPACE_END
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment