Ejemplo n.º 1
0
void CEdge::GetTools(std::list<Tool*>* t_list, const wxPoint* p){
	edge_for_tools = this;
	if(!wxGetApp().m_no_creation_mode && GetParentBody())t_list->push_back(&fillet_tool);
	if(!wxGetApp().m_no_creation_mode)t_list->push_back(&chamfer_tool);
	if(!wxGetApp().m_no_creation_mode)t_list->push_back(&make_sketch_tool);
	if(!wxGetApp().m_no_creation_mode)t_list->push_back(&link_flat_tool);
}
Ejemplo n.º 2
0
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
Ejemplo n.º 3
0
void CFace::glCommands(bool select, bool marked, bool no_color){
	bool owned_by_solid = false;
	if(GetParentBody()) {
		// using existing BRepMesh::Mesh
		// use solid's colour
		owned_by_solid = true;

		// add a marking display list
		if(m_marking_gl_list)
		{
			glCallList(m_marking_gl_list);
		}
	}
	else {
		// clean mesh
		double pixels_per_mm = wxGetApp().GetPixelScale();
		MeshFace(m_topods_face, 1/pixels_per_mm);

		// use a default material
		Material().glMaterial(1.0);
		glEnable(GL_LIGHTING);
		glShadeModel(GL_SMOOTH);
	}

	DrawFaceWithCommands(m_topods_face);

	if(!owned_by_solid)
	{
		glDisable(GL_LIGHTING);
		glShadeModel(GL_FLAT);
	}
}
Ejemplo n.º 4
0
void CFace::UpdateMarkingGLList(bool marked)
{
	if(m_marking_gl_list)
	{
		glNewList(m_marking_gl_list, GL_COMPILE);

		if(marked)
		{
			Material(wxGetApp().face_selection_color).glMaterial(1.0);
			glDisable(GL_BLEND);
			glDepthMask(1);
		}
		else
		{
			// use the parent body's colour
			CShape* parent_body = GetParentBody();
			if(parent_body)Material(parent_body->m_color).glMaterial(parent_body->GetOpacity());
			else
			{
				Material().glMaterial(1.0);
				glDisable(GL_BLEND);
				glDepthMask(1);
			}
		}

		glEndList();
	}
}
Ejemplo n.º 5
0
void CFace::GetGripperPositionsTransformed(std::list<GripData> *list, bool just_for_endof)
{
	if(GetParentBody() == NULL)
	{
		HeeksObj::GetGripperPositionsTransformed(list, just_for_endof);
	}
}
Ejemplo n.º 6
0
void CFace::ModifyByMatrix(const double *m){
	if(GetParentBody() == NULL)
	{
		gp_Trsf mat = make_matrix(m);
		BRepBuilderAPI_Transform myBRepTransformation(m_topods_face,mat);
		m_topods_face = TopoDS::Face(myBRepTransformation.Shape());
	}
}
Ejemplo n.º 7
0
void CFace::GetTriangles(void(*callbackfunc)(const double* x, const double* n), double cusp, bool just_one_average_normal){
	if(GetParentBody()) {
		// using existing BRepMesh::Mesh
	}
	else {
		MeshFace(m_topods_face,1/cusp);
	}

	DrawFace(m_topods_face,callbackfunc,just_one_average_normal);
}
Ejemplo n.º 8
0
void CFace::MakeSureMarkingGLListExists()
{
	// create a marking display list
	if(!m_marking_gl_list)
	{
		CShape* parent_body = GetParentBody();
		if(parent_body)
		{
			m_marking_gl_list = glGenLists(1);
			glNewList(m_marking_gl_list, GL_COMPILE_AND_EXECUTE);
			glEndList();
		}
	}
}
Ejemplo n.º 9
0
void HVertex::FindEdges()
{
	CShape* body = GetParentBody();
	if(body)
	{
		for(HeeksObj* object = body->m_edges->GetFirstChild(); object; object = body->m_edges->GetNextChild())
		{
			CEdge* e = (CEdge*)object;
			HVertex* v0 = e->GetVertex0();
			HVertex* v1 = e->GetVertex1();
			if(v0 == this || v1 == this)m_edges.push_back(e);
		}
	}
}
Ejemplo n.º 10
0
void CFace::GetBox(CBox &box){
//	if(!m_box.m_valid)
	{
		// there must be a better way than re-using the render code
		// Get triangulation
		if(GetParentBody() == NULL){
			MeshFace(m_topods_face,.01);
		}

		FaceForBoxCallback = this;
		DrawFace(m_topods_face,box_callback,false);
	}

	box.Insert(m_box);
}
Ejemplo n.º 11
0
//[-------------------------------------------------------]
//[ Public virtual PLPhysics::Joint functions             ]
//[-------------------------------------------------------]
void JointUniversal::GetCurrentPivotPoint(Vector3 &vPosition) const
{
	const PLPhysics::Body *pParentBody = GetParentBody();
	if (pParentBody) {
		// Get transform matrix
		Quaternion qQ;
		pParentBody->GetRotation(qQ);
		Vector3 vPos;
		pParentBody->GetPosition(vPos);
		Matrix3x4 mTrans;
		mTrans.FromQuatTrans(qQ, vPos);

		// Get the current joint anchor in world space
		vPosition = m_vLocalAnchor;
		vPosition *= mTrans;
	}
}
Ejemplo n.º 12
0
void CEdge::FindVertices()
{
	CShape* body = GetParentBody();
	if(body)
	{
		int i = 0;
		for (TopExp_Explorer expVertex(m_topods_edge, TopAbs_VERTEX); expVertex.More() && i<2; expVertex.Next(), i++)
		{
			const TopoDS_Shape &V = expVertex.Current();
			for(HeeksObj* object = body->m_vertices->GetFirstChild(); object; object = body->m_vertices->GetNextChild())
			{
				HVertex* v = (HVertex*)object;
				if(v->Vertex().IsSame(V))
				{
					if(i == 0)m_vertex0 = v;
					else m_vertex1 = v;
					break;
				}
			}
		}
	}
}