Ejemplo n.º 1
0
void TransformObjectsTool::RollBack(){
	std::list<HeeksObj*>::const_iterator It;
	for(It = m_list.begin(); It != m_list.end(); It++){
		HeeksObj* object = *It;
		object->ModifyByMatrix(revert_matrix);
	}
	wxGetApp().WereModified(m_list);
}
Ejemplo n.º 2
0
void TransformObjectsTool::Run(bool redo){
	std::list<HeeksObj*>::iterator It;
	for(It = m_list.begin(); It != m_list.end(); It++){
		HeeksObj* object = *It;
		object->ModifyByMatrix(modify_matrix);
	}
	wxGetApp().WereModified(m_list);
}
Ejemplo n.º 3
0
HeeksObj *VectorFont::Glyph::GlyphArc::Sketch( const gp_Pnt & location, const gp_Trsf & transformation_matrix, const float width, COrientationModifier *pOrientationModifier ) const
{
	double start[3];
	double end[3];
	double centre[3];
	double up[3];

	gp_Pnt centre_point( location.X() + m_xcentre, location.Y() + m_ycentre, location.Z() );
	gp_Pnt start_point( centre_point.X() + m_radius, centre_point.Y(), centre_point.Z() );
	gp_Pnt end_point( centre_point.X() + m_radius, centre_point.Y(), centre_point.Z() );

    gp_Dir z_direction( 0, 0, 1 );

    if (pOrientationModifier) centre_point = pOrientationModifier->Transform(transformation_matrix, location.Distance(gp_Pnt(0.0,0.0,0.0)), centre_point, width );

    if (pOrientationModifier) start_point = pOrientationModifier->Transform(transformation_matrix, location.Distance(gp_Pnt(0.0,0.0,0.0)), start_point, width );

	gp_Trsf start_rotation_matrix;
	start_rotation_matrix.SetRotation( gp_Ax1(centre_point, z_direction), m_start_angle );
	start_point.Transform(start_rotation_matrix);	// Rotate to start_angle

	start[0] = start_point.X();
	start[1] = start_point.Y();
	start[2] = start_point.Z();

	if (pOrientationModifier) end_point = pOrientationModifier->Transform(transformation_matrix, location.Distance(gp_Pnt(0.0,0.0,0.0)), end_point, width );

	gp_Trsf end_rotation_matrix;
	end_rotation_matrix.SetRotation( gp_Ax1(centre_point, z_direction), m_end_angle );
	end_point.Transform(end_rotation_matrix);	// Rotate to start_angle

	end[0] = end_point.X();
	end[1] = end_point.Y();
	end[2] = end_point.Z();



	centre[0] = centre_point.X();
	centre[1] = centre_point.Y();
	centre[2] = centre_point.Z();

	gp_Pnt up_point( 0.0, 0.0, 1.0 );

	// For counter-clockwise (always in this font format)
	up[0] = up_point.X();
	up[1] = up_point.Y();
	up[2] = up_point.Z();

	HeeksObj *arc = heekscad_interface.NewArc( start, end, centre, up );
	double m[16];
	extract(transformation_matrix,m);
	arc->ModifyByMatrix(m);
	return(arc);
} // End Sketch() method
Ejemplo n.º 4
0
Python CWaterline::AppendTextToProgram(CMachineState *pMachineState)
{
	Python python;

    ReloadPointers();   // Make sure all the solids in m_solids are included as child objects.

	CTool *pTool = CTool::Find(m_tool_number);
	if(pTool == NULL)
	{
		return(python);
	}

	python << CDepthOp::AppendTextToProgram(pMachineState);

	// write the corner radius
	python << _T("corner_radius = float(");
	double cr = pTool->m_params.m_corner_radius - pTool->m_params.m_flat_radius;
	if(cr<0)cr = 0.0;
	python << ( cr / theApp.m_program->m_units ) << _T(")\n");

	heeksCAD->CreateUndoPoint();

	//write stl file
	std::list<HeeksObj*> solids;
	for (HeeksObj *object = GetFirstChild(); object != NULL; object = GetNextChild())
	{
	    if (object->GetType() != SolidType && object->GetType() != StlSolidType)
	    {
	        continue;
	    }

		if (object != NULL)
		{
			// Need to rotate a COPY of the solid by the fixture settings.
			HeeksObj* copy = object->MakeACopy();
			if (copy != NULL)
			{
				double m[16];	// A different form of the transformation matrix.
				CFixture::extract( pMachineState->Fixture().GetMatrix(CFixture::YZ), m );
                copy->ModifyByMatrix(m);

                CFixture::extract( pMachineState->Fixture().GetMatrix(CFixture::XZ), m );
                copy->ModifyByMatrix(m);

                CFixture::extract( pMachineState->Fixture().GetMatrix(CFixture::XY), m );
                copy->ModifyByMatrix(m);

                solids.push_back(copy);
            } // End if - then
        } // End if - then
	} // End for


    wxStandardPaths standard_paths;
    wxFileName filepath( standard_paths.GetTempDir().c_str(), wxString::Format(_T("waterline%d.stl"), number_for_stl_file).c_str() );
	number_for_stl_file++;

	heeksCAD->SaveSTLFile(solids, filepath.GetFullPath(), m_params.m_tolerance);

	// We don't need the duplicate solids any more.  Delete them.
	for (std::list<HeeksObj*>::iterator l_itSolid = solids.begin(); l_itSolid != solids.end(); l_itSolid++)
	{
		heeksCAD->Remove( *l_itSolid );
	} // End for
	heeksCAD->Changed();

    python << _T("ocl_funcs.waterline( filepath = ") << PythonString(filepath.GetFullPath()) << _T(", ")
            << _T("tool_diameter = ") << pTool->CuttingRadius() * 2.0 << _T(", ")
            << _T("corner_radius = ") << pTool->m_params.m_corner_radius / theApp.m_program->m_units << _T(", ")
            << _T("step_over = ") << m_params.m_step_over / theApp.m_program->m_units << _T(", ")
            << _T("mat_allowance = ") << m_params.m_material_allowance / theApp.m_program->m_units << _T(", ")
            << _T("clearance = clearance, ")
            << _T("rapid_safety_space = rapid_safety_space, ")
            << _T("start_depth = start_depth, ")
            << _T("step_down = step_down, ")
            << _T("final_depth = final_depth, ")
            << _T("units = ") << theApp.m_program->m_units << _T(", ")
            << _T("x0 = ") << m_params.m_box.m_x[0] / theApp.m_program->m_units << _T(", ")
            << _T("y0 = ") << m_params.m_box.m_x[1] / theApp.m_program->m_units << _T(", ")
            << _T("x1 = ") << m_params.m_box.m_x[3] / theApp.m_program->m_units << _T(", ")
            << _T("y1 = ") << m_params.m_box.m_x[4] / theApp.m_program->m_units << _T(", ")
            << _T("tolerance = ") << m_params.m_tolerance << _T(")\n");

	return(python);
}
Ejemplo n.º 5
0
Python CAdaptive::AppendTextToProgram(CMachineState *pMachineState )
{
	Python python;

	python << COp::AppendTextToProgram(pMachineState);

	heeksCAD->CreateUndoPoint();

	//write stl file
	std::list<HeeksObj*> solids;
	for(std::list<int>::iterator It = m_solids.begin(); It != m_solids.end(); It++)
	{
		HeeksObj* object = heeksCAD->GetIDObject(SolidType, *It);
		if (object != NULL)
		{
			// Need to rotate a COPY of the solid by the fixture settings.
			HeeksObj* copy = object->MakeACopy();
			if (copy != NULL)
			{
				double m[16];	// A different form of the transformation matrix.
				CFixture::extract( pMachineState->Fixture().GetMatrix(CFixture::YZ), m );
				copy->ModifyByMatrix(m);

				CFixture::extract( pMachineState->Fixture().GetMatrix(CFixture::XZ), m );
				copy->ModifyByMatrix(m);

				CFixture::extract( pMachineState->Fixture().GetMatrix(CFixture::XY), m );
				copy->ModifyByMatrix(m);

				solids.push_back(copy);
			} // End if - then
		} // End if - then
	} // End for

	// Reconfirm that our retractzheight value is sufficient.
	const double small_buffer = 5.0;	// Don't scrape the mountain tops.
	double max_z = CAdaptive::GetMaxHeight( SolidType, m_solids );
	if (m_params.m_retractzheight < (max_z + small_buffer))
	{
		m_params.m_retractzheight = max_z + small_buffer;
	} // End if - then

	max_z = CAdaptive::GetMaxHeight( SketchType, m_sketches );
	if (m_params.m_boundaryclear < max_z) m_params.m_boundaryclear = max_z;

    wxStandardPaths standard_paths;
    wxFileName filepath;

    filepath.Assign( standard_paths.GetTempDir().c_str(), wxString::Format(_T("adaptive%d.stl"), number_for_stl_file).c_str() );

	number_for_stl_file++;
	heeksCAD->SaveSTLFile(solids, filepath.GetFullPath());

	// We don't need the duplicate solids any more.  Delete them.
	for (std::list<HeeksObj*>::iterator l_itSolid = solids.begin(); l_itSolid != solids.end(); l_itSolid++)
	{
		heeksCAD->Remove( *l_itSolid );
	} // End for

	python << _T("rapid(z=") << m_params.m_retractzheight << _T(")\n");

	gp_Pnt start = pMachineState->Fixture().Adjustment( gp_Pnt( m_params.m_startpoint_x, m_params.m_startpoint_y, m_params.m_retractzheight ) );
	python << _T("rapid(x=") << start.X() << _T(", y=") << start.Y() << _T(")\n");

	python << _T("actp.setleadoffdz(") << m_params.m_leadoffdz << _T(")\n");

	python << _T("actp.setleadofflen(") << m_params.m_leadofflen << _T(")\n");

	python << _T("actp.setleadoffrad(") << m_params.m_leadoffrad << _T(")\n");

	python << _T("actp.setretractzheight(") << m_params.m_retractzheight << _T(")\n");

	python << _T("actp.setleadoffsamplestep(") << m_params.m_leadoffsamplestep << _T(")\n");

	if ((((COp *)this)->m_tool_number > 0) &&
	    (CTool::FindTool( ((COp *)this)->m_tool_number ) > 0) )
	{
		// We have a  tool to refer to.  Get these values from there instead.

		CTool *pTool = (CTool *) CTool::Find( ((COp *)this)->m_tool_number );
		if (pTool != NULL)
		{
			python << _T("actp.settoolcornerrad(") << pTool->m_params.m_corner_radius << _T(")\n");
			python << _T("actp.settoolflatrad(") << pTool->m_params.m_flat_radius << _T(")\n");
		} // End if - then
	} // End if - then
	else
	{
		// This object has values and/or we don't have a  tool number to refer to.
		// Use these values instead.

		python << _T("actp.settoolcornerrad(") << m_params.m_toolcornerrad << _T(")\n");
		python << _T("actp.settoolflatrad(") << m_params.m_toolflatrad << _T(")\n");
	} // End if - else

	python << _T("actp.setsamplestep(") << m_params.m_samplestep << _T(")\n");

	python << _T("actp.setstepdown(") << m_params.m_stepdown << _T(")\n");

	python << _T("actp.setclearcuspheight(") << m_params.m_clearcuspheight << _T(")\n");

	python << _T("actp.settriangleweaveres(") << m_params.m_triangleweaveres << _T(")\n");

	python << _T("actp.setflatradweaveres(") << m_params.m_flatradweaveres << _T(")\n");

	python << _T("actp.setdchangright(") << m_params.m_dchangright << _T(")\n");

	python << _T("actp.setdchangrightoncontour(") << m_params.m_dchangrightoncontour << _T(")\n");

	python << _T("actp.setdchangleft(") << m_params.m_dchangleft << _T(")\n");

	python << _T("actp.setdchangefreespace(") << m_params.m_dchangefreespace << _T(")\n");

	python << _T("actp.setsidecutdisplch(") << m_params.m_sidecutdisplch << _T(")\n");

	python << _T("actp.setfcut(") << m_params.m_fcut << _T(")\n");

	python << _T("actp.setfretract(") << m_params.m_fretract << _T(")\n");

	python << _T("actp.setthintol(") << m_params.m_thintol << _T(")\n");

	python << _T("actp.setstartpoint(") << start.X() << _T(", ") << start.Y() << _T(", ") << m_params.m_startvel_x << _T(", ") << m_params.m_startvel_y << _T(")\n");

	python << _T("actp.setminz(") << m_params.m_minz << _T(")\n");

	python << _T("actp.boundaryclear(") << m_params.m_boundaryclear << _T(")\n");

	if(!m_sketches.empty())
	{
		std::list<HeeksObj*> sketches;
		for(std::list<int>::iterator It = m_sketches.begin(); It != m_sketches.end(); It++)
		{
			HeeksObj* sketch = heeksCAD->GetIDObject(SketchType, *It);
			if(sketch){
				for(HeeksObj* span_object = sketch->GetFirstChild(); span_object; span_object = sketch->GetNextChild())
				{
					double s[3] = {0, 0, 0};
					double e[3] = {0, 0, 0};
					if(span_object){
						int type = span_object->GetType();
						//TODO: add support for arcs
						if(type == LineType)
						{
							span_object->GetStartPoint(s);
							pMachineState->Fixture().Adjustment(s);

							span_object->GetEndPoint(e);
							pMachineState->Fixture().Adjustment(e);

							python << _T("actp.boundaryadd(") << s[0] << _T(", ") << s[1] << _T(")\n");
							python << _T("actp.boundaryadd(") << e[0] << _T(", ") << e[1] << _T(")\n");
						}
					}
				}
			}
			python << _T("actp.boundarybreak()\n");
		}
	}
	else
	{
		gp_Pnt boundary[2];
		boundary[0] = pMachineState->Fixture().Adjustment( gp_Pnt( m_params.m_boundary_x0, m_params.m_boundary_y0, 0.0 ) );
		boundary[1] = pMachineState->Fixture().Adjustment( gp_Pnt( m_params.m_boundary_x1, m_params.m_boundary_y1, 0.0 ) );

		python << _T("actp.boundaryadd(") << boundary[0].X() << _T(", ") << boundary[0].Y() << _T(")\n");

		python << _T("actp.boundaryadd(") << boundary[0].X() << _T(", ") << boundary[1].Y() << _T(")\n");

		python << _T("actp.boundaryadd(") << boundary[1].X() << _T(", ") << boundary[1].Y() << _T(")\n");

		python << _T("actp.boundaryadd(") << boundary[1].X() << _T(", ") << boundary[0].Y() << _T(")\n");

		python << _T("actp.boundarybreak()\n");

	}

	python << _T("actp_funcs.cut(") << PythonString(filepath.GetFullPath()) << _T(")\n");

	python << _T("rapid(z=") << m_params.m_retractzheight << _T(")\n");

	return(python);
}