1/*
2---------------------------------------------------------------------------
3Open Asset Import Library (assimp)
4---------------------------------------------------------------------------
5
6Copyright (c) 2006-2017, assimp team
7
8
9All rights reserved.
10
11Redistribution and use of this software in source and binary forms,
12with or without modification, are permitted provided that the following
13conditions are met:
14
15* Redistributions of source code must retain the above
16 copyright notice, this list of conditions and the
17 following disclaimer.
18
19* Redistributions in binary form must reproduce the above
20 copyright notice, this list of conditions and the
21 following disclaimer in the documentation and/or other
22 materials provided with the distribution.
23
24* Neither the name of the assimp team, nor the names of its
25 contributors may be used to endorse or promote products
26 derived from this software without specific prior
27 written permission of the assimp team.
28
29THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
30"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
31LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
32A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
33OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
34SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
35LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
36DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
37THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
38(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
39OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
40---------------------------------------------------------------------------
41*/
42
43/** @file Implementation of BaseProcess */
44
45#include "BaseImporter.h"
46#include "BaseProcess.h"
47#include <assimp/DefaultLogger.hpp>
48#include <assimp/scene.h>
49#include "Importer.h"
50
51using namespace Assimp;
52
53// ------------------------------------------------------------------------------------------------
54// Constructor to be privately used by Importer
55BaseProcess::BaseProcess()
56: shared()
57, progress()
58{
59}
60
61// ------------------------------------------------------------------------------------------------
62// Destructor, private as well
63BaseProcess::~BaseProcess()
64{
65 // nothing to do here
66}
67
68// ------------------------------------------------------------------------------------------------
69void BaseProcess::ExecuteOnScene( Importer* pImp)
70{
71 ai_assert(NULL != pImp && NULL != pImp->Pimpl()->mScene);
72
73 progress = pImp->GetProgressHandler();
74 ai_assert(progress);
75
76 SetupProperties( pImp );
77
78 // catch exceptions thrown inside the PostProcess-Step
79 try
80 {
81 Execute(pImp->Pimpl()->mScene);
82
83 } catch( const std::exception& err ) {
84
85 // extract error description
86 pImp->Pimpl()->mErrorString = err.what();
87 DefaultLogger::get()->error(pImp->Pimpl()->mErrorString);
88
89 // and kill the partially imported data
90 delete pImp->Pimpl()->mScene;
91 pImp->Pimpl()->mScene = NULL;
92 }
93}
94
95// ------------------------------------------------------------------------------------------------
96void BaseProcess::SetupProperties(const Importer* /*pImp*/)
97{
98 // the default implementation does nothing
99}
100
101// ------------------------------------------------------------------------------------------------
102bool BaseProcess::RequireVerboseFormat() const
103{
104 return true;
105}
106
107