Beispiel #1
0
// Builds the parent child relationships.
void CTiglUIDManager::BuildParentChildTree(void)
{
    UIDStoreContainerType::iterator pIter;

    for (pIter = physicalShapes.begin(); pIter != physicalShapes.end(); ++pIter) {
        CTiglAbstractPhysicalComponent* component = pIter->second;
        if (!component->GetParentUID().empty()) {
            CTiglAbstractPhysicalComponent* parent = GetPhysicalComponent(component->GetParentUID());
            parent->AddChild(component);
        }
    }
}
Beispiel #2
0
// Builds the parent child relationships.
void CTiglUIDManager::BuildParentChildTree(void)
{
    // root component must be set manually, error if not
    if (!rootComponent) {
        throw CTiglError("CTiglUIDManager::BuildParentChildTree(); no root component set!");
    }

    UIDStoreContainerType::iterator pIter;

    for (pIter = physicalShapes.begin(); pIter != physicalShapes.end(); ++pIter) {
        CTiglAbstractPhysicalComponent* component = pIter->second;

        // TODO: when this method is called more than once the components will be added 
        //       multiple times as childs
        if (!component->GetParentUID().empty() && component->GetParentUID() != rootComponent->GetUID()) {
            CTiglAbstractPhysicalComponent* parent = GetPhysicalComponent(component->GetParentUID());
            parent->AddChild(component);
        }
        else {
            rootComponent->AddChild(component);
        }
    }
}
Beispiel #3
0
// Returns the root component of the geometric topology.
void CTiglUIDManager::FindRootComponent(void)
{
    rootComponent = 0;
    UIDStoreContainerType::iterator pIter;
    int parentCnt = 0;

    for (pIter = physicalShapes.begin(); pIter != physicalShapes.end(); ++pIter) {
        CTiglAbstractPhysicalComponent* component = pIter->second;
        if (component->GetParentUID().empty()) {
            if (parentCnt != 0) {
                throw CTiglError("Error: More than one root component found in CTiglUIDManager::FindRootComponent", TIGL_ERROR);
            }
            parentCnt++;
            rootComponent = component;
        }
    }

    if (parentCnt == 0) {
        throw CTiglError("Error: No root component found in CTiglUIDManager::FindRootComponent", TIGL_ERROR);
    }

}
Beispiel #4
0
// Finds and saves all root components and the main root component of the geometric topology.
void CTiglUIDManager::FindRootComponents(void)
{
    rootComponent = 0;
    rootComponentCnt = 0;
    int childCnt = 0;
    int maxChildCnt = -1;

    for (UIDStoreContainerType::iterator pIter = physicalShapes.begin(); pIter != physicalShapes.end(); ++pIter) {
        CTiglAbstractPhysicalComponent* component = pIter->second;
        if (component->GetParentUID().empty()) {
            // Select the component with the maximum number of children as root component if there are multiple components without parentUID in the dataset
            childCnt = static_cast<int>(component->GetChildren(true).size());
            if (childCnt > maxChildCnt) {
                maxChildCnt = childCnt;
                rootComponent = component;
            }
            if (childCnt > 0) {
                allRootComponentsWithChildren[pIter->first] = component;
            }
            rootComponentCnt++;
        }
    }
}
Beispiel #5
0
// Returns the parent component for a component or a null pointer
// if there is no parent.
CTiglAbstractPhysicalComponent* CTiglUIDManager::GetParentComponent(const std::string& uid)
{
    CTiglAbstractPhysicalComponent* component = GetPhysicalComponent(uid);
    std::string parentUID = component->GetParentUID();
    return (parentUID.empty() ? 0 : GetPhysicalComponent(parentUID));
}