DualGraph.h
Go to the documentation of this file.
1 /*
2 * ==========================================================================
3 * This file is part of the implementation of
4 *
5 * <FrameFab: Robotic Fabrication of Frame Shapes>
6 * Yijiang Huang, Juyong Zhang, Xin Hu, Guoxian Song, Zhongyuan Liu, Lei Yu, Ligang Liu
7 * In ACM Transactions on Graphics (Proc. SIGGRAPH Asia 2016)
8 ----------------------------------------------------------------------------
9 * class: DualGraph
10 *
11 * Description: dual graph is the basic data structure used to perform ADMMCut Algorthim
12 *
13 * Version: 2.0
14 * Created: Oct/10/2015
15 *
16 * Author: Xin Hu, Yijiang Huang, Guoxian Song
17 * Company: GCL@USTC
18 ----------------------------------------------------------------------------
19 * Copyright (C) 2016 Yijiang Huang, Xin Hu, Guoxian Song, Juyong Zhang
20 * and Ligang Liu.
21 *
22 * FrameFab is free software: you can redistribute it and/or modify
23 * it under the terms of the GNU General Public License as published by
24 * the Free Software Foundation, either version 3 of the License, or
25 * (at your option) any later version.
26 *
27 * FrameFab is distributed in the hope that it will be useful,
28 * but WITHOUT ANY WARRANTY; without even the implied warranty of
29 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
30 * GNU General Public License for more details.
31 *
32 * You should have received a copy of the GNU General Public License
33 * along with FrameFab. If not, see <http://www.gnu.org/licenses/>.
34 * ==========================================================================
35 */
36 
37 #pragma once
38 #include <iostream>
39 #include <Eigen/Core>
40 
42 
43 using namespace std;
44 using namespace Eigen;
45 
46 
48 {
49 public:
50  DualVertex(){ orig_id_ = -1; dual_id_ = -1; }
52 
53 public:
54  void SetOrigId(int orig_id) { orig_id_ = orig_id; }
55  void SetDualId(int dual_id) { dual_id_ = dual_id; }
56  void SetHeight(double height){ height_ = height; }
57 
58  int orig_id() const { return orig_id_; }
59  int dual_id() const { return dual_id_; }
60  double Height() const { return height_; }
61 
62 private:
63  int orig_id_; // indexed by dual edge id
64  int dual_id_; // indexed by original edge id
65  double height_; // z of central points on this original edge
66  // indexed by dual id
67 };
68 
69 
70 class DualEdge
71 {
72 public:
74  DualEdge(int u, int v, double w, WF_vert* vert)
75  {
76  u_ = u;
77  v_ = v;
78  w_ = w;
79  pvert_ = vert;
80  }
82 
83 public:
84  int u() const { return u_; }
85  int v() const { return v_; }
86  double w() const { return w_; }
87  WF_vert* CentralVert() const { return pvert_; }
88 
89 private:
90  int u_;
91  int v_;
92  double w_;
94 };
95 
96 
97 class DualFace
98 {
99 public:
100  DualFace(){ orig_id_ = -1; dual_id_ = -1; }
102 
103 public:
104  void SetOrigId(int orig_id) { orig_id_ = orig_id; }
105  void SetDualId(int dual_id) { dual_id_ = dual_id; }
106 
107  int orig_id() const { return orig_id_; }
108  int dual_id() const { return dual_id_; }
109 
110 private:
111  int orig_id_; // indexed by dual vertex id
112  int dual_id_; // indexed by original vertex id
113 };
114 
115 
117 {
118 public:
119  DualGraph();
120  DualGraph(WireFrame *ptr_frame);
121  ~DualGraph();
122 
123 public:
124  void Init();
125  void Clear();
126 
127  void Dualization(); // dualization on the whole frame
128 
129  void UpdateDualization(VectorXd *ptr_x); // update from graphcut
130  void Establish();
131 
132  int UpdateDualization(WF_edge *e); // insert a trail edge ei from frame
133  int RemoveUpdation(WF_edge *e); // remove the trail edge
134 
135  void InsertVertex(WF_edge *e);
136  void InsertEdge(WF_edge *e1, WF_edge *e2, double w, WF_vert *vert);
137  int InsertFace(WF_vert *p); // insert a dual face at the end of free face
138  void DeleteVertex(WF_edge *e);
139  int DeleteFace(WF_vert *p); // delete a dual face by moving
140 
141  vector<DualVertex*> *GetVertList() { return vert_list_; }
142  vector<DualEdge*> *GetEdgeList() { return edge_list_; }
143  vector<DualFace*> *GetFaceList() { return face_list_; }
144 
145  int SizeOfVertList() { return Nd_; }
146  int SizeOfEdgeList() { return Md_; }
147  int SizeOfFaceList() { return Fd_; }
148  int SizeOfFreeFace() { return Fd_free_; }
149 
150  int u(int ei) { return (*edge_list_)[ei]->u(); }
151  int v(int ei) { return (*edge_list_)[ei]->v(); }
152  int e_orig_id(int u) { return (*vert_list_)[u]->orig_id(); }
153  int e_dual_id(int u) { return (*vert_list_)[u]->dual_id(); }
154  int v_orig_id(int i) { return (*face_list_)[i]->orig_id(); }
155  int v_dual_id(int i) { return (*face_list_)[i]->dual_id(); }
156 
157  double Weight(int ei) { return (*edge_list_)[ei]->w(); }
158  WF_vert*CentralVert(int ei) { return (*edge_list_)[ei]->CentralVert(); }
159  double Height(int ei) { return (*vert_list_)[ei]->Height(); }
160  double maxZ() { return maxz_; }
161  double minZ() { return minz_; }
162 
163  bool isExistingVert(int u) { return (exist_vert_[u] > 0); }
164  int getExistingVertValence(int u) { return exist_vert_[u]; }
165  bool isExistingEdge(WF_edge *e) { return exist_edge_[e->ID()]; }
166 
167  bool isAdjacent(int i, int j)
168  {
169  WF_edge *e1 = ptr_frame_->GetEdge(e_orig_id(i));
170  WF_edge *e2 = ptr_frame_->GetEdge(e_orig_id(j));
171  int u1 = e1->ppair_->pvert_->ID();
172  int v1 = e1->pvert_->ID();
173  int u2 = e2->ppair_->pvert_->ID();
174  int v2 = e2->pvert_->ID();
175 
176  if (u1 == u2 || u1 == v2 || v1 == u2 || v1 == v2)
177  {
178  return true;
179  }
180  else
181  {
182  return false;
183  }
184  }
185 
186  void Debug();
187 
188 public:
190 
191 private:
192  vector<DualEdge*> *edge_list_; // dual edge: original edge -> original edge
193  vector<DualVertex*> *vert_list_; // dual vert: original edge
194  vector<DualFace*> *face_list_; // dual face: original vert
195 
196  vector<int> exist_vert_; // indexed by original id
197  vector<bool> exist_edge_; // indexed by original id
198 
199  vector<vector<bool>> is_adjacent_;
200 
201  int Nd_;
202  int Md_;
203  int Fd_;
204  int Fd_free_;
205 
206  double maxz_;
207  double minz_;
208 };
GLfixed GLfixed u2
void SetOrigId(int orig_id)
Definition: DualGraph.h:54
int orig_id_
Definition: DualGraph.h:111
WF_vert * CentralVert() const
Definition: DualGraph.h:87
vector< DualFace * > * GetFaceList()
Definition: DualGraph.h:143
int orig_id() const
Definition: DualGraph.h:58
double height_
Definition: DualGraph.h:65
double Height() const
Definition: DualGraph.h:60
int v_orig_id(int i)
Definition: DualGraph.h:154
GLfixed u1
double w() const
Definition: DualGraph.h:86
double maxZ()
Definition: DualGraph.h:160
double minz_
Definition: DualGraph.h:207
~DualFace()
Definition: DualGraph.h:101
int v(int ei)
Definition: DualGraph.h:151
int u() const
Definition: DualGraph.h:84
GLfloat GLfloat v1
double w_
Definition: DualGraph.h:92
int u(int ei)
Definition: DualGraph.h:150
int orig_id() const
Definition: DualGraph.h:107
WF_vert * pvert_
Definition: DualGraph.h:93
vector< DualFace * > * face_list_
Definition: DualGraph.h:194
int SizeOfFaceList()
Definition: DualGraph.h:147
bool isExistingVert(int u)
Definition: DualGraph.h:163
int orig_id_
Definition: DualGraph.h:63
vector< DualVertex * > * GetVertList()
Definition: DualGraph.h:141
int v() const
Definition: DualGraph.h:85
DualFace()
Definition: DualGraph.h:100
GLubyte GLubyte GLubyte GLubyte w
double Height(int ei)
Definition: DualGraph.h:159
int getExistingVertValence(int u)
Definition: DualGraph.h:164
void SetHeight(double height)
Definition: DualGraph.h:56
int e_orig_id(int u)
Definition: DualGraph.h:152
double minZ()
Definition: DualGraph.h:161
int ID() const
Definition: WireFrame.h:123
int dual_id() const
Definition: DualGraph.h:108
void SetOrigId(int orig_id)
Definition: DualGraph.h:104
WF_edge * ppair_
Definition: WireFrame.h:166
Debug
int SizeOfEdgeList()
Definition: DualGraph.h:146
bool isAdjacent(int i, int j)
Definition: DualGraph.h:167
WF_vert * CentralVert(int ei)
Definition: DualGraph.h:158
vector< DualEdge * > * edge_list_
Definition: DualGraph.h:192
~DualEdge()
Definition: DualGraph.h:81
int SizeOfFreeFace()
Definition: DualGraph.h:148
int dual_id() const
Definition: DualGraph.h:59
int u_
Definition: DualGraph.h:90
double maxz_
Definition: DualGraph.h:206
vector< vector< bool > > is_adjacent_
Definition: DualGraph.h:199
double Weight(int ei)
Definition: DualGraph.h:157
GLint GLsizei GLsizei height
vector< bool > exist_edge_
Definition: DualGraph.h:197
void SetDualId(int dual_id)
Definition: DualGraph.h:105
vector< DualVertex * > * vert_list_
Definition: DualGraph.h:193
int e_dual_id(int u)
Definition: DualGraph.h:153
int Fd_free_
Definition: DualGraph.h:204
WireFrame * ptr_frame_
Definition: DualGraph.h:189
int ID() const
Definition: WireFrame.h:80
vector< int > exist_vert_
Definition: DualGraph.h:196
bool isExistingEdge(WF_edge *e)
Definition: DualGraph.h:165
const GLdouble * v
WF_vert * pvert_
Definition: WireFrame.h:164
GLfloat GLfloat GLfloat v2
DualEdge(int u, int v, double w, WF_vert *vert)
Definition: DualGraph.h:74
int dual_id_
Definition: DualGraph.h:64
int v_dual_id(int i)
Definition: DualGraph.h:155
~DualVertex()
Definition: DualGraph.h:51
int SizeOfVertList()
Definition: DualGraph.h:145
void SetDualId(int dual_id)
Definition: DualGraph.h:55
DualVertex()
Definition: DualGraph.h:50
GLfloat GLfloat p
int v_
Definition: DualGraph.h:91
int dual_id_
Definition: DualGraph.h:112
DualEdge()
Definition: DualGraph.h:73
vector< DualEdge * > * GetEdgeList()
Definition: DualGraph.h:142


choreo_task_sequence_planner
Author(s): Yijiang Huang
autogenerated on Thu Jul 18 2019 04:03:14