Пример #1
1
void Text::layout1()
      {
      if (styled() && !_editMode)
            SimpleText::layout();
      else {
            _doc->setDefaultFont(textStyle().font(spatium()));
            qreal w = -1.0;
            QPointF o(textStyle().offset(spatium()));

            if (parent() && layoutToParentWidth()) {
                  Element* e = parent();
                  w = e->width();
                  if (e->type() == HBOX || e->type() == VBOX || e->type() == TBOX) {
                        Box* b = static_cast<Box*>(e);
                        w -= ((b->leftMargin() + b->rightMargin()) * MScore::DPMM);
                        }
                  }

            QTextOption to = _doc->defaultTextOption();
            to.setUseDesignMetrics(true);
            to.setWrapMode(w <= 0.0 ? QTextOption::NoWrap : QTextOption::WrapAtWordBoundaryOrAnywhere);
            _doc->setDefaultTextOption(to);

            if (w <= 0.0)
                  w = _doc->idealWidth();
            _doc->setTextWidth(w);

            QSizeF size(_doc->size());

            if (align() & ALIGN_BOTTOM)
                  o.ry() -= size.height();
            else if (align() & ALIGN_VCENTER)
                  o.ry() -= (size.height() * .5);
            else if (align() & ALIGN_BASELINE)
                  o.ry() -= baseLine();

            if (align() & ALIGN_RIGHT)
                  o.rx() -= size.width();
            else if (align() & ALIGN_HCENTER)
                  o.rx() -= (size.width() * .5);

            setbbox(QRectF(QPointF(0.0, 0.0), size));
            _doc->setModified(false);
            setPos(o);
            }
      if (parent()) {
            Element* e = parent();
            qreal w, h, xo, yo;
            if (layoutToParentWidth()) {
                  if (e->type() == HBOX || e->type() == VBOX || e->type() == TBOX) {
                        // consider inner margins of frame
                        Box* b = static_cast<Box*>(e);
                        xo = b->leftMargin() * MScore::DPMM;
                        yo = b->topMargin()  * MScore::DPMM;
                        w  = b->width()  - xo - b->rightMargin() * MScore::DPMM;
                        h  = b->height() - yo - b->bottomMargin()   * MScore::DPMM;
                        }
                  else {
                        w  = e->width();
                        h  = e->height();
                        xo = 0.0;
                        yo = 0.0;
                        }
                  QPointF ro(_textStyle.reloff() * .01);
                  rxpos() += xo + ro.x() * w;
                  rypos() += yo + ro.y() * h;
                  }
            if (e->type() == SEGMENT) {
                  Segment* s = static_cast<Segment*>(e);
                  rypos() += s->measure()->system()->staff(staffIdx())->y();
                  }
            }

      if (hasFrame())
            layoutFrame();
      }
Пример #2
0
static void at91sam9x5_video_params(unsigned width, unsigned height,
		int rotation, u32 *xstride, u32 *pstride, u32 *tloffset)
{
/* offset of pixel at (x, y) in the buffer */
#define po(x, y) ((x) + width * (y))

	/* offsets of the edges in counter-clockwise order */
	const unsigned e[] = {
		po(0, 0),
		po(0, height - 1),
		po(width - 1, height - 1),
		po(width - 1, 0),
	};

	/*
	 * offsets of the pixels next to the corresponding edges
	 * If edge[i] goes to the top left corner, edge_neighbour[i] is
	 * located just below of edge[i].
	 */
	const unsigned en[] = {
		po(0, 1),
		po(1, height - 1),
		po(width - 1, height - 2),
		po(width - 2, 0),
	};

#define ro(r) ((rotation + (r)) % 4)

	*xstride = en[ro(0)] - e[ro(3)];
	*pstride = e[ro(3)] - en[ro(3)];
	*tloffset = e[ro(0)];
}
Пример #3
0
//------------------------------------------------------------------------------
void
Canvas::DrawAnnulus(int x, int y,
                    unsigned inner_r, unsigned outer_r,
                    Angle start, Angle end)
  {
  QPainterPath p;
  QRectF ri(x - inner_r, y - inner_r, 2 * inner_r, 2 * inner_r);
  QRectF ro(x - outer_r, y - outer_r, 2 * outer_r, 2 * outer_r);
  // Draw the inner radius of the annulus.
  p.arcMoveTo(ri, start.Degrees());
  p.arcTo(ri, start.Degrees(), end.Degrees() - start.Degrees());
  if (start != end)
    { // Only draw the end caps when needed.
    // The currentPosition() will be at the end of the inner circle. Draw
    // one side of the annulus.
    // \todo This doesn't work because Angle(360) != Angle(0)!
    double xx = (outer_r - inner_r) * cos(end.Radians()) +
                p.currentPosition().rx();
    double yy = (outer_r - inner_r) * -sin(end.Radians()) +
                p.currentPosition().ry();
    p.lineTo(xx, yy);
    }
  else
    p.arcMoveTo(ro, end.Degrees());  // Set up for the outer circle.
  // The currentPosition() will be at the 'end' of the outer circle. Draw the
  // outer to the start.
  p.arcTo(ro, end.Degrees(), start.Degrees() - end.Degrees());
  if (start != end)
    {// And close it off to finish up.
    p.closeSubpath();
    }
  this->pushObject(p, this->pen(), this->brush());
  }
