Esempio n. 1
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);
	}
}
Esempio n. 2
0
/** Initialise the list of faces for the mesh
 *
 * \param nverts - number of vertices per face
 * \param verts - concatenated array of vertex indices into the primvar arrays.
 * \param faces - newly initialised faces go here.
 */
void EmitterMesh::createFaceList(const Ri::IntArray& nverts,
		const Ri::IntArray& verts,
		FaceVec& faces) const
{
	// Create face list
	int faceStart = 0;
	float totWeight = 0;
	int sizeNVerts = nverts.size();
	int totVerts = 0;
	faces.reserve(sizeNVerts);
	for(int i = 0; i < sizeNVerts; ++i)
	{
		if(nverts[i] != 3 && nverts[i] != 4)
		{
			assert(0 && "emitter mesh can only deal with 3 and 4-sided faces");
			continue;
		}
		faces.push_back(MeshFace(&verts[0]+faceStart, totVerts, nverts[i]));
		faceStart += nverts[i];
		// Get weight for face
		float w = faceArea(faces.back());
		faces.back().weight = w;
		totWeight += w;
		totVerts += nverts[i];
	}
	// normalized areas so that total area = 1.
	float scale = 1/totWeight;
	for(int i = 0; i < sizeNVerts; ++i)
		faces[i].weight *= scale;
}
Esempio n. 3
0
void CSketch::glCommands(bool select, bool marked, bool no_color)
{
	if(m_coordinate_system && m_draw_with_transform)
	{
		glPushMatrix();
		m_coordinate_system->ApplyMatrix();
	}

	ObjList::glCommands(select,marked,no_color);

	if(m_solidify)
	{
	    try
	    {
            //TODO: we should really only be doing this when geometry changes
            std::vector<TopoDS_Face> faces = GetFaces();

            double pixels_per_mm = wxGetApp().GetPixelScale();

            for(unsigned i=0; i < faces.size(); i++)
            {
                MeshFace(faces[i],pixels_per_mm);
                DrawFaceWithCommands(faces[i]);
            }
	    }catch(...)
	    {

	    }
	}

	if(m_coordinate_system && m_draw_with_transform)
		glPopMatrix();
}
Esempio n. 4
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);
}
Esempio n. 5
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);
}