+ for picking of alignment save point plus normal
This commit is contained in:
parent
f83506c510
commit
330df84419
|
@ -179,7 +179,7 @@ Gui::Document* AlignmentGroup::getDocument() const
|
|||
return 0;
|
||||
}
|
||||
|
||||
void AlignmentGroup::addPoint(const Base::Vector3d& pnt)
|
||||
void AlignmentGroup::addPoint(const PickedPoint& pnt)
|
||||
{
|
||||
this->_pickedPoints.push_back(pnt);
|
||||
}
|
||||
|
@ -194,7 +194,7 @@ int AlignmentGroup::countPoints() const
|
|||
return this->_pickedPoints.size();
|
||||
}
|
||||
|
||||
const std::vector<Base::Vector3d>& AlignmentGroup::getPoints() const
|
||||
const std::vector<PickedPoint>& AlignmentGroup::getPoints() const
|
||||
{
|
||||
return this->_pickedPoints;
|
||||
}
|
||||
|
@ -206,14 +206,19 @@ void AlignmentGroup::clearPoints()
|
|||
|
||||
void AlignmentGroup::setAlignable(bool align)
|
||||
{
|
||||
//std::vector<Gui::ViewProviderDocumentObject*>::iterator it;
|
||||
//for (it = this->_views.begin(); it != this->_views.end(); ++it) {
|
||||
// if (!align){
|
||||
// App::PropertyColor* pColor = (App::PropertyColor*)(*it)->getPropertyByName("ShapeColor");
|
||||
// if (pColor)
|
||||
// pColor->touch(); // resets to color defined by property
|
||||
// }
|
||||
//}
|
||||
std::vector<Gui::ViewProviderDocumentObject*>::iterator it;
|
||||
for (it = this->_views.begin(); it != this->_views.end(); ++it) {
|
||||
App::PropertyBool* pAlignMode = dynamic_cast<App::PropertyBool*>((*it)->getPropertyByName("AlignMode"));
|
||||
if (pAlignMode) {
|
||||
pAlignMode->setValue(align);
|
||||
}
|
||||
// leaving alignment mode
|
||||
else if (!align){
|
||||
App::PropertyColor* pColor = dynamic_cast<App::PropertyColor*>((*it)->getPropertyByName("ShapeColor"));
|
||||
if (pColor)
|
||||
pColor->touch(); // resets to color defined by property
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void AlignmentGroup::moveTo(AlignmentGroup& that)
|
||||
|
@ -1001,8 +1006,8 @@ bool ManualAlignment::canAlign() const
|
|||
* This method computes the alignment. For the calculation of the alignment the picked points of both views
|
||||
* are taken. If the alignment fails false is returned, true otherwise.
|
||||
*/
|
||||
bool ManualAlignment::computeAlignment(const std::vector<Base::Vector3d>& movPts,
|
||||
const std::vector<Base::Vector3d>& fixPts)
|
||||
bool ManualAlignment::computeAlignment(const std::vector<PickedPoint>& movPts,
|
||||
const std::vector<PickedPoint>& fixPts)
|
||||
{
|
||||
assert((int)movPts.size() >= myPickPoints);
|
||||
assert((int)fixPts.size() >= myPickPoints);
|
||||
|
@ -1011,33 +1016,33 @@ bool ManualAlignment::computeAlignment(const std::vector<Base::Vector3d>& movPts
|
|||
|
||||
if (movPts.size() == 1) {
|
||||
// 1 point partial solution: Simple translation only
|
||||
myTransform.setPosition(fixPts[0] - movPts[0]);
|
||||
myTransform.setPosition(fixPts[0].point - movPts[0].point);
|
||||
}
|
||||
else if (movPts.size() == 2) {
|
||||
const Base::Vector3d& p1 = movPts[0];
|
||||
const Base::Vector3d& p2 = movPts[1];
|
||||
const Base::Vector3d& p1 = movPts[0].point;
|
||||
const Base::Vector3d& p2 = movPts[1].point;
|
||||
Base::Vector3d d1 = p2-p1;
|
||||
d1.Normalize();
|
||||
|
||||
const Base::Vector3d& q1 = fixPts[0];
|
||||
const Base::Vector3d& q2 = fixPts[1];
|
||||
const Base::Vector3d& q1 = fixPts[0].point;
|
||||
const Base::Vector3d& q2 = fixPts[1].point;
|
||||
Base::Vector3d d2 = q2-q1;
|
||||
d2.Normalize();
|
||||
|
||||
myTransform = Private::transformation2x2(p1, d1, q1, d2);
|
||||
}
|
||||
else if (movPts.size() >= 3) {
|
||||
const Base::Vector3d& p1 = movPts[0];
|
||||
const Base::Vector3d& p2 = movPts[1];
|
||||
const Base::Vector3d& p3 = movPts[2];
|
||||
const Base::Vector3d& p1 = movPts[0].point;
|
||||
const Base::Vector3d& p2 = movPts[1].point;
|
||||
const Base::Vector3d& p3 = movPts[2].point;
|
||||
Base::Vector3d d1 = p2-p1;
|
||||
d1.Normalize();
|
||||
Base::Vector3d n1 = (p2-p1) % (p3-p1);
|
||||
n1.Normalize();
|
||||
|
||||
const Base::Vector3d& q1 = fixPts[0];
|
||||
const Base::Vector3d& q2 = fixPts[1];
|
||||
const Base::Vector3d& q3 = fixPts[2];
|
||||
const Base::Vector3d& q1 = fixPts[0].point;
|
||||
const Base::Vector3d& q2 = fixPts[1].point;
|
||||
const Base::Vector3d& q3 = fixPts[2].point;
|
||||
Base::Vector3d d2 = q2-q1;
|
||||
d2.Normalize();
|
||||
Base::Vector3d n2 = (q2-q1) % (q3-q1);
|
||||
|
@ -1276,7 +1281,9 @@ bool ManualAlignment::applyPickedProbe(Gui::ViewProviderDocumentObject* prov, co
|
|||
std::vector<Base::Vector3d> pts = prov->getModelPoints(pnt);
|
||||
if (pts.empty())
|
||||
return false;
|
||||
myAlignModel.activeGroup().addPoint(pts.front());
|
||||
PickedPoint pp;
|
||||
pp.point = pts.front();
|
||||
myAlignModel.activeGroup().addPoint(pp);
|
||||
// Adds a point marker for the picked point.
|
||||
d->picksepLeft->addChild(pickedPointsSubGraph(vec, nor, myAlignModel.activeGroup().countPoints()));
|
||||
return true;
|
||||
|
@ -1285,7 +1292,9 @@ bool ManualAlignment::applyPickedProbe(Gui::ViewProviderDocumentObject* prov, co
|
|||
std::vector<Base::Vector3d> pts = prov->getModelPoints(pnt);
|
||||
if (pts.empty())
|
||||
return false;
|
||||
myFixedGroup.addPoint(pts.front());
|
||||
PickedPoint pp;
|
||||
pp.point = pts.front();
|
||||
myFixedGroup.addPoint(pp);
|
||||
// Adds a point marker for the picked point.
|
||||
d->picksepRight->addChild(pickedPointsSubGraph(vec, nor, myFixedGroup.countPoints()));
|
||||
return true;
|
||||
|
|
|
@ -41,6 +41,14 @@ class Document;
|
|||
class AlignmentView;
|
||||
class View3DInventorViewer;
|
||||
|
||||
class PickedPoint {
|
||||
public:
|
||||
PickedPoint() {}
|
||||
PickedPoint(const Base::Vector3d& p, const Base::Vector3d& n) : point(p), normal(n) {}
|
||||
Base::Vector3d point;
|
||||
Base::Vector3d normal;
|
||||
};
|
||||
|
||||
/**
|
||||
* The AlignemntGroup class is the base for fixed and movable groups.
|
||||
* @author Werner Mayer
|
||||
|
@ -81,7 +89,7 @@ public:
|
|||
/**
|
||||
* Add a point to an array of picked points.
|
||||
*/
|
||||
void addPoint(const Base::Vector3d&);
|
||||
void addPoint(const PickedPoint&);
|
||||
/**
|
||||
* Remove last point from array of picked points.
|
||||
*/
|
||||
|
@ -93,7 +101,7 @@ public:
|
|||
/**
|
||||
* Return an array of picked points.
|
||||
*/
|
||||
const std::vector<Base::Vector3d>& getPoints() const;
|
||||
const std::vector<PickedPoint>& getPoints() const;
|
||||
/**
|
||||
* Clear all picked points.
|
||||
*/
|
||||
|
@ -117,7 +125,7 @@ public:
|
|||
int count() const;
|
||||
|
||||
protected:
|
||||
std::vector<Base::Vector3d> _pickedPoints;
|
||||
std::vector<PickedPoint> _pickedPoints;
|
||||
std::vector<Gui::ViewProviderDocumentObject*> _views;
|
||||
};
|
||||
|
||||
|
@ -209,7 +217,7 @@ public:
|
|||
void slotDeletedObject(const Gui::ViewProvider& Obj);
|
||||
|
||||
protected:
|
||||
bool computeAlignment(const std::vector<Base::Vector3d>& unnavPts, const std::vector<Base::Vector3d>& navigPts);
|
||||
bool computeAlignment(const std::vector<PickedPoint>& unnavPts, const std::vector<PickedPoint>& fixPts);
|
||||
void continueAlignment();
|
||||
void showInstructions();
|
||||
/** @name Probe picking */
|
||||
|
|
Loading…
Reference in New Issue
Block a user