vtf-logo

ScanConversionPolyhedron.h

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 
00008 #if !defined(__geom_ScanConversionPolyhedron_h__)
00009 #define __geom_ScanConversionPolyhedron_h__
00010 
00011 #include "IndexedEdgePolyhedron.h"
00012 #include "ScanConversionPolygon.h"
00013 
00014 #include "../kernel/SegmentMath.h"
00015 #include "../grid/RegularGrid.h"
00016 
00017 #include <iostream>
00018 #include <iomanip>
00019 #include <vector>
00020 
00021 #include <cassert>
00022 #include <cmath>
00023 
00024 BEGIN_NAMESPACE_GEOM
00025 
00027 
00035 template<typename T = double>
00036 class ScanConversionPolyhedron {
00037   //
00038   // Public types.
00039   //
00040 
00041 public:
00042 
00044   typedef T Number;
00046   typedef ads::FixedArray<3,Number> Point;
00048   typedef SegmentMath<3,Number> Segment;
00049 
00050   //
00051   // Private types.
00052   //
00053 
00054 private:
00055 
00056   typedef ScanConversionPolygon<Number> Polygon;
00057 
00058   // 
00059   // Data
00060   //
00061 
00062 private:
00063 
00065   std::vector<Segment> _edges;
00066 
00067 public:
00068 
00069   //--------------------------------------------------------------------------
00071   // @{
00072 
00074   ScanConversionPolyhedron() :
00075     _edges()
00076   {}
00077 
00079   ScanConversionPolyhedron(const ScanConversionPolyhedron& other) : 
00080     _edges(other._edges) 
00081   {}
00082 
00084   ScanConversionPolyhedron& 
00085   operator=(const ScanConversionPolyhedron& other);
00086   
00088   ScanConversionPolyhedron& 
00089   operator=(const IndexedEdgePolyhedron<Number>& x);
00090   
00092   ~ScanConversionPolyhedron()
00093   {}
00094 
00095   // @}
00096   //--------------------------------------------------------------------------
00098   // @{
00099 
00101   void 
00102   computeBBox(BBox<3,Number>* bb) const;
00103 
00105   void
00106   convertLocationsToIndices(const RegularGrid<3,Number>& grid);
00107 
00109 
00113   template<typename IndexOutputIterator>
00114   void
00115   scanConvert(IndexOutputIterator coordinates, 
00116               const RegularGrid<3,Number>& grid) const;
00117 
00118   // @}
00119   //--------------------------------------------------------------------------
00121   // @{
00122 
00124   const std::vector<Segment>& 
00125   getEdges() const { 
00126     return _edges; 
00127   }
00128 
00129   // @}
00130   //--------------------------------------------------------------------------
00132   // @{
00133 
00135   void 
00136   clear() {
00137     _edges.clear();
00138   }
00139 
00141   void 
00142   insertEdge(const Point& p, const Point& q);
00143 
00144   // @}
00145 
00146 private:
00147 
00148   // Intersect with the plane of constant z value to obtain a polygon.
00149   void 
00150   computeZIntersection(Polygon* polygon, Number z) const;
00151 
00152 };
00153 
00154 
00155 //-----------------------------------------------------------------------------
00156 // File I/O Operators
00157 //-----------------------------------------------------------------------------
00158 
00159 
00161 
00162 template<typename T>
00163 std::ostream& 
00164 operator<<(std::ostream& out, const ScanConversionPolyhedron<T>& polyhedron);
00165 
00166 
00168 
00169 template<typename T>
00170 void 
00171 mathematicaPrint(std::ostream& out, 
00172                  const ScanConversionPolyhedron<T>& polyhedron);
00173 
00174 
00176 
00177 template<typename T>
00178 std::istream& 
00179 operator>>(std::istream& in, ScanConversionPolyhedron<T>& polyhedron);
00180 
00181 
00182 
00183 //-----------------------------------------------------------------------------
00184 // Equality Operators
00185 //-----------------------------------------------------------------------------
00186 
00188 
00189 template<typename T>
00190 inline
00191 bool 
00192 operator==(const ScanConversionPolyhedron<T>& a, 
00193            const ScanConversionPolyhedron<T>& b) { 
00194   return a.getEdges() == b.getEdges(); 
00195 }
00196 
00197 
00199 
00200 template<typename T>
00201 inline
00202 bool 
00203 operator!=(const ScanConversionPolyhedron<T>& a, 
00204            const ScanConversionPolyhedron<T>& b) { 
00205   return !(a == b);
00206 }
00207 
00208 
00209 END_NAMESPACE_GEOM
00210 
00211 #define __geom_ScanConversionPolyhedron_ipp__
00212 #include "ScanConversionPolyhedron.ipp"
00213 #undef __geom_ScanConversionPolyhedron_ipp__
00214 
00215 #endif

Generated on Fri Aug 24 12:55:56 2007 for Computational Geometry Package by  doxygen 1.4.7