Ejemplo n.º 1
0
void wendy_GIO_ROP::save_mata_ass(string arDsoPath,string dpCachePath,GU_Detail *gdp )
{
    //get arnold dso path


    g_particle_mataAss assROP;
    ofstream fout;
    string getCacheDP=dpCachePath;

    stringstream ss(getCacheDP);
    string sub_str;
    vector <string> sp_strPath;
    sp_strPath.clear();
    while(getline(ss,sub_str,'.'))
    {
        sp_strPath.push_back(sub_str);
    }

    string newAssPathName = sp_strPath[0]+"."+sp_strPath[1]+string(".ass");
    fout.open(newAssPathName);
    assROP.setGioCachePath(getCacheDP);  // set Link GIO CACHE
    for (GA_AttributeDict::iterator it = gdp->getAttributeDict(GA_ATTRIB_POINT).begin(GA_SCOPE_PUBLIC); !it.atEnd(); ++it)
    {
        GA_Attribute *attrib = it.attrib();
        string attName( attrib->getName() );
        assROP.inserExtraMataInfo(attName);
    }
    //set ass bbox
    UT_BoundingBox BBOX;
    gdp->getBBox(&BBOX);
    BBOX.expandBounds(2,2,2);
    float min_x=BBOX.xmin();
    float min_y=BBOX.xmin();
    float min_z=BBOX.xmin();
    float max_x=BBOX.xmax();
    float max_y=BBOX.ymax();
    float max_z=BBOX.zmax();
    assROP.setBBOX(min_x,min_y,min_z,max_x,max_y,max_z);
    assROP.setDsoPath(arDsoPath);
    assROP.save(fout);
    fout.close();
}
VError ThrowError( VError inError, const VString *inParam, ...)
{
	VErrorBase *errBase = new VErrorBase( inError, 0);
	if (errBase != NULL)
	{
		VValueBag *bag = errBase->GetBag();
		if (bag != NULL)
		{
			VIndex paramNum = 1;
			
			va_list argList;
			va_start( argList, inParam);
			
			for (const VString *param = inParam ; param != NULL ; param = va_arg( argList, const VString*), ++paramNum)
			{
				VString attName( "param");
				attName.AppendLong( paramNum);
				bag->SetString( attName, *param);
			}
			
			va_end( argList);
		}
Ejemplo n.º 3
0
//! Query the name of an attribute given a location id, a variable id and the attribute number
int CNetCdfInterface::inqAttName(int ncid, int varid, int attnum, StdString& name)
{
  std::vector<char> attName(NC_MAX_NAME + 1,' ');
  int status = nc_inq_attname(ncid, varid, attnum, &attName[0]);
  if (NC_NOERR != status)
  {
    StdString errormsg(nc_strerror(status));
    StdStringStream sstr;

    sstr << "Error when calling function nc_inq_attname(ncid, varid, attnum, attName)" << std::endl;
    sstr << errormsg << std::endl;
    sstr << "Unable to query the name: " << name << " of attribute " << attnum << " given the location id:" << ncid << " and the variable id:" << varid << std::endl;
    StdString e = sstr.str();
    throw CNetCdfException(e);
  }

  int nameSize = 0;
  while ((nameSize < NC_MAX_NAME) && (' ' != attName[nameSize] )) ++nameSize;
  name.resize(nameSize);
//  for (int idx = 0; idx < nameSize; ++idx) name.at(idx) = attName[idx];
  std::copy(&attName[0], &attName[nameSize-1], name.begin());

  return status;
}
Ejemplo n.º 4
0
static void updateAttributeList(g_global_io &io,GU_Detail *cur_gdp)
{
    fpreal numPt= cur_gdp->getNumPoints();
    GA_Iterator iter(cur_gdp->getPointRange());
    fpreal start_point_num = *iter;

    if ( cur_gdp )
    {
        for (GA_AttributeDict::iterator it = cur_gdp->getAttributeDict(GA_ATTRIB_POINT).begin(GA_SCOPE_PUBLIC); !it.atEnd(); ++it)
        {
            GA_Attribute *attrib = it.attrib();
            UT_String attName( attrib->getName() );
            // std::cout<<"the att name is"<<attName<<std::endl;
            int attSize = attrib->getTupleSize();
            GA_StorageClass     storage= attrib->getStorageClass();
            GA_TypeInfo typeInfo = attrib->getTypeInfo();

            //save mata info



            switch(attSize)
            {
            case 1:                    // per  int or float
                if(storage==GA_STORECLASS_FLOAT)
                {
                    std::cout<<"the att name is "<<attName<< " and the type is float\n";
                    g_particles_io t_io;
                    t_io.GIO_SetCurrentAttributeName(attName);
                    t_io.GIO_SetCurrentAttributeType(g_particles_io::FLT_TYPE);
                    std::vector<float> t_value;  // create empty stack
                    forkTheFLTData(t_value,attrib,numPt,start_point_num);
                    t_io.GIO_setFLTAttributeList(t_value);
                    io.GIO_installParticleHandle(t_io);  // install this attribute into our global IO

                }
                if(storage==GA_STORECLASS_INT)
                {
                    std::cout<<"the att name is "<<attName<< " and the type is int\n";
                    g_particles_io t_io;
                    t_io.GIO_SetCurrentAttributeName(attName);
                    t_io.GIO_SetCurrentAttributeType(g_particles_io::INT_TYPE);
                    std::vector<int> t_value;  // create empty  int stack
                    forkTheINTData(t_value,attrib,numPt,start_point_num);
                    t_io.GIO_setINTAttributeList(t_value);
                    io.GIO_installParticleHandle(t_io);
                }
                break;
            case 3:                   // int vector or float vector
                if(storage==GA_STORECLASS_FLOAT)
                {
                    std::cout<<"the att name is "<<attName<< " and the type is float vector\n";
                    g_particles_io t_io;
                    t_io.GIO_SetCurrentAttributeName(attName);
                    t_io.GIO_SetCurrentAttributeType(g_particles_io::FLT_VEC_TYPE);
                    std::vector<per_float_vector> t_value;  // create empty  int stack
                    forkTheFLTVectorData(t_value,attrib,numPt,start_point_num);
                    t_io.GIO_setFLTVecAttributeList(t_value);
                    io.GIO_installParticleHandle(t_io);

                }
                if(storage==GA_STORECLASS_INT)
                {
                    std::cout<<"the att name is "<<attName<< " and the type is int vector\n";
                    g_particles_io t_io;
                    t_io.GIO_SetCurrentAttributeName(attName);
                    t_io.GIO_SetCurrentAttributeType(g_particles_io::INT_VEC_TYPE);
                    std::vector<per_int_vector> t_value;  // create empty  int stack
                    forkTheINTVectorData(t_value,attrib,numPt,start_point_num);
                    t_io.GIO_setINTVecAttributeList(t_value);
                    io.GIO_installParticleHandle(t_io);
                }
                break;
            case 4:                   // P attrib
            {
                std::cout<<"the att name is "<<attName<< " and the type is float 4 \n";
                g_particles_io t_io;
                t_io.GIO_SetCurrentAttributeName(attName);
                t_io.GIO_SetCurrentAttributeType(g_particles_io::FLT_VEC_TYPE);
                std::vector<per_float_vector> t_value;  // create empty  int stack
                forkTheFLTVectorData(t_value,it.attrib(),numPt,start_point_num);

                t_io.GIO_setFLTVecAttributeList(t_value);
                io.GIO_installParticleHandle(t_io);
            }

            break;
            }

        }
    }
}
Ejemplo n.º 5
0
void XSAXMLScanner::scanRawAttrListforNameSpaces(int attCount)
{
    //  Make an initial pass through the list and find any xmlns attributes or
    //  schema attributes.
    //  When we find one, send it off to be used to update the element stack's
    //  namespace mappings.
    int index = 0;
    for (index = 0; index < attCount; index++)
    {
        // each attribute has the prefix:suffix="value"
        const KVStringPair* curPair = fRawAttrList->elementAt(index);
        const XMLCh* rawPtr = curPair->getKey();

        //  If either the key begins with "xmlns:" or its just plain
        //  "xmlns", then use it to update the map.
        if (!XMLString::compareNString(rawPtr, XMLUni::fgXMLNSColonString, 6)
        ||  XMLString::equals(rawPtr, XMLUni::fgXMLNSString))
        {
            const XMLCh* valuePtr = curPair->getValue();

            updateNSMap(rawPtr, valuePtr, fRawAttrColonList[index]);

            // if the schema URI is seen in the the valuePtr, set the boolean seeXsi
            if (XMLString::equals(valuePtr, SchemaSymbols::fgURI_XSI)) {
                fSeeXsi = true;
            }
        }
    }

    // walk through the list again to deal with "xsi:...."
    if (fSeeXsi)
    {
        //  Schema Xsi Type yyyy (e.g. xsi:type="yyyyy")
        XMLBufBid bbXsi(&fBufMgr);
        XMLBuffer& fXsiType = bbXsi.getBuffer();

        QName attName(fMemoryManager);

        for (index = 0; index < attCount; index++)
        {
            // each attribute has the prefix:suffix="value"
            const KVStringPair* curPair = fRawAttrList->elementAt(index);
            const XMLCh* rawPtr = curPair->getKey();

            attName.setName(rawPtr, fEmptyNamespaceId);
            const XMLCh* prefPtr = attName.getPrefix();

            // if schema URI has been seen, scan for the schema location and uri
            // and resolve the schema grammar; or scan for schema type
            if (resolvePrefix(prefPtr, ElemStack::Mode_Attribute) == fSchemaNamespaceId) {

                const XMLCh* valuePtr = curPair->getValue();
                const XMLCh* suffPtr = attName.getLocalPart();

                if (XMLString::equals(suffPtr, SchemaSymbols::fgXSI_TYPE)) {
                    fXsiType.set(valuePtr);
                }
                else if (XMLString::equals(suffPtr, SchemaSymbols::fgATT_NILL)
                         && XMLString::equals(valuePtr, SchemaSymbols::fgATTVAL_TRUE)) {
                    ((SchemaValidator*)fValidator)->setNillable(true);
                }
            }
        }

        if (!fXsiType.isEmpty())
        {
            int colonPos = -1;
            unsigned int uriId = resolveQName
            (
                fXsiType.getRawBuffer(), fPrefixBuf, ElemStack::Mode_Element, colonPos
            );
            ((SchemaValidator*)fValidator)->setXsiType(fPrefixBuf.getRawBuffer(), fXsiType.getRawBuffer() + colonPos + 1, uriId);
        }
    }
}