<commit_before>/**
 * \file vtkFbxExporter.cxx
 * 2012-06-01 LB Initial implementation
 * 
 * Implementation of vtkFbxExporter class
 */

// ** INCLUDES **
#include "vtkFbxExporter.h"
#include "vtkFbxConverter.h"

#include "vtkAssemblyNode.h"
#include "vtkAssemblyPath.h"
#include "vtkObjectFactory.h"
#include "vtkRendererCollection.h"
#include "vtkRenderWindow.h"

#include <fbxsdk.h>
#include <QDebug>

#include "../Common.h"

extern FbxManager* lSdkManager;
extern FbxScene* lScene;

vtkStandardNewMacro(vtkFbxExporter);
vtkCxxRevisionMacro(vtkFbxExporter, "$Revision$");

vtkFbxExporter::vtkFbxExporter()
{
	this->DebugOn();
	this->FileName = NULL;
}

vtkFbxExporter::~vtkFbxExporter()
{
	if ( this->FileName )
		delete [] this->FileName;
}

void vtkFbxExporter::WriteData()
{
	// make sure the user specified a FileName or FilePointer
	if (this->FileName == NULL)
	{
		vtkErrorMacro(<< "Please specify FileName to use");
		return;
	}

	// get the renderer
	vtkRenderer *ren = this->RenderWindow->GetRenderers()->GetFirstRenderer();
	
	// make sure it has at least one actor
	if (ren->GetActors()->GetNumberOfItems() < 1)
	{
		vtkErrorMacro(<< "no actors found for writing Fbx file.");
		return;
	}

	// do the actors now
	vtkActor *anActor, *aPart;
	vtkActorCollection *ac = ren->GetActors();
	ac->PrintSelf(std::cout, vtkIndent());
	vtkAssemblyPath *apath;
	vtkCollectionSimpleIterator ait;
	int count = 0;
	for (ac->InitTraversal(ait); (anActor = ac->GetNextActor(ait)); )
  	{
		for (anActor->InitPathTraversal(); (apath=anActor->GetNextPath()); )
		{
			if (anActor->GetMapper() != NULL && anActor->GetVisibility() != 0)
	  		{
	  			aPart=static_cast<vtkActor *>(apath->GetLastNode()->GetViewProp());
	  			VtkFbxConverter converter(aPart, lScene);
        		if(converter.convert())
        		{
        			converter.convertZUpAxis();
        			FbxNode* node = converter.getNode();
	
       				if (node != NULL)
       				{
            			lScene->GetRootNode()->AddChild(node);
            			++count;
            		}
            	}
	  		}
		}
  	} 
	vtkDebugMacro(<< "Fbx converter starts writing file with " << count << " objects.");
	// Possible values for file format:
	//  - FBX 6.0 binary (*.fbx) : works
	//  - FBX 6.0 ascii (*.fbx) : works
	//  - FBX binary (*.fbx) : Out of disk space error
	//  - FBX ascii (*.fbx) : Out of disk space error
	int lFormat = lSdkManager->GetIOPluginRegistry()->FindWriterIDByDescription("FBX 6.0 binary (*.fbx)");
	vtkDebugMacro(<< "Fbx converter finished writing with exit code: " << SaveScene(lSdkManager, lScene, this->FileName, lFormat, true));

    lScene->Clear();
}

void vtkFbxExporter::PrintSelf(ostream& os, vtkIndent indent)
{<commit_msg>Give the exported object a name (the file name).<commit_after>/**
 * \file vtkFbxExporter.cxx
 * 2012-06-01 LB Initial implementation
 * 
 * Implementation of vtkFbxExporter class
 */

// ** INCLUDES **
#include "vtkFbxExporter.h"
#include "vtkFbxConverter.h"

#include "vtkAssemblyNode.h"
#include "vtkAssemblyPath.h"
#include "vtkObjectFactory.h"
#include "vtkRendererCollection.h"
#include "vtkRenderWindow.h"

#include <fbxsdk.h>
#include <QDebug>

#include "../Common.h"

extern FbxManager* lSdkManager;
extern FbxScene* lScene;

vtkStandardNewMacro(vtkFbxExporter);
vtkCxxRevisionMacro(vtkFbxExporter, "$Revision$");

vtkFbxExporter::vtkFbxExporter()
{
	this->DebugOn();
	this->FileName = NULL;
}

vtkFbxExporter::~vtkFbxExporter()
{
	if ( this->FileName )
		delete [] this->FileName;
}

void vtkFbxExporter::WriteData()
{
	// make sure the user specified a FileName or FilePointer
	if (this->FileName == NULL)
	{
		vtkErrorMacro(<< "Please specify FileName to use");
		return;
	}

	// get the renderer
	vtkRenderer *ren = this->RenderWindow->GetRenderers()->GetFirstRenderer();
	
	// make sure it has at least one actor
	if (ren->GetActors()->GetNumberOfItems() < 1)
	{
		vtkErrorMacro(<< "no actors found for writing Fbx file.");
		return;
	}

	// do the actors now
	vtkActor *anActor, *aPart;
	vtkActorCollection *ac = ren->GetActors();
	ac->PrintSelf(std::cout, vtkIndent());
	vtkAssemblyPath *apath;
	vtkCollectionSimpleIterator ait;
	int count = 0;
	for (ac->InitTraversal(ait); (anActor = ac->GetNextActor(ait)); )
  	{
		for (anActor->InitPathTraversal(); (apath=anActor->GetNextPath()); )
		{
			if (anActor->GetMapper() != NULL && anActor->GetVisibility() != 0)
	  		{
	  			aPart=static_cast<vtkActor *>(apath->GetLastNode()->GetViewProp());
	  			VtkFbxConverter converter(aPart, lScene);
				if(converter.convert(this->FileName))
				{
					converter.convertZUpAxis();
					FbxNode* node = converter.getNode();

					if (node != NULL)
					{
						lScene->GetRootNode()->AddChild(node);
						++count;
					}
				}
	  		}
		}
  	} 
	vtkDebugMacro(<< "Fbx converter starts writing file with " << count << " objects.");
	// Possible values for file format:
	//  - FBX 6.0 binary (*.fbx) : works
	//  - FBX 6.0 ascii (*.fbx) : works
	//  - FBX binary (*.fbx) : Out of disk space error
	//  - FBX ascii (*.fbx) : Out of disk space error
	int lFormat = lSdkManager->GetIOPluginRegistry()->FindWriterIDByDescription("FBX 6.0 binary (*.fbx)");
	vtkDebugMacro(<< "Fbx converter finished writing with exit code: " << SaveScene(lSdkManager, lScene, this->FileName, lFormat, true));

    lScene->Clear();
}

void vtkFbxExporter::PrintSelf(ostream& os, vtkIndent indent)
{
{'fraction_non_alphanumeric': 0.15143069490895578, 'fraction_numerical': 0.0063173541434411, 'mean_word_length': 3.8408273381294964, 'pattern_counts': {'":': 0, '<': 39, '<?xml version=': 0, '>': 62, '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': '5189385', 'n_tokens_mistral': 2128, 'n_tokens_neox': 1939, 'n_words': 424}