Home
Reply
Contributor
titus
Posts: 13

Inverted normals problem with some models

[ Edited ]
Hi,

i have encountered a strange problem when faceting certain entities. Some normals have the wrong orientation. See attached image (dark regions).

I used the MESH_MANAGER with the indexed protocol.

I get the normals from the faceter via the parameter N from the method announce_indexed_node(). I also tried to calculate the normal myself with face->geometry()->equation()->point_normal() and then find the right orientation with face->sense() but this produces the same. Seems that face->sense() sometimes returns incorrect values. Is this a bug or am I doing something wrong?? Please help!

See the attached files.

Best regards,

    Titus


Message Edited by titus on 12-13-2007 06:42 AM

Message Edited by titus on 12-13-2007 06:44 AM
part2.jpg
Spatial Employee
gweedo
Posts: 14

Re: Inverted normals problem with some models

There is nothing wrong with the normals.  To verify that, bring this part up in the ToolKit (acis3dt.exe).  It can use the IndexedMeshManager. Perform the following commands:
            (option:set 'mesh_manager 'indexed)

            (view:gl 0 0 500 500)
            (zoom-all)
            (front)
            (view:facet-vertex-normals #t)
This will show the normals for each facet node.  They all look good to me.  Someone may question the few normals that point into the positive Z direction.  They are attributed to the single face on the back. To verify that, perform the following:
            (view:facet-vertex-normals #f)
            (ray:queue 0.362951 -1.06663 12.1439 -0.0154647 0.142293 -0.989704 0.0351844)
            (entity:delete (face:unhook (pick-face)))
            (view:facet-vertex-normals #t)
Now you can see that no normals point into the positive Z direction. I have taken a look at the rest of the normals and they appear to be correct.

Now to fix the problem that I can see.  There are facets poking through and intersecting facets from the other side of the model. This can give the appearance of facet normals pointing the wrong way.  This model is very thin (0.028 units) and almost flat, but does have noticeable curvature. The back side is one smooth face, but the front side has many indentations.  These indentation come close to intersecting the back face (0.010 units), but they don't intersect.  The model is very, very thin at these points.  The facets approximate the surface of the back face, but because of the slight curvature, the approximating facets intersect the facets of the indentations.  To clean this up in the ToolKit, perform the following:
            (view:facet-vertex-normals #f)
            (part:clear)
            (part:load "part.sab")     ; You may need to specify the file's path
            (define r1 (refinement))
            (entity:set-refinement (car (part:entities)) r1)
            (refinement:set-prop r1 "surface tolerance" -0.1)
            (entity:facet (part:entities))
            (render:rebuild)

The IndexedMeshManager uses the indexed protocol and gets its normals from announce_indexed_node() also, so it is very likely that it will operate the same as your mesh manager in this regard.  The code above is easily converted to C++ and will take care of the problem I can see in the Toolkit.  However, I could not get the ToolKit to produce a rendering that looked anything like your rendering.  Some of the dark areas may be the back side of facets from the other side of the model (the side with the indentations), but that only makes sense if there is some rendering technique applied to the back side of facets.  And that doesn't explain such a large black area.  Anyways, I noticed a problem and hopefully this discussion helps you.

The default refinements are set up so that the facets will target a surface tolerance of 1/500th of the length of the bounding box of the body.  This produces the desired results in the vast majority of cases; most applications require a minimum number of facets that renders well.  But this case requires special attention because it has very, very tiny features.  Facets are planar polygons (usually triangles) that approximate true geometry.  A non-planar surface will have a series of facets that lie close to the surface.  The facet nodes lie on the surface, but the rest of the facet may not.  In this case, the back face (the one I removed above) has good facets, facets that lie close to the surface.  But there are features on the other side of the model that come even closer.  In other words, there are other faces on the front side whose distance to the back face is closer than the default surface tolerance.  The default surface tolerance used is 0.021 units, which is more than twice the distance between faces on opposite sides of the model.  When you have a part and you need to see these tiny features, you need to set the surface tolerance of the faceter smaller than the features.  Usually the features we are concerned about are bumps and holes.  In this case, the feature is the distance between opposite facing faces, we don't want faces poking through other faces.  The true geometry doesn't poke through other faces, but the approximating facets do poke through each other, so the approximation (faceting) needs to be finer than the default.

Setting the surface tolerance to a negative value indicates that the faceter should use that positive value divided by 500, multiplied by the length of the diagonal of the bounding box.  In this case  surface tolerance = -(-0.1)/500 * 10.5116259272469 = 0.00210232518544938.  This is very small, but these features are very small.  I feel uncomfortable setting the surface tolerance for faceting below SPAresfit, whose default is 0.001.  However, I have tried setting the surface tolerance value to -0.01, resulting a true surface tolerance of 0.000210232518544938 for this model and got satisfactory results.


Contributor
titus
Posts: 13

Re: Inverted normals problem with some models

Hi!

Thank you for the quick answer!
You are right, the normals are ok but the faces are penetrating each other because the model is very thin. I played around a bit with the tesselation parameters but I did not find any appropriate parameters to display the model correctly.
The toolkit is somehow strange... I can display anything in edge mode but the viewer always hangs when I switch to faces render mode. But in edge mode, the result looks correct as far as I could figure it out.

The simplest solution for this problem is to enable backface culling. This will at least remove the ugly dark areas...

Thanks for your help
Best regards


    Titus