DiscussionsIssue archiveOther usage issues

Archived discussion

How to get the normal direction of a gp_Pln object?

Other usage issuesThu, 05/14/2009 - 10:502 replies

Browse this forum
QuestionAuthor

Hi,

How to get the normal direction of a gp_Pln object? My code follows below:

if (m_FirstShape.ShapeType() == TopAbs_FACE)
{
TopoDS_Face faceShape = TopoDS::Face(m_FirstShape);
Handle_Geom_Surface surface = BRep_Tool::Surface(faceShape);
Handle(Geom_Plane) pln = Handle(Geom_Plane)::DownCast(surface);
return pln->Pln().Axis().Direction();
}

But the result is not correct,why?

Thanks in advance!

Discussion

2 archived replies

Posts are displayed in their archived order.

01Commenter-1

My guess is that when you say "the result is not correct" you mean sometimes it's pointing to the opposite direction. To know when to flip the normal, check the Orientation of the Face. If it's TopAbs_REVERSED, flip the plane's Direction.

02Author

Hi Paul,

Thank you for you reply, and you answer is just right.
My revised code is:

if (m_FirstShape.ShapeType() == TopAbs_FACE)
{
TopoDS_Face faceShape = TopoDS::Face(m_FirstShape);
Handle_Geom_Surface surface = BRep_Tool::Surface(faceShape);
Handle(Geom_Plane) pln = Handle(Geom_Plane)::DownCast(surface);
if (m_FirstShape.Orientation() == TopAbs_REVERSED)
{
return pln->Pln().Axis().Direction().Reversed();
}
return pln->Pln().Axis().Direction();
}

Thanks again!