diff --git a/Modules/Simulation/mitkSimulationDrawTool.cpp b/Modules/Simulation/mitkSimulationDrawTool.cpp index a5d51729ac..ee6221a1da 100644 --- a/Modules/Simulation/mitkSimulationDrawTool.cpp +++ b/Modules/Simulation/mitkSimulationDrawTool.cpp @@ -1,606 +1,619 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #include "mitkSimulation.h" #include "mitkSimulationDrawTool.h" #include #include #include #include #include #include #include #include #include #include #include #include mitk::SimulationDrawTool::SimulationDrawTool() : m_PolygonMode(0), m_Wireframe(false), m_Update(true) { } mitk::SimulationDrawTool::~SimulationDrawTool() { this->DeleteVtkObjects(); } void mitk::SimulationDrawTool::DeleteVtkObjects() { for (std::vector::const_iterator object = m_VtkObjects.begin(); object != m_VtkObjects.end(); ++object) (*object)->Delete(); m_VtkObjects.clear(); for (std::vector::const_iterator actor = m_Actors.begin(); actor != m_Actors.end(); ++actor) (*actor)->Delete(); m_Actors.clear(); } void mitk::SimulationDrawTool::DisableUpdate() { m_Update = false; } std::vector mitk::SimulationDrawTool::GetActors() const { return m_Actors; } void mitk::SimulationDrawTool::InitProperty(vtkProperty* property) const { if (m_Wireframe) property->SetRepresentationToWireframe(); else property->SetRepresentationToSurface(); } void mitk::SimulationDrawTool::Reset() { this->DeleteVtkObjects(); m_Update = true; } void mitk::SimulationDrawTool::drawPoints(const std::vector& points, float pointSize, const Vec4f color) { if (!m_Update || points.empty()) return; unsigned int numPoints = points.size(); vtkPoints* vtkPoints = vtkPoints::New(); vtkPoints->SetNumberOfPoints(numPoints); vtkCellArray* cellArray = vtkCellArray::New(); for (unsigned int i = 0; i < numPoints; ++i) { vtkPoints->SetPoint(i, points[i].elems); cellArray->InsertNextCell(1); cellArray->InsertCellPoint(i); } vtkPolyData* polyData = vtkPolyData::New(); polyData->SetPoints(vtkPoints); polyData->SetVerts(cellArray); vtkPoints->Delete(); cellArray->Delete(); vtkPolyDataMapper* polyDataMapper = vtkPolyDataMapper::New(); polyDataMapper->SetInput(polyData); vtkActor* actor = vtkActor::New(); actor->SetMapper(polyDataMapper); actor->SetScale(Simulation::ScaleFactor); vtkProperty* property = actor->GetProperty(); property->SetColor(color.x(), color.y(), color.z()); property->SetPointSize(pointSize); m_VtkObjects.push_back(polyData); m_VtkObjects.push_back(polyDataMapper); m_Actors.push_back(actor); } void mitk::SimulationDrawTool::drawLines(const std::vector& points, float lineWidth, const Vec4f color) { if (!m_Update || points.empty()) return; unsigned int numPoints = points.size(); std::vector indices; for (unsigned int i = 0; i < numPoints; i += 2) indices.push_back(Vec2i(i, i + 1)); this->drawLines(points, indices, lineWidth, color); } void mitk::SimulationDrawTool::drawLines(const std::vector& points, const std::vector& indices, float lineWidth, const Vec4f color) { if (!m_Update || points.empty()) return; unsigned int numPoints = points.size(); vtkPoints* vtkPoints = vtkPoints::New(); vtkPoints->SetNumberOfPoints(numPoints); for (unsigned int i = 0; i < numPoints; ++i) vtkPoints->SetPoint(i, points[i].elems); vtkPolyData* polyData = vtkPolyData::New(); polyData->SetPoints(vtkPoints); vtkPoints->Delete(); vtkCellArray* lines = vtkCellArray::New(); unsigned int numIndices = indices.size(); for (unsigned int i = 0; i < numIndices; ++i) - lines->InsertNextCell(2, indices[i].elems); + { + lines->InsertNextCell(2); + lines->InsertCellPoint(indices[i].elems[0]); + lines->InsertCellPoint(indices[i].elems[1]); + } polyData->SetLines(lines); lines->Delete(); vtkPolyDataMapper* polyDataMapper = vtkPolyDataMapper::New(); polyDataMapper->SetInput(polyData); vtkActor* actor = vtkActor::New(); actor->SetMapper(polyDataMapper); actor->SetScale(Simulation::ScaleFactor); vtkProperty* property = actor->GetProperty(); property->SetLineWidth(lineWidth); property->SetColor(color.x(), color.y(), color.z()); m_VtkObjects.push_back(polyData); m_VtkObjects.push_back(polyDataMapper); m_Actors.push_back(actor); } void mitk::SimulationDrawTool::drawTriangles(const std::vector& points, const Vec4f color) { if (!m_Update || points.empty()) return; unsigned int numPoints = points.size(); vtkPoints* vtkPoints = vtkPoints::New(); vtkPoints->SetNumberOfPoints(numPoints); for (unsigned int i = 0; i < numPoints; ++i) vtkPoints->SetPoint(i, points[i].elems); vtkPolyData* polyData = vtkPolyData::New(); polyData->SetPoints(vtkPoints); vtkPoints->Delete(); vtkCellArray* triangles = vtkCellArray::New(); for (unsigned int i = 0; i < points.size(); i += 3) { - vtkIdType triangle[] = { i, i + 1, i + 2 }; - triangles->InsertNextCell(3, triangle); + triangles->InsertNextCell(3); + triangles->InsertCellPoint(i); + triangles->InsertCellPoint(i + 1); + triangles->InsertCellPoint(i + 2); } polyData->SetPolys(triangles); triangles->Delete(); vtkPolyDataNormals* polyDataNormals = vtkPolyDataNormals::New(); polyDataNormals->ComputeCellNormalsOff(); polyDataNormals->SetInput(polyData); polyDataNormals->SplittingOff(); vtkPolyDataMapper* polyDataMapper = vtkPolyDataMapper::New(); polyDataMapper->SetInput(polyDataNormals->GetOutput()); vtkActor* actor = vtkActor::New(); actor->SetMapper(polyDataMapper); actor->SetScale(Simulation::ScaleFactor); vtkProperty* property = actor->GetProperty(); this->InitProperty(property); property->SetColor(color.x(), color.y(), color.z()); m_VtkObjects.push_back(polyData); m_VtkObjects.push_back(polyDataMapper); m_VtkObjects.push_back(polyDataNormals); m_Actors.push_back(actor); } void mitk::SimulationDrawTool::drawTriangles(const std::vector& points, const Vector3 normal, const Vec4f color) { if (!m_Update || points.empty()) return; unsigned int numPoints = points.size(); vtkPoints* vtkPoints = vtkPoints::New(); vtkPoints->SetNumberOfPoints(numPoints); for (unsigned int i = 0; i < numPoints; ++i) vtkPoints->SetPoint(i, points[i].elems); vtkPolyData* polyData = vtkPolyData::New(); polyData->SetPoints(vtkPoints); vtkPoints->Delete(); vtkCellArray* triangles = vtkCellArray::New(); for (unsigned int i = 0; i < points.size(); i += 3) { - vtkIdType triangle[] = { i, i + 1, i + 2 }; - triangles->InsertNextCell(3, triangle); + triangles->InsertNextCell(3); + triangles->InsertCellPoint(i); + triangles->InsertCellPoint(i + 1); + triangles->InsertCellPoint(i + 2); } polyData->SetPolys(triangles); triangles->Delete(); vtkFloatArray* normals = vtkFloatArray::New(); normals->SetNumberOfComponents(3); normals->SetName("Normals"); for (int i = 0; i < numPoints; i += 3) normals->InsertNextTuple(normal.elems); polyData->GetCellData()->SetNormals(normals); normals->Delete(); vtkPolyDataMapper* polyDataMapper = vtkPolyDataMapper::New(); polyDataMapper->SetInput(polyData); vtkActor* actor = vtkActor::New(); actor->SetMapper(polyDataMapper); actor->SetScale(Simulation::ScaleFactor); vtkProperty* property = actor->GetProperty(); this->InitProperty(property); property->SetColor(color.x(), color.y(), color.z()); m_VtkObjects.push_back(polyData); m_VtkObjects.push_back(polyDataMapper); m_Actors.push_back(actor); } void mitk::SimulationDrawTool::drawTriangles(const std::vector& points, const std::vector& indices, const std::vector& normals, const Vec4f color) { if (!m_Update || points.empty() || indices.empty() || normals.empty()) return; unsigned int numPoints = points.size(); vtkPoints* vtkPoints = vtkPoints::New(); vtkPoints->SetNumberOfPoints(numPoints); for (unsigned int i = 0; i < numPoints; ++i) vtkPoints->SetPoint(i, points[i].elems); vtkPolyData* polyData = vtkPolyData::New(); polyData->SetPoints(vtkPoints); vtkPoints->Delete(); vtkCellArray* triangles = vtkCellArray::New(); unsigned int numIndices = indices.size(); for (unsigned int i = 0; i < numIndices; ++i) - triangles->InsertNextCell(3, indices[i].elems); + { + triangles->InsertNextCell(3); + triangles->InsertCellPoint(indices[i].elems[0]); + triangles->InsertCellPoint(indices[i].elems[1]); + triangles->InsertCellPoint(indices[i].elems[2]); + } polyData->SetPolys(triangles); triangles->Delete(); unsigned int numNormals = normals.size(); vtkFloatArray* vtkNormals = vtkFloatArray::New(); vtkNormals->SetNumberOfComponents(3); vtkNormals->SetName("Normals"); for (int i = 0; i < numNormals; ++i) vtkNormals->InsertNextTuple(normals[i].elems); polyData->GetCellData()->SetNormals(vtkNormals); vtkNormals->Delete(); vtkPolyDataMapper* polyDataMapper = vtkPolyDataMapper::New(); polyDataMapper->SetInput(polyData); vtkActor* actor = vtkActor::New(); actor->SetMapper(polyDataMapper); actor->SetScale(Simulation::ScaleFactor); vtkProperty* property = actor->GetProperty(); this->InitProperty(property); property->SetColor(color.x(), color.y(), color.z()); m_VtkObjects.push_back(polyData); m_VtkObjects.push_back(polyDataMapper); m_Actors.push_back(actor); } -void mitk::SimulationDrawTool::drawTriangles(const std::vector& points, const std::vector& normals, const std::vector& colors) +void mitk::SimulationDrawTool::drawTriangles(const std::vector&, const std::vector&, const std::vector&) { } -void mitk::SimulationDrawTool::drawTriangleStrip(const std::vector& points, const std::vector& normals, const Vec4f color) +void mitk::SimulationDrawTool::drawTriangleStrip(const std::vector&, const std::vector&, const Vec4f) { } -void mitk::SimulationDrawTool::drawTriangleFan(const std::vector& points, const std::vector& normals, const Vec4f color) +void mitk::SimulationDrawTool::drawTriangleFan(const std::vector&, const std::vector&, const Vec4f) { } void mitk::SimulationDrawTool::drawFrame(const Vector3& position, const Quaternion& orientation, const Vec3f& size) { if (!m_Update) return; const float radius = 0.05f; bool wireframeBackup = m_Wireframe; m_Wireframe = false; std::vector colors; colors.push_back(Vec4f(0.0f, 0.0f, 1.0f, 1.0f)); colors.push_back(Vec4f(0.0f, 1.0f, 0.0f, 1.0f)); colors.push_back(Vec4f(1.0f, 0.0f, 0.0f, 1.0f)); if (size.x() != 0.0f) { Vector3 point2 = position + orientation.rotate(Vec3f(size.x(), 0.0f, 0.0f)); this->drawArrow(position, point2, radius, colors.back()); colors.pop_back(); } if (size.y() != 0.0f) { Vector3 point2 = position + orientation.rotate(Vec3f(0.0f, size.y(), 0.0f)); this->drawArrow(position, point2, radius, colors.back()); colors.pop_back(); } if (size.z() != 0.0f) { Vector3 point2 = position + orientation.rotate(Vec3f(0.0f, 0.0f, size.z())); this->drawArrow(position, point2, radius, colors.back()); } m_Wireframe = wireframeBackup; } void mitk::SimulationDrawTool::drawSpheres(const std::vector& points, const std::vector& radii, const Vec4f color) { if (!m_Update || points.empty()) return; unsigned int numSpheres = points.size(); for (unsigned int i = 0; i < numSpheres; ++i) { vtkSphereSource *sphereSource = vtkSphereSource::New(); sphereSource->SetCenter(const_cast(points[i].elems)); sphereSource->SetRadius(radii[i]); sphereSource->SetPhiResolution(16); sphereSource->SetThetaResolution(32); sphereSource->LatLongTessellationOn(); vtkPolyDataMapper* polyDataMapper = vtkPolyDataMapper::New(); polyDataMapper->SetInput(sphereSource->GetOutput()); vtkActor* actor = vtkActor::New(); actor->SetMapper(polyDataMapper); actor->SetScale(Simulation::ScaleFactor); vtkProperty* property = actor->GetProperty(); this->InitProperty(property); property->SetColor(color.x(), color.y(), color.z()); m_VtkObjects.push_back(sphereSource); m_VtkObjects.push_back(polyDataMapper); m_Actors.push_back(actor); } } void mitk::SimulationDrawTool::drawSpheres(const std::vector& points, float radius, const Vec4f color) { if (!m_Update || points.empty()) return; unsigned int numPoints = points.size(); std::vector radii(numPoints, radius); this->drawSpheres(points, radii, color); } void mitk::SimulationDrawTool::drawCone(const Vector3& point1, const Vector3& point2, float radius1, float radius2, const Vec4f color, int subdivisions) { if (!m_Update) return; vtkPoints* points = vtkPoints::New(); points->SetNumberOfPoints(2); points->SetPoint(0, point1.elems); points->SetPoint(1, point2.elems); vtkCellArray* line = vtkCellArray::New(); line->InsertNextCell(2); line->InsertCellPoint(0); line->InsertCellPoint(1); vtkPolyData* polyData = vtkPolyData::New(); polyData->SetPoints(points); polyData->SetLines(line); points->Delete(); line->Delete(); const char* radiiName = "Radii"; vtkFloatArray* radii = vtkFloatArray::New(); radii->SetName(radiiName); radii->SetNumberOfTuples(2); radii->SetTuple1(0, radius1); radii->SetTuple1(1, radius2); vtkPointData* pointData = polyData->GetPointData(); pointData->AddArray(radii); pointData->SetActiveScalars(radiiName); radii->Delete(); vtkTubeFilter* tubeFilter = vtkTubeFilter::New(); tubeFilter->SetInput(polyData); tubeFilter->CappingOn(); tubeFilter->SetNumberOfSides(subdivisions); tubeFilter->SetVaryRadiusToVaryRadiusByAbsoluteScalar(); vtkPolyDataMapper* polyDataMapper = vtkPolyDataMapper::New(); polyDataMapper->SetInput(tubeFilter->GetOutput()); polyDataMapper->ScalarVisibilityOff(); vtkActor* actor = vtkActor::New(); actor->SetMapper(polyDataMapper); actor->SetScale(Simulation::ScaleFactor); vtkProperty* property = actor->GetProperty(); this->InitProperty(property); property->SetColor(color.x(), color.y(), color.z()); m_VtkObjects.push_back(polyData); m_VtkObjects.push_back(tubeFilter); m_VtkObjects.push_back(polyDataMapper); m_Actors.push_back(actor); } -void mitk::SimulationDrawTool::drawCube(const float& edgeRadius, const Vec4f& color, const int& subdivisions) +void mitk::SimulationDrawTool::drawCube(const float&, const Vec4f&, const int&) { } void mitk::SimulationDrawTool::drawCylinder(const Vector3& point1, const Vector3& point2, float radius, const Vec4f color, int subdivisions) { if (!m_Update) return; this->drawCone(point1, point2, radius, radius, color, subdivisions); } void mitk::SimulationDrawTool::drawArrow(const Vector3& point1, const Vector3& point2, float radius, const Vec4f color, int subdivisions) { if (!m_Update) return; Vector3 point3 = point1 * 0.2f + point2 * 0.8f; this->drawCylinder(point1, point3, radius, color, subdivisions); this->drawCone(point3, point2, radius * 2.5f, 0.0f, color, subdivisions); } void mitk::SimulationDrawTool::drawPlus(const float& edgeRadius, const Vec4f& color, const int& subdivisions) { if (!m_Update) return; this->drawCylinder(Vector3(-1.0, 0.0, 0.0), Vector3(1.0, 0.0, 0.0), edgeRadius, color, subdivisions); this->drawCylinder(Vector3(0.0, -1.0, 0.0), Vector3(0.0, 1.0, 0.0), edgeRadius, color, subdivisions); this->drawCylinder(Vector3(0.0, 0.0, -1.0), Vector3(0.0, 0.0, 1.0), edgeRadius, color, subdivisions); } -void mitk::SimulationDrawTool::drawPoint(const Vector3& position, const Vec4f& color) +void mitk::SimulationDrawTool::drawPoint(const Vector3&, const Vec4f&) { } -void mitk::SimulationDrawTool::drawPoint(const Vector3& position, const Vector3& normal, const Vec4f& color) +void mitk::SimulationDrawTool::drawPoint(const Vector3&, const Vector3&, const Vec4f&) { } -void mitk::SimulationDrawTool::drawTriangle(const Vector3& point1, const Vector3& point2, const Vector3& point3, const Vector3& normal, const Vec4f& color) +void mitk::SimulationDrawTool::drawTriangle(const Vector3&, const Vector3&, const Vector3&, const Vector3&, const Vec4f&) { } -void mitk::SimulationDrawTool::drawTriangle(const Vector3& point1, const Vector3& point2, const Vector3& point3, const Vector3& normal, const Vec4f& color1, const Vec4f& color2, const Vec4f& color3) +void mitk::SimulationDrawTool::drawTriangle(const Vector3&, const Vector3&, const Vector3&, const Vector3&, const Vec4f&, const Vec4f&, const Vec4f&) { } -void mitk::SimulationDrawTool::drawSphere(const Vector3& position, float radius) +void mitk::SimulationDrawTool::drawSphere(const Vector3&, float) { } void mitk::SimulationDrawTool::pushMatrix() { } void mitk::SimulationDrawTool::popMatrix() { } -void mitk::SimulationDrawTool::multMatrix(float* matrix) +void mitk::SimulationDrawTool::multMatrix(float*) { } -void mitk::SimulationDrawTool::scale(float factor) +void mitk::SimulationDrawTool::scale(float) { } -void mitk::SimulationDrawTool::setMaterial(const Vec4f& color, std::string name) +void mitk::SimulationDrawTool::setMaterial(const Vec4f&, std::string) { } -void mitk::SimulationDrawTool::resetMaterial(const Vec4f& color, std::string name) +void mitk::SimulationDrawTool::resetMaterial(const Vec4f&, std::string) { } void mitk::SimulationDrawTool::setPolygonMode(int mode, bool wireframe) { if (!m_Update) return; m_PolygonMode = mode; m_Wireframe = wireframe; } -void mitk::SimulationDrawTool::setLightingEnabled(bool isEnabled) +void mitk::SimulationDrawTool::setLightingEnabled(bool) { } void mitk::SimulationDrawTool::clear() { } diff --git a/Modules/Simulation/mitkSimulationModel.cpp b/Modules/Simulation/mitkSimulationModel.cpp index 6dc14fe952..0da8b91eb0 100644 --- a/Modules/Simulation/mitkSimulationModel.cpp +++ b/Modules/Simulation/mitkSimulationModel.cpp @@ -1,324 +1,336 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #include "mitkSimulation.h" #include "mitkSimulationModel.h" #include #include #include #include #include #include #include #include #include #include #include mitk::SimulationModel::SimulationModel() : m_LastTime(-1.0), m_LastShowNormals(false), m_LastShowVisualModels(true), m_LastShowWireFrame(false) { } mitk::SimulationModel::~SimulationModel() { this->DeleteVtkTextures(); this->DeleteVtkObjects(); } void mitk::SimulationModel::DeleteVtkObjects() { for (std::vector::const_iterator object = m_VtkObjects.begin(); object != m_VtkObjects.end(); ++object) (*object)->Delete(); m_VtkObjects.clear(); for (std::vector::const_iterator actor = m_Actors.begin(); actor != m_Actors.end(); ++actor) (*actor)->Delete(); m_Actors.clear(); } void mitk::SimulationModel::DeleteVtkTextures() { for (std::map::const_iterator texture = m_Textures.begin(); texture != m_Textures.end(); ++texture) texture->second->Delete(); m_Textures.clear(); } void mitk::SimulationModel::DrawGroup(int ig, const sofa::core::visual::VisualParams* vparams, bool transparent) { const sofa::defaulttype::ResizableExtVector& triangles = this->getTriangles(); const sofa::defaulttype::ResizableExtVector& quads = this->getQuads(); FaceGroup g; if (ig < 0) { g.materialId = -1; g.tri0 = 0; g.nbt = triangles.size(); g.quad0 = 0; g.nbq = quads.size(); } else { g = groups.getValue()[ig]; } const sofa::defaulttype::ResizableExtVector& vertices = this->getVertices(); unsigned int numVertices = vertices.size(); vtkPoints* points = vtkPoints::New(); points->SetNumberOfPoints(numVertices); for (unsigned int i = 0; i < numVertices; ++i) points->SetPoint(i, vertices[i].elems); vtkPolyData* polyData = vtkPolyData::New(); polyData->SetPoints(points); points->Delete(); vtkCellArray* polys = vtkCellArray::New(); int numTriangles = g.tri0 + g.nbt; int numQuads = g.quad0 + g.nbq; for (int i = g.tri0; i < numTriangles; ++i) - polys->InsertNextCell(3, reinterpret_cast(triangles[i].elems)); + { + polys->InsertNextCell(3); + polys->InsertCellPoint(triangles[i].elems[0]); + polys->InsertCellPoint(triangles[i].elems[1]); + polys->InsertCellPoint(triangles[i].elems[2]); + } for (int i = g.quad0; i < numQuads; ++i) - polys->InsertNextCell(4, reinterpret_cast(quads[i].elems)); + { + polys->InsertNextCell(4); + polys->InsertCellPoint(quads[i].elems[0]); + polys->InsertCellPoint(quads[i].elems[1]); + polys->InsertCellPoint(quads[i].elems[2]); + polys->InsertCellPoint(quads[i].elems[3]); + } polyData->SetPolys(polys); polys->Delete(); const sofa::defaulttype::ResizableExtVector& normals = this->getVnormals(); unsigned int numNormals = normals.size(); vtkFloatArray* vtkNormals = vtkFloatArray::New(); vtkNormals->SetNumberOfComponents(3); for (unsigned int i = 0; i < numNormals; ++i) vtkNormals->InsertNextTuple(normals[i].elems); polyData->GetPointData()->SetNormals(vtkNormals); vtkNormals->Delete(); sofa::core::loader::Material m = g.materialId >= 0 ? materials.getValue()[g.materialId] : material.getValue(); if (m.useTexture && m.activated) { const sofa::defaulttype::ResizableExtVector& texCoords = this->getVtexcoords(); unsigned int numTexCoords = texCoords.size(); vtkFloatArray* vtkTexCoords = vtkFloatArray::New(); vtkTexCoords->SetNumberOfComponents(2); for (unsigned int i = 0; i < numTexCoords; ++i) vtkTexCoords->InsertNextTuple(texCoords[i].elems); polyData->GetPointData()->SetTCoords(vtkTexCoords); vtkTexCoords->Delete(); } vtkPolyDataMapper* polyDataMapper = vtkPolyDataMapper::New(); polyDataMapper->SetInput(polyData); vtkActor* actor = vtkActor::New(); actor->SetMapper(polyDataMapper); actor->SetScale(Simulation::ScaleFactor); if (m.useTexture && m.activated) actor->SetTexture(m_Textures[g.materialId]); sofa::defaulttype::Vec4f ambient = !m.useAmbient ? sofa::defaulttype::Vec4f() : m.ambient; sofa::defaulttype::Vec4f diffuse = !m.useDiffuse ? sofa::defaulttype::Vec4f() : m.diffuse; sofa::defaulttype::Vec4f specular = !m.useSpecular ? sofa::defaulttype::Vec4f() : m.specular; float shininess = m.useShininess ? m.shininess : 45.0f; if (shininess == 0.0f) { specular.clear(); shininess = 1.0f; } vtkProperty* property = actor->GetProperty(); property->SetAmbientColor(ambient.x(), ambient.y(), ambient.z()); property->SetDiffuseColor(diffuse.x(), diffuse.y(), diffuse.z()); property->SetSpecular(1.0); property->SetSpecularColor(specular.x(), specular.y(), specular.z()); property->SetSpecularPower(shininess); if (vparams->displayFlags().getShowWireFrame()) property->SetRepresentationToWireframe(); m_VtkObjects.push_back(polyData); m_VtkObjects.push_back(polyDataMapper); m_Actors.push_back(actor); if (!m_LastShowNormals) return; points = vtkPoints::New(); points->SetNumberOfPoints(numVertices * 2); vtkCellArray* lines = vtkCellArray::New(); for (unsigned int i = 0; i < numVertices; ++i) { unsigned int j = 2 * i; unsigned int k = j + 1; points->SetPoint(j, vertices[i].elems); points->SetPoint(k, (vertices[i] + normals[i]).elems); - vtkIdType line[] = { j, k }; - lines->InsertNextCell(2, line); + lines->InsertNextCell(2); + lines->InsertCellPoint(j); + lines->InsertCellPoint(k); } polyData = vtkPolyData::New(); polyData->SetPoints(points); polyData->SetLines(lines); points->Delete(); lines->Delete(); polyDataMapper = vtkPolyDataMapper::New(); polyDataMapper->SetInput(polyData); actor = vtkActor::New(); actor->SetMapper(polyDataMapper); actor->SetScale(Simulation::ScaleFactor); m_VtkObjects.push_back(polyData); m_VtkObjects.push_back(polyDataMapper); m_Actors.push_back(actor); } std::vector mitk::SimulationModel::GetActors() const { return m_Actors; } void mitk::SimulationModel::internalDraw(const sofa::core::visual::VisualParams* vparams, bool transparent) { double time = this->getContext()->getTime(); const sofa::core::visual::DisplayFlags& displayFlags = vparams->displayFlags(); bool showNormals = displayFlags.getShowNormals(); bool showVisualModels = displayFlags.getShowVisualModels(); bool showWireFrame = displayFlags.getShowWireFrame(); if (time == m_LastTime && showNormals == m_LastShowNormals && showVisualModels == m_LastShowVisualModels && showWireFrame == m_LastShowWireFrame) return; m_LastTime = time; m_LastShowNormals = showNormals; m_LastShowVisualModels = showVisualModels; m_LastShowWireFrame = showWireFrame; if (transparent) return; this->DeleteVtkObjects(); if (!vparams->displayFlags().getShowVisualModels()) return; sofa::helper::ReadAccessor > > groups = this->groups; if (groups.empty()) { this->DrawGroup(-1, vparams, transparent); } else { for (unsigned int i = 0; i < groups.size(); ++i) this->DrawGroup(i, vparams, transparent); } } bool mitk::SimulationModel::loadTexture(const std::string& filename) { return false; } bool mitk::SimulationModel::loadTextures() { this->DeleteVtkTextures(); std::vector activatedTextures; const sofa::helper::vector& materials = this->materials.getValue(); unsigned int numMaterials = materials.size(); for (unsigned int i = 0; i < numMaterials; ++i) { const sofa::core::loader::Material& material = materials[i]; if (material.useTexture && material.activated) activatedTextures.push_back(i); } unsigned int numActivatedTextures = activatedTextures.size(); for (unsigned int i = 0; i < numActivatedTextures; ++i) { std::string textureFilename = materials[activatedTextures[i]].textureFilename; if (!sofa::helper::system::DataRepository.findFile(textureFilename)) return false; vtkImageReader2* imageReader = vtkImageReader2Factory::CreateImageReader2(textureFilename.c_str()); if (imageReader == NULL) return false; imageReader->SetFileName(textureFilename.c_str()); vtkTexture* texture = vtkTexture::New(); texture->SetInput(imageReader->GetOutputDataObject(0)); texture->InterpolateOn(); imageReader->Delete(); m_Textures.insert(std::make_pair(activatedTextures[i], texture)); } return true; } diff --git a/Plugins/org.mitk.gui.qt.simulation/src/internal/QmitkSimulationViewControls.ui b/Plugins/org.mitk.gui.qt.simulation/src/internal/QmitkSimulationViewControls.ui index 8b127b1909..5ee48dfb0d 100644 --- a/Plugins/org.mitk.gui.qt.simulation/src/internal/QmitkSimulationViewControls.ui +++ b/Plugins/org.mitk.gui.qt.simulation/src/internal/QmitkSimulationViewControls.ui @@ -1,167 +1,167 @@ QmitkSimulationViewControls true 0 0 301 548 Simulation QLayout::SetMinimumSize 0 0 Simulation 0 0 false 0 0 Animate true false 0 0 Step 0 0 Reset Scene 0 0 dt 0 0 s 3 0.010000000000000 Qt::Vertical 20 421 QmitkDataStorageComboBox QWidget -
qmitkdatastoragecombobox.h
+
QmitkDataStorageComboBox.h