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
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
//- Class:       ChollaSurface
//- Description: Temporary class for constructing the facet-based geometry
//-              
//- Owner:       Steven J. Owen
//- Checked by:
//- Version:
#include "ChollaSurface.hpp"
#include "ChollaCurve.hpp"
#include "ChollaPoint.hpp"
#include "TDGeomFacet.hpp"
#include "CastTo.hpp"
#include "CubitPoint.hpp"
#include "CubitFacet.hpp"
#include "CubitFacetData.hpp"
#include "CubitFacetEdge.hpp"
#include "CubitPointData.hpp"
#include "CubitFacetEdgeData.hpp"
#include "ChollaDebug.hpp"
#include "TDFacetBoundaryPoint.hpp"
#include "TDFacetBoundaryEdge.hpp"
#include "GfxDebug.hpp"
#include "FacetEvalTool.hpp"
#include "FacetDataUtil.hpp"

//===============================================================================
//Function:  ChollaSurface (PUBLIC) (constructor)
//===============================================================================
ChollaSurface::ChollaSurface(int block_id)
{
  static int count = 100;
  id = count++;
  myFlag = CUBIT_FALSE;
  mySurface = NULL;
  myEvalTool = NULL;
  blockId = block_id;
  myMergePartner = NULL;
}
//===============================================================================
//Function:  ~ChollaSurface (PUBLIC) (destructor)
//===============================================================================
ChollaSurface::~ChollaSurface()
{
}

//===========================================================================
//Function Name: check_faceting
//
//Member Type:  PRIVATE
//Descriptoin:  check the edge/face orientations  
//===========================================================================
void ChollaSurface::check_faceting()
{

}


//=============================================================================
//Function:  split_surface (PUBLIC)
//Description: split this surface into multiple ChollaSurface where there are
//             discontinuous faces.  
//Author: sjowen
//Date: 12/22/00
//=============================================================================
CubitStatus ChollaSurface::split_surface( 
  DLIList<ChollaSurface*> &facet_surface_list 
  )
{
  DLIList<ChollaSurface*> new_surface_list;
  CubitStatus stat = CUBIT_SUCCESS;<--- Variable 'stat' is assigned a value that is never used.

  // Go through the surfaceElemList and pull faces off one by one as we
  // determine which surface it belongs to.  Continue until we have depleted
  // the list

  int jj;
  int mydebug = 0;
  int num_surfs_created = 0;
  while( surfaceElemList.size() > 0)
  {

    // start with the first face and create a list of all elements 
    // attached to the face

    DLIList<FacetEntity*> face_list;
    FacetEntity *start_face_ptr = surfaceElemList.get_and_step();
    stat = get_adj_facets( start_face_ptr, face_list, mydebug );
    if (stat != CUBIT_SUCCESS)
      return stat;

    // if we have the same number of faces on the face_list as we do
    // on the surfaceElemList, then we are done.  This surface is
    // not multiply connected.  Oherwise continue...

    if (face_list.size() == surfaceElemList.size())
    {

      // if this surface had a curve already defined (its a 2D topology
      // defined in skin2D) then its no longer valid if the surface was split
      // (for 3D the curves aren't defined until later)

      if (num_surfs_created > 0 && curveList.size() > 0)
      {
        ChollaCurve *fcm_ptr = curveList.get();  // there should only be 1
        curveList.remove();
        fcm_ptr->remove_td_associativity( this );
        delete fcm_ptr;
      }
      return CUBIT_SUCCESS;
    }

    // create a new surface to hold the face info

    num_surfs_created++;
    ChollaSurface *fsm_ptr = new ChollaSurface( blockId );
    facet_surface_list.append( fsm_ptr );

    // update the geometric curve pointer

    fsm_ptr->assign_geometric_surface( NULL );

    // add the faces to this surface and update the surface 
    // pointers in the face tool data

      // surfaceElemList: nullify the items then compress the list
      // afterwards, instead of removing the items one by one, for
      // speed.
    for (jj=face_list.size(); jj > 0; jj--)
    {
      FacetEntity *face_ptr = face_list.get_and_step();
      TDGeomFacet *td_gm_face = TDGeomFacet::get_geom_facet(face_ptr); 
      td_gm_face->remove_cholla_surf( this );
      td_gm_face->add_cholla_surf( fsm_ptr );
      surfaceElemList.move_to_nearby( face_ptr );
      surfaceElemList.extract();
      fsm_ptr->add_facet( face_ptr );
    }
  }

  return CUBIT_SUCCESS;
}


