contrib/gel/vtol/vtol_block.h
Go to the documentation of this file.
00001 // This is gel/vtol/vtol_block.h
00002 #ifndef vtol_block_h_
00003 #define vtol_block_h_
00004 //-----------------------------------------------------------------------------
00005 //:
00006 // \file
00007 // \brief Highest node in a 3D topological structure
00008 //
00009 //   The vtol_block class is used to represent the highest node in a 3D topological
00010 //   structure. A vtol_block consists of its inferior 2-chains which must be
00011 //   cyclic, and no topological superiors.
00012 //
00013 // \author
00014 //     Patricia A. Vrobel
00015 //
00016 // \verbatim
00017 //  Modifications:
00018 //   JLM Dec 1995, Added timeStamp (Touch) to operations which affect bounds.
00019 //   JLM Dec 1995  (Need to decide proper policy for curved volumes
00020 //                 and possibly inconsistent polyhedra volume geometry)
00021 //   JNS Dec 1998, Added is_within functions (used in 2D display of a block,
00022 //                 these functions must be wrong for 3D use)
00023 //   Dec. 2002, Peter Vanroose -interface change: vtol objects -> smart pointers
00024 // \endverbatim
00025 //-----------------------------------------------------------------------------
00026 
00027 #include <vcl_iosfwd.h>
00028 #include <vtol/vtol_topology_object.h>
00029 #include <vtol/vtol_two_chain.h>
00030 class vtol_vertex;
00031 class vtol_edge;
00032 class vtol_zero_chain;
00033 class vtol_one_chain;
00034 class vtol_face;
00035 class vtol_two_chain;
00036 
00037 class vtol_block : public vtol_topology_object
00038 {
00039  public:
00040   //***************************************************************************
00041   // Initialization
00042   //***************************************************************************
00043 
00044   //---------------------------------------------------------------------------
00045   //: Default constructor
00046   //---------------------------------------------------------------------------
00047   vtol_block() {}
00048 
00049   //---------------------------------------------------------------------------
00050   //: Constructor from a two-chain (inferior)
00051   //---------------------------------------------------------------------------
00052   explicit vtol_block(vtol_two_chain_sptr const& faceloop);
00053  private:
00054   // Deprecated
00055   explicit vtol_block(vtol_two_chain &faceloop);
00056  public:
00057   //---------------------------------------------------------------------------
00058   //: Constructor from a list of two-chains.
00059   //  The first two-chain is the outside boundary.
00060   //  The remaining two-chains are considered holes inside the outside volume.
00061   //---------------------------------------------------------------------------
00062   explicit vtol_block(two_chain_list const& faceloops);
00063 
00064   //---------------------------------------------------------------------------
00065   //: Constructor from a list of faces
00066   //---------------------------------------------------------------------------
00067   explicit vtol_block(face_list const& new_face_list);
00068 
00069   //---------------------------------------------------------------------------
00070   //: Pseudo copy constructor. Deep copy.
00071   //---------------------------------------------------------------------------
00072   vtol_block(vtol_block_sptr const& other);
00073  private:
00074   //---------------------------------------------------------------------------
00075   //: Copy constructor. Deep copy. Deprecated.
00076   //---------------------------------------------------------------------------
00077   vtol_block(const vtol_block &other);
00078  public:
00079   //---------------------------------------------------------------------------
00080   //: Destructor
00081   //---------------------------------------------------------------------------
00082   virtual ~vtol_block();
00083 
00084   //---------------------------------------------------------------------------
00085   //: Clone `this': creation of a new object and initialization
00086   //  See Prototype pattern
00087   //---------------------------------------------------------------------------
00088   virtual vsol_spatial_object_2d* clone() const;
00089 
00090   //: Return a platform independent string identifying the class
00091   virtual vcl_string is_a() const { return vcl_string("vtol_block"); }
00092 
00093   //: Return true if the argument matches the string identifying the class or any parent class
00094   virtual bool is_class(const vcl_string& cls) const { return cls==is_a(); }
00095 
00096   // Accessors
00097 
00098  private: // has been superseded by is_a()
00099   //: Return the topology type
00100   virtual vtol_topology_object_type topology_type() const { return BLOCK; }
00101 
00102  public:
00103   virtual vtol_two_chain_sptr get_boundary_cycle();
00104 
00105   //***************************************************************************
00106   // Replaces dynamic_cast<T>
00107   //***************************************************************************
00108 
00109   //---------------------------------------------------------------------------
00110   //: Return `this' if `this' is a block, 0 otherwise
00111   //---------------------------------------------------------------------------
00112   virtual const vtol_block *cast_to_block() const { return this; }
00113 
00114   //---------------------------------------------------------------------------
00115   //: Return `this' if `this' is a block, 0 otherwise
00116   //---------------------------------------------------------------------------
00117   virtual vtol_block *cast_to_block() { return this; }
00118 
00119   //***************************************************************************
00120   // Status report
00121   //***************************************************************************
00122 
00123   void link_inferior(vtol_two_chain_sptr inf);
00124   void unlink_inferior(vtol_two_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_two_chain()!=0; }
00131   bool valid_inferior_type(vtol_two_chain_sptr const& ) const { return true; }
00132 
00133   virtual vertex_list *outside_boundary_vertices();
00134   virtual zero_chain_list *outside_boundary_zero_chains();
00135   virtual edge_list *outside_boundary_edges();
00136   virtual one_chain_list *outside_boundary_one_chains();
00137   virtual face_list *outside_boundary_faces();
00138   virtual two_chain_list *outside_boundary_two_chains();
00139 
00140  protected:
00141   // \warning these methods should not be used by clients
00142   // The returned pointers must be deleted after use.
00143 
00144   virtual vcl_vector<vtol_vertex *> *compute_vertices();
00145   virtual vcl_vector<vtol_edge *> *compute_edges();
00146   virtual vcl_vector<vtol_zero_chain *> *compute_zero_chains();
00147   virtual vcl_vector<vtol_one_chain *> *compute_one_chains();
00148   virtual vcl_vector<vtol_face *> *compute_faces();
00149   virtual vcl_vector<vtol_two_chain *> *compute_two_chains();
00150   virtual vcl_vector<vtol_block *> *compute_blocks();
00151 
00152   virtual vcl_vector<vtol_vertex *> *outside_boundary_compute_vertices();
00153   virtual vcl_vector<vtol_zero_chain *> *outside_boundary_compute_zero_chains();
00154   virtual vcl_vector<vtol_edge *> *outside_boundary_compute_edges();
00155   virtual vcl_vector<vtol_one_chain *> *outside_boundary_compute_one_chains();
00156   virtual vcl_vector<vtol_face *> *outside_boundary_compute_faces();
00157   virtual vcl_vector<vtol_two_chain *> *outside_boundary_compute_two_chains();
00158 
00159  public:
00160   virtual two_chain_list *hole_cycles() const;
00161 
00162   //: Utility and Editing Functions
00163   virtual bool add_hole_cycle(vtol_two_chain_sptr new_hole);
00164 
00165   //  virtual void update();
00166   virtual bool operator==(const vtol_block &other) const;
00167   inline bool operator!=(const vtol_block &other)const{return !operator==(other);}
00168   virtual bool operator==(const vsol_spatial_object_2d& obj) const; // virtual of vsol_spatial_object_2d
00169 
00170   //: Printing Functions
00171   virtual void print(vcl_ostream &strm=vcl_cout) const;
00172   virtual void describe(vcl_ostream &strm=vcl_cout,
00173                         int blanking=0) const;
00174 };
00175 
00176 #endif // vtol_block_h_