Skip to content

Commit 4998629

Browse files
committed
Fix bad logic for certain Data Structure requirements for Filter Parameters
Signed-off-by: Michael Jackson <mike.jackson@bluequartz.net>
1 parent 1d8ba0b commit 4998629

3 files changed

Lines changed: 98 additions & 70 deletions

File tree

Source/SIMPLib/Common/SIMPLibSetGetMacros.h

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -396,13 +396,6 @@ public:
396396
return m_##prpty; \
397397
}
398398

399-
// -----------------------------------------------------------------------------
400-
//
401-
// -----------------------------------------------------------------------------
402-
#define SIMPL_CONTAINER_TYPE(thisClass, container) \
403-
typedef(container)<thisClass> ContainerT; \
404-
typedef std::shared_ptr<(container) < (thisClass)>> ContainerPType;
405-
406399
/**
407400
* @brief Creates a "setter" method to set the property.
408401
*/

Source/SVWidgetsLib/Widgets/DataArrayPathSelectionWidget.cpp

Lines changed: 94 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -52,57 +52,6 @@
5252
#include "SVWidgetsLib/QtSupport/QtSSettings.h"
5353
#include "SVWidgetsLib/Widgets/SVStyle.h"
5454

55-
namespace
56-
{
57-
58-
/**
59-
* @brief CheckPathRequirements This is a common function that 3 other methods below implement
60-
* @param filter AbstractFilter
61-
* @param path The DataArrayPath
62-
* @param reqs The requirements
63-
* @return Boolean if we pass or not.
64-
*/
65-
template <typename RequirementsType>
66-
bool CheckDataPathAndRequirements(AbstractFilter* filter, const DataArrayPath& path, const RequirementsType& reqs)
67-
{
68-
if(nullptr == filter)
69-
{
70-
return false;
71-
}
72-
if(nullptr == filter->getDataContainerArray())
73-
{
74-
return false;
75-
}
76-
77-
// Check that the DataContainer exists
78-
DataContainer::Pointer dc = filter->getDataContainerArray()->getDataContainer(path);
79-
if(nullptr == dc)
80-
{
81-
return false;
82-
}
83-
84-
// Check Geometry
85-
if(!reqs.dcGeometryTypes.empty())
86-
{
87-
// Unknown Geometry gets a pass
88-
if(!SIMPL::contains(reqs.dcGeometryTypes, IGeometry::Type::Unknown))
89-
{
90-
IGeometry::Pointer geom = dc->getGeometry();
91-
if(nullptr == geom)
92-
{
93-
return false;
94-
}
95-
if(!SIMPL::contains(reqs.dcGeometryTypes, geom->getGeometryType()) && !SIMPL::contains(reqs.dcGeometryTypes, IGeometry::Type::Any))
96-
{
97-
return false;
98-
}
99-
}
100-
}
101-
102-
return true;
103-
}
104-
105-
} // namespace
10655
// -----------------------------------------------------------------------------
10756
//
10857
// -----------------------------------------------------------------------------
@@ -231,7 +180,41 @@ bool DataArrayPathSelectionWidget::CheckPathRequirements(AbstractFilter* filter,
231180
{
232181
return false;
233182
}
234-
return ::CheckDataPathAndRequirements(filter, path, reqs);
183+
if(nullptr == filter)
184+
{
185+
return false;
186+
}
187+
if(nullptr == filter->getDataContainerArray())
188+
{
189+
return false;
190+
}
191+
192+
// Check that the DataContainer exists
193+
DataContainer::Pointer dc = filter->getDataContainerArray()->getDataContainer(path);
194+
if(nullptr == dc)
195+
{
196+
return false;
197+
}
198+
199+
// Check Geometry
200+
if(!reqs.dcGeometryTypes.empty())
201+
{
202+
// Unknown Geometry gets a pass
203+
if(!SIMPL::contains(reqs.dcGeometryTypes, IGeometry::Type::Unknown))
204+
{
205+
IGeometry::Pointer geom = dc->getGeometry();
206+
if(nullptr == geom)
207+
{
208+
return false;
209+
}
210+
if(!SIMPL::contains(reqs.dcGeometryTypes, geom->getGeometryType()) && !SIMPL::contains(reqs.dcGeometryTypes, IGeometry::Type::Any))
211+
{
212+
return false;
213+
}
214+
}
215+
}
216+
217+
return true;
235218
}
236219

