k-dot-p 0.1

shapes.h++

Go to the documentation of this file.
00001 /*
00002 
00003 
00004     Copyright (C) 2009 Joseph Pingenot
00005 
00006     This program is free software: you can redistribute it and/or modify
00007     it under the terms of the GNU Affero General Public License as published by
00008     the Free Software Foundation, either version 3 of the License, or
00009     (at your option) any later version.
00010 
00011     This program is distributed in the hope that it will be useful,
00012     but WITHOUT ANY WARRANTY; without even the implied warranty of
00013     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014     GNU Affero General Public License for more details.
00015 
00016     You should have received a copy of the GNU Affero General Public License
00017     along with this program.  If not, see <http://www.gnu.org/licenses/>.
00018 
00019 
00020 */
00021 
00022 #include <glib.h>
00023 #include <libmodelxx/function_specification.h++>
00024 
00025 #ifndef SHAPES_HXX__
00026 #define SHAPES_HXX__
00027 
00028 namespace kdotp {
00029   namespace libmodelxx {
00030     namespace grid {
00031 
00032 
00033       /*Enum contaning types of shapes we support
00034        *Shapes supported thus far:
00035        *  BLOCK: A "relatively positioned" block (center, width)
00036        *  ABSBLOCK: Absolutely positioned block (corner, opposite corner)
00037        *  DEFAULT: used when no other shape is specified.
00038        */
00039       enum shape_type {
00040   INVALID=-1,
00041   GLOBAL,       //Puts this material everywhere
00042   BLOCK,          //Block type shape
00043   ABSBLOCK      //Absolutely-positioned Block type shape
00044       };
00045 
00046       /*How to combine shapes*/
00047       enum shape_operation {
00048   OR,             //Total shape is an OR of the individual shapes
00049   XOR,
00050   AND,
00051   NOT,             //Unary not; operatos on l, not r (r=NULL)
00052   LEAF             //special "type"; a LEAF is just a plain shape.
00053       };
00054 
00055       /*Specifies a shape*/
00056       struct shape {
00057   /*How to combine the two shapes
00058    *NOTE: THIS MUST BE 'LEAF' here.
00059    */
00060   enum shape_operation op;
00061   /*Type of shape*/
00062   enum shape_type type;
00063   /*Is this a generic shape*/
00064   bool generic;
00065   /*Shape descriptor. The meaning of this is dependent upon the
00066     shape type. It is simply a list of functions.
00067     Units are nanometers
00068   */
00069   GList *descriptor;
00070       };
00071       /**
00072        * Specific types of shapes
00073        *\note shape_block is used for both a block and an absblock.
00074        *\note center and L are just two coordinate for an absblock.
00075        */
00076       struct shape_block {
00077   enum shape_operation op;
00078   enum shape_type type;
00079   bool generic;
00080   /*Coordinates in Cartesian real space of the center of the box*/
00081 	::kdotp::libmodelxx::postprocessing::function_exp* center;
00082   /*Length of a box edge, in Cartesian real space*/
00083 	::kdotp::libmodelxx::postprocessing::function_exp* L;
00084       };
00085       struct shape_global {
00086   enum shape_operation op;
00087   enum shape_type type;
00088   bool generic;
00089       };
00090 
00091       struct shape_tree {
00092   /*How to combine the two shapes*/
00093   enum shape_operation op;
00094   /*The shapes to be operated on: left, right*/
00095   struct shape_tree *l;
00096   struct shape_tree *r;
00097       };
00098 
00099       /*
00100        *Sets up and verifies a shape tree that was given by */
00101       struct shape_tree* postprocess_shape_tree(struct shape_tree* st, int dim);
00102 
00103 
00104       /*Frees a shape tree (includes just one shape)*/
00105       void shape_tree_free(struct shape_tree *st);
00106 
00107       /*Frees a specific shape instance*/
00108       void shape_free(struct shape *s);
00109 
00110 
00111       enum shape_type get_shape_from_identifier(const char* identifier);
00112 
00113       void get_string_from_shape_type(char** str, enum shape_type t);
00114 
00115     }
00116   }
00117 }
00118 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Defines