Menu

#58 Potential pitfall

3.0
closed
nobody
2021-08-25
2021-07-17
Filip Tsai
No

Hi,

When I re-meshed my model, I did by accident missed a face with four vertices. Unaware of my miss, I proceed further without any problem in NumCalc. However, the computation failed when I attempted to compute the HRTF. Therefore, I just wanted to highlight this potential pitfall. My suggested solution would be to check that all rows in "Model_Name"\ObjectMeshes\Elements.txt, except for the first row, consists of seven numbers.

Best Regards,
Filip Tsai

Discussion

  • Fabian Brinkmann

    Hi Filip,

    sorry for my slow responses lately - I had quite a work stack followed by a vacation. A check for triangular faces would be good, indeed. It might be easier though to directly check it in Blender upon project export. Here's an example for checking if all faces are quads, but it would be easy to change:

    https://blender.stackexchange.com/questions/146051/how-to-check-if-all-my-faces-on-mesh-are-all-quads-using-a-script

    Would you have time to try to incorporate this in the Python export script? This might be how it's done:
    - change to edit mode (theres an example of how to switch somewhere in the beginning)
    - check all faces
    - raise an Error if there is a quad face
    - switch back to object mode

    Best, Fabian

     
  • Filip Tsai

    Filip Tsai - 2021-08-10

    Hi Fabian,

    Oh, silly me.

    Here is my Python solution:

    import bpy
    
    # Go to object mode so that we can select
    bpy.ops.object.mode_set(mode = 'OBJECT')
    
    # Get active object
    obj = bpy.context.active_object
    
    
    has_error_message = False
    # Select non quad faces (polygons)
    for p in obj.data.polygons:
        p.select = len(p.vertices) != 3
        if p.select:
            has_error_message = True
    
    
    # Go in edit mode to show the result    
    bpy.ops.object.mode_set(mode = 'EDIT') 
    
    
    if has_error_message:
        raise Exception('Error! Not all meshes are triangular!')
    

    Best Regards,
    Filip

     
  • Fabian Brinkmann

    Thanks - that looks good! I think I would only change the error message to
    "Error! Not all faces in the Reference mesh are triangular!"

    Can you give it a try and include it in exportMesh2HRTF.py in the develop branch? That would be great. It might be the most modular solution to make it a function that is called after line 344

    Best, Fabian

     
  • Filip Tsai

    Filip Tsai - 2021-08-13

    Hi Fabian,

    I was able to change it on my exportMesh2HRTF.py version after adding an else-statement. Unfortunately, I have forgotten how to changing the file in a branch as I barely use git. If you guide me through the steps I can do it or you can add the following code after the if-statement:

    else:
        bpy.ops.object.mode_set(mode = 'OBJECT', toggle=False)
    

    Best Regards,
    Filip

     
  • Filip Tsai

    Filip Tsai - 2021-08-13

    Hi again,

    After som additional code editing and testing I think this code should work in exportMesh2HRTF.py

            # Get Reference object
            obj2 = bpy.data.objects['Reference']
    
            has_error_message = False
            # Select non quad faces (polygons)
            for p in obj2.data.polygons:
                p.select = len(p.vertices) != 3
                if p.select:
                    has_error_message = True
    
            if has_error_message:
                # Go in edit mode to show the result
                bpy.ops.object.mode_set(mode = 'EDIT')
                raise Exception('Error! Not all faces in the Reference mesh are triangular!')
    

    Best Regards,
    Filip

     

    Last edit: Filip Tsai 2021-08-13
  • Fabian Brinkmann

    Hi Filip,

    can you upload your entire export_Mesh2HRTF.py? This would make it easier for me to spot and update your changes :)

    Best, Fabian

     
  • Filip Tsai

    Filip Tsai - 2021-08-18

    Hi Fabian,

    Here is my export_Mesh2HRTF.py

    Best Regards,
    Filip

     
  • Fabian Brinkmann

    thanks - This is now part of the develop branch :)

     
  • Fabian Brinkmann

    • status: open --> closed
     

Log in to post a comment.