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

Classes

class  RFC_Window_overlay::Feature_0
 
struct  RFC_Window_overlay::Feature_1
 

Typedefs

typedef std::list< Feature_0 > Feature_list_0
 
typedef std::list< Feature_1 > Feature_list_1
 

Functions

void detect_features ()
 The main entry of feature detection. More...
 
bool snap_on_features () const
 
Feature_list_0 & flist_0 ()
 
Feature_list_1 & flist_1 ()
 
const Feature_list_0 & flist_0 () const
 
const Feature_list_1 & flist_1 () const
 

Detailed Description

Typedef Documentation

typedef std::list< Feature_0> Feature_list_0

Definition at line 394 of file RFC_Window_overlay.h.

typedef std::list< Feature_1> Feature_list_1

Definition at line 395 of file RFC_Window_overlay.h.

Function Documentation

void detect_features ( )

The main entry of feature detection.

Definition at line 728 of file RFC_Window_overlay_fea.C.

References RFC_Pane_overlay::_ad_0, RFC_Pane_overlay::_ea_0, RFC_Pane_overlay::_fd_1, RFC_Pane_overlay::_hds, RFC_Pane_overlay::_is_f_0, RFC_Pane_overlay::_is_f_1, RFC_Pane_overlay::_is_on_f, acc, cimg_library::acos(), cos, d, for(), free_vector(), HDS_accessor< _MP >::get_destination(), HDS_accessor< _MP >::get_next_around_origin(), HDS_accessor< _MP >::get_opposite(), HDS_accessor< _MP >::get_origin(), HDS_accessor< _MP >::get_pane(), get_tangent(), get_wtime(), RFC_Pane_overlay::hds(), HUGE_VALF, i, RFC_Pane_base::id(), iend, RFC_Pane_overlay::init_angle_defect(), RFC_Pane_overlay::init_edge_angle(), RFC_Pane_overlay::init_face_angle(), HDS_accessor< _MP >::mark(), HDS_accessor< _MP >::marked(), max(), min(), Vertex_overlay::point(), s, RFC_Pane_overlay::set_strong_edge(), and sqrt().

Referenced by Overlay::overlay().

