This code sample shows how to align scans using the SDK and store the results into an Artec Studio project. It performs in sequence the following operations:
#ifdef _MSC_VER
#define _CRT_SECURE_NO_WARNINGS 1
#endif // _MSC_VER 
#include <boost/atomic.hpp>
#include <boost/thread.hpp>
#include <iomanip>
#include <iostream>
#include <string>
#include <stdlib.h>
#define SDK_STRINGIFY(x) #x
#define SDK_STRING(x) SDK_STRINGIFY(x)
#define SAFE_SDK_CALL(x)                                                    \
{                                                                           \
    base::ErrorCode ec = (x);                                               \
    if ( ec != base::ErrorCode_OK )                                         \
    {                                                                       \
        reportError( ec, __FILE__ " [ line " SDK_STRING(__LINE__) " ]");    \
        return ec;                                                          \
    }                                                                       \
}
void printUsage()
{
    std::cout << "Usage:" << '\n';
    std::cout << " project-sample.exe input_project_path output_project_path" << '\n';
    std::cout << '\n';
    std::cout << "  input_project_path \t path to a valid ArteŃ Studio project which must exist" << '\n';
    std::cout << "  output_project_path \t path to the destination project which must NOT exist" << '\n';
    std::cout << '\n';
    std::cout << "Example:" << '\n';
    std::cout << " project-sample.exe C:\\project1\\project1.sproj C:\\processed\\processed.sproj" << std::endl;
    std::cout << '\n';
}
std::wstring stringToWString(const std::string& src)
{
    std::wstring result(src.length(), L' ');
    mbstowcs(&result[0], src.c_str(), src.length());
    return result;
}
{
    const char* msg = "No error";
    switch (ec)
    {
        msg = "Not enough storage is available to process the operation";
        break;
        msg = "Provided argument is invalid";
        break;
        msg = "Requested operation is invalid";
        break;
        msg = "Data format is unsupported or invalid";
        break;
        msg = "Requested scanner is not connected";
        break;
        msg = "Requested scanner is not licensed";
        break;
        msg = "Requested scanner is already used by someone else";
        break;
        msg = "Scanner initialization failed";
        break;
        msg = "Frame is corrupted";
        break;
        msg = "Frame reconstruction failed";
        break;
        msg = "Frame registration failed";
        break;
        msg = "Requested operation is unsupported. Check versions";
        break;
        msg = "Requested operation is denied. Check your license(s)";
        break;
        msg = "Requested operation has failed";
        break;
        msg = "Requested operation was canceled from client's side";
        break;
        msg = "Unable to start algorithm because input data turned out to be invalid. Please rescan the object.";
        break;
    default:
        msg = "Unexplained error";
        break;
    }
    std::cerr << msg << " [error " << std::hex << ec << "] " << "at " << place << std::endl;
}
{
public:
    SleepingObserver()
    : done_(false)
    {
    }
    {
        result_ = result;
        done_ = true;
    }
    void waitForCompletion() const
    {
        while (!done_)
        {
            boost::this_thread::yield();
        }
    }
    {
        return result_;
    }
private:
    boost::atomic<bool> done_;
}; 
{
    if (!observer)
    {
    }
    *observer = new SleepingObserver;
}
{
public:
    SimpleConsoleProgress(const char* name)
    : name_(name)
    {
    }
private:
    void report(
int current, 
int total)
 override 
    {
        std::cout << name_ << ": " << current << " of " << total << std::endl;
    }
    void pulse() override {}
private:
    const std::string name_;
}; 
{
    
    SimpleConsoleProgress* const progress = new SimpleConsoleProgress(jobName);
    createSleepingObserver(&observer);
    
    observer->waitForCompletion();
    return observer->getResult();
}
{
    
    const int numScansToLoad = 2;
    int numScans = 0;
    for (int i = 0; i < numEntries && numScans < numScansToLoad; ++i)
    {
        SAFE_SDK_CALL(project->
getEntry(i, &entry));
        {
            ++numScans;
        }
    }
    
    if (numScans < numScansToLoad)
    {
        std::cerr << "Not enough scans to align." << std::endl;
    }
    
    SAFE_SDK_CALL(runJobAsynchronously(nullptr, *pModel, loader, "Loading scans"));
}
{
    
    const int numScans = model->
getSize();
 
    for (int i = 0; i < numScans; ++i)
    {
        const int numFrames = scan->
getSize();
 
        for (int j = 0; j < numFrames; ++j)
        {
        }
    }
    
    
    {
        SAFE_SDK_CALL(runJobAsynchronously(model, targetModel, autoAlignAlgorithm, "Auto-aligning"));
    }
    
    if (secondScanTransformationAfter == secondScanTransformationBefore)
    {
        std::cerr << "No alignment happened." << std::endl;
    }
}
{
    
    {
        SAFE_SDK_CALL(runJobAsynchronously(model, registrationTargetModel, registrationAlgorithm, "Global registration"));
    }
    
    {
        SAFE_SDK_CALL(runJobAsynchronously(registrationTargetModel, targetModel, fastFusionAlgorithm, "Fast fusion"));
    }
    
    if (compositeContainer == NULL || compositeContainer->
getSize() < 1)
 
    {
        std::cerr << "No model mesh created." << std::endl;
    }
}
{
    saveSettings.
path = projectDstPath;
    SAFE_SDK_CALL(project->
createSaver(&saver, &saveSettings));
    SAFE_SDK_CALL(runJobAsynchronously(model, nullptr, saver, "Saving project"));
}
int main(int argc, char** argv)
{
    if (argc < 3)
    {
        printUsage();
        return -1;
    }
    const std::wstring srcProjectPath = stringToWString(argv[1]);
    {
        std::cerr << "Failed to load input data. Exiting..." << std::endl;
        return 1;
    }
    {
        std::cerr << "Auto-alignment failed. Exiting..." << std::endl;
        return 1;
    }
    {
        std::cerr << "3D mesh model creation failed. Exiting..." << std::endl;
        return 1;
    }
    const std::wstring dstProjectPath = stringToWString(argv[2]);
    if (saveModelAsProject(fusionTargetModel, srcProject, dstProjectPath.c_str()) != 
base::ErrorCode_OK)
 
    {
        std::cerr << "Project saving failed. Exiting..." << std::endl;
        return 1;
    }
    return 0;
}