Edgeselection tag & Neighbor.GetPolyInfo



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

    On 21/02/2006 at 19:58, xxxxxxxx wrote:

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

    ---------
    Am I to assume that

    polyinfo->edge[n]
    baseselect->IsSelected(polyinfo->edge[n])

    refer to the same edge index for both what is returned in PolyInfo and what is stored in BaseSelect? For I am not seeing this.

    For every point, I get a PolyInfo structure from an Init.ialized Neightbor class. I then check mark[] == FALSE and edge[] != NOTOK. But the polygon indices and/or the edge indices are not correlating. Here's the code:

    // SSDialog:SplitTagEdge  
    //*---------------------------------------------------------------------------*  
    BOOL SSDialog::SplitTagEdge(PolygonObject* obj, SelectionTag* stagOld)  
    //*---------------------------------------------------------------------------*  
    {  
         // Get tag object's points and polys  
         Vector*               vert =               obj->GetPoint();  
         if (!vert)          return TRUE;  
    #ifdef C4D_R9  
         CPolygon*          poly =               obj->GetPolygon();  
    #else  
         Polygon*          poly =               obj->GetPolygon();  
    #endif  
         if (!poly)          return TRUE;  
      
         // Copy tag  
         SelectionTag*     stagNew =          static_cast<SelectionTag*>(stagOld->GetClone(0L, NULL));  
         if (!stagNew)     return     ErrorException::Throw(GeLoadString(ERROR_MEMORY_TEXT), "SSDialog.SplitTagEdge.stagNew");  
         obj->InsertTag(stagNew, NULL);  
         baseDocument->AddUndo(UNDO_NEW, stagNew);  
      
         // Split old and new tags  
         BaseSelect*          selectOld =          stagOld->GetBaseSelect();  
         if (!selectOld)     return ErrorException::Throw(GeLoadString(ERROR_MEMORY_TEXT), "SSDialog.SplitTagEdge.selectOld");  
         BaseSelect*          selectNew =          stagNew->GetBaseSelect();  
         if (!selectNew)     return ErrorException::Throw(GeLoadString(ERROR_MEMORY_TEXT), "SSDialog.SplitTagEdge.selectNew");  
      
         String               baseName =          stagOld->GetName();  
         Matrix               m =                    obj->GetMg();  
         LONG               pcount =          obj->GetPolygonCount();  
         LONG               x;  
         LONG               e;  
      
         PolyInfo*          pli;  
         Neighbor          neighbor;  
         if (!neighbor.Init(obj->GetPointCount(), poly, pcount, NULL))     return ErrorException::Throw(GeLoadString(ERROR_MEMORY_TEXT), "SSDialog.SplitTagEdge.neighbor.Init()");  
      
         if          (symPlane == PLANE_XY)  
         {  
              // Remove redundant selections  
              if          (oldSide == SIDE_POS)  
              {  
                   for (x = 0; x < pcount; x++)  
                   {  
                        pli =     neighbor.GetPolyInfo(x);  
                        e =          pli->edge[0];  
                        if (e != NOTOK)  
                        {  
                             if (selectOld->IsSelected(e) && ((vert[poly[x].a]*m).z <= 0.0)) selectOld->Deselect(e);  
                             if (selectNew->IsSelected(e) && ((vert[poly[x].a]*m).z >= 0.0)) selectNew->Deselect(e);  
                        }  
                        e =          pli->edge[1];  
                        if (e != NOTOK)  
                        {  
                             if (selectOld->IsSelected(e) && ((vert[poly[x].b]*m).z <= 0.0)) selectOld->Deselect(e);  
                             if (selectNew->IsSelected(e) && ((vert[poly[x].b]*m).z >= 0.0)) selectNew->Deselect(e);  
                        }  
                        e =          pli->edge[2];  
                        if (e != NOTOK)  
                        {  
                             if (selectOld->IsSelected(e) && ((vert[poly[x].c]*m).z <= 0.0)) selectOld->Deselect(e);  
                             if (selectNew->IsSelected(e) && ((vert[poly[x].c]*m).z >= 0.0)) selectNew->Deselect(e);  
                        }  
                        e =          pli->edge[3];  
                        if (e != NOTOK)  
                        {  
                             if (selectOld->IsSelected(e) && ((vert[poly[x].d]*m).z <= 0.0)) selectOld->Deselect(e);  
                             if (selectNew->IsSelected(e) && ((vert[poly[x].d]*m).z >= 0.0)) selectNew->Deselect(e);  
                        }  
                   }  
                   stagOld->SetName(posPrefix+baseName);  
                   stagNew->SetName(negPrefix+baseName);  
              }  
              else if (oldSide == SIDE_NEG)  
              {  
                   for (x = 0; x < pcount; x++)  
                   {  
                        pli =     neighbor.GetPolyInfo(x);  
                        e =          pli->edge[0];  
                        if (e != NOTOK)  
                        {  
                             if (selectOld->IsSelected(e) && ((vert[poly[x].a]*m).z >= 0.0)) selectOld->Deselect(e);  
                             if (selectNew->IsSelected(e) && ((vert[poly[x].a]*m).z <= 0.0)) selectNew->Deselect(e);  
                        }  
                        e =          pli->edge[1];  
                        if (e != NOTOK)  
                        {  
                             if (selectOld->IsSelected(e) && ((vert[poly[x].b]*m).z >= 0.0)) selectOld->Deselect(e);  
                             if (selectNew->IsSelected(e) && ((vert[poly[x].b]*m).z <= 0.0)) selectNew->Deselect(e);  
                        }  
                        e =          pli->edge[2];  
                        if (e != NOTOK)  
                        {  
                             if (selectOld->IsSelected(e) && ((vert[poly[x].c]*m).z >= 0.0)) selectOld->Deselect(e);  
                             if (selectNew->IsSelected(e) && ((vert[poly[x].c]*m).z <= 0.0)) selectNew->Deselect(e);  
                        }  
                        e =          pli->edge[3];  
                        if (e != NOTOK)  
                        {  
                             if (selectOld->IsSelected(e) && ((vert[poly[x].d]*m).z >= 0.0)) selectOld->Deselect(e);  
                             if (selectNew->IsSelected(e) && ((vert[poly[x].d]*m).z <= 0.0)) selectNew->Deselect(e);  
                        }  
                   }  
                   stagOld->SetName(negPrefix+baseName);  
                   stagNew->SetName(posPrefix+baseName);  
              }  
         }  
    ...  
    }  
    

    Note that I've removed the mark[] check. This started out using the identical code in the docs and has been slowly modified for speed and removal of unused junk. It did not work then and still doesn't work now.

    Why can't you just have a stupidly easy method on PolygonObject to return an array of edges? Or can you explain how the Tedgeselection SelectionTag BaseSelect is structured?

    Thank you,



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

    On 22/02/2006 at 13:06, xxxxxxxx wrote:

    Found a workaround. I think it is not only correct but true to assume that the indices in the EdgeSelection tags and those in the Neighbor class do not correspond.

    Instead, I use the tag to select the edges, GetSelectedEdges(), use that BaseSelect, SetSelectedEdges(), and then SendModelingCommand(MCOMMAND_GENERATESELECTION) (with caveats for R8.x and R9.x since the former does not create new tags and the latter does). That works.

    You didn't think about this happening did you? ;) You need to keep edge indices correlated between the object, EdgeSelection tags (!!), and the Neighbor class. Just a suggestion.

    Thanks,



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

    On 24/02/2006 at 15:55, xxxxxxxx wrote:

    the edge refered to by
    GetPolyInfo(p)->edge[side]
    is selected if and only if
    edgesel->IsSelected(p*4+side);
    returns true.
    ( all edge selections work this way: sel.tags, selected edges, hidden edges and phong breaks )
    ( it doesn't matter which polygon-side-pair you use in p*4+side, the selection state will be the same if the edges are the same )



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

    On 24/02/2006 at 17:45, xxxxxxxx wrote:

    Is this in the documentation anywhere? If not (and it is not since I search the documentation), it should be. I only assumed that there was a 'uniquely indexed' set of edges in an Edge SelectionTag since this is how the neighbor class returns them (and with no other information to contradict or illuminate) and how they are stored for points and polygons. With no special instructions or differentiations noted, I must assume away... ;)

    So, the Edge SelectionTag contains not a set of unique edge states, but a set of every polygons' edges states. If an edge is coincident to two (or more) polygons and selected, it will be selected in two (or more) places in the BaseSelect, by polygon then edge.



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

    On 25/02/2006 at 04:03, xxxxxxxx wrote:

    1. It is in the documentation, but it's not mentioned in the SelectionTag section. See GetEdgeS() and GetSelectedEdges()

    2. Yes.



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

    On 25/02/2006 at 09:45, xxxxxxxx wrote:

    You might think to include it there (or a reference back to GetEdgeS()). I really didn't think there would be a correspondence between the two, thinking that this was more in line with the Neighbor class only.

    Thanks!


Log in to reply