237220
// -----------------------------------------------------------------------------
@@ -243,13 +226,39 @@ bool DataArrayPathSelectionWidget::CheckPathRequirements(AbstractFilter* filter,
243226
{
244227
return false;
245228
}
246-
247-
if(!::CheckDataPathAndRequirements(filter, path, reqs))
229+
if(nullptr == filter)
230+
{
231+
return false;
232+
}
233+
if(nullptr == filter->getDataContainerArray())
248234
{
249235
return false;
250236
}
251-
// This is OK because one of the checks in the function above is if "dc" would be nullptr
237+
238+
// Check that the DataContainer exists
252239
DataContainer::Pointer dc = filter->getDataContainerArray()->getDataContainer(path);
240+
if(nullptr == dc)
241+
{
242+
return false;
243+
}
244+
245+
// Check if geometry exists and matches the requirements only if a geometry is required
246+
if(!reqs.dcGeometryTypes.empty())
247+
{
248+
// Unknown Geometry gets a pass
249+
if(!SIMPL::contains(reqs.dcGeometryTypes, IGeometry::Type::Unknown))
250+
{
251+
IGeometry::Pointer geom = dc->getGeometry();
252+
if(nullptr == geom)
253+
{
254+
return false;
255+
}
256+
if(!SIMPL::contains(reqs.dcGeometryTypes, geom->getGeometryType()) && !SIMPL::contains(reqs.dcGeometryTypes, IGeometry::Type::Any))
257+
{
258+
return false;
259+
}
260+
}
261+
}
253262

254263
// Check AttributeMatrix
255264
AttributeMatrix::Pointer am = dc->getAttributeMatrix(path);
@@ -278,13 +287,39 @@ bool DataArrayPathSelectionWidget::CheckPathRequirements(AbstractFilter* filter,
278287
{
279288
return false;
280289
}
281-
282-
if(!::CheckDataPathAndRequirements(filter, path, reqs))
290+
if(nullptr == filter)
291+
{
292+
return false;
293+
}
294+
if(nullptr == filter->getDataContainerArray())
283295
{
284296
return false;
285297
}
286-
// This is OK because one of the checks in the function above is if "dc" would be nullptr
298+
299+
// Check that the DataContainer exists
287300
DataContainer::Pointer dc = filter->getDataContainerArray()->getDataContainer(path);
301+
if(nullptr == dc)
302+
{
303+
return false;
304+
}
305+
306+
// Check if geometry exists and matches the requirements only if a geometry is required
307+
if(!reqs.dcGeometryTypes.empty())
308+
{
309+
// Unknown Geometry gets a pass
310+
if(!SIMPL::contains(reqs.dcGeometryTypes, IGeometry::Type::Unknown))
311+
{
312+
IGeometry::Pointer geom = dc->getGeometry();
313+
if(nullptr == geom)
314+
{
315+
return false;
316+
}
317+
if(!SIMPL::contains(reqs.dcGeometryTypes, geom->getGeometryType()) && !SIMPL::contains(reqs.dcGeometryTypes, IGeometry::Type::Any))
318+
{
319+
return false;
320+
}
321+
}
322+
}
288323

289324
// Check AttributeMatrix
290325
AttributeMatrix::Pointer am = dc->getAttributeMatrix(path);
@@ -295,7 +330,7 @@ bool DataArrayPathSelectionWidget::CheckPathRequirements(AbstractFilter* filter,
295330

296331
if(!SIMPL::contains(reqs.amTypes, AttributeMatrix::Type::Unknown))
297332
{
298-
if(!reqs.amTypes.empty() && !(SIMPL::contains(reqs.amTypes, am->getType()) && SIMPL::contains(reqs.amTypes, AttributeMatrix::Type::Any)))
333+
if(!reqs.amTypes.empty() && !(SIMPL::contains(reqs.amTypes, am->getType()) || SIMPL::contains(reqs.amTypes, AttributeMatrix::Type::Any)))
299334
{
300335
return false;
301336
}

Source/SVWidgetsLib/Widgets/ImportASCIIDataWizard/DataFormatPage.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -453,10 +453,10 @@ void DataFormatPage::createAMSelectionMenu()
453453
// Get the DataContainerArray object
454454
// Loop over the data containers until we find the proper data container
455455
DataContainerArray::Container containers = dca->getDataContainers();
456-
std::vector<QString> daTypes; // = m_FilterParameter->getDefaultAttributeArrayTypes();
457-
QVector<std::vector<size_t>> cDims; // = m_FilterParameter->getDefaultComponentDimensions();
458-
AttributeMatrix::Types amTypes; // = m_FilterParameter->getDefaultAttributeMatrixTypes();
459-
IGeometry::Types geomTypes; // = m_FilterParameter->getDefaultGeometryTypes();
456+
std::vector<QString> daTypes; // = m_FilterParameter->getDefaultAttributeArrayTypes();
457+
QVector<std::vector<size_t>> cDims; // = m_FilterParameter->getDefaultComponentDimensions();
458+
AttributeMatrix::Types amTypes; // = m_FilterParameter->getDefaultAttributeMatrixTypes();
459+
IGeometry::Types geomTypes; // = m_FilterParameter->getDefaultGeometryTypes();
460460

461461
for(DataContainer::Pointer dc : containers)
462462
{

0 commit comments

Comments
 (0)