Skip to content
Snippets Groups Projects
Node.h 2.63 KiB
Newer Older
  • Learn to ignore specific revisions
  • Lars Bilke's avatar
    Lars Bilke committed
     * \file
     * \author Karsten Rink
     * \date   2012-05-02
     * \brief  Definition of the Node class.
     *
     * \copyright
    
     * Copyright (c) 2012-2014, OpenGeoSys Community (http://www.opengeosys.org)
    
    Lars Bilke's avatar
    Lars Bilke committed
     *            Distributed under a Modified BSD License.
     *              See accompanying file LICENSE.txt or
    
    Lars Bilke's avatar
    Lars Bilke committed
     *              http://www.opengeosys.org/project/license
    
    Lars Bilke's avatar
    Lars Bilke committed
     *
    
     */
    
    #ifndef NODE_H_
    #define NODE_H_
    
    #include <cstdlib>
    #include <limits>
    #include <vector>
    
    #include "GeoLib/PointWithID.h"
    
    #include "MeshEditing/removeMeshNodes.h"
    
    Karsten Rink's avatar
    Karsten Rink committed
    #include "MeshSurfaceExtraction.h"
    
    #include "MeshGenerators/MeshLayerMapper.h"
    
    
    namespace MeshLib {
    
    class Element;
    
    /**
     * A mesh node with coordinates in 3D space.
     */
    
    class Node : public GeoLib::PointWithID
    
    	friend bool MeshLayerMapper::layerMapping(MeshLib::Mesh &mesh, const GeoLib::Raster &raster, double noDataReplacementValue);
    
    	friend MeshLib::Mesh* MeshSurfaceExtraction::getMeshSurface(const MeshLib::Mesh &mesh, const MathLib::Vector3 &dir, bool keep3dMeshIds);
    
    	/* friend classes: */
    
    Karsten Rink's avatar
    Karsten Rink committed
    	friend class Mesh;
    
    	friend class MeshRevision;
    
    Karsten Rink's avatar
    Karsten Rink committed
    	/// Constructor using a coordinate array
    
    	Node(const double coords[3], unsigned id = std::numeric_limits<unsigned>::max());
    
    Karsten Rink's avatar
    Karsten Rink committed
    
    	/// Constructor using single coordinates
    
    	Node(double x, double y, double z, unsigned id = std::numeric_limits<unsigned>::max());
    
    Karsten Rink's avatar
    Karsten Rink committed
    
    	/// Copy constructor
    
    	/// Return all the nodes connected to this one
    
    	const std::vector<MeshLib::Node*>& getConnectedNodes() const { return _connected_nodes; }
    
    	/// Get an element the node is part of.
    
    	const Element* getElement(unsigned idx) const { return _elements[idx]; }
    
    
    	/// Get all elements the node is part of.
    
    	const std::vector<Element*>& getElements() const { return _elements; }
    
    
    	/// Get number of elements the node is part of.
    
    	std::size_t getNElements() const { return _elements.size(); }
    
    Karsten Rink's avatar
    Karsten Rink committed
    	/// Destructor
    
    	virtual ~Node();
    
    protected:
    	/**
    	 * Add an element the node is part of.
    	 * This method is called by Mesh::addElement(Element*), see friend definition.
    	 */
    
    	void addElement(Element* elem) { _elements.push_back(elem); }
    
    	void setConnectedNodes(std::vector<Node*> &connected_nodes) { this->_connected_nodes = connected_nodes; }
    
    	/// Sets the ID of a node to the given value.
    
    	void setID(unsigned id) { this->_id = id; }
    
    	/// Update coordinates of a node.
    	/// This method automatically also updates the areas/volumes of all connected elements.
    	virtual void updateCoordinates(double x, double y, double z);
    
    }; /* class */
    
    } /* namespace */
    
    #endif /* NODE_H_ */