LCOV - code coverage report
Current view: top level - geom/virtual - CACompositeVG.cpp (source / functions) Hit Total Coverage
Test: coverage_sk.info Lines: 21 137 15.3 %
Date: 2020-06-30 00:58:45 Functions: 6 9 66.7 %
Branches: 21 466 4.5 %

           Branch data     Line data    Source code
       1                 :            : // CACompositeVG class
       2                 :            : 
       3                 :            : #include "CACompositeVG.hpp"
       4                 :            : #include "CADeferredAttrib.hpp"
       5                 :            : #include "CAUniqueId.hpp"
       6                 :            : #include "TDUniqueId.hpp"
       7                 :            : #include "CastTo.hpp"
       8                 :            : #include "RefFace.hpp"
       9                 :            : #include "RefEdge.hpp"
      10                 :            : #include "BasicTopologyEntity.hpp"
      11                 :            : #include "PartitionEntity.hpp"
      12                 :            : #include "TopologyBridge.hpp"
      13                 :            : #include "CubitMessage.hpp"
      14                 :            : 
      15                 :            : 
      16                 :            : #include "CompositeTool.hpp"
      17                 :            : #include "CompositeSurface.hpp"
      18                 :            : #include "CompositeCurve.hpp"
      19                 :            : 
      20                 :      15852 : CubitAttrib* CACompositeVG_creator(RefEntity* entity, const CubitSimpleAttrib &p_csa)
      21                 :            : {
      22         [ +  - ]:      15852 :   return new CACompositeVG(entity, p_csa);
      23                 :            : }
      24                 :            : 
      25                 :      15852 : CACompositeVG::CACompositeVG(RefEntity *owner, const CubitSimpleAttrib &simple_attrib)
      26         [ +  - ]:      15852 :         : CubitAttrib(owner)
      27                 :            : {
      28                 :            : 
      29                 :      15852 :   compositeId = -1;
      30                 :            : 
      31 [ +  - ][ -  + ]:      15852 :   if(!simple_attrib.isEmpty())
      32                 :            :   {
      33                 :            : 
      34                 :            :       // generate a simple attribute containing the data in this CA
      35         [ #  # ]:          0 :     const std::vector<int>& i_list = simple_attrib.int_data_list();
      36                 :            : 
      37                 :            :       // (no string)
      38                 :            : 
      39                 :            :       // now the integers
      40                 :            :       // compositeId, numSubEntities
      41         [ #  # ]:          0 :     compositeId = i_list[0];
      42         [ #  # ]:          0 :     int numSubEntities = i_list[1];
      43                 :            :     int i;
      44         [ #  # ]:          0 :     for (i = 0; i < numSubEntities; i++)
      45                 :            :     {
      46 [ #  # ][ #  # ]:          0 :       subEntityIds.append(i_list[i+2]);
      47                 :            :     }
      48                 :            : 
      49                 :            :       // If we are constructing from a CubitSimpleAttrib,
      50                 :            :       // then this attrib is already written
      51         [ #  # ]:          0 :     has_written(CUBIT_TRUE);
      52                 :            :   }
      53                 :      15852 : }
      54                 :            : 
      55                 :      15852 : CubitStatus CACompositeVG::update()
      56                 :            : {
      57                 :      15852 :   hasUpdated = CUBIT_TRUE;
      58                 :      15852 :   delete_attrib(CUBIT_TRUE);
      59                 :      15852 :   return CUBIT_SUCCESS;
      60                 :            : }
      61                 :            : 
      62                 :          0 : CubitStatus CACompositeVG::reset()
      63                 :            : {
      64                 :            : 
      65                 :            :     // reset the info on this CACVG; don't reset info on underlying
      66                 :            :     // entities, since the lists on this CACVG get *assigned* to that
      67                 :            :     // entity and not *appended*
      68                 :          0 :   compositeId = -1;
      69                 :          0 :   subEntityIds.clean_out();
      70                 :          0 :   return CUBIT_SUCCESS;
      71                 :            : }
      72                 :            :   
      73                 :      15852 : CubitSimpleAttrib CACompositeVG::cubit_simple_attrib()
      74                 :            : {
      75                 :            :     // generate a simple attribute containing the data in this CA
      76         [ +  - ]:      15852 :   std::vector<CubitString> cs_list;
      77 [ +  - ][ +  - ]:      31704 :   std::vector<int> i_list;
      78                 :            : 
      79                 :            :     // first the string
      80 [ +  - ][ +  - ]:      15852 :   cs_list.push_back(att_internal_name());
         [ +  - ][ +  - ]
      81                 :            : 
      82                 :            :     // now the integers
      83                 :            :     // compositeId, numSubEntities
      84         [ +  - ]:      15852 :   i_list.push_back(compositeId);
      85 [ +  - ][ +  - ]:      15852 :   i_list.push_back(subEntityIds.size());
      86                 :            :   int i;
      87         [ +  - ]:      15852 :   subEntityIds.reset();
      88 [ +  - ][ -  + ]:      15852 :   for (i = subEntityIds.size(); i > 0; i--)
      89 [ #  # ][ #  # ]:          0 :     i_list.push_back(subEntityIds.get_and_step());
      90                 :            :     
      91                 :            : 
      92 [ +  - ][ +  - ]:      31704 :   return CubitSimpleAttrib(&cs_list, NULL, &i_list);
      93                 :            : }
      94                 :            : 
      95                 :          0 : CubitStatus CACompositeVG::actuate()
      96                 :            : {
      97                 :            :     // actuate this CA
      98 [ #  # ][ #  # ]:          0 :   if (has_actuated() == CUBIT_TRUE) return CUBIT_SUCCESS;
      99                 :            : 
     100                 :            :     // actuate all the unique id attribute first, since CA_COMPOSITE_VG
     101                 :            :     // depends on CA_UNIQUEID
     102         [ #  # ]:          0 :   CAUniqueId::actuate_all();
     103                 :            :   
     104                 :            :     // now, gather up all the sub entities; if they're not all around,
     105                 :            :     // exit without setting the actuate flag
     106         [ #  # ]:          0 :   DLIList<ToolDataUser*> tdu_list;
     107                 :            :   int i;
     108         [ #  # ]:          0 :   subEntityIds.reset();
     109                 :          0 :   CubitBoolean all_actuated = CUBIT_TRUE;
     110                 :            : 
     111 [ #  # ][ #  # ]:          0 :   DLIList<CACompositeVG*> comp_attribs;
     112                 :            : 
     113 [ #  # ][ #  # ]:          0 :   for (i = subEntityIds.size(); i > 0; i--) {
     114 [ #  # ][ #  # ]:          0 :     ToolDataUser *tdu = TDUniqueId::find_td_unique_id(subEntityIds.get_and_step());
     115 [ #  # ][ #  # ]:          0 :     if (tdu != NULL) tdu_list.append(tdu);
     116                 :            :     else {
     117                 :            : 
     118                 :            :       // put this CA on a list for future actuation
     119                 :            :       //has_actuated( CUBIT_FALSE );
     120         [ #  # ]:          0 :       bool result = CADeferredAttrib::add_unactuated_ca(this);
     121                 :            : 
     122         [ #  # ]:          0 :       if (true == result) {
     123 [ #  # ][ #  # ]:          0 :         PRINT_DEBUG_90("Can't actuate composite vg attrib on %s %d; adding to unactuated "
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     124                 :            :                        "list.\n",
     125         [ #  # ]:          0 :                       attrib_owner()->class_name(), attrib_owner()->id());
     126                 :            :       }
     127                 :          0 :       return CUBIT_FAILURE;
     128                 :            :     }
     129                 :            : 
     130                 :            :     //The portion of code below examines the entities that this entity will be 
     131                 :            :     //composited with.  If the CACompositeVG attribute on these entities-to-be-composited 
     132                 :            :     //do not have their 'has_actuated' variable set to TRUE, then this Composite attribute
     133                 :            :     //is not ready to be actuated.  All entities-to-be-composited must have their 
     134                 :            :     //'has_actuated' flag set to TRUE to be ready to be composited
     135                 :            :     
     136         [ #  # ]:          0 :     RefEntity *ref_entity = CAST_TO( tdu, RefEntity );
     137         [ #  # ]:          0 :     if( ref_entity == NULL )
     138                 :          0 :       return CUBIT_FAILURE;
     139                 :            :     else
     140                 :            :     {
     141         [ #  # ]:          0 :       CACompositeVG *comp_vg_attrib = (CACompositeVG *) ref_entity->get_cubit_attrib(CA_COMPOSITE_VG);
     142         [ #  # ]:          0 :       if( comp_vg_attrib ) 
     143                 :            :       {
     144         [ #  # ]:          0 :         comp_attribs.append( comp_vg_attrib );
     145 [ #  # ][ #  # ]:          0 :         if( ref_entity == attrib_owner() ) //skip owner of this attribute..it will be actuated in a minute
     146                 :          0 :           continue;
     147 [ #  # ][ #  # ]:          0 :         if( !comp_vg_attrib->has_actuated() )
     148                 :          0 :           all_actuated = CUBIT_FALSE;
     149                 :          0 :         continue;
     150                 :            :       }
     151                 :            :       else
     152                 :            :       {
     153                 :          0 :         all_actuated = CUBIT_FALSE;
     154                 :          0 :         continue;  
     155                 :            :       }
     156                 :            :     }
     157                 :            :   }
     158                 :            : 
     159         [ #  # ]:          0 :   has_actuated( CUBIT_TRUE );
     160                 :            : 
     161                 :            :   //if all sub entities CACompositeVG attribs haven't been here, 
     162                 :            :   //set this one and get out 
     163         [ #  # ]:          0 :   if( all_actuated == CUBIT_FALSE )
     164                 :          0 :     return CUBIT_SUCCESS;
     165                 :            : 
     166                 :            :     // ok, we've got a list of tdu's; cast to list of ref edges or faces (currently
     167                 :            :     // the only entities we know how to composite)
     168 [ #  # ][ #  # ]:          0 :   DLIList<RefEdge*> ref_edges;
     169 [ #  # ][ #  # ]:          0 :   CAST_LIST(tdu_list, ref_edges, RefEdge);
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
     170 [ #  # ][ #  # ]:          0 :   DLIList<RefFace*> ref_faces;
     171 [ #  # ][ #  # ]:          0 :   CAST_LIST(tdu_list, ref_faces, RefFace);
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
     172                 :            : 
     173                 :            :     // do a little error checking: the entities should all be the same type, and
     174                 :            :     // should be either ref edges or ref faces
     175 [ #  # ][ #  # ]:          0 :   if ((ref_edges.size() > 0 && ref_faces.size() > 0) ||
         [ #  # ][ #  # ]
                 [ #  # ]
     176 [ #  # ][ #  # ]:          0 :       (ref_edges.size() > 0 && ref_edges.size() != tdu_list.size()) ||
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     177 [ #  # ][ #  # ]:          0 :       (ref_faces.size() > 0 && ref_faces.size() != tdu_list.size())) {
         [ #  # ][ #  # ]
     178 [ #  # ][ #  # ]:          0 :     PRINT_ERROR("Entities for composite containing %s %d not all the same.\n",
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
     179         [ #  # ]:          0 :                 attrib_owner()->class_name(), attrib_owner()->id());
     180                 :          0 :     return CUBIT_FAILURE;
     181                 :            :   }
     182 [ #  # ][ #  # ]:          0 :   else if (ref_edges.size() == 0 && ref_faces.size() == 0) {
         [ #  # ][ #  # ]
                 [ #  # ]
     183 [ #  # ][ #  # ]:          0 :     PRINT_ERROR("Can't find any faces or edges for composite containing %s %d.\n",
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
     184         [ #  # ]:          0 :                 attrib_owner()->class_name(), attrib_owner()->id());
     185                 :          0 :     return CUBIT_FAILURE;
     186                 :            :   }
     187                 :            : 
     188                 :            :     // first, check to see that we can composite these entities; if
     189                 :            :     // not, return without setting actuated flag; this CA will get 
     190                 :            :     // re-actuated if a parent gets composited or partitioned.
     191 [ #  # ][ #  # ]:          0 :   DLIList<BasicTopologyEntity*> bte_list;
     192 [ #  # ][ #  # ]:          0 :   if (ref_edges.size() > 0) {
     193 [ #  # ][ #  # ]:          0 :     CAST_LIST_TO_PARENT(ref_edges, bte_list);
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     194                 :            :   }
     195                 :            :   else {
     196 [ #  # ][ #  # ]:          0 :     CAST_LIST_TO_PARENT(ref_faces, bte_list);
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     197                 :            :   }
     198                 :            :   
     199 [ #  # ][ #  # ]:          0 :   if (!CompositeTool::instance()->okayToComposite(bte_list, NULL, NULL, CUBIT_FALSE))
                 [ #  # ]
     200                 :            :   {
     201 [ #  # ][ #  # ]:          0 :     for( int k = comp_attribs.size(); k--; )
     202 [ #  # ][ #  # ]:          0 :       comp_attribs.get_and_step()->has_actuated( CUBIT_FALSE );
     203         [ #  # ]:          0 :     has_actuated( CUBIT_FALSE );
     204                 :          0 :     return CUBIT_FAILURE;
     205                 :            :   }
     206                 :            :     
     207                 :            : // ok, we can build the composite
     208                 :          0 :   RefEntity *new_entity = NULL;
     209 [ #  # ][ #  # ]:          0 :   if (ref_edges.size() > 0) {
     210 [ #  # ][ #  # ]:          0 :     PRINT_DEBUG_90("Creating composite edge from %d edges\n",
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
     211         [ #  # ]:          0 :                    ref_edges.size());
     212                 :            : 
     213                 :            :     //need to get the RefEdge that owns this attribute
     214                 :          0 :     RefEdge *edge_to_keep= NULL;
     215 [ #  # ][ #  # ]:          0 :     edge_to_keep = CAST_TO( attrib_owner(), RefEdge );
     216                 :            : 
     217         [ #  # ]:          0 :     if( edge_to_keep == NULL )
     218                 :          0 :       return CUBIT_FAILURE;
     219                 :            : 
     220 [ #  # ][ #  # ]:          0 :     new_entity = CompositeTool::instance()->composite(ref_edges, NULL, edge_to_keep);
                 [ #  # ]
     221                 :            : 
     222 [ #  # ][ #  # ]:          0 :     new TDUniqueId(new_entity, compositeId);
                 [ #  # ]
     223         [ #  # ]:          0 :     CADeferredAttrib::owner_created(new_entity, compositeId);
     224                 :            :   }
     225 [ #  # ][ #  # ]:          0 :   else if (ref_faces.size() > 0) {
     226 [ #  # ][ #  # ]:          0 :     PRINT_DEBUG_90("Creating composite face from %d faces\n",
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
     227         [ #  # ]:          0 :                    ref_faces.size());
     228                 :            : 
     229                 :            :     //need to get the RefFace that owns this attribute
     230                 :          0 :     RefFace *face_to_keep = NULL;
     231 [ #  # ][ #  # ]:          0 :     face_to_keep = CAST_TO( attrib_owner(), RefFace );
     232                 :            :     
     233         [ #  # ]:          0 :     if( face_to_keep == NULL )
     234                 :          0 :       return CUBIT_FAILURE;
     235                 :            : 
     236 [ #  # ][ #  # ]:          0 :     new_entity = CompositeTool::instance()->composite(ref_faces, face_to_keep);
                 [ #  # ]
     237                 :            : 
     238 [ #  # ][ #  # ]:          0 :     new TDUniqueId(new_entity, compositeId);
                 [ #  # ]
     239         [ #  # ]:          0 :     CADeferredAttrib::owner_created(new_entity, compositeId);
     240                 :            :   }
     241                 :            :   else {
     242                 :            :       // shouldn't get here
     243                 :          0 :     assert(CUBIT_FALSE);
     244                 :            :   }
     245                 :            : /*
     246                 :            :     // otherwise, we're done
     247                 :            :     // set the actuated flag for all the CACVG's for this composite
     248                 :            :   for (i = tdu_list.size(); i > 0; i--) {
     249                 :            :     RefEntity *entity;
     250                 :            :     if (ref_faces.size() > 0) entity = ref_faces.get_and_step();
     251                 :            :     else entity = ref_edges.get_and_step();
     252                 :            :     CACompositeVG *cacvg = (CACompositeVG *) entity->get_cubit_attrib(CA_COMPOSITE_VG);
     253                 :            :     assert(cacvg != 0);
     254                 :            :     cacvg->has_actuated(CUBIT_TRUE);
     255                 :            :   }
     256                 :            : */
     257                 :            :     // ok, we've composited; now check for CACVG's on any children, and
     258                 :            :     // call actuate functions on those if they exist
     259         [ #  # ]:          0 :   check_child_cacvgs(new_entity);
     260                 :            : 
     261         [ #  # ]:          0 :   return CUBIT_SUCCESS;
     262                 :            : }
     263                 :            : 
     264                 :          0 : void CACompositeVG::check_child_cacvgs(RefEntity *new_entity) 
     265                 :            : {
     266                 :            :     // check the new entity's children for CACVG's, and actuate those
     267                 :            :     // if they exist
     268         [ #  # ]:          0 :   DLIList<RefEntity*> children;
     269         [ #  # ]:          0 :   new_entity->get_child_ref_entities(children);
     270                 :            : 
     271 [ #  # ][ #  # ]:          0 :   DLIList<CubitAttrib*> ca_list;
     272                 :            :   
     273                 :            :     // get the CA list first, then actuate; if we looped over entities,
     274                 :            :     // actuating as we went, some entities might eventually be gone
     275                 :            :     // when we got to them
     276                 :            :   int i;
     277 [ #  # ][ #  # ]:          0 :   for (i = children.size(); i > 0; i--) {
     278         [ #  # ]:          0 :     RefEntity *child = children.get_and_step();
     279         [ #  # ]:          0 :     child->find_cubit_attrib_type(CA_COMPOSITE_VG, ca_list);
     280                 :            :   }
     281                 :            : 
     282                 :            :   //get unactuated deferred attribs
     283 [ #  # ][ #  # ]:          0 :   DLIList<CubitAttrib*> unact_deferred_attribs;
     284 [ #  # ][ #  # ]:          0 :   unact_deferred_attribs = CADeferredAttrib::get_unactuated_deferred_attribs();
                 [ #  # ]
     285                 :            : 
     286                 :            : 
     287 [ #  # ][ #  # ]:          0 :   for (i = ca_list.size(); i > 0; i--) 
     288                 :            :   {
     289         [ #  # ]:          0 :     CubitAttrib *ca_ptr = ca_list.get();
     290 [ #  # ][ #  # ]:          0 :     if (ca_ptr->has_actuated() == CUBIT_TRUE)
     291         [ #  # ]:          0 :       ca_list.remove();
     292                 :            :     else
     293         [ #  # ]:          0 :       ca_list.step();
     294                 :            :   }
     295                 :            : 
     296                 :            :     // for the same reason, don't delete until we've gone through the list
     297 [ #  # ][ #  # ]:          0 :   for (i = ca_list.size(); i > 0; i--) {
     298         [ #  # ]:          0 :     CubitAttrib *ca_ptr = ca_list.get();
     299                 :            : 
     300                 :            :     //don't try and actuate unactuated deferred attribs.....wait till later
     301 [ #  # ][ #  # ]:          0 :     if( unact_deferred_attribs.move_to( ca_ptr ) )
     302                 :            :     {
     303         [ #  # ]:          0 :       ca_list.remove();
     304                 :          0 :       continue;
     305                 :            :     }
     306                 :            : 
     307 [ #  # ][ #  # ]:          0 :     if (ca_ptr->delete_attrib() == CUBIT_FALSE && 
         [ #  # ][ #  # ]
     308         [ #  # ]:          0 :         ca_ptr->has_actuated() == CUBIT_FALSE) 
     309                 :            :     {
     310         [ #  # ]:          0 :       ca_ptr->actuate();
     311                 :            :     }
     312                 :            : 
     313                 :            :       // remove undeletable attribs from the list so we don't delete them later
     314 [ #  # ][ #  # ]:          0 :     if (ca_ptr->delete_attrib() == CUBIT_FALSE)
     315         [ #  # ]:          0 :       ca_list.remove();
     316                 :            :     else
     317         [ #  # ]:          0 :       ca_list.step();
     318                 :            :   }
     319                 :            :   
     320 [ #  # ][ #  # ]:          0 :   for (i = ca_list.size(); i > 0; i--)
     321 [ #  # ][ #  # ]:          0 :     delete ca_list.get_and_step();
         [ #  # ][ #  # ]
     322 [ +  - ][ +  - ]:       6364 : }
     323                 :            : 
     324                 :            : 

Generated by: LCOV version 1.11