Rocstar  1.0
Rocstar multiphysics simulation application
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Feature-Detection Primitives

Functions

float comp_angle_defect (Vertex *v)
 Compute the angle defect of a vertex. More...
 
float cos_face_angle (Halfedge *h, Halfedge *hopp)
 Compute the cosine of the face angle (dihedral angle) at an edge. More...
 
float cos_edge_angle (const Halfedge *h1, const Halfedge *h2)
 Compute the cosine of the edge angle at a vertex between two incident feature edges. More...
 
float cos_edge_angle (const Feature_1 &f1, Feature_1::const_iterator it, bool isloop)
 Compute the cosine of the edge angle at a vertex in a given feature curve. More...
 
bool is_strong_ad (Vertex *v)
 Determine whether a vertex is strong (either theta-strong or relatively strong) in angle defect. More...
 
bool is_rstrong_ea (const Feature_1 &f1, Feature_1::const_iterator hprev, Feature_1::const_iterator hnext, float cos_ea, bool isloop)
 Determine whether a vertex is relatively strong in edge angle within a give feature. More...
 
template<class T >
squares (const T &t)
 
void init_feature_parameters ()
 Read in the control file for feature detection. More...
 

Detailed Description

Function Documentation

float comp_angle_defect ( Vertex v)
protected

Compute the angle defect of a vertex.

The angle defect at v is defined as:

  1. the difference between 2*pi and the sum of its angles in incident faces if v is not a border vertex;
  2. the difference between pi and the sum of its angles in incident faces if v is a border vertex. When the angle defect was computed for a vertex for the first time, it is saved, and subsequent calls for the same vertex will return saved value.

Definition at line 224 of file RFC_Window_overlay_fea.C.

References NTS::abs(), acc, cimg_library::acos(), d, RFC_Pane_overlay::get_angle_defect(), HDS_accessor< _MP >::get_halfedge(), HDS_accessor< _MP >::get_next(), HDS_accessor< _MP >::get_next_around_destination(), HDS_accessor< _MP >::get_pane(), HUGE_VALF, HDS_accessor< _MP >::is_border(), and pi.

224  {
225  const float pi = 3.1415926535;
226 
227  // Precondition: d was initialized to HUGE_VALF
228  float &t=acc.get_pane(v)->get_angle_defect(v), d=t;
229  if ( d < HUGE_VALF) return d;
230 
231  float angle_sum = 0.;
232 
233  Halfedge *h = acc.get_halfedge( v), *h0=h;
234  bool is_border = false;
235  do {
236  if ( !acc.is_border(h))
237  angle_sum += acos( -cos_edge_angle( h, acc.get_next(h)));
238  else
239  is_border = true;
240  } while ( (h=acc.get_next_around_destination( h)) != h0);
241 
242  return t = abs((2-is_border)*pi - angle_sum);
243 }
Halfedge * get_next(Halfedge *h) const
Definition: HDS_accessor.h:108
float cos_edge_angle(const Halfedge *h1, const Halfedge *h2)
Compute the cosine of the edge angle at a vertex between two incident feature edges.
const NT & d
RFC_Pane_overlay * get_pane(Vertex *v) const
Definition: HDS_accessor.h:128
Halfedge * get_halfedge(Vertex *v) const
Definition: HDS_accessor.h:75
*********************************************************************Illinois Open Source License ****University of Illinois NCSA **Open Source License University of Illinois All rights reserved ****Developed free of to any person **obtaining a copy of this software and associated documentation to deal with the Software without including without limitation the rights to and or **sell copies of the and to permit persons to whom the **Software is furnished to do subject to the following this list of conditions and the following disclaimers ****Redistributions in binary form must reproduce the above **copyright this list of conditions and the following **disclaimers in the documentation and or other materials **provided with the distribution ****Neither the names of the Center for Simulation of Advanced the University of nor the names of its **contributors may be used to endorse or promote products derived **from this Software without specific prior written permission ****THE SOFTWARE IS PROVIDED AS WITHOUT WARRANTY OF ANY **EXPRESS OR INCLUDING BUT NOT LIMITED TO THE WARRANTIES **OF FITNESS FOR A PARTICULAR PURPOSE AND **NONINFRINGEMENT IN NO EVENT SHALL THE CONTRIBUTORS OR **COPYRIGHT HOLDERS BE LIABLE FOR ANY DAMAGES OR OTHER WHETHER IN AN ACTION OF TORT OR **ARISING OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE **USE OR OTHER DEALINGS WITH THE SOFTWARE v
Definition: roccomf90.h:20
static HDS_accessor< Tag_true > acc
const double pi
#define HUGE_VALF
Definition: Rocout_hdf4.C:719
NT abs(const NT &x)
Definition: number_utils.h:130
Halfedge_overlay Halfedge
Halfedge * get_next_around_destination(Halfedge *h) const
Definition: HDS_accessor.h:146
CImg< _cimg_Tfloat > acos(const CImg< T > &instance)
Definition: CImg.h:6051
bool is_border(const Halfedge *h) const
Definition: HDS_accessor.h:153
const float & get_angle_defect(const Vertex *v) const

