Esempio n. 1
0
    bool insertEdge(int iv1, int iv2, int fid)
    {
      MB_ASSERT(iv1!=iv2);

      Edge eg(iv1, iv2);

      super_t::iterator iter = super_t::find(eg);

      if (iter==end()) {
        eg.if1 = fid;
        eg.if2 = -1;
	super_t::insert(eg);
        return true;
      }

      if (iter->if2!=-1) {
        MB_DPRINTLN("insertEdge error iv=(%d,%d)", iv1, iv2);
        return false;
      }

      //iter->if2 = fid;
      eg.if1 = iter->if1;
      eg.if2 = fid;

      super_t::erase(iter);
      super_t::insert(eg);

      return false;
    }
Esempio n. 2
0
		arbint sup(arbint a,S x){
			int chemin;
			arbin racine=a;
			arbin pere;

			while(x!=r(a)){
				if (x>r(a)){
					pere=a;
					a=ad(a);
					chemin=1;
				}
			else{
				pere=a;
				a=ag(a);
				chemin=0;
			}

			nouv_racine=r(eg(ad(a)));
			otermin(ad(a));

			if(chemin==0)
				pere->ag=e(ag(a),nouv_racine,ad(a));
			else
				pere->ad=e(ag(a),nouv_racine,ad(a));

			free(a);		

		return racine;
	}	
}
Esempio n. 3
0
    virtual void on_draw()
    {
        pixfmt pf(rbuf_window());

        typedef agg::pixfmt_alpha_blend_gray<gray_blender, agg::rendering_buffer, 3, 2> pixfmt_r;
        typedef agg::pixfmt_alpha_blend_gray<gray_blender, agg::rendering_buffer, 3, 1> pixfmt_g;
        typedef agg::pixfmt_alpha_blend_gray<gray_blender, agg::rendering_buffer, 3, 0> pixfmt_b;

        pixfmt_r pfr(rbuf_window());
        pixfmt_g pfg(rbuf_window());
        pixfmt_b pfb(rbuf_window());

        agg::renderer_base<pixfmt>   rbase(pf);
        agg::renderer_base<pixfmt_r> rbr(pfr);
        agg::renderer_base<pixfmt_g> rbg(pfg);
        agg::renderer_base<pixfmt_b> rbb(pfb);

        agg::rasterizer_scanline_aa<> ras;
        agg::scanline_p8 sl;

        rbase.clear(agg::rgba(1,1,1));

        agg::ellipse er(width() / 2 - 0.87*50, height() / 2 - 0.5*50, 100, 100, 100);
        ras.add_path(er);
        agg::render_scanlines_aa_solid(ras, sl, rbr,
                                       agg::gray8(0, unsigned(m_alpha.value())));
        
        agg::ellipse eg(width() / 2 + 0.87*50, height() / 2 - 0.5*50, 100, 100, 100);
        ras.add_path(eg);
        agg::render_scanlines_aa_solid(ras, sl, rbg, 
                                       agg::gray8(0, unsigned(m_alpha.value())));

        agg::ellipse eb(width() / 2, height() / 2 + 50, 100, 100, 100);
        ras.add_path(eb);
        agg::render_scanlines_aa_solid(ras, sl, rbb,
                                       agg::gray8(0, unsigned(m_alpha.value())));

        agg::render_ctrl(ras, sl, rbase, m_alpha);
    }
