contrib/gel/vtol/vtol_face.h
Go to the documentation of this file.
00001 // This is gel/vtol/vtol_face.h
00002 #ifndef vtol_face_h_
00003 #define vtol_face_h_
00004 //:
00005 // \file
00006 // \brief Represents the basic 2D topological entity
00007 //
00008 //  The vtol_face class is used to represent a topological face.
00009 //  The connectivity between faces may be obtained from the superior 2-chains
00010 //  of the face. The boundary of the face may be obtained from the inferior
00011 //  1-chains of the face.
00012 //
00013 // \verbatim
00014 //  Modifications:
00015 //   JLM Dec 1995: Added timeStamp (Touch) to
00016 //       operations which affect bounds.
00017 //   JLM Dec 1995: Added method for ComputeBoundingBox
00018 //       (Need to decide proper policy for curved surfaces
00019 //       and possibly inconsistent planar surface geometry)
00020 //   JSL Computed Area()
00021 //   JLM Sep 1996: Fixed the face copy constructor which
00022 //       did not handle the construction of new vtol_edge(s) properly.
00023 //       The old implementation always constructed ImplicitLine(s)
00024 //       for the curve of each new edge.  See vtol_edge.h for the required
00025 //       alterations of the vtol_edge constructors.  There is still an
00026 //       issue with proper copying of the vtol_face's Surface.  It isn't
00027 //       done correctly.
00028 //   PVR Aug 97: is_within_projection() implementation restored.
00029 //   AWF Jul 1998: General topology speedup by replacing calls to
00030 //       vertices() et al with iterators.  Benchmark: constructing
00031 //       40K triangles, old: 37 sec, new: 9 sec.
00032 //   PTU may-2000 ported to vxl
00033 //   Dec. 2002, Peter Vanroose -interface change: vtol objects -> smart pointers
00034 //   9 Jan. 2003, Peter Vanroose - added pure virtual "copy_geometry()"
00035 //   5 Feb. 2003, Peter Vanroose - moved IsHoleP() here from vtol_intensity_face
00036 //   22 Sep.2004, Peter Vanroose - added cast_to_intensity_face()
00037 // \endverbatim
00038 
00039 #include <vcl_iosfwd.h>
00040 #include <vcl_vector.h>
00041 #include <vtol/vtol_topology_object.h>
00042 #include <vtol/vtol_one_chain.h>
00043 #include <vtol/vtol_two_chain.h>
00044 class vtol_vertex;
00045 class vtol_edge;
00046 class vtol_face_2d;
00047 class vtol_one_chain;
00048 class vtol_two_chain;
00049 class vtol_intensity_face;
00050 
00051 class vtol_face : public vtol_topology_object
00052 {
00053  public:
00054   //***************************************************************************
00055   // Initialization
00056   //***************************************************************************
00057 
00058   //---------------------------------------------------------------------------
00059   //: Default constructor
00060   //---------------------------------------------------------------------------
00061   vtol_face() {}
00062 
00063   //---------------------------------------------------------------------------
00064   //: Destructor
00065   //---------------------------------------------------------------------------
00066   virtual ~vtol_face();
00067 
00068   // Accessors
00069 
00070  private: // has been superseded by is_a()
00071   //: Return the topology type
00072   virtual vtol_topology_object_type topology_type() const { return FACE; }
00073 
00074  public:
00075   virtual vtol_one_chain_sptr get_one_chain(int which = 0);
00076   virtual vtol_one_chain_sptr get_boundary_cycle();
00077   virtual bool add_hole_cycle(vtol_one_chain_sptr new_hole);
00078   virtual one_chain_list *get_hole_cycles();
00079 
00080   // Methods that are here for now in transition.. :x
00081 
00082   //: Inferior/Superior Accessor Methods
00083   virtual vtol_face * copy_with_arrays(topology_list &verts, topology_list &edges) const =0;
00084 
00085   //***************************************************************************
00086   // Replaces dynamic_cast<T>
00087   //***************************************************************************
00088 
00089   //---------------------------------------------------------------------------
00090   //: Return `this' if `this' is a face, 0 otherwise
00091   //---------------------------------------------------------------------------
00092   virtual const vtol_face *cast_to_face() const { return this; }
00093 
00094   //---------------------------------------------------------------------------
00095   //: Return `this' if `this' is a face, 0 otherwise
00096   //---------------------------------------------------------------------------
00097   virtual vtol_face *cast_to_face() { return this; }
00098 
00099   //---------------------------------------------------------------------------
00100   //: Return `this' if `this' is a 2D face, 0 otherwise
00101   //---------------------------------------------------------------------------
00102   virtual const vtol_face_2d *cast_to_face_2d() const {return 0;}
00103 
00104   //---------------------------------------------------------------------------
00105   //: Return `this' if `this' is a 2D face, 0 otherwise
00106   //---------------------------------------------------------------------------
00107   virtual vtol_face_2d *cast_to_face_2d() {return 0;}
00108 
00109   //---------------------------------------------------------------------------
00110   //: Return `this' if `this' is an intensity face, 0 otherwise
00111   //---------------------------------------------------------------------------
00112   virtual const vtol_intensity_face *cast_to_intensity_face() const { return 0; }
00113 
00114   //---------------------------------------------------------------------------
00115   //: Return `this' if `this' is an intensity face, 0 otherwise
00116   //---------------------------------------------------------------------------
00117   virtual vtol_intensity_face *cast_to_intensity_face() { return 0; }
00118 
00119   //***************************************************************************
00120   // Status report
00121   //***************************************************************************
00122 
00123   void link_inferior(vtol_one_chain_sptr inf);
00124   void unlink_inferior(vtol_one_chain_sptr inf);
00125 
00126   //---------------------------------------------------------------------------
00127   //: Is `inferior' type valid for `this' ?
00128   //---------------------------------------------------------------------------
00129   virtual bool valid_inferior_type(vtol_topology_object const* inferior) const
00130   { return inferior->cast_to_one_chain()!=0; }
00131   bool valid_inferior_type(vtol_one_chain_sptr const& ) const { return true; }
00132   bool valid_superior_type(vtol_two_chain_sptr const& ) const { return true; }
00133 
00134   //: accessors for boundary elements
00135   virtual vertex_list *outside_boundary_vertices();
00136   virtual zero_chain_list *outside_boundary_zero_chains();
00137   virtual edge_list *outside_boundary_edges();
00138   virtual one_chain_list *outside_boundary_one_chains();
00139  protected:
00140   // \warning these methods should not be used by clients
00141   // The returned pointers must be deleted after use.
00142 
00143   virtual vcl_vector<vtol_vertex*> *compute_vertices();
00144   virtual vcl_vector<vtol_edge*> *compute_edges();
00145   virtual vcl_vector<vtol_zero_chain*> *compute_zero_chains();
00146   virtual vcl_vector<vtol_one_chain*> *compute_one_chains();
00147   virtual vcl_vector<vtol_face*> *compute_faces();
00148   virtual vcl_vector<vtol_two_chain*> *compute_two_chains();
00149   virtual vcl_vector<vtol_block*> *compute_blocks();
00150 
00151   virtual vcl_vector<vtol_vertex*> *outside_boundary_compute_vertices();
00152   virtual vcl_vector<vtol_zero_chain*> *outside_boundary_compute_zero_chains();
00153   virtual vcl_vector<vtol_edge*> *outside_boundary_compute_edges();
00154   virtual vcl_vector<vtol_one_chain*> *outside_boundary_compute_one_chains();
00155  public:
00156 
00157   // Editing Functions
00158 
00159   virtual void add_one_chain(vtol_one_chain_sptr const&);
00160  private:
00161   // Deprecated:
00162   virtual void add_one_chain(vtol_one_chain &);
00163  public:
00164   //: Utility Functions and overloaded operators
00165 
00166   virtual void reverse_normal();
00167   virtual int get_num_edges() const;
00168 
00169   //: This method determines if a vtol_face is a hole of another vtol_face.
00170   bool IsHoleP() const;
00171 
00172   //---------------------------------------------------------------------------
00173   //: Copy with no links. Only copy the surface if it exists
00174   //---------------------------------------------------------------------------
00175   virtual vtol_face *shallow_copy_with_no_links() const =0;
00176 
00177   virtual bool operator==(const vtol_face &other)const;
00178   inline bool operator!=(const vtol_face &other)const{return !operator==(other);}
00179   bool operator==(const vsol_spatial_object_2d& obj) const; // virtual of vsol_spatial_object_2d
00180 
00181   //: determine bounding box from bounding boxes of underlying edges
00182   virtual void compute_bounding_box() const;
00183 
00184   virtual void print(vcl_ostream &strm=vcl_cout) const;
00185 
00186   virtual void describe(vcl_ostream &strm=vcl_cout,
00187                         int blanking=0) const;
00188   //---------------------------------------------------------------------------
00189   //: Does `this' share an edge with `f' ?
00190   // Comparison of edge pointers, not geometric values
00191   //---------------------------------------------------------------------------
00192   virtual bool shares_edge_with(vtol_face_sptr const& f);
00193 
00194   //: have the inherited classes copy the geometry
00195   virtual void copy_geometry(const vtol_face &other)=0;
00196 
00197   //: compare the geometry
00198   virtual bool compare_geometry(const vtol_face &other) const =0;
00199 
00200   //: Return a platform independent string identifying the class
00201   virtual vcl_string is_a() const { return vcl_string("vtol_face"); }
00202 
00203   //: Return true if the argument matches the string identifying the class or any parent class
00204   virtual bool is_class(const vcl_string& cls) const { return cls==is_a(); }
00205 };
00206 
00207 #endif // vtol_face_h_