Here is the call graph for this function:

float cos_edge_angle ( const Halfedge h1,
const Halfedge h2 
)
protected

Compute the cosine of the edge angle at a vertex between two incident feature edges.

Definition at line 163 of file RFC_Window_overlay_fea.C.

References acc, d, HDS_accessor< _MP >::get_destination(), HDS_accessor< _MP >::get_origin(), get_tangent(), max(), min(), and sqrt().

163  {
164  Vector_3 v1 = get_tangent( h1);
165  Vector_3 v2 = get_tangent( h2);
166 
167  float d=std::max( -1., std::min( (v1*v2)/sqrt((v1*v1)*(v2*v2)), 1.));
168  if ( acc.get_destination( h1) == acc.get_destination( h2) ||
169  acc.get_origin( h1) == acc.get_origin( h2))
170  return -d;
171  else
172  return d;
173 }
Vertex * get_origin(Halfedge *h) const
Definition: HDS_accessor.h:87
const NT & d
Vector_n max(const Array_n_const &v1, const Array_n_const &v2)
Definition: Vector_n.h:354
SURF::Vector_3< Real > Vector_3
Definition: rfc_basic.h:42
double sqrt(double d)
Definition: double.h:73
Vector_3 get_tangent(const Halfedge *h)
static HDS_accessor< Tag_true > acc
Vector_n min(const Array_n_const &v1, const Array_n_const &v2)
Definition: Vector_n.h:346
Vertex * get_destination(Halfedge *h) const
Definition: HDS_accessor.h:93

Here is the call graph for this function:

float cos_edge_angle ( const Feature_1 f1,
Feature_1::const_iterator  it,
bool  isloop 
)
protected

Compute the cosine of the edge angle at a vertex in a given feature curve.

It saves the solution by associating it with the vertex. When the routine is invoked on the same vertex next time, it will return the saved value if the vertex is not at the end of the feature curve.

Definition at line 181 of file RFC_Window_overlay_fea.C.

References acc, RFC_Pane_overlay::get_cos_edge_angle(), HDS_accessor< _MP >::get_destination(), HDS_accessor< _MP >::get_origin(), HDS_accessor< _MP >::get_pane(), HUGE_VALF, and v.

