QuadricCollision.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: QuadricCollision
10 *
11 * Description:
12 *
13 * Version: 2.0
14 * Created: Oct/20/2015
15 * Updated: Aug/24/2016
16 *
17 * Author: Xin Hu, Yijiang Huang, Guoxian Song
18 * Company: GCL@USTC
19 * Citation: This file use some geometric API and objects from
20 * Title: Geometric Tools Engine
21 * a library of source code for computing in the fields of
22 * mathematics, graphics, image analysis, and physics.
23 * Code Version: 3.2.6
24 * Availability: http://www.geometrictools.com/index.html
25 ----------------------------------------------------------------------------
26 * Copyright (C) 2016 Yijiang Huang, Xin Hu, Guoxian Song, Juyong Zhang
27 * and Ligang Liu.
28 *
29 * FrameFab is free software: you can redistribute it and/or modify
30 * it under the terms of the GNU General Public License as published by
31 * the Free Software Foundation, either version 3 of the License, or
32 * (at your option) any later version.
33 *
34 * FrameFab is distributed in the hope that it will be useful,
35 * but WITHOUT ANY WARRANTY; without even the implied warranty of
36 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
37 * GNU General Public License for more details.
38 *
39 * You should have received a copy of the GNU General Public License
40 * along with FrameFab. If not, see <http://www.gnu.org/licenses/>.
41 * ==========================================================================
42 */
43 
44 #ifndef FRAMEFAB_TASK_SEQUENCE_PLANNER_QUADCOLLISION_H
45 #define FRAMEFAB_TASK_SEQUENCE_PLANNER_QUADCOLLISION_H
46 
52 
53 // geometric tools engine
54 #include <GTEnginePCH.h>
60 
61 #define STRICT_COLLISION
62 
63 // used to express feasible end effector directions
64 typedef unsigned long long lld;
65 
66 using namespace Geometry;
67 using namespace std;
68 
69 // theta=(0,180), phi=(0,360)
70 // target means unprinted edge under current consideration, order edge means existing edge
71 
73 {
74  public:
76  QuadricCollision(WireFrame *ptr_frame);
78 
79  public:
80  void Init(vector <lld> &colli_map);
81  bool DetectCollision(WF_edge* target_e, DualGraph* ptr_subgraph, std::vector<lld>& result_map);
82  bool DetectCollision(WF_edge* target_e, WF_edge* order_e, std::vector<lld>& colli_map);
83  void DetectCollision(WF_edge* target_e, std::vector<WF_edge*> exist_edge, std::vector<GeoV3>& output);
84 
85  public:
86  void ModifyAngle(std::vector<lld>& angle_state, const std::vector<lld>& colli_map);
87 
88  int ColFreeAngle(const std::vector<lld>& colli_map);
89 
90  std::vector<Eigen::Vector3d> ConvertCollisionMapToEigenDirections(const std::vector<lld>& colli_map);
91  std::vector<int> ConvertCollisionMapToIntMap(const std::vector<lld>& colli_map);
92 
93  inline int Divide()
94  {
95  return 18 * 10 + 2;
96  }
97 
98  private:
99  // convert to eef direction 3d vector
100  inline GeoV3 Orientation(double theta, double phi)
101  {
102  return GeoV3(sin(theta) * cos(phi), sin(theta) * sin(phi), cos(theta));
103  }
104 
105  inline Eigen::Vector3d ConvertAngleToEigenDirection(double theta, double phi)
106  {
107  return Eigen::Vector3d(sin(theta) * cos(phi), sin(theta) * sin(phi), cos(theta));
108  }
109 
110  private:
111  bool DetectBulk(WF_edge *order_e, double theta, double phi);
112  bool DetectEdge(WF_edge *order_e, vector <lld> &colli_map);
113  bool DetectEdges(std::vector<WF_edge*> exist_edge, double theta, double phi);
114  bool DetectAngle(GeoV3 connect, GeoV3 end, GeoV3 target_end, GeoV3 normal);
115 
116  bool Case(GeoV3 target_start, GeoV3 target_end,
117  GeoV3 order_start, GeoV3 order_end, GeoV3 normal);
118  bool SpecialCase(GeoV3 connect, GeoV3 target_s, GeoV3 order_s, GeoV3 normal);
119  bool ParallelCase(GeoV3 target_start, GeoV3 target_end,
120  GeoV3 order_start, GeoV3 order_end, GeoV3 normal);
121 
122  bool DetectCone(GeoV3 start, GeoV3 normal, GeoV3 target_start, GeoV3 target_end);
123  bool DetectCylinder(GeoV3 start, GeoV3 normal, GeoV3 target_start, GeoV3 target_end);
124  bool DetectTriangle(Triangle triangle, GeoV3 target_start, GeoV3 target_end);
125  bool DetectTopCylinder(GeoV3 start, GeoV3 normal, GeoV3 target_start, GeoV3 target_end);
126 
127  void GenerateVolume(GeoV3 start, GeoV3 end, GeoV3 target_start, GeoV3 target_end, GeoV3 normal);
128  void GenerateVolume(GeoV3 connect, GeoV3 target_s, GeoV3 order_s, GeoV3 normal);
129 
130  bool Parallel(GeoV3 a, GeoV3 b);
131  double Distance(WF_edge *order_e);
132 
133  gte::Segment<3, float> Seg(point target_start, point target_end);
134  gte::Segment<3, float> Seg(GeoV3 target_start, GeoV3 target_end);
136 
137  public:
140 
141  private:
143  std::vector<Triangle> bulk_;
144  int divide_;
145 
146  // compact representation of end effector's feasible direction
147  // each lld is a bit-wise map, value 1 means it causes collision
148  std::vector<std::vector<lld>*> colli_map_;
149 };
150 
151 #endif
WireFrame * ptr_frame_
Eigen::Vector3d ConvertAngleToEigenDirection(double theta, double phi)
GLuint start
GeoV3 Orientation(double theta, double phi)
std::vector< Triangle > bulk_
GLboolean GLboolean GLboolean GLboolean a
const GLubyte * c
GLuint GLuint end
unsigned long long lld
std::vector< std::vector< lld > * > colli_map_
GLboolean GLboolean GLboolean b
ExtruderCone extruder_
Geometry::Vector3d GeoV3
Definition: Polyface.h:51


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