/******************************************************** * ██████╗ ██████╗████████╗██╗ * ██╔════╝ ██╔════╝╚══██╔══╝██║ * ██║ ███╗██║ ██║ ██║ * ██║ ██║██║ ██║ ██║ * ╚██████╔╝╚██████╗ ██║ ███████╗ * ╚═════╝ ╚═════╝ ╚═╝ ╚══════╝ * Geophysical Computational Tools & Library (GCTL) * * Copyright (c) 2023 Yi Zhang (yizhang-geo@zju.edu.cn) * * GCTL is distributed under a dual licensing scheme. You can redistribute * it and/or modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation, either version 2 * of the License, or (at your option) any later version. You should have * received a copy of the GNU Lesser General Public License along with this * program. If not, see . * * If the terms and conditions of the LGPL v.2. would prevent you from using * the GCTL, please consider the option to obtain a commercial license for a * fee. These licenses are offered by the GCTL's original author. As a rule, * licenses are provided "as-is", unlimited in time for a one time fee. Please * send corresponding requests to: yizhang-geo@zju.edu.cn. Please do not forget * to include some description of your company and the realm of its activities. * Also add information on how to contact you by electronic and paper mail. ******************************************************/ #ifndef _GCTL_NODE_H #define _GCTL_NODE_H #include "vertex.h" #include "entity.h" namespace gctl { // Declaration of the basic node type template struct type_node; // node type of attribute type of void typedef type_node enode; /** * @brief 点结构体 */ template struct type_node : public entity { /** * Constructor */ type_node(); /** * @brief Set object from parameters * * @warning This function will locate memories to store vertice * * @param[in] p0 The location point * @param[in] index The element index */ type_node(const point3dc &p0, int index = 0); /** * @brief Set object's parameters * * @param vert0 The location vertex * @param[in] index The index */ type_node(vertex3dc &vert0, int index = 0); /** * @brief De-constructor */ virtual ~type_node(){} /** * @brief Set object from parameters * * @warning This function will locate memories to store vertice * * @param[in] p0 The location point * @param[in] index The element index */ void set(const point3dc &p0, int index = 0); /** * @brief Set object's parameters * * @param vert0 The location vertex * @param[in] index The index */ void set(vertex3dc &vert0, int index = 0); /** * @brief Reset the structure to initial state */ void reset(); }; template type_node::type_node() : entity::entity(){} template type_node::type_node(const point3dc &p0, int index) : type_node() { set(p0, index); } template type_node::type_node(vertex3dc &vert0, int index) : type_node() { set(vert0, index); } template void type_node::set(const point3dc &p0, int index) { if (index < 0) { throw out_of_range("Invalid index number, From type_node::set(...)"); } this->vert[0] = new vertex3dc; this->self_host = true; this->id = index; this->vert[0]->set(p0, index); return; } template void type_node::set(vertex3dc &vert0, int index) { if (index < 0) { throw out_of_range("Invalid index number, From type_node::set(...)"); } this->id = index; this->vert[0] = &vert0; return; } template void type_node::reset() { entity::reset(); return; } template void copy_type_node(type_node *tar, const type_node *src) { copy_entity(tar, src); return; } } #endif // _GCTL_NODE_H