From: Leonardo Florez-Valencia Date: Thu, 11 Dec 2014 08:45:30 +0000 (+0100) Subject: "Extesions" code reorganized X-Git-Tag: v0.1~442 X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=commitdiff_plain;h=1740a32cbb99c4abd76ee0c0e5e45e0df3a8e800;p=cpPlugins.git "Extesions" code reorganized --- diff --git a/appli/examples/example_ReadQuadEdgeMeshWithoutPlugins.cxx b/appli/examples/example_ReadQuadEdgeMeshWithoutPlugins.cxx index 63abac7..2379fe4 100644 --- a/appli/examples/example_ReadQuadEdgeMeshWithoutPlugins.cxx +++ b/appli/examples/example_ReadQuadEdgeMeshWithoutPlugins.cxx @@ -2,13 +2,15 @@ #include #include -#include -#include +#include +#include // ------------------------------------------------------------------------- const unsigned int Dimension = 3; typedef float TScalar; -typedef cpPlugins::Extensions::QuadEdgeMesh< TScalar, Dimension > TMesh; +typedef cpPlugins::Extensions:: +DataStructures::QuadEdgeMesh< TScalar, Dimension > +TMesh; // ------------------------------------------------------------------------- int main( int argc, char* argv[] ) @@ -23,7 +25,7 @@ int main( int argc, char* argv[] ) } // fi - typedef cpPlugins::Extensions::MeshReader< TMesh > TReader; + typedef cpPlugins::Extensions::IO::MeshReader< TMesh > TReader; TReader::Pointer reader = TReader::New( ); reader->SetFileName( argv[ 1 ] ); reader->Update( ); diff --git a/appli/examples/example_RenderQuadEdgeMeshWithoutPlugins.cxx b/appli/examples/example_RenderQuadEdgeMeshWithoutPlugins.cxx index 35d9ab6..8f01af9 100644 --- a/appli/examples/example_RenderQuadEdgeMeshWithoutPlugins.cxx +++ b/appli/examples/example_RenderQuadEdgeMeshWithoutPlugins.cxx @@ -2,9 +2,9 @@ #include #include -#include -#include -#include +#include +#include +#include #include #include @@ -17,8 +17,9 @@ // ------------------------------------------------------------------------- const unsigned int Dimension = 3; typedef float TScalar; -typedef cpPlugins::Extensions::QuadEdgeMesh< TScalar, Dimension > TMesh; -typedef cpPlugins::Extensions::OpenGLMeshMapper< TMesh > TMeshMapper; +using namespace cpPlugins::Extensions; +typedef DataStructures::QuadEdgeMesh< TScalar, Dimension > TMesh; +typedef Visualization::OpenGLMeshMapper< TMesh > TMeshMapper; // ------------------------------------------------------------------------- int main( int argc, char* argv[] ) @@ -33,7 +34,7 @@ int main( int argc, char* argv[] ) } // fi - typedef cpPlugins::Extensions::MeshReader< TMesh > TReader; + typedef IO::MeshReader< TMesh > TReader; TReader::Pointer reader = TReader::New( ); reader->SetFileName( argv[ 1 ] ); reader->Update( ); diff --git a/lib/cpPlugins/Extensions/CMakeLists.txt b/lib/cpPlugins/Extensions/CMakeLists.txt index 42f7765..b331297 100644 --- a/lib/cpPlugins/Extensions/CMakeLists.txt +++ b/lib/cpPlugins/Extensions/CMakeLists.txt @@ -11,6 +11,27 @@ FILE(GLOB LIB_SOURCES_C "*.c") FILE(GLOB LIB_SOURCES_CPP "*.cpp") FILE(GLOB LIB_SOURCES_CXX "*.cxx") +FILE(GLOB LIB_DataStructures_HEADERS_H "*.h") +FILE(GLOB LIB_DataStructures_HEADERS_HPP "*.hpp") +FILE(GLOB LIB_DataStructures_HEADERS_HXX "*.hxx") +FILE(GLOB LIB_DataStructures_SOURCES_C "*.c") +FILE(GLOB LIB_DataStructures_SOURCES_CPP "*.cpp") +FILE(GLOB LIB_DataStructures_SOURCES_CXX "*.cxx") + +FILE(GLOB LIB_IO_HEADERS_H "*.h") +FILE(GLOB LIB_IO_HEADERS_HPP "*.hpp") +FILE(GLOB LIB_IO_HEADERS_HXX "*.hxx") +FILE(GLOB LIB_IO_SOURCES_C "*.c") +FILE(GLOB LIB_IO_SOURCES_CPP "*.cpp") +FILE(GLOB LIB_IO_SOURCES_CXX "*.cxx") + +FILE(GLOB LIB_Visualization_HEADERS_H "*.h") +FILE(GLOB LIB_Visualization_HEADERS_HPP "*.hpp") +FILE(GLOB LIB_Visualization_HEADERS_HXX "*.hxx") +FILE(GLOB LIB_Visualization_SOURCES_C "*.c") +FILE(GLOB LIB_Visualization_SOURCES_CPP "*.cpp") +FILE(GLOB LIB_Visualization_SOURCES_CXX "*.cxx") + ## ===================== ## = Compilation rules = ## ===================== diff --git a/lib/cpPlugins/Extensions/DataStructures/QuadEdge.h b/lib/cpPlugins/Extensions/DataStructures/QuadEdge.h new file mode 100644 index 0000000..70a6325 --- /dev/null +++ b/lib/cpPlugins/Extensions/DataStructures/QuadEdge.h @@ -0,0 +1,473 @@ +#ifndef __CPPLUGINS__EXTENSIONS__DATASTRUCTURES__QUADEDGE__H__ +#define __CPPLUGINS__EXTENSIONS__DATASTRUCTURES__QUADEDGE__H__ + +#include +#include + +namespace cpPlugins +{ + namespace Extensions + { + namespace DataStructures + { + /** + */ + template< typename P, typename D, bool IsPrimal = true > + class QuadEdge + : public itk::LightObject + { + public: + typedef QuadEdge Self; + typedef itk::LightObject Superclass; + typedef itk::SmartPointer< Self > Pointer; + typedef itk::SmartPointer< const Self > ConstPointer; + + /// Vertices and faces types + typedef P TPrimalGeometry; + typedef D TDualGeometry; + + /** + * Dual type, basically the same type with swapped template + * parameters. + */ + typedef QuadEdge< D, P, !IsPrimal > TDual; + typedef Self TPrimal; + typedef typename TDual::Pointer PtrDual; + friend TDual; + + /// Iterators + typedef QuadEdgeIterator< TPrimal > Iterator; + typedef QuadEdgeConstIterator< TPrimal > ConstIterator; + typedef QuadEdgePointIterator< TPrimal > PointIterator; + typedef QuadEdgePointConstIterator< TPrimal > PointConstIterator; + + public: + itkNewMacro( Self ); + itkTypeMacro( QuadEdge, itkLightObject ); + + cpPluginsExtensionsQEAllIteratorsMacro( Onext ); + cpPluginsExtensionsQEAllIteratorsMacro( Lnext ); + cpPluginsExtensionsQEAllIteratorsMacro( Rnext ); + cpPluginsExtensionsQEAllIteratorsMacro( Dnext ); + cpPluginsExtensionsQEAllIteratorsMacro( Oprev ); + cpPluginsExtensionsQEAllIteratorsMacro( Lprev ); + cpPluginsExtensionsQEAllIteratorsMacro( Rprev ); + cpPluginsExtensionsQEAllIteratorsMacro( Dprev ); + + public: + void CreateRings( ); + + /// First order access methods + inline TPrimal* GetOnext( ) + { return( this->m_Onext ); } + inline TDual* GetRot( ) + { return( this->m_Rot ); } + inline const TPrimal* GetOnext( ) const + { return( this->m_Onext ); } + inline const TDual* GetRot( ) const + { return( this->m_Rot ); } + + /// First order configuration methods + inline void SetOnext( TPrimal* e ) + { this->m_Onext = e; } + inline void SetRot( TDual* e ) + { this->m_Rot = e; } + + /// Second order accessors: around base rings + inline TPrimal* GetSym( ) + { return( this->m_Rot->m_Rot ); } + inline TDual* GetInvRot( ) + { return( this->m_Rot->m_Rot->m_Rot ); } + + /// Second order accessors: neighboring topology + inline TPrimal* GetLnext( ) + { return( this->m_Rot->m_Rot->m_Rot->m_Onext->m_Rot ); } + inline TPrimal* GetRnext( ) + { return( this->m_Rot->m_Onext->m_Rot->m_Rot->m_Rot ); } + inline TPrimal* GetDnext( ) + { return( this->m_Rot->m_Rot->m_Onext->m_Rot->m_Rot ); } + inline TPrimal* GetOprev( ) + { return( this->m_Rot->m_Onext->m_Rot ); } + inline TPrimal* GetLprev( ) + { return( this->m_Onext->m_Rot->m_Rot ); } + inline TPrimal* GetRprev( ) + { return( this->m_Rot->m_Rot->m_Onext ); } + inline TPrimal* GetDprev( ) + { + return( this->m_Rot->m_Rot->m_Rot->m_Onext->m_Rot->m_Rot->m_Rot ); + } + + /// Second order accessors: around base rings (const versions) + inline const TPrimal* GetSym( ) const + { return( this->m_Rot->m_Rot ); } + inline const TDual* GetInvRot( ) const + { return( this->m_Rot->m_Rot->m_Rot ); } + + /// Second order accessors: neighboring topology (const versions) + inline const TPrimal* GetLnext( ) const + { return( this->m_Rot->m_Rot->m_Rot->m_Onext->m_Rot ); } + inline const TPrimal* GetRnext( ) const + { return( this->m_Rot->m_Onext->m_Rot->m_Rot->m_Rot ); } + inline const TPrimal* GetDnext( ) const + { return( this->m_Rot->m_Rot->m_Onext->m_Rot->m_Rot ); } + inline const TPrimal* GetOprev( ) const + { return( this->m_Rot->m_Onext->m_Rot ); } + inline const TPrimal* GetLprev( ) const + { return( this->m_Onext->m_Rot->m_Rot ); } + inline const TPrimal* GetRprev( ) const + { return( this->m_Rot->m_Rot->m_Onext ); } + inline const TPrimal* GetDprev( ) const + { + return( this->m_Rot->m_Rot->m_Rot->m_Onext->m_Rot->m_Rot->m_Rot ); + } + + /// Get geometry methods + inline P& GetOrigin( ) + { return ( this->m_Origin ); } + inline P& GetDestination( ) + { return ( this->m_Rot->m_Rot->m_Origin ); } + inline D& GetRight( ) + { return ( this->m_Rot->m_Origin ); } + inline D& GetLeft( ) + { return ( this->m_Rot->m_Rot->m_Rot->m_Origin ); } + + /// Get geometry methods (const versions) + inline const P& GetOrigin( ) const + { return ( this->m_Origin ); } + inline const P& GetDestination( ) const + { return ( this->m_Rot->m_Rot->m_Origin ); } + inline const D& GetRight( ) const + { return ( this->m_Rot->m_Origin ); } + inline const D& GetLeft( ) const + { return ( this->m_Rot->m_Rot->m_Rot->m_Origin ); } + + /// Set geometry methods + inline void SetOrigin( const P& v ) + { this->m_Origin = v; } + inline void SetDestination( const P& v ) + { this->m_Rot->m_Rot->m_Origin = v; } + inline void SetRight( const D& v ) + { this->m_Rot->m_Origin = v; } + inline void SetLeft( const D& v ) + { this->m_Rot->m_Rot->m_Rot->m_Origin = v; } + inline void UnsetOrigin( ) + { this->m_Origin = TPrimal::NoGeometry; } + inline void UnsetDestination( ) + { this->m_Rot->m_Rot->m_Origin = TPrimal::NoGeometry; } + inline void UnsetRight( ) + { this->m_Rot->m_Origin = TDual::NoGeometry; } + inline void UnsetLeft( ) + { this->m_Rot->m_Rot->m_Rot->m_Origin = TDual::NoGeometry; } + + /** + * Set the Left( ) of all the edges in the Lnext( ) ring of "this" + * with the same given geometrical information. + * @param faceGeom Looks at most maxSize edges in the Lnext( ) ring. + * @return Returns true on success. False otherwise. + */ + void SetLnextRingGeometry( const D& v ); + void UnsetLnextRingGeometry( ); + + /// Topological queries + inline bool IsIsolated( ) const + { return( this == this->m_Onext ); } + bool IsEdgeInOnextRing( const TPrimal* e ) const; + bool IsEdgeInLnextRing( const TPrimal* e ) const; + unsigned int GetOnextRingSize( ) const; + unsigned int GetLnextRingSize( ) const; + + /** + * @return Returns true when "this" has no faces set on both sides. + * Return false otherwise. + */ + inline bool IsWire( ) + { return( !( this->IsLeftSet( ) ) && !( this->IsRightSet( ) ) ); } + + /** + * @return Returns true when "this" is on the boundary i.e. + * one and only one of the faces is set. Return false + * otherwise. + */ + inline bool IsAtBorder( ) const; + + /** + * @return Returns true when "this" has faces set on both sides. + * Return false otherwise. + */ + inline bool IsInternal( ) const + { return ( this->IsLeftSet( ) && this->IsRightSet( ) ); } + + /// Geometrical queries + inline bool IsOriginSet( ) const + { return ( this->m_Origin != Self::NoGeometry ); } + inline bool IsDestinationSet( ) const + { return ( this->m_Rot->m_Rot->IsOriginSet( ) ); } + inline bool IsRightSet( ) const + { return ( this->m_Rot->IsOriginSet( ) ); } + inline bool IsLeftSet( ) const + { return ( this->m_Rot->m_Rot->m_Rot->IsOriginSet( ) ); } + + /** + * \brief Check wether edge's Origin is internal to the mesh (as + * opposed to being on the boundary) by looking if all the edges + * in the Onext() ring have a face set on both their Left() and + * Right() side. + */ + bool IsOriginInternal( ) const; + + /** + * Definition: an edge is said to be a boundary edge when it is + * adjacent to i.e. when at least one of the faces edge->GetLeft() or + * edge->GetRight() is unset. Definition: an point is said to be a + * boundary point when at least one of the edges of it's Onext() ring + * is a boundary edge. + * + * Assume "this" edge belongs to a triangulation (i.e. it belongs to a + * QEMesh which represents a 2-manifold) which possesses a boundary. + * Assume "this" edge instance is a boundary edge. Let us denote by P + * the point which is the origin of "this" edge i.e. P is + * this->Origin(). By definition P is a boundary point. Then AT + * LEAST two [see the note below] edges of the Onext() ring of P + * [which all have the point P as Origin()] are themselves boundary + * edges. And among those boundary edges AT LEAST one has it's Left() + * face unset. By iterating over the Onext() ring (which defines a + * local ordering on edges) this method searches for the first edge + * whose Left() face is unset AND which is encountered AFTER edgeTest. + * + * @param edgeTest When present, this edge will be considered as + * the entry edge in the Onext() ring. When absent it shall + * be defaulted to "this" edge. (see the warning below). + * @return When "this" edge is a boundary edge, return the first + * edge in "this" Onext() ring whose Left() face is unset + * AND located after edgeTest. + * When "this" edge is NOT a boundary edge the 0 is + * returned. + * @warning When the Mesh possessing "this" edge is a 2-manifold + * then result of this method is unique in the sense that + * it is independent from the edgeTest parameter. + * But when the Mesh is not 2-manifold (this state can + * happen at intermediary stages of the building process, + * or during "surgical" operations on the Mesh, and + * even though the Mesh represents a triangulation) + * the result of this method is not unique in the sense + * that the result depends on the edgeTest parameter. + * Let us illusatre this dependence by considering a + * Mesh (which is a triangulation) which is not a 2-manifold. + * Assume the point P (the origin of "this" edge i.e. + * P = this->Originv()) is TWICE on the border i.e. it + * is adjacent twice to noface. We can consider the situation + * of the following diagram, which depicts some Onext() + * ring around point P: + * + * \ / // + * \ * / // + * i3 b2 counter-clockwise // + * * \ / NO FACE Onext() order. // + * \ / // + * ----b4-----P----b1------ // + * /|\ // + * NO FACE / | \ // + * / | \ * <------ a * indicates the // + * / | \ the presence of a face // + * / | \ // + * b5 i6 i7 // + * / * | * \ // + * / | \ // + * + * On this example, and if we assume the Onext() oder is + * represented counter-clockwise, the edges are ordered as + * follows: + * b1, b2, i3, b4, b5, i6, i7 + * (when arbitrarily starting at edge b1). + * We have four Boundary edges labeled b1, b2, b4, b5 and + * we have three internal edges (i.e. non boundary edges) + * labeled i3, i6 and i7. + * Depending on edgeTest, the result of this method + * will NOT return the same edge: + * - when edgeTest == b5 (or i6 or i7 or b1) then the edge + * b1 will be returned, + * - when edgeTest == b2 (or i3 or b4) then the edge + * b4 will be returned, + * Eventually, when edgeTest is absent, the result shall + * depend on the position of "this" in the Onext() ring(). + * + */ + TPrimal* GetNextBorderEdgeWithUnsetLeft( TPrimal* edge = NULL ) const; + + /** + * Assume "this->Originv()" is a boundary point P that is thrice + * adjacent to noface and consider the given situation is the one + * depicted by the following diagram where: + * - P is "this->Originv()" instance, + * - the * (star) indicates the presence of a face, + * - b1, b2, b3, b4, b5, b6 denote boundary edges, + * - p denotes some generic point, + * - A and B denote some specific points we want to discuss, + * - the Onext() ring order is represented counter-clockwise + * [which is coherent with the definition of edge->GetRigth()] + * i.e. the ordering of the edges is: + * b1, b2, b3, b4, b5, b6, b1... + * + * p N p + * / \ O / \ // + * / \ / \ // + * / \ F / \ counter-clockwise // + * / b3 A b2 \ Onext() ring order // + * / \ C / \ // + * / * \ E / * \ // + * / \ / \ // + * A------b4------P------b1-------B // + * / \ // + * / \ // + * NO FACE / \ NO FACE // + * / \ // + * b5 b6 // + * / * \ // + * / \ // + * p---------------p // + * + * At P this Mesh doesn't represent a 2-manifold (since we are thrice + * on the boundary). Nevertheless such a situation could arise in + * intermediary stages (e.g. when building the Mesh, or during + * surgical changes on the Mesh). + * Now, assume we are asked to build the triangle [P, A, B]. Note + * that this request is not absurd since the current situation at + * P isn't the one of a 2-manifold: hence when building the current + * Onext() ring of P, we had not enough information to decide + * wheter b4.Onext() should be b5 or b1. It is ONLY when we are + * required to build the triangle [P, A, B] that we have the + * additional information that b4.Onext() is indeed b1. + * When we are required to build triangle [P, A, B], we hence + * need to change the Onext() ring order at P, i.e. we need to deal + * with the triangle [P, b5, b6] which currently prevents + * b4.Onext() to be b1. In other terms, when considering the + * additional information that b4.Onext() is b1, and before + * building the triangle [P, A, B], we need to reorder + * the Onext() ring of P from it's current state + * b1, b2, b3, b4, b5, b6, b1... + * to an order coherent with the [P, A, B] request, i.e. + * b1, b2, b5, b6, b3, b4, b1... + * + * In order to establish the "proper" Onext() ring at P we use + * two Splice operations. The algorithm goes: + * - first disconnect the piece of the surface containing the edge + * [PB] (it would be the same process if we chose [PA]) from + * the Onext() ring at P. + * - second, re-integrate the disconnected piece at the desired + * location i.e. side by side with [PA] (respectively [PB] if + * we chose [PA] at first stage). + * By "piece of surface containing the edge [PB]" we mean [all] + * the triangle[s] starting at [PB] in the Onext() order and + * having a left face set. + * + * We can illustrate this process on bit more general diagram than + * the last case (where the "piece of surface containing the edge + * [PB]" is constituted by two triangles) and when using + * the arguments of this method (i.e. [PA] = this and [PB] = second). + * The initial stage is the following (we note first=this=[PA] and + * second=[PB]) where the Onext() ring order is: + * first, b2, b3, second, b5, bsplice, b7, first... + * + * p N A // + * / \ O / \ // + * / \ / \ // + * / \ F / \ counter-clockwise // + * / b2 A first \ Onext() ring order // + * / \ C / \ // + * / * \ E / * \ // + * / \ / \ // + * p-------b3------P------b7-------p // + * /|\ // + * / | \ // + * NO FACE / | \ NO FACE // + * / | \ // + * second b5 bsplice // + * / * | * \ // + * / | \ // + * B-------p-------p // + * + * The first stage, implemented as + * second->Oprev()->Splice( bsplice ), + * yields the following diagram: + * + * p N A // + * / \ O / \ // + * / \ F / \ // + * / \ A / \ counter-clockwise // + * / b2 C first \ Onext() ring order // + * / \ E / \ // + * / * \ / * \ // + * / \ / \ // + * p-------b3------P------b7-------p // + * // + * NO FACE // + * // + * /|\ // + * / | \ // + * / | \ // + * / | \ // + * second b5 bsplice // + * / * | * \ // + * / | \ // + * B-------p-------p // + * + * and the second stage, implemented as + * first->Splice( bsplice ), + * yields the following diagram: + * + * A // + * B__ NO FACE / \ // + * | \__ / \ // + * | \__ / \ counter- // + * | second first \ clockwise for all // + * | \__ / \ // + * | * \__ / * \ // + * | \ / \ // + * p-------b5---------P------b7-------p // + * | __/|\ // + * | * __/ | \ // + * | / | \ NO FACE // + * | bsplice | \ // + * | __/ b2 b3 // + * p__/ | * \ // + * NO FACE | \ // + * p-------p // + * + */ + inline static bool ReorderOnextRing( TPrimal* first, TPrimal* second ); + + /** + * \brief Basic quad-edge topological method. + * + * This method describes all possible topological operations on an + * edge since it is its own inverse. It works in two ways: + * + * 1. If this->m_Org != b->m_Org, it slice a face in two. + * 2. If this->m_Org == b->m_Org, it unifies two faces. + */ + inline static void Splice( TPrimal* a, TPrimal* b ); + + protected: + QuadEdge( ); + virtual ~QuadEdge( ); + + public: + static const TPrimalGeometry NoGeometry; + + protected: + Pointer m_Onext; /**< Onext ring */ + PtrDual m_Rot; /**< Rot ring */ + TPrimalGeometry m_Origin; /**< Geometry attached to edge's origin */ + }; + + } // ecapseman + + } // ecapseman + +} // ecapseman + +#include + +#endif // __CPPLUGINS__EXTENSIONS__DATASTRUCTURES__QUADEDGE__H__ + +// eof - $RCSfile$ diff --git a/lib/cpPlugins/Extensions/QuadEdge.hxx b/lib/cpPlugins/Extensions/DataStructures/QuadEdge.hxx similarity index 79% rename from lib/cpPlugins/Extensions/QuadEdge.hxx rename to lib/cpPlugins/Extensions/DataStructures/QuadEdge.hxx index e0dc302..6f7ff60 100644 --- a/lib/cpPlugins/Extensions/QuadEdge.hxx +++ b/lib/cpPlugins/Extensions/DataStructures/QuadEdge.hxx @@ -1,17 +1,18 @@ -#ifndef __CPPLUGINS__EXTENSIONS__QUADEDGE__HXX__ -#define __CPPLUGINS__EXTENSIONS__QUADEDGE__HXX__ +#ifndef __CPPLUGINS__EXTENSIONS__DATASTRUCTURES__QUADEDGE__HXX__ +#define __CPPLUGINS__EXTENSIONS__DATASTRUCTURES__QUADEDGE__HXX__ #include // ------------------------------------------------------------------------- template< typename P, typename D, bool IsPrimal > -const typename cpPlugins::Extensions::QuadEdge< P, D, IsPrimal >:: -TPrimalGeometry cpPlugins::Extensions::QuadEdge< P, D, IsPrimal >:: +const typename cpPlugins::Extensions::DataStructures:: +QuadEdge< P, D, IsPrimal >::TPrimalGeometry +cpPlugins::Extensions::DataStructures::QuadEdge< P, D, IsPrimal >:: NoGeometry = std::numeric_limits< P >::max( ); // ------------------------------------------------------------------------- template< typename P, typename D, bool IsPrimal > -void cpPlugins::Extensions::QuadEdge< P, D, IsPrimal >:: +void cpPlugins::Extensions::DataStructures::QuadEdge< P, D, IsPrimal >:: CreateRings( ) { TPrimal* e = this; @@ -32,7 +33,7 @@ CreateRings( ) // ------------------------------------------------------------------------- template< typename P, typename D, bool IsPrimal > -void cpPlugins::Extensions::QuadEdge< P, D, IsPrimal >:: +void cpPlugins::Extensions::DataStructures::QuadEdge< P, D, IsPrimal >:: SetLnextRingGeometry( const D& v ) { for( Iterator i = this->BeginLnext( ); i != this->EndLnext( ); ++i ) @@ -41,7 +42,7 @@ SetLnextRingGeometry( const D& v ) // ------------------------------------------------------------------------- template< typename P, typename D, bool IsPrimal > -void cpPlugins::Extensions::QuadEdge< P, D, IsPrimal >:: +void cpPlugins::Extensions::DataStructures::QuadEdge< P, D, IsPrimal >:: UnsetLnextRingGeometry( ) { this->SetLnextRingGeometry( TDual::NoGeometry ); @@ -49,7 +50,7 @@ UnsetLnextRingGeometry( ) // ------------------------------------------------------------------------- template< typename P, typename D, bool IsPrimal > -bool cpPlugins::Extensions::QuadEdge< P, D, IsPrimal >:: +bool cpPlugins::Extensions::DataStructures::QuadEdge< P, D, IsPrimal >:: IsEdgeInOnextRing( const TPrimal* e ) const { bool found = false; @@ -64,7 +65,7 @@ IsEdgeInOnextRing( const TPrimal* e ) const // ------------------------------------------------------------------------- template< typename P, typename D, bool IsPrimal > -bool cpPlugins::Extensions::QuadEdge< P, D, IsPrimal >:: +bool cpPlugins::Extensions::DataStructures::QuadEdge< P, D, IsPrimal >:: IsEdgeInLnextRing( const TPrimal* e ) const { bool found = false; @@ -79,7 +80,8 @@ IsEdgeInLnextRing( const TPrimal* e ) const // ------------------------------------------------------------------------- template< typename P, typename D, bool IsPrimal > -unsigned int cpPlugins::Extensions::QuadEdge< P, D, IsPrimal >:: +unsigned int +cpPlugins::Extensions::DataStructures::QuadEdge< P, D, IsPrimal >:: GetOnextRingSize( ) const { unsigned int count = 0; @@ -94,7 +96,8 @@ GetOnextRingSize( ) const // ------------------------------------------------------------------------- template< typename P, typename D, bool IsPrimal > -unsigned int cpPlugins::Extensions::QuadEdge< P, D, IsPrimal >:: +unsigned int +cpPlugins::Extensions::DataStructures::QuadEdge< P, D, IsPrimal >:: GetLnextRingSize( ) const { unsigned int count = 0; @@ -109,7 +112,7 @@ GetLnextRingSize( ) const // ------------------------------------------------------------------------- template< typename P, typename D, bool IsPrimal > -bool cpPlugins::Extensions::QuadEdge< P, D, IsPrimal >:: +bool cpPlugins::Extensions::DataStructures::QuadEdge< P, D, IsPrimal >:: IsAtBorder( ) const { return( @@ -120,7 +123,7 @@ IsAtBorder( ) const // ------------------------------------------------------------------------- template< typename P, typename D, bool IsPrimal > -bool cpPlugins::Extensions::QuadEdge< P, D, IsPrimal >:: +bool cpPlugins::Extensions::DataStructures::QuadEdge< P, D, IsPrimal >:: IsOriginInternal( ) const { bool internal = true; @@ -135,8 +138,8 @@ IsOriginInternal( ) const // ------------------------------------------------------------------------- template< typename P, typename D, bool IsPrimal > -typename cpPlugins::Extensions::QuadEdge< P, D, IsPrimal >:: -TPrimal* cpPlugins::Extensions::QuadEdge< P, D, IsPrimal >:: +typename cpPlugins::Extensions::DataStructures::QuadEdge< P, D, IsPrimal >:: +TPrimal* cpPlugins::Extensions::DataStructures::QuadEdge< P, D, IsPrimal >:: GetNextBorderEdgeWithUnsetLeft( TPrimal* edge ) const { // Be sure the Onext ring isn't already full @@ -162,7 +165,7 @@ GetNextBorderEdgeWithUnsetLeft( TPrimal* edge ) const // ------------------------------------------------------------------------- template< typename P, typename D, bool IsPrimal > -bool cpPlugins::Extensions::QuadEdge< P, D, IsPrimal >:: +bool cpPlugins::Extensions::DataStructures::QuadEdge< P, D, IsPrimal >:: ReorderOnextRing( TPrimal* first, TPrimal* second ) { // Making sure point adjacency is correct: @@ -194,7 +197,7 @@ ReorderOnextRing( TPrimal* first, TPrimal* second ) // ------------------------------------------------------------------------- template< typename P, typename D, bool IsPrimal > -void cpPlugins::Extensions::QuadEdge< P, D, IsPrimal >:: +void cpPlugins::Extensions::DataStructures::QuadEdge< P, D, IsPrimal >:: Splice( TPrimal* a, TPrimal* b ) { // Don't waste time splicing the same edge (or non-existent) @@ -218,7 +221,7 @@ Splice( TPrimal* a, TPrimal* b ) // ------------------------------------------------------------------------- template< typename P, typename D, bool IsPrimal > -cpPlugins::Extensions::QuadEdge< P, D, IsPrimal >:: +cpPlugins::Extensions::DataStructures::QuadEdge< P, D, IsPrimal >:: QuadEdge( ) : m_Origin( Self::NoGeometry ) { @@ -228,11 +231,11 @@ QuadEdge( ) // ------------------------------------------------------------------------- template< typename P, typename D, bool IsPrimal > -cpPlugins::Extensions::QuadEdge< P, D, IsPrimal >:: +cpPlugins::Extensions::DataStructures::QuadEdge< P, D, IsPrimal >:: ~QuadEdge( ) { } -#endif // __CPPLUGINS__EXTENSIONS__QUADEDGE__HXX__ +#endif // __CPPLUGINS__EXTENSIONS__DATASTRUCTURES__QUADEDGE__HXX__ // eof - $RCSfile$ diff --git a/lib/cpPlugins/Extensions/DataStructures/QuadEdgeCell.h b/lib/cpPlugins/Extensions/DataStructures/QuadEdgeCell.h new file mode 100644 index 0000000..ed8558e --- /dev/null +++ b/lib/cpPlugins/Extensions/DataStructures/QuadEdgeCell.h @@ -0,0 +1,128 @@ +#ifndef __CPPLUGINS__EXTENSIONS__DATASTRUCTURES__QUADEDGECELL__H__ +#define __CPPLUGINS__EXTENSIONS__DATASTRUCTURES__QUADEDGECELL__H__ + +#include + +namespace cpPlugins +{ + namespace Extensions + { + namespace DataStructures + { + /** + */ + template< class I, class E > + class QuadEdgeCell + : public I + { + public: + // Base types + typedef QuadEdgeCell Self; + typedef I Superclass; + typedef itk::AutoPointer< Self > SelfAutoPointer; + typedef itk::AutoPointer< const Self > ConstSelfAutoPointer; + typedef Self* RawPointer; + typedef const Self* ConstRawPointer; + + // QuadEdge objects + typedef E TPrimalEdge; + typedef typename E::TDual TDualEdge; + + // Inherited types + typedef typename I::PixelType PixelType; + typedef typename I::CellType CellType; + typedef typename I::CellAutoPointer CellAutoPointer; + typedef typename I::CellConstAutoPointer CellConstAutoPointer; + typedef typename I::CellRawPointer CellRawPointer; + typedef typename I::CellConstRawPointer CellConstRawPointer; + typedef typename I::CellTraits CellTraits; + typedef typename I::CoordRepType CoordRepType; + typedef typename I::InterpolationWeightType InterpolationWeightType; + typedef typename I::PointIdentifier PointIdentifier; + typedef typename I::PointIdIterator PointIdIterator; + typedef typename I::PointIdConstIterator PointIdConstIterator; + typedef typename I::CellIdentifier CellIdentifier; + typedef typename I::CellFeatureIdentifier CellFeatureIdentifier; + typedef typename I::CellFeatureIdentifier CellFeatureCount; + typedef typename I::PointType PointType; + typedef typename I::VectorType VectorType; + typedef typename I::PointsContainer PointsContainer; + typedef typename I::UsingCellsContainer UsingCellsContainer; + typedef typename I::CellGeometry CellGeometry; + typedef typename I::ParametricCoordArrayType ParametricCoordArrayType; + typedef typename I::ShapeFunctionsArrayType ShapeFunctionsArrayType; + + itkStaticConstMacro( PointDimension, unsigned int, I::PointDimension ); + itkStaticConstMacro( CellDimension, unsigned int, 2 ); + + public: + itkTypeMacro( QuadEdgeCell, I ); + + public: + QuadEdgeCell( ); + QuadEdgeCell( E* entry ); + virtual ~QuadEdgeCell( ); + + /// Implement the standard CellInterface. + virtual CellGeometry GetType( ) const; + virtual void MakeCopy( CellAutoPointer& other ) const; + virtual unsigned int GetDimension( ) const; + virtual unsigned int GetNumberOfPoints( ) const; + virtual CellFeatureCount GetNumberOfBoundaryFeatures( + int dimension + ) const; + virtual bool GetBoundaryFeature( + int dimension, CellFeatureIdentifier fId, CellAutoPointer& ptr + ); + virtual void SetPointIds( PointIdConstIterator first ); + virtual void SetPointIds( + PointIdConstIterator first, PointIdConstIterator last + ); + virtual void AddPointId( PointIdentifier pId ); + virtual void RemovePointId( PointIdentifier pId ); + virtual void SetPointIds( + int dummy, int num, PointIdConstIterator first + ); + virtual void BuildEdges( ); + virtual void ClearPoints( ); + virtual void SetPointId( int localId, PointIdentifier pId ); + + // Visitor methods + static int GetTopologyId( ); + virtual void Accept( + CellIdentifier cellid, + typename itk::CellInterface< PixelType, CellTraits >:: + MultiVisitor* mv + ); + + // Iterators + virtual PointIdIterator PointIdsBegin( ); + virtual PointIdConstIterator PointIdsBegin( ) const; + virtual PointIdIterator PointIdsEnd( ); + virtual PointIdConstIterator PointIdsEnd( ) const; + + /// QuadEdgeCell-specific interface. + virtual E* GetEntryPrimalEdge( ); + virtual const E* GetEntryPrimalEdge( ) const; + virtual void SetEntryPrimalEdge( E* entry ); + + private: + /// Purposely not implemented. + QuadEdgeCell( const Self& ); + Self& operator=( const Self& ); + + protected: + E* m_EntryEdge; + }; + + } // ecapseman + + } // ecapseman + +} // ecapseman + +#include + +#endif // __CPPLUGINS__EXTENSIONS__DATASTRUCTURES__QUADEDGECELL__H__ + +// eof - $RCSfile$ diff --git a/lib/cpPlugins/Extensions/QuadEdgeCell.hxx b/lib/cpPlugins/Extensions/DataStructures/QuadEdgeCell.hxx similarity index 69% rename from lib/cpPlugins/Extensions/QuadEdgeCell.hxx rename to lib/cpPlugins/Extensions/DataStructures/QuadEdgeCell.hxx index c474dc0..9b6fbc3 100644 --- a/lib/cpPlugins/Extensions/QuadEdgeCell.hxx +++ b/lib/cpPlugins/Extensions/DataStructures/QuadEdgeCell.hxx @@ -1,9 +1,9 @@ -#ifndef __CPPLUGINS__EXTENSIONS__QUADEDGECELL__HXX__ -#define __CPPLUGINS__EXTENSIONS__QUADEDGECELL__HXX__ +#ifndef __CPPLUGINS__EXTENSIONS__DATASTRUCTURES__QUADEDGECELL__HXX__ +#define __CPPLUGINS__EXTENSIONS__DATASTRUCTURES__QUADEDGECELL__HXX__ // ------------------------------------------------------------------------- template< class I, class E > -cpPlugins::Extensions::QuadEdgeCell< I, E >:: +cpPlugins::Extensions::DataStructures::QuadEdgeCell< I, E >:: QuadEdgeCell( ) : Superclass( ), m_EntryEdge( NULL ) @@ -12,7 +12,7 @@ QuadEdgeCell( ) // ------------------------------------------------------------------------- template< class I, class E > -cpPlugins::Extensions::QuadEdgeCell< I, E >:: +cpPlugins::Extensions::DataStructures::QuadEdgeCell< I, E >:: QuadEdgeCell( E* entry ) : Superclass( ), m_EntryEdge( entry ) @@ -22,15 +22,15 @@ QuadEdgeCell( E* entry ) // ------------------------------------------------------------------------- template< class I, class E > -cpPlugins::Extensions::QuadEdgeCell< I, E >:: +cpPlugins::Extensions::DataStructures::QuadEdgeCell< I, E >:: ~QuadEdgeCell( ) { } // ------------------------------------------------------------------------- template< class I, class E > -typename cpPlugins::Extensions::QuadEdgeCell< I, E >:: -CellGeometry cpPlugins::Extensions::QuadEdgeCell< I, E >:: +typename cpPlugins::Extensions::DataStructures::QuadEdgeCell< I, E >:: +CellGeometry cpPlugins::Extensions::DataStructures::QuadEdgeCell< I, E >:: GetType( ) const { std::cout << "QuadEdgeCell GetType" << std::endl; @@ -39,7 +39,7 @@ GetType( ) const // ------------------------------------------------------------------------- template< class I, class E > -void cpPlugins::Extensions::QuadEdgeCell< I, E >:: +void cpPlugins::Extensions::DataStructures::QuadEdgeCell< I, E >:: MakeCopy( CellAutoPointer& other ) const { std::cout << "QuadEdgeCell MakeCopy" << std::endl; @@ -48,7 +48,7 @@ MakeCopy( CellAutoPointer& other ) const // ------------------------------------------------------------------------- template< class I, class E > -unsigned int cpPlugins::Extensions::QuadEdgeCell< I, E >:: +unsigned int cpPlugins::Extensions::DataStructures::QuadEdgeCell< I, E >:: GetDimension( ) const { std::cout << "QuadEdgeCell GetDimension" << std::endl; @@ -57,7 +57,7 @@ GetDimension( ) const // ------------------------------------------------------------------------- template< class I, class E > -unsigned int cpPlugins::Extensions::QuadEdgeCell< I, E >:: +unsigned int cpPlugins::Extensions::DataStructures::QuadEdgeCell< I, E >:: GetNumberOfPoints( ) const { return( this->m_EntryEdge->GetLnextRingSize( ) ); @@ -65,8 +65,8 @@ GetNumberOfPoints( ) const // ------------------------------------------------------------------------- template< class I, class E > -typename cpPlugins::Extensions::QuadEdgeCell< I, E >:: -CellFeatureCount cpPlugins::Extensions::QuadEdgeCell< I, E >:: +typename cpPlugins::Extensions::DataStructures::QuadEdgeCell< I, E >:: +CellFeatureCount cpPlugins::Extensions::DataStructures::QuadEdgeCell< I, E >:: GetNumberOfBoundaryFeatures( int dimension ) const { std::cout << "QuadEdgeCell GetNumberOfBoundaryFeatures" << std::endl; @@ -75,7 +75,7 @@ GetNumberOfBoundaryFeatures( int dimension ) const // ------------------------------------------------------------------------- template< class I, class E > -bool cpPlugins::Extensions::QuadEdgeCell< I, E >:: +bool cpPlugins::Extensions::DataStructures::QuadEdgeCell< I, E >:: GetBoundaryFeature( int dimension, CellFeatureIdentifier fId, @@ -88,7 +88,7 @@ GetBoundaryFeature( // ------------------------------------------------------------------------- template< class I, class E > -void cpPlugins::Extensions::QuadEdgeCell< I, E >:: +void cpPlugins::Extensions::DataStructures::QuadEdgeCell< I, E >:: SetPointIds( PointIdConstIterator first ) { std::cout << "QuadEdgeCell SetPointIds" << std::endl; @@ -97,7 +97,7 @@ SetPointIds( PointIdConstIterator first ) // ------------------------------------------------------------------------- template< class I, class E > -void cpPlugins::Extensions::QuadEdgeCell< I, E >:: +void cpPlugins::Extensions::DataStructures::QuadEdgeCell< I, E >:: SetPointIds( PointIdConstIterator first, PointIdConstIterator last @@ -109,7 +109,7 @@ SetPointIds( // ------------------------------------------------------------------------- template< class I, class E > -void cpPlugins::Extensions::QuadEdgeCell< I, E >:: +void cpPlugins::Extensions::DataStructures::QuadEdgeCell< I, E >:: AddPointId( PointIdentifier pId ) { std::cout << "QuadEdgeCell AddPointId" << std::endl; @@ -118,7 +118,7 @@ AddPointId( PointIdentifier pId ) // ------------------------------------------------------------------------- template< class I, class E > -void cpPlugins::Extensions::QuadEdgeCell< I, E >:: +void cpPlugins::Extensions::DataStructures::QuadEdgeCell< I, E >:: RemovePointId( PointIdentifier pId ) { std::cout << "QuadEdgeCell RemovePointId" << std::endl; @@ -127,7 +127,7 @@ RemovePointId( PointIdentifier pId ) // ------------------------------------------------------------------------- template< class I, class E > -void cpPlugins::Extensions::QuadEdgeCell< I, E >:: +void cpPlugins::Extensions::DataStructures::QuadEdgeCell< I, E >:: SetPointIds( int dummy, int num, @@ -140,7 +140,7 @@ SetPointIds( // ------------------------------------------------------------------------- template< class I, class E > -void cpPlugins::Extensions::QuadEdgeCell< I, E >:: +void cpPlugins::Extensions::DataStructures::QuadEdgeCell< I, E >:: BuildEdges( ) { std::cout << "QuadEdgeCell BuildEdges" << std::endl; @@ -149,7 +149,7 @@ BuildEdges( ) // ------------------------------------------------------------------------- template< class I, class E > -void cpPlugins::Extensions::QuadEdgeCell< I, E >:: +void cpPlugins::Extensions::DataStructures::QuadEdgeCell< I, E >:: ClearPoints( ) { std::cout << "QuadEdgeCell ClearPoints" << std::endl; @@ -158,7 +158,7 @@ ClearPoints( ) // ------------------------------------------------------------------------- template< class I, class E > -void cpPlugins::Extensions::QuadEdgeCell< I, E >:: +void cpPlugins::Extensions::DataStructures::QuadEdgeCell< I, E >:: SetPointId( int localId, PointIdentifier pId ) { std::cout << "QuadEdgeCell SetPointId(localId,pId)" << std::endl; @@ -167,7 +167,7 @@ SetPointId( int localId, PointIdentifier pId ) // ------------------------------------------------------------------------- template< class I, class E > -int cpPlugins::Extensions::QuadEdgeCell< I, E >:: +int cpPlugins::Extensions::DataStructures::QuadEdgeCell< I, E >:: GetTopologyId( ) { // TODO: return( Superclass::POLYGON_CELL ); @@ -177,7 +177,7 @@ GetTopologyId( ) // ------------------------------------------------------------------------- template< class I, class E > -void cpPlugins::Extensions::QuadEdgeCell< I, E >:: +void cpPlugins::Extensions::DataStructures::QuadEdgeCell< I, E >:: Accept( CellIdentifier cellid, typename itk::CellInterface< PixelType, CellTraits >::MultiVisitor* mv @@ -189,8 +189,8 @@ Accept( // ------------------------------------------------------------------------- template< class I, class E > -typename cpPlugins::Extensions::QuadEdgeCell< I, E >:: -PointIdIterator cpPlugins::Extensions::QuadEdgeCell< I, E >:: +typename cpPlugins::Extensions::DataStructures::QuadEdgeCell< I, E >:: +PointIdIterator cpPlugins::Extensions::DataStructures::QuadEdgeCell< I, E >:: PointIdsBegin( ) { std::cout << "QuadEdgeCell PointIdsBegin" << std::endl; @@ -199,8 +199,9 @@ PointIdsBegin( ) // ------------------------------------------------------------------------- template< class I, class E > -typename cpPlugins::Extensions::QuadEdgeCell< I, E >:: -PointIdConstIterator cpPlugins::Extensions::QuadEdgeCell< I, E >:: +typename cpPlugins::Extensions::DataStructures::QuadEdgeCell< I, E >:: +PointIdConstIterator +cpPlugins::Extensions::DataStructures::QuadEdgeCell< I, E >:: PointIdsBegin( ) const { std::cout << "QuadEdgeCell PointIdsBegin (const)" << std::endl; @@ -209,8 +210,8 @@ PointIdsBegin( ) const // ------------------------------------------------------------------------- template< class I, class E > -typename cpPlugins::Extensions::QuadEdgeCell< I, E >:: -PointIdIterator cpPlugins::Extensions::QuadEdgeCell< I, E >:: +typename cpPlugins::Extensions::DataStructures::QuadEdgeCell< I, E >:: +PointIdIterator cpPlugins::Extensions::DataStructures::QuadEdgeCell< I, E >:: PointIdsEnd( ) { std::cout << "QuadEdgeCell PointIdsEnd" << std::endl; @@ -219,8 +220,9 @@ PointIdsEnd( ) // ------------------------------------------------------------------------- template< class I, class E > -typename cpPlugins::Extensions::QuadEdgeCell< I, E >:: -PointIdConstIterator cpPlugins::Extensions::QuadEdgeCell< I, E >:: +typename cpPlugins::Extensions::DataStructures::QuadEdgeCell< I, E >:: +PointIdConstIterator +cpPlugins::Extensions::DataStructures::QuadEdgeCell< I, E >:: PointIdsEnd( ) const { std::cout << "QuadEdgeCell PointIdsEnd (const)" << std::endl; @@ -229,7 +231,7 @@ PointIdsEnd( ) const // ------------------------------------------------------------------------- template< class I, class E > -E* cpPlugins::Extensions::QuadEdgeCell< I, E >:: +E* cpPlugins::Extensions::DataStructures::QuadEdgeCell< I, E >:: GetEntryPrimalEdge( ) { return( this->m_EntryEdge ); @@ -237,7 +239,7 @@ GetEntryPrimalEdge( ) // ------------------------------------------------------------------------- template< class I, class E > -const E* cpPlugins::Extensions::QuadEdgeCell< I, E >:: +const E* cpPlugins::Extensions::DataStructures::QuadEdgeCell< I, E >:: GetEntryPrimalEdge( ) const { return( this->m_EntryEdge ); @@ -245,12 +247,12 @@ GetEntryPrimalEdge( ) const // ------------------------------------------------------------------------- template< class I, class E > -void cpPlugins::Extensions::QuadEdgeCell< I, E >:: +void cpPlugins::Extensions::DataStructures::QuadEdgeCell< I, E >:: SetEntryPrimalEdge( E* entry ) { this->m_EntryEdge = entry; } -#endif // __CPPLUGINS__EXTENSIONS__QUADEDGECELL__HXX__ +#endif // __CPPLUGINS__EXTENSIONS__DATASTRUCTURES__QUADEDGECELL__HXX__ // eof - $RCSfile$ diff --git a/lib/cpPlugins/Extensions/DataStructures/QuadEdgeIterators.h b/lib/cpPlugins/Extensions/DataStructures/QuadEdgeIterators.h new file mode 100644 index 0000000..7ba20f0 --- /dev/null +++ b/lib/cpPlugins/Extensions/DataStructures/QuadEdgeIterators.h @@ -0,0 +1,175 @@ +#ifndef __CPPLUGINS__EXTENSIONS__DATASTRUCTURES__QUADEDGEITERATORS__H__ +#define __CPPLUGINS__EXTENSIONS__DATASTRUCTURES__QUADEDGEITERATORS__H__ + +#include + +// ------------------------------------------------------------------------- +#define cpPluginsQEIteratorsMacro( op, it, cit ) \ + inline it Begin##op( ) \ + { return( it( this, it::Op##op, true ) ); } \ + inline it End##op( ) \ + { return( it( this, it::Op##op, false ) ); } \ + inline cit Begin##op( ) const \ + { return( cit( this, cit::Op##op, true ) ); } \ + inline cit End##op( ) const \ + { return( cit( this, cit::Op##op, false ) ); } + +// ------------------------------------------------------------------------- +#define cpPluginsExtensionsQEPointIteratorsMacro( op, it, cit ) \ + inline Point##it BeginPoint##op( ) \ + { return( Point##it( this, it::Op##op, true ) ); } \ + inline Point##it EndPoint##op( ) \ + { return( Point##it( this, it::Op##op, false ) ); } \ + inline Point##cit BeginPoint##op( ) const \ + { return( Point##cit( this, cit::Op##op, true ) ); } \ + inline Point##cit EndPoint ##op( ) const \ + { return( Point##cit( this, cit::Op##op, false ) ); } + +// ------------------------------------------------------------------------- +#define cpPluginsExtensionsQEAllIteratorsMacro( op ) \ + cpPluginsQEIteratorsMacro( op, Iterator, ConstIterator ); \ + cpPluginsExtensionsQEPointIteratorsMacro( op, Iterator, ConstIterator ); + +namespace cpPlugins +{ + namespace Extensions + { + namespace DataStructures + { + /** + */ + template< class E > + class QuadEdgeBaseIterator + { + public: + typedef QuadEdgeBaseIterator Self; + typedef E TQuadEdge; + + // Different types of logical iterators + enum + { + OpOnext = 0, + OpLnext = 1, + OpRnext = 2, + OpDnext = 3, + OpOprev = 4, + OpLprev = 5, + OpRprev = 6, + OpDprev = 7 + }; + + public: + QuadEdgeBaseIterator( E* e, int op = OpOnext, bool start = true ); + virtual ~QuadEdgeBaseIterator( ); + Self& operator=( const Self& r ); + + E* GetStartEdge( ) const; + E* GetIterator( ) const; + int GetOpType( ) const; + bool GetStart( ) const; + + bool operator==( Self& r ); + bool operator==( const Self& r ) const; + bool operator!=( Self& r ); + bool operator!=( const Self& r ) const; + Self& operator++( ); + Self& operator++( int ); + + protected: + /// Method that should do all the iteration work + virtual void _GoToNext( ); + + protected: + E* m_StartEdge; /**< Start edge */ + E* m_Iterator; /**< Current iteration position */ + int m_OpType; /**< Operation type */ + bool m_Start; /**< Indicates iteration has just started */ + }; + + /** + */ + template< class E > + class QuadEdgeIterator + : public QuadEdgeBaseIterator< E > + { + public: + typedef QuadEdgeIterator Self; + typedef QuadEdgeBaseIterator< E > Superclass; + typedef E TQuadEdge; + + public: + QuadEdgeIterator( + E* e = NULL, int op = Superclass::OpOnext, bool start = true + ); + virtual ~QuadEdgeIterator( ); + E* operator*( ); + }; + + /** + */ + template< class E > + class QuadEdgeConstIterator + : public QuadEdgeBaseIterator< const E > + { + public: + typedef QuadEdgeConstIterator Self; + typedef QuadEdgeBaseIterator< const E > Superclass; + typedef E TQuadEdge; + + public: + QuadEdgeConstIterator( + const E* e = NULL, int op = Superclass::OpOnext, bool start = true + ); + virtual ~QuadEdgeConstIterator( ); + const E* operator*( ) const; + }; + + /** + */ + template< class E > + class QuadEdgePointIterator + : public QuadEdgeBaseIterator< const E > + { + public: + typedef QuadEdgePointIterator Self; + typedef QuadEdgeBaseIterator< const E > Superclass; + typedef E TQuadEdge; + + public: + QuadEdgePointIterator( + const E* e = NULL, int op = Superclass::OpOnext, bool start = true + ); + virtual ~QuadEdgePointIterator( ); + typename E::TPrimalGeometry& operator*( ); + }; + + /** + */ + template< class E > + class QuadEdgePointConstIterator + : public QuadEdgeBaseIterator< const E > + { + public: + typedef QuadEdgePointConstIterator Self; + typedef QuadEdgeBaseIterator< const E > Superclass; + typedef E TQuadEdge; + + public: + QuadEdgePointConstIterator( + const E* e = NULL, int op = Superclass::OpOnext, bool start = true + ); + virtual ~QuadEdgePointConstIterator( ); + const typename E::TPrimalGeometry& operator*( ) const; + }; + + } // ecapseman + + } // ecapseman + +} // ecapseman + +#include + +#endif // __CPPLUGINS__EXTENSIONS__DATASTRUCTURES__QUADEDGEITERATORS__H__ + +// eof - $RCSfile$ diff --git a/lib/cpPlugins/Extensions/QuadEdgeIterators.hxx b/lib/cpPlugins/Extensions/DataStructures/QuadEdgeIterators.hxx similarity index 71% rename from lib/cpPlugins/Extensions/QuadEdgeIterators.hxx rename to lib/cpPlugins/Extensions/DataStructures/QuadEdgeIterators.hxx index f519ca4..874292f 100644 --- a/lib/cpPlugins/Extensions/QuadEdgeIterators.hxx +++ b/lib/cpPlugins/Extensions/DataStructures/QuadEdgeIterators.hxx @@ -1,9 +1,9 @@ -#ifndef __CPPLUGINS__EXTENSIONS__QUADEDGEITERATORS__HXX__ -#define __CPPLUGINS__EXTENSIONS__QUADEDGEITERATORS__HXX__ +#ifndef __CPPLUGINS__EXTENSIONS__DATASTRUCTURES__QUADEDGEITERATORS__HXX__ +#define __CPPLUGINS__EXTENSIONS__DATASTRUCTURES__QUADEDGEITERATORS__HXX__ // ------------------------------------------------------------------------- template< class E > -cpPlugins::Extensions::QuadEdgeBaseIterator< E >:: +cpPlugins::Extensions::DataStructures::QuadEdgeBaseIterator< E >:: QuadEdgeBaseIterator( E* e, int op, bool start ) : m_StartEdge( e ), m_Iterator( e ), @@ -14,15 +14,15 @@ QuadEdgeBaseIterator( E* e, int op, bool start ) // ------------------------------------------------------------------------- template< class E > -cpPlugins::Extensions::QuadEdgeBaseIterator< E >:: +cpPlugins::Extensions::DataStructures::QuadEdgeBaseIterator< E >:: ~QuadEdgeBaseIterator( ) { } // ------------------------------------------------------------------------- template< class E > -typename cpPlugins::Extensions::QuadEdgeBaseIterator< E >:: -Self& cpPlugins::Extensions::QuadEdgeBaseIterator< E >:: +typename cpPlugins::Extensions::DataStructures::QuadEdgeBaseIterator< E >:: +Self& cpPlugins::Extensions::DataStructures::QuadEdgeBaseIterator< E >:: operator=( const Self& r ) { if( this != &r ) @@ -38,7 +38,7 @@ operator=( const Self& r ) // ------------------------------------------------------------------------- template< class E > -E* cpPlugins::Extensions::QuadEdgeBaseIterator< E >:: +E* cpPlugins::Extensions::DataStructures::QuadEdgeBaseIterator< E >:: GetStartEdge( ) const { return( this->m_StartEdge ); @@ -46,7 +46,7 @@ GetStartEdge( ) const // ------------------------------------------------------------------------- template< class E > -E* cpPlugins::Extensions::QuadEdgeBaseIterator< E >:: +E* cpPlugins::Extensions::DataStructures::QuadEdgeBaseIterator< E >:: GetIterator( ) const { return( this->m_Iterator ); @@ -54,7 +54,7 @@ GetIterator( ) const // ------------------------------------------------------------------------- template< class E > -int cpPlugins::Extensions::QuadEdgeBaseIterator< E >:: +int cpPlugins::Extensions::DataStructures::QuadEdgeBaseIterator< E >:: GetOpType( ) const { return( this->m_OpType ); @@ -62,7 +62,7 @@ GetOpType( ) const // ------------------------------------------------------------------------- template< class E > -bool cpPlugins::Extensions::QuadEdgeBaseIterator< E >:: +bool cpPlugins::Extensions::DataStructures::QuadEdgeBaseIterator< E >:: GetStart( ) const { return( this->m_Start ); @@ -70,7 +70,7 @@ GetStart( ) const // ------------------------------------------------------------------------- template< class E > -bool cpPlugins::Extensions::QuadEdgeBaseIterator< E >:: +bool cpPlugins::Extensions::DataStructures::QuadEdgeBaseIterator< E >:: operator==( Self& r ) { return( @@ -83,7 +83,7 @@ operator==( Self& r ) // ------------------------------------------------------------------------- template< class E > -bool cpPlugins::Extensions::QuadEdgeBaseIterator< E >:: +bool cpPlugins::Extensions::DataStructures::QuadEdgeBaseIterator< E >:: operator==( const Self& r ) const { return( @@ -96,7 +96,7 @@ operator==( const Self& r ) const // ------------------------------------------------------------------------- template< class E > -bool cpPlugins::Extensions::QuadEdgeBaseIterator< E >:: +bool cpPlugins::Extensions::DataStructures::QuadEdgeBaseIterator< E >:: operator!=( Self& r ) { return( !( this->operator==( r ) ) ); @@ -104,7 +104,7 @@ operator!=( Self& r ) // ------------------------------------------------------------------------- template< class E > -bool cpPlugins::Extensions::QuadEdgeBaseIterator< E >:: +bool cpPlugins::Extensions::DataStructures::QuadEdgeBaseIterator< E >:: operator!=( const Self& r ) const { return( !( this->operator==( r ) ) ); @@ -112,8 +112,8 @@ operator!=( const Self& r ) const // ------------------------------------------------------------------------- template< class E > -typename cpPlugins::Extensions::QuadEdgeBaseIterator< E >:: -Self& cpPlugins::Extensions::QuadEdgeBaseIterator< E >:: +typename cpPlugins::Extensions::DataStructures::QuadEdgeBaseIterator< E >:: +Self& cpPlugins::Extensions::DataStructures::QuadEdgeBaseIterator< E >:: operator++( ) { if( this->m_Start ) @@ -127,8 +127,8 @@ operator++( ) // ------------------------------------------------------------------------- template< class E > -typename cpPlugins::Extensions::QuadEdgeBaseIterator< E >:: -Self& cpPlugins::Extensions::QuadEdgeBaseIterator< E >:: +typename cpPlugins::Extensions::DataStructures::QuadEdgeBaseIterator< E >:: +Self& cpPlugins::Extensions::DataStructures::QuadEdgeBaseIterator< E >:: operator++( int ) { if( this->m_Start ) @@ -142,7 +142,7 @@ operator++( int ) // ------------------------------------------------------------------------- template< class E > -void cpPlugins::Extensions::QuadEdgeBaseIterator< E >:: +void cpPlugins::Extensions::DataStructures::QuadEdgeBaseIterator< E >:: _GoToNext( ) { switch( this->m_OpType ) @@ -178,7 +178,7 @@ _GoToNext( ) // ------------------------------------------------------------------------- template< class E > -cpPlugins::Extensions::QuadEdgeIterator< E >:: +cpPlugins::Extensions::DataStructures::QuadEdgeIterator< E >:: QuadEdgeIterator( E* e, int op, bool start ) : Superclass( e, op, start ) { @@ -186,14 +186,14 @@ QuadEdgeIterator( E* e, int op, bool start ) // ------------------------------------------------------------------------- template< class E > -cpPlugins::Extensions::QuadEdgeIterator< E >:: +cpPlugins::Extensions::DataStructures::QuadEdgeIterator< E >:: ~QuadEdgeIterator( ) { } // ------------------------------------------------------------------------- template< class E > -E* cpPlugins::Extensions::QuadEdgeIterator< E >:: +E* cpPlugins::Extensions::DataStructures::QuadEdgeIterator< E >:: operator*( ) { return( this->m_Iterator ); @@ -201,7 +201,7 @@ operator*( ) // ------------------------------------------------------------------------- template< class E > -cpPlugins::Extensions::QuadEdgeConstIterator< E >:: +cpPlugins::Extensions::DataStructures::QuadEdgeConstIterator< E >:: QuadEdgeConstIterator( const E* e, int op, bool start ) : Superclass( e, op, start ) { @@ -209,14 +209,14 @@ QuadEdgeConstIterator( const E* e, int op, bool start ) // ------------------------------------------------------------------------- template< class E > -cpPlugins::Extensions::QuadEdgeConstIterator< E >:: +cpPlugins::Extensions::DataStructures::QuadEdgeConstIterator< E >:: ~QuadEdgeConstIterator( ) { } // ------------------------------------------------------------------------- template< class E > -const E* cpPlugins::Extensions::QuadEdgeConstIterator< E >:: +const E* cpPlugins::Extensions::DataStructures::QuadEdgeConstIterator< E >:: operator*( ) const { return( this->m_Iterator ); @@ -224,7 +224,7 @@ operator*( ) const // ------------------------------------------------------------------------- template< class E > -cpPlugins::Extensions::QuadEdgePointIterator< E >:: +cpPlugins::Extensions::DataStructures::QuadEdgePointIterator< E >:: QuadEdgePointIterator( const E* e, int op, bool start ) : Superclass( e, op, start ) { @@ -232,7 +232,7 @@ QuadEdgePointIterator( const E* e, int op, bool start ) // ------------------------------------------------------------------------- template< class E > -cpPlugins::Extensions::QuadEdgePointIterator< E >:: +cpPlugins::Extensions::DataStructures::QuadEdgePointIterator< E >:: ~QuadEdgePointIterator( ) { } @@ -240,7 +240,7 @@ cpPlugins::Extensions::QuadEdgePointIterator< E >:: // ------------------------------------------------------------------------- template< class E > typename E::TPrimalGeometry& -cpPlugins::Extensions::QuadEdgePointIterator< E >:: +cpPlugins::Extensions::DataStructures::QuadEdgePointIterator< E >:: operator*( ) { return( this->m_Iterator->GetOrigin( ) ); @@ -248,7 +248,7 @@ operator*( ) // ------------------------------------------------------------------------- template< class E > -cpPlugins::Extensions::QuadEdgePointConstIterator< E >:: +cpPlugins::Extensions::DataStructures::QuadEdgePointConstIterator< E >:: QuadEdgePointConstIterator( const E* e, int op, bool start ) : Superclass( e, op, start ) { @@ -256,7 +256,7 @@ QuadEdgePointConstIterator( const E* e, int op, bool start ) // ------------------------------------------------------------------------- template< class E > -cpPlugins::Extensions::QuadEdgePointConstIterator< E >:: +cpPlugins::Extensions::DataStructures::QuadEdgePointConstIterator< E >:: ~QuadEdgePointConstIterator( ) { } @@ -264,12 +264,12 @@ cpPlugins::Extensions::QuadEdgePointConstIterator< E >:: // ------------------------------------------------------------------------- template< class E > const typename E::TPrimalGeometry& -cpPlugins::Extensions::QuadEdgePointConstIterator< E >:: +cpPlugins::Extensions::DataStructures::QuadEdgePointConstIterator< E >:: operator*( ) const { return( this->m_Iterator->GetOrigin( ) ); } -#endif // __CPPLUGINS__EXTENSIONS__QUADEDGEITERATORS__HXX__ +#endif // __CPPLUGINS__EXTENSIONS__DATASTRUCTURES__QUADEDGEITERATORS__HXX__ // eof - $RCSfile$ diff --git a/lib/cpPlugins/Extensions/DataStructures/QuadEdgeMesh.h b/lib/cpPlugins/Extensions/DataStructures/QuadEdgeMesh.h new file mode 100644 index 0000000..c93d465 --- /dev/null +++ b/lib/cpPlugins/Extensions/DataStructures/QuadEdgeMesh.h @@ -0,0 +1,287 @@ +#ifndef __CPPLUGINS__EXTENSIONS__DATASTRUCTURES__QUADEDGEMESH__H__ +#define __CPPLUGINS__EXTENSIONS__DATASTRUCTURES__QUADEDGEMESH__H__ + +#include +#include + +#include +#include +#include + +namespace cpPlugins +{ + namespace Extensions + { + namespace DataStructures + { + /** + */ + template< typename P, unsigned int D = 3, typename T = itk::DefaultStaticMeshTraits< P, D, D > > + class QuadEdgeMesh + : public itk::Mesh< P, D, T > + { + public: + typedef QuadEdgeMesh Self; + typedef itk::Mesh< P, D, T > Superclass; + typedef itk::SmartPointer< Self > Pointer; + typedef itk::SmartPointer< const Self > ConstPointer; + + /// Types from superclass + typedef typename + Superclass::BoundaryAssignmentsContainer + BoundaryAssignmentsContainer; + + typedef typename + Superclass::BoundaryAssignmentsContainerPointer + BoundaryAssignmentsContainerPointer; + + typedef typename Superclass::BoundingBoxType BoundingBoxType; + typedef typename Superclass::CellAutoPointer CellAutoPointer; + typedef typename Superclass::CellsContainer CellsContainer; + typedef typename Superclass::CellDataContainer CellDataContainer; + typedef typename Superclass::CellFeatureCount CellFeatureCount; + typedef typename Superclass::CellFeatureIdentifier CellFeatureIdentifier; + typedef typename Superclass::CellIdentifier CellIdentifier; + typedef typename Superclass::CellLinksContainer CellLinksContainer; + typedef typename Superclass::CellMultiVisitorType CellMultiVisitorType; + typedef typename Superclass::CellPixelType CellPixelType; + typedef typename Superclass::CellType CellType; + typedef typename Superclass::PointIdentifier PointIdentifier; + typedef typename Superclass::PointsContainer PointsContainer; + typedef typename Superclass::PointType PointType; + + /// QuadEdge types (primal and dual) + typedef QuadEdge< PointIdentifier, CellIdentifier > TPrimalEdge; + typedef typename TPrimalEdge::TDual TDualEdge; + typedef QuadEdgeCell< CellType, TPrimalEdge > TQuadEdgeCell; + + /// Memory management objects + typedef std::set< typename TPrimalEdge::Pointer > CntPrimalEdges; + typedef std::set< typename TDualEdge::Pointer > CntDualEdges; + typedef std::vector< TPrimalEdge* > CntOnextRings; + + /// More geometry types + typedef typename PointType::VectorType VectorType; + typedef typename VectorType::ValueType TScalar; + typedef std::vector< VectorType > CntNormals; + typedef typename CntNormals::const_iterator NormalsIterator; + + protected: + typedef std::vector< TPrimalEdge* > _TEdges; + + public: + itkNewMacro( Self ); + itkTypeMacro( QuadEdgeMesh, itkMesh ); + + public: + // Edge related methods + TPrimalEdge* FindEdge( const PointIdentifier& a ) const; + TPrimalEdge* FindEdge( + const PointIdentifier& a, const PointIdentifier& b + ) const; + TPrimalEdge* FindEntryEdge( const CellIdentifier& i ) const; + + /// New geometric methods + const CntNormals& GetPointNormalsContainer( ) const; + NormalsIterator BeginPointNormals( ) const; + NormalsIterator EndPointNormals( ) const; + const VectorType& GetPointNormal( const PointIdentifier& id ) const; + + /// itk::DataObject methods overloading + virtual bool RequestedRegionIsOutsideOfTheBufferedRegion( ); + + /// itk::PointSet methods overloading + virtual void SetPoints( PointsContainer* points ); + virtual void SetPoint( PointIdentifier id , PointType point ); + + /// itk::Mesh methods overloading + virtual void PassStructure( Self* inputMesh ) + { + std::cout << "PassStructure" << std::endl; + std::exit( 1 ); + } + + virtual void Initialize( ); + virtual void Graft( const itk::DataObject* data ); + + void SetCellLinks( CellLinksContainer* cellLinks ) + { + std::cout << "SetCellLinks" << std::endl; + std::exit( 1 ); + } + virtual CellLinksContainer* GetCellLinks( ) + { + std::cout << "GetCellLinks" << std::endl; + std::exit( 1 ); + } + virtual const CellLinksContainer* GetCellLinks( ) const + { + std::cout << "GetCellLinks (const)" << std::endl; + std::exit( 1 ); + } + virtual void SetCells( CellsContainer* cells ); + virtual void SetCellData( CellDataContainer* data ); + virtual CellDataContainer* GetCellData( ) + { + std::cout << "GetCellData" << std::endl; + std::exit( 1 ); + } + virtual const CellDataContainer* GetCellData( ) const + { + std::cout << "GetCellData (const)" << std::endl; + std::exit( 1 ); + } + +#if !defined( CABLE_CONFIGURATION ) + virtual void SetBoundaryAssignments( + int dimension, BoundaryAssignmentsContainer* container + ) + { + std::cout << "SetBoundaryAssignments" << std::endl; + std::exit( 1 ); + } + virtual BoundaryAssignmentsContainerPointer + GetBoundaryAssignments( int dimension ) + { + std::cout << "GetBoundaryAssignments" << std::endl; + std::exit( 1 ); + } + virtual const BoundaryAssignmentsContainerPointer + GetBoundaryAssignments( int dimension ) const + { + std::cout << "GetBoundaryAssignments (const)" << std::endl; + std::exit( 1 ); + } +#endif + + virtual void SetCell( CellIdentifier id, CellAutoPointer& ptr ); + virtual void SetCellData( CellIdentifier id, CellPixelType data ); + virtual bool GetCellData( CellIdentifier id, CellPixelType* data ) const + { + std::cout << "GetCellData" << std::endl; + std::exit( 1 ); + } + virtual void SetBoundaryAssignment( + int dimension, CellIdentifier cellId, + CellFeatureIdentifier featureId, + CellIdentifier boundaryId + ) + { + std::cout << "SetBoundaryAssignment" << std::endl; + std::exit( 1 ); + } + virtual bool GetBoundaryAssignment( + int dimension, CellIdentifier cellId, + CellFeatureIdentifier featureId, + CellIdentifier* boundaryId + ) const + { + std::cout << "GetBoundaryAssignment" << std::endl; + std::exit( 1 ); + } + virtual bool RemoveBoundaryAssignment( + int dimension, CellIdentifier cellId, + CellFeatureIdentifier featureId + ) + { + std::cout << "RemoveBoundaryAssignment" << std::endl; + std::exit( 1 ); + } + virtual CellFeatureCount GetNumberOfCellBoundaryFeatures( + int dimension, + CellIdentifier id + ) const + { + std::cout << "GetNumberOfCellBoundaryFeatures" << std::endl; + std::exit( 1 ); + } + virtual bool GetCellBoundaryFeature( + int dimension, CellIdentifier id, + CellFeatureIdentifier fid, + CellAutoPointer& ptr + ) const + { + std::cout << "GetCellBoundaryFeature" << std::endl; + std::exit( 1 ); + } + virtual CellIdentifier GetCellBoundaryFeatureNeighbors( + int dimension, + CellIdentifier id, + CellFeatureIdentifier fid, + std::set< CellIdentifier >* cellSet ) + { + std::cout << "GetCellBoundaryFeatureNeighbors" << std::endl; + std::exit( 1 ); + } + virtual CellIdentifier GetCellNeighbors( + CellIdentifier cellId, + std::set< CellIdentifier >* cellSet + ) + { + std::cout << "GetCellNeighbors" << std::endl; + std::exit( 1 ); + } + virtual bool GetAssignedCellBoundaryIfOneExists( + int dimension, CellIdentifier id, + CellFeatureIdentifier fid, + CellAutoPointer& ptr + ) const + { + std::cout << "GetAssignedCellBoundaryIfOneExists" << std::endl; + std::exit( 1 ); + } + virtual void BuildCellLinks( ) const; + + virtual void Accept( CellMultiVisitorType* mv ) const + { + std::cout << "Accept" << std::endl; + std::exit( 1 ); + } + + protected: + QuadEdgeMesh( ); + virtual ~QuadEdgeMesh( ); + + virtual void ReleaseCellsMemory( ) + { + std::cout << "ReleaseCellsMemory" << std::endl; + std::exit( 1 ); + } + + inline bool _CheckPoints( const CellAutoPointer& ptr ) const; + inline void _DeletePoint( const PointIdentifier& pId ); + inline TPrimalEdge* _CreateQuadEdge( + const PointIdentifier& a, const PointIdentifier& b + ); + inline void _DeleteEdge( TPrimalEdge* edge ); + inline void _DeleteFace( const CellIdentifier& f ); + inline void _ConstructEdges( + _TEdges& edges, const CellAutoPointer& ptr + ); + virtual VectorType _ComputePointNormal( const TPrimalEdge* e ) const; + inline void _ReleaseQuadEdgeObjects( ); + + private: + QuadEdgeMesh( const Self& ); // Not implemented + void operator=( const Self& ); // Not implemented + + protected: + CntPrimalEdges m_PrimalEdges; + CntDualEdges m_DualEdges; + + CntOnextRings m_OnextRings; + + CntNormals m_PointNormals; + }; + + } // ecapseman + + } // ecapseman + +} // ecapseman + +#include + +#endif // __CPPLUGINS__EXTENSIONS__DATASTRUCTURES__QUADEDGEMESH__H__ + +// eof - $RCSfile$ diff --git a/lib/cpPlugins/Extensions/QuadEdgeMesh.hxx b/lib/cpPlugins/Extensions/DataStructures/QuadEdgeMesh.hxx similarity index 83% rename from lib/cpPlugins/Extensions/QuadEdgeMesh.hxx rename to lib/cpPlugins/Extensions/DataStructures/QuadEdgeMesh.hxx index 31b39d3..cfcf232 100644 --- a/lib/cpPlugins/Extensions/QuadEdgeMesh.hxx +++ b/lib/cpPlugins/Extensions/DataStructures/QuadEdgeMesh.hxx @@ -1,10 +1,10 @@ -#ifndef __CPPLUGINS__EXTENSIONS__QUADEDGEMESH__HXX__ -#define __CPPLUGINS__EXTENSIONS__QUADEDGEMESH__HXX__ +#ifndef __CPPLUGINS__EXTENSIONS__DATASTRUCTURES__QUADEDGEMESH__HXX__ +#define __CPPLUGINS__EXTENSIONS__DATASTRUCTURES__QUADEDGEMESH__HXX__ // ------------------------------------------------------------------------- template< typename P, unsigned int D, typename T > -typename cpPlugins::Extensions::QuadEdgeMesh< P, D, T >:: -TPrimalEdge* cpPlugins::Extensions::QuadEdgeMesh< P, D, T >:: +typename cpPlugins::Extensions::DataStructures::QuadEdgeMesh< P, D, T >:: +TPrimalEdge* cpPlugins::Extensions::DataStructures::QuadEdgeMesh< P, D, T >:: FindEdge( const PointIdentifier& a ) const { if( a < this->m_OnextRings.size( ) ) @@ -15,8 +15,8 @@ FindEdge( const PointIdentifier& a ) const // ------------------------------------------------------------------------- template< typename P, unsigned int D, typename T > -typename cpPlugins::Extensions::QuadEdgeMesh< P, D, T >:: -TPrimalEdge* cpPlugins::Extensions::QuadEdgeMesh< P, D, T >:: +typename cpPlugins::Extensions::DataStructures::QuadEdgeMesh< P, D, T >:: +TPrimalEdge* cpPlugins::Extensions::DataStructures::QuadEdgeMesh< P, D, T >:: FindEdge( const PointIdentifier& a, const PointIdentifier& b ) const { TPrimalEdge* found = NULL; @@ -34,8 +34,8 @@ FindEdge( const PointIdentifier& a, const PointIdentifier& b ) const // ------------------------------------------------------------------------- template< typename P, unsigned int D, typename T > -typename cpPlugins::Extensions::QuadEdgeMesh< P, D, T >:: -TPrimalEdge* cpPlugins::Extensions::QuadEdgeMesh< P, D, T >:: +typename cpPlugins::Extensions::DataStructures::QuadEdgeMesh< P, D, T >:: +TPrimalEdge* cpPlugins::Extensions::DataStructures::QuadEdgeMesh< P, D, T >:: FindEntryEdge( const CellIdentifier& i ) const { if( i < this->GetNumberOfCells( ) ) @@ -55,8 +55,8 @@ FindEntryEdge( const CellIdentifier& i ) const // ------------------------------------------------------------------------- template< typename P, unsigned int D, typename T > -const typename cpPlugins::Extensions::QuadEdgeMesh< P, D, T >:: -CntNormals& cpPlugins::Extensions::QuadEdgeMesh< P, D, T >:: +const typename cpPlugins::Extensions::DataStructures::QuadEdgeMesh< P, D, T >:: +CntNormals& cpPlugins::Extensions::DataStructures::QuadEdgeMesh< P, D, T >:: GetPointNormalsContainer( ) const { return( this->m_PointNormals ); @@ -64,8 +64,8 @@ GetPointNormalsContainer( ) const // ------------------------------------------------------------------------- template< typename P, unsigned int D, typename T > -typename cpPlugins::Extensions::QuadEdgeMesh< P, D, T >:: -NormalsIterator cpPlugins::Extensions::QuadEdgeMesh< P, D, T >:: +typename cpPlugins::Extensions::DataStructures::QuadEdgeMesh< P, D, T >:: +NormalsIterator cpPlugins::Extensions::DataStructures::QuadEdgeMesh< P, D, T >:: BeginPointNormals( ) const { return( this->m_PointNormals.begin( ) ); @@ -73,8 +73,8 @@ BeginPointNormals( ) const // ------------------------------------------------------------------------- template< typename P, unsigned int D, typename T > -typename cpPlugins::Extensions::QuadEdgeMesh< P, D, T >:: -NormalsIterator cpPlugins::Extensions::QuadEdgeMesh< P, D, T >:: +typename cpPlugins::Extensions::DataStructures::QuadEdgeMesh< P, D, T >:: +NormalsIterator cpPlugins::Extensions::DataStructures::QuadEdgeMesh< P, D, T >:: EndPointNormals( ) const { return( this->m_PointNormals.end( ) ); @@ -82,8 +82,8 @@ EndPointNormals( ) const // ------------------------------------------------------------------------- template< typename P, unsigned int D, typename T > -const typename cpPlugins::Extensions::QuadEdgeMesh< P, D, T >:: -VectorType& cpPlugins::Extensions::QuadEdgeMesh< P, D, T >:: +const typename cpPlugins::Extensions::DataStructures::QuadEdgeMesh< P, D, T >:: +VectorType& cpPlugins::Extensions::DataStructures::QuadEdgeMesh< P, D, T >:: GetPointNormal( const PointIdentifier& id ) const { static const VectorType zero( TScalar( 0 ) ); @@ -95,7 +95,7 @@ GetPointNormal( const PointIdentifier& id ) const // ------------------------------------------------------------------------- template< typename P, unsigned int D, typename T > -bool cpPlugins::Extensions::QuadEdgeMesh< P, D, T >:: +bool cpPlugins::Extensions::DataStructures::QuadEdgeMesh< P, D, T >:: RequestedRegionIsOutsideOfTheBufferedRegion( ) { // Mesh regions don't have meaning with QuadEdges, this is important @@ -105,7 +105,7 @@ RequestedRegionIsOutsideOfTheBufferedRegion( ) // ------------------------------------------------------------------------- template< typename P, unsigned int D, typename T > -void cpPlugins::Extensions::QuadEdgeMesh< P, D, T >:: +void cpPlugins::Extensions::DataStructures::QuadEdgeMesh< P, D, T >:: SetPoints( PointsContainer* points ) { this->_ReleaseQuadEdgeObjects( ); @@ -118,7 +118,7 @@ SetPoints( PointsContainer* points ) // ------------------------------------------------------------------------- template< typename P, unsigned int D, typename T > -void cpPlugins::Extensions::QuadEdgeMesh< P, D, T >:: +void cpPlugins::Extensions::DataStructures::QuadEdgeMesh< P, D, T >:: SetPoint( PointIdentifier id , PointType point ) { // If the point is brand new, add some non-existent edges and normals @@ -137,7 +137,7 @@ SetPoint( PointIdentifier id , PointType point ) // ------------------------------------------------------------------------- template< typename P, unsigned int D, typename T > -void cpPlugins::Extensions::QuadEdgeMesh< P, D, T >:: +void cpPlugins::Extensions::DataStructures::QuadEdgeMesh< P, D, T >:: Initialize( ) { this->Superclass::Initialize( ); @@ -146,7 +146,7 @@ Initialize( ) // ------------------------------------------------------------------------- template< typename P, unsigned int D, typename T > -void cpPlugins::Extensions::QuadEdgeMesh< P, D, T >:: +void cpPlugins::Extensions::DataStructures::QuadEdgeMesh< P, D, T >:: Graft( const itk::DataObject* data ) { this->Superclass::Graft( data ); @@ -164,7 +164,7 @@ Graft( const itk::DataObject* data ) // ------------------------------------------------------------------------- template< typename P, unsigned int D, typename T > -void cpPlugins::Extensions::QuadEdgeMesh< P, D, T >:: +void cpPlugins::Extensions::DataStructures::QuadEdgeMesh< P, D, T >:: SetCells( CellsContainer* cells ) { // Clear cells @@ -188,7 +188,7 @@ SetCells( CellsContainer* cells ) // ------------------------------------------------------------------------- template< typename P, unsigned int D, typename T > -void cpPlugins::Extensions::QuadEdgeMesh< P, D, T >:: +void cpPlugins::Extensions::DataStructures::QuadEdgeMesh< P, D, T >:: SetCellData( CellDataContainer* data ) { /* TODO @@ -199,7 +199,7 @@ SetCellData( CellDataContainer* data ) // ------------------------------------------------------------------------- template< typename P, unsigned int D, typename T > -void cpPlugins::Extensions::QuadEdgeMesh< P, D, T >:: +void cpPlugins::Extensions::DataStructures::QuadEdgeMesh< P, D, T >:: SetCell( CellIdentifier id, CellAutoPointer& ptr ) { // Overwrite an existing cell? @@ -252,7 +252,7 @@ SetCell( CellIdentifier id, CellAutoPointer& ptr ) // ------------------------------------------------------------------------- template< typename P, unsigned int D, typename T > -void cpPlugins::Extensions::QuadEdgeMesh< P, D, T >:: +void cpPlugins::Extensions::DataStructures::QuadEdgeMesh< P, D, T >:: SetCellData( CellIdentifier id, CellPixelType data ) { /* TODO @@ -263,7 +263,7 @@ SetCellData( CellIdentifier id, CellPixelType data ) // ------------------------------------------------------------------------- template< typename P, unsigned int D, typename T > -void cpPlugins::Extensions::QuadEdgeMesh< P, D, T >:: +void cpPlugins::Extensions::DataStructures::QuadEdgeMesh< P, D, T >:: BuildCellLinks( ) const { // This is no longer required when using QuadEdges @@ -271,7 +271,7 @@ BuildCellLinks( ) const // ------------------------------------------------------------------------- template< typename P, unsigned int D, typename T > -cpPlugins::Extensions::QuadEdgeMesh< P, D, T >:: +cpPlugins::Extensions::DataStructures::QuadEdgeMesh< P, D, T >:: QuadEdgeMesh( ) : Superclass( ) { @@ -280,7 +280,7 @@ QuadEdgeMesh( ) // ------------------------------------------------------------------------- template< typename P, unsigned int D, typename T > -cpPlugins::Extensions::QuadEdgeMesh< P, D, T >:: +cpPlugins::Extensions::DataStructures::QuadEdgeMesh< P, D, T >:: ~QuadEdgeMesh( ) { this->_ReleaseQuadEdgeObjects( ); @@ -288,7 +288,7 @@ cpPlugins::Extensions::QuadEdgeMesh< P, D, T >:: // ------------------------------------------------------------------------- template< typename P, unsigned int D, typename T > -bool cpPlugins::Extensions::QuadEdgeMesh< P, D, T >:: +bool cpPlugins::Extensions::DataStructures::QuadEdgeMesh< P, D, T >:: _CheckPoints( const CellAutoPointer& ptr ) const { const typename Superclass::PointsContainer* pnts = this->GetPoints( ); @@ -302,7 +302,7 @@ _CheckPoints( const CellAutoPointer& ptr ) const // ------------------------------------------------------------------------- template< typename P, unsigned int D, typename T > -void cpPlugins::Extensions::QuadEdgeMesh< P, D, T >:: +void cpPlugins::Extensions::DataStructures::QuadEdgeMesh< P, D, T >:: _DeletePoint( const PointIdentifier& pId ) { PointIdentifier lastId = this->GetNumberOfPoints( ) - 1; @@ -332,8 +332,8 @@ _DeletePoint( const PointIdentifier& pId ) // ------------------------------------------------------------------------- template< typename P, unsigned int D, typename T > -typename cpPlugins::Extensions::QuadEdgeMesh< P, D, T >:: -TPrimalEdge* cpPlugins::Extensions::QuadEdgeMesh< P, D, T >:: +typename cpPlugins::Extensions::DataStructures::QuadEdgeMesh< P, D, T >:: +TPrimalEdge* cpPlugins::Extensions::DataStructures::QuadEdgeMesh< P, D, T >:: _CreateQuadEdge( const PointIdentifier& a, const PointIdentifier& b ) { // Create brand new object @@ -355,7 +355,7 @@ _CreateQuadEdge( const PointIdentifier& a, const PointIdentifier& b ) // ------------------------------------------------------------------------- template< typename P, unsigned int D, typename T > -void cpPlugins::Extensions::QuadEdgeMesh< P, D, T >:: +void cpPlugins::Extensions::DataStructures::QuadEdgeMesh< P, D, T >:: _DeleteEdge( TPrimalEdge* edge ) { this->m_DualEdges.erase( edge->GetInvRot( ) ); @@ -366,7 +366,7 @@ _DeleteEdge( TPrimalEdge* edge ) // ------------------------------------------------------------------------- template< typename P, unsigned int D, typename T > -void cpPlugins::Extensions::QuadEdgeMesh< P, D, T >:: +void cpPlugins::Extensions::DataStructures::QuadEdgeMesh< P, D, T >:: _DeleteFace( const CellIdentifier& f ) { unsigned long cellId = this->GetNumberOfCells( ) - 1; @@ -389,7 +389,7 @@ _DeleteFace( const CellIdentifier& f ) // ------------------------------------------------------------------------- template< typename P, unsigned int D, typename T > -void cpPlugins::Extensions::QuadEdgeMesh< P, D, T >:: +void cpPlugins::Extensions::DataStructures::QuadEdgeMesh< P, D, T >:: _ConstructEdges( _TEdges& edges, const CellAutoPointer& ptr ) { edges.clear( ); @@ -474,8 +474,8 @@ _ConstructEdges( _TEdges& edges, const CellAutoPointer& ptr ) // ------------------------------------------------------------------------- template< typename P, unsigned int D, typename T > -typename cpPlugins::Extensions::QuadEdgeMesh< P, D, T >:: -VectorType cpPlugins::Extensions::QuadEdgeMesh< P, D, T >:: +typename cpPlugins::Extensions::DataStructures::QuadEdgeMesh< P, D, T >:: +VectorType cpPlugins::Extensions::DataStructures::QuadEdgeMesh< P, D, T >:: _ComputePointNormal( const TPrimalEdge* e ) const { static const TScalar zero = TScalar( 0 ); @@ -514,7 +514,7 @@ _ComputePointNormal( const TPrimalEdge* e ) const // ------------------------------------------------------------------------- template< typename P, unsigned int D, typename T > -void cpPlugins::Extensions::QuadEdgeMesh< P, D, T >:: +void cpPlugins::Extensions::DataStructures::QuadEdgeMesh< P, D, T >:: _ReleaseQuadEdgeObjects( ) { this->m_PrimalEdges.clear( ); @@ -523,6 +523,6 @@ _ReleaseQuadEdgeObjects( ) this->m_PointNormals.clear( ); } -#endif // __CPPLUGINS__EXTENSIONS__QUADEDGEMESH__HXX__ +#endif // __CPPLUGINS__EXTENSIONS__DATASTRUCTURES__QUADEDGEMESH__HXX__ // eof - $RCSfile$ diff --git a/lib/cpPlugins/Extensions/IO/MeshReader.h b/lib/cpPlugins/Extensions/IO/MeshReader.h new file mode 100644 index 0000000..2e75bf3 --- /dev/null +++ b/lib/cpPlugins/Extensions/IO/MeshReader.h @@ -0,0 +1,66 @@ +#ifndef __CPPLUGINS__EXTENSIONS__IO__MESHREADER__H__ +#define __CPPLUGINS__EXTENSIONS__IO__MESHREADER__H__ + +#include +#include + +namespace cpPlugins +{ + namespace Extensions + { + namespace IO + { + /** + */ + template< typename M > + class MeshReader + : public itk::MeshSource< M > + { + public: + typedef MeshReader Self; + typedef itk::MeshSource< M > Superclass; + typedef itk::SmartPointer< Self > Pointer; + typedef itk::SmartPointer< const Self > ConstPointer; + + typedef M MeshType; + + public: + itkNewMacro( Self ); + itkTypeMacro( MeshReader, itkMeshSource ); + + itkSetStringMacro( FileName ); + itkGetStringMacro( FileName ); + + public: + virtual itk::ModifiedTimeType GetMTime( ) const; + + protected: + MeshReader( ); + virtual ~MeshReader( ); + + virtual void GenerateData( ); + + template< class R > + void _Read( ); + + private: + // Purposely not implemented + MeshReader( const Self& ); + Self& operator=( const Self & ); + + protected: + typename Superclass::Pointer m_Reader; + std::string m_FileName; + }; + + } // ecapseman + + } // ecapseman + +} // ecapseman + +#include + +#endif // __CPPLUGINS__EXTENSIONS__IO__MESHREADER__H__ + +// eof - $RCSfile$ diff --git a/lib/cpPlugins/Extensions/MeshReader.hxx b/lib/cpPlugins/Extensions/IO/MeshReader.hxx similarity index 76% rename from lib/cpPlugins/Extensions/MeshReader.hxx rename to lib/cpPlugins/Extensions/IO/MeshReader.hxx index 90be53e..26cd268 100644 --- a/lib/cpPlugins/Extensions/MeshReader.hxx +++ b/lib/cpPlugins/Extensions/IO/MeshReader.hxx @@ -1,13 +1,13 @@ -#ifndef __CPPLUGINS__EXTENSIONS__MESHREADER__HXX__ -#define __CPPLUGINS__EXTENSIONS__MESHREADER__HXX__ +#ifndef __CPPLUGINS__EXTENSIONS__IO__MESHREADER__HXX__ +#define __CPPLUGINS__EXTENSIONS__IO__MESHREADER__HXX__ #include -#include +#include #include // ------------------------------------------------------------------------- template< typename M > -itk::ModifiedTimeType cpPlugins::Extensions::MeshReader< M >:: +itk::ModifiedTimeType cpPlugins::Extensions::IO::MeshReader< M >:: GetMTime( ) const { itk::ModifiedTimeType mtime = this->Superclass::GetMTime( ); @@ -22,7 +22,7 @@ GetMTime( ) const // ------------------------------------------------------------------------- template< typename M > -cpPlugins::Extensions::MeshReader< M >:: +cpPlugins::Extensions::IO::MeshReader< M >:: MeshReader( ) : Superclass( ) { @@ -30,14 +30,14 @@ MeshReader( ) // ------------------------------------------------------------------------- template< typename M > -cpPlugins::Extensions::MeshReader< M >:: +cpPlugins::Extensions::IO::MeshReader< M >:: ~MeshReader( ) { } // ------------------------------------------------------------------------- template< typename M > -void cpPlugins::Extensions::MeshReader< M >:: +void cpPlugins::Extensions::IO::MeshReader< M >:: GenerateData( ) { std::string fn = this->m_FileName; @@ -45,13 +45,13 @@ GenerateData( ) if( fn.rfind( ".vtk" ) != std::string::npos ) this->_Read< itk::VTKPolyDataReader< M > >( ); else if( fn.rfind( ".obj" ) != std::string::npos ) - this->_Read< cpPlugins::Extensions::WaveFrontOBJReader< M > >( ); + this->_Read< cpPlugins::Extensions::IO::WaveFrontOBJReader< M > >( ); } // ------------------------------------------------------------------------- template< typename M > template< class R > -void cpPlugins::Extensions::MeshReader< M >:: +void cpPlugins::Extensions::IO::MeshReader< M >:: _Read( ) { typename R::Pointer reader = NULL; @@ -87,6 +87,6 @@ _Read( ) } // fi } -#endif // __CPPLUGINS__EXTENSIONS__MESHREADER__HXX__ +#endif // __CPPLUGINS__EXTENSIONS__IO__MESHREADER__HXX__ // eof - $RCSfile$ diff --git a/lib/cpPlugins/Extensions/IO/WaveFrontOBJReader.h b/lib/cpPlugins/Extensions/IO/WaveFrontOBJReader.h new file mode 100644 index 0000000..8d619c7 --- /dev/null +++ b/lib/cpPlugins/Extensions/IO/WaveFrontOBJReader.h @@ -0,0 +1,83 @@ +#ifndef __CPPLUGINS__EXTENSIONS__IO__WAVEFRONTOBJREADER__H__ +#define __CPPLUGINS__EXTENSIONS__IO__WAVEFRONTOBJREADER__H__ + +#include +#include +#include +#include +#include + +namespace cpPlugins +{ + namespace Extensions + { + namespace IO + { + /** + * \class WaveFrontOBJReader + * \brief + * Reads a wavefront OBJ file and create an itkMesh. + * + * Caveat1: itkWaveFrontOBJReader will read only vertices and faces. + * Normal, parameters and textures vectors are ignored. + * + */ + template< typename M > + class WaveFrontOBJReader + : public itk::MeshSource< M > + { + public: + typedef WaveFrontOBJReader Self; + typedef itk::MeshSource< M > Superclass; + typedef itk::SmartPointer< Self > Pointer; + typedef itk::SmartPointer< const Self > ConstPointer; + + typedef M MeshType; + typedef typename M::MeshTraits MeshTraits; + typedef typename M::PointType PointType; + typedef typename MeshTraits::PixelType PixelType; + typedef typename M::Pointer MeshPointer; + typedef typename M::CellTraits CellTraits; + typedef typename M::CellIdentifier CellIdentifier; + typedef typename M::CellType CellType; + typedef typename M::CellAutoPointer CellAutoPointer; + typedef typename M::PointIdentifier PointIdentifier; + typedef typename CellTraits::PointIdIterator PointIdIterator; + typedef typename M::PointsContainerPointer PointsContainerPointer; + typedef typename M::PointsContainer PointsContainer; + + typedef itk::PolygonCell< CellType > TPolygonCell; + + public: + itkNewMacro( Self ); + itkTypeMacro( WaveFrontOBJReader, itkMeshSource ); + + itkSetStringMacro( FileName ); + itkGetStringMacro( FileName ); + + protected: + WaveFrontOBJReader( ); + virtual ~WaveFrontOBJReader( ); + + virtual void GenerateData( ); + + private: + // Purposely not implemented + WaveFrontOBJReader( const Self& ); + Self& operator=( const Self & ); + + protected: + std::string m_FileName; + }; + + } // ecapseman + + } // ecapseman + +} // ecapseman + +#include + +#endif // __CPPLUGINS__EXTENSIONS__IO__WAVEFRONTOBJREADER__H__ + +// eof - $RCSfile$ diff --git a/lib/cpPlugins/Extensions/WaveFrontOBJReader.hxx b/lib/cpPlugins/Extensions/IO/WaveFrontOBJReader.hxx similarity index 88% rename from lib/cpPlugins/Extensions/WaveFrontOBJReader.hxx rename to lib/cpPlugins/Extensions/IO/WaveFrontOBJReader.hxx index d5ccb28..2e10b01 100644 --- a/lib/cpPlugins/Extensions/WaveFrontOBJReader.hxx +++ b/lib/cpPlugins/Extensions/IO/WaveFrontOBJReader.hxx @@ -1,5 +1,5 @@ -#ifndef __CPPLUGINS__EXTENSIONS__WAVEFRONTOBJREADER__HXX__ -#define __CPPLUGINS__EXTENSIONS__WAVEFRONTOBJREADER__HXX__ +#ifndef __CPPLUGINS__EXTENSIONS__IO__WAVEFRONTOBJREADER__HXX__ +#define __CPPLUGINS__EXTENSIONS__IO__WAVEFRONTOBJREADER__HXX__ #include #include @@ -7,7 +7,7 @@ // ------------------------------------------------------------------------- template< typename M > -cpPlugins::Extensions::WaveFrontOBJReader< M >:: +cpPlugins::Extensions::IO::WaveFrontOBJReader< M >:: WaveFrontOBJReader( ) : Superclass( ) { @@ -15,14 +15,14 @@ WaveFrontOBJReader( ) // ------------------------------------------------------------------------- template< typename M > -cpPlugins::Extensions::WaveFrontOBJReader< M >:: +cpPlugins::Extensions::IO::WaveFrontOBJReader< M >:: ~WaveFrontOBJReader( ) { } // ------------------------------------------------------------------------- template< typename M > -void cpPlugins::Extensions::WaveFrontOBJReader< M >:: +void cpPlugins::Extensions::IO::WaveFrontOBJReader< M >:: GenerateData( ) { typedef typename PointType::ValueType TScalar; @@ -118,6 +118,6 @@ GenerateData( ) in.close( ); } -#endif // __CPPLUGINS__EXTENSIONS__WAVEFRONTOBJREADER__HXX__ +#endif // __CPPLUGINS__EXTENSIONS__IO__WAVEFRONTOBJREADER__HXX__ // eof - $RCSfile$ diff --git a/lib/cpPlugins/Extensions/MeshMapper.h b/lib/cpPlugins/Extensions/MeshMapper.h deleted file mode 100644 index 23e0232..0000000 --- a/lib/cpPlugins/Extensions/MeshMapper.h +++ /dev/null @@ -1,103 +0,0 @@ -#ifndef __CPPLUGINS__EXTENSIONS__MESHMAPPER__H__ -#define __CPPLUGINS__EXTENSIONS__MESHMAPPER__H__ - -#include -#include - -class vtkActor; -class vtkInformation; -class vtkRenderer; - -namespace cpPlugins -{ - namespace Extensions - { - /** - */ - template< class M > - class MeshMapper - : public vtkMapper - { - public: - typedef MeshMapper Self; - vtkTypeMacro( MeshMapper, vtkMapper ); - - typedef M TMesh; - typedef typename M::PointType TPoint; - typedef typename TPoint::VectorType TVector; - typedef typename TPoint::CoordRepType TScalar; - itkStaticConstMacro( Dimension, unsigned int, M::PointDimension ); - - // Begin concept checking -#ifdef ITK_USE_CONCEPT_CHECKING - /* TODO - itkConceptMacro( - InputMeshIsTwoOrThreeimensionalCheck, - ( itk::Concept::SameDimensionOrMinusOne< Self::Dimension, 3 > ) - ); - itkConceptMacro( - ScalarTypeHasFloatResolution, - ( itk::Concept::IsFloatingPoint< TScalar > ) - ); - */ -#endif - // End concept checking - - public: - // TODO: static Self* New( ); - virtual void ShallowCopy( vtkAbstractMapper* m ); - - virtual void SetInputData( M* in ); - virtual M* GetInput( ); - virtual const M* GetInput( ) const; - - virtual double* GetBounds( ); - virtual void GetBounds( double bounds[ 6 ] ); - - virtual void RenderPiece( vtkRenderer* aren, vtkActor* act ) = 0; - virtual void Render( vtkRenderer* aren, vtkActor* act ); - virtual void Update( ); - virtual void Update( int port ); - - virtual void MapDataArrayToVertexAttribute( - const char* vertexAttributeName, - const char* dataArrayName, - int fieldAssociation, - int componentno = -1 - ); - virtual void MapDataArrayToMultiTextureAttribute( - int unit, - const char* dataArrayName, - int fieldAssociation, - int componentno = -1 - ); - virtual void RemoveVertexAttributeMapping( - const char* vertexAttributeName - ); - virtual void RemoveAllVertexAttributeMappings( ); - - protected: - MeshMapper( ); - virtual ~MeshMapper( ); - - virtual void ComputeBounds( ); - virtual int FillInputPortInformation( int port, vtkInformation* info ); - - private: - // These methods aren't supposed to be implemented - MeshMapper( const Self& other ); - Self& operator=( const Self& other ); - - protected: - typename M::Pointer Mesh; - }; - - } // ecapseman - -} // ecapseman - -#include - -#endif // __CPPLUGINS__EXTENSIONS__MESHMAPPER__H__ - -// eof - $RCSfile$ diff --git a/lib/cpPlugins/Extensions/MeshReader.h b/lib/cpPlugins/Extensions/MeshReader.h deleted file mode 100644 index 7189187..0000000 --- a/lib/cpPlugins/Extensions/MeshReader.h +++ /dev/null @@ -1,62 +0,0 @@ -#ifndef __CPPLUGINS__EXTENSIONS__MESHREADER__H__ -#define __CPPLUGINS__EXTENSIONS__MESHREADER__H__ - -#include -#include - -namespace cpPlugins -{ - namespace Extensions - { - /** - */ - template< typename M > - class MeshReader - : public itk::MeshSource< M > - { - public: - typedef MeshReader Self; - typedef itk::MeshSource< M > Superclass; - typedef itk::SmartPointer< Self > Pointer; - typedef itk::SmartPointer< const Self > ConstPointer; - - typedef M MeshType; - - public: - itkNewMacro( Self ); - itkTypeMacro( MeshReader, itkMeshSource ); - - itkSetStringMacro( FileName ); - itkGetStringMacro( FileName ); - - public: - virtual itk::ModifiedTimeType GetMTime( ) const; - - protected: - MeshReader( ); - virtual ~MeshReader( ); - - virtual void GenerateData( ); - - template< class R > - void _Read( ); - - private: - // Purposely not implemented - MeshReader( const Self& ); - Self& operator=( const Self & ); - - protected: - typename Superclass::Pointer m_Reader; - std::string m_FileName; - }; - - } // ecapseman - -} // ecapseman - -#include - -#endif // __CPPLUGINS__EXTENSIONS__MESHREADER__H__ - -// eof - $RCSfile$ diff --git a/lib/cpPlugins/Extensions/OpenGLMeshMapper.h b/lib/cpPlugins/Extensions/OpenGLMeshMapper.h deleted file mode 100644 index 9efa722..0000000 --- a/lib/cpPlugins/Extensions/OpenGLMeshMapper.h +++ /dev/null @@ -1,81 +0,0 @@ -#ifndef __CPPLUGINS__EXTENSIONS__OPENGLMESHMAPPER__H__ -#define __CPPLUGINS__EXTENSIONS__OPENGLMESHMAPPER__H__ - -#include - -/* - #include - #include -*/ - -#include - -namespace cpPlugins -{ - namespace Extensions - { - /** - */ - template< class M > - class OpenGLMeshMapper - : public MeshMapper< M > - { - public: - typedef OpenGLMeshMapper Self; - vtkTypeMacro( OpenGLMeshMapper, MeshMapper< M > ); - - typedef typename Superclass::TMesh TMesh; - typedef typename Superclass::TPoint TPoint; - typedef typename Superclass::TVector TVector; - typedef typename Superclass::TScalar TScalar; - - protected: - typedef unsigned int TIndex; - typedef typename M::CellType TCell; - typedef typename M::CellsContainer TCellsContainer; - typedef typename TCellsContainer::ConstIterator TCellIt; - - public: - virtual const char* GetNameOfClass( ) const - { return( "cpPlugins::Extensions::OpenGLMeshMapper" ); } - static Self* New( ); - - virtual void RenderPiece( vtkRenderer* aren, vtkActor* act ); - virtual void ReleaseGraphicsResources( vtkWindow* win ); - virtual int Draw( vtkRenderer* aren, vtkActor* act ); - - protected: - OpenGLMeshMapper( ); - virtual ~OpenGLMeshMapper( ); - - bool _ConfigureOpenGL( ); - - private: - // Purposely not implemented - OpenGLMeshMapper( const Self& other ); - Self& operator=( const Self& other ); - - protected: - vtkIdType TotalCells; - // TODO: vtkSmartPointer< vtkOpenGLTexture > InternalColorTexture; - - bool FirstRendering; - - bool VBOSupported; - unsigned int VBOID1, VBOID2; - - std::vector< unsigned int > Sizes; - std::vector< TIndex > Indices; - long IndexElementType; - long ElementValueType; - }; - - } // ecapseman - -} // ecapseman - -#include - -#endif // __CPPLUGINS__EXTENSIONS__OPENGLMESHMAPPER__H__ - -// eof - $RCSfile$ diff --git a/lib/cpPlugins/Extensions/QuadEdge.h b/lib/cpPlugins/Extensions/QuadEdge.h deleted file mode 100644 index 41d511b..0000000 --- a/lib/cpPlugins/Extensions/QuadEdge.h +++ /dev/null @@ -1,465 +0,0 @@ -#ifndef __CPPLUGINS__EXTENSIONS__QUADEDGE__H__ -#define __CPPLUGINS__EXTENSIONS__QUADEDGE__H__ - -#include -#include - -namespace cpPlugins -{ - namespace Extensions - { - /** - */ - template< typename P, typename D, bool IsPrimal = true > - class QuadEdge - : public itk::LightObject - { - public: - typedef QuadEdge Self; - typedef itk::LightObject Superclass; - typedef itk::SmartPointer< Self > Pointer; - typedef itk::SmartPointer< const Self > ConstPointer; - - /// Vertices and faces types - typedef P TPrimalGeometry; - typedef D TDualGeometry; - - /** - * Dual type, basically the same type with swapped template - * parameters. - */ - typedef QuadEdge< D, P, !IsPrimal > TDual; - typedef Self TPrimal; - typedef typename TDual::Pointer PtrDual; - friend TDual; - - /// Iterators - typedef QuadEdgeIterator< TPrimal > Iterator; - typedef QuadEdgeConstIterator< TPrimal > ConstIterator; - typedef QuadEdgePointIterator< TPrimal > PointIterator; - typedef QuadEdgePointConstIterator< TPrimal > PointConstIterator; - - public: - itkNewMacro( Self ); - itkTypeMacro( QuadEdge, itkLightObject ); - - cpPluginsExtensionsQEAllIteratorsMacro( Onext ); - cpPluginsExtensionsQEAllIteratorsMacro( Lnext ); - cpPluginsExtensionsQEAllIteratorsMacro( Rnext ); - cpPluginsExtensionsQEAllIteratorsMacro( Dnext ); - cpPluginsExtensionsQEAllIteratorsMacro( Oprev ); - cpPluginsExtensionsQEAllIteratorsMacro( Lprev ); - cpPluginsExtensionsQEAllIteratorsMacro( Rprev ); - cpPluginsExtensionsQEAllIteratorsMacro( Dprev ); - - public: - void CreateRings( ); - - /// First order access methods - inline TPrimal* GetOnext( ) - { return( this->m_Onext ); } - inline TDual* GetRot( ) - { return( this->m_Rot ); } - inline const TPrimal* GetOnext( ) const - { return( this->m_Onext ); } - inline const TDual* GetRot( ) const - { return( this->m_Rot ); } - - /// First order configuration methods - inline void SetOnext( TPrimal* e ) - { this->m_Onext = e; } - inline void SetRot( TDual* e ) - { this->m_Rot = e; } - - /// Second order accessors: around base rings - inline TPrimal* GetSym( ) - { return( this->m_Rot->m_Rot ); } - inline TDual* GetInvRot( ) - { return( this->m_Rot->m_Rot->m_Rot ); } - - /// Second order accessors: neighboring topology - inline TPrimal* GetLnext( ) - { return( this->m_Rot->m_Rot->m_Rot->m_Onext->m_Rot ); } - inline TPrimal* GetRnext( ) - { return( this->m_Rot->m_Onext->m_Rot->m_Rot->m_Rot ); } - inline TPrimal* GetDnext( ) - { return( this->m_Rot->m_Rot->m_Onext->m_Rot->m_Rot ); } - inline TPrimal* GetOprev( ) - { return( this->m_Rot->m_Onext->m_Rot ); } - inline TPrimal* GetLprev( ) - { return( this->m_Onext->m_Rot->m_Rot ); } - inline TPrimal* GetRprev( ) - { return( this->m_Rot->m_Rot->m_Onext ); } - inline TPrimal* GetDprev( ) - { return( this->m_Rot->m_Rot->m_Rot->m_Onext->m_Rot->m_Rot->m_Rot ); } - - /// Second order accessors: around base rings (const versions) - inline const TPrimal* GetSym( ) const - { return( this->m_Rot->m_Rot ); } - inline const TDual* GetInvRot( ) const - { return( this->m_Rot->m_Rot->m_Rot ); } - - /// Second order accessors: neighboring topology (const versions) - inline const TPrimal* GetLnext( ) const - { return( this->m_Rot->m_Rot->m_Rot->m_Onext->m_Rot ); } - inline const TPrimal* GetRnext( ) const - { return( this->m_Rot->m_Onext->m_Rot->m_Rot->m_Rot ); } - inline const TPrimal* GetDnext( ) const - { return( this->m_Rot->m_Rot->m_Onext->m_Rot->m_Rot ); } - inline const TPrimal* GetOprev( ) const - { return( this->m_Rot->m_Onext->m_Rot ); } - inline const TPrimal* GetLprev( ) const - { return( this->m_Onext->m_Rot->m_Rot ); } - inline const TPrimal* GetRprev( ) const - { return( this->m_Rot->m_Rot->m_Onext ); } - inline const TPrimal* GetDprev( ) const - { return( this->m_Rot->m_Rot->m_Rot->m_Onext->m_Rot->m_Rot->m_Rot ); } - - /// Get geometry methods - inline P& GetOrigin( ) - { return ( this->m_Origin ); } - inline P& GetDestination( ) - { return ( this->m_Rot->m_Rot->m_Origin ); } - inline D& GetRight( ) - { return ( this->m_Rot->m_Origin ); } - inline D& GetLeft( ) - { return ( this->m_Rot->m_Rot->m_Rot->m_Origin ); } - - /// Get geometry methods (const versions) - inline const P& GetOrigin( ) const - { return ( this->m_Origin ); } - inline const P& GetDestination( ) const - { return ( this->m_Rot->m_Rot->m_Origin ); } - inline const D& GetRight( ) const - { return ( this->m_Rot->m_Origin ); } - inline const D& GetLeft( ) const - { return ( this->m_Rot->m_Rot->m_Rot->m_Origin ); } - - /// Set geometry methods - inline void SetOrigin( const P& v ) - { this->m_Origin = v; } - inline void SetDestination( const P& v ) - { this->m_Rot->m_Rot->m_Origin = v; } - inline void SetRight( const D& v ) - { this->m_Rot->m_Origin = v; } - inline void SetLeft( const D& v ) - { this->m_Rot->m_Rot->m_Rot->m_Origin = v; } - inline void UnsetOrigin( ) - { this->m_Origin = TPrimal::NoGeometry; } - inline void UnsetDestination( ) - { this->m_Rot->m_Rot->m_Origin = TPrimal::NoGeometry; } - inline void UnsetRight( ) - { this->m_Rot->m_Origin = TDual::NoGeometry; } - inline void UnsetLeft( ) - { this->m_Rot->m_Rot->m_Rot->m_Origin = TDual::NoGeometry; } - - /** - * Set the Left( ) of all the edges in the Lnext( ) ring of "this" - * with the same given geometrical information. - * @param faceGeom Looks at most maxSize edges in the Lnext( ) ring. - * @return Returns true on success. False otherwise. - */ - void SetLnextRingGeometry( const D& v ); - void UnsetLnextRingGeometry( ); - - /// Topological queries - inline bool IsIsolated( ) const - { return( this == this->m_Onext ); } - bool IsEdgeInOnextRing( const TPrimal* e ) const; - bool IsEdgeInLnextRing( const TPrimal* e ) const; - unsigned int GetOnextRingSize( ) const; - unsigned int GetLnextRingSize( ) const; - - /** - * @return Returns true when "this" has no faces set on both sides. - * Return false otherwise. - */ - inline bool IsWire( ) - { return( !( this->IsLeftSet( ) ) && !( this->IsRightSet( ) ) ); } - - /** - * @return Returns true when "this" is on the boundary i.e. - * one and only one of the faces is set. Return false - * otherwise. - */ - inline bool IsAtBorder( ) const; - - /** - * @return Returns true when "this" has faces set on both sides. - * Return false otherwise. - */ - inline bool IsInternal( ) const - { return ( this->IsLeftSet( ) && this->IsRightSet( ) ); } - - /// Geometrical queries - inline bool IsOriginSet( ) const - { return ( this->m_Origin != Self::NoGeometry ); } - inline bool IsDestinationSet( ) const - { return ( this->m_Rot->m_Rot->IsOriginSet( ) ); } - inline bool IsRightSet( ) const - { return ( this->m_Rot->IsOriginSet( ) ); } - inline bool IsLeftSet( ) const - { return ( this->m_Rot->m_Rot->m_Rot->IsOriginSet( ) ); } - - /** - * \brief Check wether edge's Origin is internal to the mesh (as - * opposed to being on the boundary) by looking if all the edges - * in the Onext() ring have a face set on both their Left() and - * Right() side. - */ - bool IsOriginInternal( ) const; - - /** - * Definition: an edge is said to be a boundary edge when it is - * adjacent to i.e. when at least one of the faces edge->GetLeft() or - * edge->GetRight() is unset. Definition: an point is said to be a - * boundary point when at least one of the edges of it's Onext() ring - * is a boundary edge. - * - * Assume "this" edge belongs to a triangulation (i.e. it belongs to a - * QEMesh which represents a 2-manifold) which possesses a boundary. - * Assume "this" edge instance is a boundary edge. Let us denote by P - * the point which is the origin of "this" edge i.e. P is - * this->Origin(). By definition P is a boundary point. Then AT - * LEAST two [see the note below] edges of the Onext() ring of P - * [which all have the point P as Origin()] are themselves boundary - * edges. And among those boundary edges AT LEAST one has it's Left() - * face unset. By iterating over the Onext() ring (which defines a - * local ordering on edges) this method searches for the first edge - * whose Left() face is unset AND which is encountered AFTER edgeTest. - * - * @param edgeTest When present, this edge will be considered as - * the entry edge in the Onext() ring. When absent it shall - * be defaulted to "this" edge. (see the warning below). - * @return When "this" edge is a boundary edge, return the first - * edge in "this" Onext() ring whose Left() face is unset - * AND located after edgeTest. - * When "this" edge is NOT a boundary edge the 0 is - * returned. - * @warning When the Mesh possessing "this" edge is a 2-manifold - * then result of this method is unique in the sense that - * it is independent from the edgeTest parameter. - * But when the Mesh is not 2-manifold (this state can - * happen at intermediary stages of the building process, - * or during "surgical" operations on the Mesh, and - * even though the Mesh represents a triangulation) - * the result of this method is not unique in the sense - * that the result depends on the edgeTest parameter. - * Let us illusatre this dependence by considering a - * Mesh (which is a triangulation) which is not a 2-manifold. - * Assume the point P (the origin of "this" edge i.e. - * P = this->Originv()) is TWICE on the border i.e. it - * is adjacent twice to noface. We can consider the situation - * of the following diagram, which depicts some Onext() - * ring around point P: - * - * \ / // - * \ * / // - * i3 b2 counter-clockwise // - * * \ / NO FACE Onext() order. // - * \ / // - * ----b4-----P----b1------ // - * /|\ // - * NO FACE / | \ // - * / | \ * <------ a * indicates the // - * / | \ the presence of a face // - * / | \ // - * b5 i6 i7 // - * / * | * \ // - * / | \ // - * - * On this example, and if we assume the Onext() oder is - * represented counter-clockwise, the edges are ordered as - * follows: - * b1, b2, i3, b4, b5, i6, i7 - * (when arbitrarily starting at edge b1). - * We have four Boundary edges labeled b1, b2, b4, b5 and - * we have three internal edges (i.e. non boundary edges) - * labeled i3, i6 and i7. - * Depending on edgeTest, the result of this method - * will NOT return the same edge: - * - when edgeTest == b5 (or i6 or i7 or b1) then the edge - * b1 will be returned, - * - when edgeTest == b2 (or i3 or b4) then the edge - * b4 will be returned, - * Eventually, when edgeTest is absent, the result shall - * depend on the position of "this" in the Onext() ring(). - * - */ - TPrimal* GetNextBorderEdgeWithUnsetLeft( TPrimal* edge = NULL ) const; - - /** - * Assume "this->Originv()" is a boundary point P that is thrice adjacent - * to noface and consider the given situation is the one depicted by - * the following diagram where: - * - P is "this->Originv()" instance, - * - the * (star) indicates the presence of a face, - * - b1, b2, b3, b4, b5, b6 denote boundary edges, - * - p denotes some generic point, - * - A and B denote some specific points we want to discuss, - * - the Onext() ring order is represented counter-clockwise - * [which is coherent with the definition of edge->GetRigth()] - * i.e. the ordering of the edges is: - * b1, b2, b3, b4, b5, b6, b1... - * - * p N p - * / \ O / \ // - * / \ / \ // - * / \ F / \ counter-clockwise // - * / b3 A b2 \ Onext() ring order // - * / \ C / \ // - * / * \ E / * \ // - * / \ / \ // - * A------b4------P------b1-------B // - * / \ // - * / \ // - * NO FACE / \ NO FACE // - * / \ // - * b5 b6 // - * / * \ // - * / \ // - * p---------------p // - * - * At P this Mesh doesn't represent a 2-manifold (since we are thrice - * on the boundary). Nevertheless such a situation could arise in - * intermediary stages (e.g. when building the Mesh, or during - * surgical changes on the Mesh). - * Now, assume we are asked to build the triangle [P, A, B]. Note - * that this request is not absurd since the current situation at - * P isn't the one of a 2-manifold: hence when building the current - * Onext() ring of P, we had not enough information to decide - * wheter b4.Onext() should be b5 or b1. It is ONLY when we are - * required to build the triangle [P, A, B] that we have the - * additional information that b4.Onext() is indeed b1. - * When we are required to build triangle [P, A, B], we hence - * need to change the Onext() ring order at P, i.e. we need to deal - * with the triangle [P, b5, b6] which currently prevents - * b4.Onext() to be b1. In other terms, when considering the - * additional information that b4.Onext() is b1, and before - * building the triangle [P, A, B], we need to reorder - * the Onext() ring of P from it's current state - * b1, b2, b3, b4, b5, b6, b1... - * to an order coherent with the [P, A, B] request, i.e. - * b1, b2, b5, b6, b3, b4, b1... - * - * In order to establish the "proper" Onext() ring at P we use - * two Splice operations. The algorithm goes: - * - first disconnect the piece of the surface containing the edge - * [PB] (it would be the same process if we chose [PA]) from - * the Onext() ring at P. - * - second, re-integrate the disconnected piece at the desired - * location i.e. side by side with [PA] (respectively [PB] if - * we chose [PA] at first stage). - * By "piece of surface containing the edge [PB]" we mean [all] - * the triangle[s] starting at [PB] in the Onext() order and - * having a left face set. - * - * We can illustrate this process on bit more general diagram than - * the last case (where the "piece of surface containing the edge - * [PB]" is constituted by two triangles) and when using - * the arguments of this method (i.e. [PA] = this and [PB] = second). - * The initial stage is the following (we note first=this=[PA] and - * second=[PB]) where the Onext() ring order is: - * first, b2, b3, second, b5, bsplice, b7, first... - * - * p N A // - * / \ O / \ // - * / \ / \ // - * / \ F / \ counter-clockwise // - * / b2 A first \ Onext() ring order // - * / \ C / \ // - * / * \ E / * \ // - * / \ / \ // - * p-------b3------P------b7-------p // - * /|\ // - * / | \ // - * NO FACE / | \ NO FACE // - * / | \ // - * second b5 bsplice // - * / * | * \ // - * / | \ // - * B-------p-------p // - * - * The first stage, implemented as - * second->Oprev()->Splice( bsplice ), - * yields the following diagram: - * - * p N A // - * / \ O / \ // - * / \ F / \ // - * / \ A / \ counter-clockwise // - * / b2 C first \ Onext() ring order // - * / \ E / \ // - * / * \ / * \ // - * / \ / \ // - * p-------b3------P------b7-------p // - * // - * NO FACE // - * // - * /|\ // - * / | \ // - * / | \ // - * / | \ // - * second b5 bsplice // - * / * | * \ // - * / | \ // - * B-------p-------p // - * - * and the second stage, implemented as - * first->Splice( bsplice ), - * yields the following diagram: - * - * A // - * B__ NO FACE / \ // - * | \__ / \ // - * | \__ / \ counter- // - * | second first \ clockwise for all // - * | \__ / \ // - * | * \__ / * \ // - * | \ / \ // - * p-------b5---------P------b7-------p // - * | __/|\ // - * | * __/ | \ // - * | / | \ NO FACE // - * | bsplice | \ // - * | __/ b2 b3 // - * p__/ | * \ // - * NO FACE | \ // - * p-------p // - * - */ - inline static bool ReorderOnextRing( TPrimal* first, TPrimal* second ); - - /** - * \brief Basic quad-edge topological method. - * - * This method describes all possible topological operations on an - * edge since it is its own inverse. It works in two ways: - * - * 1. If this->m_Org != b->m_Org, it slice a face in two. - * 2. If this->m_Org == b->m_Org, it unifies two faces. - */ - inline static void Splice( TPrimal* a, TPrimal* b ); - - protected: - QuadEdge( ); - virtual ~QuadEdge( ); - - public: - static const TPrimalGeometry NoGeometry; - - protected: - Pointer m_Onext; /**< Onext ring */ - PtrDual m_Rot; /**< Rot ring */ - TPrimalGeometry m_Origin; /**< Geometry attached to edge's origin */ - }; - - } // ecapseman - -} // ecapseman - -#include - -#endif // __CPPLUGINS__EXTENSIONS__QUADEDGE__H__ - -// eof - $RCSfile$ diff --git a/lib/cpPlugins/Extensions/QuadEdgeCell.h b/lib/cpPlugins/Extensions/QuadEdgeCell.h deleted file mode 100644 index 1ca068f..0000000 --- a/lib/cpPlugins/Extensions/QuadEdgeCell.h +++ /dev/null @@ -1,124 +0,0 @@ -#ifndef __CPPLUGINS__EXTENSIONS__QUADEDGECELL__H__ -#define __CPPLUGINS__EXTENSIONS__QUADEDGECELL__H__ - -#include - -namespace cpPlugins -{ - namespace Extensions - { - /** - */ - template< class I, class E > - class QuadEdgeCell - : public I - { - public: - // Base types - typedef QuadEdgeCell Self; - typedef I Superclass; - typedef itk::AutoPointer< Self > SelfAutoPointer; - typedef itk::AutoPointer< const Self > ConstSelfAutoPointer; - typedef Self* RawPointer; - typedef const Self* ConstRawPointer; - - // QuadEdge objects - typedef E TPrimalEdge; - typedef typename E::TDual TDualEdge; - - // Inherited types - typedef typename I::PixelType PixelType; - typedef typename I::CellType CellType; - typedef typename I::CellAutoPointer CellAutoPointer; - typedef typename I::CellConstAutoPointer CellConstAutoPointer; - typedef typename I::CellRawPointer CellRawPointer; - typedef typename I::CellConstRawPointer CellConstRawPointer; - typedef typename I::CellTraits CellTraits; - typedef typename I::CoordRepType CoordRepType; - typedef typename I::InterpolationWeightType InterpolationWeightType; - typedef typename I::PointIdentifier PointIdentifier; - typedef typename I::PointIdIterator PointIdIterator; - typedef typename I::PointIdConstIterator PointIdConstIterator; - typedef typename I::CellIdentifier CellIdentifier; - typedef typename I::CellFeatureIdentifier CellFeatureIdentifier; - typedef typename I::CellFeatureIdentifier CellFeatureCount; - typedef typename I::PointType PointType; - typedef typename I::VectorType VectorType; - typedef typename I::PointsContainer PointsContainer; - typedef typename I::UsingCellsContainer UsingCellsContainer; - typedef typename I::CellGeometry CellGeometry; - typedef typename I::ParametricCoordArrayType ParametricCoordArrayType; - typedef typename I::ShapeFunctionsArrayType ShapeFunctionsArrayType; - - itkStaticConstMacro( PointDimension, unsigned int, I::PointDimension ); - itkStaticConstMacro( CellDimension, unsigned int, 2 ); - - public: - itkTypeMacro( QuadEdgeCell, I ); - - public: - QuadEdgeCell( ); - QuadEdgeCell( E* entry ); - virtual ~QuadEdgeCell( ); - - /// Implement the standard CellInterface. - virtual CellGeometry GetType( ) const; - virtual void MakeCopy( CellAutoPointer& other ) const; - virtual unsigned int GetDimension( ) const; - virtual unsigned int GetNumberOfPoints( ) const; - virtual CellFeatureCount GetNumberOfBoundaryFeatures( - int dimension - ) const; - virtual bool GetBoundaryFeature( - int dimension, CellFeatureIdentifier fId, CellAutoPointer& ptr - ); - virtual void SetPointIds( PointIdConstIterator first ); - virtual void SetPointIds( - PointIdConstIterator first, PointIdConstIterator last - ); - virtual void AddPointId( PointIdentifier pId ); - virtual void RemovePointId( PointIdentifier pId ); - virtual void SetPointIds( - int dummy, int num, PointIdConstIterator first - ); - virtual void BuildEdges( ); - virtual void ClearPoints( ); - virtual void SetPointId( int localId, PointIdentifier pId ); - - // Visitor methods - static int GetTopologyId( ); - virtual void Accept( - CellIdentifier cellid, - typename itk::CellInterface< PixelType, CellTraits >:: - MultiVisitor* mv - ); - - // Iterators - virtual PointIdIterator PointIdsBegin( ); - virtual PointIdConstIterator PointIdsBegin( ) const; - virtual PointIdIterator PointIdsEnd( ); - virtual PointIdConstIterator PointIdsEnd( ) const; - - /// QuadEdgeCell-specific interface. - virtual E* GetEntryPrimalEdge( ); - virtual const E* GetEntryPrimalEdge( ) const; - virtual void SetEntryPrimalEdge( E* entry ); - - private: - /// Purposely not implemented. - QuadEdgeCell( const Self& ); - Self& operator=( const Self& ); - - protected: - E* m_EntryEdge; - }; - - } // ecapseman - -} // ecapseman - -#include - -#endif // __CPPLUGINS__EXTENSIONS__QUADEDGECELL__H__ - -// eof - $RCSfile$ diff --git a/lib/cpPlugins/Extensions/QuadEdgeIterators.h b/lib/cpPlugins/Extensions/QuadEdgeIterators.h deleted file mode 100644 index 131b8b4..0000000 --- a/lib/cpPlugins/Extensions/QuadEdgeIterators.h +++ /dev/null @@ -1,171 +0,0 @@ -#ifndef __CPPLUGINS__EXTENSIONS__QUADEDGEITERATORS__H__ -#define __CPPLUGINS__EXTENSIONS__QUADEDGEITERATORS__H__ - -#include - -// ------------------------------------------------------------------------- -#define cpPluginsExtensionsQEIteratorsMacro( op, it, cit ) \ - inline it Begin##op( ) \ - { return( it( this, it::Op##op, true ) ); } \ - inline it End##op( ) \ - { return( it( this, it::Op##op, false ) ); } \ - inline cit Begin##op( ) const \ - { return( cit( this, cit::Op##op, true ) ); } \ - inline cit End##op( ) const \ - { return( cit( this, cit::Op##op, false ) ); } - -// ------------------------------------------------------------------------- -#define cpPluginsExtensionsQEPointIteratorsMacro( op, it, cit ) \ - inline Point##it BeginPoint##op( ) \ - { return( Point##it( this, it::Op##op, true ) ); } \ - inline Point##it EndPoint##op( ) \ - { return( Point##it( this, it::Op##op, false ) ); } \ - inline Point##cit BeginPoint##op( ) const \ - { return( Point##cit( this, cit::Op##op, true ) ); } \ - inline Point##cit EndPoint ##op( ) const \ - { return( Point##cit( this, cit::Op##op, false ) ); } - -// ------------------------------------------------------------------------- -#define cpPluginsExtensionsQEAllIteratorsMacro( op ) \ - cpPluginsExtensionsQEIteratorsMacro( op, Iterator, ConstIterator ); \ - cpPluginsExtensionsQEPointIteratorsMacro( op, Iterator, ConstIterator ); - -namespace cpPlugins -{ - namespace Extensions - { - /** - */ - template< class E > - class QuadEdgeBaseIterator - { - public: - typedef QuadEdgeBaseIterator Self; - typedef E TQuadEdge; - - // Different types of logical iterators - enum - { - OpOnext = 0, - OpLnext = 1, - OpRnext = 2, - OpDnext = 3, - OpOprev = 4, - OpLprev = 5, - OpRprev = 6, - OpDprev = 7 - }; - - public: - QuadEdgeBaseIterator( E* e, int op = OpOnext, bool start = true ); - virtual ~QuadEdgeBaseIterator( ); - Self& operator=( const Self& r ); - - E* GetStartEdge( ) const; - E* GetIterator( ) const; - int GetOpType( ) const; - bool GetStart( ) const; - - bool operator==( Self& r ); - bool operator==( const Self& r ) const; - bool operator!=( Self& r ); - bool operator!=( const Self& r ) const; - Self& operator++( ); - Self& operator++( int ); - - protected: - /// Method that should do all the iteration work - virtual void _GoToNext( ); - - protected: - E* m_StartEdge; /**< Start edge */ - E* m_Iterator; /**< Current iteration position */ - int m_OpType; /**< Operation type */ - bool m_Start; /**< Indicates iteration has just started */ - }; - - /** - */ - template< class E > - class QuadEdgeIterator - : public QuadEdgeBaseIterator< E > - { - public: - typedef QuadEdgeIterator Self; - typedef QuadEdgeBaseIterator< E > Superclass; - typedef E TQuadEdge; - - public: - QuadEdgeIterator( - E* e = NULL, int op = Superclass::OpOnext, bool start = true - ); - virtual ~QuadEdgeIterator( ); - E* operator*( ); - }; - - /** - */ - template< class E > - class QuadEdgeConstIterator - : public QuadEdgeBaseIterator< const E > - { - public: - typedef QuadEdgeConstIterator Self; - typedef QuadEdgeBaseIterator< const E > Superclass; - typedef E TQuadEdge; - - public: - QuadEdgeConstIterator( - const E* e = NULL, int op = Superclass::OpOnext, bool start = true - ); - virtual ~QuadEdgeConstIterator( ); - const E* operator*( ) const; - }; - - /** - */ - template< class E > - class QuadEdgePointIterator - : public QuadEdgeBaseIterator< const E > - { - public: - typedef QuadEdgePointIterator Self; - typedef QuadEdgeBaseIterator< const E > Superclass; - typedef E TQuadEdge; - - public: - QuadEdgePointIterator( - const E* e = NULL, int op = Superclass::OpOnext, bool start = true - ); - virtual ~QuadEdgePointIterator( ); - typename E::TPrimalGeometry& operator*( ); - }; - - /** - */ - template< class E > - class QuadEdgePointConstIterator - : public QuadEdgeBaseIterator< const E > - { - public: - typedef QuadEdgePointConstIterator Self; - typedef QuadEdgeBaseIterator< const E > Superclass; - typedef E TQuadEdge; - - public: - QuadEdgePointConstIterator( - const E* e = NULL, int op = Superclass::OpOnext, bool start = true - ); - virtual ~QuadEdgePointConstIterator( ); - const typename E::TPrimalGeometry& operator*( ) const; - }; - - } // ecapseman - -} // ecapseman - -#include - -#endif // __CPPLUGINS__EXTENSIONS__QUADEDGEITERATORS__H__ - -// eof - $RCSfile$ diff --git a/lib/cpPlugins/Extensions/QuadEdgeMesh.h b/lib/cpPlugins/Extensions/QuadEdgeMesh.h deleted file mode 100644 index a92c68f..0000000 --- a/lib/cpPlugins/Extensions/QuadEdgeMesh.h +++ /dev/null @@ -1,283 +0,0 @@ -#ifndef __CPPLUGINS__EXTENSIONS__QUADEDGEMESH__H__ -#define __CPPLUGINS__EXTENSIONS__QUADEDGEMESH__H__ - -#include -#include - -#include -#include -#include - -namespace cpPlugins -{ - namespace Extensions - { - /** - */ - template< typename P, unsigned int D = 3, typename T = itk::DefaultStaticMeshTraits< P, D, D > > - class QuadEdgeMesh - : public itk::Mesh< P, D, T > - { - public: - typedef QuadEdgeMesh Self; - typedef itk::Mesh< P, D, T > Superclass; - typedef itk::SmartPointer< Self > Pointer; - typedef itk::SmartPointer< const Self > ConstPointer; - - /// Types from superclass - typedef typename - Superclass::BoundaryAssignmentsContainer - BoundaryAssignmentsContainer; - - typedef typename - Superclass::BoundaryAssignmentsContainerPointer - BoundaryAssignmentsContainerPointer; - - typedef typename Superclass::BoundingBoxType BoundingBoxType; - typedef typename Superclass::CellAutoPointer CellAutoPointer; - typedef typename Superclass::CellsContainer CellsContainer; - typedef typename Superclass::CellDataContainer CellDataContainer; - typedef typename Superclass::CellFeatureCount CellFeatureCount; - typedef typename Superclass::CellFeatureIdentifier CellFeatureIdentifier; - typedef typename Superclass::CellIdentifier CellIdentifier; - typedef typename Superclass::CellLinksContainer CellLinksContainer; - typedef typename Superclass::CellMultiVisitorType CellMultiVisitorType; - typedef typename Superclass::CellPixelType CellPixelType; - typedef typename Superclass::CellType CellType; - typedef typename Superclass::PointIdentifier PointIdentifier; - typedef typename Superclass::PointsContainer PointsContainer; - typedef typename Superclass::PointType PointType; - - /// QuadEdge types (primal and dual) - typedef QuadEdge< PointIdentifier, CellIdentifier > TPrimalEdge; - typedef typename TPrimalEdge::TDual TDualEdge; - typedef QuadEdgeCell< CellType, TPrimalEdge > TQuadEdgeCell; - - /// Memory management objects - typedef std::set< typename TPrimalEdge::Pointer > CntPrimalEdges; - typedef std::set< typename TDualEdge::Pointer > CntDualEdges; - typedef std::vector< TPrimalEdge* > CntOnextRings; - - /// More geometry types - typedef typename PointType::VectorType VectorType; - typedef typename VectorType::ValueType TScalar; - typedef std::vector< VectorType > CntNormals; - typedef typename CntNormals::const_iterator NormalsIterator; - - protected: - typedef std::vector< TPrimalEdge* > _TEdges; - - public: - itkNewMacro( Self ); - itkTypeMacro( QuadEdgeMesh, itkMesh ); - - public: - // Edge related methods - TPrimalEdge* FindEdge( const PointIdentifier& a ) const; - TPrimalEdge* FindEdge( - const PointIdentifier& a, const PointIdentifier& b - ) const; - TPrimalEdge* FindEntryEdge( const CellIdentifier& i ) const; - - /// New geometric methods - const CntNormals& GetPointNormalsContainer( ) const; - NormalsIterator BeginPointNormals( ) const; - NormalsIterator EndPointNormals( ) const; - const VectorType& GetPointNormal( const PointIdentifier& id ) const; - - /// itk::DataObject methods overloading - virtual bool RequestedRegionIsOutsideOfTheBufferedRegion( ); - - /// itk::PointSet methods overloading - virtual void SetPoints( PointsContainer* points ); - virtual void SetPoint( PointIdentifier id , PointType point ); - - /// itk::Mesh methods overloading - virtual void PassStructure( Self* inputMesh ) - { - std::cout << "PassStructure" << std::endl; - std::exit( 1 ); - } - - virtual void Initialize( ); - virtual void Graft( const itk::DataObject* data ); - - void SetCellLinks( CellLinksContainer* cellLinks ) - { - std::cout << "SetCellLinks" << std::endl; - std::exit( 1 ); - } - virtual CellLinksContainer* GetCellLinks( ) - { - std::cout << "GetCellLinks" << std::endl; - std::exit( 1 ); - } - virtual const CellLinksContainer* GetCellLinks( ) const - { - std::cout << "GetCellLinks (const)" << std::endl; - std::exit( 1 ); - } - virtual void SetCells( CellsContainer* cells ); - virtual void SetCellData( CellDataContainer* data ); - virtual CellDataContainer* GetCellData( ) - { - std::cout << "GetCellData" << std::endl; - std::exit( 1 ); - } - virtual const CellDataContainer* GetCellData( ) const - { - std::cout << "GetCellData (const)" << std::endl; - std::exit( 1 ); - } - -#if !defined( CABLE_CONFIGURATION ) - virtual void SetBoundaryAssignments( - int dimension, BoundaryAssignmentsContainer* container - ) - { - std::cout << "SetBoundaryAssignments" << std::endl; - std::exit( 1 ); - } - virtual BoundaryAssignmentsContainerPointer - GetBoundaryAssignments( int dimension ) - { - std::cout << "GetBoundaryAssignments" << std::endl; - std::exit( 1 ); - } - virtual const BoundaryAssignmentsContainerPointer - GetBoundaryAssignments( int dimension ) const - { - std::cout << "GetBoundaryAssignments (const)" << std::endl; - std::exit( 1 ); - } -#endif - - virtual void SetCell( CellIdentifier id, CellAutoPointer& ptr ); - virtual void SetCellData( CellIdentifier id, CellPixelType data ); - virtual bool GetCellData( CellIdentifier id, CellPixelType* data ) const - { - std::cout << "GetCellData" << std::endl; - std::exit( 1 ); - } - virtual void SetBoundaryAssignment( - int dimension, CellIdentifier cellId, - CellFeatureIdentifier featureId, - CellIdentifier boundaryId - ) - { - std::cout << "SetBoundaryAssignment" << std::endl; - std::exit( 1 ); - } - virtual bool GetBoundaryAssignment( - int dimension, CellIdentifier cellId, - CellFeatureIdentifier featureId, - CellIdentifier* boundaryId - ) const - { - std::cout << "GetBoundaryAssignment" << std::endl; - std::exit( 1 ); - } - virtual bool RemoveBoundaryAssignment( - int dimension, CellIdentifier cellId, - CellFeatureIdentifier featureId - ) - { - std::cout << "RemoveBoundaryAssignment" << std::endl; - std::exit( 1 ); - } - virtual CellFeatureCount GetNumberOfCellBoundaryFeatures( - int dimension, - CellIdentifier id - ) const - { - std::cout << "GetNumberOfCellBoundaryFeatures" << std::endl; - std::exit( 1 ); - } - virtual bool GetCellBoundaryFeature( - int dimension, CellIdentifier id, - CellFeatureIdentifier fid, - CellAutoPointer& ptr - ) const - { - std::cout << "GetCellBoundaryFeature" << std::endl; - std::exit( 1 ); - } - virtual CellIdentifier GetCellBoundaryFeatureNeighbors( - int dimension, - CellIdentifier id, - CellFeatureIdentifier fid, - std::set< CellIdentifier >* cellSet ) - { - std::cout << "GetCellBoundaryFeatureNeighbors" << std::endl; - std::exit( 1 ); - } - virtual CellIdentifier GetCellNeighbors( - CellIdentifier cellId, - std::set< CellIdentifier >* cellSet - ) - { - std::cout << "GetCellNeighbors" << std::endl; - std::exit( 1 ); - } - virtual bool GetAssignedCellBoundaryIfOneExists( - int dimension, CellIdentifier id, - CellFeatureIdentifier fid, - CellAutoPointer& ptr - ) const - { - std::cout << "GetAssignedCellBoundaryIfOneExists" << std::endl; - std::exit( 1 ); - } - virtual void BuildCellLinks( ) const; - - virtual void Accept( CellMultiVisitorType* mv ) const - { - std::cout << "Accept" << std::endl; - std::exit( 1 ); - } - - protected: - QuadEdgeMesh( ); - virtual ~QuadEdgeMesh( ); - - virtual void ReleaseCellsMemory( ) - { - std::cout << "ReleaseCellsMemory" << std::endl; - std::exit( 1 ); - } - - inline bool _CheckPoints( const CellAutoPointer& ptr ) const; - inline void _DeletePoint( const PointIdentifier& pId ); - inline TPrimalEdge* _CreateQuadEdge( - const PointIdentifier& a, const PointIdentifier& b - ); - inline void _DeleteEdge( TPrimalEdge* edge ); - inline void _DeleteFace( const CellIdentifier& f ); - inline void _ConstructEdges( - _TEdges& edges, const CellAutoPointer& ptr - ); - virtual VectorType _ComputePointNormal( const TPrimalEdge* e ) const; - inline void _ReleaseQuadEdgeObjects( ); - - private: - QuadEdgeMesh( const Self& ); // Not implemented - void operator=( const Self& ); // Not implemented - - protected: - CntPrimalEdges m_PrimalEdges; - CntDualEdges m_DualEdges; - - CntOnextRings m_OnextRings; - - CntNormals m_PointNormals; - }; - - } // ecapseman - -} // ecapseman - -#include - -#endif // __CPPLUGINS__EXTENSIONS__QUADEDGEMESH__H__ - -// eof - $RCSfile$ diff --git a/lib/cpPlugins/Extensions/Visualization/MeshMapper.h b/lib/cpPlugins/Extensions/Visualization/MeshMapper.h new file mode 100644 index 0000000..c97835c --- /dev/null +++ b/lib/cpPlugins/Extensions/Visualization/MeshMapper.h @@ -0,0 +1,107 @@ +#ifndef __CPPLUGINS__EXTENSIONS__VISUALIZATION__MESHMAPPER__H__ +#define __CPPLUGINS__EXTENSIONS__VISUALIZATION__MESHMAPPER__H__ + +#include +#include + +class vtkActor; +class vtkInformation; +class vtkRenderer; + +namespace cpPlugins +{ + namespace Extensions + { + namespace Visualization + { + /** + */ + template< class M > + class MeshMapper + : public vtkMapper + { + public: + typedef MeshMapper Self; + vtkTypeMacro( MeshMapper, vtkMapper ); + + typedef M TMesh; + typedef typename M::PointType TPoint; + typedef typename TPoint::VectorType TVector; + typedef typename TPoint::CoordRepType TScalar; + itkStaticConstMacro( Dimension, unsigned int, M::PointDimension ); + + // Begin concept checking +#ifdef ITK_USE_CONCEPT_CHECKING + /* TODO + itkConceptMacro( + InputMeshIsTwoOrThreeimensionalCheck, + ( itk::Concept::SameDimensionOrMinusOne< Self::Dimension, 3 > ) + ); + itkConceptMacro( + ScalarTypeHasFloatResolution, + ( itk::Concept::IsFloatingPoint< TScalar > ) + ); + */ +#endif + // End concept checking + + public: + // TODO: static Self* New( ); + virtual void ShallowCopy( vtkAbstractMapper* m ); + + virtual void SetInputData( M* in ); + virtual M* GetInput( ); + virtual const M* GetInput( ) const; + + virtual double* GetBounds( ); + virtual void GetBounds( double bounds[ 6 ] ); + + virtual void RenderPiece( vtkRenderer* aren, vtkActor* act ) = 0; + virtual void Render( vtkRenderer* aren, vtkActor* act ); + virtual void Update( ); + virtual void Update( int port ); + + virtual void MapDataArrayToVertexAttribute( + const char* vertexAttributeName, + const char* dataArrayName, + int fieldAssociation, + int componentno = -1 + ); + virtual void MapDataArrayToMultiTextureAttribute( + int unit, + const char* dataArrayName, + int fieldAssociation, + int componentno = -1 + ); + virtual void RemoveVertexAttributeMapping( + const char* vertexAttributeName + ); + virtual void RemoveAllVertexAttributeMappings( ); + + protected: + MeshMapper( ); + virtual ~MeshMapper( ); + + virtual void ComputeBounds( ); + virtual int FillInputPortInformation( int port, vtkInformation* info ); + + private: + // These methods aren't supposed to be implemented + MeshMapper( const Self& other ); + Self& operator=( const Self& other ); + + protected: + typename M::Pointer Mesh; + }; + + } // ecapseman + + } // ecapseman + +} // ecapseman + +#include + +#endif // __CPPLUGINS__EXTENSIONS__VISUALIZATION__MESHMAPPER__H__ + +// eof - $RCSfile$ diff --git a/lib/cpPlugins/Extensions/MeshMapper.hxx b/lib/cpPlugins/Extensions/Visualization/MeshMapper.hxx similarity index 75% rename from lib/cpPlugins/Extensions/MeshMapper.hxx rename to lib/cpPlugins/Extensions/Visualization/MeshMapper.hxx index 94b9037..5b44f2c 100644 --- a/lib/cpPlugins/Extensions/MeshMapper.hxx +++ b/lib/cpPlugins/Extensions/Visualization/MeshMapper.hxx @@ -1,25 +1,27 @@ -#ifndef __CPPLUGINS__EXTENSIONS__MESHMAPPER__HXX__ -#define __CPPLUGINS__EXTENSIONS__MESHMAPPER__HXX__ +#ifndef __CPPLUGINS__EXTENSIONS__VISUALIZATION__MESHMAPPER__HXX__ +#define __CPPLUGINS__EXTENSIONS__VISUALIZATION__MESHMAPPER__HXX__ #include #include -// TODO: #include +// TODO: #include // ------------------------------------------------------------------------- /* TODO template< class M > - typename cpPlugins::Extensions::MeshMapper< M >:: - Self* cpPlugins::Extensions::MeshMapper< M >:: + typename cpPlugins::Extensions::Visualization::MeshMapper< M >:: + Self* cpPlugins::Extensions::Visualization::MeshMapper< M >:: New( ) { - return( cpPlugins::Extensions::OpenGLMeshMapper< M >::New( ) ); + return( + cpPlugins::Extensions::Visualization::OpenGLMeshMapper< M >::New( ) + ); } */ // ------------------------------------------------------------------------- template< class M > -void cpPlugins::Extensions::MeshMapper< M >:: +void cpPlugins::Extensions::Visualization::MeshMapper< M >:: ShallowCopy( vtkAbstractMapper* m ) { Self* mapper = Self::SafeDownCast( m ); @@ -30,7 +32,7 @@ ShallowCopy( vtkAbstractMapper* m ) // ------------------------------------------------------------------------- template< class M > -void cpPlugins::Extensions::MeshMapper< M >:: +void cpPlugins::Extensions::Visualization::MeshMapper< M >:: SetInputData( M* in ) { if( this->Mesh != in ) @@ -43,7 +45,7 @@ SetInputData( M* in ) // ------------------------------------------------------------------------- template< class M > -M* cpPlugins::Extensions::MeshMapper< M >:: +M* cpPlugins::Extensions::Visualization::MeshMapper< M >:: GetInput( ) { return( this->Mesh ); @@ -51,7 +53,7 @@ GetInput( ) // ------------------------------------------------------------------------- template< class M > -const M* cpPlugins::Extensions::MeshMapper< M >:: +const M* cpPlugins::Extensions::Visualization::MeshMapper< M >:: GetInput( ) const { return( this->Mesh ); @@ -59,7 +61,7 @@ GetInput( ) const // ------------------------------------------------------------------------- template< class M > -double* cpPlugins::Extensions::MeshMapper< M >:: +double* cpPlugins::Extensions::Visualization::MeshMapper< M >:: GetBounds( ) { // do we have an input @@ -82,7 +84,7 @@ GetBounds( ) // ------------------------------------------------------------------------- template< class M > -void cpPlugins::Extensions::MeshMapper< M >:: +void cpPlugins::Extensions::Visualization::MeshMapper< M >:: GetBounds( double bounds[ 6 ] ) { this->Superclass::GetBounds( bounds ); @@ -90,7 +92,7 @@ GetBounds( double bounds[ 6 ] ) // ------------------------------------------------------------------------- template< class M > -void cpPlugins::Extensions::MeshMapper< M >:: +void cpPlugins::Extensions::Visualization::MeshMapper< M >:: Render( vtkRenderer* aren, vtkActor* act ) { if( this->Mesh.IsNull( ) ) @@ -104,7 +106,7 @@ Render( vtkRenderer* aren, vtkActor* act ) // ------------------------------------------------------------------------- template< class M > -void cpPlugins::Extensions::MeshMapper< M >:: +void cpPlugins::Extensions::Visualization::MeshMapper< M >:: Update( ) { // TODO: @@ -113,7 +115,7 @@ Update( ) // ------------------------------------------------------------------------- template< class M > -void cpPlugins::Extensions::MeshMapper< M >:: +void cpPlugins::Extensions::Visualization::MeshMapper< M >:: Update( int port ) { // TODO: @@ -122,7 +124,7 @@ Update( int port ) // ------------------------------------------------------------------------- template< class M > -void cpPlugins::Extensions::MeshMapper< M >:: +void cpPlugins::Extensions::Visualization::MeshMapper< M >:: MapDataArrayToVertexAttribute( const char* vertexAttributeName, const char* dataArrayName, @@ -135,7 +137,7 @@ MapDataArrayToVertexAttribute( // ------------------------------------------------------------------------- template< class M > -void cpPlugins::Extensions::MeshMapper< M >:: +void cpPlugins::Extensions::Visualization::MeshMapper< M >:: MapDataArrayToMultiTextureAttribute( int unit, const char* dataArrayName, @@ -148,7 +150,7 @@ MapDataArrayToMultiTextureAttribute( // ------------------------------------------------------------------------- template< class M > -void cpPlugins::Extensions::MeshMapper< M >:: +void cpPlugins::Extensions::Visualization::MeshMapper< M >:: RemoveVertexAttributeMapping( const char* vertexAttributeName ) { vtkErrorMacro( "Not implemented at this level..." ); @@ -156,7 +158,7 @@ RemoveVertexAttributeMapping( const char* vertexAttributeName ) // ------------------------------------------------------------------------- template< class M > -void cpPlugins::Extensions::MeshMapper< M >:: +void cpPlugins::Extensions::Visualization::MeshMapper< M >:: RemoveAllVertexAttributeMappings( ) { vtkErrorMacro( "Not implemented at this level..." ); @@ -164,7 +166,7 @@ RemoveAllVertexAttributeMappings( ) // ------------------------------------------------------------------------- template< class M > -cpPlugins::Extensions::MeshMapper< M >:: +cpPlugins::Extensions::Visualization::MeshMapper< M >:: MeshMapper( ) : Superclass( ) { @@ -172,14 +174,14 @@ MeshMapper( ) // ------------------------------------------------------------------------- template< class M > -cpPlugins::Extensions::MeshMapper< M >:: +cpPlugins::Extensions::Visualization::MeshMapper< M >:: ~MeshMapper( ) { } // ------------------------------------------------------------------------- template< class M > -void cpPlugins::Extensions::MeshMapper< M >:: +void cpPlugins::Extensions::Visualization::MeshMapper< M >:: ComputeBounds( ) { static const TScalar _0 = TScalar( 0 ); @@ -210,13 +212,13 @@ ComputeBounds( ) // ------------------------------------------------------------------------- template< class M > -int cpPlugins::Extensions::MeshMapper< M >:: +int cpPlugins::Extensions::Visualization::MeshMapper< M >:: FillInputPortInformation( int port, vtkInformation* info ) { info->Set( vtkAlgorithm::INPUT_REQUIRED_DATA_TYPE( ), "itk::Mesh" ); return( 1 ); } -#endif // __CPPLUGINS__EXTENSIONS__MESHMAPPER__HXX__ +#endif // __CPPLUGINS__EXTENSIONS__VISUALIZATION__MESHMAPPER__HXX__ // eof - $RCSfile$ diff --git a/lib/cpPlugins/Extensions/Visualization/OpenGLMeshMapper.h b/lib/cpPlugins/Extensions/Visualization/OpenGLMeshMapper.h new file mode 100644 index 0000000..f22c6b4 --- /dev/null +++ b/lib/cpPlugins/Extensions/Visualization/OpenGLMeshMapper.h @@ -0,0 +1,80 @@ +#ifndef __CPPLUGINS__EXTENSIONS__VISUALIZATION__OPENGLMESHMAPPER__H__ +#define __CPPLUGINS__EXTENSIONS__VISUALIZATION__OPENGLMESHMAPPER__H__ + +#include + +#include + +namespace cpPlugins +{ + namespace Extensions + { + namespace Visualization + { + /** + */ + template< class M > + class OpenGLMeshMapper + : public MeshMapper< M > + { + public: + typedef OpenGLMeshMapper Self; + vtkTypeMacro( OpenGLMeshMapper, MeshMapper< M > ); + + typedef typename Superclass::TMesh TMesh; + typedef typename Superclass::TPoint TPoint; + typedef typename Superclass::TVector TVector; + typedef typename Superclass::TScalar TScalar; + + protected: + typedef unsigned int TIndex; + typedef typename M::CellType TCell; + typedef typename M::CellsContainer TCellsContainer; + typedef typename TCellsContainer::ConstIterator TCellIt; + + public: + virtual const char* GetNameOfClass( ) const + { return( "cpPlugins::Extensions::OpenGLMeshMapper" ); } + static Self* New( ); + + virtual void RenderPiece( vtkRenderer* aren, vtkActor* act ); + virtual void ReleaseGraphicsResources( vtkWindow* win ); + virtual int Draw( vtkRenderer* aren, vtkActor* act ); + + protected: + OpenGLMeshMapper( ); + virtual ~OpenGLMeshMapper( ); + + bool _ConfigureOpenGL( ); + + private: + // Purposely not implemented + OpenGLMeshMapper( const Self& other ); + Self& operator=( const Self& other ); + + protected: + vtkIdType TotalCells; + // TODO: vtkSmartPointer< vtkOpenGLTexture > InternalColorTexture; + + bool FirstRendering; + + bool VBOSupported; + unsigned int VBOID1, VBOID2; + + std::vector< unsigned int > Sizes; + std::vector< TIndex > Indices; + long IndexElementType; + long ElementValueType; + }; + + } // ecapseman + + } // ecapseman + +} // ecapseman + +#include + +#endif // __CPPLUGINS__EXTENSIONS__VISUALIZATION__OPENGLMESHMAPPER__H__ + +// eof - $RCSfile$ diff --git a/lib/cpPlugins/Extensions/OpenGLMeshMapper.hxx b/lib/cpPlugins/Extensions/Visualization/OpenGLMeshMapper.hxx similarity index 95% rename from lib/cpPlugins/Extensions/OpenGLMeshMapper.hxx rename to lib/cpPlugins/Extensions/Visualization/OpenGLMeshMapper.hxx index 3610b43..524f4e8 100644 --- a/lib/cpPlugins/Extensions/OpenGLMeshMapper.hxx +++ b/lib/cpPlugins/Extensions/Visualization/OpenGLMeshMapper.hxx @@ -1,5 +1,5 @@ -#ifndef __CPPLUGINS__EXTENSIONS__OPENGLMESHMAPPER__HXX__ -#define __CPPLUGINS__EXTENSIONS__OPENGLMESHMAPPER__HXX__ +#ifndef __CPPLUGINS__EXTENSIONS__VISUALIZATION__OPENGLMESHMAPPER__HXX__ +#define __CPPLUGINS__EXTENSIONS__VISUALIZATION__OPENGLMESHMAPPER__HXX__ #include #include @@ -35,8 +35,8 @@ // ------------------------------------------------------------------------- template< class M > -typename cpPlugins::Extensions::OpenGLMeshMapper< M >:: -Self* cpPlugins::Extensions::OpenGLMeshMapper< M >:: +typename cpPlugins::Extensions::Visualization::OpenGLMeshMapper< M >:: +Self* cpPlugins::Extensions::Visualization::OpenGLMeshMapper< M >:: New( ) { return( new Self( ) ); @@ -44,7 +44,7 @@ New( ) // ------------------------------------------------------------------------- template< class M > -void cpPlugins::Extensions::OpenGLMeshMapper< M >:: +void cpPlugins::Extensions::Visualization::OpenGLMeshMapper< M >:: RenderPiece( vtkRenderer* aren, vtkActor* act ) { vtkOpenGLClearErrorMacro( ); @@ -213,7 +213,7 @@ RenderPiece( vtkRenderer* aren, vtkActor* act ) // ------------------------------------------------------------------------- template< class M > -void cpPlugins::Extensions::OpenGLMeshMapper< M >:: +void cpPlugins::Extensions::Visualization::OpenGLMeshMapper< M >:: ReleaseGraphicsResources( vtkWindow* win ) { if( win && win->GetMapped( ) ) @@ -234,7 +234,7 @@ ReleaseGraphicsResources( vtkWindow* win ) // ------------------------------------------------------------------------- template< class M > -int cpPlugins::Extensions::OpenGLMeshMapper< M >:: +int cpPlugins::Extensions::Visualization::OpenGLMeshMapper< M >:: Draw( vtkRenderer* aren, vtkActor* act ) { vtkOpenGLClearErrorMacro( ); @@ -479,7 +479,7 @@ Draw( vtkRenderer* aren, vtkActor* act ) // ------------------------------------------------------------------------- template< class M > -cpPlugins::Extensions::OpenGLMeshMapper< M >:: +cpPlugins::Extensions::Visualization::OpenGLMeshMapper< M >:: OpenGLMeshMapper( ) : Superclass( ), TotalCells( 0 ), @@ -505,7 +505,7 @@ OpenGLMeshMapper( ) // ------------------------------------------------------------------------- template< class M > -cpPlugins::Extensions::OpenGLMeshMapper< M >:: +cpPlugins::Extensions::Visualization::OpenGLMeshMapper< M >:: ~OpenGLMeshMapper( ) { if( this->LastWindow ) @@ -523,7 +523,7 @@ cpPlugins::Extensions::OpenGLMeshMapper< M >:: // ------------------------------------------------------------------------- template< class M > -bool cpPlugins::Extensions::OpenGLMeshMapper< M >:: +bool cpPlugins::Extensions::Visualization::OpenGLMeshMapper< M >:: _ConfigureOpenGL( ) { M* input = this->GetInput( ); @@ -609,6 +609,6 @@ _ConfigureOpenGL( ) return( true ); } -#endif // __CPPLUGINS__EXTENSIONS__OPENGLMESHMAPPER__HXX__ +#endif // __CPPLUGINS__EXTENSIONS__VISUALIZATION__OPENGLMESHMAPPER__HXX__ // eof - $RCSfile$ diff --git a/lib/cpPlugins/Extensions/WaveFrontOBJReader.h b/lib/cpPlugins/Extensions/WaveFrontOBJReader.h deleted file mode 100644 index 373bd48..0000000 --- a/lib/cpPlugins/Extensions/WaveFrontOBJReader.h +++ /dev/null @@ -1,79 +0,0 @@ -#ifndef __CPPLUGINS__EXTENSIONS__WAVEFRONTOBJREADER__H__ -#define __CPPLUGINS__EXTENSIONS__WAVEFRONTOBJREADER__H__ - -#include -#include -#include -#include -#include - -namespace cpPlugins -{ - namespace Extensions - { - /** - * \class WaveFrontOBJReader - * \brief - * Reads a wavefront OBJ file and create an itkMesh. - * - * Caveat1: itkWaveFrontOBJReader will read only vertices and faces. - * Normal, parameters and textures vectors are ignored. - * - */ - template< typename M > - class WaveFrontOBJReader - : public itk::MeshSource< M > - { - public: - typedef WaveFrontOBJReader Self; - typedef itk::MeshSource< M > Superclass; - typedef itk::SmartPointer< Self > Pointer; - typedef itk::SmartPointer< const Self > ConstPointer; - - typedef M MeshType; - typedef typename M::MeshTraits MeshTraits; - typedef typename M::PointType PointType; - typedef typename MeshTraits::PixelType PixelType; - typedef typename M::Pointer MeshPointer; - typedef typename M::CellTraits CellTraits; - typedef typename M::CellIdentifier CellIdentifier; - typedef typename M::CellType CellType; - typedef typename M::CellAutoPointer CellAutoPointer; - typedef typename M::PointIdentifier PointIdentifier; - typedef typename CellTraits::PointIdIterator PointIdIterator; - typedef typename M::PointsContainerPointer PointsContainerPointer; - typedef typename M::PointsContainer PointsContainer; - - typedef itk::PolygonCell< CellType > TPolygonCell; - - public: - itkNewMacro( Self ); - itkTypeMacro( WaveFrontOBJReader, itkMeshSource ); - - itkSetStringMacro( FileName ); - itkGetStringMacro( FileName ); - - protected: - WaveFrontOBJReader( ); - virtual ~WaveFrontOBJReader( ); - - virtual void GenerateData( ); - - private: - // Purposely not implemented - WaveFrontOBJReader( const Self& ); - Self& operator=( const Self & ); - - protected: - std::string m_FileName; - }; - - } // ecapseman - -} // ecapseman - -#include - -#endif // __CPPLUGINS__EXTENSIONS__WAVEFRONTOBJREADER__H__ - -// eof - $RCSfile$ diff --git a/lib/cpPlugins/Interface/Mesh.cxx b/lib/cpPlugins/Interface/Mesh.cxx index 3bcb5af..8a184c9 100644 --- a/lib/cpPlugins/Interface/Mesh.cxx +++ b/lib/cpPlugins/Interface/Mesh.cxx @@ -2,8 +2,8 @@ #include -#include -#include +#include +#include // ------------------------------------------------------------------------- cpPlugins::Interface::Mesh:: @@ -34,10 +34,11 @@ SetDataObject( itk::DataObject* dobj ) this->Superclass::SetDataObject( dobj ); // WARNING: Only 2 and 3 dimensions at this moment - typedef cpPlugins::Extensions::QuadEdgeMesh< float, 2 > _TF2; - typedef cpPlugins::Extensions::QuadEdgeMesh< double, 2 > _TD2; - typedef cpPlugins::Extensions::QuadEdgeMesh< float, 3 > _TF3; - typedef cpPlugins::Extensions::QuadEdgeMesh< double, 3 > _TD3; + using namespace cpPlugins::Extensions; + typedef DataStructures::QuadEdgeMesh< float, 2 > _TF2; + typedef DataStructures::QuadEdgeMesh< double, 2 > _TD2; + typedef DataStructures::QuadEdgeMesh< float, 3 > _TF3; + typedef DataStructures::QuadEdgeMesh< double, 3 > _TD3; if ( dynamic_cast< _TF2* >( dobj ) ) this->_Map< _TF2 >( ); else if( dynamic_cast< _TD2* >( dobj ) ) this->_Map< _TD2 >( ); @@ -57,7 +58,9 @@ template< class M > void cpPlugins::Interface::Mesh:: _Map( ) { - typedef cpPlugins::Extensions::OpenGLMeshMapper< M > _TMapper; + typedef + cpPlugins::Extensions::Visualization::OpenGLMeshMapper< M > + _TMapper; if( this->m_Mapper != NULL ) this->m_Mapper->Delete( ); M* mesh = dynamic_cast< M* >( this->Superclass::GetDataObject( ) ); diff --git a/lib/cpPlugins/Plugins/MeshReader.cxx b/lib/cpPlugins/Plugins/MeshReader.cxx index 17d668c..322e49c 100644 --- a/lib/cpPlugins/Plugins/MeshReader.cxx +++ b/lib/cpPlugins/Plugins/MeshReader.cxx @@ -1,8 +1,8 @@ #include #include -#include -#include +#include +#include // ------------------------------------------------------------------------- cpPlugins::Plugins::MeshReader:: @@ -80,8 +80,9 @@ _GD1( ) if( fIt == this->m_Parameters.end( ) ) fIt = this->m_DefaultParameters.find( "FileName" ); - typedef cpPlugins::Extensions::QuadEdgeMesh< P, D > _TMesh; - typedef cpPlugins::Extensions::MeshReader< _TMesh > _TReader; + using namespace cpPlugins::Extensions; + typedef DataStructures::QuadEdgeMesh< P, D > _TMesh; + typedef IO::MeshReader< _TMesh > _TReader; _TReader* reader = dynamic_cast< _TReader* >( this->m_Reader.GetPointer( ) );