728  {
729  int size_edges=0, dropped=0;
730 
731  // Initializing data arrays.
732  Pane_set::iterator it=_pane_set.begin(), iend=_pane_set.end();
733  for ( ; it != iend; ++it) {
734  RFC_Pane_overlay &pane = (RFC_Pane_overlay &)*it->second;
735  int num_hedgs=pane._hds.size_of_halfedges();
736  int num_verts=pane._hds.size_of_vertices();
737  size_edges+=num_hedgs/2;
738 
739  pane.init_face_angle(); pane.init_angle_defect(); pane.init_edge_angle();
740  pane._is_f_1.clear(); pane._is_f_1.resize( num_hedgs, false);
741  pane._is_f_0.clear(); pane._is_f_0.resize( num_verts, false);
742  pane._is_on_f.clear(); pane._is_on_f.resize( num_verts, false);
743  }
744  std::vector< pair<float, Halfedge*> > tstrong_edges, rstrong_edges;
745  tstrong_edges.reserve(size_edges/10);
746  rstrong_edges.reserve(size_edges/10);
747 
748  float t0=get_wtime(), totaltime=0;
749  // loop through all panes and primary halfedges in each pane
750  for ( it=_pane_set.begin(); it != iend; ++it) {
751  RFC_Pane_overlay &pane = (RFC_Pane_overlay &)*it->second;
752 
753  // Detect theta-strong edges
754  for ( RFC_Pane_overlay::HDS::Halfedge_iterator
755  hit=pane.hds().halfedges_begin(), hend=pane.hds().halfedges_end();
756  hit!=hend; ++ ++hit) {
757  Halfedge *h = &*hit, *hopp = acc.get_opposite(h);
758  if ( pane.id() <= acc.get_pane(hopp)->id()) {
759  // Determine whether the edge is theta-strong
760  float d = cos_face_angle( h, hopp);
761 
762  if ( d < _cos_uf) tstrong_edges.push_back( make_pair(d,h));
763  }
764  }
765  }
766  float t1=get_wtime(); totaltime+=t1-t0;
767  if ( verb >= 3) {
768  std::cout << "\tIdentified " << tstrong_edges.size()
769  << " theta-strong edges with Theta=" << acos( _cos_uf)*r2d
770  << " in " << t1-t0 << " sec." << std::endl;
771  t0=get_wtime();
772  }
773 
774  sort(tstrong_edges.begin(),tstrong_edges.end());
775  t1=get_wtime(); totaltime+=t1-t0;
776  if ( verb >= 3) {
777  std::cout << "\tSorted theta-strong edges in "
778  << t1-t0 << " sec." << std::endl;
779  }
780 
781  vector<std::pair<float,Halfedge*> > iedges; iedges.reserve(16);
782  _f_list_1.clear();
783 
784  // Sort the strong edges into strong curves
785  unmark_alledges();
786  float min_fa_r=HUGE_VALF;
787  t0=get_wtime();
788  for ( vector< pair<float,Halfedge*> >::iterator
789  it=tstrong_edges.begin(),iend=tstrong_edges.end(); it!=iend; ++it){
790  Halfedge *h=it->second;
791  if ( acc.marked( h)) continue;
792  Halfedge *hopp=acc.get_opposite( h);
793 
794  // Create a new list
795  Feature_1 f1;
796  f1.push_back( h);
797 
798  // Mark the edge and its opposite
799  acc.get_pane(h)->set_strong_edge(h); acc.mark( h);
800  acc.get_pane(hopp)->set_strong_edge(hopp); acc.mark( hopp);
801 
802  Vertex *src=acc.get_origin( f1.front());
803  Vertex *dst=acc.get_destination(f1.back());
804 
805  // Traverse forwards and backwards along the curve, and append an
806  // r-strong edge to the curve until we reach a non-strong curve.
807  for (int c=0; c<2; ++c) {
808  for (;;) {
809  Halfedge *h = ((c==0)?f1.back():f1.front());
810  if ( src == dst || c==0&&is_on_feature(dst) || c&&is_on_feature(src))
811  break;
812 
813  // Get the unmarked 1-feature with mimimum angle
814  iedges.clear();
815  Halfedge *h0=acc.get_opposite(h);
816  float d0=cos_face_angle( h, h0);
817  pair<float, Halfedge*> t0(d0,(c==0)?h0:h);
818  pair<float, Halfedge*> cos_max(HUGE_VALF,NULL);
819 
820  Halfedge *h1=acc.get_next_around_origin(t0.second);
821  do {
822  Halfedge *h1o=acc.get_opposite(h1);
823  float d = cos_face_angle(h1, h1o);
824  pair<float, Halfedge*> t(d,h1);
825  iedges.push_back( t);
826 
827  if ( t < cos_max) cos_max = t;
828  } while ( (h1=acc.get_next_around_origin(h1)) != t0.second);
829 
830  bool is_strong=true;
831  const Vector_3 v1=get_tangent( t0.second);
832  if ( cos_max.first>_cos_uf && iedges.size()>1) {
833  for ( int i=0,s=iedges.size(); i<s; ++i) {
834  const Vector_3 v2=get_tangent( iedges[i].second);
835  const Real t = std::max(-v1*v2/sqrt((v1*v1)*(v2*v2)),0.);
836  iedges[i].first = acos(iedges[i].first)*t;
837  }
838  sort(iedges.rbegin(),iedges.rend());
839  cos_max = iedges[0];
840  if ( cos(cos_max.first)>_cos_lf) break;
841 
842  is_strong = cos_max.first >= iedges[1].first*_rf ||
843  is_on_feature( acc.get_destination(cos_max.second)) ||
844  is_strong_ad( acc.get_destination(cos_max.second));
845  min_fa_r=std::min(min_fa_r,cos_max.first/iedges[1].first);
846  }
847  const Vector_3 v2=get_tangent( cos_max.second);
848  float a = -v1*v2/sqrt((v1*v1)*(v2*v2));
849  if ( a<_cos_ue || a<cos_face_angle(cos_max.second,NULL)) break;
850 
851  rstrong_edges.push_back(make_pair(cos_face_angle(cos_max.second,0),
852  cos_max.second));
853 
854  h = cos_max.second;
855  if ( acc.marked( h)) break;
856  Halfedge *hopp = acc.get_opposite( h);
857 
858  acc.mark( h); acc.get_pane(h)->set_strong_edge( h);
859  acc.mark( hopp); acc.get_pane(hopp)->set_strong_edge( hopp);
860  if (c==0) {
861  f1.push_back( h);
862  dst = acc.get_destination( h);
863  }
864  else {
865  f1.push_front( hopp);
866  src = acc.get_origin( hopp);
867  }
868  if ( !is_strong) break;
869  }
870  }
871 
872  Feature_list_1 flist;
873  subdiv_feature_curve( f1, flist, dropped);
874  _f_list_1.splice( _f_list_1.end(), flist);
875  }
876 
877  t1=get_wtime(); totaltime+=t1-t0;
878  if ( verb >= 3) {
879  std::cout << "\tIdentified " << rstrong_edges.size()
880  << " r-strong edges with r=" << _rf
881  << " in " << t1-t0 << " sec." << std::endl;
882  sort(rstrong_edges.begin(), rstrong_edges.end());
883  dump_strong_edges( tstrong_edges, rstrong_edges);
884  t0=get_wtime();
885  }
886 
888 
889  totaltime+=t1-t0;
890  if ( verb >= 1) {
891  std::cout << "\tFound " << _f_list_1.size() << " ridges and "
892  << _f_list_0.size() << " corners and dropped "
893  << dropped << " false-strong edges.\n"
894  << "\tDone in " << totaltime << " sec." << std::endl;
895 #ifndef DEBUG
896  if ( verb >= 2)
897 #endif
898  print_features();
899  }
900 
901  // Compute the bounding boxes of the 1-features
902  for ( Feature_list_1::iterator it=_f_list_1.begin();
903  it != _f_list_1.end(); ++it) {
904  it->bbox += Bbox_3(acc.get_origin( it->front())->point());
905  for (Feature_1::iterator hi=it->begin(), hiend=it->end(); hi!=hiend; ++hi){
906  it->bbox += Bbox_3(acc.get_destination( *hi)->point());
907  }
908  }
909 
910  // Finalization
911  unmark_alledges();
912 
913  free_vector( tstrong_edges); rstrong_edges.clear();
914  for ( it=_pane_set.begin(); it != _pane_set.end(); ++it) {
915  RFC_Pane_overlay &pane = (RFC_Pane_overlay &)*it->second;
916 
917  free_vector( pane._fd_1);
918  free_vector( pane._ad_0);
919  free_vector( pane._ea_0);
920  }
921 }
bool is_strong_ad(Vertex *v)
Determine whether a vertex is strong (either theta-strong or relatively strong) in angle defect...
Vertex * get_origin(Halfedge *h) const
Definition: HDS_accessor.h:87
void set_strong_edge(Halfedge *h)
std::vector< bool > _is_f_0
void subdiv_feature_curve(const Feature_1 &f1, Feature_list_1 &new_flist, int &dropped)
Subdivide a feature curve by splitting it at 0-features.
void free_vector(std::vector< _TT > &v)
Definition: rfc_basic.h:54
static const float r2d
const Pane & pane(const int pid) const
Get a reference to the pane with give id pid.
const NT & d
Halfedge * get_opposite(Halfedge *h) const
Definition: HDS_accessor.h:99
double s
Definition: blastest.C:80
RFC_Pane_overlay * get_pane(Vertex *v) const
Definition: HDS_accessor.h:128
Vector_n max(const Array_n_const &v1, const Array_n_const &v2)
Definition: Vector_n.h:354
bool marked(const Halfedge *h) const
Definition: HDS_accessor.h:299
double Real
Definition: mapbasic.h:322
SURF::Vector_3< Real > Vector_3
Definition: rfc_basic.h:42
std::vector< bool > _is_on_f
double sqrt(double d)
Definition: double.h:73
Vector_3 get_tangent(const Halfedge *h)
std::list< Feature_1 > Feature_list_1
float cos_face_angle(Halfedge *h, Halfedge *hopp)
Compute the cosine of the face angle (dihedral angle) at an edge.
std::vector< bool > _is_f_1
Feature_list_1 _f_list_1
const Point & point() const
**********************************************************************Rocstar Simulation Suite Illinois Rocstar LLC All rights reserved ****Illinois Rocstar LLC IL **www illinoisrocstar com **sales illinoisrocstar com 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 **********************************************************************INTERFACE SUBROUTINE knode iend
void identify_features_0()
Identify the 0-features.
static HDS_accessor< Tag_true > acc
blockLoc i
Definition: read.cpp:79
void print_features()
Dump out the 0- and 1-features in Tecplot format into files &lt;name&gt;f0.plt, &lt;name&gt;f1.plt, respectively.
std::vector< float > _fd_1
Vector_n min(const Array_n_const &v1, const Array_n_const &v2)
Definition: Vector_n.h:346
Feature_list_0 _f_list_0
Pane_set _pane_set
The set of panes contained in the window.
bool is_on_feature(const Vertex *v) const
Halfedge * get_next_around_origin(Halfedge *h) const
Definition: HDS_accessor.h:136
#define HUGE_VALF
Definition: Rocout_hdf4.C:719
void mark(Halfedge *h) const
Definition: HDS_accessor.h:295
std::vector< float > _ad_0
Halfedge_overlay Halfedge
Vertex * get_destination(Halfedge *h) const
Definition: HDS_accessor.h:93
CImg< _cimg_Tfloat > acos(const CImg< T > &instance)
Definition: CImg.h:6051
for(;;)
int id() const
RFC_BEGIN_NAME_SPACE double get_wtime()
Definition: Timing.h:33
NT & cos
void dump_strong_edges(const std::vector< std::pair< float, Halfedge * > > &, const std::vector< std::pair< float, Halfedge * > > &)
Dump out the strong edges in Tecplot format into file &lt;name&gt;s1.plt.
std::vector< float > _ea_0

