Nektar++
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
Public Member Functions | Static Public Member Functions | Static Public Attributes | List of all members
Nektar::Utilities::OutputSTL Class Reference

#include <OutputSTL.h>

Inheritance diagram for Nektar::Utilities::OutputSTL:
Inheritance graph
[legend]
Collaboration diagram for Nektar::Utilities::OutputSTL:
Collaboration graph
[legend]

Public Member Functions

 OutputSTL (NekMeshUtils::MeshSharedPtr m)
 
virtual ~OutputSTL ()
 
virtual void Process ()
 Write mesh to output file. More...
 
- Public Member Functions inherited from Nektar::NekMeshUtils::OutputModule
NEKMESHUTILS_EXPORT OutputModule (MeshSharedPtr p_m)
 
NEKMESHUTILS_EXPORT void OpenStream ()
 Open a file for output. More...
 
- Public Member Functions inherited from Nektar::NekMeshUtils::Module
NEKMESHUTILS_EXPORT Module (MeshSharedPtr p_m)
 
NEKMESHUTILS_EXPORT void RegisterConfig (std::string key, std::string value)
 Register a configuration option with a module. More...
 
NEKMESHUTILS_EXPORT void PrintConfig ()
 Print out all configuration options for a module. More...
 
NEKMESHUTILS_EXPORT void SetDefaults ()
 Sets default configuration options for those which have not been set. More...
 
NEKMESHUTILS_EXPORT MeshSharedPtr GetMesh ()
 
virtual NEKMESHUTILS_EXPORT void ProcessVertices ()
 Extract element vertices. More...
 
virtual NEKMESHUTILS_EXPORT void ProcessEdges (bool ReprocessEdges=true)
 Extract element edges. More...
 
virtual NEKMESHUTILS_EXPORT void ProcessFaces (bool ReprocessFaces=true)
 Extract element faces. More...
 
virtual NEKMESHUTILS_EXPORT void ProcessElements ()
 Generate element IDs. More...
 
virtual NEKMESHUTILS_EXPORT void ProcessComposites ()
 Generate composites. More...
 
virtual NEKMESHUTILS_EXPORT void ClearElementLinks ()
 

Static Public Member Functions

static boost::shared_ptr< Modulecreate (NekMeshUtils::MeshSharedPtr m)
 Creates an instance of this class. More...
 

Static Public Attributes

static NekMeshUtils::ModuleKey className
 

Additional Inherited Members

- Protected Member Functions inherited from Nektar::NekMeshUtils::Module
NEKMESHUTILS_EXPORT void ReorderPrisms (PerMap &perFaces)
 Reorder node IDs so that prisms and tetrahedra are aligned correctly. More...
 
NEKMESHUTILS_EXPORT void PrismLines (int prism, PerMap &perFaces, std::set< int > &prismsDone, std::vector< ElementSharedPtr > &line)
 
- Protected Attributes inherited from Nektar::NekMeshUtils::OutputModule
io::filtering_ostream m_mshFile
 Output stream. More...
 
std::ofstream m_mshFileStream
 Input stream. More...
 
- Protected Attributes inherited from Nektar::NekMeshUtils::Module
MeshSharedPtr m_mesh
 Mesh object. More...
 
std::map< std::string,
ConfigOption
m_config
 List of configuration values. More...
 

Detailed Description

Definition at line 46 of file OutputSTL.h.

Constructor & Destructor Documentation

Nektar::Utilities::OutputSTL::OutputSTL ( NekMeshUtils::MeshSharedPtr  m)

Definition at line 51 of file OutputSTL.cpp.

51  : OutputModule(m)
52 {
53 }
NEKMESHUTILS_EXPORT OutputModule(MeshSharedPtr p_m)
Nektar::Utilities::OutputSTL::~OutputSTL ( )
virtual

Definition at line 55 of file OutputSTL.cpp.

56 {
57 }

Member Function Documentation

