コード例 #1
0
ファイル: NodeId.cpp プロジェクト: bilgili/Livre
NodeIds NodeId::getChildren() const
{
    if( _level == INVALID_LEVEL )
        return NodeIds();

    NodeIds nodeIds;
    const Vector3ui childPos = getPosition() * 2;
    for( uint32_t x = 0; x < 2; ++x )
    {
        for( uint32_t y = 0; y < 2; ++y )
        {
            for( uint32_t z = 0; z < 2; ++z )
            {
                const Vector3ui pos( childPos[ 0 ] + x,
                                     childPos[ 1 ] + y,
                                     childPos[ 2 ] + z );
                nodeIds.push_back( NodeId( _level + 1, pos, _timeStep ) );
            }
        }
    }
    return nodeIds;
}
コード例 #2
0
    ConstCacheObjects generateRenderingSet( const NodeIds& visibles,
                                            size_t& nAvailable,
                                            size_t& nNotAvailable ) const
    {
        ConstCacheMap cacheMap;
        for( const NodeId& nodeId : visibles )
        {
            collectLoadedTextures( nodeId, cacheMap );
            cacheMap.count( nodeId.getId( )) > 0 ? ++nAvailable : ++nNotAvailable;
        }

        if( visibles.size() != cacheMap.size( ))
        {
            ConstCacheMap::const_iterator it = cacheMap.begin();
            size_t previousSize = 0;
            do
            {
                previousSize = cacheMap.size();
                while( it != cacheMap.end( ))
                {
                    if( hasParentInMap( NodeId( it->first ), cacheMap ))
                        it = cacheMap.erase( it );
                    else
                        ++it;
                }
            }
            while( previousSize != cacheMap.size( ));
        }

        ConstCacheObjects cacheObjects;
        cacheObjects.reserve( cacheMap.size( ));
        for( ConstCacheMap::const_iterator it = cacheMap.begin();
             it != cacheMap.end(); ++it )
        {
            cacheObjects.push_back( it->second );
        }

        return cacheObjects;
    }
