SetNgon/GetEdgeNgons issue



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 03/09/2011 at 09:36, xxxxxxxx wrote:

    User Information:
    Cinema 4D Version:   12 
    Platform:   Windows  ;   
    Language(s) :     C++  ;

    ---------
    Hi all!
    I'm getting some weird behaviour when using the Modeling library. Here's what I do:

    1. I use the SetNgon() function to set the ngon at index i to a manually created Ngon. This Ngon includes the edge a,b.

    2. To double check, I use GetNgon to retrieve the Ngon at i. I print the points and segments of this Ngon, and verify that it indeed contains the edge a,b.

    3. I use GetEdgeNgons() to get all Ngons that contain the edge a,b. Since we just created such a Ngon, there should be at least one. But the number of adjacent polygons, pcnt, is zero!

    This may be caused by a bug in my code - I just wanted to check that I'm not missing something here, e.g, if the neighborhod information of the modeling object needs to be updated after calling SetNgon or something like that?

    I'll try to put together a minimal code example that shows this behavior and post it as soon as I can.

    Best regards
    /Filip



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 04/09/2011 at 01:26, xxxxxxxx wrote:

    Here is a small code example that illustrates my problem:

      
              AutoAlloc<PolygonObject> op(0,0);   
              AutoAlloc<Modeling> m;   
              m->InitObject(op);   
                 
              LONG a = m->AddPoint(op, Vector(0,0,0));   
              LONG b = m->AddPoint(op, Vector(0,100,0));   
              LONG c = m->AddPoint(op, Vector(100,100,0));   
              LONG d = m->AddPoint(op, Vector(100,0,0));   
              LONG e = m->AddPoint(op, Vector(50,0,0));   
      
              LONG padr[] = {a,b,c,d};   
              LONG i = m->CreateNgon(op, padr, 4);   
                 
              Ngon ngon;   
              ngon.Alloc(5,1);   
              ngon.points[0]=a;   
              ngon.points[1]=b;   
              ngon.points[2]=c;   
              ngon.points[3]=d;   
              ngon.points[4]=e;   
      
              ngon.segments[0]=5;   
            
              m->SetNgon(op,i,ngon); //Replace the Ngon at index i with "ngon".   
      
              if(m->IsValidEdge(op,NOTINDEX,d,e)){   
                   GePrint("Edge found"); //This is what we expect   
              }   
              else{   
                   GePrint("Edge not found");     //This is what actually happens   
              }   
    

    Any ideas?

    Best regards
    /Filip



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 06/09/2011 at 08:45, xxxxxxxx wrote:

    Hi again!
    I found a workaround for this. If I replace the SetNgon() command in the above code with this:

      
    m->DeleteNgon(op,i,false);   
    m->AddNgon(op, ngon);   
    

    ...then everything seems to work fine. I still don't understand why my original code didn't work tough. Could this be a bug in the SetNgon() function?

    Best regards
    /Filip


Log in to reply