Esempio n. 4
0
double Legendre::GetDeterminant(DMatrix &dMatrix) {
 EigenValues eg(dMatrix);
 eg.ComputeEigenValues();
 return eg.GetDeterminant();
}
//***************************************************************************************
void CBCGPRadialMenuObject::OnDraw(CBCGPGraphicsManager* pGM, const CBCGPRect& /*rectClip*/, DWORD dwFlags)
{
	if (dwFlags == BCGP_DRAW_STATIC)
	{
		return;
	}

	m_nShadowDepth = pGM->IsSupported(BCGP_GRAPHICS_MANAGER_COLOR_OPACITY) ? GetShadowDepth() : 0;

	CBCGPRect rect = m_rect;
	if (rect.Width() < rect.Height())
	{
		rect.top += (rect.Height() - rect.Width()) / 2;
		rect.bottom = rect.top + rect.Width();
	}
	else if (rect.Height() < rect.Width())
	{
		rect.left += (rect.Width() - rect.Height()) / 2;
		rect.right = rect.left + rect.Height();
	}

	rect.DeflateRect(2., 2.);

	rect.right -= m_nShadowDepth;
	rect.bottom -= m_nShadowDepth;

	const double radius = rect.Width() / 2;
	const double radiusSmall = INTERNAL_PART * rect.Width() + 1.0;
	const CBCGPPoint center = rect.CenterPoint();

	CBCGPSize sizeIcon((double)m_cxIcon, 16);

	if (!m_Icons.IsNull())
	{
		sizeIcon.cy = pGM->GetImageSize(m_Icons).cy;
	}

	const int nItems = (int)m_arItems.GetSize();

	if (IsDirty())
	{
		int nCircleItems = m_bHasCenterButton ? nItems - 1 : nItems;

		double dblDeltaAngle = nCircleItems == 0 ? 0. : 360. / nCircleItems;
		double dblStartAngle = 90. - dblDeltaAngle / 2;

		for (int i = 0; i < nItems; i++)
		{
			CBCGPRadialMenuItem* pItem = m_arItems[i];
			ASSERT_VALID(pItem);

			pItem->m_bIsCenter = i == nItems -1 && m_bHasCenterButton;

			pItem->m_Shape.Destroy();
			pItem->m_Shape.Clear();

			if (!pItem->m_bIsCenter)
			{
				double dblFinishAngle = dblStartAngle + dblDeltaAngle;

				const double dblStartAngleRad = bcg_deg2rad(dblStartAngle);
				const double dblFinishAngleRad = bcg_deg2rad(dblFinishAngle);
				const double dblMiddleAngleRad = bcg_deg2rad(dblStartAngle + dblDeltaAngle / 2);

				double angleStartCos = cos(dblStartAngleRad);
				double angleStartSin = sin(dblStartAngleRad);
				double angleFinishCos = cos(dblFinishAngleRad);
				double angleFinishSin = sin(dblFinishAngleRad);

				pItem->m_Shape.SetStart(
					CBCGPPoint(center.x + angleStartCos * radius, center.y - angleStartSin * radius));
				pItem->m_Shape.AddArc(
					CBCGPPoint(center.x + angleFinishCos * radius, center.y - angleFinishSin * radius),
					CBCGPSize(radius, radius), dblStartAngle > dblFinishAngle, FALSE);
				pItem->m_Shape.AddLine(
					CBCGPPoint(center.x + angleFinishCos * radiusSmall, center.y - angleFinishSin * radiusSmall));
				pItem->m_Shape.AddArc(
					CBCGPPoint(center.x + angleStartCos * radiusSmall, center.y - angleStartSin * radiusSmall),
					CBCGPSize(radiusSmall, radiusSmall), dblStartAngle < dblFinishAngle, FALSE);

				pItem->m_ptCenter = CBCGPPoint(
					center.x + cos(dblMiddleAngleRad) * 2 * radius / 3,
					center.y - sin(dblMiddleAngleRad) * 2 * radius / 3);

				dblStartAngle = dblFinishAngle;
			}
			else
			{
				pItem->m_Shape.SetStart(center);
				pItem->m_Shape.AddLine(center);
				pGM->CombineGeometry(pItem->m_Shape, pItem->m_Shape, CBCGPEllipseGeometry(CBCGPEllipse(center, radiusSmall, radiusSmall)), RGN_OR);

				pItem->m_ptCenter = center;
			}
		}
	}

	CBCGPEllipse ellipseInt(center, radiusSmall, radiusSmall);

	CBCGPRect rectShadow = rect;
	rectShadow.OffsetRect(m_nShadowDepth, m_nShadowDepth);

	if (!m_bHasCenterButton && m_pCtrl->GetSafeHwnd() != NULL && (m_pCtrl->GetExStyle() & WS_EX_LAYERED))
	{
		if (m_nShadowDepth > 0)
		{
			CBCGPEllipseGeometry egShadow(rectShadow);

			CBCGPPoint centerShadow = center;
			centerShadow.x += m_nShadowDepth;
			centerShadow.y += m_nShadowDepth;

			CBCGPEllipse ellipseIntShadow(centerShadow, radiusSmall, radiusSmall);
			CBCGPEllipseGeometry egInternalShadow(ellipseIntShadow);

			CBCGPComplexGeometry shapeShadow;
			pGM->CombineGeometry(shapeShadow, egShadow, egInternalShadow, RGN_DIFF);

			pGM->FillGeometry(shapeShadow, m_brShadow);
		}

		CBCGPEllipseGeometry eg(rect);
		CBCGPEllipseGeometry egInternal(ellipseInt);

		CBCGPComplexGeometry shape;
		pGM->CombineGeometry(shape, eg, egInternal, RGN_DIFF);

		pGM->FillGeometry(shape, m_brFill);

	}
	else
	{
		if (m_nShadowDepth > 0)
		{
			pGM->FillEllipse(rectShadow, m_brShadow);
		}

		pGM->FillEllipse(rect, m_brFill);
	}

	pGM->DrawEllipse(rect, m_brBorder);

	if (!pGM->IsSupported(BCGP_GRAPHICS_MANAGER_COLOR_OPACITY))
	{
		CBCGPRect rect1 = rect;
		rect1.DeflateRect(1, 1);

		pGM->DrawEllipse(rect1, m_brFill);
	}

	BOOL bIsCtrlDisabled = m_pCtrl->GetSafeHwnd() != NULL && !m_pCtrl->IsWindowEnabled();

	for (int i = 0; i < nItems; i++)
	{
		CBCGPRadialMenuItem* pItem = m_arItems[i];
		ASSERT_VALID(pItem);

		if (i == m_nHighlighted)
		{
			pGM->FillGeometry(pItem->m_Shape, m_nHighlighted == m_nPressed ? m_brPressed : 
				m_brHighlighted.IsEmpty() ? m_brFill : m_brHighlighted);
		}

		pItem->OnDrawIcon(pGM, bIsCtrlDisabled, m_Icons, sizeIcon);

		pGM->DrawGeometry(pItem->m_Shape, m_brBorder);
	}

	pGM->DrawEllipse(ellipseInt, m_brBorder);

	if (!pGM->IsSupported(BCGP_GRAPHICS_MANAGER_ANTIALIAS))
	{
		rect.InflateRect(1, 1);
		pGM->DrawEllipse(rect, m_brBorder);
	}

	if (m_pCtrl->GetSafeHwnd() != NULL && m_pCtrl->IsFocused() && !m_pCtrl->IsPopup())
	{
		rect.InflateRect(1, 1);
		pGM->DrawEllipse(rect, m_brFocusedBorder);
	}
}
Esempio n. 6
0
/**
 * Replace the query with its query descriptor text.
 * The MVQR_LOG_QUERY_DESCRIPTORS CQD was set to 'DUMP', so instead of running
 * this query, we are going to replace it with something that, when executed,
 * will produce the XML text of the query descriptor as its output. This
 * 'something' is a TupleList node that has the text lines of the descriptor 
 * as its tuples.
 * 
 * @param rootExpr The RelExpr tree of the existing query
 * @param xmlText The XML text of the query descriptor
 */
