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

    get face number count for geometrics

    Scheduled Pinned Locked Moved SDK Help
    4 Posts 0 Posters 387 Views
    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 Offline
      Helper
      last edited by

      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;
      }

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

        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

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

          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;

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

            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

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