28 #include "WMWriteAmiraMesh.h"
29 #include "core/common/datastructures/WFiber.h"
30 #include "core/kernel/WKernel.h"
35 WMWriteAmiraMesh::WMWriteAmiraMesh():
40 WMWriteAmiraMesh::~WMWriteAmiraMesh()
53 return "Write Amira Mesh";
58 return "Write AmiraMesh file format. At the moment only line sets are supported.";
73 m_savePath =
m_properties->addProperty(
"Save Path",
"Where to save the result", boost::filesystem::path(
"/no/such/file" ) );
110 boost::filesystem::path meshFile(
m_savePath->get() );
111 std::string fnPath = meshFile.string();
113 debugLog() <<
"Opening " << fnPath <<
" for writing.";
114 std::ofstream dataFile( fnPath.c_str(), std::ios_base::binary );
117 errorLog() <<
"Opening " << fnPath <<
" failed.";
127 std::size_t numPoints = fibVerts->size() / 3;
132 dataFile <<
"# AmiraMesh 3D ASCII 2.0" << std::endl << std::endl;
134 dataFile <<
"define Lines " << numPoints +
m_tractConnector->getData()->size() << std::endl;
135 dataFile <<
"nVertices " << numPoints << std::endl;
136 dataFile << std::endl;
137 dataFile <<
"Parameters {" << std::endl;
138 dataFile <<
" ContentType \"HxLineSet\"" << std::endl;
139 dataFile <<
"}" << std::endl;
140 dataFile << std::endl;
141 dataFile <<
"Lines { int LineIdx } @1" << std::endl;
142 dataFile <<
"Vertices { float[3] Coordinates } @2" << std::endl;
143 dataFile << std::endl;
144 dataFile <<
"# Data section follows" << std::endl;
145 dataFile << std::endl;
146 dataFile <<
"@1" << std::endl;
147 size_t vertCounter = 0;
149 for(
size_t vertId = 0; vertId < numPoints; ++vertId )
151 dataFile << vertId << std::endl;
153 if( vertCounter == (*fibLen)[lineId] )
157 dataFile << -1 << std::endl;
160 dataFile << std::endl;
161 dataFile <<
"@2" << std::endl;
162 for(
size_t vertId = 0; vertId < numPoints; ++vertId )
164 dataFile << (*fibVerts)[vertId*3+0] <<
" " << (*fibVerts)[vertId*3+1] <<
" " << (*fibVerts)[vertId*3+2] <<
" " << std::endl;
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.
std::shared_ptr< std::vector< size_t > > LengthArray
Lengths of fibers in terms of vertices.
std::shared_ptr< std::vector< float > > VertexArray
List of vertex coordinates in term of components of vertices.
Someone should add some documentation here.
virtual const std::string getName() const
Gives back the name of this module.
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 requirements()
Initialize requirements for this module.
WPropTrigger m_run
Button to start saving.
std::shared_ptr< WModuleInputData< const WDataSetFibers > > m_tractConnector
Input connector for writing directly tracts to a file.
void writeFile()
Writes the data to file.
virtual void connectors()
Initialize the connectors this module is using.
virtual void properties()
Initialize the properties for this module.
virtual void moduleMain()
Entry point after loading the module.
WPropFilename m_savePath
Path where tracts should be stored.
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.
virtual void connectors()
Initialize connectors in this function.
WBoolFlag m_shutdownFlag
Condition getting fired whenever the thread should quit.
@ PV_TRIGGER_TRIGGERED
Trigger property: got triggered.
@ PV_TRIGGER_READY
Trigger property: is ready to be triggered (again)
void addTo(WPropSelection prop)
Add the PC_NOTEMPTY constraint to the property.