コード例 #3
0
ファイル: NodeId.cpp プロジェクト: chevtche/Livre
NodeIds NodeId::getChildrenAtLevel(const uint32_t level) const
{
    if (_level == INVALID_LEVEL || _level >= level)
        return NodeIds();

    NodeIds nodeIds;
    const uint32_t childCount = 1u << (level - _level);
    const Vector3f& startPosInLevel = getPosition() * childCount;

    for (uint32_t x = 0; x < childCount; ++x)
    {
        for (uint32_t y = 0; y < childCount; ++y)
        {
            for (uint32_t z = 0; z < childCount; ++z)
            {
                const Vector3ui pos(startPosInLevel[0] + x,
                                    startPosInLevel[1] + y,
                                    startPosInLevel[2] + z);
                nodeIds.push_back(NodeId(level, pos, _timeStep));
            }
        }
    }
    return nodeIds;
}
コード例 #4
0
ファイル: NodeId.cpp プロジェクト: chevtche/Livre
NodeId NodeId::getRoot() const
{
    return NodeId(0, getPosition() / (1u << _level), _timeStep);
}
コード例 #5
0
TVerdict CTcpClientTestUPnP13::RunTestL()
	{
	switch ( iState )
		{
		case ECreateTestServer:
			{
			iLogger.WriteFormat(_L("<i>Creating TestServer..... </i>"));
			
			iTestServer = CTestTcpServer::NewL ( *this );
			
			iState  = ECreateTestClient;
			iStatus = KRequestPending;			
			Reschedule();
			return EPass;
			}
		
		case ECreateTestClient:
			{
			iLogger.WriteFormat(_L("<i>TestServer is created..... </i>"));			
			iLogger.WriteFormat(_L("<i>Creating TestClient..... </i>"));
			
			THttpClientFlowQuery flowQuery ( TAppProtAddr ( KInetAddrLoop, KHttpDefaultPort ), Id (), EHttpClientFlow, THttpClientFlowQuery::ECreateNew, iChunkManager );
			const TUid requestedUid = { CUPnPFlowFactory::iUid };
			
			TNodeId factoryContainer = SockManGlobals::Get( )->GetPlaneFC( TCFPlayerRole ( TCFPlayerRole::EDataPlane ) );
			
			RClientInterface::OpenPostMessageClose ( NodeId (), TNodeCtxId ( KActivityNull, factoryContainer ), TCFFactory::TFindOrCreatePeer ( TCFPlayerRole::EDataPlane, requestedUid, &flowQuery ).CRef () );
			
			iState  = ESendRequestData;
			iStatus = KRequestPending;
			Reschedule();
			return EPass;
			}
		
		case ESendRequestData:
			{
			iLogger.WriteFormat(_L("<i>Client is Created</i>"));
			iLogger.WriteFormat(_L("<i>Send data..... </i>"));
			
			TPtrC8 data(KData1);
			TPtrC8 data2(KData2);
			TPtrC8 data3(KData3);
			
			iSSP->SetOption(KCHOptionLevel, KCHAbsoluteUri, _L8 ("http://127.0.0.1"));
			
			TCHMessageOption option ( 1, data.Length()+data2.Length()+data3.Length() );
			
			TPckg < TCHMessageOption > optionBuf ( option );
			
			iSSP->SetOption(KCHOptionLevel, KCHMaxLength, optionBuf);
			
			RMBufChain bodyBuf;
			bodyBuf.CreateL(KData1);
			iSSPData->Write(bodyBuf, 0, NULL);
			
			/*
			
			TCHMessageOption option2 ( 1, data2.Length() );
			TPckg < TCHMessageOption > optionBuf2 ( option2 );
			
			iSSP->SetOption(KCHOptionLevel, KCHMaxLength, optionBuf2);
			*/
			
			RMBufChain bodyBuf1;
			bodyBuf1.CreateL(KData2);
			iSSPData->Write(bodyBuf1, 0, NULL);

			/*
			
			TCHMessageOption option3 ( 1, data3.Length() );
			TPckg < TCHMessageOption > optionBuf3 ( option3 );
			
			iSSP->SetOption(KCHOptionLevel, KCHMaxLength, optionBuf3);
			*/
			
			RMBufChain bodyBuf2;
			bodyBuf2.CreateL(KData3);
			iSSPData->Write(bodyBuf2, 0, NULL);

			iState = ECleanup;
			iStatus = KRequestPending;
			Reschedule ();
			return EPass;
			}

		case ECleanup:
			{
			delete iTestServer;
			
			// cleanup tcp client flow
			delete reinterpret_cast<CHttpClientFlow*> ( iClientId.Ptr () );
			iTimer.After ( iStatus, 60000000 ); //10 secs
			iState = EComplete;
			iStatus = KRequestPending;
			Reschedule ();
			return EPass;
			}
		case EComplete:
			{
			iLogger.WriteFormat(_L("<i>TestCase: Complete..... </i>"));
			return EPass;
			}
			
		default:
			iLogger.WriteFormat(_L("<i> Failed: TestCase:..... </i>"));
			ASSERT(0);
			return EFail;
		}
	}
