コード例 #1
0
ファイル: HDxf.cpp プロジェクト: play113/swer
void HeeksDxfRead::OnReadInsert(const char* block_name, const double* insert_point, double rotation_angle)
{
	if (m_blocks.find( wxString(Ctt(block_name)) ) == m_blocks.end())
	{
		return; // block not foundblock_name, const double* insert_point, double rotation_angle
	}
	else
	{
		BlockName_t b_name = wxString(Ctt(block_name));
#if 0
		// insert an insert object. To be expanded at the end
		HInsert* new_object = new HInsert(block_name, insert_point, rotation_angle);
		AddObject(new_object);
#else
		CSketch* block = m_blocks[b_name];
		CSketch* block_copy = new CSketch(*block);
		gp_Trsf tm;
		tm.SetTranslationPart(make_vector(insert_point));
		gp_Trsf rm;
		rm.SetRotation(gp_Ax1(gp_Pnt(0, 0, 0), gp_Dir(0, 0, 1)), rotation_angle * 0.01745329251994329);
		double m[16];
		extract(tm * rm, m);
		block_copy->ModifyByMatrix(m);
		AddObject(block_copy);
#endif
		inserted_blocks.insert(b_name);
	}
}
コード例 #2
0
ファイル: FaceTools.cpp プロジェクト: CarlosGS/heekscad
gp_Dir GetFaceNormalAtUV(const TopoDS_Face &face, double u, double v, gp_Pnt *pos){
	if(face.IsNull()) return gp_Dir(0, 0, 1);

	try
	{
		Handle(Geom_Surface) surf=BRep_Tool::Surface(face);          // get surface properties
		GeomLProp_SLProps props(surf, u, v, 1, 0.01);          // get surface normal
		if(!props.IsNormalDefined())return gp_Dir(0, 0, 1);
		gp_Dir norm=props.Normal();                         // check orientation
		if(pos)*pos = props.Value();
		if(face.Orientation()==TopAbs_REVERSED) norm.Reverse();
		return norm;
	}
	catch (Standard_Failure) {
		Handle_Standard_Failure e = Standard_Failure::Caught();
		wxMessageBox(wxString(_("Error in GetFaceNormalAtUV")) + _T(": ") + Ctt(e->GetMessageString()));
		return gp_Dir(0, 0, 1);
	}
	catch (const char* str)
	{
		wxMessageBox(wxString(_("Error in GetFaceNormalAtUV")) + _T(": ") + Ctt(str));
		return gp_Dir(0, 0, 1);
	}
	catch (...)
	{
		wxMessageBox(_("Error in GetFaceNormalAtUV"));
		return gp_Dir(0, 0, 1);
	}
}
コード例 #3
0
ファイル: HDxf.cpp プロジェクト: play113/swer
void HeeksDxfRead::OnReadBlock(const char* block_name, const double* base_point)
{
	if (m_blocks.find( wxString(Ctt(block_name)) ) == m_blocks.end())
	{
		m_current_block = new CSketch();
		m_current_block->OnEditString(Ctt(block_name));
		m_blocks.insert( std::make_pair( wxString(Ctt(block_name)), m_current_block ) );
	}
	else
	{
		m_current_block = m_blocks[wxString(Ctt(block_name))];
	}
}
コード例 #4
0
ファイル: HImage.cpp プロジェクト: Blokkendoos/heekscad
// static member function
HeeksObj* HImage::ReadFromXMLElement(TiXmlElement* pElem)
{
	wxString filepath;

	double x[4][3];

	// get the attributes
	for(TiXmlAttribute* a = pElem->FirstAttribute(); a; a = a->Next())
	{
		std::string name(a->Name());
		if(name == "filepath"){filepath.assign(Ctt(a->Value()));}
		else if(name == "x00"){x[0][0] = a->DoubleValue();}
		else if(name == "x01"){x[0][1] = a->DoubleValue();}
		else if(name == "x02"){x[0][2] = a->DoubleValue();}
		else if(name == "x10"){x[1][0] = a->DoubleValue();}
		else if(name == "x11"){x[1][1] = a->DoubleValue();}
		else if(name == "x12"){x[1][2] = a->DoubleValue();}
		else if(name == "x20"){x[2][0] = a->DoubleValue();}
		else if(name == "x21"){x[2][1] = a->DoubleValue();}
		else if(name == "x22"){x[2][2] = a->DoubleValue();}
		else if(name == "x30"){x[3][0] = a->DoubleValue();}
		else if(name == "x31"){x[3][1] = a->DoubleValue();}
		else if(name == "x32"){x[3][2] = a->DoubleValue();}
	}

	HImage *new_object = new HImage(filepath.c_str());
	memcpy(new_object->m_x[0], x[0], 12*sizeof(double));
	new_object->m_rectangle_intialized = true;
	new_object->ReadBaseXML(pElem);

	return new_object;
}
コード例 #5
0
ファイル: RuledSurface.cpp プロジェクト: play113/swer
void CreateRevolutions(const std::list<TopoDS_Shape> &faces_or_wires, std::list<TopoDS_Shape>& new_shapes, const gp_Ax1& axis, double angle)
{
	try{
		for(std::list<TopoDS_Shape>::const_iterator It = faces_or_wires.begin(); It != faces_or_wires.end(); It++)
		{
			const TopoDS_Shape& face_or_wire = *It;
			if(fabs(angle - 360.0) < 0.00001)
			{
				BRepPrimAPI_MakeRevol generator( face_or_wire, axis );
				generator.Build();
				new_shapes.push_back(generator.Shape());
			}
			else
			{
				BRepPrimAPI_MakeRevol generator( face_or_wire, axis, angle * M_PI/180 );
				generator.Build();
				new_shapes.push_back(generator.Shape());
			}
		}
	}
	catch (Standard_Failure) {
		Handle_Standard_Failure e = Standard_Failure::Caught();
		wxMessageBox(wxString(_("Error making revolved solid")) + _T(": ") + Ctt(e->GetMessageString()));
	}
	catch(...)
	{
		wxMessageBox(_("Fatal error making revolved solid"));
	}

}
コード例 #6
0
ファイル: Sketch.cpp プロジェクト: CarlosGS/heekscad
void CSketch::GetProperties(std::list<Property *> *list)
{
	list->push_back(new PropertyInt(_("Number of elements"), ObjList::GetNumChildren(), this));

	int initial_index = 0;
	std::list< wxString > choices;
	SketchOrderType sketch_order = GetSketchOrder();
	order_map_for_properties.clear();
	int j = 0;
	for(int i = 0; i< MaxSketchOrderTypes; i++)
	{
		if((SketchOrderType)i == sketch_order)initial_index = j;

		if(SketchOrderAvailable(sketch_order, (SketchOrderType)i))
		{
			order_map_for_properties.insert(std::pair<int, int>(j, i));
			choices.push_back(Ctt(m_sketch_order_str[i].c_str()));
			j++;
		}
	}

	list->push_back ( new PropertyChoice ( _("order"), choices, initial_index, this, on_set_order_type ) );

	list->push_back ( new PropertyCheck( _("solidify"), m_solidify, this, on_set_solidify) );

	ObjList::GetProperties(list);
}
コード例 #7
0
ファイル: HDxf.cpp プロジェクト: play113/swer
void HeeksDxfRead::OnReadText(const double *point, const double height,  const char* text, int hj, int vj)
{
	gp_Trsf trsf;
	trsf.SetTranslation( gp_Vec( gp_Pnt(0,0,0), gp_Pnt(point[0], point[1], point[2]) ) );
	trsf.SetScaleFactor( height * 1.7 );

	wxString txt(Ctt(text));
	txt.Replace(_T("\\P"),_T("\n"),true);
	txt.Replace(_T("%%010"),_T("\n"),true);

	int offset = 0;
	while ((txt.Length() > 0) && (txt[0] == _T('\\')) && ((offset = txt.find(_T(';'))) != -1))
	{
		txt.Remove(0, offset+1);
	}

	wxArrayString retArray;
	Split(txt, retArray, _T("\n"));

	gp_Trsf line_feed_shift;
	line_feed_shift.SetTranslationPart(gp_Vec(0, -height, 0));

	for(unsigned int i = 0; i<retArray.GetCount(); i++)
	{
		HText *new_object = new HText(trsf, retArray[i], ActiveColorPtr(m_aci),
#ifndef WIN32
			NULL, 
#endif
			hj, vj);
		AddObject(new_object);
		trsf = trsf * line_feed_shift;
	}
}
コード例 #8
0
ファイル: CxfFont.cpp プロジェクト: Blokkendoos/heekscad
/* static */ std::list<wxString> VectorFonts::GetFileNames( const wxString & Root )
#ifdef WIN32
{
	std::list<wxString>	results;

	WIN32_FIND_DATA file_data;
	HANDLE hFind;

	std::string pattern = std::string(Ttc(Root.c_str())) + "\\*";
	hFind = FindFirstFile(Ctt(pattern.c_str()), &file_data);

	// Now recurse down until we find document files within 'current' directories.
	if (hFind != INVALID_HANDLE_VALUE)
	{
		do
		{
			if ((file_data.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) == FILE_ATTRIBUTE_DIRECTORY) continue;

			results.push_back(file_data.cFileName);
		} while (FindNextFile( hFind, &file_data));

		FindClose(hFind);
	} // End if - then

	return(results);
} // End of GetFileNames() method.
コード例 #9
0
ファイル: RuledSurface.cpp プロジェクト: play113/swer
bool CreateRuledSurface(const std::list<TopoDS_Wire> &wire_list, TopoDS_Shape& shape, bool make_solid)
{
	if(wire_list.size() > 0)
	{
			BRepOffsetAPI_ThruSections generator( make_solid ? Standard_True : Standard_True, Standard_False );
			for(std::list<TopoDS_Wire>::const_iterator It = wire_list.begin(); It != wire_list.end(); It++)
			{
				const TopoDS_Wire &wire = *It;
				generator.AddWire(wire);
			}

		try{
			generator.Build();
			shape = generator.Shape();
		}
		catch (Standard_Failure) {
			Handle_Standard_Failure e = Standard_Failure::Caught();
			wxMessageBox(wxString(_("Error making ruled solid")) + _T(": ") + Ctt(e->GetMessageString()));
			return false;
		}
		catch(...)
		{
			wxMessageBox(_("Fatal error making ruled solid"));
			return false;
		}

		return true;
	}
	return false;
}
コード例 #10
0
ファイル: Shape.cpp プロジェクト: JonasThomas/heekscad
	// Tool's virtual functions
	void Run(){
		double offset_value = 2.0;
		HeeksConfig config;
		config.Read(_T("OffsetShapeValue"), &offset_value);
		if(wxGetApp().InputLength(_("Enter Offset Value, + for making bigger, - for making smaller"), _("Offset value"), offset_value))
		{
			try
			{
				TopoDS_Shape new_shape = BRepOffsetAPI_MakeOffsetShape(shape_for_tools->Shape(), offset_value, wxGetApp().m_geom_tol);

#ifdef TESTNEWSHAPE
				//This will end up throwing 90% of the exceptions caused by a bad offset
				BRepTools::Clean(new_shape);
				BRepMesh::Mesh(new_shape, 1.0);
#endif

				HeeksObj* new_object = CShape::MakeObject(new_shape, _("Result of 'Offset Shape'"), SOLID_TYPE_UNKNOWN, shape_for_tools->m_color, shape_for_tools->GetOpacity());
				shape_for_tools->HEEKSOBJ_OWNER->Add(new_object, NULL);
				shape_for_tools->HEEKSOBJ_OWNER->Remove(shape_for_tools);
				config.Write(_T("OffsetShapeValue"), offset_value);
			}
			catch (Standard_Failure) {
				Handle_Standard_Failure e = Standard_Failure::Caught();
				wxMessageBox(wxString(_("Error making offset")) + _T(": ") + Ctt(e->GetMessageString()));
			}
		}
	}
