Пример #1
0
	void Run()
	{
		CBox box;
		sketch_for_tools->GetBox(box);
		double centre[3];
		box.Centre(centre);		

		wxGetApp().m_digitizing->digitized_point = DigitizedPoint(gp_Pnt(centre[0], box.MinY(), centre[2]), DigitizeInputType);
		Drawing *pDrawingMode = dynamic_cast<Drawing *>(wxGetApp().input_mode_object);
		if (pDrawingMode != NULL)
		{
			pDrawingMode->AddPoint();
		}
	}
Пример #2
0
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";
}
Пример #3
0
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();
    }
}