コード例 #1
0
void
GaussianControlPointList::SetFromNode(DataNode *parentNode)
{
    int i;
    if(parentNode == 0)
        return;

    DataNode *searchNode = parentNode->GetNode("GaussianControlPointList");
    if(searchNode == 0)
        return;

    //DataNode *node;
    DataNode **children;
    // Clear all the GaussianControlPoints.
    ClearControlPoints();

    // Go through all of the children and construct a new
    // GaussianControlPoint for each one of them.
    children = searchNode->GetChildren();
    for(i = 0; i < searchNode->GetNumChildren(); ++i)
    {
        if(children[i]->GetKey() == std::string("GaussianControlPoint"))
        {
            GaussianControlPoint temp;
            temp.SetFromNode(children[i]);
            AddControlPoints(temp);
        }
    }

}
コード例 #2
0
void ColorControlPointList::SetFromNode(DataNode* parentNode)
{
  if (parentNode == 0)
    return;

  DataNode* searchNode = parentNode->GetNode("ColorControlPointList");
  if (searchNode == 0)
    return;

  DataNode* node;
  DataNode** children;
  // Clear all the ColorControlPoints.
  ClearControlPoints();

  //
  // Try setting the colors from the compact color and position vectors.
  //
  bool colorsAreSet = false;
  DataNode* compactColorNode = searchNode->GetNode("compactColors");
  DataNode* compactPositionNode = searchNode->GetNode("compactPositions");
  if (compactColorNode != 0 && compactPositionNode != 0)
  {
    const unsignedCharVector& colors = compactColorNode->AsUnsignedCharVector();
    const floatVector& positions = compactPositionNode->AsFloatVector();
    unsigned int npts = static_cast<unsigned int>(colors.size() / 4);
    if (npts > static_cast<unsigned int>(positions.size()))
      npts = static_cast<unsigned int>(positions.size());
    if (npts > 0)
    {
      for (unsigned int i = 0; i < npts; ++i)
      {
        int index = i << 2;
        AddControlPoints(ColorControlPoint(
          positions[i], colors[index], colors[index + 1], colors[index + 2], colors[index + 3]));
      }

      colorsAreSet = true;
    }
  }

  if (!colorsAreSet)
  {
    // Go through all of the children and construct a new
    // ColorControlPoint for each one of them.
    children = searchNode->GetChildren();
    for (int i = 0; i < searchNode->GetNumChildren(); ++i)
    {
      if (children[i]->GetKey() == std::string("ColorControlPoint"))
      {
        ColorControlPoint temp;
        temp.SetFromNode(children[i]);
        AddControlPoints(temp);
      }
    }
  }

  if ((node = searchNode->GetNode("smoothingFlag")) != 0)
    SetSmoothingFlag(node->AsBool());
  if ((node = searchNode->GetNode("equalSpacingFlag")) != 0)
    SetEqualSpacingFlag(node->AsBool());
  if ((node = searchNode->GetNode("discreteFlag")) != 0)
    SetDiscreteFlag(node->AsBool());
  if ((node = searchNode->GetNode("externalFlag")) != 0)
    SetExternalFlag(node->AsBool());
}