Commit 9d2e8367 authored by mike turner's avatar mike turner
Browse files

more updates

parent c9c2c2c2
......@@ -139,7 +139,7 @@ void Generator2D::Process()
////////////////////////////////////
EdgeSet::iterator it;
/*EdgeSet::iterator it;
for (it = m_mesh->m_edgeSet.begin(); it != m_mesh->m_edgeSet.end(); it++)
{
vector<NodeSharedPtr> ns;
......@@ -159,7 +159,7 @@ void Generator2D::Process()
LibUtilities::eSegment, conf, ns, tags);
m_mesh->m_element[1].push_back(E2);
}
}*/
ProcessVertices();
ProcessEdges();
......@@ -219,11 +219,6 @@ void Generator2D::MakeBL(int faceid)
Array<OneD, NekDouble> n(2);
n[0] = p2[1] - p1[1];
n[1] = p1[0] - p2[0];
if(m_mesh->m_cad->GetSurf(faceid)->IsReversedNormal())
{
n[0] *= -1.0;
n[1] *= -1.0;
}
NekDouble mag = sqrt(n[0] * n[0] + n[1] * n[1]);
n[0] /= mag;
n[1] /= mag;
......
......@@ -32,7 +32,6 @@
// Description: cad object methods.
//
////////////////////////////////////////////////////////////////////////////////
#include "CADSurf.h"
#include "CADCurve.h"
......@@ -89,6 +88,8 @@ void CADSurf::OrientateEdges(CADSurfSharedPtr surf,
loopt.push_back(loop);
}
cout << surf->GetId() << endl;
for (int i = 0; i < loopt.size(); i++)
{
NekDouble area = 0.0;
......@@ -107,6 +108,8 @@ void CADSurf::OrientateEdges(CADSurfSharedPtr surf,
area = bg::area(polygon);
ein[i]->area = area;
cout << area << endl;
}
// order by absoulte area
......@@ -127,7 +130,7 @@ void CADSurf::OrientateEdges(CADSurfSharedPtr surf,
} while (ct > 0);
if (ein[0]->area < 0) // reverse the first uvLoop
/*if (ein[0]->area < 0) // reverse the first uvLoop
{
ein[0]->area *= -1.0;
reverse(ein[0]->edgeo.begin(), ein[0]->edgeo.end());
......@@ -168,7 +171,7 @@ void CADSurf::OrientateEdges(CADSurfSharedPtr surf,
}
}
}
}
}*/
//only need center points for inner loops
for(int i = 1; i < ein.size(); i++)
......
......@@ -52,10 +52,11 @@ void CADSurfOCE::Initialise(int i, TopoDS_Shape in)
m_s = BRep_Tool::Surface(TopoDS::Face(in));
//reverse the face
if(in.Orientation() == 0)
/*if(in.Orientation() == 0)
{
SetReverseNomral();
}
}*/
gp_Trsf transform;
gp_Pnt ori(0.0, 0.0, 0.0);
......@@ -66,6 +67,20 @@ void CADSurfOCE::Initialise(int i, TopoDS_Shape in)
m_occSurface = BRepAdaptor_Surface(TopoDS::Face(in));
m_correctNormal = true;
m_id = i;
Array<OneD, NekDouble> uv(2);
uv[0] = GetBounds()[0];
uv[1] = GetBounds()[2];
BRepLProp_SLProps slp(m_occSurface, 2, 1e-6);
slp.SetParameters(uv[0],uv[1]);
gp_Dir d = slp.Normal();
cout << d.X() << " " << d.Y() << " " << d.Z() << endl;
Array<OneD, NekDouble> n = N(uv);
cout << n[0] << " " << n[1] << " " << n[2] << endl;
exit(-1);
}
Array<OneD, NekDouble> CADSurfOCE::GetBounds()
......
......@@ -72,110 +72,45 @@ bool CADSystemOCE::LoadCAD()
shape = BuildNACA(m_name);
}
// faces and verts can be extracted straight from shape
TopTools_IndexedMapOfShape mapOfVerts, mapOfFaces;
TopExp::MapShapes(shape, TopAbs_VERTEX, mapOfVerts);
TopExp::MapShapes(shape, TopAbs_FACE, mapOfFaces);
// edges need to be built from loops around faces to elimiate degen and
// hanging edges
TopTools_IndexedMapOfShape mapOfEdges;
TopExp_Explorer explr;
// build map of verticies
for (int i = 1; i <= mapOfVerts.Extent(); i++)
for (explr.Init(shape, TopAbs_VERTEX); explr.More(); explr.Next())
{
TopoDS_Shape v = mapOfVerts.FindKey(i);
TopoDS_Shape v = explr.Current();
if(mapOfVerts.Contains(v))
{
continue;
}
int i = mapOfVerts.Add(v);
AddVert(i, v);
}
// For each face of the geometry, get the local edges which bound it. If
// they are valid (their type != 7), then add them to an edge map. This
// filters out the dummy edges which OCC uses.
for (int i = 1; i <= mapOfFaces.Extent(); i++)
{
TopoDS_Shape face = mapOfFaces.FindKey(i);
TopTools_IndexedMapOfShape localEdges;
TopExp::MapShapes(face, TopAbs_EDGE, localEdges);
for (int j = 1; j <= localEdges.Extent(); j++)
{
TopoDS_Shape edge = localEdges.FindKey(j);
BRepAdaptor_Curve curve = BRepAdaptor_Curve(TopoDS::Edge(edge));
if (curve.GetType() != 7)
{
if (!(mapOfEdges.Contains(edge)))
{
mapOfEdges.Add(edge);
}
}
}
}
// Adds edges to our type and map
for (int i = 1; i <= mapOfEdges.Extent(); i++)
for (explr.Init(shape, TopAbs_EDGE); explr.More(); explr.Next())
{
TopoDS_Shape edge = mapOfEdges.FindKey(i);
TopoDS_Vertex fv =
TopExp::FirstVertex(TopoDS::Edge(edge), Standard_True);
TopoDS_Vertex lv =
TopExp::LastVertex(TopoDS::Edge(edge), Standard_True);
if (edge.Orientation() == 0)
TopoDS_Shape e = explr.Current().Oriented(TopAbs_FORWARD);
if(mapOfEdges.Contains(e))
{
AddCurve(i, edge, mapOfVerts.FindIndex(fv),
mapOfVerts.FindIndex(lv));
continue;
}
else
BRepAdaptor_Curve curve = BRepAdaptor_Curve(TopoDS::Edge(e));
if (curve.GetType() != 7)
{
AddCurve(i, edge, mapOfVerts.FindIndex(lv),
mapOfVerts.FindIndex(fv));
int i = mapOfEdges.Add(e);
AddCurve(i,e);
}
}
// For each face, examine all the wires (i.e. bounding loops) and
// investigates the loop. Using this information, connectivity is determined
// and edges are associated with surfaces.
for (int i = 1; i <= mapOfFaces.Extent(); i++)
for (explr.Init(shape, TopAbs_FACE); explr.More(); explr.Next())
{
TopoDS_Shape face = mapOfFaces.FindKey(i);
TopoDS_Shape f = explr.Current().Oriented(TopAbs_FORWARD);
ASSERTL0(!mapOfFaces.Contains(f), "duplicated faces");
int i = mapOfFaces.Add(f);
TopTools_IndexedMapOfShape mapOfWires;
TopExp::MapShapes(face, TopAbs_WIRE, mapOfWires);
vector<EdgeLoopSharedPtr> edgeloops;
// now we acutally analyse the loops for cad building
for (int j = 1; j <= mapOfWires.Extent(); j++)
{
EdgeLoopSharedPtr edgeloop = EdgeLoopSharedPtr(new EdgeLoop);
TopoDS_Shape wire = mapOfWires.FindKey(j);
BRepTools_WireExplorer exp;
exp.Init(TopoDS::Wire(wire));
while (exp.More())
{
TopoDS_Shape edge = exp.Current();
if (mapOfEdges.Contains(edge))
{
int e = mapOfEdges.FindIndex(edge);
edgeloop->edges.push_back(m_curves[e]);
edgeloop->edgeo.push_back(
exp.Orientation() == TopAbs_FORWARD ? eForwards
: eBackwards);
}
exp.Next();
}
edgeloops.push_back(edgeloop);
}
AddSurf(i, face, edgeloops);
AddSurf(i, f);
}
// attempts to identify properties of the vertex on the degen edge
......@@ -227,41 +162,75 @@ void CADSystemOCE::AddVert(int i, TopoDS_Shape in)
m_verts[i] = newVert;
}
void CADSystemOCE::AddCurve(int i, TopoDS_Shape in, int fv, int lv)
void CADSystemOCE::AddCurve(int i, TopoDS_Shape in)
{
CADCurveSharedPtr newCurve = GetCADCurveFactory().CreateInstance(key);
boost::static_pointer_cast<CADCurveOCE>(newCurve)->Initialise(i, in);
TopoDS_Vertex fv = TopExp::FirstVertex(TopoDS::Edge(in));
TopoDS_Vertex lv = TopExp::LastVertex(TopoDS::Edge(in));
vector<CADVertSharedPtr> vs;
vs.push_back(m_verts[fv]);
vs.push_back(m_verts[lv]);
vs.push_back(m_verts[mapOfVerts.FindIndex(fv)]);
vs.push_back(m_verts[mapOfVerts.FindIndex(lv)]);
newCurve->SetVert(vs);
m_curves[i] = newCurve;
m_curves[i]->SetVert(vs);
}
void CADSystemOCE::AddSurf(int i, TopoDS_Shape in,
vector<EdgeLoopSharedPtr> ein)
void CADSystemOCE::AddSurf(int i, TopoDS_Shape in)
{
CADSurfSharedPtr newSurf = GetCADSurfFactory().CreateInstance(key);
boost::static_pointer_cast<CADSurfOCE>(newSurf)->Initialise(i, in);
TopTools_IndexedMapOfShape mapOfWires;
TopExp::MapShapes(in, TopAbs_WIRE, mapOfWires);
vector<EdgeLoopSharedPtr> edgeloops;
// now we acutally analyse the loops for cad building
for (int j = 1; j <= mapOfWires.Extent(); j++)
{
EdgeLoopSharedPtr edgeloop = EdgeLoopSharedPtr(new EdgeLoop);
TopoDS_Shape wire = mapOfWires.FindKey(j);
BRepTools_WireExplorer exp;
exp.Init(TopoDS::Wire(wire));
while (exp.More())
{
TopoDS_Shape edge = exp.Current();
if (mapOfEdges.Contains(edge))
{
int e = mapOfEdges.FindIndex(edge);
edgeloop->edges.push_back(m_curves[e]);
edgeloop->edgeo.push_back(
exp.Orientation() == TopAbs_FORWARD ? eForwards
: eBackwards);
}
exp.Next();
}
edgeloops.push_back(edgeloop);
}
int tote = 0;
for (int k = 0; k < ein.size(); k++)
for (int k = 0; k < edgeloops.size(); k++)
{
tote += ein[k]->edges.size();
tote += edgeloops[k]->edges.size();
}
ASSERTL0(tote != 1, "cannot handle periodic curves");
CADSurf::OrientateEdges(newSurf, ein);
newSurf->SetEdges(ein);
CADSurf::OrientateEdges(newSurf, edgeloops);
newSurf->SetEdges(edgeloops);
// now the loops are orientated, tell the curves how they are
for (int k = 0; k < ein.size(); k++)
for (int k = 0; k < edgeloops.size(); k++)
{
for (int j = 0; j < ein[k]->edges.size(); j++)
for (int j = 0; j < edgeloops[k]->edges.size(); j++)
{
ein[k]->edges[j]->SetAdjSurf(make_pair(newSurf, ein[k]->edgeo[j]));
edgeloops[k]->edges[j]->SetAdjSurf(make_pair(newSurf, edgeloops[k]->edgeo[j]));
}
}
......
......@@ -69,13 +69,14 @@ private:
/// Function to add curve to CADSystem::m_verts.
void AddVert(int i, TopoDS_Shape in);
/// Function to add curve to CADSystem::m_curves.
void AddCurve(int i, TopoDS_Shape in, int fv, int lv);
void AddCurve(int i, TopoDS_Shape in);
/// Function to add surface to CADSystem::m_surfs.
void AddSurf(int i, TopoDS_Shape in, std::vector<EdgeLoopSharedPtr> ein);
void AddSurf(int i, TopoDS_Shape in);
TopoDS_Shape BuildNACA(std::string naca);
/// OCC master object
TopoDS_Shape shape;
TopTools_IndexedMapOfShape mapOfVerts, mapOfEdges, mapOfFaces;
};
......
......@@ -69,6 +69,7 @@
#include <TopoDS_Wire.hxx>
#include <ShapeAnalysis_Surface.hxx>
#include <ShapeAnalysis_Curve.hxx>
#include <BRepLProp_SLProps.hxx>
#include <Standard_Macro.hxx>
#include <GeomAPI_PointsToBSpline.hxx>
......
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