コード例 #1
0
void traverse(Abc::IObject object, bool includeSelf)
{
    if (includeSelf)
    {
        std::cout << "---------------------------------" << std::endl;
        std::cout << object.getFullName() << std::endl;
        
        
        
        
        if (Mat::IMaterial::matches(object.getHeader()))
        {
            std::cout << "(is material, local data shown)\n";
            Mat::IMaterial mat(object, Abc::kWrapExisting);
            printMaterialSchema(mat.getSchema());
            TESTING_ASSERT(object.getName() == "materialA" ||
                object.getName() == "materialB");
        }
        else
        {
            Mat::MaterialFlatten mafla(object);

            std::string name = object.getName();
            std::cout << name << " " << mafla.empty() << std::endl;
            TESTING_ASSERT(
                (!mafla.empty() &&
                    (name == "geoA" || name == "geoB" || name == "geoC")) ||
                (mafla.empty() &&
                    (name == "geometry" || name == "materials")));

            if (!mafla.empty())
            {
                std::cout << "(flattened material via has and/or assigned)\n";
                printFlattenedMafla(mafla);
            }
            else
            {
                std::cout << "(neither is, has or is assigned)\n";
            }
        }
        
        
        
        
        
        
        
        
    }
    
    for (size_t i = 0; i < object.getNumChildren(); ++i)
    {
        traverse(object.getChild(i), true);
    }
    
}
コード例 #2
0
ファイル: AbcTree.cpp プロジェクト: AWhetter/alembic
//-*****************************************************************************
bool is_leaf( AbcG::IObject iObj )
{
    if ( !iObj.getParent().valid() ) {
        return true;
    }

    Abc::IObject parent = iObj.getParent();
    int numChildren = parent.getNumChildren();

    Abc::IObject test = parent.getChild(numChildren - 1);
    if ( test.valid() && test.getName() != iObj.getName() ) {
        return false;
    }
    return true;
}
コード例 #3
0
// returns the number of nodes
int prescanAlembicHierarchy(AbcArchiveCache* pArchiveCache,
                            AbcObjectCache* pRootObjectCache,
                            std::vector<std::string>& nodes,
                            std::map<std::string, bool>& map,
                            bool bIncludeChildren)
{
  for (int i = 0; i < nodes.size(); i++) {
    boost::to_upper(nodes[i]);
  }

  std::list<AlembicSelectionStackElement> sceneStack;

  for (size_t j = 0; j < pRootObjectCache->childIdentifiers.size(); j++) {
    AbcObjectCache* pChildObjectCache =
        &(pArchiveCache->find(pRootObjectCache->childIdentifiers[j])->second);
    sceneStack.push_back(
        AlembicSelectionStackElement(pChildObjectCache, false));
  }

  int nNumNodes = 0;
  while (!sceneStack.empty()) {
    AlembicSelectionStackElement sElement = sceneStack.back();
    Alembic::Abc::IObject iObj = sElement.pObjectCache->obj;
    bool bSelected = sElement.bSelected;
    sceneStack.pop_back();

    nNumNodes++;

    bool bCreateNullNode = false;
    int nMergedGeomNodeIndex = -1;
    AbcObjectCache* pMergedChildObjectCache = NULL;
    getMergeInfo(pArchiveCache, sElement.pObjectCache, bCreateNullNode,
                 nMergedGeomNodeIndex, &pMergedChildObjectCache);

    std::string name;
    std::string fullname;

    if (nMergedGeomNodeIndex != -1) {  // we are merging
      Alembic::AbcGeom::IObject mergedGeomChild = pMergedChildObjectCache->obj;
      name = mergedGeomChild.getName();
      fullname = mergedGeomChild.getFullName();
    }
    else {  // geometry node(s) under a dummy node (in pParentMaxNode)
      name = iObj.getName();
      fullname = iObj.getFullName();
    }

    bool bSelectChildren = false;

    if (bSelected) {
      map[fullname] = true;
      bSelectChildren = true;
    }
    else {
      boost::to_upper(name);
      for (int i = 0; i < nodes.size(); i++) {
        const char* cstrName = name.c_str();
        const char* cstrNode = nodes[i].c_str();

        if (name.find(nodes[i]) != std::string::npos) {
          if (bIncludeChildren) {
            bSelectChildren = true;
          }

          std::vector<std::string> parts;
          boost::split(parts, fullname, boost::is_any_of("/"));

          std::string nodeName;
          for (int j = 1; j < parts.size(); j++) {
            nodeName += "/";
            nodeName += parts[j];
            map[nodeName] = true;
          }
        }
      }
    }

    // push the children as the last step, since we need to who the parent is
    // first (we may have merged)
    for (size_t j = 0; j < sElement.pObjectCache->childIdentifiers.size();
         j++) {
      AbcObjectCache* pChildObjectCache =
          &(pArchiveCache->find(sElement.pObjectCache->childIdentifiers[j])
                ->second);
      Alembic::AbcGeom::IObject childObj = pChildObjectCache->obj;
      NodeCategory::type childCat = NodeCategory::get(childObj);
      if (childCat == NodeCategory::UNSUPPORTED)
        continue;  // skip over unsupported types

      // I assume that geometry nodes are always leaf nodes. Thus, if we merged
      // a geometry node will its parent transform, we don't
      // need to push that geometry node to the stack.
      // A geometry node can't be combined with its transform node, the
      // transform node has other tranform nodes as children. These
      // nodes must be pushed.
      if (nMergedGeomNodeIndex != j) {
        sceneStack.push_back(
            AlembicSelectionStackElement(pChildObjectCache, bSelectChildren));
      }
    }
  }

  return nNumNodes;
}