コード例 #6
0
TVerdict CTcpClientTestUPnP1::RunTestL()
	{
	switch ( iState )
		{
		case ECreateTestServer:
			{
			iLogger.WriteFormat(_L("<i>Creating TestServer..... </i>"));
			
			iTestServer = CTestTcpServer::NewL ( *this );
			
			iState  = ECreateTestClient;
			iStatus = KRequestPending;			
			Reschedule();
			return EPass;
			}
		
		case ECreateTestClient:
			{
			iLogger.WriteFormat(_L("<i>TestServer is created..... </i>"));			
			iLogger.WriteFormat(_L("<i>Creating TestClient..... </i>"));
			
			THttpClientFlowQuery flowQuery ( TAppProtAddr ( KInetAddrLoop, KHttpDefaultPort ), Id (), EHttpClientFlow, THttpClientFlowQuery::ECreateNew, iChunkManager );
			const TUid requestedUid = { CUPnPFlowFactory::iUid };
			
			TNodeId factoryContainer = SockManGlobals::Get( )->GetPlaneFC( TCFPlayerRole ( TCFPlayerRole::EDataPlane ) );
						
			RClientInterface::OpenPostMessageClose ( NodeId (), TNodeCtxId ( KActivityNull, factoryContainer ), TCFFactory::TFindOrCreatePeer ( TCFPlayerRole::EDataPlane, requestedUid, &flowQuery ).CRef () );
			
			iState  = ESendRequestData;
			iStatus = KRequestPending;
			Reschedule();
			return EPass;
			}
		
		case ESendRequestData:
			{
			iLogger.WriteFormat(_L("<i>Client is Created</i>"));
			iLogger.WriteFormat(_L("<i>Send data..... </i>"));
			
			RMemChunk bodyBuf;
			RMemChunk uriBuf;
			//uriBuf.CreateL ( _L8 ("http://127.0.0.1:9999") );
			uriBuf.CreateL ( _L8 ("http://[0:0:0:0:0:0:0:1]"), iAllocator );
			TUpnpMessage::TUPnPClientRequestInfo msg ( HTTP::EGET, uriBuf, bodyBuf, NULL );
			iClientId.Node ().ReceivedL ( TNodeCtxId ( KActivityNull, Id () ), TNodeCtxId ( KActivityNull, iClientId ), msg );
			
			iState = ECleanup;
			iStatus = KRequestPending;
			Reschedule ();
			return EPass;
			}

		case ECleanup:
			{
			delete iTestServer;
			// cleanup tcp client flow
			delete reinterpret_cast<CHttpClientFlow*> ( iClientId.Ptr () );
			iTimer.After ( iStatus, 60000000 ); //10 secs
			iState = EComplete;
			iStatus = KRequestPending;
			Reschedule ();
			return EPass;
			}
		case EComplete:
			{
			iLogger.WriteFormat(_L("<i>TestCase: Complete..... </i>"));
			return EPass;
			}
			
		default:
			iLogger.WriteFormat(_L("<i> Failed: TestCase:..... </i>"));
			ASSERT(0);
			return EFail;
		}
	}
コード例 #7
0
 Variable Object::CreateVariable(const QualifiedName& browseName, const Variant& value)
 {
   return CreateVariable(NodeId(), browseName, value);
 }
コード例 #8
0
 Object Object::CreateObject(const ObjectType& type, const QualifiedName& browseName, const std::string& displayName)
 {
   return CreateObject(NodeId(), GetId(), type.GetId(), browseName, displayName);
 }
コード例 #9
0
 Object Object::CreateObject(const ObjectType& type, const QualifiedName& browseName)
 {
   return CreateObject(NodeId(), type, browseName);
 }
コード例 #10
0
    AddNodesResult AddressSpaceInMemory::AddNode( const AddNodesItem& item )
    {
      AddNodesResult result;
      if (Debug) std::cout << "AddressSpaceInternal | address_space| Adding new node id='" << item.RequestedNewNodeId << "' name=" << item.BrowseName.Name << std::endl;

      if (!Nodes.empty() && item.RequestedNewNodeId != ObjectId::Null && Nodes.find(item.RequestedNewNodeId) != Nodes.end())
      {
        std::cerr << "AddressSpaceInternal | Error: NodeId '"<< item.RequestedNewNodeId << "' allready exist: " << std::endl;
        result.Status = StatusCode::BadNodeIdExists;
        return result;
      }

      NodesMap::iterator parent_node_it = Nodes.end();
      if (item.ParentNodeId != NodeId())
      {
        parent_node_it = Nodes.find(item.ParentNodeId);
        if ( parent_node_it == Nodes.end() )
        {
          if (Debug) std::cout << "AddressSpaceInternal | Error: Parent node '"<< item.ParentNodeId << "'does not exist" << std::endl;
          result.Status = StatusCode::BadParentNodeIdInvalid;
          return result;
        }
      }

      const NodeId resultId = GetNewNodeId(item.RequestedNewNodeId);
      NodeStruct nodestruct;
      //Add Common attributes
      nodestruct.Attributes[AttributeId::NodeId].Value = resultId;
      nodestruct.Attributes[AttributeId::BrowseName].Value = item.BrowseName;
      nodestruct.Attributes[AttributeId::NodeClass].Value = static_cast<int32_t>(item.Class);

      // Add requested attributes
      for (const auto& attr: item.Attributes.Attributes)
      {
        AttributeValue attval;
        attval.Value = attr.second;

        nodestruct.Attributes.insert(std::make_pair(attr.first, attval));
      }

      Nodes.insert(std::make_pair(resultId, nodestruct));

      if (parent_node_it != Nodes.end())
      {
        // Link to parent
        ReferenceDescription desc;
        desc.ReferenceTypeId = item.ReferenceTypeId;
        desc.TargetNodeId = resultId;
        desc.TargetNodeClass = item.Class;
        desc.BrowseName = item.BrowseName;
        desc.DisplayName = LocalizedText(item.BrowseName.Name);
        desc.TargetNodeTypeDefinition = item.TypeDefinition;
        desc.IsForward = true; // should this be in constructor?

        parent_node_it->second.References.push_back(desc);
      }

      if (item.TypeDefinition != ObjectId::Null)
      {
        // Link to parent
        AddReferencesItem typeRef;
        typeRef.SourceNodeId = resultId;
        typeRef.IsForward = true;
        typeRef.ReferenceTypeId = ObjectId::HasTypeDefinition;
        typeRef.TargetNodeId = item.TypeDefinition;
        typeRef.TargetNodeClass = NodeClass::DataType;
        AddReference(typeRef);
      }

      result.Status = StatusCode::Good;
      result.AddedNodeId = resultId;
      if (Debug) std::cout << "AddressSpaceInternal | node added." << std::endl;
      return result;
    }
コード例 #11
0
ファイル: NodeId.cpp プロジェクト: VMML/Livre
NodeId NodeId::getRoot() const
{
    return NodeId( 0, getPosition() / ( 1u << _level ), _frame );
}
コード例 #12
0
ファイル: HistogramFilter.cpp プロジェクト: chevtche/Livre
    void execute(const FutureMap& input, PromiseMap& output) const
    {
        const auto& frustums = input.get<Frustum>("Frustum");
        const auto& viewports = input.get<Viewport>("RelativeViewport");

        auto dataSourceRange = input.get<Vector2f>("DataSourceRange").front();
        const auto& frustum = frustums.front();
        const auto& viewport = viewports.front();

        Histogram histogramAccumulated;
        for (const auto& cacheObjects : input.getFutures("CacheObjects"))
            for (const auto& cacheObject :
                 cacheObjects.get<ConstCacheObjects>())
            {
                const CacheId& cacheId = cacheObject->getId();

                // Hist cache object expands the data source range if data has
                // larger values
                ConstHistogramObjectPtr histCacheObject =
                    _histogramCache.load<HistogramObject>(cacheId, _dataCache,
                                                          _dataSource,
                                                          dataSourceRange);
                if (!histCacheObject)
                    continue;

                const Vector2f& currentRange =
                    histCacheObject->getHistogram().getRange();
                if (currentRange[0] < dataSourceRange[0])
                    dataSourceRange[0] = currentRange[0];
                histogramAccumulated.setMin(dataSourceRange[0]);

                if (currentRange[1] > dataSourceRange[1])
                    dataSourceRange[1] = currentRange[1];
                histogramAccumulated.setMax(dataSourceRange[1]);

                const size_t currentBinCount =
                    histCacheObject->getHistogram().getBins().size();
                if (histogramAccumulated.getBins().empty())
                    histogramAccumulated.resize(currentBinCount);

                // When a frame is rendered in multi-channel, multi-node, etc
                // config, some nodes are rendered twice in sort-first
                // renderings
                // To avoid counting nodes twice, we check if the center of the
                // node is in
                // this frustum (because it can only be in one tile at a time).
                // For viewports
                // on the border of the absolute viewport, the frustum is
                // virtually extended
                // to infinity on the boundary.
                try
                {
                    const LODNode& lodNode =
                        _dataSource.getNode(NodeId(cacheId));
                    if (isCenterInViewport(frustum, lodNode.getWorldBox(),
                                           viewport))
                        histogramAccumulated += histCacheObject->getHistogram();
                }
                catch (const std::runtime_error&)
                {
                    // Only compatible histograms can be added.( i.e same data
                    // range and number of
                    // bins.) Until data range converges to the full data range
                    // combined from other
                    // rendering clients, the cache objects are purged from the
                    // cache.
                    _histogramCache.purge(cacheId);
                }
            }

        output.set("Histogram", histogramAccumulated);
    }
コード例 #13
0
NodeId NodeReport::getNodeId() {
	return NodeId(reportProto.nodeid());
}