예제 #1
0
// An Occurence has been added
void GLC_WorldHandle::addOccurence(GLC_StructOccurence* pOccurence, bool isSelected, GLuint shaderId)
{
	Q_ASSERT(!m_OccurenceHash.contains(pOccurence->id()));
	m_OccurenceHash.insert(pOccurence->id(), pOccurence);
	GLC_StructReference* pRef= pOccurence->structReference();
	Q_ASSERT(NULL != pRef);

	// Add instance representation in the collection
	if (pOccurence->useAutomatic3DViewInstanceCreation() && pRef->representationIsLoaded())
	{
		//qDebug() << "GLC_WorldHandle::addOccurence with rep";
		GLC_3DRep* p3DRep= dynamic_cast<GLC_3DRep*>(pRef->representationHandle());
		GLC_3DViewInstance representation(*p3DRep);
		// Force instance representation id
		representation.setId(pOccurence->id());
		// Force instance representation name
		representation.setName(pOccurence->name());
		if (0 != shaderId) m_Collection.bindShader(shaderId);
		m_Collection.add(representation, shaderId);
		if (isSelected)
		{
			//qDebug() << pOccurence->name() << "selected";
			m_Collection.select(pOccurence->id());
		}
	}
}
int main(int argc, char* argv[]) {
    assert(argc>3);

    Bayesian bayesian(256, 256);

    std::string output_folder = argv[1];
    std::string train_folder = argv[2];
    std::string filename = argv[3];

    fs::path path_to_output_folder(output_folder);
    path_to_output_folder/=filename;
    fs::path path_to_train_folder(train_folder);

    bayesian.train_from_folder<0,1>(path_to_train_folder);

    auto bayesian_m = bayesian.model();

    std::ofstream file(path_to_output_folder.string());
    bayesian_m.save_to_file(file);
    bayesian_m.gaussian_blur(5,5,1,1);
    cv::Mat color_map = bayesian_m.representation();
    cv::imwrite(path_to_output_folder.string() + ".jpg",color_map);

    cv::imshow("color map",color_map);
    cv::waitKey(0);

    return 0;
}
예제 #3
0
void SunMenuItemView::initialize()
{
    Q_ASSERT_X(mItemModel != 0 && mItemModel->displayedItem() != 0,
               "MenuItemView::initialize()",
               "You should pass a valid MenuItemModel pointer");

    Q_ASSERT_X(mParentLayer != 0, "MenuItemView::initialize()",
               "Parent layer for item MUST be specified.");

    connect(representation(),SIGNAL(brushChanged(const QBrush&)), this, SLOT(updateBrush(const QBrush&)));
    updateBrush(representation()->brush());

    setAcceptHoverEvents(true);
    setParent(mItemModel);
    setParentItem(mParentItemView);

    // Cache useless in this situation because we don't use transformation and menu doesn't change it's position.
    //It's increases memory usage and greatly reduces the animation performance.
    setCacheMode(QGraphicsItem::NoCache);
    //	setFlag(QGraphicsItem::ItemStacksBehindParent, true);

    if (mItemModel->displayedItem()->graphicsItem())
        mItemModel->displayedItem()->graphicsItem()->setParentItem(this);

    connect(mItemModel, SIGNAL(childAdded(MenuItemModel*)), this,
            SLOT(childItemAdded(MenuItemModel*)));

    mSubLayer = 0;

    mStartAngle = 0;
    mSweepLength = 0;
    mWidth = 0;
    mInnerRadius = 0;

    if (!mItemModel->childMenus().isEmpty())
    {
        foreach(MenuItemModel* mc, mItemModel->childMenus())
            addChildItem(mc);
    }

    updateShape();
    recalculateChildMenusAngles();
}
typename mpfr_bin_ieee754_flavor<T>::representation
mpfr_bin_ieee754_flavor<T>::intersection(mpfr_bin_ieee754_flavor<T>::representation const& x,
                                      mpfr_bin_ieee754_flavor<T>::representation const& y)
{
    if (!is_valid(x) || !is_valid(y))
        return empty();

    if (disjoint(x, y))
        return empty();
    else
        return representation(std::max(x.first, y.first),
                              std::min(x.second, y.second));
}
typename mpfr_bin_ieee754_flavor<T>::representation
mpfr_bin_ieee754_flavor<T>::convex_hull(mpfr_bin_ieee754_flavor<T>::representation const& x,
                                 mpfr_bin_ieee754_flavor<T>::representation const& y)
{
    if (!is_valid(x) || !is_valid(y))
        return empty();

    if (is_empty(x))
        return y;
    else if (is_empty(y))
        return x;
    else
        return representation(std::min(x.first, y.first),
                              std::max(x.second, y.second));
}
bool NumericRepresentationSetter::canUse(const QString &id) const
{
    try {
        bool ok;
        quint64 objid = id.toULongLong(&ok);
        if ( !ok)
            return false;
        Resource resource = mastercatalog()->id2Resource(objid);
        if ( !resource.isValid())
            return false;
        if ( resource.ilwisType() != itREPRESENTATION)
            return false;
        IRepresentation representation(resource);
        return hasType(representation->domain()->ilwisType(), itNUMERICDOMAIN);

    } catch(const ErrorObject& err){

    }
    return false;

}
nsresult
nsDASHWebMODParser::SetRepresentations(nsIDOMElement* aAdaptSetElem,
                                       AdaptationSet* aAdaptationSet,
                                       bool &bIgnoreThisAdaptSet)
{
  NS_ENSURE_ARG(aAdaptSetElem);
  NS_ENSURE_ARG(aAdaptationSet);

  // Assume ok until an error is found.
  bIgnoreThisAdaptSet = false;

  nsCOMPtr<nsIDOMElement> child, nextChild;
  nsresult rv = aAdaptSetElem->GetFirstElementChild(getter_AddRefs(child));
  NS_ENSURE_SUCCESS(rv, rv);

#ifdef PR_LOGGING
  int i = 0;
#endif
  bIgnoreThisAdaptSet = false;
  while (child) {
    nsAutoString tagName;
    rv = child->GetTagName(tagName);
    NS_ENSURE_SUCCESS(rv, rv);

    // If child is invalid, return and ignore this |Period|
    if (tagName.EqualsLiteral("SegmentList")
        || tagName.EqualsLiteral("SegmentTemplate")) {
      bIgnoreThisAdaptSet = true;
      return NS_OK;
    }

    if (tagName.EqualsLiteral("Representation")) {

      nsAutoPtr<Representation> representation(new Representation());

      nsAutoString value;
      rv = GetAttribute(child, NS_LITERAL_STRING("width"), value);
      NS_ENSURE_SUCCESS(rv, rv);
      if(!value.IsEmpty()) {
        representation->SetWidth(value.ToInteger(&rv));
      }

      rv = GetAttribute(child, NS_LITERAL_STRING("height"), value);
      NS_ENSURE_SUCCESS(rv, rv);
      if(!value.IsEmpty()) {
        representation->SetHeight(value.ToInteger(&rv));
      }

      rv = GetAttribute(child, NS_LITERAL_STRING("bandwidth"), value);
      NS_ENSURE_SUCCESS(rv, rv);
      if(!value.IsEmpty()) {
        representation->SetBitrate(value.ToInteger(&rv));
      }

      LOG("Representation #%d: width:%d height:%d bitrate:%d",
          i, representation->GetWidth(),
          representation->GetHeight(),
          representation->GetBitrate());

      // Get |BaseURL| elements
      bool bIgnoreThisRep;
      SetRepresentationBaseUrls(child, representation, bIgnoreThisRep);

      // Get |SegmentBase| elements
      if (!bIgnoreThisRep)
        SetRepSegmentBase(child, representation, bIgnoreThisRep);

      if (!bIgnoreThisRep) {
        aAdaptationSet->AddRepresentation(representation.forget());
        LOG("Representation #%d: added to AdaptationSet", i++);
      }
    }
    rv = child->GetNextElementSibling(getter_AddRefs(nextChild));
    NS_ENSURE_SUCCESS(rv, rv);
    child = nextChild;
  }
  return NS_OK;
}
예제 #8
0
/**
  Overloaded for TDesC
  @returns Error code if any during writing
  @leave KErrNoMemory if no memory
  */
  TInt CSerialWriter::WriteDecorated(const TDesC& aText, TInt aSeverity)
  {
  	TPtrC8 representation((TUint8*)(&aText)->Ptr(), (&aText)->Size());
  	return WriteDecorated(representation,  aSeverity )	;
  }
