17 #include "internal/org_mitk_simulation_Activator.h"
23 #include <vtkCellArray.h>
24 #include <vtkLinearTransform.h>
25 #include <vtkPolyData.h>
26 #include <vtkSmartPointer.h>
27 #include <vtkTransformPolyDataFilter.h>
31 mitk::IDataStorageService* dataStorageService = mitk::org_mitk_simulation_Activator::GetService<mitk::IDataStorageService>();
33 if (dataStorageService !=
nullptr)
38 return dataStorageReference->GetDataStorage();
49 if (dataStorage.IsNull())
55 for (mitk::DataStorage::SetOfObjects::ConstIterator it = subset->Begin(); it != subset->End(); ++it)
59 if (dataNode->GetName() == name)
61 typename T::Pointer data =
static_cast<T*
>(dataNode->GetData());
71 mitk::MeshMitkLoader::MeshMitkLoader()
73 this->addAlias(&m_filename,
"dataNode");
74 this->addAlias(&m_filename,
"surface");
77 mitk::MeshMitkLoader::~MeshMitkLoader()
88 vtkPolyData* polyData = surface->GetVtkPolyData();
90 if (polyData ==
nullptr || polyData->GetNumberOfCells() == 0)
99 vtkPolyData* polyData = surface->GetVtkPolyData();
108 sofa::helper::vector<sofa::defaulttype::Vector3>& positions = *this->positions.beginEdit();
109 sofa::helper::vector<Edge>& edges = *this->edges.beginEdit();
110 sofa::helper::vector<Triangle>& triangles = *this->triangles.beginEdit();
111 sofa::helper::vector<Quad>& quads = *this->quads.beginEdit();
112 sofa::helper::vector<sofa::helper::vector<unsigned int> > polygons = *this->polygons.beginEdit();
114 vtkPoints* points = polyData->GetPoints();
115 vtkIdType numPoints = points->GetNumberOfPoints();
118 for (vtkIdType i = 0; i < numPoints; ++i)
120 points->GetPoint(i, point);
121 positions.push_back(sofa::defaulttype::Vec3d(point[0], point[1], point[2]));
124 vtkCellArray* polys = polyData->GetPolys();
125 vtkIdType numPolys = polys->GetNumberOfCells();
131 polys->InitTraversal();
133 while (polys->GetNextCell(poly) != 0)
135 switch (poly->GetNumberOfIds())
141 edge[0] = poly->GetId(0);
142 edge[1] = poly->GetId(1);
144 edges.push_back(edge);
148 triangle[0] = poly->GetId(0);
149 triangle[1] = poly->GetId(1);
150 triangle[2] = poly->GetId(2);
152 triangles.push_back(triangle);
156 quad[0] = poly->GetId(0);
157 quad[1] = poly->GetId(1);
158 quad[2] = poly->GetId(2);
159 quad[3] = poly->GetId(3);
161 quads.push_back(quad);
165 sofa::helper::vector<unsigned int> polygon;
166 vtkIdType numIds = poly->GetNumberOfIds();
168 polygon.reserve(numIds);
170 for (vtkIdType i = 0; i < numIds; ++i)
171 polygon.push_back(poly->GetId(i));
173 polygons.push_back(polygon);
178 this->positions.endEdit();
179 this->edges.endEdit();
180 this->triangles.endEdit();
181 this->quads.endEdit();
182 this->polygons.endEdit();
virtual IDataStorageReference::Pointer GetDefaultDataStorage() const =0
itk::SmartPointer< Self > Pointer
static mitk::DataStorage::Pointer GetDataStorage()
itk::SmartPointer< const Self > ConstPointer
T::Pointer GetData(const std::string &name)
static itkEventMacro(BoundingShapeInteractionEvent, itk::AnyEvent) class MITKBOUNDINGSHAPE_EXPORT BoundingShapeInteractor Pointer New()
Basic interaction methods for mitk::GeometryData.