<commit_before>#include "stdafx.h"
#include "AlembicArchiveStorage.h"
#include "AlembicVisibilityController.h"
#include "AlembicLicensing.h"
#include "AlembicNames.h"
#include "Utility.h"
#include "AlembicNurbsUtilities.h"
#include "AlembicMAXScript.h"
#include "AlembicMetadataUtils.h"
#include <surf_api.h> 


bool isAlembicNurbsTopoDynamic( AbcG::IObject *pIObj ) {
	AbcG::ICurves objCurves;

	if(AbcG::ICurves::matches((*pIObj).getMetaData())) {
		objCurves = AbcG::ICurves(*pIObj,Abc::kWrapExisting);
		return ! objCurves.getSchema().getNumVerticesProperty().isConstant();
	}
	return false;
}

bool LoadNurbs(NURBSSet& nset, Abc::P3fArraySamplePtr pCurvePos, Abc::Int32ArraySamplePtr pCurveNbVertices, Abc::FloatArraySamplePtr pKnotVec, AbcG::CurveType type, AbcG::CurvePeriodicity wrap, TimeValue time )
{
   const int nOrder = 4;
   const int numCurves = (int)pCurveNbVertices->size();
   const int numControl = (int)pCurvePos->size();

   const int abcTotalKnots = numControl + numCurves * (nOrder - 2) ;
   const int maxTotalKnots = numControl + numCurves * nOrder;

   //ESS_LOG_WARNING("abcTotalKnots: "<<abcTotalKnots);
   //ESS_LOG_WARNING("maxTotalKnots: "<<maxTotalKnots);
   //ESS_LOG_WARNING("knotVecSize: "<<pKnotVec->size());

   bool bDefaultKnot = false;
   if(pKnotVec){
      if( abcTotalKnots == pKnotVec->size() ){
         
      }
      else if( maxTotalKnots == pKnotVec->size() ){
         ESS_LOG_WARNING("3DS Max knot vector format not supported. Using Default knot vector.");
         bDefaultKnot = true;
      }
      else{
         ESS_LOG_WARNING("Knot vector has the wrong size. Using Default knot vector.");
         bDefaultKnot = true;      
      }
   }
   else{
      ESS_LOG_WARNING("Knot vector not found. Using Default knot vector.");
      bDefaultKnot = true;
   }

   //bDefaultKnot = true;

   size_t offset = 0;
   size_t abcKnotOffset = 0;
   for(size_t j=0;j<pCurveNbVertices->size();j++)
   {
      LONG nbVertices = (LONG)pCurveNbVertices->get()[j];
	  if( nbVertices == 0 ) {
		  continue;
	  }

      NURBSCVCurve *c = new NURBSCVCurve();
      c->SetNumCVs(nbVertices);
      c->SetOrder(nOrder);

      const int nNumMaxKnots = nbVertices + nOrder;
      const int nNumAbcKnots = nbVertices + nOrder - 2;

      c->SetNumKnots(nNumMaxKnots);
      c->SetName("");

      if(bDefaultKnot){
         
         // based on curve type, we do this for linear or closed cubic curves
         if(type == AbcG::kLinear)
         { 
            c->SetNumKnots(nbVertices+2);
            c->SetOrder(2);
            
            c->SetKnot(0, 0.0);
		    for(LONG k=0; k<nbVertices; k++) {
               c->SetKnot(k+1, k);
		    }
            c->SetKnot(nbVertices+1, nbVertices-1);
            //if(wrap == AbcG::kPeriodic){
            //   c->SetKnot(nNumMaxKnots, nNumMaxKnots);
            //}
         }
         else // cubic open
         {
            c->SetKnot(0, 0.0);
            c->SetKnot(1, 0.0);
            c->SetKnot(2, 0.0);<commit_msg>added comment<commit_after>#include "stdafx.h"
#include "AlembicArchiveStorage.h"
#include "AlembicVisibilityController.h"
#include "AlembicLicensing.h"
#include "AlembicNames.h"
#include "Utility.h"
#include "AlembicNurbsUtilities.h"
#include "AlembicMAXScript.h"
#include "AlembicMetadataUtils.h"
#include <surf_api.h> 


bool isAlembicNurbsTopoDynamic( AbcG::IObject *pIObj ) {
	AbcG::ICurves objCurves;

	if(AbcG::ICurves::matches((*pIObj).getMetaData())) {
		objCurves = AbcG::ICurves(*pIObj,Abc::kWrapExisting);
		return ! objCurves.getSchema().getNumVerticesProperty().isConstant();
	}
	return false;
}

bool LoadNurbs(NURBSSet& nset, Abc::P3fArraySamplePtr pCurvePos, Abc::Int32ArraySamplePtr pCurveNbVertices, Abc::FloatArraySamplePtr pKnotVec, AbcG::CurveType type, AbcG::CurvePeriodicity wrap, TimeValue time )
{
   const int nOrder = 4;
   const int numCurves = (int)pCurveNbVertices->size();
   const int numControl = (int)pCurvePos->size();

   const int abcTotalKnots = numControl + numCurves * (nOrder - 2) ;
   const int maxTotalKnots = numControl + numCurves * nOrder;

   //ESS_LOG_WARNING("abcTotalKnots: "<<abcTotalKnots);
   //ESS_LOG_WARNING("maxTotalKnots: "<<maxTotalKnots);
   //ESS_LOG_WARNING("knotVecSize: "<<pKnotVec->size());

   bool bDefaultKnot = false;
   if(pKnotVec){
      if( abcTotalKnots == pKnotVec->size() ){
         
      }
      else if( maxTotalKnots == pKnotVec->size() ){
         ESS_LOG_WARNING("3DS Max knot vector format not supported. Using Default knot vector.");
         bDefaultKnot = true;
      }
      else{
         ESS_LOG_WARNING("Knot vector has the wrong size. Using Default knot vector.");
         bDefaultKnot = true;      
      }
   }
   else{
      ESS_LOG_WARNING("Knot vector not found. Using Default knot vector.");
      bDefaultKnot = true;
   }

   //bDefaultKnot = true;

   size_t offset = 0;
   size_t abcKnotOffset = 0;
   for(size_t j=0;j<pCurveNbVertices->size();j++)
   {
      LONG nbVertices = (LONG)pCurveNbVertices->get()[j];
	  if( nbVertices == 0 ) {
		  continue;
	  }

      NURBSCVCurve *c = new NURBSCVCurve();
      c->SetNumCVs(nbVertices);
      c->SetOrder(nOrder);

      const int nNumMaxKnots = nbVertices + nOrder;
      const int nNumAbcKnots = nbVertices + nOrder - 2;

      c->SetNumKnots(nNumMaxKnots);
      c->SetName("");

      if(bDefaultKnot){
         
         // based on curve type, we do this for linear or closed cubic curves
         if(type == AbcG::kLinear)
         { 
            c->SetNumKnots(nbVertices+2);
            c->SetOrder(2);
            
            c->SetKnot(0, 0.0);
		    for(LONG k=0; k<nbVertices; k++) {
               c->SetKnot(k+1, k);
		    }
            c->SetKnot(nbVertices+1, nbVertices-1);

            //Not sure how to interpret the periodic attribute
            //if(wrap == AbcG::kPeriodic){
            //   c->SetKnot(nNumMaxKnots, nNumMaxKnots);
            //}
         }
         else // cubic open
         {
            c->SetKnot(0, 0.0);
            c->SetKnot(1, 0.0);
            c->SetKnot(2, 0.0);
{'fraction_non_alphanumeric': 0.13331138907175774, 'fraction_numerical': 0.009545753785385122, 'mean_word_length': 2.76751394916305, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 45, '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': '3593143', 'n_tokens_mistral': 2312, 'n_tokens_neox': 2224, 'n_words': 416}