LCOV - code coverage report
Current view: top level - core/meshkit - MKCore.hpp (source / functions) Hit Total Coverage
Test: coverage_sk.info Lines: 40 54 74.1 %
Date: 2020-07-01 15:24:36 Functions: 13 14 92.9 %
Branches: 12 46 26.1 %

           Branch data     Line data    Source code
       1                 :            : #ifndef MESHKIT_MKCORE_HPP
       2                 :            : #define MESHKIT_MKCORE_HPP
       3                 :            : 
       4                 :            : /** \file MKCore.hpp
       5                 :            :  */
       6                 :            : #include "meshkit/Types.hpp"
       7                 :            : #include "meshkit/Error.hpp"
       8                 :            : #include "meshkit/MKGraph.hpp"
       9                 :            : #include "meshkit/iGeom.hpp"
      10                 :            : #include "moab/Interface.hpp"
      11                 :            : #include "meshkit/iMesh.hpp"
      12                 :            : #include "meshkit/iRel.hpp"
      13                 :            : #include "lemon/list_graph.h"
      14                 :            : #include <vector>
      15                 :            : 
      16                 :            : namespace MeshKit {
      17                 :            : 
      18                 :            :       //! Forward declare since we store a vector of these
      19                 :            : class SizingFunction;
      20                 :            : 
      21                 :            :       //! Single instance of VertexMesher
      22                 :            : class VertexMesher;
      23                 :            : 
      24                 :            :       //! Single instance of EBMesher
      25                 :            : class EBMesher;
      26                 :            : 
      27                 :            :       //! Returned by some MKCore functions
      28                 :            : class MeshOpProxy;
      29                 :            : 
      30                 :            : /** \class MKCore MKCore.hpp "meshkit/MKCore.hpp"
      31                 :            :  * \brief The core MeshKit instance
      32                 :            :  *
      33                 :            :  * The MKCore object stores MeshKit-wide data like the geometry/mesh/relations instances,
      34                 :            :  * and is the object through which other MeshKit class objects are accessed.  Since it is
      35                 :            :  * a child class of MeshOp, the MKCore instance can also be a node in the MeshOp graph.  By
      36                 :            :  * convention, the MKCore instance serves as the root of the this (directed) graph.
      37                 :            :  *
      38                 :            :  * If the MKCore constructor is called with no arguments, then instances of the geometry, mesh,
      39                 :            :  * and relations databases are created inside the constructor; these instances are then deleted
      40                 :            :  * in the MKCore destructor.  If this is not the desired behavior, either pass in non-NULL
      41                 :            :  * instances to the MKCore constructor, or re-set the iCreatedIgeom, iCreatedMoab,
      42                 :            :  * and/or iCreatedIrel flags in this class.
      43                 :            :  */
      44                 :            : 
      45                 :            : class MKCore : public MKGraph
      46                 :            : {
      47                 :            : public:
      48                 :            : 
      49                 :            :     /** \name Constructor/destructor */
      50                 :            : 
      51                 :            :     /**@{*/
      52                 :            : 
      53                 :            :     /** \brief Constructor
      54                 :            :      * \param igeom iGeom instance
      55                 :            :      * \param moab MOAB instance
      56                 :            :      * \param imesh iMesh instance; if non-NULL, should use/point to moab parameter
      57                 :            :      * \param irel iRel instance
      58                 :            :      * \param construct_missing_ifaces If true, constructs the interfaces whose handles are passed in NULL
      59                 :            :      */
      60                 :            :   MKCore(iGeom *igeom = NULL, 
      61                 :            :          moab::Interface *moab = NULL, 
      62                 :            :          iMesh *imesh = NULL, 
      63                 :            :          iRel *irel = NULL,
      64                 :            :          bool construct_missing_ifaces = true);
      65                 :            :   
      66                 :            :     //! virtual destructor
      67                 :            :   virtual ~MKCore();
      68                 :            : 
      69                 :            :     /**@}*/
      70                 :            : 
      71                 :            :     /** \brief Register a new MeshOp factory
      72                 :            :      * \param proxy class-specific (as opposed to instance-specific) polymorphic methods
      73                 :            :      */
      74                 :            :   static void register_meshop(MeshOpProxy* proxy);
      75                 :            :   
      76                 :            :     /** \brief Return the MeshOp type with the given name
      77                 :            :      * \param op_name Operation name requested
      78                 :            :      * \return MeshOpProxy for the corresponding MeshOp type
      79                 :            :      */
      80                 :            :   static MeshOpProxy* meshop_proxy(const char *op_name);
      81                 :            :   
      82                 :            :     /** \brief Return the MeshOp type at the sepcified index
      83                 :            :      * \param index Operation index requested
      84                 :            :      * \return MeshOpProxy for the corresponding MeshOp type
      85                 :            :      */
      86                 :            :   static MeshOpProxy* meshop_proxy(unsigned index);
      87                 :            :   
      88                 :            :     /**\brief Number of registered MeshOps
      89                 :            :      *
      90                 :            :      *\return One more than largest possible MeshOp index
      91                 :            :      */
      92                 :            :   static unsigned num_meshops();
      93                 :            :   
      94                 :            :     /** \brief Return the MeshOp index given the name
      95                 :            :      * \param op_name Operation name requested
      96                 :            :      * \return OpInfo index for the corresponding MeshOp type
      97                 :            :      */
      98                 :            :   static unsigned int meshop_index(const char *op_name);
      99                 :            : 
     100                 :            :     /** \name Non-static MeshOp construction and query */
     101                 :            : 
     102                 :            :     /**@{*/
     103                 :            : 
     104                 :            :     /** \brief Make the specified MeshOp name the default for the given dimension(s)
     105                 :            :      * 
     106                 :            :      * If the specified MeshOp cannot produce entities of the specified dimension, an error is
     107                 :            :      * thrown with type MK_BAD_INPUT.
     108                 :            :      * \param op_name MeshOp name being set
     109                 :            :      * \param dims Bitmask, where 2^x indicates that this MeshOp should be the default for dimension x 
     110                 :            :      */
     111                 :            :   void set_default_meshop(const char *op_name, unsigned short dims);
     112                 :            :   
     113                 :            :     /** \brief Make the specified MeshOp the default for the given dimension(s)
     114                 :            :      * 
     115                 :            :      * If the specified MeshOp cannot produce entities of the specified dimension, an error is
     116                 :            :      * thrown with type MK_BAD_INPUT.
     117                 :            :      * \param op_index MeshOp index being set
     118                 :            :      * \param dims Bitmask, where 2^x indicates that this MeshOp should be the default for dimension x 
     119                 :            :      */
     120                 :            :   void set_default_meshop(unsigned op_index, unsigned short dims);
     121                 :            :   
     122                 :            :     /** \brief Make the specified MeshOp the default for the given dimension(s)
     123                 :            :      * 
     124                 :            :      * If the specified MeshOp cannot produce entities of the specified dimension, an error is
     125                 :            :      * thrown with type MK_BAD_INPUT.
     126                 :            :      * \param mesh_op MeshOp being set
     127                 :            :      * \param dims Bitmask, where 2^x indicates that this MeshOp should be the default for dimension x 
     128                 :            :      */
     129                 :            :   void set_default_meshop(MeshOpProxy* mesh_op, unsigned short dims);
     130                 :            :   
     131                 :            :     /**\brief Get default MeshOp for dimension 
     132                 :            :      *
     133                 :            :      * Get the default meshop for the specified dimension of entity.
     134                 :            :      * Throws excpetion if no there are no registered MeshOps that
     135                 :            :      * can mesh entities of the passed dimension.
     136                 :            :      *
     137                 :            :      *\param dimension Dimension of entity to be meshed.
     138                 :            :      *\return pointer to proxy for MeshOp 
     139                 :            :      */
     140                 :            :   MeshOpProxy* get_default_meshop( unsigned dimension );
     141                 :            :   
     142                 :            :     /** \brief Return MeshOp types that can generate or operate on the specified mesh entity type
     143                 :            :      * \param tp Entity type requested
     144                 :            :      * \param ops MeshOp types returned
     145                 :            :      */
     146                 :            :   void meshop_by_mesh_type(moab::EntityType tp, std::vector<MeshOpProxy*> &ops);
     147                 :            :     
     148                 :            :     /** \brief Return MeshOp types that can operate on geometric entities of specified dimension
     149                 :            :      * \param dim Entity dimension requested
     150                 :            :      * \param ops MeshOp types returned
     151                 :            :      */
     152                 :            :   void meshop_by_dimension(int dim, std::vector<MeshOpProxy*> &ops);
     153                 :            :     
     154                 :            :     /** \brief Return MeshOp types that can mesh the specified ModelEnt
     155                 :            :      * \param ent ModelEnt* requested
     156                 :            :      * \param ops MeshOp types returned
     157                 :            :      */
     158                 :            :   void meshop_by_modelent(ModelEnt * const ent, std::vector<MeshOpProxy*> &ops);
     159                 :            :     
     160                 :            :     /** \brief Construct a new MeshOp of the specified OpInfo type
     161                 :            :      * \param op_info OpInfo for the MeshOp being requested
     162                 :            :      * \param me_vec MEntVector of entities the operation applies to
     163                 :            :      * \return Pointer to new MeshOp constructed
     164                 :            :      */
     165                 :            :   MeshOp *construct_meshop(MeshOpProxy* op_info, const MEntVector &me_vec = MEntVector());
     166                 :            :     
     167                 :            :     /** \brief Construct a new MeshOp of the specified name
     168                 :            :      * \param op_name MeshOp name being requested
     169                 :            :      * \param me_vec MEntVector of entities the operation applies to
     170                 :            :      * \return Pointer to new MeshOp constructed
     171                 :            :      */
     172                 :            :   MeshOp *construct_meshop(std::string op_name, const MEntVector &me_vec = MEntVector());
     173                 :            :     
     174                 :            :     /** \name MeshOp construction and query */
     175                 :            : 
     176                 :            :     /**@{*/
     177                 :            : 
     178                 :            :     /** \brief Construct the default type of MeshOp for the specified dimension
     179                 :            :      * \param dim Dimension requested
     180                 :            :      * \param me_vec MEntVector of entities the operation applies to
     181                 :            :      * \return Pointer to new MeshOp constructed
     182                 :            :      */
     183                 :            :   MeshOp *construct_meshop(unsigned int dim, const MEntVector &me_vec = MEntVector());
     184                 :            :     
     185                 :            :     /**@}*/
     186                 :            : 
     187                 :            :     /** \name Loading/saving models */
     188                 :            : 
     189                 :            :     /**@{*/
     190                 :            : 
     191                 :            :     /** \brief Load a geometry model from a file, and populate mesh entity sets
     192                 :            :      * \param geom_filename The file from which to load geometry
     193                 :            :      * \param mesh_filename The file from which to load mesh
     194                 :            :      * \param geom_options File options to be passed to the load_geometry function
     195                 :            :      * \param mesh_options File options to be passed to the load_mesh function
     196                 :            :      * \param geom_index Index of geometry instance to use
     197                 :            :      * \param mesh_index Index of mesh instance to use
     198                 :            :      * \param irel_index Index of irel instance to use
     199                 :            :      * \param relate_too If true, infers all geometry-mesh relations after mesh load
     200                 :            :      * \param populate_too If true, calls populate_modelents after load and relate
     201                 :            :      */
     202                 :            :   void load_geometry_mesh(const char *geom_filename, 
     203                 :            :                           const char *mesh_filename, 
     204                 :            :                           const char *geom_options = NULL, 
     205                 :            :                           const char *mesh_options = NULL, 
     206                 :            :                           int geom_index = 0,
     207                 :            :                           int mesh_index = 0,
     208                 :            :                           int irel_index = 0,
     209                 :            :                           bool relate_too = true,
     210                 :            :                           bool populate_too = true);
     211                 :            : 
     212                 :            :     /** \brief Load a geometry model from a file, and populate mesh entity sets
     213                 :            :      * \param filename The file to load
     214                 :            :      * \param options File options to be passed to the load function
     215                 :            :      * \param geom_index Index of geometry instance to use
     216                 :            :      * \param mesh_index Index of mesh instance to use
     217                 :            :      * \param irel_index Index of irel instance to use
     218                 :            :      * \param relate_too If true, infers all geometry-mesh relations after load
     219                 :            :      * \param populate_too If true, calls populate_modelents after load and relate
     220                 :            :      */
     221                 :            :   void load_geometry(const char *filename, const char *options = NULL, 
     222                 :            :                      int geom_index = 0,
     223                 :            :                      int mesh_index = 0,
     224                 :            :                      int irel_index = 0,
     225                 :            :                      bool relate_too = false,
     226                 :            :                      bool populate_too = true);
     227                 :            : 
     228                 :            :     /** \brief Load a mesh model from a file
     229                 :            :      * \param filename The file to load
     230                 :            :      * \param options File options to be passed to the load function
     231                 :            :      * \param geom_index Index of geometry instance to use
     232                 :            :      * \param mesh_index Index of mesh instance to use
     233                 :            :      * \param irel_index Index of irel instance to use
     234                 :            :      * \param relate_too If true, infers all geometry-mesh relations after load
     235                 :            :      * \param populate_too If true, calls populate_modelents after load and relate
     236                 :            :      */
     237                 :            :   void load_mesh(const char *filename, const char *options = NULL,
     238                 :            :                  int geom_index = 0,
     239                 :            :                  int mesh_index = 0,
     240                 :            :                  int irel_index = 0,
     241                 :            :                  bool relate_too = false,
     242                 :            :                  bool populate_too = true);
     243                 :            : 
     244                 :            :     /** \brief Save a geometry model to a file
     245                 :            :      * \param filename The file to save
     246                 :            :      * \param options File options to be passed to the save function
     247                 :            :      * \param index Index of geometry instance to use
     248                 :            :      */
     249                 :            :   void save_geometry(const char *filename, const char *options = NULL,
     250                 :            :                      int index = 0);
     251                 :            : 
     252                 :            :     /** \brief Save a mesh model to a file
     253                 :            :      * \param filename The file to save
     254                 :            :      * \param options File options to be passed to the save function
     255                 :            :      * \param index Index of mesh instance to use
     256                 :            :      */
     257                 :            :   void save_mesh(const char *filename, const char *options = NULL,
     258                 :            :                  int index = 0);
     259                 :            : 
     260                 :            :   /** \brief Save part of a model mesh to a file
     261                 :            :       * \param filename The file to save
     262                 :            :       * \param ments vector of model entities to be exported
     263                 :            :       * \param options File options to be passed to the save function
     264                 :            :       * \param index Index of mesh instance to use
     265                 :            :       */
     266                 :            :   void save_mesh_from_model_ents(const char *filename, MEntVector & ments, const char *options = NULL,
     267                 :            :                   int index = 0);
     268                 :            : 
     269                 :            :     /** \brief Populate model entities for geometry and mesh
     270                 :            :      * Pass -1 for geom, mesh, or irel index to disable checking for entities in those
     271                 :            :      * interfaces (geom, mesh) or skip the check for relations (irel)
     272                 :            :      * \param geom_index Index of geometry instance to use
     273                 :            :      * \param mesh_index Index of mesh instance to use
     274                 :            :      * \param irel_index Index of irel instance to use
     275                 :            :      * \param use_irel flag to create relations or not
     276                 :            :      */
     277                 :            :   void populate_model_ents(int geom_index = 0, 
     278                 :            :                            int mesh_index = 0, 
     279                 :            :                            int irel_index = 0, bool only_geom = false);
     280                 :            : 
     281                 :            :   /**
     282                 :            :    *  \ brief  create model entities based on a set root for mesh based geometry
     283                 :            :    *  \param modelRootSet root model for a complete topology model (for GeomTopoTool)
     284                 :            :    *  \param geometry flag true for FBiGeom geometry, false for simple mesh ModelEnts
     285                 :            :    */
     286                 :            :   void create_mbg_model_entities(moab::EntityHandle modelRootSet, bool geometry);
     287                 :            : 
     288                 :            :     /**@}*/
     289                 :            : 
     290                 :            :     /** \name Entity access */
     291                 :            : 
     292                 :            :     /**@{*/
     293                 :            : 
     294                 :            :     /** \brief Get model entities of a given dimension
     295                 :            :      * \param dim Dimension of entities to get (-1 to get all model entities)
     296                 :            :      * \param model_ents The list these entities get appended to
     297                 :            :      * \param igindx the geometry instance index of the retrieved model ents
     298                 :            :      *   (default -1 means no check on igeom instance index)
     299                 :            :      */
     300                 :            :   void get_entities_by_dimension(int dim, MEntVector &model_ents,
     301                 :            :       int igindx = -1);
     302                 :            : 
     303                 :            :     /** \brief Get all model entities
     304                 :            :      * \param model_ents The list these entities get appended to
     305                 :            :      */
     306                 :            :   void get_entities_by_handle(MEntVector &model_ents);
     307                 :            : 
     308                 :            :     /**@}*/
     309                 :            : 
     310                 :            :     /** \name Interface instances */
     311                 :            : 
     312                 :            :     /**@{*/
     313                 :            : 
     314                 :            :     /** \brief Return the iGeom instance pointer
     315                 :            :      * \param index Index of desired iGeom, default to first
     316                 :            :      */
     317                 :            :   iGeom *igeom_instance(unsigned index = 0);
     318                 :            :   
     319                 :            :     /** \brief Return the index of iGeom instance added
     320                 :            :      * \param igeom iGeom interface to be added
     321                 :            :      */
     322                 :            :   unsigned int add_igeom_instance(iGeom * igeom);
     323                 :            : 
     324                 :            :     /** \brief Return the MOAB instance pointer
     325                 :            :      * \param index Index of desired moab instance, default to first
     326                 :            :      */
     327                 :            :   moab::Interface *moab_instance(unsigned index = 0);
     328                 :            :   
     329                 :            :     /** \brief Return the iMesh instance pointer
     330                 :            :      * \param index Index of desired iMesh, default to first
     331                 :            :      */
     332                 :            :   iMesh *imesh_instance(unsigned index = 0);
     333                 :            :   
     334                 :            :     /** \brief Return the iRel instance pointer
     335                 :            :      */
     336                 :            :   iRel *irel_instance(unsigned index = 0);
     337                 :            : 
     338                 :            :     /** \brief Return the index of irel_pair added
     339                 :            :        * \param pair iRel::PairHandle pointer to be added
     340                 :            :       */
     341                 :            :   inline unsigned int add_irel_pair(iRel::PairHandle * pair);
     342                 :            : 
     343                 :            :     /** \brief Return the iRel pair handle used to relate geometry/mesh entities
     344                 :            :      */
     345                 :            :   iRel::PairHandle *irel_pair(unsigned index = 0);
     346                 :            : 
     347                 :            :   /** \brief Return the iRel pair handle used to relate geometry sets to mesh entity sets
     348                 :            :      */
     349                 :            :   iRel::PairHandle *group_set_pair(unsigned index = 0);
     350                 :            : 
     351                 :            :     /** \brief Return the (iGeom) tag used to relate geometry entities to ModelEnts
     352                 :            :      */
     353                 :            :   iGeom::TagHandle igeom_model_tag(unsigned index = 0);
     354                 :            : 
     355                 :            :     /** \brief Return the (MOAB) tag used to relate mesh entities to ModelEnts
     356                 :            :      */
     357                 :            :   moab::Tag moab_model_tag(unsigned index = 0);
     358                 :            : 
     359                 :            :     /** \brief Return the (MOAB) geometry dimension tag
     360                 :            :      */
     361                 :            :   moab::Tag moab_geom_dim_tag(unsigned index = 0);
     362                 :            : 
     363                 :            :     /** \brief Return the (MOAB) global id tag
     364                 :            :      */
     365                 :            :   moab::Tag moab_global_id_tag(unsigned index = 0);
     366                 :            : 
     367                 :            :     /**@}*/
     368                 :            : 
     369                 :            :     /** \name Singleton MeshOps */
     370                 :            : 
     371                 :            :     /**@{*/
     372                 :            : 
     373                 :            :     /** \brief Get the (single) VertexMesher instance
     374                 :            :      * \return VertexMesher for this MKCore
     375                 :            :      */
     376                 :            :   VertexMesher *vertex_mesher() const;
     377                 :            :   
     378                 :            :     /** \brief Set the (single) VertexMesher instance
     379                 :            :      * \param vm VertexMesher for this MKCore
     380                 :            :      */
     381                 :            :   void vertex_mesher(VertexMesher *vm);
     382                 :            : 
     383                 :            :     /** \brief Get the (single) EBMesher instance
     384                 :            :      * \return EBMesher for this MKCore
     385                 :            :      */
     386                 :            :   EBMesher *eb_mesher() const;
     387                 :            :   
     388                 :            :     /** \brief Set the (single) EBMesher instance
     389                 :            :      * \param ebm EBMesher for this MKCore
     390                 :            :      */
     391                 :            :   void eb_mesher(EBMesher *ebm);
     392                 :            : 
     393                 :            :     /**@}*/
     394                 :            : 
     395                 :            :     /** \name Sizing functions */
     396                 :            : 
     397                 :            :     /**@{*/
     398                 :            : 
     399                 :            :     /** \brief Get sizing function by index
     400                 :            :      * If the requested index is outside the range of SizingFunction's currently registered,
     401                 :            :      * throws an Error.
     402                 :            :      * \param index Index of sizing function requested
     403                 :            :      * \return SizingFunction* to requested sizing function, NULL of no SizingFunction with that index
     404                 :            :      */
     405                 :            :   SizingFunction *sizing_function(int index);
     406                 :            :   
     407                 :            :     /** \brief Get sizing function by size
     408                 :            :      * If there is no sizing function with that size and create_if_missing is true, one is constructed and registered with MKCore.
     409                 :            :      * \param size Requested size
     410                 :            :      * \param create_if_missing If true and no sizing function exists with the specified size, one is created.
     411                 :            :      * \return SizingFunction* to requested sizing function, NULL if no SizingFunction with that size
     412                 :            :      */
     413                 :            :   SizingFunction *sizing_function(double size, bool create_if_missing);
     414                 :            :   
     415                 :            :     /** \brief Add sizing function to those managed by MeshKit
     416                 :            :      *
     417                 :            :      * The argument to this function is a SizingFunction*; once added, it is MKCore's
     418                 :            :      * responsibility to delete this SizingFunction.  Applications can tell MKCore to delete
     419                 :            :      * a given SizingFunction (e.g. if it requires lots of memory) by calling delete_sizing_function.
     420                 :            :      * \param sf SizingFunction* to be added
     421                 :            :      * \return Index of sizing function in MKCore's list of SizingFunction's
     422                 :            :      */
     423                 :            :   int add_sizing_function(SizingFunction *sf);
     424                 :            : 
     425                 :            :     /** \brief Remove and, optionally, delete sizing function
     426                 :            :      *
     427                 :            :      * This function removes the referenced sizing function from MKCore's list (setting the
     428                 :            :      * corresponding SizingFunction* to NULL, to keep others at the same index position).  
     429                 :            :      * Throws an Error if requested sizing function is NULL.
     430                 :            :      * \param index Index of SizingFunction to be removed
     431                 :            :      * \param delete_too If true, deletes the SizingFunction object too
     432                 :            :      */
     433                 :            :   void remove_sizing_function(int index, bool delete_too = true);
     434                 :            :   
     435                 :            : #if 1
     436                 :            :   /** \brief interpret mesh-based geometry
     437                 :            :        *
     438                 :            :        * This function interprets the mesh from a moab db as mesh based geometry
     439                 :            :        * it will create a new FBiGeom instance and populate the model ents
     440                 :            :        * accordingly, with the geometry implied from moab sets and tags
     441                 :            :        * it returns the index of FBiGeom in iGeomInstances vector
     442                 :            :        */
     443                 :            : 
     444                 :            :   int initialize_mesh_based_geometry(iBase_EntitySetHandle modelSet);
     445                 :            : 
     446                 :            :   /** \brief remove mesh-based geometry instance
     447                 :            :      *
     448                 :            :      * This function removes the FBiGeom instance and clears some memory
     449                 :            :      * (will delete the smooth tags, among other things), but it should preserve
     450                 :            :      * the geom topo model intact
     451                 :            :      */
     452                 :            :   void remove_mesh_based_geometry(int index);
     453                 :            : #endif
     454                 :            :   /** \brief retrieve number of iGeom instances
     455                 :            :      *
     456                 :            :      * This function returns number of igeom instances, to be used
     457                 :            :      * by some mesh operations.
     458                 :            :      */
     459                 :            :   int number_of_igeom_instances()
     460                 :            :   {
     461                 :            :     return (int)iGeomInstances.size();
     462                 :            :   }
     463                 :            :   /** \brief delete model entities
     464                 :            :        *
     465                 :            :        * This function clears memory occupied by model entities, and
     466                 :            :        * empties the vectors.
     467                 :            :        * more careful with the lifecycles.
     468                 :            :        */
     469                 :            :   void delete_model_entities();
     470                 :            :   /** \brief delete all
     471                 :            :    *
     472                 :            :    * This function clears memory occupied by model entities,
     473                 :            :    * deletes graph,
     474                 :            :    * deletes mesh and geometry
     475                 :            :    */
     476                 :            :   void delete_all();
     477                 :            :     /**@}*/
     478                 :            : 
     479                 :            : private:
     480                 :            :     //! initialize, creating missing geom/mesh/rel interfaces if requested
     481                 :            :   void init(bool construct_missing_ifaces);
     482                 :            : 
     483                 :            :     //! Initialize the opsByDim array
     484                 :            :   void init_opsbydim();
     485                 :            : 
     486                 :            :     //! Geometry api instance
     487                 :            :   std::vector<iGeom *> iGeomInstances;
     488                 :            :   
     489                 :            :     //! MOAB instance
     490                 :            :   std::vector<moab::Interface *> moabInstances;
     491                 :            :   
     492                 :            :     //! iMesh api instance, for use in iRel
     493                 :            :   std::vector<iMesh *> iMeshInstances;
     494                 :            :   
     495                 :            :     //! IREL api instance
     496                 :            :   std::vector<iRel *> iRelInstances;
     497                 :            : 
     498                 :            :     //! iRel pair handle used to relate geometry/mesh entities
     499                 :            :   std::vector<iRel::PairHandle *> iRelPairs;
     500                 :            :   
     501                 :            :     //! iRel pair handle used to relate geometry groups to mesh entity sets
     502                 :            :   std::vector<iRel::PairHandle *> groupSetPairs;
     503                 :            :   
     504                 :            :     //! Tag used to associate geometry entities with model entities
     505                 :            :   std::vector<iGeom::TagHandle> iGeomModelTags;
     506                 :            :   
     507                 :            :     //! Tag used to associate mesh entities with model entities
     508                 :            :   std::vector<moab::Tag> moabModelTags;
     509                 :            : 
     510                 :            :     //! Tag used to associate existing mesh entities with model entities
     511                 :            :   std::vector<moab::Tag> moabGeomDimTags;
     512                 :            : 
     513                 :            :     //! Tag used to associate existing mesh entities with model entities
     514                 :            :   std::vector<moab::Tag> moabIDTags;
     515                 :            : 
     516                 :            :     //! If true, the corresponding interfaces will get deleted from the destructor
     517                 :            :   std::vector<bool> iCreatedIgeoms, iCreatedMoabs, iCreatedImeshs, iCreatedIrels;
     518                 :            : 
     519                 :            :     //! Model entities, in array by topological dimension
     520                 :            :   MEntVector modelEnts[5];
     521                 :            :   
     522                 :            :     //! (Single) VertexMesher scheme for this MKCore
     523                 :            :   VertexMesher *vertexMesher;
     524                 :            : 
     525                 :            :       //! (Single) EBMesher scheme for this MKCore
     526                 :            :   EBMesher *ebMesher;
     527                 :            :   
     528                 :            :     //! Default algorithms for each dimension
     529                 :            :   MeshOpProxy* defaultMeshOps[4];
     530                 :            :   
     531                 :            :     //! SizingFunction vector
     532                 :            :   std::vector<SizingFunction*> sizingFunctions;
     533                 :            : };
     534                 :            : 
     535                 :     152769 : inline iGeom *MKCore::igeom_instance(unsigned index) 
     536                 :            : {
     537         [ -  + ]:     152769 :   if (iGeomInstances.size() <= index)
     538         [ #  # ]:          0 :     throw Error(MK_BAD_INPUT, "No instance of that index.");
     539                 :            :   
     540                 :     152769 :   return iGeomInstances[index];
     541                 :            : }
     542                 :            : 
     543                 :     278199 : inline moab::Interface *MKCore::moab_instance(unsigned index)
     544                 :            : {
     545         [ -  + ]:     278199 :   if (moabInstances.size() <= index)
     546         [ #  # ]:          0 :     throw Error(MK_BAD_INPUT, "No instance of that index.");
     547                 :            :   
     548                 :     278199 :   return moabInstances[index];
     549                 :            : }
     550                 :            : 
     551                 :      81095 : inline iMesh *MKCore::imesh_instance(unsigned index) 
     552                 :            : {
     553         [ -  + ]:      81095 :   if (iMeshInstances.size() <= index)
     554         [ #  # ]:          0 :     throw Error(MK_BAD_INPUT, "No instance of that index.");
     555                 :            :   
     556                 :      81095 :   return iMeshInstances[index];
     557                 :            : }
     558                 :            : 
     559                 :          1 : inline iRel *MKCore::irel_instance(unsigned index)
     560                 :            : {
     561         [ -  + ]:          1 :   if (iRelInstances.size() <= index)
     562         [ #  # ]:          0 :     throw Error(MK_BAD_INPUT, "No instance of that index.");
     563                 :            : 
     564                 :          1 :   return iRelInstances[index];
     565                 :            : }
     566                 :            : 
     567                 :       6793 : inline iRel::PairHandle *MKCore::irel_pair(unsigned index)
     568                 :            : {
     569         [ -  + ]:       6793 :   if (iRelPairs.size() <= index)
     570         [ #  # ]:          0 :     throw Error(MK_BAD_INPUT, "No pair of that index.");
     571                 :            : 
     572                 :       6793 :   return iRelPairs[index];
     573                 :            : }
     574                 :            : 
     575                 :          1 : inline unsigned int MKCore::add_irel_pair(iRel::PairHandle * pair)
     576                 :            : {
     577                 :          1 :   iRelPairs.push_back(pair);
     578                 :          1 :   return iRelPairs.size()-1;
     579                 :            : }
     580                 :            : 
     581                 :          0 : inline iRel::PairHandle *MKCore::group_set_pair(unsigned index)
     582                 :            : {
     583         [ #  # ]:          0 :   if (groupSetPairs.size() <= index)
     584         [ #  # ]:          0 :     throw Error(MK_BAD_INPUT, "No pair of that index.");
     585                 :            : 
     586                 :          0 :   return groupSetPairs[index];
     587                 :            : }
     588                 :            : 
     589                 :       1142 : inline iGeom::TagHandle MKCore::igeom_model_tag(unsigned index)
     590                 :            : {
     591         [ -  + ]:       1142 :   if (iGeomModelTags.size() <= index)
     592         [ #  # ]:          0 :     throw Error(MK_BAD_INPUT, "No tag of that index.");
     593                 :            : 
     594                 :       1142 :   return iGeomModelTags[index];
     595                 :            : }
     596                 :            : 
     597                 :       2826 : inline moab::Tag MKCore::moab_model_tag(unsigned index)
     598                 :            : {
     599         [ -  + ]:       2826 :   if (moabModelTags.size() <= index)
     600         [ #  # ]:          0 :     throw Error(MK_BAD_INPUT, "No tag of that index.");
     601                 :            : 
     602                 :       2826 :   return moabModelTags[index];
     603                 :            : }
     604                 :            : 
     605                 :       2061 : inline moab::Tag MKCore::moab_geom_dim_tag(unsigned index)
     606                 :            : {
     607         [ -  + ]:       2061 :   if (moabGeomDimTags.size() <= index)
     608         [ #  # ]:          0 :     throw Error(MK_BAD_INPUT, "No tag of that index.");
     609                 :            : 
     610                 :       2061 :   return moabGeomDimTags[index];
     611                 :            : }
     612                 :            : 
     613                 :        998 : inline moab::Tag MKCore::moab_global_id_tag(unsigned index)
     614                 :            : {
     615         [ -  + ]:        998 :   if (moabIDTags.size() <= index)
     616         [ #  # ]:          0 :     throw Error(MK_BAD_INPUT, "No tag of that index.");
     617                 :            : 
     618                 :        998 :   return moabIDTags[index];
     619                 :            : }
     620                 :            : 
     621                 :         62 : inline void MKCore::vertex_mesher(VertexMesher *vm) 
     622                 :            : {
     623                 :         62 :   vertexMesher = vm;
     624                 :         62 : }
     625                 :            : 
     626                 :        127 : inline VertexMesher *MKCore::vertex_mesher() const
     627                 :            : {
     628                 :        127 :   return vertexMesher;
     629                 :            : }
     630                 :            : 
     631                 :            : inline EBMesher *MKCore::eb_mesher() const 
     632                 :            : {
     633                 :            :   return ebMesher;
     634                 :            : }
     635                 :            : 
     636                 :            : inline void MKCore::eb_mesher(EBMesher *ebm) 
     637                 :            : {
     638                 :            :   ebMesher = ebm;
     639                 :            : }
     640                 :            : 
     641                 :        962 : inline SizingFunction *MKCore::sizing_function(int index) 
     642                 :            : {
     643                 :            :     // don't check for NULL here 'cuz sometimes we just want to know there isn't one
     644                 :            :     // with that index
     645         [ -  + ]:        962 :   if (index >= (int)sizingFunctions.size())
     646         [ #  # ]:          0 :     throw Error(MK_BAD_INPUT, "Sizing function index outside range of valid indices.");
     647         [ +  + ]:        962 :   else if (index == -1)
     648                 :          4 :     return NULL;
     649                 :            : 
     650                 :        962 :   return sizingFunctions[index];
     651                 :            : }
     652                 :            :   
     653                 :            : } // namespace MeshKit
     654                 :            : 
     655                 :            : #endif
     656                 :            : 
     657                 :            :   

Generated by: LCOV version 1.11