moab
|
00001 #ifndef DRAWDUAL_HPP 00002 #define DRAWDUAL_HPP 00003 00004 class Agnode_t; 00005 class Agedge_t; 00006 class Agraph_t; 00007 00008 class SheetDiagramPopup; 00009 00010 #include "moab/Interface.hpp" 00011 #include "moab/Range.hpp" 00012 #include <map> 00013 #include <vector> 00014 00015 class vtkPolyData; 00016 class vtkRenderer; 00017 class vtkCellPicker; 00018 class vtkUnstructuredGrid; 00019 class vtkExtractCells; 00020 class vtkObject; 00021 class vtkFloatArray; 00022 class vtkCellArray; 00023 class vtkActor; 00024 class Agsym_t; 00025 class QLineEdit; 00026 00027 using namespace moab; 00028 00029 class DrawDual 00030 { 00031 public: 00032 DrawDual(QLineEdit *pickline1, QLineEdit *pickline2); 00033 ~DrawDual(); 00034 00035 bool draw_dual_surfs(Range &dual_surfs, 00036 const bool use_offsets = false); 00037 bool print_dual_surfs(Range &dual_surfs, 00038 const bool use_offsets = false); 00039 bool draw_dual_surfs(std::vector<EntityHandle> &dual_surfs, 00040 const bool use_offsets = false); 00041 ErrorCode draw_dual_surf(EntityHandle dual_surf, 00042 int offset_num = 0); 00043 00044 EntityHandle lastPickedEnt; // last picked entity 00045 EntityHandle secondLastPickedEnt; // second last picked entity 00046 00048 ErrorCode reset_drawing_data(EntityHandle dual_surf); 00049 00050 ErrorCode reset_drawn_sheets(Range *drawn_sheets = NULL); 00051 00052 void print_picked_ents(Range &picked_ents, 00053 bool from_return = false); 00054 00055 private: 00056 00057 static DrawDual *gDrawDual; 00058 QLineEdit *pickLine1, *pickLine2; 00059 00060 static bool useGraphviz; 00061 00062 class GVEntity 00063 { 00064 public: 00065 int numGvizEntities; 00066 EntityHandle dualSurfs[3]; 00067 EntityHandle moabEntity; 00068 int pointPos[3][2]; 00069 int vtkEntityIds[4]; // extra pt for edge mid-pts 00070 vtkActor *myActors[3]; 00071 void *gvizPoints[5]; // extra 2 for edge mid-pts 00072 void *gvizEdges[4]; // extra 2 for extra edges 00073 00074 GVEntity() 00075 { 00076 numGvizEntities = 0; 00077 dualSurfs[0] = dualSurfs[1] = dualSurfs[2] = 0; 00078 moabEntity = 0; 00079 pointPos[0][0] = pointPos[0][1] = pointPos[0][2] = 00080 pointPos[1][0] = pointPos[1][1] = pointPos[1][2] = 0; 00081 vtkEntityIds[0] = vtkEntityIds[1] = vtkEntityIds[2] = vtkEntityIds[3] = -1; 00082 myActors[0] = myActors[1] = myActors[2] = NULL; 00083 gvizPoints[0] = gvizPoints[1] = gvizPoints[2] = gvizPoints[3] = 00084 gvizPoints[4] = NULL; 00085 gvizEdges[0] = gvizEdges[1] = gvizEdges[2] = gvizEdges[3] = NULL; 00086 } 00087 void reset(const int index); 00088 int get_index(const EntityHandle dual_surf) 00089 { 00090 if (dual_surf == dualSurfs[0]) return 0; 00091 else if (dual_surf == dualSurfs[1]) return 1; 00092 else if (dual_surf == dualSurfs[2]) return 2; 00093 else if (dualSurfs[0] == 0) return -1; 00094 else if (dualSurfs[1] == 0) return -2; 00095 else if (dualSurfs[2] == 0) return -3; 00096 else return -10; 00097 } 00098 }; 00099 00100 class GraphWindows 00101 { 00102 public: 00103 Agraph_t *gvizGraph; 00104 SheetDiagramPopup *sheetDiagram; 00105 vtkActor *pickActor; 00106 00107 GraphWindows() : gvizGraph(NULL), sheetDiagram(NULL), pickActor(NULL) {} 00108 ErrorCode reset(EntityHandle dual_surf); 00109 }; 00110 00112 ErrorCode construct_graphviz_data(EntityHandle dual_surf, 00113 Range &dcells, Range &dedges, 00114 Range &dverts, Range &face_verts, 00115 Range &loop_edges); 00116 00118 ErrorCode compute_fixed_points(EntityHandle dual_surf, Range &dverts, 00119 Range &face_verts, Range &loop_edges); 00120 00122 ErrorCode compute_pillow_fixed_points(EntityHandle dual_surf, 00123 Range &face_verts, 00124 Range &face_edges); 00125 00127 void get_loop_vertex_pos(unsigned int vert_num, 00128 unsigned int loop_num, 00129 unsigned int num_loops, 00130 double angle, int &xpos_pts, int &ypos_pts); 00131 00133 ErrorCode make_vtk_data(EntityHandle dual_surf, 00134 vtkPolyData *pd, 00135 vtkRenderer *this_ren); 00136 00138 ErrorCode make_vtk_cells(const Range &cell_range, const int dim, 00139 const float color_index, 00140 const EntityHandle dual_surf, 00141 std::map<EntityHandle, GVEntity *> &vert_gv_map, 00142 vtkPolyData *pd, 00143 vtkFloatArray *color_ids); 00144 00146 vtkPolyData *get_polydata(SheetDiagramPopup *this_sdpopup); 00147 00149 void get_clean_pd(EntityHandle dual_surf, 00150 SheetDiagramPopup *&this_sdpopup, vtkPolyData *&pd); 00151 00153 ErrorCode draw_labels(EntityHandle dual_surf, 00154 vtkPolyData *pd, 00155 vtkPolyData *new_pd); 00156 00157 ErrorCode label_other_sheets(EntityHandle dual_surf, 00158 vtkPolyData *pd, 00159 vtkPolyData *&new_pd); 00160 00161 void label_interior_verts(EntityHandle dual_surf, 00162 vtkPolyData *pd, 00163 vtkRenderer *ren); 00164 00165 EntityHandle other_sheet(const EntityHandle this_chord, 00166 const EntityHandle dual_surf); 00167 00168 ErrorCode get_primal_ids(const Range &ents, std::vector<int> &ids); 00169 00170 ErrorCode allocate_points(EntityHandle dual_surf, 00171 vtkPolyData *pd, 00172 Range &verts, 00173 Range &loop_edges, 00174 std::map<EntityHandle, GVEntity*> &vert_gv_map); 00175 00176 static void add_picker(vtkRenderer *this_ren); 00177 00178 static void process_events(vtkObject *caller, 00179 unsigned long event, 00180 void* clientdata, 00181 void* /*vtkNotUsed(calldata)*/); 00182 00183 static void process_pick(vtkRenderer *ren); 00184 00187 ErrorCode process_pick(EntityHandle dual_surf, 00188 const double x, const double y, 00189 Range &picked_ents); 00190 00192 std::map<EntityHandle, GraphWindows> surfDrawrings; 00193 00194 00196 Tag gvEntityHandle, dualEntityTagHandle; 00197 00198 static Tag dualSurfaceTagHandle, dualCurveTagHandle; 00199 00201 void *gvizGvc; 00202 00204 int xSize, ySize, xOrigin, yOrigin; 00205 00207 static vtkCellPicker *dualPicker; 00208 00210 static Range pickRange; 00211 00212 EntityHandle get_picked_cell(EntityHandle cell_set, 00213 const int dim, 00214 const int picked_cell); 00215 00216 void update_high_polydatas(); 00217 00218 ErrorCode get_xform(EntityHandle dual_surf, Agsym_t *asym_pos, 00219 double &x_xform, double &y_xform); 00220 00221 ErrorCode construct_graphviz_points(EntityHandle dual_surf, 00222 Range &dverts, 00223 Agsym_t *asym_pos); 00224 00225 ErrorCode construct_graphviz_edges(EntityHandle dual_surf, 00226 Range &dedges, 00227 Range &loop_verts, 00228 Agsym_t *asym_pos); 00229 00230 Agsym_t *get_asym(EntityHandle dual_surf, const int dim, 00231 const char *name, const char *def_val = NULL); 00232 00233 ErrorCode fixup_degen_bchords(EntityHandle dual_surf); 00234 00236 void get_points(const EntityHandle *ents, const int num_ents, 00237 const bool extra, 00238 EntityHandle dual_surf, Agnode_t **points); 00239 00241 ErrorCode smooth_dual_surf(EntityHandle dual_surf, 00242 Range &dcells, Range &dedges, 00243 Range &dverts, Range &face_verts, 00244 Range &loop_edges); 00245 00246 ErrorCode set_graphpoint_pos(void *point, double *pos); 00247 00248 ErrorCode get_graphpoint_pos(void *point, double *pos); 00249 00250 void get_graph_points(const EntityHandle *ents, const int gnum_ents, 00251 EntityHandle dual_surf, void **points); 00252 00253 void get_graph_points(Range ents, 00254 EntityHandle dual_surf, void **points); 00255 00257 EntityHandle get_dual_surf(vtkRenderer *this_ren); 00258 }; 00259 00260 00261 #endif