get face number count for geometrics



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

    On 26/10/2007 at 02:08, xxxxxxxx wrote:

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

    ---------
    I want to find out and get the face number  of count result and vertex number .... but I have a little trouble that  my code can't get back the correct result :
     
    my code:

    void GetAllPolygon(AtomArray *oPolygons,BaseObject *oPolys)
    {
         if(oPolys)
         {
      
       //MessageDialog("GetType Begin");
       if( oPolys->GetType() == Opolygonn ) //||( oPolys->GetType() == Ocylinder)||( oPolys->GetType() == Ocube)||( oPolys->GetType() == Osphere))
       {    
        oPolygons->Append(oPolys);
       }
       
             if(oPolys->GetDown())
        {
        GetAllPolygon(oPolygons,oPolys->GetDown());
       }
       
       if(oPolys->GetNext())
       {
        GetAllPolygon(oPolygons,oPolys->GetNext());
       }
       
       }
      // MessageDialog("GetNext End");
       
    }
    LONG GetAllPolygon(AtomArray * oPolygon)
    {
         if(!oPolygon)
      {
       //MessageDialog("Alloc AtomArray Fail that Can't get polygon ");
       return 0;
      }
         BaseDocument *doc=GetActiveDocument();
         BaseObject *obj = doc->GetFirstObject();
         if(obj)
         {
        //MessageDialog("To  get polyon ");
              GetAllPolygon(oPolygon,obj);
         }
         return oPolygon->GetCount();
    }

    void SnapPolygonData( AtomArray *oPolygons, LONG lPolygonCnt, LONG& out_iFaceNumCount, LONG& out_iVertexNumCount)
    {
     LONG nCount = 0;
     if ( lPolygonCnt == 0)
     {
      return;
     }
     BaseDocument* doc = GetActiveDocument();
     //MessageDialog( LongToString(lPolygonCnt) );
        for(LONG i = 0;i < lPolygonCnt; i++)
        {
            PolygonObject *obj=(PolygonObject* )oPolygons->GetIndex(i);
            //MessageDialog(obj->GetName());
      if ( !obj) break;
           
      LONG lngFace = obj->GetPolygonCount();
      LONG lngVertex = obj->GetNgonCount();
      out_iFaceNumCount += lngFace;
      out_iVertexNumCount += lngVertex;
     
        }

    }
    bool GetMetaData( LONG& out_iFaceCount, LONG& out_iVertexCount )

      LONG iFaceNumCount = 0;
     LONG iVertexNumCount = 0;
     AtomArray* oPolygons = AtomArray::Alloc();
     if ( !oPolygons )
     {
      MessageDialog( "AtomArray Alloc Is Fail" );
      return false;
     }
     //MessageDialog( "AtomArray Alloc Is Succuss" );
      
        LONG lPolygonCnt = GetAllPolygon(oPolygons);
     MessageDialog( LongToString(lPolygonCnt) );
     SnapPolygonData( oPolygons, lPolygonCnt, iFaceNumCount, iVertexNumCount);

    out_iFaceCount = iFaceNumCount;
     out_iVertexCount = iVertexNumCount;

    AtomArray::Free(oPolygons) ;
     
     
     return true;
    }



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

    On 26/10/2007 at 05:10, xxxxxxxx wrote:

    where in your code do you run into problems?

    cheers,
    Matthias



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

    On 28/10/2007 at 17:58, xxxxxxxx wrote:

    that can't to get polygon object and count face number back when I had  added cube to  scence after. show me the result of polygon's face and vertex number is 0;



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

    On 02/11/2007 at 04:49, xxxxxxxx wrote:

    It seems you don't convert your primitve objects into polygon objects. For instance you have first to convert the cube into a polygon object to access the polygons. The savest way to it is by using SendModelingCommand() to get the current state of your object. Here a little example.

    > _
    > Bool MenuTest::Execute(BaseDocument *doc)
    > {
    >      StopAllThreads();
    >
    >      BaseObject *op = doc->GetActiveObject();
    >      if(!op) return TRUE;
    >
    >      BaseObject *res = NULL;
    >      ModelingCommandData cd;
    >      cd.doc = doc;
    >      cd.op = op;
    >      if(!SendModelingCommand(MCOMMAND_CURRENTSTATETOOBJECT, cd)) return FALSE;
    >      res = static_cast<BaseObject*>(cd.result->GetIndex(0));
    >
    >      if(!res) return FALSE;
    >
    >      if(res->GetType() == Opolygon)
    >      {
    >           GePrint("point count "+LongToString(ToPoly(res)->GetPointCount()));
    >      }
    >
    >      return TRUE;
    > }
    > _

    cheers,
    Matthias


Log in to reply