RelRoot* MvQueryRewriteHandler::handleAnalyzeOnlyQuery(RelRoot* rootExpr, NAString* xmlText)
{
  static NAString empty("No descriptor generated.");
  if (xmlText==NULL)
    xmlText = &empty;
    
  CollHeap *heap = CmpCommon::statementHeap();
  Int32 maxLen=xmlText->length();
  Int32 pos=0;
  Int32 lastPos=-1;
  ItemExpr* tupleExpr = NULL;  
  
  while (pos<maxLen-1)
  {
    // Find the next CR character
    pos = xmlText->index("\n", 1, pos+1, NAString::exact);
    if (pos==-1) // If this is the last line with no CR.
      pos=maxLen;

    // The next line if from the last CR to this one.
    NASubString line=(*xmlText)(lastPos+1, pos-lastPos-1);
    lastPos=pos;

    // Make a constant character string from it.
    ItemExpr* tuple = new (heap) 
      Convert(new(heap) SystemLiteral(line));
    
    // Collect the tuples in a list
    if (tupleExpr==NULL)
      tupleExpr = tuple;
    else
      tupleExpr = new(heap) ItemList(tuple, tupleExpr);    
  }

  // Construct the TupleList node
  TupleList* tupleListNode = new(heap) TupleList(tupleExpr->reverseTree(), heap); 
  RelRoot* newRoot = new(heap) RelRoot(tupleListNode);
  
  // A RenameTable above it to give a name to the column of text.
  ItemExpr *renExpr = new(heap) 
    RenameCol(NULL, new(heap) ColRefName("Query Descriptor", heap));
  NAString tableName("Descriptor table");
  RelExpr* renameNode = new(heap) 
    RenameTable(TRUE, newRoot, tableName, renExpr, heap);
  
  // And a final RelRoot on top with a SELECT *.
  ItemExpr *starExpr = new(heap) ColReference(new(heap) ColRefName(1));
  RelRoot* topRoot = new(heap) RelRoot(renameNode, REL_ROOT, starExpr);
  topRoot->setRootFlag(TRUE);
  
  // Now bind the new query tree
  BindWA* bindWA = rootExpr->getRETDesc()->getBindWA();
  RelExpr* boundRoot = topRoot->bindNode(bindWA);

  // Transform it. This will eliminate the Rename node and the extraneous root.
  NormWA normWA(CmpCommon::context());
  ExprGroupId eg(boundRoot);
  boundRoot->transformNode(normWA, eg);

  // And Normalize it.
  RelRoot *normRoot = (RelRoot *)eg.getPtr();
  normRoot->normalizeNode(normWA);
  
  return normRoot;
}
Esempio n. 7
0
void  ObjectRenderer::Render(){
    if(!bDrawObject) return;

    if(mObject!=NULL){
        glPushMatrix();
        glMultMatrixf(mObject->GetReferenceFrame().GetHMatrix().RowOrderForceFloat());
    }

    if(bDrawRef)
        GLT::DrawRef(mRefSize);

    for(int i=0;i<int(mShapes.size());i++){
        glPushMatrix();
        if(bDrawCom){
            GLT::SetColor(mComColor[0],mComColor[1],mComColor[2],mComColor[3]);
            Matrix ine(3,3);
            Vector d(3);
            Matrix eg(3,3);
            Matrix3 egt;
            Matrix3 degt;
            Matrix  dd(3,3);
            Matrix3 ddd;
            ine = (mObject->GetSpatialInertia().mInertiaMoment);
            ine.EigenValuesDecomposition(d, eg);
            egt.Set(eg);
            egt.STranspose();
            dd.Diag(d);
            ddd.Set(dd);

            egt.Mult(ddd,degt);

            glPushMatrix();
                Vector3 &com = mObject->GetSpatialInertia().mCenterOfMass;
                glTranslatef(com[0],com[1],com[2]);
                GLT::DrawVector(degt.GetColumn(0),0.1);
                GLT::DrawVector(degt.GetColumn(1),0.1);
                GLT::DrawVector(degt.GetColumn(2),0.1);
            glPopMatrix();
        }

        float col[4];
        //bUseDefaultColor is not needed since providing no color tag automatically sets the color to default
//        if(bUseDefaultColor){
//            col[0] = mDefaultColor[0];
//            col[1] = mDefaultColor[1];
//            col[2] = mDefaultColor[2];
//            col[3] = mDefaultColor[3];
//        }else{
            col[0] = mShapes[i]->color[0];
            col[1] = mShapes[i]->color[1];
            col[2] = mShapes[i]->color[2];
            col[3] = mShapes[i]->color[3];
//        }

        if(!bUseTransparency)
            col[3] = 1.0;


        glColor4fv(col);
        glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR,col);

        if(mShapes[i]->culling)
        	glDisable(GL_CULL_FACE);


        if(mShapes[i]->shape){
            mShapes[i]->shape->Render();
        }


        if(mShapes[i]->culling)
        	glEnable(GL_CULL_FACE);

        glPopMatrix();
    }

    if(mObject!=NULL){
        glPopMatrix();
    }

    AbstractRenderer::Render();
}