[QGIS Commit] r10298 - branches/analysis_branch/src/analysis/interpolation

svn_qgis at osgeo.org svn_qgis at osgeo.org
Thu Mar 19 12:53:51 EDT 2009


Author: mhugent
Date: 2009-03-19 12:53:51 -0400 (Thu, 19 Mar 2009)
New Revision: 10298

Added:
   branches/analysis_branch/src/analysis/interpolation/Node.cc
   branches/analysis_branch/src/analysis/interpolation/Node.h
Log:
Add missing class

Added: branches/analysis_branch/src/analysis/interpolation/Node.cc
===================================================================
--- branches/analysis_branch/src/analysis/interpolation/Node.cc	                        (rev 0)
+++ branches/analysis_branch/src/analysis/interpolation/Node.cc	2009-03-19 16:53:51 UTC (rev 10298)
@@ -0,0 +1,64 @@
+/***************************************************************************
+                          Node.cc  -  description
+                             -------------------
+    copyright            : (C) 2004 by Marco Hugentobler
+    email                : mhugent at geo.unizh.ch
+ ***************************************************************************/
+
+/***************************************************************************
+ *                                                                         *
+ *   This program is free software; you can redistribute it and/or modify  *
+ *   it under the terms of the GNU General Public License as published by  *
+ *   the Free Software Foundation; either version 2 of the License, or     *
+ *   (at your option) any later version.                                   *
+ *                                                                         *
+ ***************************************************************************/
+
+#include "Node.h"
+
+Node::Node( const Node& n )
+{
+  if ( n.getPoint() )
+  {
+    Point3D* point = new Point3D( n.getPoint()->getX(), n.getPoint()->getY(), n.getPoint()->getZ() );
+    mPoint = point;
+  }
+  else
+  {
+    mPoint = 0;
+  }
+
+  mNext = n.getNext();
+}
+
+
+Node& Node::operator=( const Node & n )
+{
+  Point3D* tmp = mPoint;
+
+  if ( n.getPoint() )//mPoint of n is not a null pointer
+  {
+    mPoint = new Point3D( n.getPoint()->getX(), n.getPoint()->getY(), n.getPoint()->getZ() );
+    if ( mPoint == 0 )//no memory
+    {
+      mPoint = tmp;
+      mNext = n.getNext();
+      return ( *this );
+    }
+
+  }
+  else//mPoint of n is a null pointer
+  {
+    mPoint = 0;
+  }
+
+  if ( tmp )
+  {
+    delete tmp;
+  }
+
+  mNext = n.getNext();
+  return ( *this );
+}
+
+

Added: branches/analysis_branch/src/analysis/interpolation/Node.h
===================================================================
--- branches/analysis_branch/src/analysis/interpolation/Node.h	                        (rev 0)
+++ branches/analysis_branch/src/analysis/interpolation/Node.h	2009-03-19 16:53:51 UTC (rev 10298)
@@ -0,0 +1,76 @@
+/***************************************************************************
+                          Node.h  -  description
+                             -------------------
+    copyright            : (C) 2004 by Marco Hugentobler
+    email                : mhugent at geo.unizh.ch
+ ***************************************************************************/
+
+/***************************************************************************
+ *                                                                         *
+ *   This program is free software; you can redistribute it and/or modify  *
+ *   it under the terms of the GNU General Public License as published by  *
+ *   the Free Software Foundation; either version 2 of the License, or     *
+ *   (at your option) any later version.                                   *
+ *                                                                         *
+ ***************************************************************************/
+
+#ifndef NODE_H
+#define NODE_H
+
+#include "Point3D.h"
+#include <iostream>
+
+/**Node is a class used by Line3D. It represents a node in the single directed linked list. Associated Point3D objects are deleted when the node is deleted.*/
+class Node
+{
+  protected:
+    /**Pointer to the Point3D object associated with the node*/
+    Point3D* mPoint;
+    /**Pointer to the next Node in the linked list*/
+    Node* mNext;
+  public:
+    Node();
+    Node( const Node& n );
+    ~Node();
+    Node& operator=( const Node& n );
+    /**Returns a pointer to the next element in the linked list*/
+    Node* getNext() const;
+    /**Returns a pointer to the Point3D object associated with the node*/
+    Point3D* getPoint() const;
+    /**Sets the pointer to the next node*/
+    void setNext( Node* n );
+    /**Sets a new pointer to an associated Point3D object*/
+    void setPoint( Point3D* p );
+};
+
+inline Node::Node() : mPoint( 0 ), mNext( 0 )
+{
+
+}
+
+inline Node::~Node()
+{
+
+}
+
+inline Node* Node::getNext() const
+{
+  return mNext;
+}
+
+inline Point3D* Node::getPoint() const
+{
+  return mPoint;
+}
+
+inline void Node::setNext( Node* n )
+{
+  mNext = n;
+}
+
+inline void Node::setPoint( Point3D* p )
+{
+  mPoint = p;
+}
+
+#endif



More information about the QGIS-commit mailing list