Пример #4
0
float Sphere::FindIntersection( const Ray & RayInst )
{
	Vec3 ro( RayInst.origin );
	Vec3 rd( RayInst.direction );
	Vec3 sc( center );
	float rad = radius;

	Vec3 ctm( ro - sc );
	float a = 1.0f;
	float b = DotProduct( ctm * 2.0f, rd );
	float c = DotProduct( ctm, ctm ) - Sq( rad );

	float disc = Sq( b ) - ( 4.0f * c );
	float result = -1.0f;

	if( disc <= 0.0f )
	{
		return result;
	}

	float root = ( ( -1.0f * b - sqrtf( disc ) ) * 0.5f );
	result = root > 0.0f ? root : ( sqrtf( disc ) - b ) * 0.5f;

	return result;
}
Пример #5
0
void CRandomOptionProperty::AwakeningExtension( void )
{
	int	anDst[eAwakeningExtension][6]	= {		// 각 부분 별 각성 가능 속성
		DST_CHR_CHANCECRITICAL, DST_ATKPOWER, DST_SPELL_RATE, DST_ATTACKSPEED, DST_MP_MAX, DST_FP_MAX,
		DST_CRITICAL_BONUS, DST_SPEED, DST_ADJDEF, DST_HP_MAX, DST_MP_MAX, DST_FP_MAX,
		DST_STR, DST_DEX, DST_INT, DST_STA, DST_MP_MAX, DST_FP_MAX	};
	int anTotal[eAwakeningExtension];
	memset( anTotal, 0, sizeof(int) * eAwakeningExtension );

	// 각성 테이블에서 해당 부분에 각성 가능한 속성만을 포함하도록
	// 각성 테이블 확장 후 구성한다
	for( DWORD i = 0; i < m_aRandomOption[eAwakening].size(); i++ )
	{
		RANDOM_OPTION* pRandomOption	= &m_aRandomOption[eAwakening][i];
		int nProb	= ( i == 0?
			m_aRandomOption[eAwakening][i].nProb:
			m_aRandomOption[eAwakening][i].nProb - m_aRandomOption[eAwakening][i-1].nProb );

		for( int j = 0; j < eAwakeningExtension; j++ )
		{
			int iRandomOptionKindIndex	= GetRandomOptionKindIndex( eAwakening, PARTS_HAND + j );
			for( int k = 0; k < 6; k++ )
				if( pRandomOption->nDst == anDst[j][k] )
				{
					RANDOM_OPTION ro( pRandomOption );
					ro.nProb	= anTotal[j] + nProb;
					anTotal[j]	= ro.nProb;
					m_aRandomOption[iRandomOptionKindIndex].push_back( ro );
				}
		}
	}
}
Пример #6
0
void RenderOperationDesc::
    test()
{
    // The RenderOperationDesc class should keep the filter operation used by a
    // render target and notify the render target about processing events.
    {
        RenderOperationDesc* rod;
        RenderOperationDescMockTarget* target;

        OperationDesc::ptr operation( new Test::TransparentOperationDesc() );
        RenderTarget::ptr rtp(target = new RenderOperationDescMockTarget());

        Signal::OperationDesc::ptr ro(rod = new RenderOperationDesc(operation, rtp));
        Signal::Operation::ptr o = ro.write ()->createOperation(0);

        // Operations are processed through a Processing::Step
        Processing::Step step(ro);
        step.deprecateCache (Interval(4,9));
        o->process (pBuffer());

        EXCEPTION_ASSERT_EQUALS( Interval(4,9), target->I );
        EXCEPTION_ASSERT_EQUALS( 1, target->processed_count );
        EXCEPTION_ASSERT_EQUALS( (void*)0, rod->transform_desc ().get () );
    }
}
Пример #7
0
void QSegmentWidget::DrawCylinder(const Cylinder &cyl,
  const SegmentList &s, const bool erase)
{
  if (!m_pixmap)
    InitPixmap();
  qreal border = 0;
  QPainter painter(m_pixmap);
  painter.setRenderHint(QPainter::Antialiasing);
  painter.setRenderHint(QPainter::SmoothPixmapTransform);
  painter.setWindow( -(BM_OSIZE / 2), -(BM_OSIZE / 2),
    BM_OSIZE, BM_OSIZE);
  QRectF rco(-cyl.outerRadius, -cyl.outerRadius, (cyl.outerRadius * 2.0)+border,
      (cyl.outerRadius * 2.0)+border);
  QRectF rci(-cyl.innerRadius, -cyl.innerRadius, (cyl.innerRadius * 2.0)+border,
      (cyl.innerRadius * 2.0)+border);
  QRegion ro(rco.toRect(), QRegion::Rectangle);
  QRegion ri(rci.toRect(), QRegion::Ellipse);
  QRegion region = ro.subtracted(ri);
  painter.setClipRegion(region);
  if (erase) {
      painter.setBrush(Qt::NoBrush);
      painter.setPen(Qt::NoPen);
  } else {
    QBrush b(cyl.color);
    painter.setBrush(b);
    painter.setPen(QPen(cyl.color.darker(200),border));
  }
  DrawSegments(&painter, s, cyl.outerRadius);
}
Пример #8
0
void Discrete_upper_envelope::build_ric(const std::vector< Line >& input,
        int LB, int UB) {

    // set the size
    init_build_and_verify_input(input, LB, UB);

    // log the input
    rLog(up_env_ric, "Input for build_ric\n %s",
            vect_to_string(input.begin(),input.end(), "\t","\n",true).c_str());

    // sort the lines by slope filtering duplicate slopes
    std::list< const Line* > sorted_lines;
    sort_and_filter_by_slope(back_inserter(sorted_lines),
            input.begin(), input.end());

    // log the sorted and filtered lines
    rLog(up_env_ric, "Sorted filtered lines:\n%s",
            vect_of_ptrs_to_cstring(sorted_lines.begin(), sorted_lines.end()));

    int num_lines = sorted_lines.size();
    Rand_order_mem ro(rand_order_mem_size(num_lines));
    Building_envelope_mem be01(building_envelope_mem_size(num_lines));
    Building_envelope_mem be02(building_envelope_mem_size(num_lines));
    build_ric_with_slope_unique_lines_sorted_by_slope(sorted_lines, ro, be01, be02);
}
void ElfSectionManager::AddSection(ElfSection & aSection){
	EnsureSectionStringTableSectionAdded();
	if (aSection.GetName().size() > 0){
		// rename sections for GDB (yuk!)
		String sectionName(aSection.GetName());
		String ro("ER_RO");
		String text(".text");
		if (sectionName == ro){
			sectionName = text;
		} else {
			String rw("ER_RW");
			String data(".data");
			if (sectionName == rw){
				sectionName = data;
			} else {
				String zi("ER_ZI");
				String bss(".bss");
				if (sectionName == zi)
					sectionName = bss;
			}
		}
		size_t nameOffset = iStringTable.AddName(sectionName);
		aSection.SetNameOffset(nameOffset);
	} else {
		// use the initial Null String.
		size_t nameOffset = iStringTable.AllocateInitialNullString();
		aSection.SetNameOffset(nameOffset);
	}
	aSection.SetIndex(iSections.size());
	iSections.push_back(aSection);
	iElf32Header.AddSectionHdr();
}
Пример #10
0
PixmapRenderer::PixmapRenderer(int width, int height, QGLWidget *shareWidget)
	: width_(width), height_(height), shareWidget_(shareWidget)
{
	QGLFormat fmt = QGLFormat::defaultFormat();
	fmt.setAlpha(true);
	fmt.setSampleBuffers(true);

	if (!QGLPixelBuffer::hasOpenGLPbuffers()) {
		throw std::runtime_error("OpenGL Pbuffer extension required.");
	}
	
	buffer_ = new QGLPixelBuffer(width_, height_, fmt, shareWidget_);
	buffer_->makeCurrent();	
	
	// Initialize GL
#ifndef KONSTRUKTOR_DB_UPDATER
	params_ = new ldraw_renderer::parameters(*Application::self()->renderer_params());
#else
	params_ = new ldraw_renderer::parameters();
	params_->set_stud_rendering_mode(ldraw_renderer::parameters::stud_regular);
#endif
	
	ldraw_renderer::renderer_opengl_factory ro(params_, ldraw_renderer::renderer_opengl_factory::mode_vbo);
	renderer_ = ro.create_renderer();
	renderer_->set_base_color(ldraw::color(7));
	renderer_->setup();
	
	glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
	glClearDepth(1.0f);
	
	glMatrixMode(GL_PROJECTION);
	glViewport(0, 0, width_, height_);
	
	buffer_->doneCurrent();
}
	std::vector < T > Get_Data(const bool &noise_amplitude_is_known, const T &noise_amplitude) {
		T alpha = 1;
		T this_sigma = 1000;
		T prev_sigma = this_sigma;
		
		std::vector < T > a, b, c, f;
		Fill(alpha, a, c, b, f);
		solveMatrix(this->N + 1, a, c, b, f, this->Z);
		while (true) {
			_Z = Z;
			prev_sigma = this_sigma;
			alpha *= 0.5;
			Fill(alpha, a, c, b, f);
			solveMatrix(this->N + 1, a, c, b, f, this->Z);
			this_sigma = sigma();
			if (noise_amplitude_is_known) {
				if (ro() - SQR(noise_amplitude) <= 0) {
					cerr << "alpha = " << alpha << endl;
					return this->Z;
				}
			} else {
//				if (this_sigma > prev_sigma) {
				if (alpha < noise_amplitude) {
					cerr << "alpha = " << alpha << ", sigma = " << this_sigma << endl;
					return this->Z;
				}
			}
		}
	}
