SET(PROJECT_MAJOR_VERSION 1)
SET(PROJECT_MINOR_VERSION 0)
-SET(PROJECT_BUILD_VERSION 0)
+SET(PROJECT_BUILD_VERSION 1)
SET(CREA_VERBOSE_CMAKE TRUE)
--- /dev/null
+#include "bbcreaMaracasVisuPlaneDirection.h"
+#include "bbcreaMaracasVisuPackage.h"
+namespace bbcreaMaracasVisu
+{
+
+BBTK_ADD_BLACK_BOX_TO_PACKAGE(creaMaracasVisu,PlaneDirection)
+BBTK_BLACK_BOX_IMPLEMENTATION(PlaneDirection,bbtk::WxBlackBox);
+void PlaneDirection::Process()
+{
+
+
+ int radio = bbGetInputArrowSize();
+ std::vector<int> lstPointsx = bbGetInputlstPointsX();
+ std::vector<int> lstPointsy = bbGetInputlstPointsY();
+ std::vector<int> lstPointsz = bbGetInputlstPointsZ();
+ std::vector<double> _lstPointsx;
+ std::vector<double> _lstPointsy;
+ std::vector<double> _lstPointsz;
+ vtkRenderer* render = bbGetInputRenderer();
+ vtkImageData* img = bbGetInputIn();
+ std::string filename = bbGetInputFilename();
+
+ _planedir->SetArrowSize(radio);
+ if(render!=NULL){
+ _planedir->SetRenderer(render);
+ }
+
+ if(lstPointsx.size()>0&&lstPointsy.size()>0&&lstPointsz.size()>0){
+ double* spc;
+ if(img != NULL){
+ spc = img->GetSpacing();
+ }else{
+ spc = new double[3];
+ spc[0]=1;
+ spc[1]=1;
+ spc[2]=1;
+ }
+
+ for(int i = 0; i < lstPointsx.size();i++){
+ _lstPointsx.push_back(lstPointsx[i]*spc[0]);
+ _lstPointsy.push_back(lstPointsy[i]*spc[1]);
+ _lstPointsz.push_back(lstPointsz[i]*spc[2]);
+ }
+
+ _planedir->SetVectors(_lstPointsx, _lstPointsy, _lstPointsz);
+ _planedir->UpdateDirections();
+ if(filename.compare("")!=0){
+ _planedir->WriteInformation(filename,spc);
+ }
+ }
+
+}
+void PlaneDirection::CreateWidget(wxWindow* parent)
+{
+ _planedir = PlaneDirectionViewer::getInstance(parent, radio, colour, opacity);
+ bbSetOutputWidget( _planedir );
+}
+void PlaneDirection::bbUserSetDefaultValues()
+{
+ radio = 5;
+ colour[0] = 1;
+ colour[1] = 0;
+ colour[2] = 0;
+ opacity = 100;
+}
+void PlaneDirection::bbUserInitializeProcessing()
+{
+ std::vector<int> temp;
+ bbSetInputFilename("");
+ bbSetInputRenderer(0);
+ bbSetInputIn(0);
+ bbSetInputlstPointsX(temp);
+ bbSetInputlstPointsY(temp);
+ bbSetInputlstPointsZ(temp);
+
+}
+void PlaneDirection::bbUserFinalizeProcessing()
+{
+
+}
+}
+// EO namespace bbcreaMaracasVisu
+
+
--- /dev/null
+#ifdef _USE_WXWIDGETS_
+#ifndef __bbcreaMaracasVisuPlaneDirection_h_INCLUDED__
+#define __bbcreaMaracasVisuPlaneDirection_h_INCLUDED__
+#include "bbcreaMaracasVisu_EXPORT.h"
+#include "bbtkWxBlackBox.h"
+
+#include <vtkRenderer.h>
+#include <vtkImageData.h>
+
+#include "PlaneDirectionViewer.h"
+
+namespace bbcreaMaracasVisu
+{
+
+class bbcreaMaracasVisu_EXPORT PlaneDirection
+ :
+ public bbtk::WxBlackBox
+{
+ BBTK_BLACK_BOX_INTERFACE(PlaneDirection,bbtk::WxBlackBox);
+
+ BBTK_DECLARE_INPUT(In,vtkImageData*);
+ BBTK_DECLARE_INPUT(Renderer, vtkRenderer* );
+ BBTK_DECLARE_INPUT(Filename, std::string );
+ BBTK_DECLARE_INPUT( lstPointsX, std::vector<int> );
+ BBTK_DECLARE_INPUT( lstPointsY, std::vector<int> );
+ BBTK_DECLARE_INPUT( lstPointsZ, std::vector<int> );
+ BBTK_DECLARE_INPUT( ArrowSize, int );
+ BBTK_PROCESS(Process);
+ void Process();
+ BBTK_CREATE_WIDGET(CreateWidget);
+ void CreateWidget(wxWindow*);
+
+private:
+ PlaneDirectionViewer* _planedir;
+ int radio;
+ double colour[3];
+ int opacity;
+};
+
+BBTK_BEGIN_DESCRIBE_BLACK_BOX(PlaneDirection,bbtk::WxBlackBox);
+BBTK_NAME("PlaneDirection");
+BBTK_AUTHOR("car-prie@uniandes.edu.co");
+BBTK_DESCRIPTION("Given a list of points and grouping them in triplets, the box calculates the direction of the plane formed by the three points");
+BBTK_CATEGORY("__CategoryBlackBox__");
+
+BBTK_INPUT(PlaneDirection,In,"Image data to get the spacing, if not found set to 1 1 1",vtkImageData*,"");
+BBTK_INPUT(PlaneDirection,Renderer,"Renderer",vtkRenderer*,"");
+BBTK_INPUT(PlaneDirection,Filename,"Filename to save the points of the plane and the direction",std::string,"");
+
+BBTK_INPUT(PlaneDirection , lstPointsX , " list of points X ", std::vector<int> ,"");
+BBTK_INPUT(PlaneDirection , lstPointsY , " list of points Y ", std::vector<int> ,"");
+BBTK_INPUT(PlaneDirection , lstPointsZ , " list of points Z ", std::vector<int> ,"");
+
+BBTK_INPUT(PlaneDirection , ArrowSize , "Size of the arrow ", int ,"");
+
+BBTK_END_DESCRIBE_BLACK_BOX(PlaneDirection);
+}
+// EO namespace bbcreaMaracasVisu
+
+#endif // __bbcreaMaracasVisuPlaneDirection_h_INCLUDED__
+#endif // _USE_WXWIDGETS_
+
# ENDIF(WIN32)
#ELSE (BUILD_BBTK_PACKAGE_creaMaracasVisu)
-
- SET(CPACK_PACKAGE_INSTALL_DIRECTORY "CreaTools/creaMaracasVisu-${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}")
+IF(WIN32)
+ SET(CPACK_PACKAGE_INSTALL_DIRECTORY "CreaTools\\\\creaMaracasVisu-${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}")
+ELSE(WIN32)
+ SET(CPACK_PACKAGE_INSTALL_DIRECTORY "CreaTools/creaMaracasVisu-${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}")
+ENDIF(WIN32)
+
IF(WIN32)
- SET(CMAKE_INSTALL_PREFIX C:/CreaTools/creaMaracasVisu)
+ SET(CMAKE_INSTALL_PREFIX C:/CreaTools/creaMaracasVisu)
ENDIF(WIN32)
SET(DOXYGEN_DOC_PREDEFINED USE_WXWIDGETS)
CREA_BUILD_DOXYGEN_DOC(
- ${CMAKE_PROJECT_NAME}
+ ${CMAKE_PROJECT_NAME}_lib
"${INPUT}"
"doxygen"
"${CREA_DEFINITIONS}"
src/interface/wxWindows/widgets
src/interface/wxWindows/widgets/pPlotter
src/interface/wxWindows/widgets/manualContour
+ src/interface/wxWindows/widgets/ThresholdImageView
../../../
)
#message(jhcl\n\n ${crea_LIBRARIES})
lib/maracasVisuLib/src/interface/wxWindows/widgets
lib/maracasVisuLib/src/interface/wxWindows/widgets/pPlotter
lib/maracasVisuLib/src/interface/wxWindows/widgets/manualContour
+ lib/maracasVisuLib/src/interface/wxWindows/widgets/ThresholdImageView
lib/maracasVisuLib/../../../
)
IF ( ${PROJECT_BINARY_DIR} STREQUAL ${EXECUTABLE_OUTPUT_PATH} )
--- /dev/null
+
+#include "PlaneDirectionViewer.h"
+
+/********************************************************************************************
+** Start of data viewmanagerData
+*********************************************************************************************/
+
+
+PlaneDirectionViewer* PlaneDirectionViewer::instance=NULL;
+
+PlaneDirectionViewer::PlaneDirectionViewer(wxWindow* parent,int radio, double colour[3], int opacity)
+:wxPanel(parent)
+{
+ manager = new PlaneDirectionManager(radio, colour, opacity);
+ wxBoxSizer* sizer = new wxBoxSizer(wxVERTICAL);
+ this->SetSizer(sizer);
+ this->SetAutoLayout(true);
+
+}
+
+
+PlaneDirectionViewer* PlaneDirectionViewer::getInstance(wxWindow* parent,int radio, double colour[3], int opacity){
+ if(instance==NULL){
+ instance = new PlaneDirectionViewer(parent,radio,colour,opacity);
+ }
+ return instance;
+}
+
+PlaneDirectionViewer* PlaneDirectionViewer::getInstance(){
+ return instance;
+}
+
+PlaneDirectionViewer::~PlaneDirectionViewer(){
+ delete manager;
+}
+
+void PlaneDirectionViewer::SetRenderer(vtkRenderer* render){
+ manager->SetRenderer(render);
+}
+void PlaneDirectionViewer::SetVectors( std::vector<double> lstPointsx, std::vector<double> lstPointsy, std::vector<double> lstPointsz){
+ manager->SetVectors(lstPointsx,lstPointsy,lstPointsz);
+}
+
+void PlaneDirectionViewer::UpdateDirections() throw (std::exception){
+ manager->UpdateDirections();
+ std::vector<PlaneDirectionManagerData*> vectdata = manager->GetPlanesData();
+ for(int i = 0; i < viewdata.size();i++){
+ this->GetSizer()->Remove(i);
+ viewdata[i]->Destroy();
+ }
+ viewdata.clear();
+ for(int i = 0; i < vectdata.size(); i++){
+ PlaneDirectionViewerPanel* planedirview = new PlaneDirectionViewerPanel(this, vectdata[i],i);
+ viewdata.push_back(planedirview);
+ this->GetSizer()->Add(planedirview,1);
+ }
+ this->Layout();
+
+}
+
+void PlaneDirectionViewer::addRemoveActor(int index, bool addremove){
+ manager->addRemoveActor(index, addremove);
+}
+
+void PlaneDirectionViewer::changeColor(int index,double r,double g,double b){
+ manager->changeColor(index, r,g,b);
+}
+
+void PlaneDirectionViewer::WriteInformation(std::string filename, double* spc){
+ manager->WriteInformation(filename,spc);
+}
+
+void PlaneDirectionViewer::SetArrowSize(int arrowsize){
+ manager->SetArrowSize(arrowsize);
+
+}
\ No newline at end of file
--- /dev/null
+#ifndef _PlaneDirectionViewer_H_
+#define _PlaneDirectionViewer_H_
+
+#include <math.h>
+
+#include <iostream>
+#include <vector>
+
+#include <vtkRenderer.h>
+
+#include <wx/wx.h>
+#include "PlaneDirectionViewerPanel.h"
+#include "PlaneDirectionManager.h"
+#include "marTypes.h"
+
+class creaMaracasVisu_EXPORT PlaneDirectionViewer : public wxPanel {
+
+public:
+ PlaneDirectionViewer(wxWindow* parent, int radio, double colour[3], int opacity);
+ ~PlaneDirectionViewer();
+
+ void SetRenderer(vtkRenderer* render);
+ void SetVectors( std::vector<double> lstPointsx, std::vector<double> lstPointsy, std::vector<double> lstPointsz);
+
+ void UpdateDirections() throw (std::exception);
+
+ static PlaneDirectionViewer* getInstance(wxWindow* parent,int radio, double colour[3], int opacity);
+
+ static PlaneDirectionViewer* getInstance();
+
+ void addRemoveActor(int index, bool addremove);
+
+ void changeColor(int index,double r,double g,double b);
+
+ void WriteInformation(std::string filename,double* spc=NULL);
+
+ void SetArrowSize(int arrowsize);
+private:
+ static PlaneDirectionViewer* instance;
+ PlaneDirectionManager* manager;
+ std::vector<PlaneDirectionViewerPanel*> viewdata;
+};
+
+#endif /*PlanesOperations_H_*/
--- /dev/null
+
+#include "PlaneDirectionViewerPanel.h"
+#include "PlaneDirectionViewer.h"
+
+#include "Color.xpm"
+#include <wx/colordlg.h>
+
+/********************************************************************************************
+** Start of data viewmanagerData
+*********************************************************************************************/
+
+PlaneDirectionViewerPanel::PlaneDirectionViewerPanel(wxWindow* parent, PlaneDirectionManagerData* data, int index)
+:wxPanel(parent,-1, wxDefaultPosition, wxDefaultSize,wxBORDER_SUNKEN){
+ wxBoxSizer* sizer = new wxBoxSizer(wxVERTICAL);
+
+ _index = index;
+ this->SetSizer(sizer);
+
+ checkbox = new wxCheckBox(this,-1,wxString(_T("Show Actor")));
+ checkbox->SetValue(true);
+ Connect(checkbox->GetId(), wxEVT_COMMAND_CHECKBOX_CLICKED, (wxObjectEventFunction)&PlaneDirectionViewerPanel::onCheckBoxChange);
+
+ wxBitmap bitmap(Color_xpm);
+ _colorchoose = new wxBitmapButton(this, -1, bitmap,wxDefaultPosition,wxSize(30,30));
+ Connect(_colorchoose->GetId(), wxEVT_COMMAND_BUTTON_CLICKED, (wxObjectEventFunction)&PlaneDirectionViewerPanel::onColorChange);
+
+
+ double* p0 = data->getPoint0();
+ double* p1 = data->getPoint1();
+ double* p2 = data->getPoint2();
+ double* dir = data->GetDirection();
+
+ wxString label(_T("[x, y, z]"));
+ wxString tempstr0;
+ tempstr0.Printf(_T("P1 [%f, %f, %f"),p0[0],p0[1],p0[2]);
+ wxString tempstr1;
+ tempstr1.Printf(_T("P2 [%f, %f, %f"),p1[0],p1[1],p1[2]);
+ wxString tempstr2;
+ tempstr2.Printf(_T("P3 [%f, %f, %f"),p2[0],p2[1],p2[2]);
+ wxString tempstr3;
+ tempstr3.Printf(_T("Direction [%f, %f, %f"),dir[0],dir[1],dir[2]);
+
+ wxStaticText* textlabel = new wxStaticText(this, -1, label);
+ wxStaticText* textp0 = new wxStaticText(this, -1, tempstr0);
+ wxStaticText* textp1 = new wxStaticText(this, -1, tempstr1);
+ wxStaticText* textp2 = new wxStaticText(this, -1, tempstr2);
+ wxStaticText* textp3 = new wxStaticText(this, -1, tempstr3);
+
+
+ sizer->Add(checkbox,1);
+ sizer->Add(_colorchoose,1);
+ sizer->Add(textlabel,1);
+ sizer->Add(textp0,1);
+ sizer->Add(textp1,1);
+ sizer->Add(textp2,1);
+ sizer->Add(textp3,1);
+
+ this->SetAutoLayout(true);
+ this->Layout();
+
+}
+
+void PlaneDirectionViewerPanel::onCheckBoxChange(wxCommandEvent& event){
+ PlaneDirectionViewer::getInstance()->addRemoveActor(this->_index, checkbox->GetValue());
+}
+
+void PlaneDirectionViewerPanel::onColorChange(wxCommandEvent& event){
+
+ wxColourDialog* colourdiag = new wxColourDialog(this);
+ if(colourdiag->ShowModal()==wxID_OK){
+ wxColour colour = colourdiag->GetColourData().GetColour();
+ _colorchoose->SetBackgroundColour(colour);
+
+ double r = (double)(colour.Red())/255.0;
+ double g = (double)(colour.Green())/255.0;
+ double b = (double)(colour.Blue())/255.0;
+
+ PlaneDirectionViewer::getInstance()->changeColor(this->_index,r,g,b);
+ }
+ delete colourdiag;
+
+}
+
+PlaneDirectionViewerPanel::~PlaneDirectionViewerPanel(){
+
+}
+
--- /dev/null
+#ifndef PlaneDirectionViewerPanel_H_
+#define PlaneDirectionViewerPanel_H_
+
+#include <wx/wx.h>
+#include "PlaneDirectionManagerData.h"
+
+class PlaneDirectionViewerPanel : public wxPanel {
+
+public:
+ PlaneDirectionViewerPanel(wxWindow* parent, PlaneDirectionManagerData* data, int index);
+ ~PlaneDirectionViewerPanel();
+
+ void onCheckBoxChange(wxCommandEvent& event);
+
+ void onColorChange(wxCommandEvent& event);
+
+private:
+ int _index;
+ wxCheckBox* checkbox;
+
+ wxBitmapButton* _colorchoose;
+};
+
+#endif /*PlaneDirectionViewerPanel_H_*/
--- /dev/null
+
+#include "PlaneDirectionManager.h"
+
+/********************************************************************************************
+** Start of data viewmanagerData
+*********************************************************************************************/
+
+PlaneDirectionManager::PlaneDirectionManager(int radio, double colour[3] , int opacity){
+ _radio = radio;
+ _colour = colour;
+ _opacity = opacity;
+
+}
+
+
+PlaneDirectionManager::~PlaneDirectionManager(){
+ RemoveAllActorsFromIndex();
+}
+
+void PlaneDirectionManager::SetRenderer(vtkRenderer* render){
+ _render = render;
+}
+void PlaneDirectionManager::SetVectors( std::vector<double> lstPointsx, std::vector<double> lstPointsy, std::vector<double> lstPointsz){
+
+ _lstPointsx = lstPointsx;
+ _lstPointsy = lstPointsy;
+ _lstPointsz = lstPointsz;
+}
+
+void PlaneDirectionManager::UpdateDirections() throw (std::exception){
+ UpdateVectors();
+ UpdateActors();
+ AddActors();
+
+}
+void PlaneDirectionManager::AddActors(){
+ for(int i = 0; i < _vectdata.size();i++){
+ _render->AddViewProp (_vectdata[i]->GetActor());
+ }
+}
+void PlaneDirectionManager::RemoveAllActorsFromIndex(int n)throw (std::exception){
+ /*due to incompleate set of points to create the plane
+ */
+ if(_render==NULL){
+ throw std::exception();
+ }
+ for(int i = _vectdata.size()-1; i >= n;i--){
+ _render->RemoveViewProp(_vectdata[i]->GetActor());
+ delete _vectdata[i];
+ _vectdata.pop_back();
+ }
+
+}
+void PlaneDirectionManager::UpdateVectors()throw (std::exception){
+ PlaneDirectionManagerData* temp;
+ bool deletelast = false;
+ int currentdata = 0;
+ for(int i = 0; i < _lstPointsx.size();i++){
+ if(i % 3 == 0){
+ if(_vectdata.size()>currentdata){
+ temp = _vectdata[currentdata];
+ }else{
+ temp = new PlaneDirectionManagerData(_radio, _colour, _opacity);
+ _vectdata.push_back(temp);
+ }
+ temp->setPoint0(_lstPointsx[i],_lstPointsy[i],_lstPointsz[i]);
+ deletelast = true;
+ }else if(i % 3 == 1){
+ temp->setPoint1(_lstPointsx[i],_lstPointsy[i],_lstPointsz[i]);
+ }else if(i % 3 == 2){
+ temp->setPoint2(_lstPointsx[i],_lstPointsy[i],_lstPointsz[i]);
+ currentdata++;
+ deletelast = false;
+ }
+ }
+ RemoveAllActorsFromIndex(currentdata);
+}
+
+void PlaneDirectionManager::UpdateActors(){
+ for(int i = 0; i < _vectdata.size();i++){
+ _vectdata[i]->UpdateActor();
+ }
+}
+
+void PlaneDirectionManager::addRemoveActor(int index, bool addremove){
+
+ if(index < _vectdata.size()){
+ if(addremove){
+ _render->AddViewProp (_vectdata[index]->GetActor());
+ }else{
+ _render->RemoveViewProp (_vectdata[index]->GetActor());
+ }
+
+ }
+
+
+}
+
+void PlaneDirectionManager::changeColor(int index,double r,double g,double b){
+ GetPlaneDirectionManagerData(index)->ChangeColour(r,g,b);
+}
+
+PlaneDirectionManagerData* PlaneDirectionManager::GetPlaneDirectionManagerData(int id) {
+
+ return _vectdata[id];
+}
+
+void PlaneDirectionManager::WriteInformation(std::string filename, double* spc){
+ FILE *ff;
+ ff = fopen( filename.c_str() , "w+" );
+ if(spc ==NULL){
+ spc = new double[3];
+ spc[0] = 1;
+ spc[1] = 1;
+ spc[2] = 1;
+ }
+ if (ff!=NULL)
+ {
+ for(int i = 0; i < _vectdata.size();i++){
+
+ double* p0 = _vectdata[i]->getPoint0();
+ double* p1 = _vectdata[i]->getPoint1();
+ double* p2 = _vectdata[i]->getPoint2();
+ double* dir = _vectdata[i]->GetDirection();
+
+ double p0x = p0[0]/spc[0];
+ double p0y = p0[1]/spc[1];
+ double p0z = p0[2]/spc[2];
+
+ double p1x = p1[0]/spc[0];
+ double p1y = p1[1]/spc[1];
+ double p1z = p1[2]/spc[2];
+
+ double p2x = p2[0]/spc[0];
+ double p2y = p2[1]/spc[1];
+ double p2z = p2[2]/spc[2];
+
+ double dirx = dir[0]/spc[0];
+ double diry = dir[1]/spc[1];
+ double dirz = dir[2]/spc[2];
+
+ fprintf(ff,"Dir%d\n",i);
+ fprintf(ff,"\tP0[%f, %f, %f]\tP1[%f, %f, %f]\tP2[%f, %f, %f]\tDir[%f, %f, %f] \n",
+ p0x,p0y,p0z, p1x,p1y,p1z, p2x,p2y,p2z, dirx,diry,dirz);
+ }
+
+ fclose(ff);
+ } else { // else ff
+ printf("PlaneDirectionManager::WriteInformation ...Error... creating file");
+ } //ff
+
+
+}
+
+void PlaneDirectionManager::SetArrowSize(int arrowsize){
+ _radio = arrowsize;
+}
\ No newline at end of file
--- /dev/null
+#ifndef PlaneDirectionManager_H_
+#define PlaneDirectionManager_H_
+
+#include <math.h>
+
+#include <iostream>
+
+#include "PlaneDirectionManagerData.h"
+
+#include <vector>
+
+#include <vtkRenderer.h>
+
+class PlaneDirectionManager {
+
+public:
+ PlaneDirectionManager(int radio, double colour[3], int opacity);
+ ~PlaneDirectionManager();
+
+ void SetRenderer(vtkRenderer* render);
+ void SetVectors( std::vector<double> lstPointsx, std::vector<double> lstPointsy, std::vector<double> lstPointsz);
+
+ void UpdateDirections() throw (std::exception);
+
+ std::vector<PlaneDirectionManagerData*> GetPlanesData(){
+ return _vectdata;
+ }
+
+ void addRemoveActor(int index, bool addremove);
+
+ void changeColor(int index,double r,double g,double b);
+
+ PlaneDirectionManagerData* GetPlaneDirectionManagerData(int id);
+
+ void WriteInformation(std::string filename, double* spc=NULL);
+
+ void SetArrowSize(int arrowsize);
+private:
+
+ std::vector<double> _lstPointsx;
+ std::vector<double> _lstPointsy;
+ std::vector<double> _lstPointsz;
+
+ std::vector<PlaneDirectionManagerData*> _vectdata;
+
+ void RemoveAllActorsFromIndex(int n=0)throw (std::exception);
+ void UpdateVectors()throw (std::exception);
+
+ void UpdateActors();
+ void AddActors();
+
+ vtkRenderer* _render;
+
+ int _radio;
+ double* _colour;
+ int _opacity;
+
+};
+
+#endif /*PlaneDirectionManager_H_*/
--- /dev/null
+
+#include "PlaneDirectionManagerData.h"
+
+/********************************************************************************************
+** Start of data viewmanagerData
+*********************************************************************************************/
+
+PlaneDirectionManagerData::PlaneDirectionManagerData(int radio, double colour[3], int opacity)
+:PlanesOperations(){
+ _vtkarrow = vtkArrowSource::New();
+ _arrowMapper = vtkPolyDataMapper::New();
+ _arrowActor = vtkActor::New();
+
+ _vtkarrow->SetTipResolution(30);
+ _vtkarrow->SetShaftResolution( 30 );
+ _arrowMapper->SetInput( _vtkarrow->GetOutput() );
+ _arrowActor->SetMapper(_arrowMapper);
+
+ _radio = radio;
+ _colour = colour;
+ _opacity = opacity;
+
+ p0 = new double[3];
+ p0[0] = 0;
+ p0[1] = 0;
+ p0[2] = 0;
+ p1 = new double[3];
+ p1[0] = 0;
+ p1[1] = 0;
+ p1[2] = 0;
+ p2 = new double[3];
+ p2[0] = 1;
+ p2[1] = 1;
+ p2[2] = 1;
+ _dir = new double[3];
+ _dir[0] = 0;
+ _dir[1] = 0;
+ _dir[2] = 0;
+}
+
+
+PlaneDirectionManagerData::~PlaneDirectionManagerData(){
+
+ _vtkarrow->Delete();
+ _arrowMapper->Delete();
+ _arrowActor->Delete();
+ delete p0;
+ delete p1;
+ delete p2;
+ delete _dir;
+}
+
+vtkProp3D* PlaneDirectionManagerData::GetActor(){
+ return _arrowActor;
+}
+
+void PlaneDirectionManagerData::UpdateActor(){
+
+ _arrowActor->GetProperty()->SetColor( _colour[0] , _colour[1] , _colour[2] );
+ _arrowActor->GetProperty()->SetOpacity( _opacity );
+
+
+ double* vect1= getNormal(makeVector(p0, p1));
+ double* vect2= getNormal(makeVector(p0, p2));
+ _dir = getNormal(getCrossProduct(vect1, vect2));
+ double *newvectnorm = getNormal(getCrossProduct(_dir, vect2));
+ double *midp = GetMidPoint();
+
+ vtkMatrix4x4* _matrix = vtkMatrix4x4::New();
+ _matrix->Identity();
+ _matrix->SetElement(0,0,_dir[0]*_radio);
+ _matrix->SetElement(1,0,_dir[1]*_radio);
+ _matrix->SetElement(2,0,_dir[2]*_radio);
+ _matrix->SetElement(0,1,vect2[0]*_radio);
+ _matrix->SetElement(1,1,vect2[1]*_radio);
+ _matrix->SetElement(2,1,vect2[2]*_radio);
+ _matrix->SetElement(0,2,newvectnorm[0]*_radio);
+ _matrix->SetElement(1,2,newvectnorm[1]*_radio);
+ _matrix->SetElement(2,2,newvectnorm[2]*_radio);
+ _matrix->SetElement(0,3,midp[0]);
+ _matrix->SetElement(1,3,midp[1]);
+ _matrix->SetElement(2,3,midp[2]);
+ _arrowActor->SetUserMatrix(_matrix);
+
+}
+
+void PlaneDirectionManagerData::ChangeColour(double r,double g,double b){
+ _colour[0] = r;
+ _colour[1] = g;
+ _colour[2] = b;
+ if(_arrowActor!=NULL){
+ _arrowActor->GetProperty()->SetColor( r,g,b );
+ }
+}
+
+double* PlaneDirectionManagerData::GetMidPoint(){
+ if(p0 != NULL && p1 != NULL && p2 != NULL){
+ double* ret = new double[3];
+ ret[0] = (p0[0] + p1[0] +p2[0])/3;
+ ret[1] = (p0[1] + p1[1] +p2[1])/3;
+ ret[2] = (p0[2] + p1[2] +p2[2])/3;
+ return ret;
+ }
+ return NULL;
+}
--- /dev/null
+#ifndef PlaneDirectionManagerData_H_
+#define PlaneDirectionManagerData_H_
+
+#include <math.h>
+
+#include "PlanesOperations.h"
+
+
+#include <iostream>
+
+#include <vtkArrowSource.h>
+//#include <vtkConeSource.h>
+#include <vtkPolyDataMapper.h>
+#include <vtkActor.h>
+#include <vtkProperty.h>
+#include <vtkMatrix4x4.h>
+#include <vtkTransform.h>
+
+
+class PlaneDirectionManagerData : public PlanesOperations {
+
+public:
+ PlaneDirectionManagerData(int radio, double colour[3], int opacity);
+ ~PlaneDirectionManagerData();
+
+ void setPoint0(double x,double y,double z){
+ p0[0] = x;
+ p0[1] = y;
+ p0[2] = z;
+ }
+ void setPoint1(double x,double y,double z){
+ p1[0] = x;
+ p1[1] = y;
+ p1[2] = z;
+ }
+ void setPoint2(double x,double y,double z){
+ p2[0] = x;
+ p2[1] = y;
+ p2[2] = z;
+ }
+ double* getPoint0(){
+ return p0;
+ }
+ double* getPoint1(){
+ return p1;
+ }
+ double* getPoint2(){
+ return p2;
+ }
+
+ void UpdateActor();
+
+ vtkProp3D* GetActor();
+
+ double* GetDirection(){
+ return _dir;
+ }
+
+ void ChangeColour(double r,double g,double b);
+
+private:
+ double* p0;
+ double* p1;
+ double* p2;
+ int _radio;
+ double* _colour;
+ int _opacity;
+ double* _dir;
+
+ vtkArrowSource *_vtkarrow;
+ vtkPolyDataMapper *_arrowMapper;
+ vtkActor *_arrowActor;
+
+ double* GetMidPoint();
+
+};
+
+#endif /*PlaneDirectionManagerData_H_*/
--- /dev/null
+
+#include "PlanesOperations.h"
+
+/********************************************************************************************
+** Start of data viewmanagerData
+*********************************************************************************************/
+
+PlanesOperations::PlanesOperations(){
+}
+
+
+PlanesOperations::~PlanesOperations(){
+
+}
+
+
+double* PlanesOperations::getCrossProduct(double* vect0,double* vect1){
+ double* vectCross;
+ vectCross = new double[3];
+ vectCross[0] = vect0[1]*vect1[2]-(vect0[2]*vect1[1]);
+ vectCross[1] = -(vect0[0]*vect1[2]-(vect0[2]*vect1[0]));
+ vectCross[2] = vect0[0]*vect1[1]-(vect0[1]*vect1[0]);
+
+ return vectCross;
+}
+/**
+** Returns the magnitud of the given vector
+**/
+double PlanesOperations::getMagnitud(double* vect){
+
+ double mag;
+
+ mag = sqrt(pow(vect[0],2) + pow(vect[1],2) + pow(vect[2],2));
+
+ std::cout<<"mag "<<mag <<std::endl;
+
+ return mag;
+
+}
+/**
+** returns the unitary vector of the given vector
+** u = 1/|vect| . vect
+**/
+double* PlanesOperations::getNormal(double* vect){
+
+ double* vectnorm;
+ double mag = getMagnitud(vect);
+
+ vectnorm = new double[3];
+
+
+ if(mag!=0){
+ vectnorm[0] = vect[0]/mag;
+ vectnorm[1] = vect[1]/mag;
+ vectnorm[2] = vect[2]/mag;
+ }else{
+ vectnorm[0] = 0;
+ vectnorm[1] = 0;
+ vectnorm[2] = 0;
+ }
+
+ return vectnorm;
+
+
+}
+
+double* PlanesOperations::makeVector(double podouble0[3], double podouble1[3]){
+ double *vect;
+ vect = new double[3];
+
+ vect[0]= podouble1[0]-podouble0[0];
+ vect[1]= podouble1[1]-podouble0[1];
+ vect[2]= podouble1[2]-podouble0[2];
+
+ return vect;
+
+}
\ No newline at end of file
--- /dev/null
+#ifndef PlanesOperations_H_
+#define PlanesOperations_H_
+
+#include <math.h>
+
+#include <iostream>
+
+class PlanesOperations {
+
+public:
+ PlanesOperations();
+ ~PlanesOperations();
+
+
+
+ double* getCrossProduct(double* vect0,double* vect1);
+ double getPodoubleProduct(double* vect0,double* vect1);
+ double* getNormal(double* vect);
+ double getMagnitud(double* vect);
+ double* makeVector(double podouble0[3], double podouble1[3]);
+
+};
+
+#endif /*PlanesOperations_H_*/