コード例 #11
0
ファイル: HDxf.cpp プロジェクト: play113/swer
void HeeksDxfRead::AddObject(HeeksObj *object)
{
	if (! IsValidLayerName(Ctt(LayerName().c_str())))
	{
		// This is one of the forbidden layer names.  Discard the
		// graphics object and move on.

		delete object;
		return;
	}

	if(wxGetApp().m_in_OpenFile && wxGetApp().m_file_open_matrix)
	{
		object->ModifyByMatrix(wxGetApp().m_file_open_matrix);
	}

	if(m_make_as_sketch)
	{
		// Check to see if we've already added a sketch for the current layer name.  If not
		// then add one now.

		if (m_sketches.find( wxString(Ctt(LayerName().c_str())) ) == m_sketches.end())
		{
			m_sketches.insert( std::make_pair( wxString(Ctt(LayerName().c_str())), new CSketch() ) );
		}

		if(m_current_block)m_current_block->Add(object, NULL);
		else
		{
			object->ModifyByMatrix(m_ucs_matrix);
			m_sketches[wxString(Ctt(LayerName().c_str()))]->Add( object, NULL );
		}
	}
	else
	{
		if(m_current_block)m_current_block->Add(object, NULL);
		else
		{
			object->ModifyByMatrix(m_ucs_matrix);
			if(m_undoable)wxGetApp().AddUndoably(object, NULL, NULL);
			else wxGetApp().Add( object, NULL );
		}
	}
}
コード例 #12
0
ファイル: Sketch.cpp プロジェクト: CarlosGS/heekscad
// static member function
HeeksObj* CSketch::ReadFromXMLElement(TiXmlElement* pElem)
{
	CSketch* new_object = new CSketch;
	if(pElem->Attribute("title"))new_object->m_title = Ctt(pElem->Attribute("title"));
	new_object->ReadBaseXML(pElem);

	new_object->ReloadPointers();

	return (ObjList*)new_object;
}
コード例 #13
0
ファイル: RuledSurface.cpp プロジェクト: play113/swer
void CreateExtrusions(const std::list<TopoDS_Shape> &faces_or_wires, std::list<TopoDS_Shape>& new_shapes, const gp_Vec& extrude_vector, double taper_angle, bool solid_if_possible)
{
	try{
		for(std::list<TopoDS_Shape>::const_iterator It = faces_or_wires.begin(); It != faces_or_wires.end(); It++)
		{
			const TopoDS_Shape& face_or_wire = *It;
			if(fabs(taper_angle) > 0.0000001)
			{
				// make an offset face
				double distance = tan(taper_angle * M_PI/180) * extrude_vector.Magnitude();
				bool wire = (face_or_wire.ShapeType() == TopAbs_WIRE);
				BRepOffsetAPI_MakeOffset offset;
				if(wire)
					offset = BRepOffsetAPI_MakeOffset(TopoDS::Wire(face_or_wire));
				else
					continue; // can't do CreateRuledSurface on faces yet
                offset.Perform(distance);

				// parallel
				std::list<TopoDS_Wire> wire_list;
				wire_list.push_back(TopoDS::Wire(face_or_wire));
				wire_list.push_back(TopoDS::Wire(offset.Shape()));

				gp_Trsf mat;
				mat.SetTranslation(extrude_vector);
				BRepBuilderAPI_Transform myBRepTransformation(wire_list.back(),mat);
				wire_list.back() = TopoDS::Wire(myBRepTransformation.Shape());

				TopoDS_Shape new_shape;
				if(CreateRuledSurface(wire_list, new_shape, solid_if_possible))
				{
					new_shapes.push_back(new_shape);
				}
            }
			else
			{
				BRepPrimAPI_MakePrism generator( face_or_wire, extrude_vector );
				generator.Build();
				new_shapes.push_back(generator.Shape());
			}
		}
	}
	catch (Standard_Failure) {
		Handle_Standard_Failure e = Standard_Failure::Caught();
		wxMessageBox(wxString(_("Error making extruded solid")) + _T(": ") + Ctt(e->GetMessageString()));
	}
	catch(...)
	{
		wxMessageBox(_("Fatal error making extruded solid"));
	}

}
コード例 #14
0
ファイル: Op.cpp プロジェクト: DesignerMK/heekscnc
void COp::ReadBaseXML(TiXmlElement* element)
{
	const char* comment = element->Attribute("comment");
	if(comment)m_comment.assign(Ctt(comment));
	const char* active = element->Attribute("active");
	if(active)
	{
		int int_active;
		element->Attribute("active", &int_active);
		m_active = (int_active != 0);
	}
	else
	{
        m_active = true;
	}

	const char* title = element->Attribute("title");
	if(title)m_title = wxString(Ctt(title));

	if (element->Attribute("tool_number") != NULL)
	{
		m_tool_number = atoi(element->Attribute("tool_number"));
	} // End if - then
	else
	{
	    // The older files used to call this attribute 'cutting_tool_number'.  Look for this old
	    // name if we can't find the new one.
	    if (element->Attribute("cutting_tool_number") != NULL)
        {
            m_tool_number = atoi(element->Attribute("cutting_tool_number"));
        } // End if - then
        else
        {
            m_tool_number = 0;
        } // End if - else
	} // End if - else

	ObjList::ReadBaseXML(element);
}
コード例 #15
0
ファイル: DepthOp.cpp プロジェクト: AlanZheng/heekscnc
void CDepthOpParams::ReadFromXMLElement(TiXmlElement* pElem)
{
	TiXmlElement* element = heeksCAD->FirstNamedXMLChildElement(pElem, "depthop");
	if(element)
	{
		element->Attribute("clear", &m_clearance_height);
		element->Attribute("down", &m_step_down);
		element->Attribute("zfinish", &m_z_finish_depth);
		element->Attribute("zthru", &m_z_thru_depth);
		m_user_depths.assign(Ctt(element->Attribute("userdepths")));
		element->Attribute("startdepth", &m_start_depth);
		element->Attribute("depth", &m_final_depth);
		element->Attribute("r", &m_rapid_safety_space);
		heeksCAD->RemoveXMLChild(pElem, element);	// We don't want to interpret this again when
										// the ObjList::ReadBaseXML() method gets to it.
	}
}
コード例 #16
0
ファイル: Profile.cpp プロジェクト: DesignerMK/heekscnc
// static member function
HeeksObj* CProfile::ReadFromXMLElement(TiXmlElement* element)
{
	CProfile* new_object = new CProfile;

	std::list<TiXmlElement *> elements_to_remove;

	// read profile parameters
	TiXmlElement* params = heeksCAD->FirstNamedXMLChildElement(element, "params");
	if(params)
	{
		new_object->m_profile_params.ReadFromXMLElement(params);
		elements_to_remove.push_back(params);
	}

	// read sketch ids
	for(TiXmlElement* sketch = heeksCAD->FirstNamedXMLChildElement(element, "sketch"); sketch; sketch = sketch->NextSiblingElement())
	{
		if ((wxString(Ctt(sketch->Value())) == wxString(_T("sketch"))) &&
			(sketch->Attribute("id") != NULL) &&
			(sketch->Attribute("title") == NULL))
		{
			int id = 0;
			sketch->Attribute("id", &id);
			if(id)
			{
				new_object->m_sketches.push_back(id);
			}

			elements_to_remove.push_back(sketch);
		} // End if - then
	}

	for (std::list<TiXmlElement*>::iterator itElem = elements_to_remove.begin(); itElem != elements_to_remove.end(); itElem++)
	{
		heeksCAD->RemoveXMLChild( element, *itElem);
	}

	// read common parameters
	new_object->ReadBaseXML(element);

	new_object->AddMissingChildren();

	return new_object;
}
コード例 #17
0
ファイル: Shape.cpp プロジェクト: JonasThomas/heekscad
static HeeksObj* Fuse(HeeksObj* s1, HeeksObj* s2){
	try
	{
		TopoDS_Shape sh1, sh2;
		TopoDS_Shape new_shape;
		if(wxGetApp().useOldFuse)new_shape = BRepAlgo_Fuse(((CShape*)s1)->Shape(), ((CShape*)s2)->Shape());
		else new_shape = BRepAlgoAPI_Fuse(((CShape*)s1)->Shape(), ((CShape*)s2)->Shape());

		HeeksObj* new_object = CShape::MakeObject(new_shape, _("Result of Fuse Operation"), SOLID_TYPE_UNKNOWN, ((CShape*)s1)->m_color, ((CShape*)s1)->GetOpacity());
		wxGetApp().Add(new_object, NULL);
		wxGetApp().Remove(s1);
		wxGetApp().Remove(s2);
		return new_object;
	}
	catch (Standard_Failure) {
		Handle_Standard_Failure e = Standard_Failure::Caught();
		wxMessageBox(wxString(_("Error with fuse operation")) + _T(": ") + Ctt(e->GetMessageString()));
		return NULL;
	}
}
コード例 #18
0
ファイル: RuledSurface.cpp プロジェクト: play113/swer
HeeksObj* CreatePipeFromProfile(const TopoDS_Wire &spine, std::list<TopoDS_Shape> &faces)
{
	std::list<HeeksObj*> pipe_shapes;

	for(std::list<TopoDS_Shape>::iterator It2 = faces.begin(); It2 != faces.end(); It2++)
	{
		TopoDS_Shape& face = *It2;

		try
		{
			// pipe profile algong spine
			BRepOffsetAPI_MakePipe makePipe(spine, face);
			makePipe.Build();
			TopoDS_Shape shape = makePipe.Shape();

			HeeksObj* new_object = CShape::MakeObject(shape, _("Pipe"), SOLID_TYPE_UNKNOWN, wxGetApp().current_color, 1.0f);
			if(new_object)pipe_shapes.push_back(new_object);
		}
		catch (Standard_Failure) {
			Handle_Standard_Failure e = Standard_Failure::Caught();
			wxMessageBox(wxString(_("Error making pipe")) + _T(": ") + Ctt(e->GetMessageString()));
		}
	}
	if(pipe_shapes.size() > 0)
	{
		wxGetApp().StartHistory();
		for(std::list<HeeksObj*>::iterator It = pipe_shapes.begin(); It != pipe_shapes.end(); It++)
		{
			HeeksObj* object = *It;
			wxGetApp().AddUndoably(object, NULL, NULL);
		}
		wxGetApp().EndHistory();
		return pipe_shapes.front();
	}

	return NULL;
}
コード例 #19
0
ファイル: Shape.cpp プロジェクト: JonasThomas/heekscad
static bool Cut(const std::list<TopoDS_Shape> &shapes, TopoDS_Shape& new_shape){
	if(shapes.size() < 2)return false;

	try
	{
		std::list<TopoDS_Shape>::const_iterator It = shapes.begin();
		TopoDS_Shape current_shape = *It;
		It++;
		while(It != shapes.end())
		{
			const TopoDS_Shape &cutting_shape = *It;
			current_shape = BRepAlgoAPI_Cut(current_shape, cutting_shape);
			It++;
		}

		new_shape = current_shape;
		return true;
	}
	catch (Standard_Failure) {
		Handle_Standard_Failure e = Standard_Failure::Caught();
		wxMessageBox(wxString(_("Error with cut operation")) + _T(": ") + Ctt(e->GetMessageString()));
		return false;
	}
}
コード例 #20
0
ファイル: Plugins.cpp プロジェクト: Blokkendoos/heekscad
void ReadPluginsList(std::list<PluginData> &plugins)
{
	plugins.clear();

	HeeksConfig plugins_config;
	plugins_config.SetPath(_T("/plugins"));

	wxString key;
	long Index;
	wxString str;

	bool entry_found = false;
	bool hCncConfigured = false;  //if true, heekscnc is a plugin already. don't automatically add it in that case

	entry_found = plugins_config.GetFirstEntry(key, Index);

	while(entry_found)
	{
		plugins_config.Read(key, &str);

		PluginData pd;
		if(str[0] == '#')
		{
			str = str.Mid(1);
			pd.enabled = false;
		}
		else
		{
			pd.enabled = true;
		}

		pd.name = key;
		pd.path = str;
		plugins.push_back(pd);
		if( str.Lower().Matches(_T("*heekscnc*")) )
			hCncConfigured = true; 

		entry_found = plugins_config.GetNextEntry(key, Index);
	}

	//look for heekscnc in the standard install location and automatically add it, if it isn't already configured
	if( !hCncConfigured ) {
#ifdef WIN32
		//this code should work on windows given the correct path
		// FIXME: put the right path under Windows
		wxString sCncplugPath = wxT("standard\\windows\\path\\to\\heekscnc.dll");
#else
  #if wxCHECK_VERSION(3, 0, 0)
		wxStandardPaths& sp = wxStandardPaths::Get();
  #else
		wxStandardPaths sp;
  #endif
		wxString sCncplugPath = sp.GetInstallPrefix()  + wxT("/lib/libheekscnc.so");
#endif
		wprintf(_T("Attempt to automatically load HeeksCNC: ") + sCncplugPath  + wxT("\n"));
		if (wxFileName::FileExists(sCncplugPath)) {
			PluginData pd;
			pd.enabled = true;
			pd.hard_coded = false; //if this was true, the plugin wouldn't be added to the config - meaning the user couldn't disable it
			pd.name = _T("HeeksCNC (Automatically added)");
			pd.path = sCncplugPath;
			plugins.push_back(pd);
		}
	}

	// add plugins from the command line
	std::list<wxString> command_line_plugins;
	wxGetApp().GetPluginsFromCommandLineParams(command_line_plugins);
	for(std::list<wxString>::iterator It = command_line_plugins.begin(); It != command_line_plugins.end(); It++)
	{
		PluginData pd;
		pd.enabled = true;
		pd.hard_coded = true;
		pd.name = _T("CommandLinePlugin");
		pd.path = *It;
		plugins.push_back(pd);
	}

	// add code to always start your dll here.
#ifdef MY_OWN_HARDCODED_PLUGIN
	{
		PluginData pd;
		pd.enabled = true;
		pd.hard_coded = true;
		pd.name = _T("MyPlugin");
		pd.path = _T("$(MYEXEPATH)/mypluing/PluginForHeeksCAD.dll");
		plugins.push_back(pd);
	}
#endif


	wxString plugins_file = wxGetApp().GetExeFolder() + _T("/plugins.txt");
    ifstream ifs(Ttc(plugins_file.c_str()));
	if(!(!ifs))
	{
		char s[1024] = "";

		while(!(ifs.eof()))
		{
			ifs.getline(s, 1024);
			wxString str(Ctt(s));

			PluginData pd;
			if(str[0] == '#')
			{
				str = str.Mid(1);
				pd.enabled = false;
			}
			else
			{
				pd.enabled = true;
			}
			pd.hard_coded = true;
			pd.name = str;
			str.Replace(_T("{app}"), wxGetApp().GetExeFolder().c_str());
			pd.path = str;
			plugins.push_back(pd);
		}
	}

}
コード例 #21
0
ファイル: CxfFont.cpp プロジェクト: Blokkendoos/heekscad
VectorFont::Glyph::Glyph( const std::list<std::string> &cxf_glyph_definition, const double word_space_percentage, const double character_space_percentage )
{
	m_word_space_percentage = word_space_percentage;
	m_character_space_percentage = character_space_percentage;

	for (std::list<std::string>::const_iterator l_itLine = cxf_glyph_definition.begin(); l_itLine != cxf_glyph_definition.end(); l_itLine++)
	{
		wxString line( Ctt(l_itLine->c_str()) );
		wxString delimiters( _T(" \t\r\n,") );

		std::vector<wxString> tokens = Tokens( line, delimiters );
		if (tokens.size() == 0)
		{
			std::ostringstream l_ossError;
			l_ossError << "Expected tokens in glyph definition";
			throw(std::runtime_error(l_ossError.str().c_str()));
		}

		// Replace dot (.) for comma (,) if the locale settings require it.
		for (std::vector<wxString>::iterator token = tokens.begin(); token != tokens.end(); token++)
		{
			*token = PrepareStringForConversion( *token );
		}
		const wxChar * c_str = tokens[0].c_str();
		switch (c_str[0])
		{
		case 'L':
			if (tokens.size() != 5)
			{
				std::ostringstream l_ossError;
				l_ossError << "Expected 5 tokens when defining a line.  We got "
							<< tokens.size() << " tokens from '" << l_itLine->c_str() << "\n";
				throw(std::runtime_error(l_ossError.str().c_str()));
			}
			else
			{
				GlyphLine *line = new GlyphLine(	 PointToMM(strtod( Ttc(tokens[1].c_str()), NULL )),
										 PointToMM(strtod( Ttc(tokens[2].c_str()), NULL )),
										 PointToMM(strtod( Ttc(tokens[3].c_str()), NULL )),
										 PointToMM(strtod( Ttc(tokens[4].c_str()), NULL )) );
				m_graphics_list.push_back( line );
				m_bounding_box.Insert( line->BoundingBox() );
			}
			break;

		case 'A':

			if (tokens.size() != 6)
			{
				std::ostringstream l_ossError;
				l_ossError << "Expected 6 tokens when defining an arc";
				throw(std::runtime_error(l_ossError.str().c_str()));
			}
			else
			{
				if ((tokens[0].size() == 2) && (c_str[1] == 'R'))
				{
					// Reverse the starting and ending points.
					GlyphArc *arc = new GlyphArc( PointToMM(strtod( Ttc(tokens[1].c_str()), NULL )),
										 PointToMM(strtod( Ttc(tokens[2].c_str()), NULL )),
										 PointToMM(strtod( Ttc(tokens[3].c_str()), NULL )),
										 strtod( Ttc(tokens[5].c_str()), NULL) ,
										 strtod( Ttc(tokens[4].c_str()), NULL ));
					m_graphics_list.push_back( arc );
					m_bounding_box.Insert( arc->BoundingBox() );
				} // End if - then
				else
				{
					GlyphArc *arc = new GlyphArc( PointToMM(strtod( Ttc(tokens[1].c_str()), NULL )),
										 PointToMM(strtod( Ttc(tokens[2].c_str()), NULL )),
										 PointToMM(strtod( Ttc(tokens[3].c_str()), NULL )),
										 strtod( Ttc(tokens[4].c_str()), NULL ),
										 strtod( Ttc(tokens[5].c_str()), NULL ) );
					m_graphics_list.push_back( arc );
					m_bounding_box.Insert( arc->BoundingBox() );
				}
			}
			break;

		default:
			std::ostringstream l_ossError;
			l_ossError << "Unexpected graphics element type '" << c_str[0] << "'";
			throw(std::runtime_error(l_ossError.str().c_str()));
		} // End switch
	} // End for
} // End constructor
コード例 #22
0
ファイル: Shape.cpp プロジェクト: JonasThomas/heekscad
void CShape::FilletOrChamferEdges(std::list<HeeksObj*> &list, double radius, bool chamfer_not_fillet)
{
	// make a map with a list of edges for each solid
	std::map< HeeksObj*, std::list< HeeksObj* > > solid_edge_map;

	for(std::list<HeeksObj*>::const_iterator It = list.begin(); It != list.end(); It++){
		HeeksObj* edge = *It;
		if(edge->GetType() == EdgeType)
		{
			HeeksObj* solid = edge->HEEKSOBJ_OWNER->HEEKSOBJ_OWNER;
			if(solid && solid->GetType() == SolidType)
			{
				std::map< HeeksObj*, std::list< HeeksObj* > >::iterator FindIt = solid_edge_map.find(solid);
				if(FindIt == solid_edge_map.end())
				{
					std::list< HeeksObj* > empty_list;
					solid_edge_map.insert( make_pair(solid, empty_list) );
					FindIt = solid_edge_map.find(solid);
				}

				std::list< HeeksObj* > &list = FindIt->second;
				list.push_back(edge);
			}
		}
	}

	// do each solid
	for(std::map< HeeksObj*, std::list< HeeksObj* > >::iterator It = solid_edge_map.begin(); It != solid_edge_map.end(); It++)
	{
		HeeksObj* solid = It->first;
		std::list< HeeksObj* > &list = It->second;

		try{
			if(chamfer_not_fillet)
			{
				BRepFilletAPI_MakeChamfer chamfer(((CShape*)solid)->Shape());
				for(std::list< HeeksObj* >::iterator It2 = list.begin(); It2 != list.end(); It2++)
				{
					CEdge* edge = (CEdge*)(*It2);
					for(CFace* face = (CFace*)(edge->GetFirstFace()); face; face = (CFace*)(edge->GetNextFace()))
					{
						chamfer.Add(radius, TopoDS::Edge(edge->Edge()), TopoDS::Face(face->Face()));
					}
				}
				TopoDS_Shape new_shape = chamfer.Shape();
				wxGetApp().Add(new CSolid(*((TopoDS_Solid*)(&new_shape)), _("Solid with edge blend"), *(solid->GetColor()), ((CShape*)solid)->m_opacity), NULL);
				wxGetApp().Remove(solid);
			}
			else
			{
				BRepFilletAPI_MakeFillet fillet(((CShape*)solid)->Shape());
				for(std::list< HeeksObj* >::iterator It2 = list.begin(); It2 != list.end(); It2++)
				{
					fillet.Add(radius, TopoDS::Edge(((CEdge*)(*It2))->Edge()));
				}
				TopoDS_Shape new_shape = fillet.Shape();
				wxGetApp().Add(new CSolid(*((TopoDS_Solid*)(&new_shape)), _("Solid with edge blend"), *(solid->GetColor()), ((CShape*)solid)->m_opacity), NULL);
				wxGetApp().Remove(solid);
			}
		}
		catch (Standard_Failure) {
			Handle_Standard_Failure e = Standard_Failure::Caught();
			wxMessageBox(wxString(_("Error making fillet")) + _T(": ") + Ctt(e->GetMessageString()));
		}
		catch(...)
		{
			wxMessageBox(_("A fatal error happened during Blend"));
		}
	}

	wxGetApp().Repaint();
}
コード例 #23
0
ファイル: Edge.cpp プロジェクト: Heeks/heekscad
void CEdge::Blend(double radius,  bool chamfer_not_fillet){
	try{
		CShape* body = GetParentBody();
		if(body){
			if(chamfer_not_fillet)
			{
				BRepFilletAPI_MakeChamfer chamfer(body->Shape());
				for(std::list<CFace*>::iterator It = m_faces.begin(); It != m_faces.end(); It++)
				{
					CFace* face = *It;
					chamfer.Add(radius, m_topods_edge, TopoDS::Face(face->Face()));
				}
				TopoDS_Shape new_shape = chamfer.Shape();
				wxGetApp().AddUndoably(new CSolid(*((TopoDS_Solid*)(&new_shape)), _("Solid with edge chamfer"), *(body->GetColor()), body->GetOpacity()), NULL, NULL);
			}
			else
			{
				BRepFilletAPI_MakeFillet fillet(body->Shape());
				fillet.Add(radius, m_topods_edge);
				TopoDS_Shape new_shape = fillet.Shape();
				wxGetApp().AddUndoably(new CSolid(*((TopoDS_Solid*)(&new_shape)), _("Solid with edge blend"), *(body->GetColor()), body->GetOpacity()), NULL, NULL);
			}
			wxGetApp().DeleteUndoably(body);
		}
	}
	catch (Standard_Failure) {
		Handle_Standard_Failure e = Standard_Failure::Caught();
		wxMessageBox(wxString(chamfer_not_fillet ?_("Error making fillet"):_("Error making fillet")) + _T(": ") + Ctt(e->GetMessageString()));
	}
	catch(...)
	{
		wxMessageBox(chamfer_not_fillet ? _("A fatal error happened during Chamfer"):_("A fatal error happened during Blend"));
	}
}// end Blend function
コード例 #24
0
ファイル: Face.cpp プロジェクト: Blokkendoos/heekscad
bool CFace::GetNurbSurfaceParams(CNurbSurfaceParams* params)
{
	try {
		BRepAdaptor_Surface surface(m_topods_face, Standard_True);
		params->rational = surface.IsURational() != 0;
		params->is_u_periodic = surface.IsUPeriodic() != 0;
		params->is_v_periodic = surface.IsVPeriodic() != 0;
		params->is_u_closed = surface.IsUClosed() != 0;
		params->is_v_closed = surface.IsVClosed() != 0;
		switch(surface.GetType())
		{
		case GeomAbs_BSplineSurface:
		case GeomAbs_BezierSurface:
		case GeomAbs_SurfaceOfExtrusion:
			params->u_order = surface.UDegree();
			params->v_order = surface.VDegree();
			params->n_u_vertices = surface.NbUPoles();
			params->n_v_vertices = surface.NbVPoles();
			break;
		default:
			params->u_order = 0;
			params->v_order = 0;
			params->n_u_vertices = 0;
			params->n_v_vertices = 0;
			break;
		}

		switch(surface.GetType())
		{
		case GeomAbs_BSplineSurface:
			{
				Handle(Geom_Surface) aGeomSurface = BRep_Tool::Surface(m_topods_face);
				Handle(Geom_BSplineSurface) aBSplineSurface = Handle(Geom_BSplineSurface)::DownCast(aGeomSurface);

				int myNbUPoles = aBSplineSurface->NbUPoles();
				int myNbVPoles = aBSplineSurface->NbVPoles();

				TColgp_Array2OfPnt aPoles(1, myNbVPoles, 1, myNbUPoles);

				TColStd_Array1OfReal aVKnots(1, aBSplineSurface->NbVKnots());
				TColStd_Array1OfReal aUKnots(1, aBSplineSurface->NbUKnots());

				aBSplineSurface->Poles(aPoles);
				aBSplineSurface->UKnots(aUKnots);
				aBSplineSurface->VKnots(aVKnots);

				//Push the nurbs in Coin3d

				// Control Point
				Standard_Integer i, j, aCounter;
				params->vertex_size = 4;
				int nVertexDoubles = myNbVPoles*myNbUPoles*params->vertex_size; //Create array of control points and their weights
				params->vertex = new double[nVertexDoubles];

				aCounter = -1;

				for(j = 1; j <= myNbVPoles; j++) {
					for(i = 1; i <= myNbUPoles; i++) {
						const gp_Pnt& aPoint = aBSplineSurface->Pole(i, j); //Control point (U,V)
						params->vertex[++aCounter] = aPoint.X();
						params->vertex[++aCounter] = aPoint.Y();
						params->vertex[++aCounter] = aPoint.Z();
						params->vertex[++aCounter] = aBSplineSurface->Weight(i, j);
					}
				}

				std::list<double> knot_list;

				//Fill the knot`s array taking into account multiplicities
				// VKnots
				for(i = aVKnots.Lower(); i<=aVKnots.Upper(); i++) {
					for(j = 1; j<= aBSplineSurface->VMultiplicity(i); j++)
						knot_list.push_back(aVKnots(i));
				}

				params->v_knot = new double[knot_list.size()];

				aCounter = -1;
				for(std::list<double>::iterator It = knot_list.begin(); It != knot_list.end(); It++)
				{
					params->v_knot[++aCounter] = *It;
				}
				params->n_v_knots = aCounter+1;

				// UKnots
				knot_list.clear();
				for(i = aUKnots.Lower(); i<=aUKnots.Upper(); i++) {
					for(j = 1; j<= aBSplineSurface->UMultiplicity(i); j++)
						knot_list.push_back(aUKnots(i));
				}

				params->u_knot = new double[knot_list.size()];

				aCounter = -1;
				for(std::list<double>::iterator It = knot_list.begin(); It != knot_list.end(); It++)
				{
					params->u_knot[++aCounter] = *It;
				}
				params->n_u_knots = aCounter+1;
			}
			break;

		case GeomAbs_BezierSurface:
			{
				Handle(Geom_Surface) aGeomSurface = BRep_Tool::Surface(m_topods_face);
				Handle(Geom_BezierSurface) aBSplineSurface = Handle(Geom_BezierSurface)::DownCast(aGeomSurface);

				int myNbUPoles = aBSplineSurface->NbUPoles();
				int myNbVPoles = aBSplineSurface->NbVPoles();

				TColgp_Array2OfPnt aPoles(1, myNbVPoles, 1, myNbUPoles);

				aBSplineSurface->Poles(aPoles);
				//Push the nurbs in Coin3d

				// Control Point
				Standard_Integer i, j, aCounter;
				params->vertex_size = 4;
				int nVertexDoubles = myNbVPoles*myNbUPoles*params->vertex_size; //Create array of control points and their weights
				params->vertex = new double[nVertexDoubles];

				aCounter = -1;

				for(j = 1; j <= myNbVPoles; j++) {
					for(i = 1; i <= myNbUPoles; i++) {
						const gp_Pnt& aPoint = aBSplineSurface->Pole(i, j); //Control point (U,V)
						params->vertex[++aCounter] = aPoint.X();
						params->vertex[++aCounter] = aPoint.Y();
						params->vertex[++aCounter] = aPoint.Z();
						params->vertex[++aCounter] = aBSplineSurface->Weight(i, j);
					}
				}

			}
			break;
		default:
			break;
		}

	}
	catch(Standard_Failure) {
		Handle_Standard_Failure e = Standard_Failure::Caught();
		wxMessageBox(wxString(_("Error in CFace::GetNurbSurfaceParams")) + _T(": ") + Ctt(e->GetMessageString()));
		return false;
	}

	return true;
}