]> Creatis software - creaMaracasVisu.git/blob - lib/maracasVisuLib/src/interface/wxWindows/widgets/pPlotter/pGraphicalFunction.cxx
creaMaracasVisu Library
[creaMaracasVisu.git] / lib / maracasVisuLib / src / interface / wxWindows / widgets / pPlotter / pGraphicalFunction.cxx
1
2 //----------------------------------------------------------------------------
3 // Class definition include
4 //----------------------------------------------------------------------------
5 #include "pGraphicalFunction.h"
6 #include "math.h"
7 #include <iostream>
8 #include <fstream>
9 #include <string>
10 #include <vector>
11
12 // ----------------------------------------------------------------------------
13 // WX headers inclusion.
14 // For compilers that support precompilation, includes <wx/wx.h>.
15 // ----------------------------------------------------------------------------
16
17 #ifndef WX_PRECOMP
18 #include <wx/wx.h>
19 #endif
20
21 //----------------------------------------------------------------------------
22 // Class implementation
23 //----------------------------------------------------------------------------
24
25 IMPLEMENT_CLASS(pGraphicalFunction, pPlotterLayer)
26
27 pGraphicalFunction:: pGraphicalFunction(wxString name, int flags)
28 {
29         SetName(name);
30         showPointsF = false;
31         validPointRange = 5;
32         logicFunction = new pLogicalFunction ();
33         fromWindow=false;
34         factorZoom=1;
35         drawing=false;
36         editable=true;
37         ifActual=false;
38         zoomIn=false;
39         setOffsetX(0);
40         setOffsetY(0);
41         initialDrawingPoint=NULL;
42         finalDrawingPoint=NULL;
43         //type=1 means that is going to be a piecewise function
44         _type=1;
45         xKSpline=NULL;
46         yKSpline=NULL;
47         offsetPixelX=0;
48         offsetPixelY=0;
49         xTraslation=0;
50         mType=DEFAULT;
51 }
52
53 /**
54 * Is the destructor!!!
55 */
56 pGraphicalFunction :: ~ pGraphicalFunction ()
57 {
58         
59 }
60
61 //set if the function has to draw the points
62 void pGraphicalFunction::SetShowPoints(bool showPoints)
63 {
64         showPointsF = showPoints;
65 }
66 //get the paramater showPointsF
67 bool pGraphicalFunction::getShowPoints()
68 {
69         return showPointsF;
70 }
71 /*
72  * Set Up startPoint, endPoint, maxY,maxX points        
73 */
74 void pGraphicalFunction::setUp()
75 {
76         logicFunction->setUp();
77         setMaxX(logicFunction->getMaxX());
78         setMinX(logicFunction->getMinX());
79         setMaxY(logicFunction->getMaxY());
80         setMinY(logicFunction->getMinY());
81         setStartX(logicFunction->getStartX());
82         setEndX(logicFunction->getEndX());
83         setStartY(logicFunction->getStartY());
84         setEndY(logicFunction->getEndY());
85         
86 }
87
88 /*
89 * validate if the function has that point in a sensible area returning the index where the point was found or -1 if is in not part of the function: define the sensible area is  
90 * x1-validPointRange<x<x1+validPointRange y1-validPointRange<y<y1+validPointRange
91 */
92 int pGraphicalFunction::validPointOnFunction(wxPoint realPoint)
93 {
94         return (logicFunction -> validPointOnFunction (realPoint));
95 }
96 /*
97 * returns the index in the list of the point 
98 */
99 int pGraphicalFunction::getIndexOf(wxPoint realpoint)
100 {
101         return logicFunction -> getIndexOf( realpoint );        
102 }
103
104 /*
105 * This metohd returns the node of the point that is the movingPointIndex position in the list of points.
106 * @param: int movingPointIndex, Is the index value of the searched node. 
107 * @return: Return a pointer to the node corresponding to the index value by parameter.
108 */
109 wxNode* pGraphicalFunction::GetPointAt( int movingPointIndex )
110 {
111         return logicFunction -> GetPointAt ( movingPointIndex );        
112 }
113 /*
114  * Set the scales of the function in x and y
115  * 
116  */
117 void pGraphicalFunction::setScales()
118 {
119         //int dx= logicFunction->getMaxX()-logicFunction->getMinX();
120         //int dy= logicFunction->getMaxY()-logicFunction->getMinY();
121         int dx= maxShowedX-minShowedX;
122         int dy= maxShowedY-minShowedY;
123         
124         
125         if(dx!=0 && dy!=0)
126         {
127                 double scaleX=(((float)(screenX-100))/dx)*factorZoom;
128                 double scaleY=(((float)(screenY-50))/dy)*factorZoom;
129                 setScaleX(scaleX);
130                 setScaleY(scaleY);
131                 logicFunction->setScaleX(scaleX);
132                 logicFunction->setScaleY(scaleY);
133
134         }
135 }
136 /*
137 * Includes a point between two existing points of this function. The new point (x,y) was not defined when the function was created.
138 * @return Returns true is the point was succcesfully added to the funcion.
139 */
140 bool pGraphicalFunction:: AddNewPoint(int x,int y)
141 {
142         bool added= logicFunction -> AddNewPoint ( x, y );
143         if(!fromWindow)
144          setUp();
145         else
146         {
147                 logicFunction->setEndPoints();
148                 logicFunction->setStartPoints();
149         }
150         return added;
151 }
152
153 /*
154 * This tries to Add a point to the function if possible it returns true.
155 * @pre: The list of existing points is ordered.
156 * @param: int aX, The x value of the point.
157 * @param: int aY, The y value of the point.
158 * @param: return Returns TRUE if the point was succesfuly included in the realPoints list.
159 */
160 bool pGraphicalFunction::AddPoint(int aX, int aY,bool order) 
161 {       
162         
163         bool added=logicFunction -> AddPoint( aX, aY,order );
164         if(!fromWindow)
165          setUp();
166         else
167         {
168                 logicFunction->setEndPoints();
169                 logicFunction->setStartPoints();
170         }
171         return added;
172 }
173
174 /**
175 * deletes the point given by the  user  from the collection of logical points of the function
176 * is not used
177 */
178
179 bool pGraphicalFunction::DeletePoint(int aX, int aY) 
180 {
181         bool added= logicFunction -> DeletePoint( aX, aY );     
182         if(!fromWindow)
183          setUp();
184         else
185         {
186                 logicFunction->setEndPoints();
187                 logicFunction->setStartPoints();
188         }
189         return added;
190 }
191
192 /**
193 * deletes a point of the functio given its index
194 */
195 bool pGraphicalFunction::deletePointAt(int index)
196 {
197         bool added=logicFunction -> deletePointAt( index );
198         if(!fromWindow)
199          setUp();
200         else
201         {
202                 logicFunction->setEndPoints();
203                 logicFunction->setStartPoints();
204         }
205         return added;
206 }
207
208 /**
209 * Change de coordinates of the given index point to the newCoords, if it is possible and return the result of the invoked action. 
210 * @retun Return TRUE if it was possible to do the change. A valid change is when the new x value of the point is still between the previous and next point, when condition.
211 */
212 bool pGraphicalFunction::changePoint(wxPoint newCoords, int movingIndexPoint) 
213 {
214         bool added= (logicFunction -> changePoint( newCoords, movingIndexPoint ));
215         if(!fromWindow)
216          setUp();
217         else
218         {
219                 logicFunction->setEndPoints();
220                 logicFunction->setStartPoints();
221         }
222         return added;
223 }
224 /**
225 * Evaluates if the given point belongs to the function.
226 */
227 /*
228 bool pGraphicalFunction::hasPoint(wxPoint aPoint) 
229 {
230         return logicFunction -> hasPoint( aPoint );     
231 }
232
233 /**
234 * Returns the real x values of the control points of the function. It dont includes the points calculated by interpolation.
235 */
236 double* pGraphicalFunction::getX_RealValues() 
237 {
238         return (logicFunction -> getX_RealValues( ));   
239 }
240
241 /**
242 * Returns the real y values of the control points of the function. It dont includes the points calculated by interpolation.
243 */
244 double * pGraphicalFunction::getY_RealValues() 
245 {  
246
247         return (logicFunction -> getY_RealValues());    
248 }
249
250 //----------------------------------
251 // Asking if it has a point (x,y)
252 //----------------------------------
253
254 /*
255 * returns true if the point is along the function
256 * false otherway
257 */
258 bool pGraphicalFunction:: isInFunction(int x, int y)
259 {
260         wxNode* before;
261         wxNode* next;
262         pFunctionPoint* point= new pFunctionPoint(x,y);
263         bool inLine;
264         before=getBefore(point);
265
266         if(before && before->GetNext())
267         {
268                 next = before->GetNext();
269                 //next = (before->GetNext())->GetNext();
270                 inLine= isInLine((pFunctionPoint*)before->GetData(),(pFunctionPoint*)next->GetData(),point);
271         }
272         else 
273                 inLine=false;
274         return inLine;
275 }
276 /*
277 * give us the point that is in the function and is exactly before
278 * the point we are giving
279 */
280 wxNode* pGraphicalFunction:: getBefore(pFunctionPoint* point)
281 {
282         int minDiference=10000000;
283         wxNode* node=logicFunction->GetPointAt(0);
284         wxNode* before=NULL;
285         while(node)
286         {
287                 pFunctionPoint* before1=(pFunctionPoint*)node->GetData();
288                 int beforeX=before1->getRealX();
289                 int pointX=point->getRealX();
290                 if(beforeX<pointX)
291                 {
292                   int minDiference1=pointX-beforeX;
293                   if(minDiference1<minDiference)
294                   {
295                           minDiference=minDiference1;
296                           before=node;
297                   }
298                 }
299                 node=node->GetNext();
300         }
301         return before;
302 }
303 /*
304 * Returns true if the point is in the line
305 */
306 bool pGraphicalFunction::isInLine(pFunctionPoint* before,pFunctionPoint* next, pFunctionPoint* point)
307 {
308         int x1,x2,x,y1,y2,y;
309         
310         x1=(float)before->getRealX();
311         x2=(float)next->getRealX();
312         y1=(float)before->getRealY();
313         y2=(float)next->getRealY();
314         x=(float)point->getRealX();
315         y=(float)point->getRealY();
316
317         
318         float d1= (float)sqrt(pow(float(x1-x),2)+ pow(float(y1-y),2));
319         float d2= (float)sqrt(pow(float(x2-x),2)+ pow(float(y2-y),2));
320         float d=(float)sqrt(pow(float(x2-x1),2)+ pow(float(y2-y1),2));
321         if(d1+d2<=(d*1.1) && d1<=d && d2<=d)
322                 return true;
323         return false;
324 }
325 /**
326 * give us the value of y in the line define by the arguments
327 */
328 double pGraphicalFunction::interpolateY(double m, int x1,int y1,int x)
329 {
330         return m*(x-x1)+y1;
331 }
332
333 //----------------------------
334 //NEW METHODS
335 //----------------------------
336
337 //----------------------------
338 // Spline Methods
339 //----------------------------
340
341
342         /*
343         * clear the spline vectors
344         */
345         void pGraphicalFunction:: clearSplineVectors()
346         {
347                 xSpline.clear();
348                 ySpline.clear();
349         }
350
351         /*
352         Initiliaze xSpline and ySpline vectors
353         */
354         void pGraphicalFunction:: initializeSplines()
355         {
356                 if(xKSpline==NULL)
357                         xKSpline = vtkKochanekSpline::New();
358                 if(yKSpline==NULL)
359                         yKSpline= vtkKochanekSpline::New();
360                 addSplinesPoints();
361
362         }
363
364         /*
365         Add the (x,y) points of the function to the 
366         spline
367         */
368         void pGraphicalFunction::addSplinesPoints()
369         {
370                 xKSpline->RemoveAllPoints();
371                 yKSpline->RemoveAllPoints();
372                 wxNode *node= logicFunction->GetPointAt(0);
373                 pFunctionPoint* p;
374                 int i=0;
375                 while(node)
376                 {
377                         p=(pFunctionPoint*)node->GetData();
378                         xKSpline->AddPoint(i,p->getRealX());
379                         yKSpline->AddPoint(i,p->getRealY());
380                         i++;
381                         node=node->GetNext();
382                 }
383         }
384         /*
385          This Method adds the point calculated by
386          the splines to the vectors
387         */
388         void pGraphicalFunction:: initializeSplineVectors()
389         {
390                 double x=0,y=0,t,delta;
391                 int i,np,nps;
392                 //realPoints.DeleteC  
393
394                 np = logicFunction->getSizePoints();
395                 nps = 100;
396                 delta=( double ) ( np ) / ( double ) ( nps );
397                 for( i = 0; i < nps; i++ )
398                 {
399                   t = delta * (double)i;
400                   GetSplinePoint(t,x,y);
401                   xSpline.push_back(x);
402                   ySpline.push_back(y);
403                 }
404         }
405         /*
406          get the spline point for t, in xKSpline and yKSpline
407         */
408         void pGraphicalFunction::GetSplinePoint(double t, double &x, double &y)
409         {
410                 if (logicFunction->getSizePoints()==0)
411                 {
412                         x = 0;
413                         y = 0;
414                 }
415                 if (logicFunction->getSizePoints()>=2)
416                 {
417                         x = xKSpline->Evaluate(t);
418                         y = yKSpline->Evaluate(t);
419                 }
420         }
421
422 //------------------------------
423 // Zoom Methods
424 //------------------------------
425
426 /**
427 This method set the initial point and the final point of drawing
428 according with the width of the square around the point clicked
429 @param clickedX
430 @param clickedY
431 @param width: width of the square
432 Note: all the parameters are pixels
433 Pre: screenX, screenY, zoom are set! with the actual data.
434 DEPRECATED!
435 */
436 void pGraphicalFunction::zooming(int clickedX,int clickedY,int width)
437 {
438         int xS,yS,x1,x2,y1,y2;
439         setScales();
440         xS=clickedX/_scaleX+_offsetX;
441         yS=clickedY/_scaleY+_offsetY;
442         //square
443         x1=(clickedX-width)/_scaleX+_offsetX;
444         x2=(clickedX+width)/_scaleX+_offsetX;
445         y1=(clickedY-width)/_scaleY+_offsetY;
446         y2=(clickedY+width)/_scaleY+_offsetY;
447
448         int numberPoints=getSizePoints();
449         pFunctionPoint* point;
450         wxNode* p;
451         bool inSquare=false,first=false;
452         
453         //if the user made a zoom
454         if(zoomIn)
455         {
456                 int i;
457                 for(i=0; i<numberPoints;i++)
458                 {
459                         p=logicFunction->GetPointAt(i);
460                         point=(pFunctionPoint*)p->GetData();
461                         int rx=point->getRealX();
462                         int ry=point->getRealY();
463                         inSquare= rx>=x1 && rx<=x2; //&& ry>=y1 && ry<=y2;
464                         if(inSquare)
465                         {
466                                 if(!first)
467                                 {
468                                         initialDrawingPoint=point;
469                                         _offsetX=rx;
470                                         _offsetY=ry;
471                                         first=true;
472                                 }
473                                 finalDrawingPoint=point;
474                         }
475                 }
476         }       
477         else
478         {
479                 //We extend the range of vision in x and y,20 and 10 respectively
480                 if((_offsetX-20)>=0)
481                 {
482                         _offsetX=_offsetX-20;
483                 }
484                 else
485                         _offsetX=0;
486                 if((_offsetY-10)>=0)
487                 {
488                         _offsetY=_offsetY-10;
489                 }
490                 else
491                         _offsetY=0;
492         }
493 }
494
495         /*
496         This method sets the offsets according with the point 
497         clicked on the window
498         @param offx: x-value of the point clicked
499         @param offx: y-value of the point clicked
500         Note: all the parameters are pixels
501         Pre: screenX, screenY are set! with the actual data.
502         Pos: Sets the value of minXshowed,minYshowed 
503         */
504         void pGraphicalFunction::setOffsets(int offx,int offy)
505         {
506                 int xS,yS;
507
508                 setScales();
509                 
510                 xS=(offx-offsetPixelX)/_scaleX+_offsetX + minShowedX;
511                 yS=(offy-offsetPixelY)/_scaleY+_offsetY+ minShowedY;
512                 
513                 setOffsetX(xS);
514                 setOffsetY(yS);
515                         
516                 //setMinShowedX(xS);
517                 //setMinShowedY(yS);
518
519                 setOffsetPixelX(offx);
520                 setOffsetPixelY(offy);
521                 //setMinShowed();
522         }
523         /*
524         *  This method sets the minShowedX 
525         *  and the minShowedY, accordig to the offset in
526         *  x-axis and y-axis respectively
527         *  pre: _offsetX>=0,_offsetY>=0
528         *               screenX and screenY are set with the actual size of the window
529         *               scaleX and scaleY are set to the actual size of the window
530         * DEPRECATED!
531         */
532         void pGraphicalFunction::setMinShowed()
533         {
534                 bool firstX=false,firstY=false;
535                 
536                 wxNode* node=logicFunction->GetPointAt(0);
537                 pFunctionPoint* p;
538
539                 float middleWX=(((float)(screenX-100))/2)/scaleX;
540                 float middleWY=(((float)(screenY-50))/2)/scaleY;
541                 
542                 //node=node->GetNext(); 
543                 while(node)
544                 {
545                         p=(pFunctionPoint*)node->GetData();
546                         int px=p->getRealX();
547                         int py=p->getRealY();
548                         int x=(px-_offsetX);//+middleWX;
549                         int y=(py-_offsetY);//+middleWY;
550                         if(!firstX && x>=0)
551                         {
552                                 firstX=true;
553                                 setMinShowedX(px);
554                         }
555                         if(!firstY && y>=0)
556                         {
557                                 firstY=true;
558                                 setMinShowedY(py);
559                         }       
560                         node=node->GetNext();
561                 }
562         }
563
564 //-----------------------
565 // Persistence
566 //-----------------------
567
568 /*
569  Save the points of the function
570 */
571 void pGraphicalFunction::save(wxString fileName)
572 {
573         
574         logicFunction->save(fileName);
575
576 }
577 /*
578  Load the points of a function 
579 */
580 void pGraphicalFunction::load(wxString fileName)
581 {
582         logicFunction->load(fileName);
583         logicFunction->setUp();
584         setMaxShowedX(logicFunction->getMaxX());
585         setMinShowedX(logicFunction->getMinX());
586         setMaxShowedY(logicFunction->getMaxY());
587         setMinShowedY(logicFunction->getMinY());
588 }
589         
590 //--------------------------
591 //GETTERS AND SETTERS
592 //---------------------------
593 /**
594 * actual
595 */
596 void pGraphicalFunction::setActual(bool act)
597 {
598   ifActual=act;
599 }
600 bool pGraphicalFunction:: getActual()
601 {
602         return ifActual;
603 }
604 /**
605 * SCALE WAY
606 * DEFECT_SCALE 1
607 * MAX_SCALE 2
608 * USER_SCALE 3
609 */
610 void pGraphicalFunction::setScaleWay(int typeS)
611 {
612   scaleWay=typeS;
613 }
614
615 int pGraphicalFunction:: getScaleWay()
616 {
617  return scaleWay;
618 }
619
620
621 /*
622 * SCREEN
623 */
624 void pGraphicalFunction::setScreenX(int scrX)
625 {
626   this->screenX=scrX;
627 }
628 int pGraphicalFunction::getScreenX()
629 {
630   return this->screenX;
631 }
632 void pGraphicalFunction::setScreenY(int scrY)
633 {
634   this->screenY=scrY;
635 }
636 int pGraphicalFunction::getScreenY()
637 {
638   return this->screenY;
639 }
640
641
642 /*
643 * STARTS
644 */
645 void pGraphicalFunction::setStartX(double aStartX) {
646         
647         logicFunction->setStartX(aStartX);
648         this->_startX =logicFunction->getStartX();
649 }
650
651 double pGraphicalFunction::getStartX() 
652 {
653         return logicFunction->getStartX();
654 }
655
656 void pGraphicalFunction::setStartY(double aStartY) 
657 {
658         logicFunction->setStartY(aStartY);
659         this->_startY = aStartY;
660 }
661
662 double pGraphicalFunction::getStartY() {
663         return logicFunction->getStartY();
664 }
665 /*
666 * ENDs
667 */
668 void pGraphicalFunction::setEndX(double aEndX) 
669 {
670         logicFunction->setEndX(aEndX);
671         this->_endX = aEndX;
672 }
673
674 double pGraphicalFunction::getEndX() {
675         return logicFunction->getEndX();
676 }
677
678 void pGraphicalFunction::setEndY(double aEndY) {
679         logicFunction->setEndY(aEndY);
680         this->_endY = aEndY;
681 }
682
683 double pGraphicalFunction::getEndY() {
684         return logicFunction->getEndY();
685 }
686 /*
687  * SCALES
688  */
689 void pGraphicalFunction::setScaleX(double aScaleX) 
690 {
691         logicFunction->setScaleX(aScaleX);
692         this->_scaleX = aScaleX;
693 }
694
695 double pGraphicalFunction::getScaleX() 
696 {
697         return this->_scaleX;
698 }
699
700 void pGraphicalFunction::setScaleY(double aScaleY) 
701 {
702         logicFunction->setScaleY(aScaleY);
703         this->_scaleY = aScaleY;
704 }
705
706 double pGraphicalFunction::getScaleY() {
707         return this->_scaleY;
708 }
709 /*
710  * Mins
711  */
712 void pGraphicalFunction::setMinX(double aMinX) 
713 {
714         logicFunction->setMinX(aMinX);
715         this->_minX = aMinX;
716 }
717
718 double pGraphicalFunction::getMinX() 
719 {
720         return logicFunction->getMinX();
721 }
722
723 void pGraphicalFunction::setMinY(double aMinY) 
724 {
725         logicFunction->setMinY(aMinY);
726         this->_minY = aMinY;
727 }
728
729 double pGraphicalFunction::getMinY() {
730         return logicFunction->getMinY();
731 }
732 /*
733  * MAXS
734  */
735 void pGraphicalFunction::setMaxX(double aMaxX) 
736 {
737         logicFunction->setMaxX(aMaxX);
738         this->_maxX = aMaxX;
739 }
740
741 double pGraphicalFunction::getMaxX() 
742 {
743         return logicFunction->getMaxX();
744 }
745
746 void pGraphicalFunction::setMaxY(double aMaxY) 
747 {
748         logicFunction->setMaxY(aMaxY);
749         this->_maxY = aMaxY;
750 }
751
752 double pGraphicalFunction::getMaxY() {
753         return logicFunction->getMaxY();
754 }
755
756 /*
757  * OFFSETS
758  */
759 void pGraphicalFunction::setOffsetX(double aOffsetX) 
760 {
761         logicFunction->setOffsetX(aOffsetX);
762         this->_offsetX = aOffsetX;
763 }
764
765 double pGraphicalFunction:: getOffsetX() 
766 {
767         
768         return this->_offsetX;
769 }
770
771 void pGraphicalFunction:: setOffsetY(double aOffsetY) 
772 {
773         logicFunction->setOffsetY(aOffsetY);
774         this->_offsetY = aOffsetY;
775 }
776
777 double pGraphicalFunction:: getOffsetY() {
778         return this->_offsetY;
779 }
780
781 /*
782  * TYPE
783  */
784 void pGraphicalFunction:: setType(int aType) 
785 {
786         logicFunction->setType(aType);
787         this->_type = aType;
788 }
789
790 int pGraphicalFunction :: getType() {
791         return this->_type;
792 }
793
794 /*
795  * validPoint
796  */
797 int pGraphicalFunction :: getValidPointRange()
798 {
799         return validPointRange;
800 }
801
802 void pGraphicalFunction :: setValidPointRange(int theRange)
803 {
804         logicFunction->setValidPointRange(theRange);
805         validPointRange = theRange;
806 }
807 /*
808 * Returns the number of points that the function
809 * has
810 */
811 int pGraphicalFunction :: getSizePoints()
812 {
813         return logicFunction->getSizePoints();
814 }
815
816 /*
817 * Sets the color points of the function by teh given parameter
818 * @param colorVector Is the color points vector to set
819 */
820 void pGraphicalFunction :: setColorPoints(std::vector<pColorPoint *> &colorVector)
821 {
822         f_colorPoints.clear();
823         int i = 0;      
824         while(i<colorVector.size())
825         {
826                 f_colorPoints.push_back(colorVector[i]);                
827                 i++;
828         }
829 }
830
831 /*
832 * Gets the color points of the function in the given parameter
833 * @param colorVector Is the color points list to get the points
834 */
835 void pGraphicalFunction :: getColorPoints(std::vector<pColorPoint *> &colorVector)
836 {
837         int i = 0;      
838         while(i<f_colorPoints.size())
839         {
840                 pColorPoint * originaslPoint = f_colorPoints[i];
841                 pColorPoint * copyPoint = new pColorPoint(originaslPoint->getRealX(), originaslPoint->getColor(), originaslPoint->isTemporalColor());
842                 colorVector.push_back(copyPoint);               
843                 i++;
844         }
845 }
846
847