Open CASCADE, the 3D modelling kernel
3D modeling & numerical simulation

Search the Forums
See All Topics

Triangulation and normal error...

Triangulation and normal error...
jeancharlesthomas 2007/02/01 16:11
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 <= ntriangles; j++){
Poly_Triangle triangle = (triangulation -> Triangles())(j);
for (int k = 1; k <= 3; 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.

Stephane Routelous 2007/02/01 18:54
Did you try BRepGProp_Face instead of BRepLProp_SLProps ?
BRepGProp_Face prop2(face);
gp_Pnt pnt;

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.


Ling 2013/01/23 13:34
      the problem of normal is not solved ,, can you give me an example

Thanks very much!
Latest news
  • Open CASCADE CAD Assistant for iOS platform is available!
  • Open CASCADE Technology 6.9.0 is available for download!
  • JT Assistant for Android

  • © OPEN CASCADE 2000 - 2015  |  Search  |  Contacts   |  Site map