Skip to content

Commit bb0d217

Browse files
committed
FILT: Add ReadNotesFile which is used to read a text file.
This filter will read a text file and create a String array in the data structure.
1 parent e45bca2 commit bb0d217

8 files changed

Lines changed: 504 additions & 0 deletions

File tree

src/Plugins/SimplnxCore/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,7 @@ set(FilterList
158158
WriteStlFileFilter
159159
WriteVtkRectilinearGridFilter
160160
WriteVtkStructuredPointsFilter
161+
ReadNotesFileFilter
161162
)
162163

163164
set(ActionList
@@ -266,6 +267,7 @@ set(AlgorithmList
266267
WriteStlFile
267268
WriteVtkRectilinearGrid
268269
WriteVtkStructuredPoints
270+
ReadNotesFile
269271
)
270272

271273
create_simplnx_plugin(NAME ${PLUGIN_NAME}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# INSERT_HUMAN_NAME
2+
3+
## Group (Subgroup)
4+
5+
What group (and possibly subgroup) does the filter belong to
6+
7+
## Description
8+
9+
This **Filter** .....
10+
11+
Images can be used with this:
12+
13+
![](Images/ReadNotesFile_1.png)
14+
15+
## Warning
16+
17+
## Notes
18+
19+
## Caveats
20+
21+
% Auto generated parameter table will be inserted here
22+
23+
## Reference
24+
25+
26+
## Example Pipelines
27+
28+
29+
## License & Copyright
30+
31+
Please see the description file distributed with this plugin.
32+
33+
## DREAM3D Mailing Lists
34+
35+
If you need help, need to file a bug report or want to request a new feature, please head over to the [DREAM3DNX-Issues](https://github.com/BlueQuartzSoftware/DREAM3DNX-Issues/discussions) GitHub site where the community of DREAM3D-NX users can help answer your questions.
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
#include "ReadNotesFile.hpp"
2+
3+
#include "simplnx/DataStructure/DataArray.hpp"
4+
#include "simplnx/DataStructure/DataGroup.hpp"
5+
6+
using namespace nx::core;
7+
8+
// -----------------------------------------------------------------------------
9+
ReadNotesFile::ReadNotesFile(DataStructure& dataStructure, const IFilter::MessageHandler& mesgHandler, const std::atomic_bool& shouldCancel, ReadNotesFileInputValues* inputValues)
10+
: m_DataStructure(dataStructure)
11+
, m_InputValues(inputValues)
12+
, m_ShouldCancel(shouldCancel)
13+
, m_MessageHandler(mesgHandler)
14+
{
15+
}
16+
17+
// -----------------------------------------------------------------------------
18+
ReadNotesFile::~ReadNotesFile() noexcept = default;
19+
20+
// -----------------------------------------------------------------------------
21+
Result<> ReadNotesFile::operator()()
22+
{
23+
/**
24+
* This section of the code should contain the actual algorithmic codes that
25+
* will accomplish the goal of the file.
26+
*
27+
* If you can parallelize the code there are a number of examples on how to do that.
28+
* GenerateIPFColors is one example
29+
*
30+
* If you need to determine what kind of array you have (Int32Array, Float32Array, etc)
31+
* look to the ExecuteDataFunction() in simplnx/Utilities/FilterUtilities.hpp template
32+
* function to help with that code.
33+
* An Example algorithm class is `CombineAttributeArrays` and `RemoveFlaggedVertices`
34+
*
35+
* There are other utility classes that can help alleviate the amount of code that needs
36+
* to be written.
37+
*
38+
* REMOVE THIS COMMENT BLOCK WHEN YOU ARE FINISHED WITH THE FILTER_HUMAN_NAME
39+
*/
40+
41+
return {};
42+
}
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
#pragma once
2+
3+
#include "SimplnxCore/SimplnxCore_export.hpp"
4+
5+
#include "simplnx/DataStructure/DataPath.hpp"
6+
#include "simplnx/DataStructure/DataStructure.hpp"
7+
#include "simplnx/Filter/IFilter.hpp"
8+
9+
// TODO: PARAMETER_INCLUDES
10+
11+
/**
12+
* This is example code to put in the Execute Method of the filter.
13+
@EXECUTE_EXAMPLE_CODE@
14+
*/
15+
16+
namespace nx::core
17+
{
18+
19+
struct SIMPLNXCORE_EXPORT ReadNotesFileInputValues
20+
{
21+
// TODO: INPUT_VALUE_STRUCT_DEF
22+
};
23+
24+
/**
25+
* @class ReadNotesFile
26+
* @brief This algorithm implements support code for the ReadNotesFileFilter
27+
*/
28+
29+
class SIMPLNXCORE_EXPORT ReadNotesFile
30+
{
31+
public:
32+
ReadNotesFile(DataStructure& dataStructure, const IFilter::MessageHandler& mesgHandler, const std::atomic_bool& shouldCancel, ReadNotesFileInputValues* inputValues);
33+
~ReadNotesFile() noexcept;
34+
35+
ReadNotesFile(const ReadNotesFile&) = delete;
36+
ReadNotesFile(ReadNotesFile&&) noexcept = delete;
37+
ReadNotesFile& operator=(const ReadNotesFile&) = delete;
38+
ReadNotesFile& operator=(ReadNotesFile&&) noexcept = delete;
39+
40+
Result<> operator()();
41+
42+
private:
43+
DataStructure& m_DataStructure;
44+
const ReadNotesFileInputValues* m_InputValues = nullptr;
45+
const std::atomic_bool& m_ShouldCancel;
46+
const IFilter::MessageHandler& m_MessageHandler;
47+
};
48+
49+
} // namespace nx::core
Lines changed: 178 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,178 @@
1+
#include "ReadNotesFileFilter.hpp"
2+
3+
#include "SimplnxCore/Filters/Algorithms/ReadNotesFile.hpp"
4+
5+
#include "simplnx/DataStructure/DataPath.hpp"
6+
#include "simplnx/Filter/Actions/EmptyAction.hpp"
7+
8+
// TODO: PARAMETER_INCLUDES
9+
10+
#include <vector>
11+
12+
using namespace nx::core;
13+
14+
namespace nx::core
15+
{
16+
//------------------------------------------------------------------------------
17+
std::string ReadNotesFileFilter::name() const
18+
{
19+
return FilterTraits<ReadNotesFileFilter>::name.str();
20+
}
21+
22+
//------------------------------------------------------------------------------
23+
std::string ReadNotesFileFilter::className() const
24+
{
25+
return FilterTraits<ReadNotesFileFilter>::className;
26+
}
27+
28+
//------------------------------------------------------------------------------
29+
Uuid ReadNotesFileFilter::uuid() const
30+
{
31+
return FilterTraits<ReadNotesFileFilter>::uuid;
32+
}
33+
34+
//------------------------------------------------------------------------------
35+
std::string ReadNotesFileFilter::humanName() const
36+
{
37+
return "@FILTER_HUMAN_NAME@";
38+
}
39+
40+
//------------------------------------------------------------------------------
41+
std::vector<std::string> ReadNotesFileFilter::defaultTags() const
42+
{
43+
return {""};
44+
}
45+
46+
//------------------------------------------------------------------------------
47+
Parameters ReadNotesFileFilter::parameters() const
48+
{
49+
Parameters params;
50+
// Create the parameter descriptors that are needed for this filter
51+
params.insertSeparator(Parameters::Separator{"Input Parameter(s)"});
52+
53+
/**
54+
* Please separate the parameters into groups generally of the following:
55+
*
56+
* params.insertSeparator(Parameters::Separator{"Input Parameters"});
57+
* params.insertSeparator(Parameters::Separator{"Required Input Cell Data"});
58+
* params.insertSeparator(Parameters::Separator{"Required Input Feature Data"});
59+
* params.insertSeparator(Parameters::Separator{"Created Cell Data"});
60+
* params.insertSeparator(Parameters::Separator{"Created Cell Feature Data"});
61+
*
62+
* .. or create appropriate separators as needed. The UI in COMPLEX no longer
63+
* does this for the developer by using catgories as in SIMPL
64+
*/
65+
66+
// Create the parameter descriptors that are needed for this filter
67+
68+
// TODO: PARAMETER_DEFS
69+
return params;
70+
}
71+
72+
//------------------------------------------------------------------------------
73+
IFilter::VersionType ReadNotesFileFilter::parametersVersion() const
74+
{
75+
return 1;
76+
}
77+
78+
//------------------------------------------------------------------------------
79+
IFilter::UniquePointer ReadNotesFileFilter::clone() const
80+
{
81+
return std::make_unique<ReadNotesFileFilter>();
82+
}
83+
84+
//------------------------------------------------------------------------------
85+
IFilter::PreflightResult ReadNotesFileFilter::preflightImpl(const DataStructure& dataStructure, const Arguments& filterArgs, const MessageHandler& messageHandler, const std::atomic_bool& shouldCancel,
86+
const ExecutionContext& executionContext) const
87+
{
88+
/****************************************************************************
89+
* Write any preflight sanity checking codes in this function
90+
***************************************************************************/
91+
92+
/**
93+
* These are the values that were gathered from the UI or the pipeline file or
94+
* otherwise passed into the filter. These are here for your convenience. If you
95+
* do not need some of them remove them.
96+
*/
97+
98+
// TODO: PREFLIGHT_DEFS
99+
100+
// Declare the preflightResult variable that will be populated with the results
101+
// of the preflight. The PreflightResult type contains the output Actions and
102+
// any preflight updated values that you want to be displayed to the user, typically
103+
// through a user interface (UI).
104+
PreflightResult preflightResult;
105+
106+
// If your filter is making structural changes to the DataStructure then the filter
107+
// is going to create OutputActions subclasses that need to be returned. This will
108+
// store those actions.
109+
nx::core::Result<OutputActions> resultOutputActions;
110+
111+
// If your filter is going to pass back some `preflight updated values` then this is where you
112+
// would create the code to store those values in the appropriate object. Note that we
113+
// in line creating the pair (NOT a std::pair<>) of Key:Value that will get stored in
114+
// the std::vector<PreflightValue> object.
115+
std::vector<PreflightValue> preflightUpdatedValues;
116+
117+
// If the filter needs to pass back some updated values via a key:value string:string set of values
118+
// you can declare and update that string here.
119+
120+
// TODO: PREFLIGHT_UPDATED_DEFS
121+
// If this filter makes changes to the DataStructure in the form of
122+
// creating/deleting/moving/renaming DataGroups, Geometries, DataArrays then you
123+
// will need to use one of the `*Actions` classes located in complex/Filter/Actions
124+
// to relay that information to the preflight and execute methods. This is done by
125+
// creating an instance of the Action class and then storing it in the resultOutputActions variable.
126+
// This is done through a `push_back()` method combined with a `std::move()`. For the
127+
// newly initiated to `std::move` once that code is executed what was once inside the Action class
128+
// instance variable is *no longer there*. The memory has been moved. If you try to access that
129+
// variable after this line you will probably get a crash or have subtle bugs. To ensure that this
130+
// does not happen we suggest using braces `{}` to scope each of the action's declaration and store
131+
// so that the programmer is not tempted to use the action instance past where it should be used.
132+
// You have to create your own Actions class if there isn't something specific for your filter's needs
133+
134+
// TODO: PROPOSED_ACTIONS
135+
// Store the preflight updated value(s) into the preflightUpdatedValues vector using
136+
// the appropriate methods.
137+
138+
// TODO: PREFLIGHT_UPDATED_VALUES
139+
// Return both the resultOutputActions and the preflightUpdatedValues via std::move()
140+
return {std::move(resultOutputActions), std::move(preflightUpdatedValues)};
141+
}
142+
143+
//------------------------------------------------------------------------------
144+
Result<> ReadNotesFileFilter::executeImpl(DataStructure& dataStructure, const Arguments& filterArgs, const PipelineFilter* pipelineNode, const MessageHandler& messageHandler,
145+
const std::atomic_bool& shouldCancel, const ExecutionContext& executionContext) const
146+
{
147+
148+
ReadNotesFileInputValues inputValues;
149+
150+
// TODO: INPUT_VALUES_DEF
151+
152+
return ReadNotesFile(dataStructure, messageHandler, shouldCancel, &inputValues)();
153+
}
154+
155+
namespace
156+
{
157+
namespace SIMPL
158+
{
159+
160+
// TODO: PARAMETER_JSON_CONSTANTS
161+
} // namespace SIMPL
162+
} // namespace
163+
164+
//------------------------------------------------------------------------------
165+
Result<Arguments> ReadNotesFileFilter::FromSIMPLJson(const nlohmann::json& json)
166+
{
167+
Arguments args = ReadNotesFileFilter().getDefaultArguments();
168+
169+
std::vector<Result<>> results;
170+
171+
/* This is a NEW filter and not ported so this section does not matter */
172+
173+
Result<> conversionResult = MergeResults(std::move(results));
174+
175+
return ConvertResultTo<Arguments>(std::move(conversionResult), std::move(args));
176+
}
177+
178+
} // namespace nx::core

0 commit comments

Comments
 (0)