Commit 10268cca authored by Michael Turner's avatar Michael Turner
Browse files

add new parseutil and fix

parent cf5a8ed4
......@@ -64,7 +64,7 @@ namespace Nektar
{
SymbolFunctor symbolFunctor(&symbol);
ValueFunctor valueFunctor(&value);
return parse(str,
// Begin grammar
(
......@@ -93,7 +93,7 @@ namespace Nektar
space_p).full;
}
static bool GenerateOrderedVector(const char *const str, std::vector<unsigned int> &vec)
{
// Functors used to parse the sequence.
......@@ -114,7 +114,7 @@ namespace Nektar
{
// Functors used to parse the sequence.
fctor4 functor4(&vec);
return parse(str,
// Begin grammar
(
......@@ -124,12 +124,12 @@ namespace Nektar
// End grammar
space_p).full;
}
static bool GenerateUnOrderedVector(const char *const str, std::vector<NekDouble> &vec)
{
// Functors used to parse the sequence.
fctor5 functor5(&vec);
return parse(str,
// Begin grammar
(
......@@ -139,7 +139,22 @@ namespace Nektar
// End grammar
space_p).full;
}
static bool GenerateUnOrderedVector(const char *const str, std::vector<unsigned int> &vec)
{
// Functors used to parse the sequence.
fctor6 functor6(&vec);
return parse(str,
// Begin grammar
(
uint_p[functor6] >> *(',' >> uint_p[functor6])
)
,
// End grammar
space_p).full;
}
static bool GenerateOrderedStringVector(const char *const str, std::vector<std::string> &vec)
{
// Functors used to parse the sequence.
......@@ -226,7 +241,7 @@ namespace Nektar
m_value(value)
{
}
void operator()(NekDouble val) const
{
*m_value = val;
......@@ -245,7 +260,7 @@ namespace Nektar
void operator()(unsigned int n) const
{
#ifdef NOTREQUIRED //SJS: I do not think we need this check
#ifdef NOTREQUIRED //SJS: I do not think we need this check
if (!m_vector->empty())
{
unsigned int prevElem = m_vector->back();
......@@ -304,7 +319,7 @@ namespace Nektar
std::vector<std::string> *m_vector;
};
// Probably should template fctor1 if that is possible?
// Probably should template fctor1 if that is possible?
struct fctor4
{
fctor4(std::vector<NekDouble> *vec):
......@@ -333,24 +348,41 @@ namespace Nektar
std::vector<NekDouble> *m_vector;
fctor4();
};
struct fctor5
{
fctor5(std::vector<NekDouble> *vec):
m_vector(vec)
{
}
void operator()(NekDouble n) const
{
m_vector->push_back(n);
}
private:
std::vector<NekDouble> *m_vector;
fctor5();
};
struct fctor6
{
fctor6(std::vector<unsigned int> *vec):
m_vector(vec)
{
}
void operator()(unsigned int n) const
{
m_vector->push_back(n);
}
private:
std::vector<unsigned int> *m_vector;
fctor6();
};
};
}
......
......@@ -445,7 +445,6 @@ TopoDS_Shape CADSystemOCE::BuildGeo(string geo)
boost::erase_all(tmp1[1], "{");
boost::erase_all(tmp1[1], "}");
boost::erase_all(tmp1[1], ";");
boost::erase_all(tmp1[1], "-");
string var = tmp1[1];
......@@ -492,22 +491,22 @@ TopoDS_Shape CADSystemOCE::BuildGeo(string geo)
map<int, TopoDS_Edge> cEdges;
for (it = lines.begin(); it != lines.end(); it++)
{
vector<NekDouble> data;
vector<unsigned int> data;
ParseUtils::GenerateUnOrderedVector(it->second.c_str(), data);
BRepBuilderAPI_MakeEdge em(cPoints[(int)data[0]],
cPoints[(int)data[1]]);
BRepBuilderAPI_MakeEdge em(cPoints[data[0]],
cPoints[data[1]]);
cEdges[it->first] = em.Edge();
}
for (it = splines.begin(); it != splines.end(); it++)
{
vector<NekDouble> data;
vector<unsigned int> data;
ParseUtils::GenerateUnOrderedVector(it->second.c_str(), data);
TColgp_Array1OfPnt pointArray(0, data.size() - 1);
for (int i = 0; i < data.size(); i++)
{
pointArray.SetValue(i, cPoints[(int)data[i]]);
pointArray.SetValue(i, cPoints[data[i]]);
}
GeomAPI_PointsToBSpline spline(pointArray);
Handle(Geom_BSplineCurve) curve = spline.Curve();
......@@ -520,12 +519,12 @@ TopoDS_Shape CADSystemOCE::BuildGeo(string geo)
map<int, TopoDS_Wire> cWires;
for (it = loops.begin(); it != loops.end(); it++)
{
vector<NekDouble> data;
vector<unsigned int> data;
ParseUtils::GenerateUnOrderedVector(it->second.c_str(), data);
BRepBuilderAPI_MakeWire wm;
for (int i = 0; i < data.size(); i++)
{
wm.Add(cEdges[(int)data[i]]);
wm.Add(cEdges[data[i]]);
}
cWires[it->first] = wm.Wire();
}
......@@ -534,12 +533,12 @@ TopoDS_Shape CADSystemOCE::BuildGeo(string geo)
// also going to assume that the first loop in the list is the outer domain
ASSERTL0(surfs.size() == 1, "more than 1 surf");
it = surfs.begin();
vector<NekDouble> data;
vector<unsigned int> data;
ParseUtils::GenerateUnOrderedVector(it->second.c_str(), data);
BRepBuilderAPI_MakeFace face(cWires[(int)data[0]], true);
BRepBuilderAPI_MakeFace face(cWires[data[0]], true);
for (int i = 1; i < data.size(); i++)
{
face.Add(cWires[(int)data[i]]);
face.Add(cWires[data[i]]);
}
ASSERTL0(face.Error() == BRepBuilderAPI_FaceDone, "build geo failed");
......
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