1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
//- Class:       ChollaSkinTool
//- Description: Creates a skin defined by facets and points, depending on the
//-              dimensionality of the desired skin.
//- Owner:       Steve Owen
//- Checked by:
//- Version:
#include "ChollaSkinTool.hpp"
#include "FacetEntity.hpp"
#include "TDGeomFacet.hpp"
#include "CastTo.hpp"
#include "ChollaSurface.hpp"
#include "ChollaCurve.hpp"
#include "CubitFacetEdge.hpp"
#include "TDFacetBoundaryEdge.hpp"
#include "debug.hpp"
#include "GfxDebug.hpp"

static int mydebug = 0;
//==================================================================================
//Function:  ChollaSkinTool (PUBLIC) (constructor)
//==================================================================================
ChollaSkinTool::ChollaSkinTool()
{
}
//==================================================================================
//Function:  ~ChollaSkinTool (PUBLIC) (destructor)
//==================================================================================
ChollaSkinTool::~ChollaSkinTool()
{
}

//==================================================================================
//Function:  skin_1d  (PUBLIC)
//Description:  creates a skin of the given facet entities.
//==================================================================================
CubitStatus ChollaSkinTool::skin_1d(DLIList<FacetEntity*> &facet_list,<--- The function 'skin_1d' is never used.
                                   ChollaCurve *&facet_curve_mesh_ptr)
{
  CubitStatus rv = CUBIT_SUCCESS;
  
  // create a ChollaCurve if we have to (only if this is a 1D facet)
  
  if (!facet_curve_mesh_ptr)
  {
    FacetEntity *edge_ptr = facet_list.get();
    TDGeomFacet *td_gm = TDGeomFacet::get_geom_facet( edge_ptr );
    facet_curve_mesh_ptr = new ChollaCurve( td_gm->get_block_id() );
    
    // associate all of the tooldata on the faces of this surf with the 
    // new ChollaCurve
    
    int ii;
    for (ii=0; ii<facet_list.size(); ii++)
    {
      edge_ptr = facet_list.get_and_step();
      facet_curve_mesh_ptr->add_facet( edge_ptr );
      td_gm = TDGeomFacet::get_geom_facet( edge_ptr );
      td_gm->add_cholla_curve( facet_curve_mesh_ptr );
    }
  }
  
  // Note: the start and end points of this curve will be defined in 
  // ChollaCurve::split_curve.  The BlockPointMesh objects at these points
  // will be defined in MeshGeometryCreator::classify_node
  
  return rv;
}

