Example #1
0
void HeeksObj::GetGripperPositionsTransformed(std::list<GripData> *list, bool just_for_endof)
{
#ifdef HEEKSCAD

	//TODO: We want to transform these coords by whatever has happened to the draw matrix on the way down to our level
	//For right now we are just grabbing the sketches coord system, but this isn't right and won't work when parts or
	//assemblies come around.
	//For that matter it has gotten out of control with the addition of faces and edges to pads
	std::list<GripData> newlist;
	GetGripperPositions(&newlist,just_for_endof);

	gp_Trsf mat;

#ifdef MULTIPLE_OWNERS
	HeeksObj* owner = Owner();
	CSketch *sketch = dynamic_cast<CSketch*>(owner);
#else
	CSketch *sketch = dynamic_cast<CSketch*>(m_owner);
#endif

	if(sketch && sketch->m_coordinate_system)
		mat = sketch->m_coordinate_system->GetMatrix();

#ifdef MULTIPLE_OWNERS
	CPad *pad = dynamic_cast<CPad*>(owner);
	if(!pad && owner)
		pad = dynamic_cast<CPad*>(owner->Owner());
#else
	CPad *pad = dynamic_cast<CPad*>(m_owner);
	if(!pad && m_owner)
		pad = dynamic_cast<CPad*>(m_owner->m_owner);
#endif
	if(pad && pad->m_sketch->m_coordinate_system)
		mat = pad->m_sketch->m_coordinate_system->GetMatrix();

	std::list<GripData>::iterator it;
	for(it = newlist.begin(); it != newlist.end(); ++it)
	{
		GripData gd = *it;

		gp_Pnt pnt(gd.m_x,gd.m_y,gd.m_z);
		pnt.Transform(mat);
		gd.m_x = pnt.X();
		gd.m_y = pnt.Y();
		gd.m_z = pnt.Z();
		list->push_back(gd);
	}
#else
	GetGripperPositions(list,just_for_endof);
#endif
}