#if 0
//=============================================================================
//Function:  get_adj_facets (PRIVATE)
//Description: recursive funstion that creates a list of all faces connected
//             the passed in face  
//Author: sjowen
//Date: 12/22/00
//=============================================================================
CubitStatus ChollaSurface::get_adj_facets( 
  FacetEntity *start_face_ptr,
  DLIList<FacetEntity*> &face_list,
  int mydebug)
{
  CubitStatus stat = CUBIT_SUCCESS;

  // add this face to the list

  if (mydebug)
  {
    //start_face_ptr->draw( CUBIT_RED_INDEX );
    //CDrawingTool::instance()->flush();
  }
  face_list.append( start_face_ptr );
  TDGeomFacet *td_gm_face = TDGeomFacet::get_geom_facet(start_face_ptr);
  td_gm_face->set_hit_flag( 0 );

  // loop through its edges

  CubitFacetEdge *edge_ptr;
  FacetEntity *face_ptr;
  DLIList<CubitFacetEdge*> edge_list;
  start_face_ptr->edges( edge_list );
  int ii;
  for (ii=0; ii<edge_list.size(); ii++)
  {
    edge_ptr = edge_list.get_and_step();
    
    // edges that already have a tool data defined are the result
    // of a feature angle.  Don't traverse past a feature angle edge
    
    TDGeomFacet *td_gm_edge = TDGeomFacet::get_geom_facet(edge_ptr);
    if (td_gm_edge == NULL)
    {
      DLIList<FacetEntity*> adj_face_list;
      edge_ptr->get_parents( adj_face_list );

      // keep traversing only if there are two adjacent faces to this edge,
      // otherwise, this is a boundary

      if (adj_face_list.size() == 2)
      {
        face_ptr = adj_face_list.get_and_step();
        if (face_ptr == start_face_ptr)
          face_ptr = adj_face_list.get();

        // go to its neighbor if it is part of the surface

        td_gm_face = TDGeomFacet::get_geom_facet(face_ptr); 
        if (td_gm_face->get_hit_flag() == id)
        {
          stat = get_adj_facets( face_ptr, face_list, mydebug );
          if (stat != CUBIT_SUCCESS)
            return stat;
        }
      }
    }
  }
  return stat;
}
#endif