182 {
183  Vertex *v;
184  if ( !isloop) {
185  if (it==f1.begin()) {
186  v=acc.get_origin( *it);
188  return -1;
189  }
190  else if ( it==f1.end()) {
191  v=acc.get_destination( f1.back());
193  return -1.;
194  }
195  }
196 
197  if ( it==f1.begin() || it==f1.end()) {
198  v = acc.get_origin(f1.front());
199  float &t = acc.get_pane(v)->get_cos_edge_angle( v);
200  if ( t == HUGE_VALF)
201  t = cos_edge_angle( f1.front(), f1.back());
202  return t;
203  }
204  else {
205  v = acc.get_origin( *it);
206  float &t = acc.get_pane(v)->get_cos_edge_angle( v);
207  if ( t == HUGE_VALF) {
208  Feature_1::const_iterator ip=it; --ip;
209  t = cos_edge_angle( *it, *ip);
210  }
211  return t;
212  }
213 }
Vertex * get_origin(Halfedge *h) const
Definition: HDS_accessor.h:87
float cos_edge_angle(const Halfedge *h1, const Halfedge *h2)
Compute the cosine of the edge angle at a vertex between two incident feature edges.
const float & get_cos_edge_angle(const Vertex *v) const
RFC_Pane_overlay * get_pane(Vertex *v) const
Definition: HDS_accessor.h:128
*********************************************************************Illinois Open Source License ****University of Illinois NCSA **Open Source License University of Illinois All rights reserved ****Developed free of to any person **obtaining a copy of this software and associated documentation to deal with the Software without including without limitation the rights to and or **sell copies of the and to permit persons to whom the **Software is furnished to do subject to the following this list of conditions and the following disclaimers ****Redistributions in binary form must reproduce the above **copyright this list of conditions and the following **disclaimers in the documentation and or other materials **provided with the distribution ****Neither the names of the Center for Simulation of Advanced the University of nor the names of its **contributors may be used to endorse or promote products derived **from this Software without specific prior written permission ****THE SOFTWARE IS PROVIDED AS WITHOUT WARRANTY OF ANY **EXPRESS OR INCLUDING BUT NOT LIMITED TO THE WARRANTIES **OF FITNESS FOR A PARTICULAR PURPOSE AND **NONINFRINGEMENT IN NO EVENT SHALL THE CONTRIBUTORS OR **COPYRIGHT HOLDERS BE LIABLE FOR ANY DAMAGES OR OTHER WHETHER IN AN ACTION OF TORT OR **ARISING OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE **USE OR OTHER DEALINGS WITH THE SOFTWARE v
Definition: roccomf90.h:20
static HDS_accessor< Tag_true > acc
#define HUGE_VALF
Definition: Rocout_hdf4.C:719
Vertex * get_destination(Halfedge *h) const
Definition: HDS_accessor.h:93

Here is the call graph for this function:

float cos_face_angle ( Halfedge h,
Halfedge hopp 
)
protected

Compute the cosine of the face angle (dihedral angle) at an edge.

When the face angle was computed the first time, it is saved and subsequent calls for the same edge will simply return the stored value. The face angle is defined to be pi if the edge is on the border.

Definition at line 139 of file RFC_Window_overlay_fea.C.

References acc, RFC_Pane_overlay::get_cos_face_angle(), Overlay_primitives::get_face_normal(), HDS_accessor< _MP >::get_pane(), HUGE_VALF, HDS_accessor< _MP >::is_border(), min(), p1, and sqrt().

139  {
140  // Precondition: Face angles are initialized to HUGE_VALF.
142  float &t = p1->get_cos_face_angle(h);
143  if ( t<HUGE_VALF) return t;
144 
145  if ( acc.is_border( h) || acc.is_border( hopp) )
146  t = -1;
147  else {
149  Vector_3 v1 = op.get_face_normal( h, Point_2(0.5,0));
150  Vector_3 v2 = op.get_face_normal( hopp, Point_2(0.5,0));
151 
152  t=std::min(v1 * v2 / sqrt( (v1*v1) * (v2*v2)),1.);
153  RFC_Pane_overlay *p2=acc.get_pane(hopp);
154  if ( p1 != p2) p2->get_cos_face_angle( hopp) = t;
155  }
156  return t;
157 }
RFC_Pane_overlay * get_pane(Vertex *v) const
Definition: HDS_accessor.h:128
NT p1
SURF::Vector_3< Real > Vector_3
Definition: rfc_basic.h:42
double sqrt(double d)
Definition: double.h:73
Vector_3 get_face_normal(const Halfedge *b, const Point_2 &nc, int scheme=0) const
const float & get_cos_face_angle(const Halfedge *h) const
static HDS_accessor< Tag_true > acc
Vector_n min(const Array_n_const &v1, const Array_n_const &v2)
Definition: Vector_n.h:346
#define HUGE_VALF
Definition: Rocout_hdf4.C:719
bool is_border(const Halfedge *h) const
Definition: HDS_accessor.h:153
SURF::Vector_2< Real > Point_2
Definition: rfc_basic.h:43

Here is the call graph for this function:

