Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions core/opengate_core/opengate_core.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,8 @@ void init_GateWeightedEdepActor(py::module &);

void init_GateActorManager(py::module &);

void init_GateInternalActions(py::module &m);

// Gate filters
void init_GateVFilter(py::module &);

Expand Down Expand Up @@ -567,6 +569,7 @@ PYBIND11_MODULE(opengate_core, m) {
init_GateVActor(m);
init_GateWeightedEdepActor(m);
init_GateActorManager(m);
init_GateInternalActions(m);
init_GateVFilter(m);
init_GateParticleFilter(m);
init_GatePrimaryScatterFilter(m);
Expand Down
1 change: 1 addition & 0 deletions core/opengate_core/opengate_lib/GateInternalActions.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#include "GateInternalActions.h"
18 changes: 18 additions & 0 deletions core/opengate_core/opengate_lib/GateInternalActions.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/* --------------------------------------------------
Copyright (C): OpenGATE Collaboration
This software is distributed under the terms
of the GNU Lesser General Public Licence (LGPL)
See LICENSE.md for further details
-------------------------------------------------- */

#ifndef CORE_OPENGATE_LIB_GATEINTERNALACTIONS_H
#define CORE_OPENGATE_LIB_GATEINTERNALACTIONS_H

#include "GateVActor.h"

class GateInternalActions : public GateVActor {
public:
using GateVActor::GateVActor;
};

#endif
20 changes: 20 additions & 0 deletions core/opengate_core/opengate_lib/pyGateInternalActions.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/* --------------------------------------------------
Copyright (C): OpenGATE Collaboration
This software is distributed under the terms
of the GNU Lesser General Public Licence (LGPL)
See LICENSE.md for further details
-------------------------------------------------- */

#include <pybind11/pybind11.h>
#include <pybind11/stl.h>

namespace py = pybind11;

#include "GateInternalActions.h"

void init_GateInternalActions(py::module &m) {
py::class_<GateInternalActions,
std::unique_ptr<GateInternalActions, py::nodelete>, GateVActor>(
m, "GateInternalActions")
.def(py::init<py::dict &>());
}
24 changes: 24 additions & 0 deletions opengate/actors/base.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from box import Box
from functools import wraps

import opengate_core as g4
from ..definitions import __world_name__
from ..exception import fatal, GateImplementationError
from ..base import GateObject, process_cls
Expand Down Expand Up @@ -611,4 +612,27 @@ def EndSimulationAction(self):
pass


class InternalActions(ActorBase, g4.GateInternalActions):
""" """

def __init__(self, *args, **kwargs):
ActorBase.__init__(self, *args, **kwargs)
self.__initcpp__()

def __initcpp__(self):
g4.GateInternalActions.__init__(self, self.user_info)

def initialize(self):
ActorBase.initialize(self)
self.InitializeUserInfo(self.user_info)
self.InitializeCpp()

def StartSimulationAction(self):
g4.GateInternalActions.StartSimulationAction(self)

def EndSimulationAction(self):
g4.GateInternalActions.EndSimulationAction(self)


process_cls(ActorBase)
process_cls(InternalActions)
9 changes: 8 additions & 1 deletion opengate/managers.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@
VolumeTreeRoot,
)
from .actors.filters import get_filter_class, FilterBase, filter_classes
from .actors.base import ActorBase
from .actors.base import ActorBase, InternalActions

from .actors.doseactors import (
DoseActor,
Expand Down Expand Up @@ -369,6 +369,8 @@ def __init__(self, simulation, *args, **kwargs) -> None:
# dictionary of actor objects. Do not fill manually. Use add_actor() method.
self.actors = {}

self._add_internal_actions()

def __str__(self):
s = "The actor manager contains the following actors: \n"
s += self.dump_actors()
Expand Down Expand Up @@ -474,6 +476,11 @@ def _create_actor(self, actor_type, name):
)
return cls(name=name, simulation=self.simulation)

def _add_internal_actions(self):
name = "_gate_internal_actions"
self.internal_actions = InternalActions(name=name, simulation=self.simulation)
self.add_actor(self.internal_actions, name)


class PhysicsListManager(GateObject):
# Names of the physics constructors that can be created dynamically
Expand Down
Loading