Skip to content
Snippets Groups Projects
Commit cac5a4dc authored by Michael Turner's avatar Michael Turner
Browse files

think 2d is fixed

parent 9d2e8367
No related branches found
No related tags found
No related merge requests found
......@@ -217,8 +217,12 @@ void Generator2D::MakeBL(int faceid)
swap(p1, p2);
}
Array<OneD, NekDouble> n(2);
n[0] = p2[1] - p1[1];
n[1] = p1[0] - p2[0];
n[0] = p1[1] - p2[1];
n[1] = p2[0] - p1[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;
......
......@@ -52,11 +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() == 1)
{
SetReverseNomral();
}*/
}
gp_Trsf transform;
gp_Pnt ori(0.0, 0.0, 0.0);
......@@ -71,16 +71,6 @@ void CADSurfOCE::Initialise(int i, TopoDS_Shape in)
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()
......@@ -273,32 +263,27 @@ Array<OneD, NekDouble> CADSurfOCE::N(Array<OneD, NekDouble> uv)
Test(uv);
#endif
Array<OneD, NekDouble> normal(3);
gp_Pnt Loc;
gp_Vec D1U, D1V;
m_occSurface.D1(uv[0], uv[1], Loc, D1U, D1V);
gp_Vec n = D1U.Crossed(D1V);
BRepLProp_SLProps slp(m_occSurface, 2, 1e-6);
slp.SetParameters(uv[0],uv[1]);
if (!m_correctNormal)
if(!slp.IsNormalDefined())
{
n.Reverse();
return Array<OneD, NekDouble>(3,0.0);
}
if (n.X() == 0 && n.Y() == 0 && n.Z() == 0)
{
// Return bad normal
normal[0] = 0.0;
normal[1] = 0.0;
normal[2] = 0.0;
}
else
gp_Dir d = slp.Normal();
Array<OneD, NekDouble> normal(3);
if (!m_correctNormal)
{
n.Normalize();
normal[0] = n.X();
normal[1] = n.Y();
normal[2] = n.Z();
d.Reverse();
}
normal[0] = d.X();
normal[1] = d.Y();
normal[2] = d.Z();
return normal;
}
......
......@@ -106,7 +106,7 @@ bool CADSystemOCE::LoadCAD()
for (explr.Init(shape, TopAbs_FACE); explr.More(); explr.Next())
{
TopoDS_Shape f = explr.Current().Oriented(TopAbs_FORWARD);
TopoDS_Shape f = explr.Current();
ASSERTL0(!mapOfFaces.Contains(f), "duplicated faces");
int i = mapOfFaces.Add(f);
......@@ -116,7 +116,7 @@ bool CADSystemOCE::LoadCAD()
// attempts to identify properties of the vertex on the degen edge
for (int i = 1; i <= mapOfFaces.Extent(); i++)
{
TopoDS_Shape face = mapOfFaces.FindKey(i);
TopoDS_Shape face = mapOfFaces.FindKey(i).Oriented(TopAbs_FORWARD);
TopTools_IndexedMapOfShape localEdges;
TopExp::MapShapes(face, TopAbs_EDGE, localEdges);
......@@ -183,8 +183,10 @@ void CADSystemOCE::AddSurf(int i, TopoDS_Shape in)
CADSurfSharedPtr newSurf = GetCADSurfFactory().CreateInstance(key);
boost::static_pointer_cast<CADSurfOCE>(newSurf)->Initialise(i, in);
//do the exploration on forward oriented
TopoDS_Shape face = in.Oriented(TopAbs_FORWARD);
TopTools_IndexedMapOfShape mapOfWires;
TopExp::MapShapes(in, TopAbs_WIRE, 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++)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment