Пример #1
0
void GetGridBox(const CViewPoint *view_point, CBox &ext){
	gp_Pnt sp[4];
	double zval = 0.5;
	wxSize size = wxGetApp().m_current_viewport->GetViewportSize();
	sp[0] = gp_Pnt(0, 0, zval);
	sp[1] = gp_Pnt(size.GetWidth(), 0, zval);
	sp[2] = gp_Pnt(size.GetWidth(), size.GetHeight(), zval);
	sp[3] = gp_Pnt(0, size.GetHeight(), zval);
	gp_Vec vx, vy;
	view_point->GetTwoAxes(vx, vy, false, 0);
	gp_Pnt datum(0, 0, 0);
	gp_Trsf orimat = wxGetApp().GetDrawMatrix(false);
	datum.Transform(orimat);
	orimat = make_matrix(datum, vx, vy);
	gp_Pln plane(datum, gp_Vec(0, 0, 1).Transformed(orimat));
	{
		for(int i =0; i<4; i++){
			gp_Pnt p1 = view_point->glUnproject(sp[i]);
			sp[i].SetZ(0);
			gp_Pnt p2 = view_point->glUnproject(sp[i]);
			gp_Lin line = make_line(p1, p2);
			gp_Pnt pnt;
			if(intersect(line, plane, pnt))
			{
				ext.Insert(pnt.X(), pnt.Y(), pnt.Z());
			}
		}
	}
}
Пример #2
0
void HRuler::GetBox(CBox &box)
{
	gp_Pnt point[4];
	GetFourCorners(point);

	for(int i = 0; i<4; i++)
	{
		point[i].Transform(m_trsf);
		box.Insert(point[i].X(), point[i].Y(), point[i].Z());
	}
}
Пример #3
0
void CEdge::GetBox(CBox &box){
	// just use the vertices for speed
	for (TopExp_Explorer expVertex(m_topods_edge, TopAbs_VERTEX); expVertex.More(); expVertex.Next())
	{
		const TopoDS_Shape &V = expVertex.Current();
		gp_Pnt pos = BRep_Tool::Pnt(TopoDS::Vertex(V));
		double p[3];
		extract(pos, p);
		box.Insert(p);
	}
}
Пример #4
0
void CShape::GetBox(CBox &box)
{
	if(!m_box.m_valid)
	{
		if(m_faces == NULL)create_faces_and_edges();
		BRepTools::Clean(m_shape);
		BRepMesh::Mesh(m_shape, 1.0);
		if(m_faces)m_faces->GetBox(m_box);
	}

	box.Insert(m_box);
}
Пример #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);
}
Пример #6
0
void HGear::GetBox(CBox &box){
	double acting_radius = (double)(m_module * m_num_teeth)/2;
	double outside_radius = acting_radius + (m_addendum_multiplier*m_module + m_addendum_offset);
	gp_Trsf mat = make_matrix(m_pos.Location(), m_pos.XDirection(), m_pos.YDirection());
	gp_Pnt p[4];
	p[0] = gp_Pnt(m_pos.Location().XYZ() + gp_XYZ(outside_radius, outside_radius, 0.0));
	p[1] = gp_Pnt(m_pos.Location().XYZ() + gp_XYZ(-outside_radius, outside_radius, 0.0));
	p[2] = gp_Pnt(m_pos.Location().XYZ() + gp_XYZ(-outside_radius, -outside_radius, 0.0));
	p[3] = gp_Pnt(m_pos.Location().XYZ() + gp_XYZ(outside_radius, -outside_radius, 0.0));
	for(int i = 0; i<4; i++)
	{
		p[i].Transform(mat);
		box.Insert(p[i].X(), p[i].Y(), p[i].Z());
	}
}
Пример #7
0
void HDimension::GetBox(CBox &box)
{
	gp_Pnt vt(0, 0, 0);
	vt.Transform(m_trsf);
	double p[3];
	extract(vt, p);
	box.Insert(p);

	wxString text = MakeText();
	float width, height;
	if(!wxGetApp().get_text_size(text, &width, &height))return;

	gp_Pnt point[3];
	point[0] = gp_Pnt(width, 0, 0);
	point[1] = gp_Pnt(0, -height, 0);
	point[2] = gp_Pnt(width, -height, 0);

	for(int i = 0; i<3; i++)
	{
		point[i].Transform(m_trsf);
		extract(point[i], p);
		box.Insert(p);
	}
}
Пример #8
0
void ObjList::GetBox(CBox &box)
{
	std::list<HeeksObj*>::iterator It;
	for(It=m_objects.begin(); It!=m_objects.end() ;It++)
	{
		HeeksObj* object = *It;
		if(object->OnVisibleLayer() && object->m_visible)
		{
		    if (It == m_objects.begin())
		    {
		        object->GetBox(box);
		    }
		    else
		    {
                CBox new_box;
                object->GetBox(new_box);
                box.Insert(new_box);
		    }
		}
	}
}
Пример #9
0
void HLine::GetBox(CBox &box){
	box.Insert(A->m_p.X(), A->m_p.Y(), A->m_p.Z());
	box.Insert(B->m_p.X(), B->m_p.Y(), B->m_p.Z());
}
Пример #10
0
void HImage::GetBox(CBox &box)
{
	for(int i = 0; i<4; i++)box.Insert(m_x[i]);
}
Пример #11
0
static void RenderGrid(const CViewPoint *view_point, double max_number_across, bool in_between_spaces, bool miss_main_lines, const HeeksColor *bg, const HeeksColor *cc, unsigned char brightness, int plane_mode){
	gp_Pnt sp[4];
	double zval = 0.5;
	wxSize size = wxGetApp().m_current_viewport->GetViewportSize();
	sp[0] = gp_Pnt(0, 0, zval);
	sp[1] = gp_Pnt(size.GetWidth(), 0, zval);
	sp[2] = gp_Pnt(size.GetWidth(), size.GetHeight(), zval);
	sp[3] = gp_Pnt(0, size.GetHeight(), zval);
	gp_Vec vx, vy;
	int plane_mode2 = view_point->GetTwoAxes(vx, vy, false, plane_mode);
	gp_Pnt datum(0, 0, 0);
	gp_Trsf orimat = wxGetApp().GetDrawMatrix(false);
	datum.Transform(orimat);
	orimat = make_matrix(datum, vx, vy);
	gp_Vec unit_forward = view_point->forwards_vector().Normalized();
	double plane_dp = fabs(gp_Vec(0, 0, 1).Transformed(orimat) * unit_forward);
	if(plane_dp < 0.3)return;
	gp_Pln plane(gp_Pnt(0, 0, 0).Transformed(orimat), gp_Vec(0, 0, 1).Transformed(orimat));
	{
		for(int i =0; i<4; i++){
			gp_Pnt p1 = view_point->glUnproject(sp[i]);
			sp[i].SetZ(0);
			gp_Pnt p2 = view_point->glUnproject(sp[i]);
			if(p1.Distance(p2) < 0.00000000001)return;
			gp_Lin line = make_line(p1, p2);
			gp_Pnt pnt;
			if(intersect(line, plane, pnt))
			{
				sp[i].SetX((gp_Vec(pnt.XYZ()) * vx) - (gp_Vec(datum.XYZ()) * vx));
				sp[i].SetY((gp_Vec(pnt.XYZ()) * vy) - (gp_Vec(datum.XYZ()) * vy));
				sp[i].SetZ(0);
			}
		}
	}
	CBox b;
	{
		for(int i = 0; i<4; i++){
			b.Insert(sp[i].X(), sp[i].Y(), sp[i].Z());
		}
	}
	double width = b.Width();
	double height = b.Height();
	double biggest_dimension;
	if(height > width)biggest_dimension = height;
	else biggest_dimension = width;
	double widest_spacing = biggest_dimension/max_number_across;
	bool dimmer = false;
	double dimness_ratio = 1.0;
	double spacing;

	if(wxGetApp().draw_to_grid){
		spacing = wxGetApp().digitizing_grid;
		if(!miss_main_lines)spacing *= 10;
		if(spacing<0.0000000001)return;
		if(biggest_dimension / spacing > max_number_across * 1.5)return;
		if(biggest_dimension / spacing > max_number_across){
			dimmer = true;
			dimness_ratio = (max_number_across * 1.5 - biggest_dimension / spacing)/ (max_number_across * 0.5);
		}

	}
	else{
		double l = log10(widest_spacing / wxGetApp().m_view_units);

		double intl = (int)l;
		if(l>0)intl++;

		spacing = pow(10.0, intl) * wxGetApp().m_view_units;
	}

	if(wxGetApp().grid_mode == 3){
		dimmer = true;
		dimness_ratio *= plane_dp;
		dimness_ratio *= plane_dp;
	}
	double ext2d[4];
	ext2d[0] = b.m_x[0];
	ext2d[1] = b.m_x[1];
	ext2d[2] = b.m_x[3];
	ext2d[3] = b.m_x[4];
	{
		for(int i = 0; i<4; i++){
			double intval = (int)(ext2d[i]/spacing);
			if(i <2 ){
				if(ext2d[i]<0)intval--;
			}
			else{
				if(ext2d[i]>0)intval++;
			}

			ext2d[i] = intval * spacing;
		}
	}
	if(cc){
		HeeksColor col = *cc;
		if(wxGetApp().grid_mode == 3){
			switch(plane_mode2){
			case 0:
				col.green = (unsigned char)(0.6 * (double)(bg->green));
				break;
			case 1:
				col.red = (unsigned char)(0.9 * (double)(bg->red));
				break;
			case 2:
				col.blue = bg->blue;
				break;
			}
		}

		if(dimmer){
			double d_brightness = (double)brightness;
			d_brightness *= dimness_ratio;
			unsigned char uc_brightness = (unsigned char)d_brightness;

			glColor4ub(col.red, col.green, col.blue, uc_brightness);
		}
		else{
			glColor4ub(col.red, col.green, col.blue, brightness);
		}
	}
	glBegin(GL_LINES);
	double extra = 0;
	if(in_between_spaces)extra = spacing * 0.5;
	for(double x = ext2d[0] - extra; x<ext2d[2] + extra; x += spacing){
		if(miss_main_lines){
			double xr = x/spacing/5;
			if( fabs(  xr - (double)(int)(xr+ (xr>0 ? 0.5:-0.5)) ) < 0.1)continue;
		}
		gp_Pnt temp(datum.XYZ() + (vx.XYZ() * x) + (vy.XYZ() * ext2d[1]));
		glVertex3d(temp.X(), temp.Y(), temp.Z());
		temp = (datum.XYZ() + (vx.XYZ() * x) + (vy.XYZ() * ext2d[3]));
		glVertex3d(temp.X(), temp.Y(), temp.Z());
	}
	for(double y = ext2d[1] - extra; y<ext2d[3] + extra; y += spacing){
		if(miss_main_lines){
			double yr = y/spacing/5;
			if( fabs(  yr - (double)(int)(yr+(yr>0 ? 0.5:-0.5)) ) < 0.1)continue;
		}
		gp_Pnt temp = (datum.XYZ() + (vx.XYZ() * ext2d[0]) + (vy.XYZ() * y));
		glVertex3d(temp.X(), temp.Y(), temp.Z());
		temp = (datum.XYZ() + (vx.XYZ() * ext2d[2]) + (vy.XYZ() * y));
		glVertex3d(temp.X(), temp.Y(), temp.Z());
	}
	glEnd();
}
Пример #12
0
void HPoint::GetBox(CBox &box)
{
	box.Insert(m_p.X(), m_p.Y(), m_p.Z());
}