//=============================================================================
//Function:  get_adj_facets (PRIVATE)
//Description: non recursive function that creates a list of all facets connected
//             to the passed in facet  
//Author: sjowen
//Date: 12/22/00
//=============================================================================
CubitStatus ChollaSurface::get_adj_facets( 
  FacetEntity *start_face_ptr,
  DLIList<FacetEntity*> &face_list,
  int mydebug,
  bool bound_check,
  bool feature_edge_check)
{
  //int found = 0;
  int ii;
  CubitStatus stat = CUBIT_SUCCESS;
  DLIList<FacetEntity*> temp_list;
  FacetEntity *face_ptr = NULL;
  FacetEntity *adj_face_ptr = NULL;
  DLIList<CubitFacetEdge *>edge_list;
  CubitFacetEdge *edge_ptr = NULL;
  DLIList<FacetEntity *>adj_face_list;

  if (mydebug)
  {
    for(ii=0; ii<surfaceElemList.size(); ii++)
    {
      face_ptr = surfaceElemList.get_and_step();
      TDGeomFacet *td_gm_face = TDGeomFacet::get_geom_facet(face_ptr);
      PRINT_INFO("%d ", td_gm_face->get_hit_flag());
      if (ii%10 == 0)
      {
        PRINT_INFO("\n");
      }
    }
  }

  // add this face to the list

  temp_list.append( start_face_ptr );
  TDGeomFacet *td_gm_face = TDGeomFacet::get_geom_facet(start_face_ptr);
  td_gm_face->set_hit_flag( 0 );

  while (temp_list.size())
  {
    face_ptr = temp_list.pop();
    td_gm_face = TDGeomFacet::get_geom_facet(face_ptr); 
    if (td_gm_face->get_hit_flag() == 0)
    {
      face_list.append( face_ptr );
      if (mydebug)
      {
        face_ptr->debug_draw( CUBIT_RED_INDEX );
        GfxDebug::flush();
      }
      edge_list.clean_out();
      face_ptr->edges( edge_list );
      for (ii=0; ii<edge_list.size(); ii++)
      {
        edge_ptr = edge_list.get_and_step();

        // edges that already have a tool data defined are the result
        // of a feature angle.  Don't traverse past a feature angle edge
    
        TDGeomFacet *td_gm_edge = TDGeomFacet::get_geom_facet(edge_ptr);
        if (td_gm_edge == NULL || !feature_edge_check )
        {
          adj_face_list.clean_out();
          edge_ptr->get_parents( adj_face_list );

          // keep traversing only if there are two adjacent faces to this edge,
          // otherwise, this is a boundary

          if (adj_face_list.size() != 2)
          {
            continue;
          }

          if( bound_check )
          {
            TDFacetBoundaryEdge *td_facet_bnd_edge = TDFacetBoundaryEdge::get_facet_boundary_edge( edge_ptr );
            if( td_facet_bnd_edge )
              continue;
          }
            
          adj_face_ptr = adj_face_list.get_and_step();
          if (adj_face_ptr == face_ptr)
            adj_face_ptr = adj_face_list.get();

          // go to its neighbor if it is part of the surface

          td_gm_face = TDGeomFacet::get_geom_facet(adj_face_ptr); 
          if (td_gm_face->get_hit_flag() == id)
          {
            temp_list.append( adj_face_ptr );
            td_gm_face->set_hit_flag( 0 );
          }
          
        }
      }
    }
  }
  return stat;
}



