• No results found

Implementing the ML Clustering Process

4.2 Realizing Multilevel Mesh Clustering

4.2.2 Implementing the ML Clustering Process

To keep track of all valid clusters, we propose to use a Cluster Array structure defined according to the Definition 4.3.

Definition 4.3. A Cluster Array (CA) is an array of a fixed length k that stores the references to all created clusters, see Figure 4.7.

A Cluster Array, see Figure 4.7, keeps references to all clusters. If a cluster gets invali-dated due to some merging operation, then it is simply marked as invalid.

C0 C1 C2 C3 . . . Ck−4 Ck−3 Ck−2 Ck−1

Figure 4.7: The Cluster Array (CA).

Now, each cluster Ci in part has three flags that describe the cluster’s state:

• C.affected flag is set to true if the cluster configuration is affected in some way by a merging or optimization operation.

• C.needOptimization flag is set to true if the cluster configuration requires opti-mization due to merging or a change in the cluster configuration.

• C.validODE flag is set to true if the cluster’s ODE is valid and the collapse cost is updated.

Initialization:

Before a ML clustering (Algorithm 4.1) can start it requires an initial starting configuration.

In the initialization step each mesh face Fj ∈ M is assigned to an individual cluster Ci, i = j, as shown in Figure 4.8. As a result the total number of clusters is equal to m.

F0 F1 F2 F3 . . . Fk−4 Fk−3 Fk−2 Fk−1

C0 C1 C2 C3 . . . Ck−4 Ck−3 Ck−2 Ck−1

Figure 4.8: The Cluster Array (CA) after initialization.

At this step no ODEs are identified. We only flag each cluster in the CA as being unchanged C.affected=false and C.needOptimization=false, i.e. the cluster configu-ration has not changed and it does not require optimization. However, we set the cluster’s ODE as being non-updated C.validODE=false, i.e. the ODE of this cluster is no longer determined.

Dual Edge Collapse:

At this step an ODE with minimal cost must be identified in the CA and the collapse operation applied to this ODE.

To efficiently identify a cluster with the smallest cost regarding its ODE out of all ODEs, we apply a single step of a bubble sort to the CA to move this cluster to the end of the CA, see Figure 4.9. If a cluster has an invalid ODE, i.e. C.validODE==false, then an ODE is identified for this cluster using the updateODE() subroutine, see Section 4.2.1. The

C Cq C Cl . . . C C C C

C C Cl C . . . C C C CODEmin

Figure 4.9: Applying a single step of bubble sort to the CA will move the cluster with smallest cost ODE to the end of CA. In this case CODEmin.ODE.opposite = Cl.

C1 C0

C2

40 10

15 Cl 5

CODEmin

C1 C0

C2

Clnew

(a) (b)

Figure 4.10: Example of a Dual Edge collapse. (a) Initial configuration. The CODEmin has smallest cost ODE. (b) Collapsing the ODE. Reassigns cluster’s data and faces to the cluster Cnewl .

C C Cl C . . . C C C CODEmin

C C Clnew C . . . C C C XX

XXX

CODEmin

Figure 4.11: Merging cluster CODEmin with Cl will result in a new cluster Clnew. Where the last cluster in the CA automatically becomes invalid by decreasing the number of clusters by one.

merging cost of the ODE is then used to decide if a given cluster has the smallest merging cost4.

Note that using the CA with all clusters ODEs and a single step of the bubble sort is an efficient solution to identify the minimal cost DE. Using a Priority Queue will result in O(n log n) complexity, because the PQ needs to be rebuilt after each optimization phase which vary the number of DEs. This is in contrast to hierarchical clustering where the number of PQ elements is fixed.

A Dual Edge collapse operation is applied to the ODE of the last valid cluster in the

4In the case of two clusters having the same merging cost, the cluster with smallest number of faces must be in general promoted. This reduces the number of operations in the merging step and the information stored for the multilevel representation.

CA, i.e. to the CODEmin, see Figure 4.9. Collapsing an ODE means merging two adjacent clusters into one representative cluster. The merging is applied between CODEmin and the opposite cluster that makes up the ODE, e.g. in Figures 4.10-4.11 the cluster Cl is the opposite cluster of ODEmin.

Figure 4.10 provides an example of a collapse operation, while Figure 4.11 shows how these changes are propagated to the CA. In the merging operation the cluster’s data and faces are reassigned to a new representative cluster Cnewl . After this operation the last cluster CODEmin in CA is invalidated, by reducing the number of valid clusters by one, as shown in Figure 4.11. Because the configuration of Cnewl cluster has changed we set its identifier Cnewl .affected to true and Cnewl .needOptimization to true, which indicates for the next step that only this cluster requires optimization.

Optimization:

The EMLO algorithm (Algorithm 3.3) is used to perform the optimization. The opti-mization is executed only for clusters that require optiopti-mization, i.e. which are flagged as C.needOptimization==true.

After performing the optimization we indicate that a given cluster does not require any further optimization by resetting its flag to C.needOptimization=false.

Any change in the cluster configuration during energy minimization flags the oppo-site cluster as requiring optimization, i.e. C.needOptimization=true. Thus, in the next optimization loop these clusters are also handled. This process repeats until no cluster configuration change occurs, i.e. all clusters have C.needOptimization=false.

Observe that the energy minimization always starts with the cluster most affected by the collapse operation, i.e. the cluster optimization is always applied to the merged cluster first, followed by an outwards propagation of that change to the neighboring clusters. This will lead to a better convergence behavior of the Multilevel approach.

After the optimization step any cluster that has been affected by the optimization will have a flag C.affected=true. Each of these clusters and its neighbors most probably have an invalid ODE, thus we reset the flag for all of them to C.validODE=false. This triggers a new identification of ODEs for these clusters and leads to a correct identification of ODEs for neighboring clusters as well.