// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
#include <string>
#include <stdlib.h>
#include <filesystem>
#include <future>
#include "SimplygonLoader.h"
class CustomErrorHandler : public Simplygon::ErrorHandler
{
public:
void HandleError(Simplygon::spObject object, const char* interfaceName, const char* methodName, Simplygon::rid errorType , const char* errorText) override
{
printf("Error (%s:%s): %s\n", interfaceName, methodName, errorText);
}
} customErrorHandler;
void RunReduction(Simplygon::ISimplygon* sg)
{
// Set the custom error handler to the Simplygon interface.
sg->SetErrorHandler(&customErrorHandler);
// Create the reduction pipeline.
Simplygon::spReductionPipeline sgReductionPipeline = sg->CreateReductionPipeline();
// Start the reduction pipeline with a faulty input file path.
sgReductionPipeline->RunSceneFromFile("Foo.bar", "output.fbx", Simplygon::EPipelineRunMode::RunInNewProcess);
}
void main()
{
Simplygon::ISimplygon* sg = NULL;
Simplygon::EErrorCodes initval = Simplygon::Initialize( &sg );
if( initval != Simplygon::EErrorCodes::NoError )
{
return;
}
RunReduction(sg);
Simplygon::Deinitialize(sg);
}
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
using System;
using System.IO;
using System.Threading.Tasks;
public class CustomErrorHandler : Simplygon.ErrorHandler
{
public override void HandleError(Simplygon.spObject obj, string interfaceName, string methodName, int errorType , string errorText)
{
Console.WriteLine($"Error ({interfaceName}:{methodName}): {errorText}");
}
}
public class Program
{
static private CustomErrorHandler customErrorHandler;
static void RunReduction(Simplygon.ISimplygon sg)
{
// Set the custom error handler to the Simplygon interface.
sg.SetErrorHandler(customErrorHandler);
// Create the reduction pipeline.
using (Simplygon.spReductionPipeline sgReductionPipeline = sg.CreateReductionPipeline())
{
// Start the reduction pipeline with a faulty input file path.
sgReductionPipeline.RunSceneFromFile("Foo.bar", "output.fbx", Simplygon.EPipelineRunMode.RunInNewProcess);
}
}
static void Main(string[] args)
{
using (var sg = Simplygon.Loader.InitSimplygon(out var errorCode, out var errorMessage))
{
if (errorCode != Simplygon.EErrorCodes.NoError)
return;
customErrorHandler = new CustomErrorHandler();
RunReduction(sg);
}
}
}
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
import math
import os
import sys
import glob
import gc
import threading
from pathlib import Path
from simplygon import simplygon_loader
from simplygon import Simplygon
class CustomErrorHandler(Simplygon.ErrorHandler):
def HandleError(self, object: Simplygon.spObject, interfaceName: str, methodName: str, errorType: int, errorText: str):
print("Error (%s:%s): %s" %(interfaceName, methodName, errorText))
customErrorHandler = CustomErrorHandler()
def RunReduction(sg: Simplygon.ISimplygon):
# Set the custom error handler to the Simplygon interface.
sg.SetErrorHandler(customErrorHandler)
# Create the reduction pipeline.
sgReductionPipeline = sg.CreateReductionPipeline()
# Start the reduction pipeline with a faulty input file path.
sgReductionPipeline.RunSceneFromFile("Foo.bar", "output.fbx", Simplygon.EPipelineRunMode_RunInNewProcess)
if __name__ == '__main__':
sg = simplygon_loader.init_simplygon()
RunReduction(sg)
sg = None
gc.collect()