//=============================================================================
//Function:  feature_angle (PRIVATE)
//Description: mark all edges that exceed the specified feature angle
//             min_dot is the minimum dot product between adjacent face normals
//Author: sjowen
//Date: 12/22/00
//=============================================================================
CubitStatus ChollaSurface::feature_angle( 
  double min_dot,
  DLIList<CubitFacetEdge *> &feature_edge_list)
{
  //CubitStatus stat = CUBIT_SUCCESS;
  int ii, jj;

  // compute face normals
  int mydebug = 0;<--- Assignment 'mydebug=0', assigned value is 0
  double dot;
  CubitVector face_normal, adj_face_normal;
  FacetEntity *face_ptr, *adj_face_ptr;
  TDGeomFacet *td_gm_face;
  CubitFacet *tri_ptr;
  for (ii=0; ii<surfaceElemList.size(); ii++)
  {
    face_ptr = surfaceElemList.get_and_step();
    td_gm_face = TDGeomFacet::get_geom_facet(face_ptr);
    tri_ptr = CAST_TO( face_ptr, CubitFacet );
    face_normal = tri_ptr->normal( );
    face_normal.normalize();
    td_gm_face->set_normal( face_normal );
  }

  // check adjacencies and compute the dot product between them
  // where dot product is less than the min_dot, create a tool data
  // on the edge
  
  if(mydebug)<--- Condition 'mydebug' is always false
    GfxDebug::clear();
  for (ii=0; ii<surfaceElemList.size(); ii++)
  {
    face_ptr = surfaceElemList.get_and_step();
    CubitFacet* curr_facet = CAST_TO(face_ptr, CubitFacet);
    CubitFacet* temp_facet = NULL;
    double curr_area=curr_facet->area();
    td_gm_face = TDGeomFacet::get_geom_facet(face_ptr);
    face_normal = td_gm_face->get_normal();
    DLIList<CubitFacetEdge*> edge_list;
    face_ptr->edges( edge_list );
    for (jj=0; jj<edge_list.size(); jj++)
    {
      CubitFacetEdge *edge_ptr = edge_list.get_and_step();
      TDGeomFacet *td_gm_edge = TDGeomFacet::get_geom_facet(edge_ptr);
      if (!td_gm_edge)
      {
        DLIList<FacetEntity*> adj_face_list;
        edge_ptr->get_parents( adj_face_list );

        // it has to be an internal edge - ignore boundaries
        if (adj_face_list.size() == 2)
        {
          adj_face_ptr = adj_face_list.get_and_step();
          
          if (adj_face_ptr == face_ptr)
            adj_face_ptr = adj_face_list.get();          
          td_gm_face = TDGeomFacet::get_geom_facet(adj_face_ptr);

          // make sure the adj face is on the same surface

          if (td_gm_face->get_hit_flag() == id)
          {

            // test the dot product between normals

            adj_face_normal = td_gm_face->get_normal();
            temp_facet = CAST_TO(adj_face_ptr, CubitFacet);
            double adj_area=temp_facet->area();
              //mbrewer:: ensure no NULL
            dot = adj_face_normal % face_normal;
            bool add_an_edge = true;
            if(mydebug){
              PRINT_INFO("This area %f, other %f\n",curr_area,adj_area);
            }
            if(curr_area<(1.e-10*adj_area)){
              DLIList<CubitFacetEdge*> edge_list_tmp;
              CubitFacetEdge* edge_ptr_tmp=NULL;
              curr_facet->edges(edge_list_tmp);
              double edge_length = edge_ptr->length();
              int k = 0;
              if(edge_list_tmp.size()>0)
                add_an_edge=false;
              for(k=edge_list_tmp.size();k>0;k--){
                edge_ptr_tmp=edge_list_tmp.get_and_step();
                if(edge_ptr_tmp != edge_ptr &&
                   edge_ptr_tmp->length() > edge_length){
                  add_an_edge=true;
                }
              }
            }
            if(adj_area<(1.e-10*curr_area))
            {
              DLIList<CubitFacetEdge*> edge_list_tmp;
              CubitFacetEdge* edge_ptr_tmp=NULL;
              temp_facet->edges(edge_list_tmp);
              double edge_length = edge_ptr->length();
              int k = 0;
              if(edge_list_tmp.size()>0)
                add_an_edge=false;
              for(k=edge_list_tmp.size();k>0;k--){
                edge_ptr_tmp=edge_list_tmp.get_and_step();
                if(edge_ptr_tmp != edge_ptr &&
                   edge_ptr_tmp->length() > edge_length){
                  add_an_edge=true;
                }
              }
            }
            if (dot <= min_dot && add_an_edge )
            {
              if(mydebug){
                edge_ptr->debug_draw(CUBIT_MAGENTA_INDEX);
              }
              TDGeomFacet::add_geom_facet(edge_ptr, -1); 
              td_gm_edge = TDGeomFacet::get_geom_facet(edge_ptr);
              edge_ptr->set_as_feature();
              feature_edge_list.append( edge_ptr );
            }
          }
        }

        // non-manifold edges (edges with more than 2 adj facets)
        // must be features

        else if (adj_face_list.size() > 2)
        {
          TDGeomFacet::add_geom_facet(edge_ptr, -1); 
          td_gm_edge = TDGeomFacet::get_geom_facet(edge_ptr);
          edge_ptr->set_as_feature();
          feature_edge_list.append( edge_ptr );
        }
      }
    }
  }
  if(mydebug){
    GfxDebug::mouse_xforms();
  }
  return CUBIT_SUCCESS;
}

