<commit_before>#include "stdafx.h"
#include "AlembicPolyMsh.h"
#include "AlembicXform.h"

#include "CommonProfiler.h"
#include "CommonMeshUtilities.h"

using namespace XSI;
using namespace MATH;

AlembicPolyMesh::AlembicPolyMesh(exoNodePtr eNode, AlembicWriteJob * in_Job, Abc::OObject oParent)
: AlembicObject(eNode, in_Job, oParent)
{
   AbcG::OPolyMesh mesh(GetMyParent(), eNode->name, GetJob()->GetAnimatedTs());
   mMeshSchema = mesh.getSchema();

   Primitive prim(GetRef());
   AddRef(prim.GetParent3DObject().GetKinematics().GetGlobal().GetRef());
   
   // create the generic properties
   mOVisibility = CreateVisibilityProperty(mesh,GetJob()->GetAnimatedTs());
}

AlembicPolyMesh::~AlembicPolyMesh()
{
   // we have to clear this prior to destruction
   // this is a workaround for issue-171
   mOVisibility.reset();
}

Abc::OCompoundProperty AlembicPolyMesh::GetCompound()
{
   return mMeshSchema;
}

XSI::CStatus AlembicPolyMesh::Save(double time)
{
   // store the transform
   Primitive prim(GetRef());
   bool globalSpace = GetJob()->GetOption(L"globalSpace");

   // query the global space
   CTransformation globalXfo;
   if(globalSpace)
      globalXfo = Kinematics(KinematicState(GetRef(1)).GetParent()).GetGlobal().GetTransform(time);
   CTransformation globalRotation;
   globalRotation.SetRotation(globalXfo.GetRotation());

   // store the metadata
   SaveMetaData(prim.GetParent3DObject().GetRef(),this);

   // set the visibility
   Property visProp;
   prim.GetParent3DObject().GetPropertyFromName(L"Visibility",visProp);
   if(isRefAnimated(visProp.GetRef()) || mNumSamples == 0)
   {
      bool visibility = visProp.GetParameterValue(L"rendvis",time);
      mOVisibility.set(visibility ?AbcG::kVisibilityVisible :AbcG::kVisibilityHidden);
   }

   // check if the mesh is animated
   if(mNumSamples > 0) {
      if(!isRefAnimated(GetRef(),false,globalSpace))
         return CStatus::OK;
   }

   // check if we just have a pure pointcache (no surface)
   bool purePointCache = (bool)GetJob()->GetOption(L"exportPurePointCache");

   // define additional vectors, necessary for this task
   std::vector<Abc::V3f> posVec;

   // access the mesh
   PolygonMesh mesh = prim.GetGeometry(time);
   CVector3Array pos = mesh.GetVertices().GetPositionArray();
   LONG vertCount = pos.GetCount();

   // prepare the bounding box
   Abc::Box3d bbox;

   // allocate the points and normals
   posVec.resize(vertCount);
   for(LONG i=0;i<vertCount;i++)
   {
      if(globalSpace)
         pos[i] = MapObjectPositionToWorldSpace(globalXfo,pos[i]);
      posVec[i].x = (float)pos[i].GetX();
      posVec[i].y = (float)pos[i].GetY();
      posVec[i].z = (float)pos[i].GetZ();
      bbox.extendBy(posVec[i]);
   }


   // store the positions && bbox
   mMeshSample.setPositions(Abc::P3fArraySample(posVec));
   mMeshSample.setSelfBounds(bbox);

   ESS_LOG_WARNING("Begin position dump: ");
   for(int i=0; i<posVec.size(); i++){
      ESS_LOG_WARNING("posVec["<<i<<"]="<<posVec[i]);  
   
   }
   ESS_LOG_WARNING("End position dump: ");

   // abort here if we are just storing points
   if(purePointCache)
   {
      if(mNumSamples == 0)
      {
         // store a dummy empty topology
         mMeshSample.setFaceCounts(Abc::Int32ArraySample(NULL, 0));
         mMeshSample.setFaceIndices(Abc::Int32ArraySample(NULL, 0));
      }

      mMeshSchema.set(mMeshSample);
      mNumSamples++;
      return CStatus::OK;
   }

   // check if we support changing topology
   bool dynamicTopology = (bool)GetJob()->GetOption(L"exportDynamicTopology");

   // get the faces
   CPolygonFaceRefArray faces = mesh.GetPolygons();
   LONG faceCount = faces.GetCount();
   LONG sampleCount = mesh.GetSamples().GetCount();<commit_msg>issue #177 - removed debugging code<commit_after>#include "stdafx.h"
#include "AlembicPolyMsh.h"
#include "AlembicXform.h"

#include "CommonProfiler.h"
#include "CommonMeshUtilities.h"

using namespace XSI;
using namespace MATH;

AlembicPolyMesh::AlembicPolyMesh(exoNodePtr eNode, AlembicWriteJob * in_Job, Abc::OObject oParent)
: AlembicObject(eNode, in_Job, oParent)
{
   AbcG::OPolyMesh mesh(GetMyParent(), eNode->name, GetJob()->GetAnimatedTs());
   mMeshSchema = mesh.getSchema();

   Primitive prim(GetRef());
   AddRef(prim.GetParent3DObject().GetKinematics().GetGlobal().GetRef());
   
   // create the generic properties
   mOVisibility = CreateVisibilityProperty(mesh,GetJob()->GetAnimatedTs());
}

AlembicPolyMesh::~AlembicPolyMesh()
{
   // we have to clear this prior to destruction
   // this is a workaround for issue-171
   mOVisibility.reset();
}

Abc::OCompoundProperty AlembicPolyMesh::GetCompound()
{
   return mMeshSchema;
}

XSI::CStatus AlembicPolyMesh::Save(double time)
{
   // store the transform
   Primitive prim(GetRef());
   bool globalSpace = GetJob()->GetOption(L"globalSpace");

   // query the global space
   CTransformation globalXfo;
   if(globalSpace)
      globalXfo = Kinematics(KinematicState(GetRef(1)).GetParent()).GetGlobal().GetTransform(time);
   CTransformation globalRotation;
   globalRotation.SetRotation(globalXfo.GetRotation());

   // store the metadata
   SaveMetaData(prim.GetParent3DObject().GetRef(),this);

   // set the visibility
   Property visProp;
   prim.GetParent3DObject().GetPropertyFromName(L"Visibility",visProp);
   if(isRefAnimated(visProp.GetRef()) || mNumSamples == 0)
   {
      bool visibility = visProp.GetParameterValue(L"rendvis",time);
      mOVisibility.set(visibility ?AbcG::kVisibilityVisible :AbcG::kVisibilityHidden);
   }

   // check if the mesh is animated
   if(mNumSamples > 0) {
      if(!isRefAnimated(GetRef(),false,globalSpace))
         return CStatus::OK;
   }

   // check if we just have a pure pointcache (no surface)
   bool purePointCache = (bool)GetJob()->GetOption(L"exportPurePointCache");

   // define additional vectors, necessary for this task
   std::vector<Abc::V3f> posVec;

   // access the mesh
   PolygonMesh mesh = prim.GetGeometry(time);
   CVector3Array pos = mesh.GetVertices().GetPositionArray();
   LONG vertCount = pos.GetCount();

   // prepare the bounding box
   Abc::Box3d bbox;

   // allocate the points and normals
   posVec.resize(vertCount);
   for(LONG i=0;i<vertCount;i++)
   {
      if(globalSpace)
         pos[i] = MapObjectPositionToWorldSpace(globalXfo,pos[i]);
      posVec[i].x = (float)pos[i].GetX();
      posVec[i].y = (float)pos[i].GetY();
      posVec[i].z = (float)pos[i].GetZ();
      bbox.extendBy(posVec[i]);
   }


   // store the positions && bbox
   mMeshSample.setPositions(Abc::P3fArraySample(posVec));
   mMeshSample.setSelfBounds(bbox);

   // abort here if we are just storing points
   if(purePointCache)
   {
      if(mNumSamples == 0)
      {
         // store a dummy empty topology
         mMeshSample.setFaceCounts(Abc::Int32ArraySample(NULL, 0));
         mMeshSample.setFaceIndices(Abc::Int32ArraySample(NULL, 0));
      }

      mMeshSchema.set(mMeshSample);
      mNumSamples++;
      return CStatus::OK;
   }

   // check if we support changing topology
   bool dynamicTopology = (bool)GetJob()->GetOption(L"exportDynamicTopology");

   // get the faces
   CPolygonFaceRefArray faces = mesh.GetPolygons();
   LONG faceCount = faces.GetCount();
   LONG sampleCount = mesh.GetSamples().GetCount();
{'fraction_non_alphanumeric': 0.13283070596298835, 'fraction_numerical': 0.006305688827964359, 'mean_word_length': 4.049134948096886, 'pattern_counts': {'":': 0, '<': 14, '<?xml version=': 0, '>': 19, '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': '4778732', 'n_tokens_mistral': 2468, 'n_tokens_neox': 2374, 'n_words': 458}