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

Converter for Ply files. More...

#include <InputPly.h>

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

Public Member Functions

 InputPly (MeshSharedPtr m)
virtual ~InputPly ()
virtual void Process ()
 Populate and validate required data structures.
void ReadPly (std::ifstream &mshFile, NekDouble scale=1.0)
- Public Member Functions inherited from Nektar::Utilities::InputModule
 InputModule (FieldSharedPtr p_m)
void AddFile (string fileType, string fileName)
 InputModule (MeshSharedPtr p_m)
void OpenStream ()
 Open a file for input.
- Public Member Functions inherited from Nektar::Utilities::Module
 Module (FieldSharedPtr p_f)
virtual void Process (po::variables_map &vm)=0
void RegisterConfig (string key, string value)
 Register a configuration option with a module.
void PrintConfig ()
 Print out all configuration options for a module.
void SetDefaults ()
 Sets default configuration options for those which have not been set.
bool GetRequireEquiSpaced (void)
void SetRequireEquiSpaced (bool pVal)
void EvaluateTriFieldAtEquiSpacedPts (LocalRegions::ExpansionSharedPtr &exp, const Array< OneD, const NekDouble > &infield, Array< OneD, NekDouble > &outfield)
 Module (MeshSharedPtr p_m)
void RegisterConfig (string key, string value)
void PrintConfig ()
void SetDefaults ()
MeshSharedPtr GetMesh ()
virtual void ProcessVertices ()
 Extract element vertices.

Static Public Member Functions

static ModuleSharedPtr create (MeshSharedPtr m)
 Creates an instance of this class.

Static Public Attributes

static ModuleKey className

Additional Inherited Members

- Protected Member Functions inherited from Nektar::Utilities::InputModule
void PrintSummary ()
 Print summary of elements.
void PrintSummary ()
 Print summary of elements.
- Protected Attributes inherited from Nektar::Utilities::InputModule
set< string > m_allowedFiles
std::ifstream m_mshFile
 Input stream.

Detailed Description

Converter for Ply files.

Definition at line 46 of file InputPly.h.

Constructor & Destructor Documentation

Nektar::Utilities::InputPly::InputPly ( MeshSharedPtr  m)

Definition at line 52 of file InputPly.cpp.

{
}
Nektar::Utilities::InputPly::~InputPly ( )
virtual

Definition at line 57 of file InputPly.cpp.

{
}

Member Function Documentation

static ModuleSharedPtr Nektar::Utilities::InputPly::create ( MeshSharedPtr  m)
inlinestatic

Creates an instance of this class.

Definition at line 50 of file InputPly.h.

{
return MemoryManager<InputPly>::AllocateSharedPtr(m);
}
void Nektar::Utilities::InputPly::Process ( )
virtual
void Nektar::Utilities::InputPly::ReadPly ( std::ifstream &  mshFile,
NekDouble  scale = 1.0 
)

Definition at line 84 of file InputPly.cpp.

References Nektar::LibUtilities::eTriangle, Nektar::Utilities::GetElementFactory(), and Nektar::Utilities::Module::m_mesh.

Referenced by Process().

{
m_mesh->m_expDim = 0;
string line;
int nVertices = 0;
int nEntities = 0;
int nProperties = 0;
map<string, int> propMap;
if (m_mesh->m_verbose)
{
cout << "InputPly: Start reading file..." << endl;
}
while (!mshFile.eof())
{
getline(mshFile, line);
stringstream s(line);
string word;
s >> word;
if (word == "element")
{
s >> word;
if (word == "vertex")
{
s >> nVertices;
}
else if (word == "face")
{
s >> nEntities;
}
continue;
}
else if (word == "property")
{
s >> word >> word;
propMap[word] = nProperties++;
}
else if (word == "end_header")
{
// Read nodes
vector<double> data(nProperties);
for (int i = 0; i < nVertices; ++i)
{
getline(mshFile, line);
stringstream st(line);
for (int j = 0; j < nProperties; ++j)
{
st >> data[j];
}
double x = data[propMap["x"]];
double y = data[propMap["y"]];
double z = data[propMap["z"]];
if ((y * y) > 0.000001 && m_mesh->m_spaceDim != 3)
{
m_mesh->m_spaceDim = 2;
}
if ((z * z) > 0.000001)
{
m_mesh->m_spaceDim = 3;
}
x *= scale;
y *= scale;
z *= scale;
m_mesh->m_node.push_back(
boost::shared_ptr<Node>(new Node(i, x, y, z)));
// Read vertex normals.
if (propMap.count("nx") > 0)
{
double nx = data[propMap["nx"]];
double ny = data[propMap["ny"]];
double nz = data[propMap["nz"]];
m_mesh->m_vertexNormals[i] = Node(0, nx, ny, nz);
}
}
// Read elements
for (int i = 0; i < nEntities; ++i)
{
getline(mshFile, line);
stringstream st(line);
int id = 0;
// Create element tags
vector<int> tags;
tags.push_back(0); // composite
// Read element node list
st >> id;
vector<NodeSharedPtr> nodeList;
for (int k = 0; k < 3; ++k)
{
int node = 0;
st >> node;
nodeList.push_back(m_mesh->m_node[node]);
}
// Create element
ElmtConfig conf(elType,1,false,false);
CreateInstance(elType,conf,nodeList,tags);
// Determine mesh expansion dimension
if (E->GetDim() > m_mesh->m_expDim)
{
m_mesh->m_expDim = E->GetDim();
}
m_mesh->m_element[E->GetDim()].push_back(E);
}
}
}
}

Member Data Documentation

ModuleKey Nektar::Utilities::InputPly::className
static
Initial value:
"Reads ply triangulation format.")

Definition at line 53 of file InputPly.h.