//==================================================================================
//Function:  skin_2d  (PUBLIC)
//Description:  creates a skin of the given mesh entities.
//==================================================================================
CubitStatus ChollaSkinTool::skin_2d(DLIList<FacetEntity*> &facet_list,
                                   ChollaSurface *&facet_surface_mesh_ptr)
{
  if(facet_list.size() == 0){
    return CUBIT_SUCCESS;
  }
  
  int debugflag=0;
  if (debugflag)
  {
    dcolor(CUBIT_YELLOW_INDEX);
    dldraw( facet_list );
    dview();
    dcolor(CUBIT_RED_INDEX);
  }
  CubitStatus rv = CUBIT_SUCCESS;
  int block_id;

  // create a ChollaSurface if we have to (only if this is a 2D model)

  FacetEntity *face_ptr = facet_list.get();
  TDGeomFacet *td_gm = TDGeomFacet::get_geom_facet( face_ptr );
  block_id = td_gm->get_block_id();
  if (!facet_surface_mesh_ptr)
  {
    facet_surface_mesh_ptr = new ChollaSurface(block_id);

    // associate all of the tooldata on the faces of this surf with the new ChollaSurface

    int ii;
    for (ii=0; ii<facet_list.size(); ii++)
    {
      face_ptr = facet_list.get_and_step();
      facet_surface_mesh_ptr->add_facet( face_ptr );
      td_gm = TDGeomFacet::get_geom_facet( face_ptr );
      td_gm->add_cholla_surf( facet_surface_mesh_ptr );
      td_gm->set_hit_flag( facet_surface_mesh_ptr->get_id() );
    }
  }

  // create a single ChollaCurve for this surface (assumes one loop of edges)

  ChollaCurve *fcm_ptr = new ChollaCurve( block_id );
  facet_surface_mesh_ptr->add_curve( fcm_ptr );
  fcm_ptr->add_surface( facet_surface_mesh_ptr );

  // loop through all faces on this surface searching for the boundary edges

  int jj, kk, ll;
  for ( kk = 0; kk < facet_list.size(); kk++)
  {
    face_ptr = facet_list.get_and_step();
    DLIList<CubitFacetEdge*> edge_list;
    face_ptr->edges( edge_list );

    // loop through each edge on this face searching for boundary edges

    for (jj=edge_list.size(); jj > 0; jj--)
    {
      CubitFacetEdge *edge_ptr = edge_list.get_and_step();

      // check if this edge has already been processed from an adjacent surface.
      // If it has, then tool data would have already been defined at this edge
      // and by definition would be at the boundary (only tooldatas on edges
      // at the boundary ofa surface are created)

      TDGeomFacet *td_gm_edge = TDGeomFacet::get_geom_facet(edge_ptr);
      int on_boundary = 0;
      if (td_gm_edge != NULL)
      { 
        on_boundary = 1;

        // check for internal C-zero edge

        if (edge_ptr->num_adj_facets() == 2)
        {
          TDFacetBoundaryEdge *td_fbe = 
            TDFacetBoundaryEdge::get_facet_boundary_edge( edge_ptr );
          if (td_fbe != NULL)
          {
            if (td_fbe->is_internal_edge())
            {
              on_boundary = 0;
            }
          }
        } 
      }

      // check for general case where no tool data yet defined

      else 
      {
        DLIList<FacetEntity*> adj_face_list;

        // check the adjacent faces to this edge.  If only one adjacent face, then
        // it is on the boundary.  If more than one face, then the other face(s)
        // must be associated with a surface other than facet_surface_mesh_ptr
        // in order to be on the boundary

        edge_ptr->get_parents( adj_face_list );
        if (adj_face_list.size() <= 1)
        {
          on_boundary = 1;
        }
        else
        {
          for (ll=adj_face_list.size(); ll> 0 && !on_boundary; ll--)
          {
            FacetEntity *adj_face_ptr = adj_face_list.get_and_step();
            if (adj_face_ptr != face_ptr)
            {
              TDGeomFacet *td_gm_adjface = TDGeomFacet::get_geom_facet(adj_face_ptr);
              DLIList<ChollaSurface*> surf_list;
              td_gm_adjface->get_cholla_surfs( surf_list );

              // if it doesn't have an associated surface yet, then it is 
              // a neighboring surface that has not been defined yet (this
              // should only occur for the 2D case)
                       
              if (surf_list.size() == 0)
              {
                on_boundary = 1;
              }
              else
              {

                // there should only be one surface associated with
                // each face - otherwise we've screwed up somewhere  

                assert ( surf_list.size() == 1 );

                // if the surface is not the same as the current surface
                // then we are at the boundary

                ChollaSurface *check_bsm_ptr = surf_list.get();
                if (facet_surface_mesh_ptr != check_bsm_ptr)
                {
                  on_boundary = 1;
                }
              }
            }
          }
        }
      }
      if (on_boundary)
      {
        // create a tool data if needed

        if (td_gm_edge == NULL)
        {
          TDGeomFacet::add_geom_facet(edge_ptr, -1); 
          td_gm_edge = TDGeomFacet::get_geom_facet( edge_ptr );
          edge_ptr->set_as_feature();
        }

        // add the pointer to this surface onto the edge tool data

        td_gm_edge->add_cholla_surf( facet_surface_mesh_ptr );

        // add this edge to the curve

        fcm_ptr->add_facet( edge_ptr );
        if (mydebug)
          dedraw(edge_ptr);
      }
    }
  }

  return rv;
}