
Sat, 02/04/2006 - 00:29
Forums:
Given a shape of any kind, I have been able to pick a point on the "surface" of the shape. I want to now calculate the normal to the "surface" of the shape at the calculated point.
I have seen examples that used TopoDS_Face objects, to convert to Geom_Surface objects, but if I have a curved surface (I'm using the Hammer.iges example) I cannot decompose it into faces (I believe), and this into surfaces.
Is there any other way to calculate a normal vector?
Sat, 02/04/2006 - 00:52
Hi,
with your picking, you should be able to have the face of the shape you selected.
if not, you could use BRepExtrema_DistShapeShape with a vertex and your shape.
You can also decompose your shape into faces (TopExp_Explorer), check with bounding box tests or RTree or whatever method which face is the closest to your point.
Once you have the TopoDS_Face, you can extract the Geom_Surface (with Brep_Tool::Surface).
once you hace the Geom_Surface, you can :
1/ if you used BRepExtrama_DistShapeShape you can have the parameters of the point on the surface.
2/ if you used your own method, you can use GeomAPI_ProjectPointOnSurf to have the parameters
once you have the parameters of your point on the surface, you can use Geom_Surface::D1 to have the 2 tangential vectors to the surface.
Computing the cross product of both vectors should give you the normal
I didn't test this method, but it should work
HTH,
Stephane Routelous
stephane.routelous@exotk.org
Mon, 02/06/2006 - 19:37
Thanks Stephane,
I have been able to apply your approach to a simple geometric object, but nothing more complicated.
What I mean is this:
My simple object is cube (brought in as an STL file). I can decompose it into the faces of the object. From the face I can gain the surface.
My complex object is a hammer (brough in as a IGES file). I cannot decompose it into faces. I use the BRepIntCurveSurface_Inter_Inter class to get the point on the surface.
Essentially I am not using faces/surfaces and thus the above algorithm for normal computation will not work.
Two questions now:
1. Can I get faces/surfaces from curved objects?
2. Is there a different way to compute the normal (not using surfaces)?
Thanks
~sinisa
Mon, 02/06/2006 - 19:37
Thanks Stephane,
I have been able to apply your approach to a simple geometric object, but nothing more complicated.
What I mean is this:
My simple object is cube (brought in as an STL file). I can decompose it into the faces of the object. From the face I can gain the surface.
My complex object is a hammer (brough in as a IGES file). I cannot decompose it into faces. I use the BRepIntCurveSurface_Inter_Inter class to get the point on the surface.
Essentially I am not using faces/surfaces and thus the above algorithm for normal computation will not work.
Two questions now:
1. Can I get faces/surfaces from curved objects?
2. Is there a different way to compute the normal (not using surfaces)?
Thanks
~sinisa
Mon, 02/06/2006 - 22:40
First off, sorry for the double post.
Secondly, I think that my last post is wrong. things seem to be "working" now. I'm not sure what I was doing that was wrong before.
My newest problem on this front is regarding the polarity of the normal.
On my example I am getting some strange behaviour. When I pick a point on a flat part of the object the normal vector is point out, and when I pick a point on the curved part of the object the normal vector is pointing in. I'm not sure why this behaviour.
I'll keep digging, and hope I find something. Any suggestions would be appriciated.
Thanks,
~sinisa