--- /dev/null
+#include "manualBaseModel.h"
+
+// ----------------------------------------------------------------------------
+manualBaseModel::manualBaseModel()
+{
+
+ _sizePointsContour = 100; //JSTG 25-02-08 The change in the inisialization of these variable is critical.
+
+}
+
+// ----------------------------------------------------------------------------
+manualBaseModel::~manualBaseModel()
+{
+ int i,size=_lstPoints.size();
+ for (i=0;i<size; i++){
+ delete _lstPoints[i];
+ }
+ _lstPoints.clear();
+
+}
+// ----------------------------------------------------------------------------
+int manualBaseModel::AddPoint(double x,double y,double z)
+{
+ manualPoint *mp = new manualPoint();
+ mp->SetPoint(x,y,z);
+ AddManualPoint(mp);
+
+ return _lstPoints.size()-1;
+}
+// ----------------------------------------------------------------------------
+int manualBaseModel::InsertPoint(double x,double y,double z)
+{
+ double dd,ddmin=9999999;
+ int ibak=0;
+ double xx,x1,x2;
+ double yy,y1,y2;
+ double zz,z1,z2;
+ int i,ii,iii,size=_lstPoints.size();
+ double j,MaxDivisions=20,porcentage;
+ int sizeB=size;
+
+ double jbak;
+
+ for ( i=0 ; i<size ; i++ )
+ {
+ ii=i % sizeB ;
+ iii=(i+1) % sizeB;
+ x1=_lstPoints[ii]->GetX();
+ y1=_lstPoints[ii]->GetY();
+ z1=_lstPoints[ii]->GetZ();
+ x2=_lstPoints[iii]->GetX();
+ y2=_lstPoints[iii]->GetY();
+ z2=_lstPoints[iii]->GetZ();
+ for (j=0; j<=MaxDivisions; j++)
+ {
+ porcentage=(j/MaxDivisions);
+ xx=(x2-x1)*porcentage+x1;
+ yy=(y2-y1)*porcentage+y1;
+ zz=(z2-z1)*porcentage+z1;
+ dd=sqrt( (xx-x)*(xx-x) + (yy-y)*(yy-y) + (zz-z)*(zz-z) );
+ if ( dd<ddmin )
+ {
+ ddmin=dd;
+ ibak=iii;
+ jbak=j;
+ }
+ }
+ }
+
+
+ InsertPoint_id(ibak,x,y,z);
+
+ return ibak;
+}
+// ----------------------------------------------------------------------------
+void manualBaseModel::InsertPoint_id(int id, double x, double y, double z)
+{
+ manualPoint *mp = new manualPoint();
+ mp->SetPoint(x,y,z);
+ std::vector<manualPoint*>::iterator itNum = _lstPoints.begin() + id;
+ _lstPoints.insert(itNum,mp);
+}
+// ----------------------------------------------------------------------------
+
+void manualBaseModel::DeletePoint(int i)
+{
+ std::vector<manualPoint*>::iterator itNum = _lstPoints.begin() + i;
+ _lstPoints.erase(itNum);
+}
+// ----------------------------------------------------------------------------
+void manualBaseModel::DeleteAllPoints()
+{
+ int i,size=_lstPoints.size();
+ for (i=0;i<size;i++){
+ _lstPoints.erase( _lstPoints.begin() );
+ }
+}
+// ----------------------------------------------------------------------------
+
+void manualBaseModel::MovePoint(int i,double dx,double dy,double dz)
+{
+ manualPoint *mp=_lstPoints[i];
+ double x=mp->GetX()+dx;
+ double y=mp->GetY()+dy;
+ double z=mp->GetZ()+dz;
+ mp->SetPoint(x,y,z);
+}
+// ----------------------------------------------------------------------------
+void manualBaseModel::MoveLstPoints(double dx,double dy,double dz)
+{
+ // ToDo
+}
+// ----------------------------------------------------------------------------
+void manualBaseModel::MoveAllPoints(double dx,double dy,double dz)
+{
+ int i,size=_lstPoints.size();
+ for (i=0;i<size;i++){
+ MovePoint(i,dx,dy,dz);
+ }
+}
+
+
+// ----------------------------------------------------------------------------
+// type=-1 x,y,z
+// type=0 y,z
+// type=1 x,z
+// type=2 x,y
+int manualBaseModel::GetIdPoint(double x, double y, double z, int i_range,int type)
+{
+ double range = i_range+1;
+
+ double xx,yy,zz,dd,ddmin=9999999;
+ int ibak=-1;
+ int i,size=_lstPoints.size();
+ for (i=0;i<size;i++){
+ manualPoint *mp=_lstPoints[i];
+ xx=mp->GetX();
+ yy=mp->GetY();
+ zz=mp->GetZ();
+
+ if (type==-1)
+ {
+ if ((fabs(xx-x)<range) && (fabs(yy-y)<range) && (fabs(zz-z)<range)) {
+ dd=sqrt( (xx-x)*(xx-x) + (yy-y)*(yy-y) + (zz-z)*(zz-z) );
+ if (dd<ddmin){
+ ddmin=dd;
+ ibak=i;
+ }
+ }
+ }
+ if (type==0)
+ {
+ if ((fabs(yy-y)<range) && (fabs(zz-z)<range)) {
+ dd=sqrt( (yy-y)*(yy-y) + (zz-z)*(zz-z) );
+ if (dd<ddmin){
+ ddmin=dd;
+ ibak=i;
+ }
+ }
+ }
+ if (type==1)
+ {
+ if ((fabs(xx-x)<range) && (fabs(zz-z)<range)) {
+ dd=sqrt( (xx-x)*(xx-x) + (zz-z)*(zz-z) );
+ if (dd<ddmin){
+ ddmin=dd;
+ ibak=i;
+ }
+ }
+ }
+ if (type==2)
+ {
+ if ((fabs(xx-x)<range) && (fabs(yy-y)<range) ) {
+ dd=sqrt( (xx-x)*(xx-x) + (yy-y)*(yy-y) );
+ if (dd<ddmin){
+ ddmin=dd;
+ ibak=i;
+ }
+ }
+ }
+ }
+ return ibak;
+}
+// ----------------------------------------------------------------------------
+int manualBaseModel::IsPoint(double x, double y)
+{
+ double xx,yy,zz;
+ bool exists=false;
+ int i,size=_lstPoints.size();
+ for (i=0;i<size;i++){
+ manualPoint *mp=_lstPoints[i];
+ xx=mp->GetX();
+ yy=mp->GetY();
+
+ //RaC Be Careful!! Cast to have a point like the one in the params 27-09-09
+ if(x==(int)xx && y==(int)yy )
+ {
+ exists=true;
+ }
+ }
+ return exists;
+
+}
+// ----------------------------------------------------------------------------
+manualPoint* manualBaseModel::GetManualPoint(int id)
+{
+ return _lstPoints[id];
+}
+// ----------------------------------------------------------------------------
+int manualBaseModel::GetSizeLstPoints()
+{
+ return _lstPoints.size();
+}
+
+// ----------------------------------------------------------------------------
+manualBaseModel * manualBaseModel :: Clone() // virtual
+{
+ manualBaseModel * clone = new manualBaseModel();
+ CopyAttributesTo(clone);
+ return clone;
+}
+
+// ----------------------------------------------------------------------------
+int manualBaseModel::GetTypeModel() //virtual
+{
+ // 0 spline
+ // 1 spline
+ // 2 rectangle
+ // 3 circle
+ // 4 BullEye
+ // 5 BullEyeSector
+ // 6 Line
+ // 7 Points
+ return 7;
+}
+
+// ---------------------------------------------------------------------------
+
+void manualBaseModel::CopyAttributesTo( manualBaseModel * cloneObject)
+{
+ int i, size = GetSizeLstPoints();
+ for( i=0; i<size; i++ )
+ {
+ cloneObject->AddManualPoint( GetManualPoint( i )->Clone() );
+ }
+}
+
+
+// ---------------------------------------------------------------------------
+void manualBaseModel::AddManualPoint( manualPoint* theManualPoint )
+{
+ _lstPoints.push_back( theManualPoint );
+}
+
+void manualBaseModel::Open(FILE *ff) // virtual
+{
+}
+void manualBaseModel::Save(FILE *ff) // virtual
+{
+}
+
+void manualBaseModel::SaveData(FILE *ff)// virtual
+{
+}
+
+
+// ---------------------------------------------------------------------------
+void manualBaseModel::SetNumberOfPointsSpline(int size)
+{
+ _sizePointsContour = size;
+}
+
+double manualBaseModel::GetPathSize()
+{
+ return 0.0;
+}
+
+void manualBaseModel::Transform_Ax_Plus_B (double Ax, double Bx, double Ay, double By)
+{
+}
+
+void manualBaseModel::GetSpline_i_Point(int i, double *x, double *y, double *z)
+{
+ //RaC 20-09-09 IF it's a points contour
+ if(GetTypeModel()==7){
+ if (_lstPoints.size()==0)
+ {
+ *x = 0;
+ *y = 0;
+ *z = 0;
+ }
+ else
+ {
+ manualPoint *mp;
+ mp = _lstPoints[i];
+ *x = mp->GetX();
+ *y = mp->GetY();
+ *z = mp->GetZ();
+ }
+
+ }
+
+}
+
+void manualBaseModel::GetSpline_t_Point(double t, double *x, double *y, double *z)
+{
+}
+
+// ---------------------------------------------------------------------------
+int manualBaseModel::GetNumberOfPointsSpline()
+{
+
+ //RaC 20-09-09 IF it's a points contour
+ if(GetTypeModel()==7){
+ return _lstPoints.size();
+ }
+ return _sizePointsContour;
+}
+
+// ---------------------------------------------------------------------------
+void manualBaseModel::UpdateSpline()
+{
+}
+
+// ---------------------------------------------------------------------------
+std::vector<manualBaseModel*> manualBaseModel::ExploseModel( )
+{
+ std::vector<manualBaseModel*> lstTmp;
+ lstTmp.push_back(this);
+ return lstTmp;
+}
+
+// ---------------------------------------------------------------------------
+double manualBaseModel::GetPathArea()
+{
+ return 0.0;
+}
+void manualBaseModel::GetNearestPointAndNormal(double *p, double *rp, double *rn)
+{
+}
+void manualBaseModel::SetCloseContour(bool closeContour)
+{
+}
+bool manualBaseModel::IfCloseContour()
+{
+ return false;
+}
+//CMRU 17-08-09----------------------------------------------------------------------------
+void manualBaseModel::SetLabel(std::string newLabel)
+{
+}
+
+void manualBaseModel::SetRealSize(double newRealSize)
+{
+}
+
+double manualBaseModel::GetRealSize()
+{
+ return -1;
+}
+
+std::string manualBaseModel::GetLabel()
+{
+ return "";
+}
+void manualBaseModel::OpenData(FILE *ff)
+{
+}
+//----------------------------------------------------------------------------
--- /dev/null
+#ifndef manualBaseModel_h
+#define manualBaseModel_h
+
+#include "vtkRenderWindow.h"
+
+#include "vtkRenderer.h"
+#include "vtkRenderWindowInteractor.h" //extremely important with VC++ don't remove !
+#include "vtkCommand.h"
+#include "vtkPolyData.h"
+#include "vtkCellArray.h"
+#include "vtkPolyDataMapper.h"
+#include "vtkInteractorObserver.h"
+#include "vtkInteractorStyleImage.h"
+#include <vtkCellPicker.h>
+#include <vtkCamera.h>
+#include <vtkPolyLine.h>
+#include <vtkDataSetMapper.h>
+#include <vtkUnstructuredGrid.h>
+
+#include "wxVTKRenderWindowInteractor.h"
+
+#include <vector>
+#include "wxVtkBaseView.h"
+#include "marTypes.h"
+#include "manualPoint.h"
+
+// --------------------------------------------------------------------------------------------
+// Includes the functionality to manage a contour without the spline line usage
+// @author RaC 09-09
+class creaMaracasVisu_EXPORT manualBaseModel
+{
+public:
+ manualBaseModel();
+ virtual ~manualBaseModel();
+
+ virtual manualBaseModel * Clone();
+ void CopyAttributesTo( manualBaseModel *cloneObject );
+ virtual void Open(FILE *ff); // virtual
+ virtual void Save(FILE *ff); // virtual
+ virtual int GetTypeModel(); // virtual
+
+ virtual void SetNumberOfPointsSpline(int size);
+
+ virtual int AddPoint(double x,double y,double z);
+ virtual int InsertPoint(double x,double y,double z);
+ virtual void InsertPoint_id(int id, double x,double y,double z);
+ virtual void AddManualPoint( manualPoint* theManualPoint );
+ virtual void DeletePoint(int i);
+ virtual void DeleteAllPoints();
+
+ virtual void MovePoint(int i,double dx,double dy,double dz);
+ virtual void MoveLstPoints(double dx,double dy,double dz);
+ virtual void MoveAllPoints(double dx,double dy,double dz);
+
+ // Returns the id of the point in the coordinates and the i_range given, according to the type
+ // which corresponds to the plane where it's necessary to find the point.
+ // @param type=-1 x,y,z - type=0 y,z - type=1 x,z - type=2 x,y
+ // @return int - Returns the id of the point in the coordinates given. Returns -1 otherwise.
+ virtual int GetIdPoint(double x, double y, double z, int i_range,int type);
+ virtual manualPoint* GetManualPoint(int id);
+ virtual int GetSizeLstPoints();
+ virtual double GetPathSize();
+ virtual void Transform_Ax_Plus_B (double Ax, double Bx, double Ay, double By);
+ virtual void GetSpline_i_Point(int i, double *x, double *y, double *z);
+ virtual void GetSpline_t_Point(double t, double *x, double *y, double *z);
+
+ //
+ // Returns the number of points of the spline line, but not the contour control points
+ // @return int - spline points size
+ //
+ virtual int GetNumberOfPointsSpline();
+ virtual void UpdateSpline();
+
+ //
+ // Returns a list with the actual model
+ // @return std::vector<manualBaseModel*>
+ //
+ virtual std::vector<manualBaseModel*> ExploseModel( );
+ virtual double GetPathArea();
+ virtual void GetNearestPointAndNormal(double *p, double *rp, double *rn);
+
+ virtual void SetCloseContour(bool closeContour);
+ virtual bool IfCloseContour();
+
+ // RaC 27-09-09 ----
+
+ //
+ // Returns true if the point with the coordinates in parameters is one of the points in
+ // the list of points of the model,
+ // @param x double
+ // @param y double
+ // @return true if the point with the coordinates in parameters is one of the points, false otherwise
+ //
+ int IsPoint(double x, double y);
+
+ // CMRU 17-08-09 -----------------------------------------------------------------
+
+ /*
+ * Assigns the parameter value to the label
+ * @param newLabel New label of the contour
+ */
+ virtual void SetLabel(std::string newLabel);
+
+ /*
+ * Assigns the parameter value to the real size
+ * @param newRealSize New real size in milimeters of the contour
+ */
+ virtual void SetRealSize(double newRealSize);
+
+ /**
+ * Returns the label of the contour
+ */
+ virtual std::string GetLabel();
+
+ /**
+ * Returns the real size in milimeters of the contour
+ */
+ virtual double GetRealSize();
+
+ /*
+ * Saves the label and the real size of the contour
+ * @param ff File where the information is stored
+ */
+ virtual void SaveData(FILE *ff);
+
+ /*
+ * Reads and interprets the information of the label and the real size
+ * @param ff File where the information is readed
+ */
+ virtual void OpenData(FILE *ff);
+
+protected:
+ int _sizePointsContour;
+ std::vector<manualPoint*> _lstPoints;
+
+};
+
+
+#endif // manualBaseModel_h
--- /dev/null
+#include "manualViewPoints.h"
+
+// ----------------------------------------------------------------------------
+manualViewPoints::manualViewPoints()
+{
+}
+
+// ----------------------------------------------------------------------------
+manualViewPoints::~manualViewPoints()
+{
+ int i,size=_copyViewPoints.size();
+ for (i=0;i<size; i++){
+ delete _copyViewPoints[i];
+ }
+ _copyViewPoints.clear();
+}
+
+
+// ----------------------------------------------------------------------------
+manualViewPoints * manualViewPoints :: Clone()
+{
+ manualViewPoints * clone = new manualViewPoints();
+ CopyAttributesTo(clone);
+ return clone;
+}
+
+// ---------------------------------------------------------------------------
+void manualViewPoints::CopyAttributesTo( manualViewPoints * cloneObject)
+{
+ // Fathers object
+ manualViewBaseContour::CopyAttributesTo(cloneObject);
+}
+
+// ----------------------------------------------------------------------------
+int manualViewPoints::GetType() // VIRTUAL
+{
+ return 7;
+}
+
+
+// ----------------------------------------------------------------------------
+bool manualViewPoints::ifTouchContour(int x,int y,int z) //VIRTUAL
+{
+ bool result=false;
+ double xx=x;
+ double yy=y;
+ double zz=z;
+ TransfromCoordViewWorld(xx,yy,zz);
+
+//EED 27 sep 2006
+ xx = xx * _spc[0];
+ yy = yy * _spc[1];
+ zz = zz * _spc[2];
+
+ int id = _manContModel->GetIdPoint(xx,yy,zz,_range,2);
+
+ if(id!=-1){
+ result = true;
+ }
+
+
+ return result;
+}
+
+// ----------------------------------------------------------------------------
+void manualViewPoints::Refresh() // VIRTUAL
+{
+ RefreshContour();
+ manualViewBaseContour::Refresh();
+}
+
+// ----------------------------------------------------------------------------
+void manualViewPoints::RefreshContour() // VIRTUAL
+{
+ int np = GetNumberOfPoints();
+ int copynp= _copyViewPoints.size();
+
+ while(copynp!=np){
+
+ if(copynp<np)
+ {
+ manualViewPoint *mvp = new manualViewPoint(_wxvtkbaseview);
+ vtkActor *actor = mvp->CreateVtkPointActor();
+ _wxvtkbaseview->GetRenderer()->AddActor( actor );
+
+ _copyViewPoints.push_back(mvp);
+ }//if
+ else if(copynp>np)
+ {
+ manualViewPoint *t = _copyViewPoints[0];
+ _wxvtkbaseview->GetRenderer()->RemoveActor( t->GetVtkActor() );
+ std::vector<manualViewPoint*>::iterator itNum = _copyViewPoints.begin();
+ _copyViewPoints.erase(itNum);
+ delete t;
+ }// else if
+ copynp= _copyViewPoints.size();
+
+ }// while
+
+ int i;
+ for(i=0;i<np;i++)
+ {
+ double xx = _manContModel->GetManualPoint(i)->GetX();
+ double yy = _manContModel->GetManualPoint(i)->GetY();
+ double zz = 900; // RaC REVISAR !!
+
+ manualViewPoint *mv = _copyViewPoints[i];
+
+ //Paints new Rectangular points bigger than the actual control points
+ mv->SetPositionXY(xx, yy, _range*2, zz);
+
+ vtkActor *_pointVtkActor = mv->GetVtkActor();
+
+ _pointVtkActor->GetProperty()->SetDiffuseColor( _coulorNormal_r , _coulorNormal_g , _coulorNormal_b );
+ if (_posibleSelected || (_posibleSelected && GetEditable() ) )
+ {
+ _pointVtkActor->GetProperty()->SetDiffuseColor( _coulorEdit_r , _coulorEdit_g , _coulorEdit_b );
+ }
+ if( _selected )
+ {
+ _pointVtkActor->GetProperty()->SetDiffuseColor( _coulorSelection_r , _coulorSelection_g , _coulorSelection_b );
+ }
+
+ //IF you want to customize the points which are going to be painted
+ //mv->UpdateColorActor(_colorViewPoints_r,_colorViewPoints_g,_colorViewPoints_b);
+ //mv->SetWidthLine(1.3);
+ }
+}
+
+// ----------------------------------------------------------------------------
+void manualViewPoints::ConstructVTKObjects() // VIRTUAL
+{
+ InitTextActor();
+}
+
+// ----------------------------------------------------------------------------
+void manualViewPoints::AddSplineActor() // VIRTUAL
+{
+ int i,size=_copyViewPoints.size();
+ for (i=0;i<size;i++)
+ {
+ _wxvtkbaseview->GetRenderer()->AddActor( _copyViewPoints[i]->GetVtkActor() );
+ }
+}
+
+// ----------------------------------------------------------------------------
+void manualViewPoints::RemoveSplineActor() // VIRTUAL
+{
+ int i,size=_copyViewPoints.size();
+ for (i=0;i<size;i++)
+ {
+ _wxvtkbaseview->GetRenderer()->RemoveActor(_copyViewPoints[i]->GetVtkActor());
+
+ }
+}
+
+
+
--- /dev/null
+#ifndef manualViewPoints_h
+#define manualViewPoints_h
+
+#include "manualViewBaseContour.h"
+#include "manualViewPoint.h"
+#include <vector>
+
+
+// --------------------------------------------------------------------------------------------
+// Class that includes the functionality to manage some selected points like a new contour
+// @author RaC 09-09
+class creaMaracasVisu_EXPORT manualViewPoints: public manualViewBaseContour
+{
+
+//---------------------------------------------------
+// PUBLIC METHODS & ATTS
+//---------------------------------------------------
+public:
+ //
+ // Class Constructor
+ //
+ manualViewPoints();
+
+ //
+ // Method to copy all attributes to the clone object references by parameter
+ // @param *cloneObject - manualViewPoints Clone object
+ ///
+ void CopyAttributesTo( manualViewPoints *cloneObject );
+
+ //---------------------------------------------------
+ // PUBLIC & VIRTUAL METHODS & ATTS
+ //---------------------------------------------------
+
+ ///
+ // Class Destructor. Delete all elements in points copy list
+ ///
+ virtual ~manualViewPoints();
+
+ //
+ // Method to clone a manualViewPoints object
+ //
+ virtual manualViewPoints * Clone();
+
+ //
+ // Returns the contour type
+ // Points Contour type := 7
+ // @return type - int
+ //
+ virtual int GetType();
+
+ //
+ // Returns true if the point with the (x,y,z) window coordinates touch the contour
+ // @param x - int
+ // @param y - int
+ // @param z - int
+ // @return true if touch contour, false otherwise
+ //
+ virtual bool ifTouchContour(int x,int y, int z);
+
+ //
+ // Refresh control points with the specified color, calls the RefreshContour method
+ // and render the contour
+ //
+ virtual void Refresh();
+
+ //
+ // Refresh contour. In this case, it synchronizes the copy list with the control points list in order
+ // to paint the point actors in the position assigned in the model points list
+ //
+ virtual void RefreshContour();
+
+ //
+ // Removes actor of the contour points, but no the control points.
+ //
+ virtual void RemoveSplineActor();
+
+ //
+ // Adds actor of the contour points, but no the control points.
+ //
+ virtual void AddSplineActor();
+
+ //
+ // Constructs VTKObjects. Only initializes text actor
+ //
+ virtual void ConstructVTKObjects();
+
+ //
+ // To move all the contour
+ //
+ //virtual void MoveContour(int x, int y, int z);
+
+//---------------------------------------------------
+// PRIVATE METHODS & ATTS
+//---------------------------------------------------
+private:
+
+ //
+ // Copy of the control points list. These are the points which are painted when the
+ // contour is not selected
+ //
+ std::vector<manualViewPoint*> _copyViewPoints;
+
+};
+
+#endif // manualViewPoints_h