void init_feature_parameters ( )
private

Read in the control file for feature detection.

The control file should be named as <window name>="">.fc. It should contain five lines. The first three lines correspond to the parameters for face angle, angle defect, and edge angle, respectively. The fourth line controls filteration rules, including the minimum edge length for open-ended 1-features, whether to apply long-falseness checking with strong endedness, and whether whether to snap the feature onto the reference mesh. The last line controls verbose level. A sample control file (default) is:

0.76604444 0.98480775 3 0.98480775 1.3962634 0.314159265 3 0.17364818 0.96592583 3 6 1 0 0 1

For RSRM dataset, use the following control files: 0.5 0.6 3 0.17365 # cos(face_angle_ub) cos(face_angle_lb) face_angle_r cos(weak_end) 1.39626 0.314159 3 # angle_defect_ub angle_defect_lb angle_defect_r 0 0.5 3 # cos(turn_angle_ub) cos(turn_angle_lb) turn_angle_r 6 1 1 0 # min-length-of-ridge long-falseness-rule strong-ended-check snapping 1 # verbose level

If the control file is missing, then the default values (above) will be used. These default values should work for most cases. For some extreme cases, adjusting the signal-to-noise ratios (the last parameters of the first three lines) and the minimum edge (line 4) should suffice.

Definition at line 81 of file RFC_Window_overlay_fea.C.

References cos, and RFC_assertion.

Referenced by RFC_Window_overlay::RFC_Window_overlay().

81  {
82  std::string fname = string(name())+".fc";
83  std::ifstream f(fname.c_str());
84 
85  if ( f) {
86  std::string buf;
87  std::cout << "Reading in parameters from file " << fname
88  << "..." << std::flush;
89  f >> _cos_uf >> _cos_lf >> _rf >> _cos_weakend; getline(f, buf);
90  f >> _ud >> _ld >> _rd; getline(f, buf);
91  f >> _cos_ue >> _cos_le >> _re; getline(f, buf);
93  >> _strong_ended >> _snap_on_features; getline(f, buf);
94  f >> verb; getline(f, buf);
95 
96  RFC_assertion( _cos_uf>=0 && _cos_uf<=1 && _cos_lf<=1 && _cos_lf>=_cos_uf);
97  RFC_assertion( _rf==0 || _rf >=1);
98  RFC_assertion( _ud>=0 && _ud<=180/r2d && _ld>=0 && _ld <= _ud);
99  RFC_assertion( _rd==0 || _rd>=1);
100  RFC_assertion( _cos_ue>=0 && _cos_ue<=1 && _cos_le<=1 && _cos_le>=_cos_ue);
101  RFC_assertion( _re==0 || _re >=1);
103  std::cout << "Done" << std::endl;
104  }
105  else {
106  // Use default parameters and write the parameters into the file
108  _ud=60/r2d; _ld=18/r2d; _rd=3;
109  _cos_ue=cos(60/r2d); _cos_le=cos(30/r2d); _re=3;
111  _strong_ended = true; _snap_on_features = false;
112  verb=1;
113  }
114 
115  if ( verb) {
116  std::cout << "Using the following threshold to detect features in "
117  << name() << ":\n\n";
118 
119  std::cout << _cos_uf << ' ' << _cos_lf << ' ' << _rf << ' ' << _cos_weakend
120  << " # cos(face_angle_ub) cos(face_angle_lb) face_angle_r cos(weak_end)" << std::endl
121  << _ud << ' ' << _ld << ' ' << _rd
122  << " # angle_defect_ub angle_defect_lb angle_defect_r" << std::endl
123  << _cos_ue << ' ' << _cos_le << ' ' << _re
124  << " # cos(turn_angle_ub) cos(turn_angle_lb) turn_angle_r" << std::endl
125  << _min_1f_len << ' ' <<_long_falseness_check << ' '
126  << _strong_ended << ' ' << _snap_on_features
127  << " # min-length-of-ridge long-falseness-rule "
128  << " strong-ended-check snapping" << std::endl
129  << verb << " # verbose level" << std::endl;
130  }
131 }
std::string name() const
The name of the window.
static const float r2d
#define RFC_assertion
Definition: rfc_basic.h:65
NT & cos

