Commit 3470e341 authored by David Moxey's avatar David Moxey

Remove a couple of flags with use of a configuration map in the CAD system.

parent 63c0ec12
......@@ -88,24 +88,51 @@ public:
return m_name;
}
/**
* @brief Set the CAD engine up to handle 2D geometries explicitly.
*/
void Set2D()
{
m_2d = true;
}
/**
* @brief Returns whether the CAD engine is set in 2D mode.
*/
bool Is2D()
{
return m_2d;
}
void SetNACA(std::string i)
/**
* @brief Gets a configuration option.
*
* @param key Configuration key.
*
* @return The configuration value.
*/
const std::string &GetConfig(const std::string &key) const
{
return m_config[key];
}
/**
* @brief Sets a configuration option @p key to @p value.
*
* @param key Configuration key.
* @param value The configuration value.
*/
void &GetConfig(const std::string &key, const std::string &value)
{
m_naca = i;
m_config[key] = value;
}
void SetVerbose()
/**
* @brief Sets the verbose flag for additional output.
*/
void SetVerbose(bool verbose = true)
{
m_verbose = true;
m_verbose = verbose;
}
/**
......@@ -175,7 +202,7 @@ public:
}
/**
* @brief Gets map of all vertices
* @brief Gets map of all vertices.
*/
std::map<int, CADVertSharedPtr> GetVerts()
{
......@@ -185,7 +212,7 @@ public:
/**
* @brief Gets number of vertices
*/
int GetNumVerts()
int GetNumVerts() const
{
return m_verts.size();
}
......@@ -221,8 +248,9 @@ protected:
bool m_verbose = false;
/// 2D cad flag
bool m_2d = false;
/// string of 4 digit NACA code to be created
std::string m_naca;
/// Configuration options which might be used per-engine, serialised in
/// strings.
std::map<std::string, std::string> m_config;
/**
* @brief Reports basic properties to screen.
......
......@@ -65,7 +65,7 @@ Array<OneD, NekDouble> CADSurfCFI::GetBounds()
}
void CADSurfCFI::GetBounds(NekDouble &umin, NekDouble &umax,
NekDouble &vmin, NekDouble &vmax)
NekDouble &vmin, NekDouble &vmax)
{
cfi::UVBox bx = m_cfiSurface->calcUVBox();
umin = bx.uLower;
......
......@@ -37,6 +37,8 @@
#include "CADSurfCFI.h"
#include "CADVertCFI.h"
#include <boost/lexical_cast.hpp>
using namespace std;
namespace Nektar
......@@ -51,27 +53,27 @@ bool CADSystemCFI::LoadCAD()
{
// it is possible to get CFI to lock on to a open gui session
// not sure it ever will with this code
cfiHandel.startServer();
m_cfiHandle.startServer();
if (m_verbose)
{
cout << "cfi loaded in mode: ";
if (cfiHandel.info.mode == cfi::MODE_STANDALONE)
if (m_cfiHandle.info.mode == cfi::MODE_STANDALONE)
{
cout << "standalone" << endl;
}
else if (cfiHandel.info.mode == cfi::MODE_CLIENT)
else if (m_cfiHandle.info.mode == cfi::MODE_CLIENT)
{
cout << "client" << endl;
}
else if (cfiHandel.info.mode == cfi::MODE_SERVER)
else if (m_cfiHandle.info.mode == cfi::MODE_SERVER)
{
cout << "server" << endl;
}
else if (cfiHandel.info.mode == cfi::MODE_BOTH)
else if (m_cfiHandle.info.mode == cfi::MODE_BOTH)
{
cout << "both" << endl;
}
else if (cfiHandel.info.mode == cfi::MODE_PLUGIN)
else if (m_cfiHandle.info.mode == cfi::MODE_PLUGIN)
{
cout << "plugin" << endl;
}
......@@ -80,16 +82,21 @@ bool CADSystemCFI::LoadCAD()
cout << "unknown" << endl;
}
cout << "\tVersion " << cfiHandel.info.version << endl
<< "\tfixno " << cfiHandel.info.fixno << endl
<< "\tubid " << cfiHandel.info.ubid << endl;
cout << "\tVersion " << m_cfiHandle.info.version << endl
<< "\tfixno " << m_cfiHandle.info.fixno << endl
<< "\tubid " << m_cfiHandle.info.ubid << endl;
}
if (m_config["UseCFIMesh"].count())
{
m_useCFImesh = boost::lexical_cast<bool>(m_config["UseCFIMesh"]);
}
model = cfiHandel.openModelFile(m_name.c_str());
m_model = m_cfiHandle.openModelFile(m_name.c_str());
if (model->getEntityTotal(cfi::TYPE_BODY, cfi::SUBTYPE_ALL) != 1)
if (m_model->getEntityTotal(cfi::TYPE_BODY, cfi::SUBTYPE_ALL) != 1)
{
if (m_useCFIMesh)
if (m_config["UseCFIMesh"].count())
{
if (m_verbose)
{
......@@ -101,21 +108,19 @@ bool CADSystemCFI::LoadCAD()
if (m_verbose)
{
cout << "\tHas multibodies and instructions to mesh, this is "
"not "
"possible"
<< endl;
"not possible" << endl;
}
abort();
}
}
vector<cfi::Entity *> *bds =
model->getEntityList(cfi::TYPE_BODY, cfi::SUBTYPE_ALL);
m_model->getEntityList(cfi::TYPE_BODY, cfi::SUBTYPE_ALL);
for (auto &i : *bds)
{
cfi::Body *b = static_cast<cfi::Body *>(i);
bodies.push_back(b);
m_bodies.push_back(b);
}
// cfi doesnt mind stupid units so this scales everything back to meters
......@@ -123,7 +128,7 @@ bool CADSystemCFI::LoadCAD()
// the m_scal object is passed to all cad entities and scales any operation
// before running it.
m_scal = 1.0;
if (model->getUnits() == cfi::UNIT_INCHES)
if (m_model->getUnits() == cfi::UNIT_INCHES)
{
if (m_verbose)
{
......@@ -131,8 +136,8 @@ bool CADSystemCFI::LoadCAD()
}
m_scal = 0.0254;
}
else if (model->getUnits() == cfi::UNIT_MILLIMETERS ||
model->getUnits() == cfi::UNIT_MILLIMETRES)
else if (m_model->getUnits() == cfi::UNIT_MILLIMETERS ||
m_model->getUnits() == cfi::UNIT_MILLIMETRES)
{
if (m_verbose)
{
......@@ -153,16 +158,16 @@ bool CADSystemCFI::LoadCAD()
// cad by cascading down from the faces
// also builds a list on unique edges in the process
for (int i = 0; i < bodies.size(); i++)
for (int i = 0; i < m_bodies.size(); i++)
{
// check that it is not a group of bodies
if (bodies[i]->getTopoSubtype() == cfi::SUBTYPE_COMBINED)
if (m_bodies[i]->getTopoSubtype() == cfi::SUBTYPE_COMBINED)
{
continue;
}
vector<cfi::Oriented<cfi::TopoEntity *>> *faceList =
bodies[i]->getChildList();
m_bodies[i]->getChildList();
vector<cfi::Oriented<cfi::TopoEntity *>>::iterator it, it2, it3;
for (it = faceList->begin(); it != faceList->end(); it++)
......@@ -225,7 +230,7 @@ bool CADSystemCFI::LoadCAD()
cfi::Point *vert =
static_cast<cfi::Point *>(orientatedVert.entity);
mapOfVerts[vert->getName()] = vert;
mapVertToListEdge[vert->getName()].push_back(
m_mapVertToListEdge[vert->getName()].push_back(
edge->getName());
}
}
......@@ -241,7 +246,7 @@ bool CADSystemCFI::LoadCAD()
for (vit = mapOfVerts.begin(); vit != mapOfVerts.end(); vit++, i++)
{
AddVert(i, vit->second);
nameToVertId[vit->second->getName()] = i;
m_nameToVertId[vit->second->getName()] = i;
}
// build curves
......@@ -250,7 +255,7 @@ bool CADSystemCFI::LoadCAD()
for (eit = mapOfEdges.begin(); eit != mapOfEdges.end(); eit++, i++)
{
AddCurve(i, eit->second);
nameToCurveId[eit->second->getName()] = i;
m_nameToCurveId[eit->second->getName()] = i;
}
// build surfaces
......@@ -258,7 +263,7 @@ bool CADSystemCFI::LoadCAD()
i = 1;
for (fit = mapOfFaces.begin(); fit != mapOfFaces.end(); fit++, i++)
{
nameToFaceId[fit->second->getName()] = i;
m_nameToFaceId[fit->second->getName()] = i;
AddSurf(i, fit->second);
}
......@@ -316,14 +321,14 @@ void CADSystemCFI::AddCurve(int i, cfi::Line *in)
ASSERTL0(t[0] < t[1], "weirdness");
vector<CADVertSharedPtr> vs;
vs.push_back(m_verts[nameToVertId[vertList->at(0).entity->getName()]]);
vs.push_back(m_verts[nameToVertId[vertList->at(1).entity->getName()]]);
vs.push_back(m_verts[m_nameToVertId[vertList->at(0).entity->getName()]]);
vs.push_back(m_verts[m_nameToVertId[vertList->at(1).entity->getName()]]);
m_curves[i] = newCurve;
m_curves[i]->SetVert(vs);
m_curves[i]->SetName(in->getName());
m_verts[nameToVertId[vertList->at(0).entity->getName()]]->AddAdjCurve(
m_verts[m_nameToVertId[vertList->at(0).entity->getName()]]->AddAdjCurve(
m_curves[i]);
m_verts[nameToVertId[vertList->at(1).entity->getName()]]->AddAdjCurve(
m_verts[m_nameToVertId[vertList->at(1).entity->getName()]]->AddAdjCurve(
m_curves[i]);
}
......@@ -384,7 +389,7 @@ void CADSystemCFI::AddSurf(int i, cfi::Face *in)
}
edgeloop->edges.push_back(
m_curves[nameToCurveId[fullEdgeList.at(done).entity->getName()]]);
m_curves[m_nameToCurveId[fullEdgeList.at(done).entity->getName()]]);
for (done++; done < fullEdgeList.size(); done++)
{
......@@ -408,7 +413,8 @@ void CADSystemCFI::AddSurf(int i, cfi::Face *in)
}
edgeloop->edges.push_back(
m_curves[nameToCurveId[fullEdgeList.at(done).entity->getName()]]);
m_curves[m_nameToCurveId[
fullEdgeList.at(done).entity->getName()]]);
if (end)
{
......@@ -448,7 +454,7 @@ void CADSystemCFI::AddSurf(int i, cfi::Face *in)
Array<OneD, NekDouble> CADSystemCFI::GetBoundingBox()
{
cfi::BoundingBox box = model->calcBoundingBox();
cfi::BoundingBox box = m_model->calcBoundingBox();
Array<OneD, NekDouble> ret(6);
ret[0] = box.xLower;
......
......@@ -95,13 +95,14 @@ private:
void AddVert(int i, cfi::Point *in);
void AddCurve(int i, cfi::Line *in);
void AddSurf(int i, cfi::Face *in);
cfi::Cfi cfiHandel;
cfi::Model *model;
std::vector<cfi::Body* >bodies;
std::map<std::string, int> nameToVertId;
std::map<std::string, int> nameToCurveId;
std::map<std::string, int> nameToFaceId;
std::map<std::string, std::vector<std::string> > mapVertToListEdge;
cfi::Cfi m_cfiHandle;
cfi::Model *m_model;
std::vector<cfi::Body* > m_bodies;
std::map<std::string, int> m_nameToVertId;
std::map<std::string, int> m_nameToCurveId;
std::map<std::string, int> m_nameToFaceId;
std::map<std::string, std::vector<std::string> > m_mapVertToListEdge;
NekDouble m_scal;
bool m_useCFIMesh = false;
};
......
......@@ -77,7 +77,7 @@ bool CADSystemOCE::LoadCAD()
bool fromStep = false;
if (m_naca.size() == 0)
if (m_config["UseNACA"].count())
{
// not a naca profile behave normally
// could be a geo
......
......@@ -78,17 +78,18 @@ void ProcessLoadCAD::Process()
string ext = boost::filesystem::extension(name);
if(boost::iequals(ext,".fbm"))
if (boost::iequals(ext, ".fbm"))
{
m_mesh->m_cad = GetEngineFactory().CreateInstance("cfi",name);
if (m_config["usecfimesh"].beenSet)
{
std::dynamic_pointer_cast<CADSystemCFI>(m_mesh->m_cad)->UseCFIMesh();
m_mesh->m_cad->SetConfig("UseCFIMesh", "1");
}
}
else
{
m_mesh->m_cad = GetEngineFactory().CreateInstance("oce",name);
m_mesh->m_cad = GetEngineFactory().CreateInstance("oce", name);
}
if(m_config["2D"].beenSet)
......@@ -98,7 +99,7 @@ void ProcessLoadCAD::Process()
if(m_config["NACA"].beenSet)
{
m_mesh->m_cad->SetNACA(m_config["NACA"].as<string>());
m_mesh->m_cad->SetConfig("UseNACA", m_config["NACA"].as<std::string>());
}
if(m_config["verbose"].beenSet)
......
......@@ -79,7 +79,7 @@ void InputCADfix::Process()
}
// Set CFI mesh flag so that we always use the mesh from the CFI file.
module->RegisterConfig("usecfimesh, "");
module->RegisterConfig("usecfimesh", "");
module->SetDefaults();
module->Process();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment