Ejemplo n.º 1
0
bool ezSockets::Connect(const MString& host, unsigned short port)
{
	if(!Check())
		return false;

#if defined(_XBOX)
	if(!isdigit(host[0])) // don't do a DNS lookup for an IP address
	{
		XNDNS *pxndns = NULL;
		XNetDnsLookup(host.c_str(), NULL, &pxndns);
		while (pxndns->iStatus == WSAEINPROGRESS)
		{
			// Do something else while lookup is in progress
		}

		if (pxndns->iStatus == 0)
			memcpy(&addr.sin_addr, &pxndns->aina[0], sizeof(struct in_addr));
		else
			return false;

		XNetDnsRelease(pxndns);
	}
	else
		addr.sin_addr.s_addr = inet_addr(host.c_str());
#else
	struct hostent* phe;
	phe = gethostbyname(host.c_str());
	if (phe == NULL)
		return false;
	memcpy(&addr.sin_addr, phe->h_addr, sizeof(struct in_addr));
#endif
	addr.sin_family = AF_INET;
	addr.sin_port   = htons(port);

	if(::connect(sock, (struct sockaddr*)&addr, sizeof(addr)) == SOCKET_ERROR)
		return false;

	state = skCONNECTED;
	return true;
}
Ejemplo n.º 2
0
MSyslogMessage5424::MSyslogMessage5424(int facility, int severity, int version,
	const MString& message,
	const MString& timeStamp,
	const MString& hostName,
	const MString& appName,
	const MString& procID,
	const MString& msgID,
	bool flagUTF8) :
  mFacility(facility),
  mSeverity(severity),
  mVersion(version),
  mTimeStamp(timeStamp),
  mHostName(hostName),
  mAppName(appName),
  mProcID(procID),
  mMsgID(msgID),
  mUTF8Flag(flagUTF8),
  mOwnMessage(false)
{
  if (version <= 0) {
    mVersion = 1;
  } else if (version > 999) {
    mVersion = 999;
  }

  if (message == "") {
    mMessage = 0;
    mUTF8Flag = true;
    mMessageSize = 3;		// BOM
  } else {
    mMessage = (unsigned char*)message.strData();
    mMessageSize = message.length();
    if (mUTF8Flag) mMessageSize += 3;
  }
  if (mTimeStamp == "") this->computeTimeStamp();
  if (mHostName  == "") this->getHostName();
  if (mAppName   == "") mAppName = "-";
  if (mProcID    == "") mProcID  = "-";
  if (mMsgID     == "") mMsgID   = "-";
}
Ejemplo n.º 3
0
void LiveScene::attributeNames( NameList &attrs ) const
{
	if( !m_isRoot && m_dagPath.length() == 0 )
	{
		throw Exception( "IECoreMaya::LiveScene::attributeNames: Dag path no longer exists!" );
	}

	tbb::mutex::scoped_lock l( s_mutex );
	attrs.clear();
	attrs.push_back( SceneInterface::visibilityName );

	// translate attributes with names starting with "ieAttr_":
	MFnDependencyNode fnNode( m_dagPath.node() );
	unsigned int n = fnNode.attributeCount();
	for( unsigned int i=0; i<n; i++ )
	{
		MObject attr = fnNode.attribute( i );
		MFnAttribute fnAttr( attr );
		MString attrName = fnAttr.name();
		if( attrName.length() > 7 && ( strstr( attrName.asChar(),"ieAttr_" ) == attrName.asChar() ) )
		{
			attrs.push_back( ( "user:" + attrName.substring( 7, attrName.length()-1 ) ).asChar() );
		}
	}

	// add attributes from custom readers:
	for ( std::vector< CustomAttributeReader >::const_iterator it = customAttributeReaders().begin(); it != customAttributeReaders().end(); it++ )
	{
		it->m_names( m_dagPath, attrs );
	}

	// remove duplicates:
	std::sort( attrs.begin(), attrs.end() );
	attrs.erase( std::unique( attrs.begin(), attrs.end() ), attrs.end() );
}
Ejemplo n.º 4
0
void printAllInstancesUsingIterator()
{
	//
	//	Just use the MItInstancer iterator to enumerate all particles in 
	//	all instancers in the scene.
	//
	MItInstancer it;
	while( !it.isDone() )
	{
		MObject instancerNode = it.instancer();
		MDagPath instancerPath = it.instancerPath();
		MDagPath instancePath = it.path();
		MMatrix instanceMatrix = it.matrix();

		MString instancerNodeName = MFnDependencyNode(instancerNode).name();
		MString instancerPathName = instancerPath.fullPathName();
		MString instancePathName = instancePath.fullPathName();
		
		MMatrix pathMatrix = instancePath.inclusiveMatrix();
		MMatrix finalMatrixForPath = pathMatrix * instanceMatrix;
		MPoint pos = MPoint::origin * finalMatrixForPath;

		char str[512];
		sprintf( str, "Instancer node %s, instancer path %s, instancing path %s at position (%lf,%lf,%lf)",
				instancerNodeName.asChar(), instancerPathName.asChar(), instancePathName.asChar(), pos.x, pos.y, pos.z );
		MGlobal::displayInfo( MString(str) );
		it.next();
	}
}
Ejemplo n.º 5
0
    // Pull the shape data.
    bool pullShape(const CacheFileEntry*   entry, 
                   GPUCache::SubNode::Ptr& geometry
    )
    {
        // Assumption: Called from the main thread.
        assert(geometry);
        if (!geometry) return false;

        // Lock the scheduler
        tbb::unique_lock<tbb::mutex> lock(fBigMutex);

        if (!entry) return false;

        // A list of finished tasks
        std::vector<WorkItem::Ptr> resultItems;

        // Find the entry tasks, we have one or more tasks for reading shapes
        std::pair<ShapeItemPtrListHashIterator,ShapeItemPtrListHashIterator> range =
                fShapeTaskDone.get<1>().equal_range(entry);
        for (ShapeItemPtrListHashIterator iter = range.first; iter != range.second; iter++) {
            resultItems.push_back(*iter);
        }
        fShapeTaskDone.get<1>().erase(range.first, range.second);

        // Background read complete
        BOOST_FOREACH (const WorkItem::Ptr& item, resultItems) {
            assert(item->type() == WorkItem::kShapeWorkItem);

#ifdef DEBUG_SCHEDULER
            MString fileName = entry->fCacheFileName;
            std::cout << "[gpuCache] Background reading (shape) of " << fileName.asChar() << " finished." << std::endl;
#endif

            // Replace the shape node data.
            SubNode::Ptr shape = item->geometry();
            MString      path  = item->validatedGeometryPath();
            if (shape && path.length() > 0) {
                ReplaceSubNodeData(geometry, shape, path);
            }
        }
	void AttributeParser::parseStringData(MFnDependencyNode & node, MObject & attr)
	{
		MStatus status;

		MPlug plug = node.findPlug(attr, &status);
		if (!status) return;

		MString value;
		status = plug.getValue(value);
		if (!status) return;

		if (value.length() == 0)
			return;

		MFnAttribute fnAttr(attr, &status);
		if (!status) return;

		MString name = fnAttr.name(&status);
		if (!status) return;
		
		onString(plug, name, value);
	}
Ejemplo n.º 7
0
renderer::AssemblyInstance* createAssemblyInstance(const MayaObject* obj)
{
    MayaObject* assemblyObject = getAssemblyMayaObject(obj);
    boost::shared_ptr<AppleseedRenderer> appleRenderer = boost::static_pointer_cast<AppleseedRenderer>(getWorldPtr()->mRenderer);
    renderer::Assembly* ass = getAssembly(obj);
    renderer::Assembly* master = getMasterAssemblyFromProject(appleRenderer->getProjectPtr());
    MString assemblyInstanceName = getAssemblyInstanceName(assemblyObject);
    foundation::auto_release_ptr<renderer::AssemblyInstance> assemblyInstance = renderer::AssemblyInstanceFactory::create(assemblyInstanceName.asChar(), renderer::ParamArray(), ass->get_name());
    fillMatrices(obj, assemblyInstance->transform_sequence());
    renderer::AssemblyInstance* assInst = assemblyInstance.get();
    master->assembly_instances().insert(assemblyInstance);
    return assInst;
}
Ejemplo n.º 8
0
MStatus ParameterisedHolder<B>::removeUnecessaryAttributes()
{
	MObjectArray toRemove;
	MFnDependencyNode fnDN( B::thisMObject() );
	for( unsigned i=0; i<fnDN.attributeCount(); i++ )
	{
		MObject attr = fnDN.attribute( i );
		MFnAttribute fnAttr( attr );

		MString attrName = fnAttr.name();
		if( 0==strncmp( attrName.asChar(), g_attributeNamePrefix.c_str(), g_attributeNamePrefix.size() ) )
		{
			if( m_attributeNamesToParameters.find( fnAttr.name() )==m_attributeNamesToParameters.end() )
			{
				MPlug plug( B::thisMObject(), attr );
				plug.setLocked( false ); // we can't remove things if they're locked
				if( fnAttr.parent().isNull() )
				{
					toRemove.append( attr );
				}
				else
				{
					// we don't need to remove attributes which are the children
					// of compounds as they'll be removed when their parent is removed
				}
			}
		}
	}
	for( unsigned i=0; i<toRemove.length(); i++ )
	{
		MStatus s = fnDN.removeAttribute( toRemove[i] );
		if( !s )
		{
			return s;
		}
	}

	return MStatus::kSuccess;
}
Ejemplo n.º 9
0
MStringArray boingRbCmd::parseArguments(MString arg, MString token) {

        MStringArray jobArgsArray;
        MString stringBuffer;
        for (unsigned int charIdx = 0; charIdx < arg.numChars(); charIdx++) {
            MString ch = arg.substringW(charIdx, charIdx);
            //cout<<"ch = "<<ch<<endl;
            if (ch == token ) {
                if (stringBuffer.length() > 0) {
                    jobArgsArray.append(stringBuffer);
                    //cout<<"jobArgsArray = "<<jobArgsArray<<endl;
                    stringBuffer.clear();
                }
            } else {
                stringBuffer += ch;
                //cout<<"stringBuffer = "<<stringBuffer<<endl;
            }
        }
        jobArgsArray.append(stringBuffer);

        return jobArgsArray;
}
Ejemplo n.º 10
0
MString AlembicObject::GetUniqueName(const MString& in_Name)
{
  Abc::OObject parent = GetParentObject();
  bool unique = false;
  MString name = in_Name;
  unsigned int index = 0;
  while (!unique) {
    unique = true;
    for (size_t i = 0; i < parent.getNumChildren(); i++) {
      MString childName = parent.getChildHeader(i).getName().c_str();
      if (childName == name) {
        index++;
        MString indexString;
        indexString.set((double)index);
        name = in_Name + indexString;
        unique = false;
        break;
      }
    }
  }
  return name;
}
Ejemplo n.º 11
0
static void add_to_status_history(const MString& message)
{
    static MString empty = rm(" ");

    if (history == 0)
	history = new MString[status_history_size];

    int last_history = 
	(status_history_size + current_history - 1) % status_history_size;

    if (message.isNull() || message.isEmpty() || message == empty)
	return;

    if (is_prefix(history[last_history], message))
    {
	history[last_history] = message;
	return;
    }

    history[current_history] = message;
    current_history = (current_history + 1) % status_history_size;
}
Ejemplo n.º 12
0
		void operator() ( const MDagPath &dagPath, IECore::SceneInterface::NameList &tags, int filter )
		{
			MString p = dagPath.fullPathName();
			IECorePython::ScopedGILLock gilLock;
			object o;
			try
			{
				o = m_read( p.asChar(), filter );
			}
			catch ( error_already_set )
			{
				PyErr_Print();
				throw IECore::Exception( std::string( "Python exception while evaluating IECoreMaya::LiveScene tags" ) );
			}
			extract<list> l( o );
			if ( !l.check() )
			{
				throw IECore::InvalidArgumentException( std::string( "Invalid value! Expecting a list of strings." ) );
			}
			
			IECorePython::listToSceneInterfaceNameList( l(), tags );
		}
Ejemplo n.º 13
0
void maTranslator::writeHeader(fstream& f, const MString& fileName)
{
	//
	// Get the current time into the same format as used by Maya ASCII
	// files.
	//
	time_t		tempTime = time(NULL);
	struct tm*	curTime = localtime(&tempTime);
	char		formattedTime[100];

	strftime(
		formattedTime, sizeof(formattedTime), "%a, %b %e, %Y %r", curTime
	);

	//
	// Write out the header information.
	//
	f << comment(fTranslatorName).asChar() << " "
		<< fFileVersion.asChar() << " scene" << endl;
	f << comment("Name: ").asChar() << fileName.asChar() << endl;
	f << comment("Last modified: ").asChar() << formattedTime << endl;
}
Ejemplo n.º 14
0
Object colorTextureObject(MString attName, MColor c)
{
	//Object Identifier="./Diffuse/Constant Texture" Label="Constant Texture" Name="" Type="Texture"
	//<Parameter Name="Color" Type="RGB" Value="0.482866 0.456655 0.792157"/>
	MString identifier = MString("./") + texObjMap[attName.asChar()].c_str() + "/Constant Texture";
	MString label = "Constant Texture";
	MString name = "";
	MString type = "Texture";
	Object o("subobject", name, type, label, identifier);
	Parameter p("Color", c);
	o.parameterList.push_back(p);
	return o;
}
/*
 * Return a new string with all occurrences of 'from' replaced with 'to'
 */
std::string replace_all(const MString &str, const char *from, const char *to)
{
    std::string result(str.asChar());
    std::string::size_type
        index = 0,
        from_len = strlen(from),
        to_len = strlen(to);
    while ((index = result.find(from, index)) != std::string::npos) {
        result.replace(index, from_len, to);
        index += to_len;
    }
    return result;
}
Ejemplo n.º 16
0
//is the specified plug on this node animation layered
//used when exporting
bool atomNodeWithAnimLayers::isPlugLayered(const MString &plugName, MStringArray &layerNames)
{
	AttrLayersMap::iterator p;
	std::string stdAttrName(plugName.asChar());
	p = fAttrLayers.find(stdAttrName);
	if(p != fAttrLayers.end())
	{
		PlugsAndLayers val = p->second;
		layerNames = val.mLayerNames;
		return true;
	}
	return false;
}
MStatus DateTimeParameterHandler::doUpdate( IECore::ConstParameterPtr parameter, MPlug &plug ) const
{
	IECore::ConstDateTimeParameterPtr p = IECore::runTimeCast<const IECore::DateTimeParameter>( parameter );
	if( !p )
	{
		return MS::kFailure;
	}

	MObject attribute = plug.attribute();

	// we'd like to be setting the default value here, but as maya doesn't save the default value
	// for dynamic string attributes in scene files, it'll be lost when the scene is reloaded. it's
	// best therefore that we don't set the default at all, so that the default is "", which is what
	// it'll be when we reload the scene - this ensures that any values set in the attribute later
	// will be saved correctly (if we set the default to "X" and the value was "X", maya won't save the
	// default or the value at all, and we end up with a value of "" on scene reload).

	MFnTypedAttribute fnTAttr( attribute );
	if( !fnTAttr.hasObj( attribute ) || fnTAttr.attrType() != MFnData::kString )
	{
		return MS::kFailure;
	}

	// Should this fail if getPlugValue fails?
	MString v = "";
	if( plug.getValue( v ) )
	{
		try
		{
			boost::posix_time::from_iso_string( v.asChar() );
		}
		catch ( boost::bad_lexical_cast )
		{
			return MS::kFailure;
		}
	}

	return finishUpdating( parameter, plug );
}
Ejemplo n.º 18
0
bool SMOnlineRoom::Msg(const MString& command, const MString& data, ChatCommandPack& ccp)
{
    MString tmp;
    MString user;
    MString message;
    if (command.find("msg") == 0)
    {
        tmp = data.substr(command.length()+1);
        if (tmp.length() > 0)
        {
            if (GetPlayerName(data, user))
                if (tmp.length() >= (user.length()+3))
                {
                    ccp.cmd = PM;
                    ccp.data.push(user);
                    ccp.data.push(tmp.substr(user.length()+3));
                    return true;
                }
        }
    }
    return false;
}
Ejemplo n.º 19
0
bool stripFileName(const MString & filePath, MString & fileName)
{
    std::string str(filePath.asChar());
    size_t found;
    found = str.find_last_of("/\\");
    str = str.substr(found+1);

    // str is now in the form of xxx.abc
    found = str.find_first_of(".");
    str = str.substr(0, found);
    fileName = MString(str.c_str());
    return true;
}
MStatus SplitFromImage::splitFromBinaryImage(MFnMesh &mesh, MString image) {
	cout << "Image filename: " << image.asChar() << endl;

	// Load image
	cv::Mat img;
	img = cv::imread(image.asChar(), CV_LOAD_IMAGE_GRAYSCALE);
	if (!img.data) // Check for invalid input
	{
		cout << "Could not open or find the image" << endl;
		return MS::kFailure;
	}

	std::vector<std::vector<cv::Point> > contours;
	std::vector<cv::Vec4i> hierarchy;
	// Find contours
	cv::findContours(img, contours, hierarchy, CV_RETR_EXTERNAL, CV_CHAIN_APPROX_SIMPLE, cv::Point(0, 0));

	for (int i = 0; i < contours.size(); i++) {
		MFloatArray uPoints;
		MFloatArray vPoints;

		for (int j = 0; j < contours[i].size(); j++) {
			cv::Point pt = contours[i][j];
			float u = (float)pt.x / img.cols;
			float v = (float)pt.y / img.rows;
			uPoints.append(u);
			vPoints.append(v);
		}

		MObject newMesh;
		if (addPlaneSubMesh(newMesh, uPoints, vPoints, mesh) == MS::kSuccess)
			cout << "Added plane sub mesh!" << endl;
		else
			cout << "Couldn't add plane sub mesh!" << endl;
 	}

	return MS::kSuccess;
}
Ejemplo n.º 21
0
// Forward Gnuplot error messages to DDD status line
static void SetStatusHP(Agent *, void *client_data, void *call_data)
{
    PlotWindowInfo *plot = (PlotWindowInfo *)client_data;
    DataLength* dl = (DataLength *) call_data;
    string s(dl->data, dl->length);

    (void) plot;		// Use it
#if 0
    if (!plot->active)
    {
	// Probably an invocation problem
	post_gdb_message(s);
	return;
    }
#endif

    if (plot->command != 0)
    {
	string msg = s;
	strip_space(msg);
	MString xmsg = tb(msg);
	XmCommandError(plot->command, xmsg.xmstring());
    }

    while (!s.empty())
    {
	string line;
	if (s.contains('\n'))
	    line = s.before('\n');
	else
	    line = s;
	s = s.after('\n');
	strip_space(line);

	if (!line.empty())
	    set_status(line);
    }
}
Ejemplo n.º 22
0
int MRtmpConnection::run()
{
    int ret = E_SUCCESS;

    if ((ret = m_protocol->handshakeWithClient()) != E_SUCCESS) {
        return ret;
    }

    while (!RequestStop) {
        MRtmpMessage *msg = NULL;
        int res = m_protocol->recv_message(&msg);
        if (res == E_SOCKET_CLOSE_NORMALLY) {
            break;
        }

        if (res != E_SUCCESS) {
            log_error("MRtmpConnection recv_message error.");
            break;
        }

        mMSleep(10);
    }

    if (m_role == Role_Connection_Publish) {
        MString url = m_protocol->getRtmpCtx()->url();
        g_cchannel->sendLine(Internal_CMD_RemoveHasBackSourceRes, url);
        BlsBackSource::instance()->remove(url);

        log_trace("remove url from master(url=%s)", url.c_str());
    }

    m_socket->close();
    deleteLater();

    log_trace("MRtmpConnection exit normally.");

    return E_SUCCESS;
}
Ejemplo n.º 23
0
void CBPoseSpaceCmd::loadVertexPosition(MObject& poseMesh)
{
    MStatus status;
    MFnMesh poseFn(poseMesh, &status);
    unsigned numVertex = poseFn.numVertices();

    float* data = new float[numVertex * 3];

    MString filename = _cacheName + ".pose";

    if(!is_regular_file(filename.asChar()))
        return;

    boost::iostreams::filtering_istream in;
    in.push( boost::iostreams::gzip_decompressor());
    in.push( boost::iostreams::file_source(filename.asChar(), ios::binary));
    if(!in.read((char*)data, numVertex * 3  * 4)) {
        MGlobal::displayError(MString("corrective blendshape failed to read enough data from pose cache ") + _cacheName);
        delete[] data;
        return;
    }


    MPointArray poseVertex;
    poseVertex.setLength(numVertex);

    for(unsigned i=0; i < numVertex; i++)
    {
        poseVertex[i].x = data[i*3];
        poseVertex[i].y = data[i*3+1];
        poseVertex[i].z = data[i*3+2];
    }

    poseFn.setPoints ( poseVertex, MSpace::kObject );
    delete[] data;

    MGlobal::displayInfo(MString("corrective blendshape read sculpt pose from ") + filename);
}
Ejemplo n.º 24
0
    //---------------------------------------------------
    void DagHelper::setArrayPlugSize ( MPlug& plug, uint size )
    {
        if ( plug.node().isNull() ) return;

#if MAYA_API_VERSION >= 800
        MStatus status = plug.setNumElements ( size );
        CHECK_STAT ( status );

#else
        MObject node = plug.node();
        MString plugPath = plug.info();
        if ( node.hasFn ( MFn::kDagNode ) )
        {
            MFnDagNode dagFn ( node );
            int dot = plugPath.index ( '.' );
            plugPath = dagFn.fullPathName() + plugPath.substring ( dot, plugPath.length() );
        }

        MString command = MString ( "setAttr -s " ) + size + " \"" + plugPath + "\";";

        MGlobal::executeCommand ( command );
#endif // MAYA 8.00+
    }
Ejemplo n.º 25
0
bool isNodeSupported(MString typeName, ShaderNode& sn, MObject& shaderObject)
{
	std::string tn(typeName.asChar());
	if(mtm_findShaderTypeByName(tn, sn))
	{
		sn.shaderObject = shaderObject;
		sn.mayaName = getObjectName(shaderObject);
		sn.setPlugShaderName();
		return true;
	}
	logger.debug(MString("Shader type ") + typeName + " not yet supported");
	return false;
	
}
Ejemplo n.º 26
0
MStringList MString::split(const MString &sep)
{
    MString temp(*this);
    MStringList ret;
    if (sep.isEmpty()) {
        return ret;
    }

    while (temp.contains(sep)) {
        size_type index = temp.find(sep);

        MString ss = temp.substr(0, index);
        if (!ss.isEmpty()) {
            ret << ss;
        }
        temp = temp.substr(index + sep.size(), temp.size() - 1);
    }
    if (!temp.isEmpty()) {
        ret << temp;
    }

    return ret;
}
Ejemplo n.º 27
0
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
GOSImage*
GOSImagePool::GetImage(PCSTR image_name)
{
	Check_Object(this);
	MString imageName = image_name;
	Verify(imageName.GetLength() > 0);
	//
	//---------------------------
	// Get the image for the name
	//---------------------------
	//
	GOSImage* image;
	if((image = imageHash.Find(imageName)) == nullptr)
	{
		gos_PushCurrentHeap(Heap);
		image = new GOSImage(image_name);
		Register_Object(image);
		gos_PopCurrentHeap();
		imageHash.AddValue(image, image->imageName);
	}
	Check_Object(image);
	return image;
}
MStatus AlembicPolyMeshToSubdivCommand::doIt(const MArgList& args)
{
	MStatus status;
	MArgParser argData(syntax(), args, &status);

	if (argData.isFlagSet("help"))
	{
		MGlobal::displayInfo("[ExocortexAlembic]: ExocortexAlembic_meshToSubdiv command:");
		MGlobal::displayInfo("                    -m : mesh to assign the initialShadingGroup on");
		return MS::kSuccess;
	}

	const MString mesh = argData.isFlagSet("mesh") ? ("\"" + argData.flagArgumentString("mesh", 0) + "\"") : "";

	MString result;
	MGlobal::executePythonCommand(("ExoAlembic._functions.alembicPolyMeshToSubdiv(" + mesh) + ")", result);
	if (result.length())
	{
		MPxCommand::setResult(result);
		return MS::kFailure;
	}
	return MS::kSuccess;
}
Ejemplo n.º 29
0
    void decreaseFileRef(const MFileObject& file)
    {
        MString resolvedFullName = file.resolvedFullName();
        std::string key = resolvedFullName.asChar();
        tbb::unique_lock<tbb::mutex> lock(fMutex);

        // look up the file ref count
        FileRefCountIterator fileRefCountIter = fFileRefCount.find(key);
        if (fileRefCountIter != fFileRefCount.end()) {
            // decrease the file ref count
            if (--(*fileRefCountIter).second == 0) {
                // file ref count reaches 0
                // purge this reader from cache since the reader won't
                // be referenced any more
                // the reader may already be closed because of the capacity
                fFileRefCount.erase(fileRefCountIter);
                LeftIterator iter = fData.left.find(key);
                if (iter != fData.left.end()) {
                    fData.left.erase(iter);
                }
            }
        }
    }
Ejemplo n.º 30
0
MayaPointPrimitiveWriter::MayaPointPrimitiveWriter(
    double iFrame, MDagPath & iDag, Alembic::AbcGeom::OObject & iParent,
    Alembic::Util::uint32_t iTimeIndex,
    const JobArgs & iArgs) :
    mIsAnimated(false), mDagPath(iDag)
{
    MFnParticleSystem particle(mDagPath);
    MString name = particle.name();

    name = util::stripNamespaces(name, iArgs.stripNamespace);

    Alembic::AbcGeom::OPoints obj(iParent, name.asChar(),
        iTimeIndex);
    mSchema = obj.getSchema();

    Alembic::Abc::OCompoundProperty cp;
    Alembic::Abc::OCompoundProperty up;
    if (AttributesWriter::hasAnyAttr(particle, iArgs))
    {
        cp = mSchema.getArbGeomParams();
        up = mSchema.getUserProperties();
    }

    mAttrs = AttributesWriterPtr(new AttributesWriter(cp, up, obj, particle,
        iTimeIndex, iArgs, true));

    MObject object = iDag.node();
    if (iTimeIndex != 0 && util::isAnimated(object))
    {
        mIsAnimated = true;
    }

    if (!mIsAnimated || iArgs.setFirstAnimShape)
    {
        write(iFrame);
    }
}