Thu, 02/01/2007 - 18:11
Hi,
I'm importing in 3D CAD software some STEP and IGES files thanks of "STEPControl_Reader" or "IGESControl_Reader".
I'm getting all the faces constituting the 3D models with "TopExp_Explorer" and I'm keeping the
faces definition in a "TopTools_IndexedMapOfShape" object (fmap).
I'm tesselating each face :
TopoDS_Face face = TopoDS::Face( fmap(face_i) );
TopLoc_Location loc;
BRepAdaptor_Surface sf(face, Standard_False);
BRepLProp_SLProps prop(sf, 1, 1e-3);
Handle(Poly_Triangulation) triangulation = BRep_Tool::Triangulation (face, loc);
if (triangulation.IsNull()) return;
gp_Pnt2d uv; gp_Pnt vertex; gp_Vec faceNormale;
int ntriangles = triangulation->NbTriangles();
for (int j = 1; j Poly_Triangle triangle = (triangulation -> Triangles())(j);
for (int k = 1; k
uv = (triangulation->UVNodes())(triangle(k));
prop.SetParameters(uv.X(), uv.Y());
vertex = (triangulation -> Nodes())(triangle(k)).Transformed(loc);
faceNormale = prop.Normal();
if( face.Orientation() == TopAbs_REVERSED )
faceNormale *= -1;
}
}
All the vertex are ok, the triangles ok, direction of the normale ok, but there is a problem with the normals orientations (outside the solid) : it's offen the inverted true normal. Why ?
It is a problem with the STEP / IGES translation, I forget a value control for the normal, an orientation test ?
If you have some idea, thank you.
Jc.
Thu, 02/01/2007 - 20:54
Did you try BRepGProp_Face instead of BRepLProp_SLProps ?
BRepGProp_Face prop2(face);
gp_Pnt pnt;
prop2.Normal(uv.X(),uv.Y(),pnt,faceNormale);
instead of
prop.SetParameters(uv.X(), uv.Y());
faceNormale = prop.Normal();
if( face.Orientation() == TopAbs_REVERSED )
faceNormale *= -1;
This should take care of the orientation of the face.
HTH,
Stephane
Wed, 01/23/2013 - 16:34
the problem of normal is not solved ,, can you give me an example
Thanks very much!