contrib/gel/vtol/vtol_face_2d.h
Go to the documentation of this file.
00001 // This is gel/vtol/vtol_face_2d.h
00002 #ifndef vtol_face_2d_h_
00003 #define vtol_face_2d_h_
00004 //:
00005 // \file
00006 // \brief Represents the basic 2D topological entity with 2d geometry (region)
00007 //
00008 //  The vtol_face_2d class is used to represent a topological face.
00009 //  A vtol_face_2d maintains a pointer to the region which describes the
00010 //  mathematical geometry of the face.  The connectivity between
00011 //  faces may be obtained from the superior 2-chains of the face.
00012 //  The boundary of the face may be obtained from the inferior 1-chains
00013 //  of the face.
00014 //
00015 // \verbatim
00016 //  Modifications:
00017 //   JLM Dec 1995: Added timeStamp (Touch) to
00018 //       operations which affect bounds.
00019 //   JLM Dec 1995: Added method for ComputeBoundingBox
00020 //       (Need to decide proper policy for curved surfaces
00021 //       and possibly inconsistent planar surface geometry)
00022 //   JSL Computed Area()
00023 //   JLM Sep 1996: Fixed the face copy constructor which
00024 //       did not handle the construction of new vtol_edge_2d(s) properly.
00025 //       The old implementation always constructed ImplicitLine(s)
00026 //       for the curve of each new edge.  See vtol_edge_2d.h for the required
00027 //       alterations of the vtol_edge_2d constructors.  There is still an
00028 //       issue with proper copying of the vtol_face_2d's Surface.  It isn't
00029 //       done correctly.
00030 //   PVR Aug 97: is_within_projection() implementation restored.
00031 //   AWF Jul 1998: General topology speedup by replacing calls to
00032 //       vertices() et al with iterators.  Benchmark: constructing
00033 //       40K triangles, old: 37 sec, new: 9 sec.
00034 //   PTU may-2000 ported to vxl
00035 //   Dec. 2002, Peter Vanroose -interface change: vtol objects -> smart pointers
00036 //   9 Jan. 2003, Peter Vanroose - added "copy_geometry()"
00037 // \endverbatim
00038 
00039 #include <vcl_iosfwd.h>
00040 #include <vsol/vsol_region_2d_sptr.h>
00041 #include <vtol/vtol_face.h>
00042 
00043 class vtol_vertex_2d;
00044 class vtol_edge_2d;
00045 class vtol_one_chain_2d;
00046 class vtol_two_chain_2d;
00047 
00048 class vtol_face_2d : public vtol_face
00049 {
00050   //***************************************************************************
00051   // Data members
00052   //***************************************************************************
00053 
00054   vsol_region_2d_sptr surface_;
00055 
00056  public:
00057   //***************************************************************************
00058   // Initialization
00059   //***************************************************************************
00060 
00061   //---------------------------------------------------------------------------
00062   //: Default constructor
00063   //---------------------------------------------------------------------------
00064   vtol_face_2d() : surface_(0) {}
00065 
00066   //---------------------------------------------------------------------------
00067   //: Constructor
00068   //  REQUIRE: verts.size()>2
00069   //---------------------------------------------------------------------------
00070   explicit vtol_face_2d(vertex_list const& verts);
00071 
00072   //---------------------------------------------------------------------------
00073   //: Constructor
00074   //---------------------------------------------------------------------------
00075   explicit vtol_face_2d(one_chain_list const& onechs);
00076 
00077   //---------------------------------------------------------------------------
00078   //: Constructor
00079   //---------------------------------------------------------------------------
00080   explicit vtol_face_2d(vtol_one_chain_sptr const& edgeloop);
00081  private:
00082   // Deprecated
00083   explicit vtol_face_2d(vtol_one_chain &edgeloop);
00084  public:
00085   //---------------------------------------------------------------------------
00086   //: Constructor
00087   //---------------------------------------------------------------------------
00088   explicit vtol_face_2d(vsol_region_2d &facesurf);
00089 
00090   //---------------------------------------------------------------------------
00091   //: Pseudo copy constructor.  Deep copy.
00092   //---------------------------------------------------------------------------
00093   vtol_face_2d(vtol_face_2d_sptr const& other);
00094  private:
00095   //---------------------------------------------------------------------------
00096   //: Copy constructor.  Deep copy.  Deprecated.
00097   //---------------------------------------------------------------------------
00098   vtol_face_2d(const vtol_face_2d &other);
00099  public:
00100   //---------------------------------------------------------------------------
00101   //: Destructor
00102   //---------------------------------------------------------------------------
00103   virtual ~vtol_face_2d() {}
00104 
00105   //---------------------------------------------------------------------------
00106   //: Clone `this': creation of a new object and initialization
00107   //  See Prototype pattern
00108   //---------------------------------------------------------------------------
00109   virtual vsol_spatial_object_2d* clone() const;
00110 
00111   //: Return a platform independent string identifying the class
00112   virtual vcl_string is_a() const { return vcl_string("vtol_face_2d"); }
00113 
00114   //: Return true if the argument matches the string identifying the class or any parent class
00115   virtual bool is_class(const vcl_string& cls) const
00116   { return cls==is_a() || vtol_face::is_class(cls); }
00117 
00118   // Accessors
00119 
00120   virtual vsol_region_2d_sptr surface() const;
00121   virtual void set_surface(vsol_region_2d_sptr const& newsurf);
00122 
00123   //***************************************************************************
00124   // Replaces dynamic_cast<T>
00125   //***************************************************************************
00126 
00127   //---------------------------------------------------------------------------
00128   //: Return `this' if `this' is a 2D face, 0 otherwise
00129   //---------------------------------------------------------------------------
00130   virtual const vtol_face_2d *cast_to_face_2d() const { return this; }
00131 
00132   //---------------------------------------------------------------------------
00133   //: Return `this' if `this' is a 2D face, 0 otherwise
00134   //---------------------------------------------------------------------------
00135   virtual vtol_face_2d *cast_to_face_2d() { return this; }
00136 
00137   //---------------------------------------------------------------------------
00138   //: Copy with no links. Only copy the surface if it exists
00139   //---------------------------------------------------------------------------
00140   virtual vtol_face *shallow_copy_with_no_links() const;
00141 
00142   virtual bool operator==(const vtol_face_2d &other)const;
00143   inline bool operator!=(const vtol_face_2d &other)const{return !operator==(other);}
00144   bool operator==(const vtol_face &other)const; // virtual of vtol_face
00145   bool operator==(const vsol_spatial_object_2d& obj) const; // virtual of vsol_spatial_object_2d
00146 
00147   virtual void print(vcl_ostream &strm=vcl_cout) const;
00148 
00149   virtual void describe(vcl_ostream &strm=vcl_cout, int blanking=0) const;
00150 
00151   //:  copy the geometry
00152   virtual void copy_geometry(const vtol_face &other);
00153 
00154   //: provide a mechanism to compare geometry
00155   virtual bool compare_geometry(const vtol_face &other) const;
00156 
00157  protected:
00158   //: this should not called by a client
00159   virtual vtol_face* copy_with_arrays(topology_list &verts, topology_list &edges) const;
00160 };
00161 
00162 #endif // vtol_face_2d_h_