bool
TopologyRefinerFactoryBase::prepareComponentTopologyAssignment(TopologyRefiner& refiner, bool fullValidation,
                                                               TopologyCallback callback, void const * callbackData) {

    Vtr::internal::Level& baseLevel = refiner.getLevel(0);

    bool completeMissingTopology = (baseLevel.getNumEdges() == 0);
    if (completeMissingTopology) {
        if (not baseLevel.completeTopologyFromFaceVertices()) {
            char msg[1024];
            snprintf(msg, 1024,
                    "Invalid topology detected : vertex with valence %d > %d max.",
                    baseLevel.getMaxValence(), Vtr::VALENCE_LIMIT);
            Warning(msg);
            return false;
        }
    } else {
        if (baseLevel.getMaxValence() == 0) {
            char msg[1024];
            snprintf(msg, 1024, "Invalid topology detected : maximum valence not assigned.");
            Warning(msg);
            return false;
        }
    }

    if (fullValidation) {
        if (not baseLevel.validateTopology(callback, callbackData)) {
            char msg[1024];
            snprintf(msg, 1024,
                     completeMissingTopology ?
                    "Invalid topology detected as completed from partial specification." :
                    "Invalid topology detected as fully specified.");
            Warning(msg);
            return false;
        }
    }

    //  Now that we have a valid base level, initialize the Refiner's component inventory:
    refiner.initializeInventory();
    return true;
}