#include "ModelImporter.h"
#include <cadex/LicenseManager_Activate.h>
#include <cadex/Base_UTF16String.hxx>
#include <cadex/ModelData_Model.hxx>
#include <cadex/ModelData_ModelReader.hxx>
#include <cadex/Unigine_NodeFactory.hxx>
#include <cadex/Unigine_NodeFactoryParameters.hxx>
#include <UnigineImport.h>
#include <UnigineFileSystem.h>
#include <../../cadex_license.cxx>
using namespace Unigine;
NodeReferencePtr ModelImporter::ImportViaPlugin (const String theFilePath)
{
String aFilePathNode;
String aFilePath = FileSystem::getAbsolutePath (theFilePath);
ImporterPtr anImporter = Import::createImporterByFileName ("CadExchanger", aFilePath);
if (anImporter) {
anImporter->setParameterDouble ("scale_factor", 1.0);
anImporter->init(aFilePath.get(), ~0);
String aFileName = aFilePath.filename();
String anOutputFolder = String::format ("../data/%s/", aFileName.get());
anImporter->import (anOutputFolder);
aFilePathNode = anImporter->getOutputFilepath();
} else {
Log::error ("Importer not found\n");
return nullptr;
}
if (aFilePathNode.empty()) {
Log::error ("Scene import failure\n");
return nullptr;
}
return NodeReference::create (aFilePathNode);;
}
NodeReferencePtr ModelImporter::ImportViaSDK (const String theFilePath)
{
String aFilePath = FileSystem::getAbsolutePath (theFilePath);
Log::error ("Failed to read the file %s\n", aFilePath.getRaw());
return nullptr;
}
String aFileName = theFilePath.filename();
Base_UTF16String anOutputFolder (String::format (
"../data/%s/", aFileName.get()).get());
return NodeReference::create (aFilePathNode.
ToUTF8().
Data());;
}
const char * Data() const
Returns an internal string buffer.
Definition: Base_String.cxx:151
Defines a Unicode (UTF-16) string wrapping a standard string.
Definition: Base_UTF16String.hxx:34
Base_String ToUTF8() const
Converts to UTF-8 string.
Definition: Base_UTF16String.cxx:138
Provides CAD Exchanger data model.
Definition: ModelData_Model.hxx:43
Reads any format that CAD Exchanger can import.
Definition: ModelData_ModelReader.hxx:33
bool Read(const Base_UTF16String &theFilePath, ModelData_Model &theModel)
Reads the file at the specified path into the specified model.
Definition: ModelData_ModelReader.cxx:182
Creates UNIGINE .node file from ModelData_Model.
Definition: Unigine_NodeFactory.hxx:40
void SetParameters(const Unigine_NodeFactoryParameters &theParameters) const
Sets parameters.
Definition: Unigine_NodeFactory.cxx:133
Base_UTF16String Create(const ModelData_Model &theModel, const Base_UTF16String &theOutputFolder)
Creates UNIGINE .node file from ModelData_Model.
Definition: Unigine_NodeFactory.cxx:112
Defines parameters of the Unigine_NodeFactory.
Definition: Unigine_NodeFactoryParameters.hxx:34
void SetScaleFactor(double theScaleFactor)
Specifies the scale factor of the created node.
Definition: Unigine_NodeFactoryParameters.cxx:184
Defines classes, types, and global functions related to CAD Exchanger.
Definition: A3DSTestLib.hxx:22