Here is the call graph for this function:

Here is the caller graph for this function:

Feature_list_0& flist_0 ( )
inline

Definition at line 399 of file RFC_Window_overlay.h.

References RFC_Window_overlay::_f_list_0.

Referenced by Overlay::match_features_0().

399 { return _f_list_0; }
Feature_list_0 _f_list_0

Here is the caller graph for this function:

const Feature_list_0& flist_0 ( ) const
inline

Definition at line 401 of file RFC_Window_overlay.h.

References RFC_Window_overlay::_f_list_0.

401 { return _f_list_0; }
Feature_list_0 _f_list_0
Feature_list_1& flist_1 ( )
inline

Definition at line 400 of file RFC_Window_overlay.h.

References RFC_Window_overlay::_f_list_1.

400 { return _f_list_1; }
Feature_list_1 _f_list_1
const Feature_list_1& flist_1 ( ) const
inline

Definition at line 402 of file RFC_Window_overlay.h.

References RFC_Window_overlay::_f_list_1.

402 { return _f_list_1; }
Feature_list_1 _f_list_1
bool snap_on_features ( ) const
inline

Definition at line 398 of file RFC_Window_overlay.h.

References RFC_Window_overlay::_snap_on_features.

Referenced by Overlay::match_features_0(), and Overlay::project_next_vertex().

398 { return _snap_on_features; }

Here is the caller graph for this function: