<commit_before>#include "AlembicGetInfo.h"

AlembicGetInfoCommand::AlembicGetInfoCommand()
{
}

AlembicGetInfoCommand::~AlembicGetInfoCommand()
{
}

MSyntax AlembicGetInfoCommand::createSyntax()
{
   MSyntax syntax;
   syntax.addFlag("-h", "-help");
   syntax.addFlag("-f", "-fileNameArg", MSyntax::kString);
   syntax.enableQuery(false);
   syntax.enableEdit(false);

   return syntax;
}

void* AlembicGetInfoCommand::creator()
{
   return new AlembicGetInfoCommand();
}

MStatus AlembicGetInfoCommand::doIt(const MArgList & args)
{
   MStatus status = MS::kSuccess;
   MArgParser argData(syntax(), args, &status);

   if (argData.isFlagSet("help"))
   {
      MGlobal::displayInfo("[ExocortexAlembic]: ExocortexAlembic_getInfo command:");
      MGlobal::displayInfo("                    -f : provide a fileName (string)");
      return MS::kSuccess;
   }

   if(!argData.isFlagSet("fileNameArg"))
   {
      // TODO: display dialog
      MGlobal::displayError("[ExocortexAlembic] No fileName specified.");
      return MS::kFailure;
   }

   // get the filename arg
   MString fileName = argData.flagArgumentString("fileNameArg",0);

   // create an archive and get it
   addRefArchive(fileName);
   Alembic::Abc::IArchive * archive = getArchiveFromID(fileName);
   if(archive == NULL)
   {
      MGlobal::displayError("[ExocortexAlembic] FileName specified. '"+fileName+"' does not exist.");
      return MS::kFailure;
   }

   // get the root object
   std::vector<Alembic::Abc::IObject> objects;
   objects.push_back(archive->getTop());

   // loop over all children and collect identifiers
   MStringArray identifiers;
   for(size_t i=0;i<objects.size();i++)
   {
      for(size_t j=0;j<objects[i].getNumChildren();j++)
      {
         Alembic::Abc::IObject child = objects[i].getChild(j);
         objects.push_back(child);

         MString identifier = child.getFullName().c_str();
         MString type = getTypeFromObject(child);
         if(type.length() == 0)
            continue;
         identifier += "|"+type;
         MString name = truncateName(child.getName().c_str());
         if(type != "Xform")
            name = injectShapeToName(name);
         identifier += "|"+name;
         MString numSamples;
         numSamples.set((double)getNumSamplesFromObject(child));
         identifier += "|"+numSamples;

         // additional data fields
         MString data;
         if(Alembic::AbcGeom::IPolyMesh::matches(child.getMetaData())) {
            // check if we have topo or not
            Alembic::AbcGeom::IPolyMesh obj(child,Alembic::Abc::kWrapExisting);
            if(obj.valid())
            {
               Alembic::AbcGeom::IPolyMeshSchema::Sample sample;
               obj.getSchema().get(sample,0);
               Alembic::Abc::Int32ArraySamplePtr faceCounts = sample.getFaceCounts();
               if(faceCounts)
               {
                  if(faceCounts->get()[0] == 0)
                  {
                     data += "purepointcache=1";
                  }
                  else
                  {
                     Alembic::Abc::ICompoundProperty abcCompound = getCompoundFromObject(obj);
                     Alembic::Abc::IInt32ArrayProperty faceCountProp = Alembic::Abc::IInt32ArrayProperty(abcCompound,".faceCounts");
                     if(faceCountProp.valid())
                     {
                        if(!faceCountProp.isConstant())
                        {
                           data += "dynamictopology=1";
                        }
                     }
                  }
               }
            }
         } else if(Alembic::AbcGeom::ISubD::matches(child.getMetaData())) {
            // check if we have topo or not
            Alembic::AbcGeom::ISubD obj(child,Alembic::Abc::kWrapExisting);
            if(obj.valid())
            {
               Alembic::AbcGeom::ISubDSchema::Sample sample;
               obj.getSchema().get(sample,0);
               Alembic::Abc::Int32ArraySamplePtr faceCounts = sample.getFaceCounts();
               if(faceCounts)
               {
                  if(faceCounts->get()[0] == 0)
                  {
                     data += "purepointcache=1";
                  }
                  else
                  {
                     Alembic::Abc::ICompoundProperty abcCompound = getCompoundFromObject(obj);
                     Alembic::Abc::IInt32ArrayProperty faceCountProp = Alembic::Abc::IInt32ArrayProperty(abcCompound,".faceCounts");
                     if(faceCountProp.valid())
                     {
                        if(!faceCountProp.isConstant())
                        {
                           data += "dynamictopology=1";<commit_msg>#72: empty meshes don't import<commit_after>#include "AlembicGetInfo.h"

AlembicGetInfoCommand::AlembicGetInfoCommand()
{
}

AlembicGetInfoCommand::~AlembicGetInfoCommand()
{
}

MSyntax AlembicGetInfoCommand::createSyntax()
{
   MSyntax syntax;
   syntax.addFlag("-h", "-help");
   syntax.addFlag("-f", "-fileNameArg", MSyntax::kString);
   syntax.enableQuery(false);
   syntax.enableEdit(false);

   return syntax;
}

void* AlembicGetInfoCommand::creator()
{
   return new AlembicGetInfoCommand();
}

MStatus AlembicGetInfoCommand::doIt(const MArgList & args)
{
   MStatus status = MS::kSuccess;
   MArgParser argData(syntax(), args, &status);

   if (argData.isFlagSet("help"))
   {
      MGlobal::displayInfo("[ExocortexAlembic]: ExocortexAlembic_getInfo command:");
      MGlobal::displayInfo("                    -f : provide a fileName (string)");
      return MS::kSuccess;
   }

   if(!argData.isFlagSet("fileNameArg"))
   {
      // TODO: display dialog
      MGlobal::displayError("[ExocortexAlembic] No fileName specified.");
      return MS::kFailure;
   }

   // get the filename arg
   MString fileName = argData.flagArgumentString("fileNameArg",0);

   // create an archive and get it
   addRefArchive(fileName);
   Alembic::Abc::IArchive * archive = getArchiveFromID(fileName);
   if(archive == NULL)
   {
      MGlobal::displayError("[ExocortexAlembic] FileName specified. '"+fileName+"' does not exist.");
      return MS::kFailure;
   }

   // get the root object
   std::vector<Alembic::Abc::IObject> objects;
   objects.push_back(archive->getTop());

   // loop over all children and collect identifiers
   MStringArray identifiers;
   for(size_t i=0;i<objects.size();i++)
   {
      for(size_t j=0;j<objects[i].getNumChildren();j++)
      {
         Alembic::Abc::IObject child = objects[i].getChild(j);
         objects.push_back(child);

         MString identifier = child.getFullName().c_str();
         MString type = getTypeFromObject(child);
         if(type.length() == 0)
            continue;
         identifier += "|"+type;
         MString name = truncateName(child.getName().c_str());
         if(type != "Xform")
            name = injectShapeToName(name);
         identifier += "|"+name;
         MString numSamples;
         numSamples.set((double)getNumSamplesFromObject(child));
         identifier += "|"+numSamples;

         // additional data fields
         MString data;
         if(Alembic::AbcGeom::IPolyMesh::matches(child.getMetaData())) {
            // check if we have topo or not
            Alembic::AbcGeom::IPolyMesh obj(child,Alembic::Abc::kWrapExisting);
            if(obj.valid())
            {
               Alembic::AbcGeom::IPolyMeshSchema::Sample sample;
               obj.getSchema().get(sample,0);
               Alembic::Abc::Int32ArraySamplePtr faceCounts = sample.getFaceCounts();
               if(faceCounts)
               {
                  if(faceCounts->get()[0] == 0)
                  {
                     // check if this eventually holds only one point
                     Alembic::Abc::P3fArraySamplePtr samplePos = sample.getPositions();
                     if(samplePos->size() <= 1)
                        data += "dynamictopology=1";
                     else
                        data += "purepointcache=1";
                  }
                  else
                  {
                     Alembic::Abc::ICompoundProperty abcCompound = getCompoundFromObject(obj);
                     Alembic::Abc::IInt32ArrayProperty faceCountProp = Alembic::Abc::IInt32ArrayProperty(abcCompound,".faceCounts");
                     if(faceCountProp.valid())
                     {
                        if(!faceCountProp.isConstant())
                        {
                           data += "dynamictopology=1";
                        }
                     }
                  }
               }
            }
         } else if(Alembic::AbcGeom::ISubD::matches(child.getMetaData())) {
            // check if we have topo or not
            Alembic::AbcGeom::ISubD obj(child,Alembic::Abc::kWrapExisting);
            if(obj.valid())
            {
               Alembic::AbcGeom::ISubDSchema::Sample sample;
               obj.getSchema().get(sample,0);
               Alembic::Abc::Int32ArraySamplePtr faceCounts = sample.getFaceCounts();
               if(faceCounts)
               {
                  if(faceCounts->get()[0] == 0)
                  {
                     // check if this eventually holds only one point
                     Alembic::Abc::P3fArraySamplePtr samplePos = sample.getPositions();
                     if(samplePos->size() <= 1)
                        data += "dynamictopology=1";
                     else
                        data += "purepointcache=1";
                  }
                  else
                  {
                     Alembic::Abc::ICompoundProperty abcCompound = getCompoundFromObject(obj);
                     Alembic::Abc::IInt32ArrayProperty faceCountProp = Alembic::Abc::IInt32ArrayProperty(abcCompound,".faceCounts");
                     if(faceCountProp.valid())
                     {
                        if(!faceCountProp.isConstant())
                        {
                           data += "dynamictopology=1";
{'fraction_non_alphanumeric': 0.12293357379020138, 'fraction_numerical': 0.006011421701232342, 'mean_word_length': 1.9246996777029006, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4288181', 'n_tokens_mistral': 2969, 'n_tokens_neox': 2844, 'n_words': 445}