30 #include "WMReadVIM.h"
31 #include "core/common/WPathHelper.h"
32 #include "core/common/WStringUtils.h"
33 #include "core/kernel/WDataModuleInputFile.h"
34 #include "core/kernel/WDataModuleInputFilterFile.h"
35 #include "core/kernel/WKernel.h"
54 return std::shared_ptr< WModule >(
new WMReadVIM() );
66 return "This module reads VIM files containing particle data.";
105 std::vector< WDataModuleInputFilter::ConstSPtr > filters;
132 boost::filesystem::path p = inputFile->getFilename();
135 ifs.open( p.string().c_str(), std::ifstream::in );
136 if( !ifs || ifs.bad() )
138 errorLog() <<
"Could not open file \"" << p.string() <<
"\".";
142 std::shared_ptr< WProgress > progress1(
new WProgress(
"Loading" ) );
150 infoLog() <<
"Start Loading ...";
154 std::vector< std::string > tokens;
155 size_t numPoints = 0;
158 std::getline( ifs, line );
161 if( ( tokens.size() == 9 ) && ( tokens[ 0 ] ==
"!" ) )
165 string_utils::fromString< float >( tokens[2] ),
166 string_utils::fromString< float >( tokens[3] ),
167 string_utils::fromString< float >( tokens[4] )
174 vertices->push_back( coord.
x() );
175 vertices->push_back( coord.
y() );
176 vertices->push_back( coord.
z() );
177 colors->push_back( 1.0 );
178 colors->push_back( 1.0 );
179 colors->push_back( 1.0 );
185 infoLog() <<
"Loaded " << numPoints <<
" points from file. Done.";
188 std::shared_ptr< WDataSetPoints> newOutput(
new WDataSetPoints( vertices, colors, bb ) );
void expandBy(const WBoundingBoxImpl< VT > &bb)
Expands this bounding box to include the given bounding box.
virtual void wait() const
Wait for the condition.
void setResetable(bool resetable=true, bool autoReset=true)
Sets the resetable flag.
virtual void notify()
Notifies all waiting threads.
Base for all data loader modules.
Dataset to store a bunch of points without order or topology.
std::shared_ptr< WDataSetPoints > SPtr
Pointer to dataset.
std::shared_ptr< std::vector< float > > ColorArray
Colors for each vertex in VertexArray.
std::shared_ptr< std::vector< float > > VertexArray
List of vertex coordinates in term of components of vertices.
This module loads VIM files (point data).
virtual void load()
Load data.
std::shared_ptr< WModuleOutputData< WDataSetPoints > > m_output
The output connector for the data.
virtual std::shared_ptr< WModule > factory() const
Due to the prototype design pattern used to build modules, this method returns a new instance of this...
virtual const std::string getDescription() const
Gives back a description of this module.
virtual void connectors()
Initialize the connectors this module is using.
virtual void handleInputChange()
Handle a newly set input.
virtual void moduleMain()
Entry point after loading the module.
virtual std::vector< WDataModuleInputFilter::ConstSPtr > getInputFilter() const
Define a list of file filters we support.
virtual ~WMReadVIM()
Destructor.
bool m_reload
True if the load function needs to be called.
virtual const std::string getName() const
Gives back the name of this module.
WMReadVIM()
Default constructor.
A fixed size matrix class.
ValueT & z()
Access z element of vector.
ValueT & y()
Access y element of vector.
ValueT & x()
Access x element of vector.
Class offering an instantiate-able data connection between modules.
void ready()
Call this whenever your module is ready and can react on property changes.
WConditionSet m_moduleState
The internal state of the module.
wlog::WStreamedLogger errorLog() const
Logger instance for comfortable error logging.
std::shared_ptr< WProgressCombiner > m_progress
Progress indicator used as parent for all progress' of this module.
wlog::WStreamedLogger infoLog() const
Logger instance for comfortable info logging.
virtual void connectors()
Initialize connectors in this function.
void waitRestored()
This method waits for the module to be restored completely.
Class managing progress inside of modules.
WBoolFlag m_shutdownFlag
Condition getting fired whenever the thread should quit.
std::vector< std::string > tokenize(const std::string &source, const std::string &delim=WHITESPACE, bool compress=true)
Splits the given string into a vector of strings (so called tokens).