//=============================================================================
//Function:  add_preexisting_feature_edges (PRIVATE)
//Description: edges that were marked previously in function ChollaEngine::mark_features
//             are added to the feature edge list
//Author: sjowen
//Date: 01/08
//=============================================================================
CubitStatus ChollaSurface::add_preexisting_feature_edges( 
	DLIList<CubitFacetEdge *> &feature_edge_list)
{
	DLIList<CubitFacetEdge *> edge_list;
	DLIList<CubitFacet *> facet_list;
	CAST_LIST( surfaceElemList, facet_list, CubitFacet );
	FacetDataUtil::get_edges( facet_list, edge_list );
	int iedge;
	CubitFacetEdge *edge;
	for (iedge=0; iedge < edge_list.size(); iedge++)
	{
		edge = edge_list.get_and_step();
		if (edge->is_feature())
			feature_edge_list.append(edge);
	}
	return CUBIT_SUCCESS;
}
	

//=============================================================================
//Function:  non_manifold_edges (PRIVATE)
//Description: mark all edges that are non-manifold (have more than 2 adj
//             facets)
//Author: sjowen
//Date: 5/01
//=============================================================================
CubitStatus ChollaSurface::non_manifold_edges( 
  DLIList<CubitFacetEdge *> &feature_edge_list)
{
  //CubitStatus stat = CUBIT_SUCCESS;
  int ii, jj;
  DLIList<CubitFacetEdge*> edge_list;
  FacetEntity *face_ptr;
  for (ii=0; ii<surfaceElemList.size(); ii++)
  {
    face_ptr = surfaceElemList.get_and_step();
    edge_list.clean_out();
    face_ptr->edges( edge_list );
    for (jj=0; jj<edge_list.size(); jj++)
    {
      CubitFacetEdge *edge_ptr = edge_list.get_and_step();
      TDGeomFacet *td_gm_edge = TDGeomFacet::get_geom_facet(edge_ptr);
      if (!td_gm_edge)
      {
        DLIList<FacetEntity*> adj_face_list;
        edge_ptr->get_parents( adj_face_list );

        // non-manifold edges (edges with more than 2 adj facets)
        // must be features

        if (adj_face_list.size() > 2 || edge_ptr->is_feature())
        {
          TDGeomFacet::add_geom_facet(edge_ptr, -1); 
          td_gm_edge = TDGeomFacet::get_geom_facet(edge_ptr);
          edge_ptr->set_as_feature();
          feature_edge_list.append( edge_ptr );
        }
      }
    }
  }
  return CUBIT_SUCCESS;
}



//=============================================================================
//Function:  clean_features (PRIVATE)
//Description: clean up edges that do not form complete loops as a result 
//             of feature angle
//Author: sjowen
//Date: 12/22/00
//=============================================================================
CubitStatus ChollaSurface::clean_features( )
{
  int ii, jj;
  for (ii=0; ii<surfaceElemList.size(); ii++)
  {
    FacetEntity *face_ptr = surfaceElemList.get_and_step();
    DLIList<CubitFacetEdge*> edge_list;
    face_ptr->edges( edge_list );
    for (jj=0; jj<edge_list.size(); jj++)
    {
      CubitFacetEdge *edge_ptr = edge_list.get_and_step();
      TDGeomFacet *td_gm_edge = TDGeomFacet::get_geom_facet(edge_ptr);
      if (td_gm_edge != NULL)
      {

        // make sure this edge actually forms the boundary between two surfaces

        DLIList<FacetEntity*> adj_face_list;
        edge_ptr->get_parents( adj_face_list );

        // it has to be an internal edge - ignore boundaries

        if (adj_face_list.size() == 2)
        {
          FacetEntity *adj_face_ptr = adj_face_list.get_and_step();
          if (adj_face_ptr == face_ptr)
            adj_face_ptr = adj_face_list.get();          
          TDGeomFacet *td_gm_adjface = TDGeomFacet::get_geom_facet(adj_face_ptr);
          if (td_gm_adjface != NULL)
          {
            DLIList<ChollaSurface*> surf_list;
            td_gm_adjface->get_cholla_surfs( surf_list );
            ChollaSurface *adj_surf = surf_list.get();  // must be only 1 surf
            if (adj_surf == this)
            {

              // the same surface is on both sides of this edge - Therefore it
              // does not form a complete loop.  Delete the tool data from
              // this edge to indicate that it is not at a boundary.

              edge_ptr->delete_TD( &TDGeomFacet::is_geom_facet );
            }
          }
        }
      }
    }
  }
  return CUBIT_SUCCESS;
}

