Maxon Developers Maxon Developers
    • Documentation
      • Cinema 4D Python API
      • Cinema 4D C++ API
      • Cineware API
      • ZBrush Python API
      • ZBrush GoZ API
      • Code Examples on Github
    • Forum
    • Downloads
    • Support
      • Support Procedures
      • Registered Developer Program
      • Plugin IDs
      • Contact Us
    • Categories
      • Overview
      • News & Information
      • Cinema 4D SDK Support
      • Cineware SDK Support
      • ZBrush 4D SDK Support
      • Bugs
      • General Talk
    • Unread
    • Recent
    • Tags
    • Users
    • Login

    Faster way to 'weld' geometry?

    SDK Help
    0
    2
    256
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • H
      Helper
      last edited by

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

      On 10/08/2004 at 11:45, xxxxxxxx wrote:

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

      ---------
      Here is the method that I'm using to 'weld' two PolygonSelections together (no change of vertices - just reassigning indices of duplicate points) :

        
      // Weld Geometry (remove seams)  
      void PoserCharacter::WeldGeometry(void)  
      {  
           ParentChild *w;  
           PoserBase *c, *p;  
           LONG seg,i,a,b,seg2,j,a2,b2;  
           LONG *fi, *fj, *fid, *fjd;  
           Polygon* polys;  
           Vector* verts;  
           BaseSelect *bs, *bs2;  
           SelectionTag *group, *group2;  
        
           polys = (static_cast<PolygonObject*>baseObject)->GetPolygon();  
           verts = (static_cast<PolygonObject*>baseObject)->GetPoint();  
           for (w = weld; w != NULL; w = (ParentChild* )w->GetNext())  
           {  
                if ((c = w->GetChild()) == NULL) continue;  
                if ((group = c->GetGroup()) == NULL) continue;  
                if ((p = w->GetParent()) == NULL) continue;  
                if ((group2 = p->GetGroup()) == NULL) continue;  
        
                bs = group->GetBaseSelect();  
                bs2 = group2->GetBaseSelect();  
                seg=0;  
                while (bs->GetRange(seg++,&a;,&b;))  
                {  
                     for (i=a; i<=b; ++i)  
                     {  
                          seg2=0;  
                          while (bs2->GetRange(seg2++, &a2;, &b2;))  
                          {  
                               for (j = a2; j<=b2; ++j)  
                               {  
                                    for (fi = &(polys _.a), fid = fi+5; fi != fid; fi++)  
                                    {  
                                         for (fj = &(polys[j].a), fjd = fj+5; fj != fjd; fj++)  
                                         {  
                                              if ((*fi != *fj) && (verts[*fi] == verts[*fj])) *fj = *fi;  
                                         }  
                                    }  
                               }  
                          }  
                     }  
                }  
           }  
      }  
      

      Is there a better way to do this? 🙂

      Thanks,
      Robert

      1 Reply Last reply Reply Quote 0
      • H
        Helper
        last edited by

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

        On 10/08/2004 at 12:19, xxxxxxxx wrote:

        Ahhhh, shucks. Nevermind again. Found a faster solution, just required some pressure waiting for a response to get it.

        So, instead of going through every BaseSelect for every BaseSelect, I'm creating a substitution array for the vertices, then when one is encountered in a BaseSelect, the substitution replaces the value:

          
        void PoserCharacter::WeldGeometry(void)  
        {  
             LONG seg, i, a, b;  
             LONG *fi, *fid, *subs;  
             Polygon* polys;  
             Vector* verts;  
             BaseSelect *bs;  
             SelectionTag *group;  
             ParentChild *w;  
             PoserBase *c;  
          
             polys = ((PolygonObject* )baseObject)->GetPolygon();  
             verts = ((PolygonObject* )baseObject)->GetPoint();  
             seg = ((PolygonObject* )baseObject)->GetPointCount();  
             // Assign substitutions if vertices are same  
             if ((subs = (LONG* )GeAlloc(sizeof(LONG)*seg)) == NULL) throw ErrorException(ERROR_MEMORY, NULL);  
             for (i = 0; i < seg; i++) subs _= -1;  
             for (i = 0; i < seg; i++)  
             {  
                  for (a = i+1; a < seg; a++)  
                  {  
                       if ((subs[a] < 0) && (verts[a] == verts _)) subs[a] = i;  
                  }  
             }  
             for (w = weld; w != NULL; w = (ParentChild* )w->GetNext())  
             {  
                  if ((c = w->GetChild()) == NULL) continue;  
                  if ((group = c->GetGroup()) == NULL) continue;  
          
                  bs = group->GetBaseSelect();  
                  seg=0;  
                  while (bs->GetRange(seg++,&a;,&b;))  
                  {  
                       for (i=a; i<=b; ++i)  
                       {  
                            for (fi = &(polys _.a), fid = fi+5; fi != fid; fi++)  
                            {  
                                 if (subs[*fi] != -1) *fi = subs[*fi];  
                            }  
                       }  
                  }  
             }  
             GeFree(subs);  
        }  
        

        Robert

        1 Reply Last reply Reply Quote 0
        • First post
          Last post