Skip to content

Commit

Permalink
Sphere paraemtric surface
Browse files Browse the repository at this point in the history
  • Loading branch information
rmucci committed Jan 21, 2011
1 parent 752d2cc commit 3bfdf1d
Show file tree
Hide file tree
Showing 2 changed files with 124 additions and 0 deletions.
58 changes: 58 additions & 0 deletions mafPluginVTK/mafVTKParametricSurfaceSphere.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
/*
* mafVTKParametricSurfaceSphere.cpp
* mafPluginVTK
*
* Created by Roberto Mucci on 19/11/11.
* Copyright 2009 B3C.s All rights reserved.
*
* See Licence at: http://tiny.cc/QXJ4D
*
*/

#include "mafVTKParametricSurfaceSphere.h"
#include <vtkSmartPointer.h>
#include <vtkSphereSource.h>
#include <vtkAlgorithmOutput.h>
#include <vtkPointData.h>
#include <vtkDoubleArray.h>


using namespace mafCore;
using namespace mafPluginVTK;


mafVTKParametricSurfaceSphere::mafVTKParametricSurfaceSphere(const mafString code_location) : mafPluginVTK::mafVTKParametricSurface(code_location), m_SphereSource(NULL) {
m_SphereRadius = 1.0;
m_SpherePhiRes = 10;
m_SphereTheRes = 10;

m_SphereSource = vtkSphereSource::New();
m_Output = m_SphereSource->GetOutputPort();
}

mafVTKParametricSurfaceSphere::~mafVTKParametricSurfaceSphere(){
m_SphereSource->Delete();
}

void mafVTKParametricSurfaceSphere::updateSurface(){
//Set parameters to surface.
m_SphereSource->SetCenter(m_Center);
m_SphereSource->SetPhiResolution(m_SpherePhiRes);
m_SphereSource->SetThetaResolution(m_SphereTheRes);
m_SphereSource->SetRadius(m_SphereRadius);
m_SphereSource->Update();
}

void mafVTKParametricSurfaceSphere::setSphereRadius(double sphereRadius){
m_SphereRadius = sphereRadius;
}

void mafVTKParametricSurfaceSphere::setSpherePhiResolution(double spherePhiRes){
m_SpherePhiRes = spherePhiRes;
}

void mafVTKParametricSurfaceSphere::setThetaResolution(double sphereTheRes){
m_SphereTheRes = sphereTheRes;
}


66 changes: 66 additions & 0 deletions mafPluginVTK/mafVTKParametricSurfaceSphere.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
/*
* mafVTKParametricSurfaceSphere.h
* mafPluginVTK
*
* Created by Roberto Mucci on 19/01/11.
* Copyright 2009 B3C.s All rights reserved.
*
* See Licence at: http://tiny.cc/QXJ4D
*
*/

#ifndef MAFVTKPARAMETRICSURFACESPHERE_H
#define MAFVTKPARAMETRICSURFACESPHERE_H

// Includes list
#include "mafPluginVTKDefinitions.h"
#include "mafVTKParametricSurface.h"

// Foundation Class forwarding list
class vtkAlgorithmOutput;
class vtkSphereSource;

namespace mafPluginVTK {

/**
Class name: mafVTKInteractorPicker
This class represent an interactor implementing a picking operation.
*/

class MAFPLUGINVTKSHARED_EXPORT mafVTKParametricSurfaceSphere : public mafPluginVTK::mafVTKParametricSurface
{
Q_OBJECT
/// typedef macro.
mafSuperclassMacro(mafPluginVTK::mafVTKParametricSurface);

public:
///< Object constructor.
mafVTKParametricSurfaceSphere(const mafString code_location = "");

///< Object destructor.
~mafVTKParametricSurfaceSphere();

public slots:
/// Set the radius for the parametric sphere.
void setSphereRadius(double radius);

/// Set the Phi resolution for the parametric sphere.
void setSpherePhiResolution(double spherePhiRes);

/// Set the Theta resolution for the parametric sphere.
void setThetaResolution(double sphereTheRes);

/// Update surface with parameters.
/*virtual*/ void updateSurface();

private:
vtkSphereSource *m_SphereSource; ///< Polydata representig a sphere.

double m_SphereRadius; ///< Radius of the sphere;
double m_SpherePhiRes; ///< Sphere Phi resolution;
double m_SphereTheRes; ///< Sphere Phi resolution;
};

}

#endif // MAFVTKPARAMETRICSURFACESPHERE_H

0 comments on commit 3bfdf1d

Please sign in to comment.