//=============================================================================
//Function:  init_hit_flags (PUBLIC)
//Description: initialize the hit flags to the block surface id - used for 
//             traversing the faces
//Author: sjowen
//Date: 01/22/01
//=============================================================================
void ChollaSurface::init_hit_flags()
{
  int ii;
  for (ii=0; ii<surfaceElemList.size(); ii++)
  {
    FacetEntity *face_ptr = surfaceElemList.get_and_step();
    TDGeomFacet *td_gm = TDGeomFacet::get_geom_facet(face_ptr);
    td_gm->set_hit_flag( id );
  }
}

//=============================================================================
//Function:  get_points (PUBLIC)
//Description: compile a list of points on the surface 
//Author: sjowen
//Date: 4/01
//=============================================================================
void ChollaSurface::get_points( DLIList<CubitPoint *> &point_list )
{
  int ii;
  CubitPoint *point[3];
  CubitFacet *facet;
  FacetEntity *facet_entity;
  for (ii=0; ii<surfaceElemList.size(); ii++)
  {
    facet_entity = surfaceElemList.get_and_step();
    facet = CAST_TO( facet_entity, CubitFacet );
    facet->points( point[0], point[1], point[2] );
    point[0]->marked(0);
    point[1]->marked(0);
    point[2]->marked(0);
  }

  int jj;
  for (ii=0; ii<surfaceElemList.size(); ii++)
  {
    facet_entity = surfaceElemList.get_and_step();
    facet = CAST_TO( facet_entity, CubitFacet );
    facet->points( point[0], point[1], point[2] );
    for (jj=0; jj<3; jj++)
    {
      if (point[jj]->marked() == 0)
      {
        point[jj]->marked(1);
        point_list.append(point[jj]);
      }
    }
  }
}

//=============================================================================
//Function:  update_boundary_tool_data (PUBLIC)
//Description: update the surface IDs on the boundary facet tooldatas
//Author: sjowen
//Date: 5/01
//=============================================================================
CubitStatus ChollaSurface::update_boundary_tool_data()
{
  int ii, jj;
  CubitPoint *point_ptr;
  CubitFacetEdge *edge_ptr;
  CubitFacet *facet_ptr;
  FacetEntity *facet_entity;

  TDFacetBoundaryPoint *td_fbp;
  TDFacetBoundaryEdge *td_fbe;
  for (ii=0; ii<surfaceElemList.size(); ii++)
  {
    facet_entity = surfaceElemList.get_and_step();
    facet_ptr = CAST_TO( facet_entity, CubitFacet );
    for (jj=0; jj<3; jj++)
    {
      point_ptr = facet_ptr->point(jj);
      td_fbp = TDFacetBoundaryPoint::get_facet_boundary_point( point_ptr );
      if (td_fbp != NULL)
      {
        td_fbp->set_surf_id( facet_ptr, id );
      }

      edge_ptr = facet_ptr->edge(jj);
      td_fbe = TDFacetBoundaryEdge::get_facet_boundary_edge( edge_ptr );
      if (td_fbe != NULL)
      {
        td_fbe->set_surf_id( facet_ptr, id );
      }
    }
  }

  return CUBIT_SUCCESS;
}