예제 #9
0
파일: gen.cpp 프로젝트: LSaldyt/Compiler
 /**
  * Replaces @ characters with any string
  * @param inner Replacement string
  * @param formatter String containing @ symbols
  * @return formatted string
  */
 string format(const string& inner, const string& formatter)
 {
     string representation(formatter);
     replaceAll(representation, "@", inner);
     return representation;
 }
예제 #10
0
// Create meshes from the 3ds File
void GLC_3dsToWorld::createMeshes(GLC_StructOccurence* pProduct, Lib3dsNode* pFatherNode)
{
	GLC_StructOccurence* pChildProduct= NULL;
	Lib3dsMesh *pMesh= NULL;

	if (pFatherNode->type == LIB3DS_OBJECT_NODE)
	{
		//qDebug() << "Node type LIB3DS_OBJECT_NODE is named : " << QString(pFatherNode->name);
		//qDebug() << "Node Matrix :";
		//qDebug() << GLC_Matrix4x4(&(pFatherNode->matrix[0][0])).toString();

		// Check if the node is a mesh or dummy
		if (!(strcmp(pFatherNode->name,"$$$DUMMY")==0))
		{
	    	pMesh = lib3ds_file_mesh_by_name(m_pLib3dsFile, pFatherNode->name);
		    if( pMesh != NULL )
		    {
		    	GLC_3DRep representation(create3DRep(pMesh));
		    	// Test if there is vertex in the mesh
		    	if (0 != representation.vertexCount())
		    	{
		    		m_LoadedMeshes.insert(representation.name());
			    	// Load node matrix
			    	GLC_Matrix4x4 nodeMat(&(pFatherNode->matrix[0][0]));
					// The mesh matrix to inverse
			    	GLC_Matrix4x4 matInv(&(pMesh->matrix[0][0]));
					matInv.invert();
					// Get the node pivot
					Lib3dsObjectData *pObjectData;
					pObjectData= &pFatherNode->data.object;
					GLC_Matrix4x4 trans(-pObjectData->pivot[0], -pObjectData->pivot[1], -pObjectData->pivot[2]);
					// Compute the part matrix
					nodeMat= nodeMat * trans * matInv; // I don't know why...
					nodeMat.optimise();
					// move the part by the matrix
					pProduct->addChild((new GLC_StructInstance(new GLC_3DRep(representation)))->move(nodeMat));
		    	}
		    	else
		    	{
		    		// the instance will be deleted, check material usage
		    		QSet<GLC_Material*> meshMaterials= representation.materialSet();
		    		QSet<GLC_Material*>::const_iterator iMat= meshMaterials.constBegin();
		    		while (iMat != meshMaterials.constEnd())
		    		{
		    			if ((*iMat)->numberOfUsage() == 1)
		    			{
		    				m_Materials.remove((*iMat)->name());
		    			}
		    			++iMat;
		    		}
		    	}
		    }
		} // End If DUMMY
	}
	else return;
	// If there is a child, create a child product
	if (NULL != pFatherNode->childs)
	{
		pChildProduct= new GLC_StructOccurence();
		pProduct->addChild(pChildProduct);

		pChildProduct->setName(QString("Product") + QString::number(pFatherNode->node_id));

		//pChildProduct->move(GLC_Matrix4x4(&(pFatherNode->matrix[0][0])));

		// Create Childs meshes if exists
		for (Lib3dsNode* pNode= pFatherNode->childs; pNode!=0; pNode= pNode->next)
		{
			createMeshes(pChildProduct, pNode);
		}
	}


}
예제 #11
0
AbstractMenuBehavior* SunMenuItemView::behavior() const
{
    return representation()->behavior();
}
예제 #12
0
파일: url.cpp 프로젝트: HalfDemon/MCPP
	String URL::Encode (const String & encode) {
	
		//	Convert to UTF-8 representation
		Vector<Byte> utf8(UTF8().Encode(encode));
		
		//	Loop and reconstruct
		String encoded;
		for (const Byte b : utf8) {
		
			if (
				//	Outside ASCII range
				(b>=128) ||
				(
					//	Not A-Z
					(
						(b<'A') ||
						(b>'Z')
					) &&
					//	Not a-z
					(
						(b<'a') ||
						(b>'z')
					) &&
					//	Not 0-9
					(
						(b<'0') ||
						(b>'9')
					) &&
					//	Not -
					(b!='-') &&
					//	Not _
					(b!='_') &&
					//	Not .
					(b!='.') &&
					//	Not ~
					(b!='~')
				)
			) {
			
				//	Percent encode
				
				encoded << "%";
				
				String representation(b,16);
				
				if (representation.Count()==1) encoded << "0";
				
				encoded << representation;
			
			} else {
			
				//	Add as regular character
				encoded << GraphemeCluster(
					static_cast<ASCIIChar>(b)
				);
			
			}
		
		}
		
		return encoded;
	
	}