Пример #12
0
void key()   //key제어
{
    int a=0;
    a=getch();
    switch(a)
    {
    case 72: //UP
        ro();
        break;
    case 75: //LEFT
        left();
        break;
    case 77: //RIGHT
        right();
        break;
    case 80: //DOWN
        down();
        break;
    case 32: //DOWN.DOWN.DOWN(SPACE BAR)
        downn();
        Time=0;
        break;
    case 27: //EXIT
        exit(1);
    }
}
Пример #13
0
QString ReplaceModifier::parseOperation(ParseSettings& settings)
{
    Q_UNUSED(settings);

    const QRegExp& reg  = regExp();
    QString original    = reg.cap(2);
    QString replacement = reg.cap(3);
    QString result      = settings.str2Modify;
    QString options     = reg.cap(5);
    Qt::CaseSensitivity caseType = (!options.isEmpty() && options.contains('i'))
                                   ? Qt::CaseInsensitive
                                   : Qt::CaseSensitive;

    QRegExp ro(original);
    ro.setCaseSensitivity(caseType);

    if (!options.isEmpty() && options.contains('r'))
    {
        result.replace(ro, replacement);
    }
    else
    {
        result.replace(original, replacement, caseType);
    }

    return result;
}
Пример #14
0
Eigen::MatrixXd Kinematics::transform(double x, double y, double z, double roll, double pitch, double yaw) const{
	Eigen::MatrixXd trans(4, 4);
	trans << 1.0, 0.0, 0.0, x,
			 0.0, 1.0, 0.0, y,
			 0.0, 0.0, 1.0, z,
			 0.0, 0.0, 0.0, 1.0;
	
	Eigen::MatrixXd ro(4, 4);
	ro << 1.0, 0.0, 0.0, 0.0,
		 0.0, cos(roll), -sin(roll), 0.0,
		 0.0, sin(roll), cos(roll), 0.0,
		 0.0, 0.0, 0.0, 1.0;
	
	Eigen::MatrixXd pi(4, 4);
	pi << cos(pitch), 0.0, sin(pitch), 0.0,
		 0.0, 1.0, 0.0, 0.0,
		 -sin(pitch), 0.0, cos(pitch), 0.0,
		 0.0, 0.0, 0.0, 1.0;
	
	Eigen::MatrixXd ya(4, 4);
	ya << cos(yaw), -sin(yaw), 0.0, 0.0,
		  sin(yaw), cos(yaw), 0.0, 0.0,
		  0.0, 0.0, 1.0, 0.0,
		  0.0, 0.0, 0.0, 1.0;
	
	Eigen::MatrixXd res = ro * pi * ya * trans;
	return res;
}
Пример #15
0
void recEventa::CreateFamilyLink() const
{
    recEventaPersonaVec eapas = GetEventaPersonas();
    recIdVec partners, children;
    for( size_t i = 0 ; i < eapas.size() ; i++ ) {
        recEventTypeRole ro(eapas[i].FGetRoleID());
        if( ro.FGetPrime() > 0 ) {
            partners.push_back( eapas[i].FGetPerID() );
        } else {
            children.push_back( eapas[i].FGetPerID() );
        }
    }
    if( partners.empty() ) {
        return;
    }
    wxASSERT( partners.size() <= 2 );

    recIdVec fams; // List of possible families.
    if( partners.size() == 2 ) {
        recIdVec ind1s = recPersona::GetIndividualIDs( partners[0] );
        recIdVec ind2s = recPersona::GetIndividualIDs( partners[1] );
        // Go through all possibilities
        for( size_t i = 0 ; i < ind1s.size() ; i++ ) {
            for( size_t j = 0 ; j < ind2s.size() ; j++ ) {
                idt famID = recFamily::FindOrCreate( ind1s[i], ind2s[j] );
                if( famID ) {
                    fams.push_back( famID );
                }
            }
        }
    } else if( partners.size() == 1 ) {
        recIdVec inds = recPersona::GetIndividualIDs( partners[0] );
        for( size_t i = 0 ; i < inds.size() ; i++ ) {
            idt famID = recFamily::FindOrCreate( inds[i], 0 );
            if( famID ) {
                fams.push_back( famID );
            }
        }
    }
    for( size_t i = 0 ; i < fams.size() ; i++ ) {
        recFamilyEventa::Create( fams[i], FGetID() );
        for( size_t j = 0 ; j < children.size() ; j++ ) {
            recIdVec inds = recPersona::GetIndividualIDs( children[j] );
            for( size_t k = 0 ; k < inds.size() ; k++ ) {
                recFamilyIndividual fi(0);
                fi.FSetFamID( fams[i] );
                fi.FSetIndID( inds[k] );
                fi.Find();
                if( fi.FGetID() == 0 ) {
                    // Doesn't exist, so create it.
                    fi.FSetSeqChild( recFamily::GetChildNextSequence( fams[i] ) );
                    fi.FSetSeqParent( recFamily::GetParentNextSequence( inds[k] ) );
                    fi.Save();
                }
                recFamilyIndEventa::Create( fi.FGetID(), FGetID() );
            }
        }
    }
}
Пример #16
0
Factor::operator SEXP() {
    int numObs = getNumObservations();
    int numLevels = getNumLevels();
    Rcpp::IntegerVector iv(numObs); // allocates R memory
    Rcpp::CharacterVector cv(numLevels); // ditto
    SEXP RFactor = iv;
    for(int i=0; i < numObs; ++i)
	iv[i] = getObservedLevelNum(i);
    for(int i=0; i < numLevels; ++i)
	cv[i] = getLevelName(i);
    Rcpp::RObject ro(RFactor);
    ro.attr("class") = "factor";
    ro.attr("levels") = cv;
    return ro;
}
Пример #17
0
void NodeJSDevToolsProtocol::Eval(clWebSocketClient& socket, const wxString& expression, const wxString& frameId)
{
    JSONItem params = JSONItem::createObject("params");
    params.addProperty("callFrameId", frameId);
    params.addProperty("expression", expression);
    params.addProperty("generatePreview", true);
    SendSimpleCommand(socket, "Debugger.evaluateOnCallFrame", params);
    // Register a handler to handle this command when it returns
    CommandHandler handler(message_id, [=](const JSONItem& result) {
        if(result.hasNamedObject("result")) {
            nSerializableObject::Ptr_t ro(new RemoteObject());
            ro->To<RemoteObject>()->SetExpression(expression);
            ro->To<RemoteObject>()->FromJSON(result.namedObject("result"));
            clDebugRemoteObjectEvent evt(wxEVT_NODEJS_DEBUGGER_EVAL_RESULT);
            evt.SetRemoteObject(ro);
            EventNotifier::Get()->AddPendingEvent(evt);
        }
    });
    m_waitingReplyCommands.insert({ handler.m_commandID, handler });
}
Пример #18
0
void recEventa::CreatePersonalEvent() const
{
    recEvent eve(0);
    recEventaPersonaVec eapas = GetEventaPersonas();
    for( size_t i = 0 ; i < eapas.size() ; i++ ) {
        recEventTypeRole ro(eapas[i].FGetRoleID());
        if( ro.FGetPrime() == 0 ) {
            continue;
        }
        // List of Individuls associated with this Persona
        recIdVec indIDs = recPersona::GetIndividualIDs( eapas[i].FGetPerID() );
        for( size_t j = 0 ; j < indIDs.size() ; j++ ) {
            if( eve.FGetID() == 0 ) {
                // About time we created the Event
                eve.CreateFromEventa( *this );
                recEventEventa::Create( eve.FGetID(), f_id );
            }
            // Find summary IndividualEvent
            idt ieSumID = recIndividual::GetPersonalSummaryIE( indIDs[j], ro.FGetTypeID() );
            if( ieSumID == 0 ) {
                // Create the summary personal Event.
                recEvent e(0);
                e.FSetTypeID( FGetTypeID() );
                e.SetAutoTitle( recIndividual::GetName( indIDs[j] ) + _(" - Summary") );
                e.FSetDate1ID( recIndividual::CreateBirthDate( indIDs[j] ) );
                e.FSetDate2ID( recIndividual::CreateDeathDate( indIDs[j] ) );
                e.Save();
                idt sum_etrID = recEventType::GetSummaryRole( FGetTypeID() );
                ieSumID = recIndividualEvent::Create( indIDs[j], e.FGetID(), sum_etrID );
            }
            recIndividualEvent ie(0);
            ie.FSetHigherID( ieSumID );
            ie.FSetIndID( indIDs[j] );
            ie.FSetEventID( eve.FGetID() );
            ie.FSetRoleID( ro.FGetID() );
            ie.FSetNote( eapas[i].FGetNote() );
            ie.Save();
        }
    }
}
Пример #19
0
LRESULT
CDeviceHostStatPage::OnWorkDone(UINT uMsg, WPARAM wParam, LPARAM lParam)
{
	// Stop the animation
	m_findHostsAnimate.Stop();
	m_findHostsAnimate.ShowWindow(SW_HIDE);

	// Fill the list view

	CString strBuffer;
	int size = m_hostInfoDataArray.GetSize();
	for (int i = 0; i < size; ++i)
	{
		HostInfoData& data = m_hostInfoDataArray[i];
		const NDAS_HOST_INFO* pHostInfo = &data.HostInfo;
		ACCESS_MASK access = data.Access;

		(void) pAddressString(
			strBuffer,
			&pHostInfo->LPXAddrs,
			&pHostInfo->IPV4Addrs);

		CString rw(MAKEINTRESOURCE(IDS_HOST_RW));
		CString ro(MAKEINTRESOURCE(IDS_HOST_RO));
		m_wndListView.AddItem(i, 0, (access & GENERIC_WRITE) ? rw : ro);
		m_wndListView.SetItemText(i, 1, pHostInfo->szHostname);
		m_wndListView.SetItemText(i, 2, strBuffer);
	}

	AdjustHeaderWidth(m_wndListView);

	m_wndRefreshLink.EnableWindow(TRUE);

	m_hCursor = AtlLoadSysCursor(IDC_ARROW);
	SetCursor(m_hCursor);

	return TRUE;
}
Пример #20
0
template<class Ar> void serialize(Ar& ar, const uint version) { ar & c() & ri() & ro(); }
Пример #21
0
    static void CalculateMDFData(T* angles, T* axes, T* weights, T* odf, T* mdf, size_t numEntries)
    {
      SpaceGroupOps orientationOps;
      const int odfsize = orientationOps.getODFSize();
      const int mdfsize = orientationOps.getMDFSize();

      uint64_t m_Seed = QDateTime::currentMSecsSinceEpoch();
      SIMPL_RANDOMNG_NEW_SEEDED(m_Seed);

      int mbin;
      float w = 0;
      int choose1, choose2;
      QuatF q1;
      QuatF q2;
      float totaldensity;
      float n1, n2, n3;
      float random1, random2, density;

      for (int i = 0; i < mdfsize; i++)
      {
        mdf[i] = 0.0;
      }
      int remainingcount = 10000;
      int aSize = static_cast<int>(numEntries);
      for (int i = 0; i < aSize; i++)
      {
        FOrientArrayType ax( axes[3 * i], axes[3 * i + 1], axes[3 * i + 2], angles[i]);
        FOrientArrayType rod(4);
        OrientationTransforms<FOrientArrayType, float>::ax2ro(ax, rod);

        rod = orientationOps.getMDFFZRod(rod);
        mbin = orientationOps.getMisoBin(rod);
        mdf[mbin] = -int((weights[i] / float(mdfsize)) * 10000.0);
        remainingcount = remainingcount + mdf[mbin];
      }

      for (int i = 0; i < remainingcount; i++)
      {
        m_Seed++;
        SIMPL_RANDOMNG_NEW_SEEDED(m_Seed);
        random1 = rg.genrand_res53();
        random2 = rg.genrand_res53();
        choose1 = 0;
        choose2 = 0;

        totaldensity = 0;
        for (int j = 0; j < odfsize; j++)
        {
          density = odf[j];
          float d = totaldensity;
          totaldensity = totaldensity + density;
          if(random1 >= d && random1 < totaldensity) { choose1 = static_cast<int>(j); }
          if(random2 >= d && random2 < totaldensity) { choose2 = static_cast<int>(j); }
        }

        FOrientArrayType eu = orientationOps.determineEulerAngles(m_Seed, choose1);
        FOrientArrayType qu(4);
        OrientationTransforms<FOrientArrayType, float>::eu2qu(eu, qu);
        q1 = qu.toQuaternion();

        m_Seed++;
        eu = orientationOps.determineEulerAngles(m_Seed, choose2);
        OrientationTransforms<FOrientArrayType, float>::eu2qu(eu, qu);
        q2 = qu.toQuaternion();
        w = orientationOps.getMisoQuat(q1, q2, n1, n2, n3);

        FOrientArrayType ax(n1, n2, n3, w);
        FOrientArrayType ro(4);
        OrientationTransforms<FOrientArrayType, float>::ax2ro(ax, ro);

        ro = orientationOps.getMDFFZRod(ro);
        mbin = orientationOps.getMisoBin(ro);
        if(mdf[mbin] >= 0) { mdf[mbin]++; }
        if(mdf[mbin] < 0) { i = i - 1; }
      }
      for (int i = 0; i < mdfsize; i++)
      {
        if(mdf[i] < 0) { mdf[i] = -mdf[i]; }
        mdf[i] = mdf[i] / 10000.0;
      }

    }
