cgma
|
00001 00002 #include "FacetEntity.hpp" 00003 #include "CubitFacet.hpp" 00004 #include "CubitPoint.hpp" 00005 #include "CubitFacetEdge.hpp" 00006 #include "GfxDebug.hpp" 00007 #include "CubitBox.hpp" 00008 #include "ChollaSurface.hpp" 00009 #include "CubitMessage.hpp" 00010 00011 #include "ChollaDebug.hpp" 00012 static int fg_color = CUBIT_MAGENTA_INDEX; 00013 void dcolor(int icol) 00014 { 00015 fg_color = icol; 00016 } 00017 00018 void ddraw( FacetEntity *facet_ptr ) 00019 { 00020 facet_ptr->debug_draw( fg_color ); 00021 } 00022 00023 void dfdraw( CubitFacet *facet_ptr ) 00024 { 00025 facet_ptr->debug_draw( fg_color ); 00026 } 00027 00028 void dedraw( CubitFacetEdge *facet_ptr ) 00029 { 00030 facet_ptr->debug_draw( fg_color ); 00031 } 00032 00033 void dpdraw( CubitPoint *facet_ptr ) 00034 { 00035 facet_ptr->debug_draw( fg_color ); 00036 } 00037 00038 00039 void dview() 00040 { 00041 GfxDebug::flush(); 00042 GfxDebug::mouse_xforms(); 00043 } 00044 00045 void dzoom(CubitBox &box) 00046 { 00047 GfxDebug::zoom(box); 00048 } 00049 00050 00051 void dsurfdraw( ChollaSurface *surf) 00052 { 00053 DLIList<FacetEntity*> surface_facets; 00054 surf->get_facets(surface_facets); 00055 dldraw(surface_facets); 00056 } 00057 00058 00059 void dldraw( DLIList<FacetEntity *> &facet_list ) 00060 { 00061 FacetEntity *facet_ptr; 00062 for (int ii=0; ii<facet_list.size(); ii++) 00063 { 00064 facet_ptr = facet_list.get_and_step(); 00065 facet_ptr->debug_draw( fg_color, 0 ); 00066 } 00067 GfxDebug::flush(); 00068 } 00069 00070 void dfldraw( DLIList<CubitFacet *> &facet_list ) 00071 { 00072 CubitFacet *facet_ptr; 00073 for (int ii=0; ii<facet_list.size(); ii++) 00074 { 00075 facet_ptr = facet_list.get_and_step(); 00076 facet_ptr->debug_draw( fg_color, 0 ); 00077 } 00078 GfxDebug::flush(); 00079 } 00080 00081 void deldraw( DLIList<CubitFacetEdge *> &edge_list ) 00082 { 00083 CubitFacetEdge *edge_ptr; 00084 for (int ii=0; ii<edge_list.size(); ii++) 00085 { 00086 edge_ptr = edge_list.get_and_step(); 00087 edge_ptr->debug_draw( fg_color, 0 ); 00088 } 00089 GfxDebug::flush(); 00090 } 00091 00092 void dpldraw( DLIList<CubitPoint *> &point_list ) 00093 { 00094 CubitPoint *point_ptr; 00095 for (int ii=0; ii<point_list.size(); ii++) 00096 { 00097 point_ptr = point_list.get_and_step(); 00098 point_ptr->debug_draw( fg_color, 0 ); 00099 } 00100 GfxDebug::flush(); 00101 } 00102 00103 int dflcheck( DLIList<CubitFacet *> &facet_list ) 00104 { 00105 int ii; 00106 int ier = 0; 00107 for (ii=0; ii<facet_list.size(); ii++) 00108 { 00109 CubitFacet *facet_ptr = facet_list.get_and_step(); 00110 ier += dfcheck( facet_ptr ); 00111 } 00112 return ier; 00113 } 00114 00115 int dcheck( DLIList<FacetEntity *> &facet_list ) 00116 { 00117 int ii; 00118 int ier = 0; 00119 for (ii=0; ii<facet_list.size(); ii++) 00120 { 00121 CubitFacet *facet_ptr = (CubitFacet *)facet_list.get_and_step(); 00122 ier += dfcheck( facet_ptr ); 00123 } 00124 return ier; 00125 } 00126 00127 int dfcheck( CubitFacet *facet_ptr ) 00128 { 00129 int ier = 0; 00130 00131 // check edges 00132 00133 int ii, jj; 00134 for (ii=0; ii<3; ii++) 00135 { 00136 CubitFacetEdge *edge_ptr = facet_ptr->edge( ii ); 00137 DLIList <CubitFacet *> facet_list; 00138 edge_ptr->facets( facet_list ); 00139 int found = 0; 00140 for (jj=0; jj<facet_list.size() && !found; jj++) 00141 { 00142 CubitFacet *f = facet_list.get_and_step(); 00143 if (f == facet_ptr) 00144 { 00145 found = 1; 00146 } 00147 } 00148 if (!found) 00149 { 00150 PRINT_ERROR( "Facet %d is not in Edge %d adjacency list\n", 00151 facet_ptr->id(), edge_ptr->id() ); 00152 ier++; 00153 } 00154 00155 // check the edge's orientation on the facet 00156 00157 CubitPoint *ep0, *ep1; 00158 int use = facet_ptr->edge_use( ii ); 00159 if (use > 0) 00160 { 00161 ep0 = edge_ptr->point( 0 ); 00162 ep1 = edge_ptr->point( 1 ); 00163 } 00164 else 00165 { 00166 ep1 = edge_ptr->point( 0 ); 00167 ep0 = edge_ptr->point( 1 ); 00168 } 00169 00170 CubitPoint *fp0 = facet_ptr->point( (ii+1)%3 ); 00171 CubitPoint *fp1 = facet_ptr->point( (ii+2)%3 ); 00172 if (fp0 != ep0 || fp1 != ep1) 00173 { 00174 PRINT_ERROR( "Edge %d on Facet %d is not oriented with points %d and %d correctly\n", 00175 edge_ptr->id(), facet_ptr->id(), fp0->id(), fp1->id() ); 00176 ier++; 00177 } 00178 } 00179 00180 // check nodes 00181 00182 for (ii=0; ii<3; ii++) 00183 { 00184 CubitPoint *point_ptr = facet_ptr->point( ii ); 00185 DLIList <CubitFacet *> facet_list; 00186 point_ptr->facets( facet_list ); 00187 int found = 0; 00188 for (jj=0; jj<facet_list.size() && !found; jj++) 00189 { 00190 CubitFacet *f = facet_list.get_and_step(); 00191 if (f == facet_ptr) 00192 { 00193 found = 1; 00194 } 00195 } 00196 if (!found) 00197 { 00198 PRINT_ERROR( "Facet %d is not in Point %d adjacency list\n", 00199 facet_ptr->id(), point_ptr->id() ); 00200 ier++; 00201 } 00202 } 00203 return ier; 00204 } 00205 00206 // draw a vector 00207 void dray( const CubitVector &start, const CubitVector &vec, double length ) 00208 { 00209 CubitVector end = start+length*vec; 00210 GfxDebug::draw_vector(end, start, fg_color ); 00211 GfxDebug::flush(); 00212 } 00213 00214 // draw a point 00215 void dpoint( const CubitVector &pt ) 00216 { 00217 GfxDebug::draw_point(pt, fg_color); 00218 GfxDebug::flush(); 00219 00220 } 00221 00222 int get_color() 00223 { 00224 return fg_color; 00225 } 00226 00227 //EOF 00228