if (orient==TopAbs_REVERSED )
// normal is oriented inside the shape ->reoriente it!
{
normal.set(0,-direc.X());
normal.set(1,-direc.Y());
normal.set(2,-direc.Z());
//std::cerr
}
Discussion
4 archived replies
Posts are displayed in their archived order.
01Commenter-1
hi
it's very easy to compute the normal to a TopoDS_Face
I consider that you know 2D-point (on surface of the face) where yuor normal will be. So, try to use the code:
//=======================================
// foo
//=======================================
void foo(const gp_Pnt2d aP2D, // 2D-point
const TopoDS_Face& aF,// face
gp_Dir& DNS) // normal
{
gp_Pnt aP;
gp_Vec aD1U, aD1V;
gp_Dir aDD1U(aD1U);
gp_Dir aDD1V(aD1V);
aDNS=aDD1U^aDD1V;
if (aF.Orientation()==TopAbs_REVERSED){
aDNS.Reverse();
}
}
Regards,
Commenter-2
03Commenter-3
Hi Peter,
The function you posted above will do what I need, at the moment I have a 3D point which I get from GeomAPI_IntCS::Point(1), could you explain how I can get the 2D point of the surface.
Many Thanks
Commenter-3
04Commenter-4
How about BOPTools_Tools3D::GetNormalToSurface()?
I'm computing normals on surface this way (from triangulation data).
You need surface, and UV position on surface:
//...
TopoDS_Face F = TopoDS::Face(ex.Current());
// Surface (face on this surface)
Handle (Geom_Surface) surface = BRep_Tool::Surface(F);
// Face orientation
TopAbs_Orientation faceOrientation = F.Orientation();
// Get triangulation
TopLoc_Location L;
Handle (Poly_Triangulation) facing = BRep_Tool::Triangulation(F,L);
const TColgp_Array1OfPnt2d & uvnodes = facing->UVNodes(); //UVs
//...
// now you have nodes, UVs in nodes, orientation and surface
:)