BioDynaMo
v1.05.120-25dc9790
core
operation
visualization_op.h
Go to the documentation of this file.
1
// -----------------------------------------------------------------------------
2
//
3
// Copyright (C) 2021 CERN & University of Surrey for the benefit of the
4
// BioDynaMo collaboration. All Rights Reserved.
5
//
6
// Licensed under the Apache License, Version 2.0 (the "License");
7
// you may not use this file except in compliance with the License.
8
//
9
// See the LICENSE file distributed with this work for details.
10
// See the NOTICE file distributed with this work for additional information
11
// regarding copyright ownership.
12
//
13
// -----------------------------------------------------------------------------
14
15
#ifndef CORE_OPERATION_VISUALIZATION_OP_H_
16
#define CORE_OPERATION_VISUALIZATION_OP_H_
17
18
#include "
core/operation/operation.h
"
19
#include "
core/operation/operation_registry.h
"
20
#include "
core/param/param.h
"
21
#include "
core/simulation.h
"
22
#include "
core/visualization/visualization_adaptor.h
"
23
24
namespace
bdm
{
25
26
class
VisualizationOp
:
public
StandaloneOperationImpl
{
27
BDM_OP_HEADER
(
VisualizationOp
);
28
29
public
:
30
~VisualizationOp
()
override
{
31
if
(
visualization_
) {
32
delete
visualization_
;
33
}
34
}
35
36
void
Initialize
() {
37
auto
* param =
Simulation::GetActive
()->
GetParam
();
38
visualization_
=
VisualizationAdaptor::Create
(param->visualization_engine);
39
initialized_
=
true
;
40
}
41
42
void
operator()
()
override
{
43
// Cannot be done in constructor because no Simulation object will be
44
// available when VisualizationOp prototype gets created.
45
if
(!
initialized_
) {
46
Initialize
();
47
}
48
if
(
visualization_
!=
nullptr
) {
49
visualization_
->
Visualize
();
50
}
51
}
52
53
private
:
54
VisualizationAdaptor
*
visualization_
=
nullptr
;
55
bool
initialized_
=
false
;
56
};
57
58
}
// namespace bdm
59
60
#endif // CORE_OPERATION_VISUALIZATION_OP_H_
bdm
Definition:
agent.cc:39
operation.h
bdm::VisualizationAdaptor
Definition:
visualization_adaptor.h:22
bdm::VisualizationOp::~VisualizationOp
~VisualizationOp() override
Definition:
visualization_op.h:30
bdm::VisualizationOp::visualization_
VisualizationAdaptor * visualization_
Definition:
visualization_op.h:54
bdm::VisualizationOp::initialized_
bool initialized_
Definition:
visualization_op.h:55
operation_registry.h
bdm::VisualizationOp::operator()
void operator()() override
Definition:
visualization_op.h:42
bdm::VisualizationOp::BDM_OP_HEADER
BDM_OP_HEADER(VisualizationOp)
bdm::VisualizationAdaptor::Visualize
virtual void Visualize()=0
bdm::VisualizationOp::Initialize
void Initialize()
Definition:
visualization_op.h:36
simulation.h
bdm::Simulation::GetParam
const Param * GetParam() const
Returns the simulation parameters.
Definition:
simulation.cc:254
bdm::VisualizationAdaptor::Create
static VisualizationAdaptor * Create(const std::string &adaptor)
Definition:
visualization_adaptor.cc:35
param.h
bdm::Simulation::GetActive
static Simulation * GetActive()
This function returns the currently active Simulation simulation.
Definition:
simulation.cc:68
bdm::VisualizationOp
Definition:
visualization_op.h:26
bdm::StandaloneOperationImpl
Interface for implementing an operation that should run on a GPU.
Definition:
operation.h:86
visualization_adaptor.h
Generated by
1.8.17