//=============================================================================
//Function:  reset_facet_flags (PUBLIC)
//Description: 
//Author: sjowen
//Date: 6/01
//=============================================================================
void ChollaSurface::reset_facet_flags()
{
  CubitFacet *facet_ptr;
  FacetEntity *fe_ptr;
  int ii;
  for (ii=0; ii<surfaceElemList.size(); ii++)
  {
    fe_ptr = surfaceElemList.get_and_step();
    facet_ptr = CAST_TO( fe_ptr, CubitFacet );
    facet_ptr->marked( 0 );
  }
}

//=============================================================================
//Function:  is_adjacent (PUBLIC)
//Description: determine if this surface is adjacent to the given surface
//Author: sjowen
//Date: 02/11/2004
//=============================================================================
CubitBoolean ChollaSurface::is_adjacent( ChollaSurface *other_surf )
{
  DLIList<ChollaSurface *> *adjsurf_list_ptr;
  ChollaCurve *curv;
  ChollaSurface *surf;
  int icurv, ii;
  for(icurv=0; icurv< curveList.size(); icurv++)
  {
    curv = curveList.get_and_step();
    adjsurf_list_ptr = curv->get_surface_list_ptr();
    for(ii=0; ii<adjsurf_list_ptr->size(); ii++)
    {
      surf = adjsurf_list_ptr->get_and_step();
      if (surf != this && surf == other_surf)
      {
        return CUBIT_TRUE;
      }
    }
  }
  return CUBIT_FALSE; 
}

//=============================================================================
//Function:  get_loop_edges (PUBLIC)
//Description: return the ordered list of edges on the boundary of this surface 
//Author: sjowen
//Date: 02/23/2004
//=============================================================================
DLIList<DLIList<CubitFacetEdge *>*> *ChollaSurface::get_loop_edges(  )
{
  assert(myEvalTool != NULL);
  return myEvalTool->loops();
}


static int icolor = 0;
void ChollaSurface::debug_draw()
{
  icolor++;
  icolor = (icolor%15)+1;
  dcolor(icolor);
  dldraw(surfaceElemList);
}

//=============================================================================
//Function:  flip_facets (PUBLIC)
//Description: invert all facets on this surface 
//Author: sjowen
//Date: 09/10/09
//=============================================================================
void ChollaSurface::flip_facets()
{
  FacetEntity *facet_entity;
  CubitFacet *facet_ptr;
  for (int ii=0; ii<surfaceElemList.size(); ii++)
  {
    facet_entity = surfaceElemList.get_and_step();
    facet_ptr = dynamic_cast<CubitFacet *> (facet_entity);
    assert( facet_ptr != NULL );
    facet_ptr->flip();
  }
}

//=============================================================================
//Function:  is_in_volume (PUBLIC)
//Description: return whether this surface is in a particular volume 
//Author: sjowen
//Date: 09/11/09
//=============================================================================
CubitBoolean ChollaSurface::is_in_volume( ChollaVolume *chvol_ptr )
{
  ChollaVolume *mychvol_ptr;
  for (int ii=0; ii<volList.size(); ii++)
  {
    mychvol_ptr = volList.get_and_step();
    if (mychvol_ptr == chvol_ptr)
      return CUBIT_TRUE;
  }
  return CUBIT_FALSE;
}

//=============================================================================
//Function:  get_vertices (PUBLIC)
//Description: get the list of ChollaPoints on this surface
//Author: sjowen
//Date: 09/11/09
//=============================================================================
void ChollaSurface::get_vertices( DLIList<ChollaPoint *> &chpt_list )
{
  chpt_list.clean_out();
  ChollaCurve *chcurv_ptr;
  for (int ii=0; ii<curveList.size(); ii++)
  {
    chcurv_ptr = curveList.get_and_step();
    DLIList<ChollaPoint *> chc_pts = chcurv_ptr->get_points(); 
    chpt_list += chc_pts;
  }
  chpt_list.uniquify_unordered();
}

bool ChollaSurface::is_contain( FacetEntity *facet )
{
  if( surfaceElemList.is_in_list( facet ) )
    return true;
  else
    return false;
}

//EOF