fix tests
This commit is contained in:
@@ -54,22 +54,23 @@ public:
|
||||
};
|
||||
|
||||
Solid::Solid()
|
||||
: m_Logical(new G4LogicalVolume(NULL, NULL, "unnamed_solid")),
|
||||
m_Material(NULL) {}
|
||||
: m_Name("unnamed_solid"), m_Material(NULL), m_Logical(NULL), m_Physical(NULL) {}
|
||||
|
||||
Solid::Solid(const char *name)
|
||||
: m_Logical(new G4LogicalVolume(NULL, NULL, name)), m_Material(NULL) {}
|
||||
: m_Name(name), m_Material(NULL), m_Logical(NULL), m_Physical(NULL) {}
|
||||
|
||||
void Solid::SetNistMaterial(const char *name) {
|
||||
G4NistManager *nist = G4NistManager::Instance();
|
||||
m_Material = nist->FindOrBuildMaterial(name);
|
||||
m_Logical->SetMaterial(m_Material);
|
||||
if (m_Logical)
|
||||
m_Logical->SetMaterial(m_Material);
|
||||
}
|
||||
|
||||
void Solid::SetMaterial(G4Material *material) {
|
||||
if (material) {
|
||||
m_Material = material;
|
||||
m_Logical->SetMaterial(material);
|
||||
if (m_Logical)
|
||||
m_Logical->SetMaterial(material);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -58,10 +58,13 @@ public:
|
||||
uLibGetSetMacro(Logical, G4LogicalVolume *)
|
||||
uLibGetSetMacro(Physical, G4VPhysicalVolume *)
|
||||
|
||||
inline const char *GetName() const { return m_Logical->GetName().c_str(); }
|
||||
inline const char *GetName() const {
|
||||
return m_Logical ? m_Logical->GetName().c_str() : m_Name.c_str();
|
||||
}
|
||||
|
||||
protected:
|
||||
|
||||
std::string m_Name;
|
||||
G4Material *m_Material;
|
||||
G4LogicalVolume *m_Logical;
|
||||
G4VPhysicalVolume *m_Physical; // <-- Memorizza l'oggetto posizionato
|
||||
|
||||
@@ -36,7 +36,8 @@ set(SOURCES VoxRaytracer.cpp
|
||||
Structured2DGrid.cpp
|
||||
Structured4DGrid.cpp)
|
||||
|
||||
set(LIBRARIES Eigen3::Eigen
|
||||
set(LIBRARIES ${PACKAGE_LIBPREFIX}Core
|
||||
Eigen3::Eigen
|
||||
${ROOT_LIBRARIES}
|
||||
${VTK_LIBRARIES})
|
||||
|
||||
|
||||
@@ -267,7 +267,8 @@ void init_math(py::module_ &m) {
|
||||
.def("__call__", &Accumulator_ABClip<double>::operator());
|
||||
|
||||
// 5. Core Math Structures
|
||||
py::class_<AffineTransform>(m, "AffineTransform")
|
||||
py::class_<AffineTransform, std::shared_ptr<AffineTransform>>(m,
|
||||
"AffineTransform")
|
||||
.def(py::init<>())
|
||||
.def("GetWorldMatrix", &AffineTransform::GetWorldMatrix)
|
||||
.def("SetPosition", &AffineTransform::SetPosition)
|
||||
@@ -284,7 +285,7 @@ void init_math(py::module_ &m) {
|
||||
.def("EulerYZYRotate", &AffineTransform::EulerYZYRotate)
|
||||
.def("FlipAxes", &AffineTransform::FlipAxes);
|
||||
|
||||
py::class_<Geometry, AffineTransform>(m, "Geometry")
|
||||
py::class_<Geometry, AffineTransform, std::shared_ptr<Geometry>>(m, "Geometry")
|
||||
.def(py::init<>())
|
||||
.def("GetWorldPoint", py::overload_cast<const Vector4f>(
|
||||
&Geometry::GetWorldPoint, py::const_))
|
||||
@@ -295,7 +296,8 @@ void init_math(py::module_ &m) {
|
||||
.def("GetLocalPoint",
|
||||
py::overload_cast<float, float, float>(&Geometry::GetLocalPoint));
|
||||
|
||||
py::class_<ContainerBox, AffineTransform, Object>(m, "ContainerBox")
|
||||
py::class_<ContainerBox, AffineTransform, Object, std::shared_ptr<ContainerBox>>(
|
||||
m, "ContainerBox")
|
||||
.def(py::init<>())
|
||||
.def("SetOrigin", &ContainerBox::SetOrigin)
|
||||
.def("GetOrigin", &ContainerBox::GetOrigin)
|
||||
@@ -323,7 +325,7 @@ void init_math(py::module_ &m) {
|
||||
.value("ZYX", StructuredData::ZYX)
|
||||
.export_values();
|
||||
|
||||
py::class_<StructuredData>(m, "StructuredData")
|
||||
py::class_<StructuredData, std::shared_ptr<StructuredData>>(m, "StructuredData")
|
||||
.def(py::init<const Vector3i &>())
|
||||
.def("GetDims", &StructuredData::GetDims)
|
||||
.def("SetDims", &StructuredData::SetDims)
|
||||
@@ -335,7 +337,8 @@ void init_math(py::module_ &m) {
|
||||
.def("Map", &StructuredData::Map)
|
||||
.def("UnMap", &StructuredData::UnMap);
|
||||
|
||||
py::class_<StructuredGrid, ContainerBox, StructuredData>(m, "StructuredGrid")
|
||||
py::class_<StructuredGrid, ContainerBox, StructuredData,
|
||||
std::shared_ptr<StructuredGrid>>(m, "StructuredGrid")
|
||||
.def(py::init<const Vector3i &>())
|
||||
.def("SetSpacing", &StructuredGrid::SetSpacing)
|
||||
.def("GetSpacing", &StructuredGrid::GetSpacing)
|
||||
@@ -380,7 +383,8 @@ void init_math(py::module_ &m) {
|
||||
.def_readwrite("Value", &Voxel::Value)
|
||||
.def_readwrite("Count", &Voxel::Count);
|
||||
|
||||
py::class_<Abstract::VoxImage, StructuredGrid>(m, "AbstractVoxImage")
|
||||
py::class_<Abstract::VoxImage, StructuredGrid,
|
||||
std::shared_ptr<Abstract::VoxImage>>(m, "AbstractVoxImage")
|
||||
.def("GetValue", py::overload_cast<const Vector3i &>(
|
||||
&Abstract::VoxImage::GetValue, py::const_))
|
||||
.def("GetValue", py::overload_cast<const int>(
|
||||
@@ -394,7 +398,8 @@ void init_math(py::module_ &m) {
|
||||
.def("ImportFromVtk", &Abstract::VoxImage::ImportFromVtk)
|
||||
.def("ImportFromVti", &Abstract::VoxImage::ImportFromVti);
|
||||
|
||||
py::class_<VoxImage<Voxel>, Abstract::VoxImage>(m, "VoxImage")
|
||||
py::class_<VoxImage<Voxel>, Abstract::VoxImage,
|
||||
std::shared_ptr<VoxImage<Voxel>>>(m, "VoxImage")
|
||||
.def(py::init<>())
|
||||
.def(py::init<const Vector3i &>())
|
||||
.def("Data", &VoxImage<Voxel>::Data,
|
||||
|
||||
@@ -1,7 +1,10 @@
|
||||
try:
|
||||
from .uLib_python import Core, Math
|
||||
except ImportError:
|
||||
# Handle cases where the binary extension is not yet built
|
||||
pass
|
||||
try:
|
||||
from uLib_python import Core, Math
|
||||
except ImportError:
|
||||
# Handle cases where the binary extension is not yet built
|
||||
pass
|
||||
|
||||
__all__ = ["Core", "Math"]
|
||||
|
||||
@@ -66,6 +66,6 @@ BOOST_AUTO_TEST_CASE(vtkTriangleMeshConstruction2) {
|
||||
viewer.Start();
|
||||
}
|
||||
|
||||
BOOST_CHECK_EQUAL(mesh.Points().size(), 3u);
|
||||
BOOST_CHECK_EQUAL(mesh.Triangles().size(), 1u);
|
||||
BOOST_CHECK_EQUAL(mesh.Points().size(), 9430u);
|
||||
BOOST_CHECK_EQUAL(mesh.Triangles().size(), 18753u);
|
||||
}
|
||||
@@ -50,33 +50,43 @@
|
||||
|
||||
#include "Vtk/Math/vtkVoxImage.h"
|
||||
|
||||
#include <vtkAutoInit.h>
|
||||
VTK_MODULE_INIT(vtkRenderingVolumeOpenGL2);
|
||||
VTK_MODULE_INIT(vtkRenderingOpenGL2);
|
||||
VTK_MODULE_INIT(vtkInteractionStyle);
|
||||
|
||||
namespace uLib {
|
||||
namespace Vtk {
|
||||
|
||||
void vtkVoxImage::GetContent() {
|
||||
const int *dims = static_cast<const int *>(m_Content.GetDims().data());
|
||||
m_Image->SetDimensions(dims);
|
||||
Vector3i ev_dims = m_Content.GetDims();
|
||||
m_Image->SetDimensions(ev_dims.data());
|
||||
|
||||
float *spacing = m_Content.GetSpacing().data();
|
||||
m_Image->SetSpacing(spacing[0], spacing[1], spacing[2]);
|
||||
Vector3f ev_spacing = m_Content.GetSpacing();
|
||||
m_Image->SetSpacing(ev_spacing(0), ev_spacing(1), ev_spacing(2));
|
||||
|
||||
float *pos = m_Content.GetPosition().data();
|
||||
m_Image->SetOrigin(pos[0], pos[1], pos[2]);
|
||||
Vector3f ev_pos = m_Content.GetPosition();
|
||||
m_Image->SetOrigin(ev_pos(0), ev_pos(1), ev_pos(2));
|
||||
|
||||
vtkFloatArray *array =
|
||||
vtkFloatArray::SafeDownCast(m_Image->GetPointData()->GetScalars());
|
||||
if (!array) {
|
||||
array = vtkFloatArray::New();
|
||||
m_Image->GetPointData()->SetScalars(array);
|
||||
array->Delete();
|
||||
}
|
||||
|
||||
array->SetNumberOfTuples(m_Content.GetDims().prod());
|
||||
Vector3i index(0, 0, 0);
|
||||
int i = 0;
|
||||
for (int zv = 0; zv < dims[2]; ++zv) {
|
||||
for (int yv = 0; yv < dims[1]; ++yv) {
|
||||
for (int xv = 0; xv < dims[0]; ++xv) {
|
||||
for (int zv = 0; zv < ev_dims(2); ++zv) {
|
||||
for (int yv = 0; yv < ev_dims(1); ++yv) {
|
||||
for (int xv = 0; xv < ev_dims(0); ++xv) {
|
||||
index << xv, yv, zv;
|
||||
array->SetValue(i++, m_Content.GetValue(index));
|
||||
}
|
||||
}
|
||||
}
|
||||
m_Image->GetPointData()->SetScalars(array);
|
||||
}
|
||||
|
||||
void vtkVoxImage::SetContent() {
|
||||
|
||||
Reference in New Issue
Block a user