30 #include "WMReadVCL.h"
31 #include "core/common/WPathHelper.h"
32 #include "core/common/WStringUtils.h"
33 #include "core/kernel/WKernel.h"
50 return std::shared_ptr< WModule >(
new WMReadVCL() );
60 return "Read VCL line data and their attributes.";
76 m_loadAttrib =
m_properties->addProperty(
"Load Attribute",
"If true, load the specified attribute from file.",
false );
77 m_attrib =
m_properties->addProperty(
"Attribute",
"Index of the attribute to use if there are any. Begins at 1.", 1 );
98 std::shared_ptr< WProgress > progress = std::shared_ptr< WProgress >(
new WProgress(
"Read Data" ) );
110 ifs.open( filename.c_str(), std::ifstream::in );
111 if( !ifs || ifs.bad() )
113 errorLog() <<
"Could not open file \"" << filename <<
"\".";
126 std::vector< std::string > tokens;
130 unsigned int attribIndex =
m_attrib->get(
true ) - 1;
132 size_t currentIndex = 0;
133 size_t currentLength = 0;
134 size_t currentStartIndex = 0;
135 size_t currentLineCount = 0;
139 std::getline( ifs, line );
144 if( ( tokens.size() >= 4 ) && ( tokens[ 0 ] ==
"p" ) )
148 string_utils::fromString< float >( tokens[1] ),
149 string_utils::fromString< float >( tokens[2] ),
150 string_utils::fromString< float >( tokens[3] )
156 if( tokens.size() - 1 >= 4 + attribIndex )
158 attribs->push_back( string_utils::fromString< double >( tokens[ 4 + attribIndex ] ) );
162 attribs->push_back( 0.5 );
169 vertices->push_back( coord.
x() );
170 vertices->push_back( coord.
y() );
171 vertices->push_back( coord.
z() );
172 verticesReverse->push_back( currentLineCount );
180 if( ( tokens.size() == 1 ) && ( tokens[ 0 ] ==
"n" ) )
183 lineStartIndices->push_back( currentStartIndex );
185 lengths->push_back( currentLength );
187 currentStartIndex = currentIndex;
195 debugLog() <<
" = Num Lines: " << currentLineCount;
196 debugLog() <<
" = Num Vertices: " << currentIndex;
void expandBy(const WBoundingBoxImpl< VT > &bb)
Expands this bounding box to include the given bounding box.
virtual void wait() const
Wait for the condition.
virtual void add(std::shared_ptr< WCondition > condition)
Adds another condition to the set of conditions to wait for.
Class to encapsulate boost::condition_variable_any.
Represents a simple set of WFibers.
std::shared_ptr< std::vector< size_t > > IndexArray
Index list indexing fibers in VertexArray in terms of vertex numbers.
std::shared_ptr< std::vector< size_t > > LengthArray
Lengths of fibers in terms of vertices.
std::shared_ptr< WDataSetFibers > SPtr
Pointer to dataset.
std::shared_ptr< std::vector< double > > VertexParemeterArray
Parameter storage for each vertex.
std::shared_ptr< std::vector< float > > VertexArray
List of vertex coordinates in term of components of vertices.
A module to read VCL line data.
WPropFilename m_dataFile
The data will be read from this file.
virtual void moduleMain()
Entry point after loading the module.
virtual const std::string getName() const
Gives back the name of this module.
virtual void connectors()
Initialize the connectors this module is using.
virtual ~WMReadVCL()
Destructor of module.
virtual void properties()
Initialize the properties for this module.
WPropInt m_attrib
The index of the attribute to use.
WPropBool m_loadAttrib
Load additional attribute.
virtual const std::string getDescription() const
Gives back a description of this module.
std::shared_ptr< WDataSetFibers > m_dataSet
This data set is provided as output through the connector.
WPropTrigger m_readTriggerProp
The trigger for loading.
WMReadVCL()
Constructor of module.
std::shared_ptr< WModuleOutputData< WDataSetFibers > > m_output
Output connector provided by this module.
std::shared_ptr< WCondition > m_propCondition
A condition used to notify about changes in several properties.
void readData(std::string filename)
Read VCL 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...
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.
static PtrType createAndAdd(std::shared_ptr< WModule > module, std::string name="", std::string description="")
Convenience method to create a new instance of this out data connector with proper type and add it to...
Class representing a single module of OpenWalnut.
virtual void properties()
Initialize properties in this function.
wlog::WStreamedLogger debugLog() const
Logger instance for comfortable debug logging.
std::shared_ptr< WProperties > m_properties
The property object for the module.
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.
virtual void connectors()
Initialize connectors in this function.
static boost::filesystem::path getAppPath()
The path where the binary file resides in.
Class managing progress inside of modules.
WBoolFlag m_shutdownFlag
Condition getting fired whenever the thread should quit.
@ PV_TRIGGER_READY
Trigger property: is ready to be triggered (again)
void addTo(WPropFilename prop)
Add the PC_PATHEXISTS constraint to the property.
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).