Пример #22
0
double Solver::p(double t, double x, double y, double p_ro) {
	return p_ro*ro(t,x,y);
}
Пример #23
0
double Solver::gg(double t, double x, double y) {
	return log(ro(t,x,y));
}
Пример #24
0
void Grid<Ndim>::MakeFilter(const double sigma){
	unsigned int nzp=nnz/2+1;
	size_t align=sizeof(Complex);
	if(!filter && !filterrc) {
		filter=new array3<Complex>;
		filter->Allocate(nnx,nny,nnz);
		filterrc=new array3<Complex>;
		filterrc->Allocate(nnx,nny,nzp,align);
	}
	int nfx,nfy,nfz;
	nfx=(nnx % 2 == 0)? nnx/2: nnx/2+1;
	nfy=(nny % 2 == 0)? nny/2: nny/2+1;
	nfz=(nnz % 2 == 0)? nnz/2: nnz/2+1;
	array3<Complex> & Mfilter=*filter;
	array3<Complex> & Mfilterrc=*filterrc;

	fft3d Forward3(nnx,nny,nnz,-1);
	fft3d Backward3(nnx,nny,nnz,1);
	Mfilter=Complex(0.0,0.0);

	double dx=co[0][0]/static_cast<double> (nnx);
	double dy=co[1][1]/static_cast<double> (nny);
	double dz=co[2][2]/static_cast<double> (nnz);
	int mx=static_cast<int> (3.0*sigma/dx);
	int my=static_cast<int> (3.0*sigma/dy);
	int mz=static_cast<int> (3.0*sigma/dz);

	double xa,ya,za;
	double sum=0.0;
	for(int i=-mx;i<=mx;i++){
		int ia=(i<0)?i+nnx:i;
		double xd=static_cast<double> (i)/static_cast<double> (nnx);
		for(int j=-my;j<=my;j++){
			int ja=(j<0)?j+nny:j;
			double yd=static_cast<double> (j)/static_cast<double> (nny);
			for(int k=-mz;k<=mz;k++){
				int ka=(k<0)?k+nnz:k;
				double zd=static_cast<double> (k)/static_cast<double> (nnz);
				xa=co[XX][XX]*xd+co[XX][YY]*yd+co[XX][ZZ]*zd;
				ya=co[YY][XX]*xd+co[YY][YY]*yd+co[YY][ZZ]*zd;
				za=co[ZZ][XX]*xd+co[ZZ][YY]*yd+co[ZZ][ZZ]*zd;
				double rs=xa*xa+ya*ya+za*za;
				double fact1=exp(-rs/(2.0*sigma*sigma));
				Mfilter[ia][ja][ka].real()=fact1;
				Mfilter(ia,ja,ka).imag()=0;

				sum+=fact1;

			}
		}
	}

	for(unsigned int i=0;i<nnx;i++)
		for(unsigned int j=0;j<nny;j++)
			for(unsigned int k=0;k<nnz;k++){
				Mfilter(i,j,k).real()=Mfilter(i,j,k).real()/sum;
			}


	array3<double> ro(nnx,nny,nnz,align);
	array3<Complex> rok(nnx,nny,nzp,align);

	rcfft3d Forward(nnz,ro,Mfilterrc);
	crfft3d Backward(nnz,Mfilterrc,ro);

	int nx0=static_cast<int>(nnx);
	int ny0=static_cast<int>(nny);
	int nz0=static_cast<int>(nnz);

	for(int i=0;i<nx0;i++)
		for(int j=0;j<ny0;j++)
			for(int k=0;k<nz0;k++){
				ro[i][j][k]=Mfilter[i][j][k].real();
			}
	Forward.fft(ro,Mfilterrc);
	Forward3.fft(Mfilter);



}
Пример #25
0
 /*! Fit Inside \p a. */
 void fit_in(const box<T,N>& a) {
     c() = a.cen();          // copy center
     auto md = a.min_dim();
     ri() = md/4;
     ro() = md/2;
 }
Пример #26
0
 box<T,N> outer_box() const { return box<T,N>(c()-ro(), c()+ro()); } ///< Outer Box.