Here is the caller graph for this function:

bool is_rstrong_ea ( const Feature_1 f1,
Feature_1::const_iterator  hprev,
Feature_1::const_iterator  hnext,
float  cos_ea,
bool  isloop 
)
protected

Determine whether a vertex is relatively strong in edge angle within a give feature.

Definition at line 278 of file RFC_Window_overlay_fea.C.

References cimg_library::acos(), and min().

281  {
282  if ( cos_ea > _cos_le) return false;
283  float cos_max = std::min( cos_edge_angle( f1, hprev, isloop),
284  cos_edge_angle( f1, hnext, isloop));
285  return acos(cos_ea) >= _re*acos(cos_max);
286 }
float cos_edge_angle(const Halfedge *h1, const Halfedge *h2)
Compute the cosine of the edge angle at a vertex between two incident feature edges.
Vector_n min(const Array_n_const &v1, const Array_n_const &v2)
Definition: Vector_n.h:346
CImg< _cimg_Tfloat > acos(const CImg< T > &instance)
Definition: CImg.h:6051

Here is the call graph for this function:

bool is_strong_ad ( Vertex v)
protected

Determine whether a vertex is strong (either theta-strong or relatively strong) in angle defect.

Definition at line 253 of file RFC_Window_overlay_fea.C.

References acc, d, HDS_accessor< _MP >::get_halfedge(), HDS_accessor< _MP >::get_next_around_destination(), HDS_accessor< _MP >::get_origin(), and max().

253  {
254  // Determine whether the edge is theta-strong
255  float d = comp_angle_defect( v);
256  if ( d >= _ud) {
257  return true;
258  }
259  else if ( d >= _ld) {
260  float max_ad=0;
261  Halfedge *h0 = acc.get_halfedge( v), *h1=h0;
262  // Loop through incident edges of v
263  do {
264  float a = comp_angle_defect( acc.get_origin(h1));
265  max_ad = std::max( max_ad, a);
266  } while ( (h1=acc.get_next_around_destination(h1))!=h0);
267 
268  if ( d >= _rd*max_ad)
269  return true;
270  }
271  return false;
272 }
Vertex * get_origin(Halfedge *h) const
Definition: HDS_accessor.h:87
const NT & d
Vector_n max(const Array_n_const &v1, const Array_n_const &v2)
Definition: Vector_n.h:354
float comp_angle_defect(Vertex *v)
Compute the angle defect of a vertex.
Halfedge * get_halfedge(Vertex *v) const
Definition: HDS_accessor.h:75
*********************************************************************Illinois Open Source License ****University of Illinois NCSA **Open Source License University of Illinois All rights reserved ****Developed free of to any person **obtaining a copy of this software and associated documentation to deal with the Software without including without limitation the rights to and or **sell copies of the and to permit persons to whom the **Software is furnished to do subject to the following this list of conditions and the following disclaimers ****Redistributions in binary form must reproduce the above **copyright this list of conditions and the following **disclaimers in the documentation and or other materials **provided with the distribution ****Neither the names of the Center for Simulation of Advanced the University of nor the names of its **contributors may be used to endorse or promote products derived **from this Software without specific prior written permission ****THE SOFTWARE IS PROVIDED AS WITHOUT WARRANTY OF ANY **EXPRESS OR INCLUDING BUT NOT LIMITED TO THE WARRANTIES **OF FITNESS FOR A PARTICULAR PURPOSE AND **NONINFRINGEMENT IN NO EVENT SHALL THE CONTRIBUTORS OR **COPYRIGHT HOLDERS BE LIABLE FOR ANY DAMAGES OR OTHER WHETHER IN AN ACTION OF TORT OR **ARISING OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE **USE OR OTHER DEALINGS WITH THE SOFTWARE v
Definition: roccomf90.h:20
static HDS_accessor< Tag_true > acc
Halfedge_overlay Halfedge
Halfedge * get_next_around_destination(Halfedge *h) const
Definition: HDS_accessor.h:146

Here is the call graph for this function:

T squares ( const T &  t)

Definition at line 246 of file RFC_Window_overlay_fea.C.

246 { return t*t; }