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


C++ HeeksObj::GetType方法代码示例

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


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

示例1: perfectly_aligned_fixture

/**
 * 	This method looks through the symbols in the list.  If they're PointType objects
 * 	then the object's location is added to the result set.  If it's a circle object
 * 	that doesn't intersect any other element (selected) then add its centre to
 * 	the result set.  Finally, find the intersections of all of these elements and
 * 	add the intersection points to the result vector.
 */
/* static */ std::vector<CNCPoint> CDrilling::FindAllLocations(
                    ObjList *parent,
                    const CNCPoint starting_location, // = CNCPoint(0.0, 0.0, 0.0)
                    const bool sort_locations, // = false
                    std::list<int> *pToolNumbersReferenced /* = NULL */ )
{
	std::vector<CNCPoint> locations;
	parent->ReloadPointers();   // Make sure our integer lists have been converted into children first.

	// Look to find all intersections between all selected objects.  At all these locations, create
	// a drilling cycle.

	std::list<HeeksObj *> lhs_children;
	std::list<HeeksObj *> rhs_children;
	for (HeeksObj *lhsPtr = parent->GetFirstChild(); lhsPtr != NULL; lhsPtr = parent->GetNextChild())
	{
	    lhs_children.push_back( lhsPtr );
	    rhs_children.push_back( lhsPtr );
	}

	for (std::list<HeeksObj *>::iterator itLhs = lhs_children.begin(); itLhs != lhs_children.end(); itLhs++)
	{
	    HeeksObj *lhsPtr = *itLhs;
		bool l_bIntersectionsFound = false;	// If it's a circle and it doesn't
							// intersect anything else, we want to know
							// about it.

		if (lhsPtr->GetType() == PointType)
		{
			double pos[3];
			lhsPtr->GetStartPoint(pos);

			// Copy the results in ONLY if each point doesn't already exist.
			if (std::find( locations.begin(), locations.end(), CNCPoint( pos ) ) == locations.end())
			{
				locations.push_back( CNCPoint( pos ) );
			} // End if - then

			continue;	// No need to intersect a point with anything.
		} // End if - then

        for (std::list<HeeksObj *>::iterator itRhs = rhs_children.begin(); itRhs != rhs_children.end(); itRhs++)
        {
            HeeksObj *rhsPtr = *itRhs;

			if (lhsPtr == rhsPtr) continue;
			if (lhsPtr->GetType() == PointType) continue;	// No need to intersect a point type.

            std::list<double> results;

            if ((lhsPtr != NULL) && (rhsPtr != NULL) && (lhsPtr->Intersects( rhsPtr, &results )))
            {
				l_bIntersectionsFound = true;
                while (((results.size() % 3) == 0) && (results.size() > 0))
                {
                    CNCPoint intersection;

                    intersection.SetX( *(results.begin()) );
                    results.erase(results.begin());

                    intersection.SetY( *(results.begin()) );
                    results.erase(results.begin());

                    intersection.SetZ( *(results.begin()) );
                    results.erase(results.begin());

					// Copy the results in ONLY if each point doesn't already exist.
					if (std::find( locations.begin(), locations.end(), intersection ) == locations.end())
					{
						locations.push_back(intersection);
					} // End if - then
				} // End while
			} // End if - then
		} // End for

		if (! l_bIntersectionsFound)
		{
			// This element didn't intersect anything else.  If it's a circle
			// then add its centre point to the result set.

			if (lhsPtr->GetType() == CircleType)
			{
				double pos[3];
				if ((lhsPtr != NULL) && (heeksCAD->GetArcCentre( lhsPtr, pos )))
				{
					// Copy the results in ONLY if each point doesn't already exist.
					if (std::find( locations.begin(), locations.end(), CNCPoint( pos ) ) == locations.end())
					{
						locations.push_back( CNCPoint( pos ) );
					} // End if - then
				} // End if - then
			} // End if - then

//.........这里部分代码省略.........
开发者ID:JonasThomas,项目名称:heekscnc,代码行数:101,代码来源:Drilling.cpp

示例2: DesignRulesAdjustment

/**
	This method adjusts any parameters that don't make sense.  It should report a list
	of changes in the list of strings.
 */
std::list<wxString> CDrilling::DesignRulesAdjustment(const bool apply_changes)
{
	std::list<wxString> changes;

	// Make some special checks if we're using a chamfering bit.
	if (m_tool_number > 0)
	{
		CTool *pChamfer = (CTool *) CTool::Find( m_tool_number );
		if (pChamfer != NULL)
		{
			std::vector<CNCPoint> these_locations = CDrilling::FindAllLocations(this);

			if (pChamfer->m_params.m_type == CToolParams::eChamfer)
			{
				// We need to make sure that the diameter of the hole (that will
				// have been drilled in a previous drilling operation) is between
				// the chamfering bit's flat_radius (smallest) and diamter/2 (largest).

				// First find ALL drilling cycles that created this hole.  Make sure
				// to get them all as we may have used a centre drill before the
				// main hole is drilled.

				for (HeeksObj *obj = theApp.m_program->Operations()->GetFirstChild();
					obj != NULL;
					obj = theApp.m_program->Operations()->GetNextChild())
				{
					if (obj->GetType() == DrillingType)
					{
						// Make sure we're looking at a hole drilled with something
						// more than a centre drill.
						CToolParams::eToolType type = CTool::CutterType( ((COp *)obj)->m_tool_number );
						if (	(type == CToolParams::eDrill) ||
							(type == CToolParams::eEndmill) ||
							(type == CToolParams::eSlotCutter) ||
							(type == CToolParams::eBallEndMill))
						{
							// See if any of the other drilling locations line up
							// with our drilling locations.  If so, we must be
							// chamfering a previously drilled hole.

							std::vector<CNCPoint> previous_locations = CDrilling::FindAllLocations((CDrilling *)obj);
							std::vector<CNCPoint> common_locations;
							std::set_intersection( previous_locations.begin(), previous_locations.end(),
										these_locations.begin(), these_locations.end(),
										std::inserter( common_locations, common_locations.begin() ));
							if (common_locations.size() > 0)
							{
								// We're here.  We must be chamfering a hole we've
								// drilled previously.  Check the diameters.

								CTool *pPreviousTool = CTool::Find( ((COp *)obj)->m_tool_number );
								if (pPreviousTool->CuttingRadius() < pChamfer->m_params.m_flat_radius)
								{
#ifdef UNICODE
									std::wostringstream l_ossChange;
#else
									std::ostringstream l_ossChange;
#endif
									l_ossChange << _("Chamfering bit for drilling op") << " (id=" << m_id << ") " << _("is too big for previously drilled hole") << " (drilling id=" << obj->m_id << ")\n";
									changes.push_back( l_ossChange.str().c_str() );
								} // End if - then

								if (pPreviousTool->CuttingRadius() > (pChamfer->m_params.m_diameter/2.0))
								{
#ifdef UNICODE
									std::wostringstream l_ossChange;
#else
									std::ostringstream l_ossChange;
#endif
									l_ossChange << _("Chamfering bit for drilling op") << " (id=" << m_id << ") " << _("is too small for previously drilled hole") << " (drilling id=" << obj->m_id << ")\n";
									changes.push_back( l_ossChange.str().c_str() );
								} // End if - then
							} // End if - then

						} // End if - then
					} // End if - then
				} // End for
			} // End if - then
		} // End if - then
	} // End if - then

	if (m_tool_number > 0)
	{
		// Make sure the hole depth isn't greater than the tool's cutting depth.
		CTool *pDrill = (CTool *) CTool::Find( m_tool_number );
		if ((pDrill != NULL) && (pDrill->m_params.m_cutting_edge_height < m_params.m_depth))
		{
			// The drill bit we've chosen can't cut as deep as we've setup to go.

			if (apply_changes)
			{
#ifdef UNICODE
				std::wostringstream l_ossChange;
#else
				std::ostringstream l_ossChange;
#endif
//.........这里部分代码省略.........
开发者ID:JonasThomas,项目名称:heekscnc,代码行数:101,代码来源:Drilling.cpp

示例3: GetProperties

void CProfileParams::GetProperties(CProfile* parent, std::list<Property *> *list)
{
	CToolParams::eToolType tool_type = CTool::FindToolType(parent->m_tool_number);

	if(CTool::IsMillingToolType(tool_type)){
		std::list< wxString > choices;

		SketchOrderType order = SketchOrderTypeUnknown;

		if(parent->GetNumSketches() == 1)
		{
#ifdef OP_SKETCHES_AS_CHILDREN
			HeeksObj* sketch = parent->GetFirstChild();
#else
			HeeksObj* sketch = heeksCAD->GetIDObject(SketchType, parent->m_sketches.front());
#endif
			if((sketch) && (sketch->GetType() == SketchType))
			{
				order = heeksCAD->GetSketchOrder(sketch);
			}
		}

		switch(order)
		{
		case SketchOrderTypeOpen:
			choices.push_back(_("Left"));
			choices.push_back(_("Right"));
			break;

		case SketchOrderTypeCloseCW:
		case SketchOrderTypeCloseCCW:
			choices.push_back(_("Outside"));
			choices.push_back(_("Inside"));
			break;

		default:
			choices.push_back(_("Outside or Left"));
			choices.push_back(_("Inside or Right"));
			break;
		}
		choices.push_back(_("On"));

		int choice = int(eOn);
		switch (m_tool_on_side)
		{
			case eRightOrInside:	choice = 1;
					break;

			case eOn:	choice = 2;
					break;

			case eLeftOrOutside:	choice = 0;
					break;
		} // End switch

		list->push_back(new PropertyChoice(_("tool on side"), choices, choice, parent, on_set_tool_on_side));
	}

	if(CTool::IsMillingToolType(tool_type)){
		std::list< wxString > choices;
		choices.push_back(_("Conventional"));
		choices.push_back(_("Climb"));
		list->push_back(new PropertyChoice(_("cut mode"), choices, m_cut_mode, parent, on_set_cut_mode));
	}

	if(parent->GetNumSketches() == 1) // multiple sketches must use auto roll on, and can not have start and end points specified
	{
		list->push_back(new PropertyCheck(_("auto roll on"), m_auto_roll_on, parent, on_set_auto_roll_on));
		if(!m_auto_roll_on)list->push_back(new PropertyVertex(_("roll on point"), m_roll_on_point, parent, on_set_roll_on_point));
		list->push_back(new PropertyCheck(_("auto roll off"), m_auto_roll_off, parent, on_set_auto_roll_off));
		if(!m_auto_roll_off)list->push_back(new PropertyVertex(_("roll off point"), m_roll_off_point, parent, on_set_roll_off_point));
		if(m_auto_roll_on || m_auto_roll_off)list->push_back(new PropertyLength(_("roll radius"), m_auto_roll_radius, parent, on_set_roll_radius));
		list->push_back(new PropertyCheck(_("use start point"), m_start_given, parent, on_set_start_given));
		if(m_start_given)list->push_back(new PropertyVertex(_("start point"), m_start, parent, on_set_start));
		list->push_back(new PropertyCheck(_("use end point"), m_end_given, parent, on_set_end_given));
		if(m_end_given)
		{
			list->push_back(new PropertyVertex(_("end point"), m_end, parent, on_set_end));
			list->push_back(new PropertyCheck(_("end beyond full profile"), m_end_beyond_full_profile, parent, on_set_end_beyond_full_profile));
		}
	}
	else
	{
		std::list< wxString > choices;

		choices.push_back(_("Respect existing order"));	// Must be 'false' (0)
		choices.push_back(_("True"));			// Must be 'true' (non-zero)

		int choice = int(m_sort_sketches);
		list->push_back(new PropertyChoice(_("sort_sketches"), choices, choice, parent, on_set_sort_sketches));

		// roll on radius
		list->push_back(new PropertyLength(_("roll radius"), m_auto_roll_radius, parent, on_set_roll_radius));
	} // End if - else
    
    list->push_back(new PropertyLength(_("extend before start"), m_extend_at_start, parent, on_set_extend_at_start));
    list->push_back(new PropertyLength(_("extend past end"), m_extend_at_end, parent, on_set_extend_at_end));

    //lead in lead out line length
    list->push_back(new PropertyLength(_("lead in line length"), m_lead_in_line_len, parent, on_set_lead_in_line_len));
//.........这里部分代码省略.........
开发者ID:DesignerMK,项目名称:heekscnc,代码行数:101,代码来源:Profile.cpp

示例4: Run

void SaveSolids::Run(){
	std::list<HeeksObj*> objects;

	for(std::list<HeeksObj*>::const_iterator It = wxGetApp().m_marked_list->list().begin(); It != wxGetApp().m_marked_list->list().end(); It++){
		HeeksObj* object = *It;
		switch(object->GetType())
		{
		case SolidType:
		case StlSolidType:
		case FaceType:
		{
				objects.push_back(object);
			}
			break;
		}
	}

	if(objects.size() > 0)
	{
		wxString filepath(_T(""));
		{
			// get last used filepath
			HeeksConfig config;
			config.Read(_T("SolidExportFilepath"), &filepath, _T(""));
		}

		wxFileDialog fd(wxGetApp().m_frame, _("Save solid file"), wxEmptyString, filepath, wxString(_("Solid Files")) + _T(" |*.igs;*.iges;*.stp;*.step;*.stl;*.cpp;*.py;*.obj|") + _("IGES files") + _T(" (*.igs *.iges)|*.igs;*.iges|") + _("STEP files") + _T(" (*.stp *.step)|*.stp;*.step|") + _("STL files") + _T(" (*.stl)|*.stl|") + _("CPP files") + _T(" (*.cpp)|*.cpp|") + _("OpenCAMLib python files") + _T(" (*.py)|*.py|") + _("Wavefront .obj files") + _T(" (*.obj)|*.obj"), wxFD_SAVE | wxFD_OVERWRITE_PROMPT);
		fd.SetFilterIndex(0);

		if (fd.ShowModal() == wxID_CANCEL)return;
		filepath = fd.GetPath();

		wxString wf(filepath);
		wf.LowerCase();

		if(wf.EndsWith(_T(".stl")))
		{
			wxGetApp().SaveSTLFile(objects, filepath, -1.0, NULL, wxGetApp().m_stl_save_as_binary);
		}
		else if(wf.EndsWith(_T(".cpp")))
		{
			wxGetApp().SaveCPPFile(objects, filepath);
		}
		else if (wf.EndsWith(_T(".py")))
		{
			wxGetApp().SavePyFile(objects, filepath);
		}
		else if (wf.EndsWith(_T(".obj")))
		{
			wxGetApp().SaveOBJFileAscii(objects, filepath);
		}
		else if (CShape::ExportSolidsFile(objects, filepath))
		{
		}
		else
		{
			wxMessageBox(_("Invalid solid file type chosen"));
			return;
		}

		{
			// save last used filepath
			HeeksConfig config;
			config.Write(_T("SolidExportFilepath"), filepath);
		}
	}
}
开发者ID:play113,项目名称:swer,代码行数:67,代码来源:SolidTools.cpp

示例5: CalculateSketchOrder

void CSketch::CalculateSketchOrder()
{
	if(m_objects.size() == 0)
	{
		m_order = SketchOrderTypeEmpty;
		return;
	}

	HeeksObj* prev_object = NULL;
	HeeksObj* first_object = NULL;

	bool well_ordered = true;

	std::list<HeeksObj*>::iterator It;
	for(It=m_objects.begin(); It!=m_objects.end() ;It++)
	{
		HeeksObj* object = *It;

		if(object->GetType() == CircleType)
		{
			m_order = SketchOrderHasCircles;
			return;
		}

		if(prev_object)
		{
			double prev_e[3], s[3];
			if(!prev_object->GetEndPoint(prev_e)){well_ordered = false; break;}
			if(!object->GetStartPoint(s)){well_ordered = false; break;}
			if(!(make_point(prev_e).IsEqual(make_point(s), wxGetApp().m_geom_tol))){well_ordered = false; break;}
		}

		if(first_object == NULL)first_object = object;
		prev_object = object;
	}

	if(well_ordered)
	{
		if(prev_object && first_object)
		{
			double e[3], s[3];
			if(prev_object->GetEndPoint(e))
			{
				if(first_object->GetStartPoint(s))
				{
					if(make_point(e).IsEqual(make_point(s), wxGetApp().m_geom_tol))
					{
						// closed
						if(IsClockwise())m_order = SketchOrderTypeCloseCW;
						else m_order = SketchOrderTypeCloseCCW;
						return;
					}
				}
			}
		}

		m_order = SketchOrderTypeOpen;
		return;
	}

	m_order = SketchOrderTypeBad; // although it might still be multiple, but will have to wait until ReOrderSketch is done.
}
开发者ID:CarlosGS,项目名称:heekscad,代码行数:62,代码来源:Sketch.cpp

示例6: Mirror

//static
void TransformTools::Mirror(bool copy)
{
	// pick items
	if(wxGetApp().m_marked_list->size() == 0){
		wxGetApp().PickObjects(_("Pick objects to mirror"));
	}
	if(wxGetApp().m_marked_list->size() == 0)return;

	if(copy)
	{
		// check for uncopyable objects
		RemoveUncopyable();
		if(wxGetApp().m_marked_list->size() == 0)return;
	}

	// clear the selection
	std::list<HeeksObj *> selected_items = wxGetApp().m_marked_list->list();
	wxGetApp().m_marked_list->Clear(true);

	// pick a line to mirror about
	bool line_found = false;
	gp_Lin line;
	int save_filter = wxGetApp().m_marked_list->m_filter;
	wxGetApp().PickObjects(_("Pick line to mirror about"), MARKING_FILTER_LINE | MARKING_FILTER_ILINE, true);
	wxGetApp().m_marked_list->m_filter = save_filter;
	for(std::list<HeeksObj *>::const_iterator It = wxGetApp().m_marked_list->list().begin(); It != wxGetApp().m_marked_list->list().end(); It++)
	{
		HeeksObj* object = *It;
		if(object->GetType() == LineType)
		{
			line = ((HLine*)object)->GetLine();
			line_found = true;
		}
		else if(object->GetType() == ILineType)
		{
			line = ((HILine*)object)->GetLine();
			line_found = true;
		}
	}
	if(!line_found)return;

	// transform the objects
	wxGetApp().CreateUndoPoint();
	gp_Trsf mat;
	mat.SetMirror(gp_Ax1(line.Location(), line.Direction()));
	double m[16];
	extract(mat, m);

	if(copy)
	{
		for(std::list<HeeksObj*>::iterator It = selected_items.begin(); It != selected_items.end(); It++)
		{
			HeeksObj* object = *It;
			HeeksObj* new_object = object->MakeACopy();
#ifdef MULTIPLE_OWNERS
			object->HEEKSOBJ_OWNER->Add(new_object, NULL);
#else
			object->m_owner->Add(new_object, NULL);
#endif
			new_object->ModifyByMatrix(m);
		}
		wxGetApp().m_marked_list->Clear(true);
	}
	else
	{
		wxGetApp().Transform(selected_items, m);
	}
	wxGetApp().Changed();
}
开发者ID:CarlosGS,项目名称:heekscad,代码行数:70,代码来源:TransformTools.cpp

示例7: DesignRulesPreamble

/**
	This method adjusts any parameters that don't make sense.  It should report a list
	of changes in the list of strings.
 */
std::list<wxString> CChamfer::DesignRulesAdjustment(const bool apply_changes)
{
	std::list<wxString> changes;

	// Make some special checks if we're using a chamfering bit.
	if (m_tool_number > 0)
	{
		CTool *pChamfer = (CTool *) CTool::Find( m_tool_number );
		if (pChamfer != NULL)
		{
			std::vector<CNCPoint> these_locations = CDrilling::FindAllLocations(this);

			if (pChamfer->m_params.m_type == CToolParams::eChamfer)
			{
				// We need to make sure that the diameter of the hole (that will
				// have been drilled in a previous drilling operation) is between
				// the chamfering bit's flat_radius (smallest) and diamter/2 (largest).

				// First find ALL drilling cycles that created this hole.  Make sure
				// to get them all as we may have used a centre drill before the
				// main hole is drilled.

				for (HeeksObj *obj = theApp.m_program->Operations()->GetFirstChild();
					obj != NULL;
					obj = theApp.m_program->Operations()->GetNextChild())
				{
					if (obj->GetType() == DrillingType)
					{
						// Make sure we're looking at a hole drilled with something
						// more than a centre drill.
						CToolParams::eToolType type = CTool::CutterType( ((COp *)obj)->m_tool_number );
						if (	(type == CToolParams::eDrill) ||
							(type == CToolParams::eEndmill) ||
							(type == CToolParams::eSlotCutter) ||
							(type == CToolParams::eBallEndMill))
						{
							// See if any of the other drilling locations line up
							// with our drilling locations.  If so, we must be
							// chamfering a previously drilled hole.

							std::vector<CNCPoint> previous_locations = CDrilling::FindAllLocations((CDrilling *)obj);
							std::vector<CNCPoint> common_locations;
							std::set_intersection( previous_locations.begin(), previous_locations.end(),
										these_locations.begin(), these_locations.end(),
										std::inserter( common_locations, common_locations.begin() ));
							if (common_locations.size() > 0)
							{
								// We're here.  We must be chamfering a hole we've
								// drilled previously.  Check the diameters.

								CTool *pPreviousTool = CTool::Find( ((COp *)obj)->m_tool_number );
								if (pPreviousTool->CuttingRadius() < pChamfer->m_params.m_flat_radius)
								{
									wxString change;
									change << DesignRulesPreamble() << _("Chamfering bit for drilling op") << _(" (id=") << m_id << _T(") ") << _("is too big for previously drilled hole") ;
									changes.push_back( change );
								} // End if - then

								if (pPreviousTool->CuttingRadius() > (pChamfer->m_params.m_diameter/2.0))
								{
									wxString change;
									change << DesignRulesPreamble() << _("Chamfering bit for drilling op") << _(" (id=") << m_id << _T(") ") << _("is too small for previously drilled hole");
									changes.push_back( change );
								} // End if - then
							} // End if - then

						} // End if - then
					} // End if - then
				} // End for
			} // End if - then
			else
			{
				wxString change;
				change << DesignRulesPreamble() << _("found with ") << pChamfer->m_params.m_type;
				changes.push_back(change);
			}
		} // End if - then
	} // End if - then

	std::list<wxString> extra_changes = CDepthOp::DesignRulesAdjustment(apply_changes);
	std::copy( extra_changes.begin(), extra_changes.end(), std::inserter( changes, changes.end() ));

	return(changes);

} // End DesignRulesAdjustment() method
开发者ID:DavidNicholls,项目名称:heekscnc,代码行数:89,代码来源:Chamfer.cpp

示例8: SimplifySketch

static void SimplifySketch(const double deviation, bool make_bspline )
{

    wxGetApp().CreateUndoPoint();

    double original_tolerance = wxGetApp().m_geom_tol;
    wxGetApp().m_geom_tol = sketch_tool_options.m_cleanup_tolerance;

    std::list<HeeksObj *> selected_sketches;
    std::copy( wxGetApp().m_marked_list->list().begin(), wxGetApp().m_marked_list->list().end(),
                std::inserter( selected_sketches, selected_sketches.begin() ));

	std::list<HeeksObj*>::const_iterator It;
	for(It = selected_sketches.begin(); It != selected_sketches.end(); It++){
		HeeksObj* object = *It;
		std::list<HeeksObj *> new_objects;

		if (object->GetType() == SketchType)
		{
			std::list<TopoDS_Shape> wires;
			try {
				heekscad_interface.ConvertSketchToFaceOrWire(object, wires, false);
			} // End try
			catch(...)
			{
				continue;
			}
			for (std::list<TopoDS_Shape>::iterator itWire = wires.begin(); itWire != wires.end(); itWire++)
			{
				std::list<SimplifySketchTool::SortPoint> points = SimplifySketchTool::GetPoints( TopoDS::Wire(*itWire), deviation );

				if (sketch_tool_options.m_sort_points)
				{
					// The sort points option is turned on.  The idea of this is to detect shapes that include
					// sections that 'double back' on themselves.  The first example being a shape made up of
					// a box as well as a single line that layed along one edge of the box.  In this case the extra
					// line was superfluous.  If we sort the points so that each point is closest to the previous
					// point then, hopefully, we will reorder these shapes that double back on themselves.  If this
					// doesn't work then the user can always turn the 'sort points' option off and try again.

					std::vector<SimplifySketchTool::SortPoint> sorted_points;
					std::copy( points.begin(), points.end(), std::inserter( sorted_points, sorted_points.begin() ));

					for (std::vector<SimplifySketchTool::SortPoint>::iterator l_itPoint = sorted_points.begin(); l_itPoint != sorted_points.end(); l_itPoint++)
					{
						// We've already begun.  Just sort based on the previous point's location.
						std::vector<SimplifySketchTool::SortPoint>::iterator l_itNextPoint = l_itPoint;
						l_itNextPoint++;

						if (l_itNextPoint != sorted_points.end())
						{
							SimplifySketchTool::sort_points_by_distance compare( *l_itPoint );
							std::sort( l_itNextPoint, sorted_points.end(), compare );
						} // End if - then
					} // End for

					points.clear();
					std::copy( sorted_points.begin(), sorted_points.end(), std::inserter( points, points.begin() ));

					// This sorting process will have resulted in the start and end points being located next to each other
					// and hence removed.  If the original wire was periodic (closed shape) then make sure the last point
					// is the same as the first point.

					TopoDS_Wire wire(TopoDS::Wire(*itWire));
					if (wire.Closed())
					{
						if (*(points.begin()) != *(points.rbegin()))
						{
							points.push_back(*points.begin());	// Close the shape manually.
						}
					}
				}

				// Whether we sorted or not, we may want to close the shape.
				if (sketch_tool_options.m_force_closed_shape)
				{
					if (*(points.begin()) != *(points.rbegin()))
					{
						points.push_back(*points.begin());	// Close the shape manually.
					}
				}

				// Now keep removing points from this list as long as the midpoints are within deviation of
				// the line between the two neighbour points.
				bool points_removed = false;
				do {
					points_removed = false;

					for (std::list<SimplifySketchTool::SortPoint>::iterator itPoint = points.begin(); itPoint != points.end(); itPoint++ )
					{
						std::list<SimplifySketchTool::SortPoint>::iterator itP1 = itPoint;
						std::list<SimplifySketchTool::SortPoint>::iterator itP2 = itPoint;
						std::list<SimplifySketchTool::SortPoint>::iterator itP3 = itPoint;

						itP2++;
						if (itP2 != points.end())
						{
							itP3 = itP2;
							itP3++;

//.........这里部分代码省略.........
开发者ID:CarlosGS,项目名称:heekscad,代码行数:101,代码来源:SketchTools.cpp

示例9: AppendTextToProgram

Python CChamfer::AppendTextToProgram(CMachineState *pMachineState)
{
	Python python;

	// Look at the child operations objects and generate a toolpath as appropriate.
	python << CDepthOp::AppendTextToProgram( pMachineState );

	// Whatever underlying sharp edges we're going to cleanup, we need to know how deep
	// we need to plunge the chamfering bit into the work before we can get the chamfering
	// width required.
	// NOTE: At this stage, we won't allow multiple passes to produce an overly wide
	// chamfer.  i.e. if the chamfering width is longer than the chamfering bit's cutting
	// edge length then we're out of business.

	CTool *pChamferingBit = CTool::Find( m_tool_number );
	if (pChamferingBit == NULL)
	{
		// No socks, no shirt, no service.
		return(python);
	} // End if - then

	if (pChamferingBit->m_params.m_type != CToolParams::eChamfer)
	{
		// We need to make the various radius and angle calculations based on the
		// assumption that it's a chamfering bit.  If not, we can't handle the
		// mathematics (at least I can't).

		wxMessageBox(_T("Only chamfering bits are supported for chamfer operations"));
		return(python);
	}

	if (m_params.m_chamfer_width > pChamferingBit->m_params.m_cutting_edge_height)
	{
		// We don't support multiple passes to chamfer the edge (yet).  Just don't try.
		wxString text;
		text << _("Chamfer width ") << m_params.m_chamfer_width / theApp.m_program->m_units
			<< _(" is too large for a single pass of the chamfering bit's edge (")
			<< pChamferingBit->m_params.m_cutting_edge_height / theApp.m_program->m_units
			<< _(")");
		wxMessageBox(text);
		return(python);
	}

	// How deep do we have to plunge in order to cut this width of chamfer?
	double theta = pChamferingBit->m_params.m_cutting_edge_angle / 360.0 * 2.0 * PI;	// in radians.




	for (HeeksObj *child = GetFirstChild(); child != NULL; child = GetNextChild())
	{
		switch (child->GetType())
		{
        case DrillingType:
		case CounterBoreType:
			python << AppendTextForCircularChildren(pMachineState, theta, child, pChamferingBit);
			break;

		case ProfileType:
		case ContourType:
		case PocketType:
		case SketchType:
			python << AppendTextForProfileChildren(pMachineState, theta, child, pChamferingBit);
			break;

		default:
			break;
		} // End switch
	} // End for

	return(python);
}
开发者ID:DavidNicholls,项目名称:heekscnc,代码行数:72,代码来源:Chamfer.cpp

示例10: GetProperties

void CChamferParams::GetProperties(CChamfer * parent, std::list<Property *> *list)
{
	list->push_back(new PropertyLength(_("Chamfer Width"), m_chamfer_width, parent, on_set_chamfer_width));

	{
        std::list< wxString > choices;

        SketchOrderType order = SketchOrderTypeUnknown;

        if(parent->GetNumChildren() > 0)
        {
            HeeksObj* sketch = NULL;

            for (HeeksObj *object = parent->GetFirstChild(); ((sketch == NULL) && (object != NULL)); object = parent->GetNextChild())
            {
                if (object->GetType() == SketchType)
                {
                    sketch = object;
                }
            }

            if(sketch != NULL)
            {
                order = heeksCAD->GetSketchOrder(sketch);
                switch(order)
                {
                case SketchOrderTypeOpen:
                    choices.push_back(_("Left"));
                    choices.push_back(_("Right"));
                    break;

                case SketchOrderTypeCloseCW:
                case SketchOrderTypeCloseCCW:
                    choices.push_back(_("Outside"));
                    choices.push_back(_("Inside"));
                    break;

                default:
                    choices.push_back(_("Outside or Left"));
                    choices.push_back(_("Inside or Right"));
                    break;
                }

				choices.push_back(_("On"));

				int choice = int(CChamferParams::eOn);
				switch (parent->m_params.m_tool_on_side)
				{
					case CChamferParams::eRightOrInside:	choice = 1;
							break;

					case CChamferParams::eOn:	choice = 2;
							break;

					case CChamferParams::eLeftOrOutside:	choice = 0;
							break;
				} // End switch

				list->push_back(new PropertyChoice(_("tool on side"), choices, choice, parent, on_set_tool_on_side));
            }
        }
    }
}
开发者ID:DavidNicholls,项目名称:heekscnc,代码行数:63,代码来源:Chamfer.cpp

示例11: AppendTextForProfileChildren

/**
	We can see what diameter tool was used to create the pocket or contour child operation.  We assume
	that this has already occured.  We want to fit down into the slot cut by these operations as far
	as possible but only touching the appropriate side of the material (inside or outside).
	We also need to make sure we don't go too deep.  If the chamfering bit is small while the endmill
	used to cut the profile or contour was large then we may need to limit the depth of cut.
 */
Python CChamfer::AppendTextForProfileChildren(
	CMachineState *pMachineState,
	const double theta,
	HeeksObj *child,
	CTool *pChamferingBit )
{
	Python python;

	unsigned int number_of_bad_sketches = 0;
	double tolerance = heeksCAD->GetTolerance();

	double start_depth = 0.0;
	double final_depth = 0.0;
	double clearance_height = 0.0;
	double rapid_safety_space = 0.0;
	std::list<HeeksObj *> sketches;

	CDepthOp *pDepthOp = dynamic_cast<CDepthOp *>(child);
	if (pDepthOp == NULL)
	{
		start_depth = m_depth_op_params.m_start_depth;
		final_depth = m_depth_op_params.m_final_depth;
		clearance_height = m_depth_op_params.ClearanceHeight();
		rapid_safety_space = m_depth_op_params.m_rapid_safety_space;

		if (child->GetType() == SketchType)
		{
			sketches.push_back(child);
		}
	}
	else
	{
		start_depth = pDepthOp->m_depth_op_params.m_start_depth;
		final_depth = pDepthOp->m_depth_op_params.m_final_depth;
		clearance_height = pDepthOp->m_depth_op_params.ClearanceHeight();
		rapid_safety_space = pDepthOp->m_depth_op_params.m_rapid_safety_space;

		for (HeeksObj *object = child->GetFirstChild(); object != NULL; object = child->GetNextChild())
		{
			if (object->GetType() == SketchType)
			{
				sketches.push_back(object);
			}
		}
	}

	for (std::list<HeeksObj *>::iterator itChild = sketches.begin(); itChild != sketches.end(); itChild++)
    {
		HeeksObj *object = *itChild;

        std::list<TopoDS_Shape> wires;
        if (! heeksCAD->ConvertSketchToFaceOrWire( object, wires, false))
        {
            number_of_bad_sketches++;
        } // End if - then
        else
        {
            // The wire(s) represent the sketch objects for a tool path.
            if (object->GetShortString() != NULL)
            {
				wxString comment;
				comment << _T("Chamfering of ") << object->GetShortString();
                python << _T("comment(") << PythonString(comment).c_str() << _T(")\n");
            }

            try {
                for(std::list<TopoDS_Shape>::iterator It2 = wires.begin(); It2 != wires.end(); It2++)
                {
                    TopoDS_Shape& wire_to_fix = *It2;
                    ShapeFix_Wire fix;
                    fix.Load( TopoDS::Wire(wire_to_fix) );
                    fix.FixReorder();

                    TopoDS_Shape wire = fix.Wire();

                    wire = pMachineState->Fixture().Adjustment(wire);

                    BRepOffsetAPI_MakeOffset offset_wire(TopoDS::Wire(wire));

                    // Now generate a toolpath along this wire.
                    std::list<double> depths = GetProfileChamferingDepths(child);

                    for (std::list<double>::iterator itDepth = depths.begin(); itDepth != depths.end(); itDepth++)
                    {
                        double radius = pChamferingBit->CuttingRadius(false,fabs(*itDepth - start_depth));

						// We know what offset we'd really like.  See how far we can offset the shape before we start
                        // getting cross-over of graphics.
                        double max_offset = CInlay::FindMaxOffset( radius, TopoDS::Wire(wire), radius / 10.0 );

						if (radius > max_offset) radius = max_offset;

						// Now move the tool slightly less than this offset so that the chamfering width is
//.........这里部分代码省略.........
开发者ID:DavidNicholls,项目名称:heekscnc,代码行数:101,代码来源:Chamfer.cpp

示例12: AppendTextToProgram

Python CProfile::AppendTextToProgram(CMachineState *pMachineState, bool finishing_pass)
{
	Python python;

	CTool *pTool = CTool::Find( m_tool_number );
	if (pTool == NULL)
	{
		if(!finishing_pass)wxMessageBox(_T("Cannot generate GCode for profile without a tool assigned"));
		return(python);
	} // End if - then

	if(!finishing_pass || m_profile_params.m_only_finishing_pass)
	{
		python << CDepthOp::AppendTextToProgram(pMachineState);

		if(m_profile_params.m_auto_roll_on || m_profile_params.m_auto_roll_off)
		{
			python << _T("roll_radius = float(");
			python << m_profile_params.m_auto_roll_radius / theApp.m_program->m_units;
			python << _T(")\n");
		}
	}

	if(finishing_pass)
	{
		python << _T("feedrate_hv(") << m_profile_params.m_finishing_h_feed_rate / theApp.m_program->m_units << _T(", ");
		python << m_speed_op_params.m_vertical_feed_rate / theApp.m_program->m_units << _T(")\n");
		python << _T("flush_nc()\n");
		python << _T("offset_extra = 0.0\n");
		python << _T("step_down = ") << m_profile_params.m_finishing_step_down << _T("\n");
	}
	else
	{
		python << _T("offset_extra = ") << m_profile_params.m_offset_extra / theApp.m_program->m_units << _T("\n");
	}

	CProfileParams::eCutMode cut_mode = finishing_pass ? m_profile_params.m_finishing_cut_mode : m_profile_params.m_cut_mode;

#ifdef OP_SKETCHES_AS_CHILDREN
	for(std::list<HeeksObj*>::iterator It = m_objects.begin(); It != m_objects.end(); It++)
	{
		// write a kurve definition
		HeeksObj* object = *It;
		if((object == NULL) || (object->GetType() != SketchType) || (object->GetNumChildren() == 0))continue;
#else
	for (std::list<int>::iterator It = m_sketches.begin(); It != m_sketches.end(); It++)
    {
		HeeksObj* object = heeksCAD->GetIDObject(SketchType, *It);
		if((object == NULL) || (object->GetNumChildren() == 0))continue;
#endif

		HeeksObj* re_ordered_sketch = NULL;
		SketchOrderType sketch_order = heeksCAD->GetSketchOrder(object);
		if(sketch_order == SketchOrderTypeBad)
		{
			re_ordered_sketch = object->MakeACopy();
			heeksCAD->ReOrderSketch(re_ordered_sketch, SketchOrderTypeReOrder);
			object = re_ordered_sketch;
		}

		if(sketch_order == SketchOrderTypeMultipleCurves || sketch_order == SketchOrderHasCircles)
		{
			std::list<HeeksObj*> new_separate_sketches;
			heeksCAD->ExtractSeparateSketches(object, new_separate_sketches, false);
			for(std::list<HeeksObj*>::iterator It = new_separate_sketches.begin(); It != new_separate_sketches.end(); It++)
			{
				HeeksObj* one_curve_sketch = *It;
				python << AppendTextForOneSketch(one_curve_sketch, pMachineState, cut_mode).c_str();
				delete one_curve_sketch;
			}
		}
		else
		{
			python << AppendTextForOneSketch(object, pMachineState, cut_mode).c_str();
		}

		if(re_ordered_sketch)
		{
			delete re_ordered_sketch;
		}
	}

	return python;
} // End AppendTextToProgram() method

static unsigned char cross16[32] = {0x80, 0x01, 0x40, 0x02, 0x20, 0x04, 0x10, 0x08, 0x08, 0x10, 0x04, 0x20, 0x02, 0x40, 0x01, 0x80, 0x01, 0x80, 0x02, 0x40, 0x04, 0x20, 0x08, 0x10, 0x10, 0x08, 0x20, 0x04, 0x40, 0x02, 0x80, 0x01};

void CProfile::glCommands(bool select, bool marked, bool no_color)
{
	CDepthOp::glCommands(select, marked, no_color);

	if(marked && !no_color)
	{
		if(GetNumSketches() == 1)
		{
			// draw roll on point
			if(!m_profile_params.m_auto_roll_on)
			{
				glColor3ub(0, 200, 200);
				glRasterPos3dv(m_profile_params.m_roll_on_point);
//.........这里部分代码省略.........
开发者ID:DesignerMK,项目名称:heekscnc,代码行数:101,代码来源:Profile.cpp

示例13: WriteSketchDefn

Python CProfile::WriteSketchDefn(HeeksObj* sketch, CMachineState *pMachineState, bool reversed )
{
	// write the python code for the sketch
	Python python;

	if ((sketch->GetShortString() != NULL) && (wxString(sketch->GetShortString()).size() > 0))
	{
		python << (wxString::Format(_T("comment(%s)\n"), PythonString(sketch->GetShortString()).c_str()));
	}

	python << _T("curve = area.Curve()\n");

	bool started = false;
	std::list<HeeksObj*> spans;
	for(HeeksObj* span_object = sketch->GetFirstChild(); span_object; span_object = sketch->GetNextChild())
	{
		if(reversed)spans.push_front(span_object);
		else spans.push_back(span_object);
	}

	std::list<HeeksObj*> new_spans;
	for(std::list<HeeksObj*>::iterator It = spans.begin(); It != spans.end(); It++)
	{
		HeeksObj* span = *It;
		if(span->GetType() == SplineType)
		{
			std::list<HeeksObj*> new_spans2;
			heeksCAD->SplineToBiarcs(span, new_spans2, CProfile::max_deviation_for_spline_to_arc);
			for(std::list<HeeksObj*>::iterator It2 = new_spans2.begin(); It2 != new_spans2.end(); It2++)
			{
				HeeksObj* s = *It2;
				if(reversed)new_spans.push_front(s);
				else new_spans.push_back(s);
			}
		}
		else
		{
			new_spans.push_back(span->MakeACopy());
		}
	}

	for(std::list<HeeksObj*>::iterator It = new_spans.begin(); It != new_spans.end(); It++)
	{
		HeeksObj* span_object = *It;
		double s[3] = {0, 0, 0};
		double e[3] = {0, 0, 0};
		double c[3] = {0, 0, 0};


		if(span_object){
			int type = span_object->GetType();
			if(type == LineType || type == ArcType || type == CircleType)
			{
				if(!started && type != CircleType)
				{
					if(reversed)span_object->GetEndPoint(s);
					else span_object->GetStartPoint(s);
					CNCPoint start(s);

					python << _T("curve.append(area.Point(");
					python << start.X(true);
					python << _T(", ");
					python << start.Y(true);
					python << _T("))\n");
					started = true;
				}
				if(reversed)span_object->GetStartPoint(e);
				else span_object->GetEndPoint(e);
				CNCPoint end(e);

				if(type == LineType)
				{
					python << _T("curve.append(area.Point(");
					python << end.X(true);
					python << _T(", ");
					python << end.Y(true);
					python << _T("))\n");
				}
				else if(type == ArcType)
				{
					span_object->GetCentrePoint(c);
					CNCPoint centre(c);

					double pos[3];
					heeksCAD->GetArcAxis(span_object, pos);
					int span_type = ((pos[2] >=0) != reversed) ? 1: -1;
					python << _T("curve.append(area.Vertex(");
					python << (span_type);
					python << (_T(", area.Point("));
					python << end.X(true);
					python << (_T(", "));
					python << end.Y(true);
					python << (_T("), area.Point("));
					python << centre.X(true);
					python << (_T(", "));
					python << centre.Y(true);
					python << (_T(")))\n"));
				}
				else if(type == CircleType)
				{
//.........这里部分代码省略.........
开发者ID:DesignerMK,项目名称:heekscnc,代码行数:101,代码来源:Profile.cpp

示例14: AppendTextToProgram

Python CPocket::AppendTextToProgram()
{
	Python python;

	CTool *pTool = CTool::Find( m_tool_number );
	if (pTool == NULL)
	{
		wxMessageBox(_T("Cannot generate GCode for pocket without a tool assigned"));
		return python;
	} // End if - then


	python << CSketchOp::AppendTextToProgram();

	HeeksObj* object = heeksCAD->GetIDObject(SketchType, m_sketch);

	if(object == NULL) {
		wxMessageBox(wxString::Format(_("Pocket operation - Sketch doesn't exist")));
		return python;
	}

	int type = object->GetType();

	// do areas and circles first, separately
    {
		switch(type)
		{
		case CircleType:
		case AreaType:
			{
				heeksCAD->ObjectAreaString(object, python);
				WritePocketPython(python);
			}
			break;
		}
	}

	if(type == SketchType)
	{
		python << _T("a = area.Area()\n");
		python << _T("entry_moves = []\n");

		double c[3] = {0, 0, 0};

		if (object->GetNumChildren() == 0){
			wxMessageBox(wxString::Format(_("Pocket operation - Sketch %d has no children"), object->GetID()));
			return python;
		}

		HeeksObj* re_ordered_sketch = NULL;
		SketchOrderType order = heeksCAD->GetSketchOrder(object);
		if( 	(order != SketchOrderTypeCloseCW) &&
			(order != SketchOrderTypeCloseCCW) &&
			(order != SketchOrderTypeMultipleCurves) &&
			(order != SketchOrderHasCircles))
		{
			re_ordered_sketch = object->MakeACopy();
			heeksCAD->ReOrderSketch(re_ordered_sketch, SketchOrderTypeReOrder);
			object = re_ordered_sketch;
			order = heeksCAD->GetSketchOrder(object);
			if(	(order != SketchOrderTypeCloseCW) &&
				(order != SketchOrderTypeCloseCCW) &&
				(order != SketchOrderTypeMultipleCurves) &&
				(order != SketchOrderHasCircles))
			{
				switch(heeksCAD->GetSketchOrder(object))
				{
				case SketchOrderTypeOpen:
					{
						wxMessageBox(wxString::Format(_("Pocket operation - Sketch must be a closed shape - sketch %d"), object->m_id));
						delete re_ordered_sketch;
						return python;
					}
					break;

				default:
					{
						wxMessageBox(wxString::Format(_("Pocket operation - Badly ordered sketch - sketch %d"), object->m_id));
						delete re_ordered_sketch;
						return python;
					}
					break;
				}
			}
		}

		if(object)
		{
			python << WriteSketchDefn(object);
		}

		if(re_ordered_sketch)
		{
			delete re_ordered_sketch;
		}

	} // End for

	// reorder the area, the outside curves must be made anti-clockwise and the insides clockwise
	python << _T("a.Reorder()\n");
//.........这里部分代码省略.........
开发者ID:silasb,项目名称:heekscnc,代码行数:101,代码来源:Pocket.cpp

示例15: ExtractSeparateSketches

void CSketch::ExtractSeparateSketches(std::list<HeeksObj*> &new_separate_sketches, const bool allow_individual_objects /* = false */ )
{
	CSketch* re_ordered_sketch = NULL;
	CSketch* sketch = this;

	if(GetSketchOrder() == SketchOrderTypeBad)
	{
	    // Duplicate and reorder the sketch to see if it's possible to make separate connected sketches.
		re_ordered_sketch = (CSketch*)(this->MakeACopy());
		re_ordered_sketch->ReOrderSketch(SketchOrderTypeReOrder);
		sketch = re_ordered_sketch;
	}
	if(sketch->GetSketchOrder() == SketchOrderTypeMultipleCurves || GetSketchOrder() == SketchOrderHasCircles)
	{
		std::list<HeeksObj*> objects_for_relinker;
		for(std::list<HeeksObj*>::iterator It=m_objects.begin(); It!=m_objects.end() ;It++)
		{
			HeeksObj* object = *It;
			if(object->GetType() == CircleType)
			{
				CSketch* new_object = new CSketch();
				new_object->color = color;
				new_object->Add(object->MakeACopy(), NULL);
				new_separate_sketches.push_back(new_object);
			}
			else
			{
				objects_for_relinker.push_back(object);
			}
		}

		// Make separate connected sketches from the child elements.
		CSketchRelinker relinker(objects_for_relinker);

		relinker.Do();

		for(std::list< std::list<HeeksObj*> >::iterator It = relinker.m_new_lists.begin(); It != relinker.m_new_lists.end(); It++)
		{
			std::list<HeeksObj*>& list = *It;
			CSketch* new_object = new CSketch();
			new_object->color = color;
			for(std::list<HeeksObj*>::iterator It2 = list.begin(); It2 != list.end(); It2++)
			{
				HeeksObj* object = *It2;
				new_object->Add(object->MakeACopy(), NULL);
			}
			new_separate_sketches.push_back(new_object);
		}
	}
	else
	{
        // The sketch does not seem to relink into separate connected shapes.  Just export
        // all the sketch's children as separate objects instead.
		if (allow_individual_objects)
		{
			for (HeeksObj *child = sketch->GetFirstChild(); child != NULL; child = sketch->GetNextChild())
			{
				new_separate_sketches.push_back( child->MakeACopy() );
			}
		}
	}

	if(re_ordered_sketch)delete re_ordered_sketch;
}
开发者ID:play113,项目名称:swer,代码行数:64,代码来源:Sketch.cpp


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