当前位置: 首页>>代码示例>>C++>>正文


C++ CBox::Height方法代码示例

本文整理汇总了C++中CBox::Height方法的典型用法代码示例。如果您正苦于以下问题:C++ CBox::Height方法的具体用法?C++ CBox::Height怎么用?C++ CBox::Height使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CBox的用法示例。


在下文中一共展示了CBox::Height方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: CBox

static void	WriteCoords(std::wofstream &ofs)
{
	CBox box;
	GetWorldBox(box);

	if(!box.m_valid)
	{
		box = CBox(-100, -100, -50, 100, 100, 50);
	}
	else
	{
		while(box.Width() < 100){box.m_x[0] -= 5.0; box.m_x[3] += 5.0;}
		while(box.Height() < 100){box.m_x[1] -= 5.0; box.m_x[4] += 5.0;}
		box.m_x[2] -= 10.0;
	}

	ofs<<"toolpath.coords = Coords("<<box.MinX()<<", "<<box.MinY()<<", "<<box.MinZ()<<", "<<box.MaxX()<<", "<<box.MaxY()<<", "<<box.MaxZ()<<")\n";
}
开发者ID:play113,项目名称:swer,代码行数:18,代码来源:Simulate.cpp

示例2: RenderGrid

static void RenderGrid(const CViewPoint *view_point, double max_number_across, bool in_between_spaces, bool miss_main_lines, const HeeksColor *bg, const HeeksColor *cc, unsigned char brightness, int plane_mode){
	gp_Pnt sp[4];
	double zval = 0.5;
	wxSize size = wxGetApp().m_current_viewport->GetViewportSize();
	sp[0] = gp_Pnt(0, 0, zval);
	sp[1] = gp_Pnt(size.GetWidth(), 0, zval);
	sp[2] = gp_Pnt(size.GetWidth(), size.GetHeight(), zval);
	sp[3] = gp_Pnt(0, size.GetHeight(), zval);
	gp_Vec vx, vy;
	int plane_mode2 = view_point->GetTwoAxes(vx, vy, false, plane_mode);
	gp_Pnt datum(0, 0, 0);
	gp_Trsf orimat = wxGetApp().GetDrawMatrix(false);
	datum.Transform(orimat);
	orimat = make_matrix(datum, vx, vy);
	gp_Vec unit_forward = view_point->forwards_vector().Normalized();
	double plane_dp = fabs(gp_Vec(0, 0, 1).Transformed(orimat) * unit_forward);
	if(plane_dp < 0.3)return;
	gp_Pln plane(gp_Pnt(0, 0, 0).Transformed(orimat), gp_Vec(0, 0, 1).Transformed(orimat));
	{
		for(int i =0; i<4; i++){
			gp_Pnt p1 = view_point->glUnproject(sp[i]);
			sp[i].SetZ(0);
			gp_Pnt p2 = view_point->glUnproject(sp[i]);
			if(p1.Distance(p2) < 0.00000000001)return;
			gp_Lin line = make_line(p1, p2);
			gp_Pnt pnt;
			if(intersect(line, plane, pnt))
			{
				sp[i].SetX((gp_Vec(pnt.XYZ()) * vx) - (gp_Vec(datum.XYZ()) * vx));
				sp[i].SetY((gp_Vec(pnt.XYZ()) * vy) - (gp_Vec(datum.XYZ()) * vy));
				sp[i].SetZ(0);
			}
		}
	}
	CBox b;
	{
		for(int i = 0; i<4; i++){
			b.Insert(sp[i].X(), sp[i].Y(), sp[i].Z());
		}
	}
	double width = b.Width();
	double height = b.Height();
	double biggest_dimension;
	if(height > width)biggest_dimension = height;
	else biggest_dimension = width;
	double widest_spacing = biggest_dimension/max_number_across;
	bool dimmer = false;
	double dimness_ratio = 1.0;
	double spacing;

	if(wxGetApp().draw_to_grid){
		spacing = wxGetApp().digitizing_grid;
		if(!miss_main_lines)spacing *= 10;
		if(spacing<0.0000000001)return;
		if(biggest_dimension / spacing > max_number_across * 1.5)return;
		if(biggest_dimension / spacing > max_number_across){
			dimmer = true;
			dimness_ratio = (max_number_across * 1.5 - biggest_dimension / spacing)/ (max_number_across * 0.5);
		}

	}
	else{
		double l = log10(widest_spacing / wxGetApp().m_view_units);

		double intl = (int)l;
		if(l>0)intl++;

		spacing = pow(10.0, intl) * wxGetApp().m_view_units;
	}

	if(wxGetApp().grid_mode == 3){
		dimmer = true;
		dimness_ratio *= plane_dp;
		dimness_ratio *= plane_dp;
	}
	double ext2d[4];
	ext2d[0] = b.m_x[0];
	ext2d[1] = b.m_x[1];
	ext2d[2] = b.m_x[3];
	ext2d[3] = b.m_x[4];
	{
		for(int i = 0; i<4; i++){
			double intval = (int)(ext2d[i]/spacing);
			if(i <2 ){
				if(ext2d[i]<0)intval--;
			}
			else{
				if(ext2d[i]>0)intval++;
			}

			ext2d[i] = intval * spacing;
		}
	}
	if(cc){
		HeeksColor col = *cc;
		if(wxGetApp().grid_mode == 3){
			switch(plane_mode2){
			case 0:
				col.green = (unsigned char)(0.6 * (double)(bg->green));
				break;
//.........这里部分代码省略.........
开发者ID:DavidNicholls,项目名称:heekscad,代码行数:101,代码来源:Grid.cpp

示例3: wxGetApp

static void	WriteSolids(std::wofstream &ofs)
{

	std::set<int> stock_ids;
	wxGetApp().m_program->Stocks()->GetSolidIds(stock_ids);
	for(std::set<int>::iterator It = stock_ids.begin(); It != stock_ids.end(); It++)
	{
		int id = *It;
		HeeksObj* object = wxGetApp().GetIDObject(SolidType, id);
		if(object)
		{
			CBox box;
			object->GetBox(box);
			ofs<<"voxelcut.set_current_color("<<object->GetColor()->COLORREF_color()<<")\n";
			double c[3];
			box.Centre(c);
			ofs<<"toolpath.coords.add_block("<<c[0]<<", "<<c[1]<<", "<<box.MinZ()<<", "<<box.Width()<<", "<<box.Height()<<", "<<box.Depth()<<")\n";
		}
	}
}
开发者ID:play113,项目名称:swer,代码行数:20,代码来源:Simulate.cpp

示例4: Pack

void CBOM::Pack(double bin_width, double height, int gap)
{
    m_gap = gap;
    Rectangles_t best_rects;
    rects.clear();
    HeeksObj* child = GetFirstChild();
    while(child)
    {
        CTrsfNCCode* code = (CTrsfNCCode*)child;
        CBox box;
        code->GetBox(box);
        //Figure out how to translate later
        NCRect ncrect(0,0,box.Width()+gap,box.Height()+gap,code);
        best_rects.push_back(ncrect);
        rects.push_back(ncrect);
        child = GetNextChild();
    }


    // Sort by height.
    std::sort(best_rects.begin(),best_rects.end(),ByHeight());


    // Make variables to track and record the best solution.
    bool* is_positioned = new bool[best_rects.size()];
    for(unsigned int i=0; i < best_rects.size(); i++)
        is_positioned[i] = false;
    int num_unpositioned = rects.size();
    // Fill by stripes.
    int max_y = 0;
    for (unsigned int i = 0; i <= rects.size() - 1; i++)
    {
        // See if this rectangle is positioned.
        if (!is_positioned[i])
        {
            // Start a new stripe.
            num_unpositioned -= 1;
            is_positioned[i] = true;
            best_rects[i].m_x = 0;
            best_rects[i].m_y = max_y;

            FillBoundedArea(
                best_rects[i].m_width, bin_width, max_y,
                max_y + best_rects[i].m_height,
                num_unpositioned, best_rects, is_positioned,0, false);

            if (num_unpositioned == 0) break;
            max_y += best_rects[i].m_height;
        }
    }

    // Save the best solution.
    rects = best_rects;

    //Apply to the NCCODE
    for(unsigned int i=0; i < rects.size(); i++)
    {
        CTrsfNCCode *code = rects[i].m_code;
        CBox box;
        code->GetBox(box);
        code->m_x = rects[i].m_x - box.MinX();
        code->m_y = rects[i].m_y - box.MinY();
    }
}
开发者ID:JonasThomas,项目名称:heekscnc,代码行数:64,代码来源:BOM.cpp


注:本文中的CBox::Height方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。