static boost::shared_ptr<Module> Nektar::Utilities::OutputSTL::create ( NekMeshUtils::MeshSharedPtr  m)
inlinestatic

Creates an instance of this class.

Definition at line 50 of file OutputSTL.h.

References Nektar::MemoryManager< DataType >::AllocateSharedPtr().

51  {
53  }
static boost::shared_ptr< DataType > AllocateSharedPtr()
Allocate a shared pointer from the memory pool.
void Nektar::Utilities::OutputSTL::Process ( )
virtual

Write mesh to output file.

Implements Nektar::NekMeshUtils::Module.

Definition at line 59 of file OutputSTL.cpp.

References ASSERTL0, Nektar::iterator, Nektar::NekMeshUtils::Module::m_mesh, Nektar::NekMeshUtils::OutputModule::m_mshFile, and Nektar::NekMeshUtils::OutputModule::OpenStream().

60 {
61  if (m_mesh->m_verbose)
62  {
63  cout << "Outputstl: Writing file..." << endl;
64  }
65 
66  ASSERTL0(m_mesh->m_expDim == 3, "3d meshes only");
67 
68  OpenStream();
69 
70  m_mshFile << std::scientific << setprecision(8);
71 
73 
74  for (it = m_mesh->m_composite.begin(); it != m_mesh->m_composite.end();
75  ++it)
76  {
77  if (it->second->m_tag != "F")
78  {
79  continue;
80  }
81 
82  m_mshFile << "solid comp:" << it->second->m_id << endl;
83 
84  vector<ElementSharedPtr> el = it->second->m_items;
85 
86  for (int i = 0; i < el.size(); i++)
87  {
88  vector<NodeSharedPtr> ns = el[i]->GetVertexList();
89 
90  Array<OneD, NekDouble> tmp(3, 0.0);
91  tmp[0] = (ns[1]->m_y - ns[0]->m_y) * (ns[2]->m_z - ns[0]->m_z) -
92  (ns[1]->m_z - ns[0]->m_z) * (ns[2]->m_y - ns[0]->m_y);
93  tmp[1] = (ns[1]->m_z - ns[0]->m_z) * (ns[2]->m_x - ns[0]->m_x) -
94  (ns[1]->m_x - ns[0]->m_x) * (ns[2]->m_z - ns[0]->m_z);
95  tmp[2] = (ns[1]->m_x - ns[0]->m_x) * (ns[2]->m_y - ns[0]->m_y) -
96  (ns[1]->m_y - ns[0]->m_y) * (ns[2]->m_x - ns[0]->m_x);
97 
98  NekDouble mt = tmp[0] * tmp[0] + tmp[1] * tmp[1] + tmp[2] * tmp[2];
99  mt = sqrt(mt);
100  tmp[0] /= mt;
101  tmp[1] /= mt;
102  tmp[2] /= mt;
103 
104  m_mshFile << "facet normal " << tmp[0] << " " << tmp[1] << " "
105  << endl;
106  m_mshFile << "outer loop" << endl;
107  for (int j = 0; j < ns.size(); j++)
108  {
109  m_mshFile << "vertex " << ns[j]->m_x << " " << ns[j]->m_y << " "
110  << ns[j]->m_z << endl;
111  }
112  m_mshFile << "endloop" << endl << "endfacet" << endl;
113  }
114  m_mshFile << "endsolid" << endl;
115  }
116 }
#define ASSERTL0(condition, msg)
Definition: ErrorUtil.hpp:198
io::filtering_ostream m_mshFile
Output stream.
NEKMESHUTILS_EXPORT void OpenStream()
Open a file for output.
double NekDouble
StandardMatrixTag boost::call_traits< LhsDataType >::const_reference rhs typedef NekMatrix< LhsDataType, StandardMatrixTag >::iterator iterator

Member Data Documentation

ModuleKey Nektar::Utilities::OutputSTL::className
static
Initial value:

Definition at line 54 of file OutputSTL.h.