#ifndef __CPM__ALGORITHMS__QUADEDGE__MESHZIPFUNCTION__HXX__ #define __CPM__ALGORITHMS__QUADEDGE__MESHZIPFUNCTION__HXX__ // ------------------------------------------------------------------------- template< class M > typename cpm::Algorithms::QuadEdge::MeshZipFunction< M >:: TOutput cpm::Algorithms::QuadEdge::MeshZipFunction< M >:: Evaluate( const TInput& e ) { if( !this->m_Mesh ) { itkDebugMacro( "No mesh present" ); return( TEdge::NoGeometry ); } // fi if( e->IsLeftSet( ) ) { itkDebugMacro( "Incoming edge must be adjacent to NOFACE" ); return( TEdge::NoGeometry ); } // fi // Initial state Final state // // // // | | \ / // // | | \ / // // | | \ / // // | | \ / // // VTrashed Vkept V // // \ / | // // \ / | // // \ ^ | // // \ / | // // \ e | // // \ / | // // \ / | // // ------- Org -------- --------- Org --------- // // / | \ / | \ // // / | \ / | \ // // / | \ / | \ // // // This is the original situation: // // \ / // // \ ^ // // \ a // // \ / // // ------ VRite VLeft -------- // // / \ / \ // // / \ / \ // // / b ^ \ // // / \ / \ // // / v e Rite \ // // / \ / Face \ // // / \ / \ // // V ------------ Org ------------ VOpposite // // / | \ // // / | \ // // // Store for latter usage (since e and e->GetRight( ) will be deleted): TEdge* a = e->GetLnext( ); TEdge* b = e->GetOnext( )->GetSym( ); TOutput VLeft = e->GetDestination( ); TOutput VRight = b->GetOrigin( ); bool wasFacePresent = e->IsRightSet( ); TOutput resultingPointId = TEdge::NoGeometry; // We should be cautious and consider the case when the very // initial situation was the following: // // // * // // * * // // // // VRight = VLeft // // / \ // // / \ // // / \ // // * | * | * // // \ / // // \ / // // \ / // // --------- Org --------- // // / | \ // // / | \ // // / | \ // if( VRight == VLeft ) { if( e->IsWire( ) && b->IsWire( ) ) { /* TODO this->m_Mesh->LightWeightDeleteEdge(e); this->m_Mesh->LightWeightDeleteEdge(b); */ return( resultingPointId ); } // fi } // fi // Delete the Edge e and it's right face: /* TODO: if( wasFacePresent ) this->m_Mesh->DeleteFace( e->GetRight( ) ); this->m_Mesh->LightWeightDeleteEdge(e); */ // We should be cautious and consider the case when the very // initial situation was the following: // \ / // // \ / // // \ / // // \ / // // VRight = VLeft ------- VOpposite // // / \ _/ // // / \ _/ // // / \ * _/ // // | | _/ // // \ / _/ // // \ / _/ // // \ /_/ // // --------- Org --------- // // / | \ // // / | \ // // / | \ // // // in which case the current situation is the following: // // \ / // // \ / // // \ / // // \ / // // VRight = VLeft ------- VOpposite // // / _/ // // / _/ // // / _/ // // | _/ // // \ _/ // // \ _/ // // \ _/ // // --------- Org --------- // // / | \ // // / | \ // // / | \ // // // and hence the connectivity part of "Zip" job is already done. // Check for that case: // if( VLeft != VRight ) { // We are now left with the following situation // // \ / // // \ ^ // // \ a // // \ / // // ----- VRight VLeft -------- // // / \ \ // // / \ \ // // / b \ // // / \ \ // // / v \ // // / \ \ // // / \ \ // // V ------------ Org ------------ VOpposite // // / | \ // // / | \ // // // where we just miss a simple Mesh::Splice( ) to obtain:: // // \ / // // \ / // // \ / // // ---- VRight = VLeft ------ VOpposite // // / \ / // // / \ / // // / b / // // / \ / // // / v / // // / \ / // // / \ / // // V ------------ Org ------------ // // / | \ // // / | \ // // // TODO: resultingPointId = this->m_Mesh->Splice(a, b); } // fi // We restore the deleted face (when it was present): /* TODO: if( wasFacePresent ) this->m_Mesh->AddFace(b); */ this->m_Mesh->Modified( ); return( resultingPointId ); } // ------------------------------------------------------------------------- template< class M > cpm::Algorithms::QuadEdge::MeshZipFunction< M >:: MeshZipFunction( ) : Superclass( ) { } // ------------------------------------------------------------------------- template< class M > cpm::Algorithms::QuadEdge::MeshZipFunction< M >:: ~MeshZipFunction( ) { } #endif // __CPM__ALGORITHMS__QUADEDGE__MESHZIPFUNCTION__HXX__ // eof - $RCSfile$