moab
|
00001 00017 #ifndef MOAB_DUAL_TOOL_HPP 00018 #define MOAB_DUAL_TOOL_HPP 00019 00020 #include "moab/Forward.hpp" 00021 00022 namespace moab { 00023 00031 class DualTool 00032 { 00033 public: 00035 static const char *DUAL_SURFACE_TAG_NAME; 00036 00038 static const char *DUAL_CURVE_TAG_NAME; 00039 00041 static const char *IS_DUAL_CELL_TAG_NAME; 00042 00044 static const char *DUAL_ENTITY_TAG_NAME; 00045 00047 static const char *EXTRA_DUAL_ENTITY_TAG_NAME; 00048 00050 static const char *DUAL_GRAPHICS_POINT_TAG_NAME; 00051 00053 class GraphicsPoint 00054 { 00055 public: 00056 GraphicsPoint() 00057 {xyz[0] = 0.0; xyz[1] = 0.0; xyz[2] = 0.0; id = -1;} 00058 00059 GraphicsPoint(float xi, float yi, float zi, int idi) 00060 {xyz[0] = xi; xyz[1] = yi; xyz[2] = zi; id = idi;} 00061 00062 GraphicsPoint(float xyzi[3], int idi) 00063 {xyz[0] = xyzi[0]; xyz[1] = xyzi[1]; xyz[2] = xyzi[2]; id = idi;} 00064 00065 GraphicsPoint(double xyzi[3], int idi) 00066 {xyz[0] = xyzi[0]; xyz[1] = xyzi[1]; xyz[2] = xyzi[2]; id = idi;} 00067 00068 GraphicsPoint(const GraphicsPoint &gp) 00069 {xyz[0] = gp.xyz[0]; xyz[1] = gp.xyz[1]; xyz[2] = gp.xyz[2]; id = gp.id;} 00070 00071 float xyz[3]; 00072 int id; 00073 }; 00074 00075 DualTool(Interface *impl); 00076 00077 ~DualTool(); 00078 00080 ErrorCode construct_dual(EntityHandle *entities, 00081 const int num_entities); 00082 00084 ErrorCode construct_hex_dual(EntityHandle *entities, 00085 const int num_entities); 00086 00088 ErrorCode construct_hex_dual(Range &entities); 00089 00091 ErrorCode get_dual_entities(const int dim, 00092 EntityHandle *entities, 00093 const int num_entities, 00094 Range &dual_ents); 00095 00097 ErrorCode get_dual_entities(const int dim, 00098 EntityHandle *entities, 00099 const int num_entities, 00100 std::vector<EntityHandle> &dual_ents); 00101 00103 EntityHandle get_dual_entity(const EntityHandle this_ent) const; 00104 00106 EntityHandle get_extra_dual_entity(const EntityHandle this_ent); 00107 00110 static ErrorCode get_dual_hyperplanes(const Interface *impl, const int dim, 00111 Range &dual_ents); 00112 00115 ErrorCode get_graphics_points(EntityHandle dual_ent, 00116 std::vector<int> &npts, 00117 std::vector<GraphicsPoint> &gpoints); 00118 00121 ErrorCode get_graphics_points(const Range &in_range, 00122 std::vector<GraphicsPoint> &gpoints, 00123 const bool assign_ids = false, 00124 const int start_id = 0); 00125 00128 EntityHandle next_loop_vertex(const EntityHandle last_v, 00129 const EntityHandle this_v, 00130 const EntityHandle dual_surf); 00131 00133 Tag dualSurface_tag() const; 00134 ErrorCode dualSurface_tag(const Tag tag); 00135 00137 Tag dualCurve_tag() const; 00138 ErrorCode dualCurve_tag(const Tag tag); 00139 00141 Tag isDualCell_tag() const; 00142 ErrorCode isDualCell_tag(const Tag tag); 00143 00145 Tag dualEntity_tag() const; 00146 ErrorCode dualEntity_tag(const Tag tag); 00147 00149 Tag extraDualEntity_tag() const; 00150 ErrorCode extraDualEntity_tag(const Tag tag); 00151 00153 Tag dualGraphicsPoint_tag() const; 00154 ErrorCode dualGraphicsPoint_tag(const Tag tag); 00155 00157 Tag globalId_tag() const; 00158 ErrorCode globalId_tag(const Tag tag); 00159 00161 EntityHandle get_dual_hyperplane(const EntityHandle ncell); 00162 00164 bool is_blind(const EntityHandle chord); 00165 00167 ErrorCode set_dual_surface_or_curve(EntityHandle entity, 00168 const EntityHandle dual_hyperplane, 00169 const int dimension); 00170 00172 ErrorCode atomic_pillow(EntityHandle odedge, EntityHandle &quad1, 00173 EntityHandle &quad2); 00174 00176 ErrorCode rev_atomic_pillow(EntityHandle pillow, Range &chords); 00177 00179 ErrorCode face_shrink(EntityHandle odedge); 00180 00182 ErrorCode rev_face_shrink(EntityHandle edge); 00183 00185 ErrorCode face_open_collapse(EntityHandle ocl, EntityHandle ocr); 00186 00189 ErrorCode foc_get_ents(EntityHandle ocl, 00190 EntityHandle ocr, 00191 EntityHandle *quads, 00192 EntityHandle *split_edges, 00193 EntityHandle *split_nodes, 00194 Range &hexes, 00195 EntityHandle *other_edges, 00196 EntityHandle *other_nodes); 00197 00200 ErrorCode get_opposite_verts(const EntityHandle middle_edge, 00201 const EntityHandle chord, 00202 EntityHandle *verts); 00203 00207 ErrorCode get_dual_entities(const EntityHandle dual_ent, 00208 Range *dcells, 00209 Range *dedges, 00210 Range *dverts, 00211 Range *dverts_loop, 00212 Range *dedges_loop); 00213 00214 ErrorCode list_entities(const Range &entities) const; 00215 ErrorCode list_entities(const EntityHandle *entities, 00216 const int num_entities) const; 00217 00219 ErrorCode delete_whole_dual(); 00220 00222 ErrorCode check_dual_adjs(); 00223 00224 private: 00225 00227 ErrorCode construct_dual_vertices(const Range &all_regions, 00228 Range &new_dual_ents); 00229 00231 ErrorCode construct_dual_edges(const Range &all_faces, 00232 Range &new_dual_ents); 00233 00235 ErrorCode construct_dual_faces(const Range &all_edges, 00236 Range &new_dual_ents); 00237 00239 ErrorCode construct_dual_cells(const Range &all_verts, 00240 Range &new_dual_ents); 00241 00244 ErrorCode construct_dual_hyperplanes(const int dim, 00245 EntityHandle *entities, 00246 const int num_entities); 00247 00249 ErrorCode order_chord(EntityHandle chord_set); 00250 00253 ErrorCode construct_new_hyperplane(const int dim, EntityHandle &new_hyperplane, 00254 int &id); 00255 00260 ErrorCode traverse_hyperplane(const Tag hp_tag, 00261 EntityHandle &this_hp, 00262 EntityHandle this_ent); 00263 00265 ErrorCode construct_hp_parent_child(); 00266 00269 ErrorCode get_radial_dverts(const EntityHandle edge, 00270 std::vector<EntityHandle> &rad_verts, 00271 bool &bdy_edge); 00272 00273 ErrorCode construct_dual_vertex(EntityHandle entity, 00274 EntityHandle &dual_ent, 00275 const bool extra = false, 00276 const bool add_graphics_pt = true); 00277 00279 ErrorCode add_graphics_point(EntityHandle entity, 00280 double *avg_pos = NULL); 00281 00283 ErrorCode get_cell_points(EntityHandle dual_ent, 00284 std::vector<int> &npts, 00285 std::vector<GraphicsPoint> &points); 00286 00289 bool check_1d_loop_edge(EntityHandle this_ent); 00290 00293 ErrorCode check_dual_equiv_edges(Range &dual_edges); 00294 00296 ErrorCode delete_dual_entities(EntityHandle *entities, const int num_entities); 00297 00299 ErrorCode delete_dual_entities(Range &entities); 00300 00302 ErrorCode fs_check_quad_sense(EntityHandle hex0, 00303 EntityHandle quad0, 00304 std::vector<EntityHandle> *connects); 00305 00308 ErrorCode fs_get_quads(EntityHandle odedge, 00309 EntityHandle *quads, 00310 EntityHandle *hexes, 00311 std::vector<EntityHandle> *connects); 00312 00314 ErrorCode fs_get_quad_loops(EntityHandle *hexes, 00315 std::vector<EntityHandle> *connects, 00316 std::vector<EntityHandle> *side_quads); 00317 00321 ErrorCode fsr_get_fourth_quad(std::vector<EntityHandle> *connects, 00322 std::vector<EntityHandle> *side_quads); 00323 00324 /* 00326 ErrorCode foc_get_merge_ents(EntityHandle *quads, EntityHandle *new_quads, 00327 Range &edge, Range &new_edge, 00328 std::vector<EntityHandle> &merge_ents); 00329 */ 00330 00333 ErrorCode foc_delete_dual(EntityHandle *split_quads, 00334 EntityHandle *split_edges, 00335 Range &hexes); 00336 00338 ErrorCode split_pair_nonmanifold(EntityHandle *split_quads, 00339 EntityHandle *split_edges, 00340 EntityHandle *split_nodes, 00341 std::vector<EntityHandle> *star_dp1, 00342 std::vector<EntityHandle> *star_dp2, 00343 EntityHandle *other_edges, 00344 EntityHandle *other_nodes, 00345 EntityHandle *new_quads, 00346 EntityHandle *new_edges, 00347 EntityHandle *new_nodes); 00348 00351 ErrorCode foc_get_addl_ents(std::vector<EntityHandle> *star_dp1, 00352 std::vector<EntityHandle> *star_dp2, 00353 EntityHandle *split_edges, 00354 EntityHandle split_node, 00355 Range *addl_ents); 00356 00360 ErrorCode foc_get_stars(EntityHandle *split_quads, 00361 EntityHandle *split_edges, 00362 std::vector<EntityHandle> *star_dp1, 00363 std::vector<EntityHandle> *star_dp2); 00364 00365 void print_cell(EntityHandle cell); 00366 00368 Interface *mbImpl; 00369 00371 enum 00372 { 00373 GP_SIZE=20 00374 }; 00375 00377 Tag dualCurveTag; 00378 Tag dualSurfaceTag; 00379 Tag isDualCellTag; 00380 Tag dualEntityTag; 00381 Tag extraDualEntityTag; 00382 Tag dualGraphicsPointTag; 00383 Tag categoryTag; 00384 Tag globalIdTag; 00385 00386 int maxHexId; 00387 }; 00388 00389 inline Tag DualTool::dualSurface_tag() const 00390 { 00391 return dualSurfaceTag; 00392 } 00393 00394 inline Tag DualTool::dualCurve_tag() const 00395 { 00396 return dualCurveTag; 00397 } 00398 00399 inline Tag DualTool::isDualCell_tag() const 00400 { 00401 return isDualCellTag; 00402 } 00403 00404 inline Tag DualTool::dualEntity_tag() const 00405 { 00406 return dualEntityTag; 00407 } 00408 00409 inline Tag DualTool::extraDualEntity_tag() const 00410 { 00411 return extraDualEntityTag; 00412 } 00413 00414 inline Tag DualTool::dualGraphicsPoint_tag() const 00415 { 00416 return dualGraphicsPointTag; 00417 } 00418 00419 inline Tag DualTool::globalId_tag() const 00420 { 00421 return globalIdTag; 00422 } 00423 00425 inline ErrorCode DualTool::dualSurface_tag(const Tag tag) 00426 { 00427 ErrorCode result = MB_FAILURE; 00428 if ((0 == dualSurfaceTag && tag) || dualSurfaceTag != tag) { 00429 dualSurfaceTag = tag; 00430 result = MB_SUCCESS; 00431 } 00432 00433 return result; 00434 } 00435 00437 inline ErrorCode DualTool::dualCurve_tag(const Tag tag) 00438 { 00439 ErrorCode result = MB_FAILURE; 00440 if ((0 == dualCurveTag && tag) || dualCurveTag != tag) { 00441 dualCurveTag = tag; 00442 result = MB_SUCCESS; 00443 } 00444 00445 return result; 00446 } 00447 00449 inline ErrorCode DualTool::isDualCell_tag(const Tag tag) 00450 { 00451 ErrorCode result = MB_FAILURE; 00452 if ((0 == isDualCellTag && tag) || isDualCellTag != tag) { 00453 isDualCellTag = tag; 00454 result = MB_SUCCESS; 00455 } 00456 00457 return result; 00458 } 00459 00461 inline ErrorCode DualTool::dualEntity_tag(const Tag tag) 00462 { 00463 ErrorCode result = MB_FAILURE; 00464 if ((0 == dualEntityTag && tag) || dualEntityTag != tag) { 00465 dualEntityTag = tag; 00466 result = MB_SUCCESS; 00467 } 00468 00469 return result; 00470 } 00471 00473 inline ErrorCode DualTool::extraDualEntity_tag(const Tag tag) 00474 { 00475 ErrorCode result = MB_FAILURE; 00476 if ((0 == extraDualEntityTag && tag) || extraDualEntityTag != tag) { 00477 extraDualEntityTag = tag; 00478 result = MB_SUCCESS; 00479 } 00480 00481 return result; 00482 } 00483 00485 inline ErrorCode DualTool::dualGraphicsPoint_tag(const Tag tag) 00486 { 00487 ErrorCode result = MB_FAILURE; 00488 if ((0 == dualGraphicsPointTag && tag) || dualGraphicsPointTag != tag) { 00489 dualGraphicsPointTag = tag; 00490 result = MB_SUCCESS; 00491 } 00492 00493 return result; 00494 } 00495 00497 inline ErrorCode DualTool::globalId_tag(const Tag tag) 00498 { 00499 ErrorCode result = MB_FAILURE; 00500 if ((0 == globalIdTag && tag) || globalIdTag != tag) { 00501 globalIdTag = tag; 00502 result = MB_SUCCESS; 00503 } 00504 00505 return result; 00506 } 00507 00508 } // namespace moab 00509 00510 #endif 00511