+ get also back normals from MeshObject::getPoints
This commit is contained in:
parent
0ea6a2ed0d
commit
70f58672c7
|
@ -256,10 +256,28 @@ void MeshObject::getPoints(std::vector<Base::Vector3d> &Points,
|
||||||
std::vector<Base::Vector3d> &Normals,
|
std::vector<Base::Vector3d> &Normals,
|
||||||
float Accuracy, uint16_t flags) const
|
float Accuracy, uint16_t flags) const
|
||||||
{
|
{
|
||||||
|
Base::Matrix4D mat = _Mtrx;
|
||||||
|
|
||||||
unsigned long ctpoints = _kernel.CountPoints();
|
unsigned long ctpoints = _kernel.CountPoints();
|
||||||
Points.reserve(ctpoints);
|
Points.reserve(ctpoints);
|
||||||
for (unsigned long i=0; i<ctpoints; i++) {
|
for (unsigned long i=0; i<ctpoints; i++) {
|
||||||
Points.push_back(this->getPoint(i));
|
Base::Vector3f vertf = _kernel.GetPoint(i);
|
||||||
|
Base::Vector3d vertd(vertf.x, vertf.y, vertf.z);
|
||||||
|
vertd = mat * vertd;
|
||||||
|
Points.push_back(vertd);
|
||||||
|
}
|
||||||
|
|
||||||
|
// nullify translation part
|
||||||
|
mat[0][3] = 0.0;
|
||||||
|
mat[1][3] = 0.0;
|
||||||
|
mat[2][3] = 0.0;
|
||||||
|
Normals.reserve(ctpoints);
|
||||||
|
MeshCore::MeshRefNormalToPoints ptNormals(_kernel);
|
||||||
|
for (unsigned long i=0; i<ctpoints; i++) {
|
||||||
|
Base::Vector3f normalf = ptNormals[i];
|
||||||
|
Base::Vector3d normald(normalf.x, normalf.y, normalf.z);
|
||||||
|
normald = mat * normald;
|
||||||
|
Normals.push_back(normald);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -193,7 +193,8 @@ void PointKernel::save(std::ostream& out) const
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void PointKernel::getFaces(std::vector<Base::Vector3d> &Points,std::vector<Facet> &Topo,
|
void PointKernel::getPoints(std::vector<Base::Vector3d> &Points,
|
||||||
|
std::vector<Base::Vector3d> &Normals,
|
||||||
float Accuracy, uint16_t flags) const
|
float Accuracy, uint16_t flags) const
|
||||||
{
|
{
|
||||||
unsigned long ctpoints = _Points.size();
|
unsigned long ctpoints = _Points.size();
|
||||||
|
|
|
@ -85,9 +85,10 @@ public:
|
||||||
{ this->_Points = pts; }
|
{ this->_Points = pts; }
|
||||||
void swap(std::vector<value_type>& pts)
|
void swap(std::vector<value_type>& pts)
|
||||||
{ this->_Points.swap(pts); }
|
{ this->_Points.swap(pts); }
|
||||||
void getFaces(std::vector<Base::Vector3d> &Points,std::vector<Facet> &Topo,
|
|
||||||
float Accuracy, uint16_t flags=0) const;
|
|
||||||
|
|
||||||
|
virtual void getPoints(std::vector<Base::Vector3d> &Points,
|
||||||
|
std::vector<Base::Vector3d> &Normals,
|
||||||
|
float Accuracy, uint16_t flags=0) const;
|
||||||
virtual void transformGeometry(const Base::Matrix4D &rclMat);
|
virtual void transformGeometry(const Base::Matrix4D &rclMat);
|
||||||
virtual Base::BoundBox3d getBoundBox(void)const;
|
virtual Base::BoundBox3d getBoundBox(void)const;
|
||||||
|
|
||||||
|
|
|
@ -101,25 +101,27 @@ void CmdApproxPlane::activated(int iMsg)
|
||||||
{
|
{
|
||||||
std::vector<App::GeoFeature*> obj = Gui::Selection().getObjectsOfType<App::GeoFeature>();
|
std::vector<App::GeoFeature*> obj = Gui::Selection().getObjectsOfType<App::GeoFeature>();
|
||||||
for (std::vector<App::GeoFeature*>::iterator it = obj.begin(); it != obj.end(); ++it) {
|
for (std::vector<App::GeoFeature*>::iterator it = obj.begin(); it != obj.end(); ++it) {
|
||||||
std::map<std::string, App::Property*> Map;
|
|
||||||
(*it)->getPropertyMap(Map);
|
|
||||||
for (std::map<std::string, App::Property*>::iterator jt = Map.begin(); jt != Map.end(); ++jt) {
|
|
||||||
if (jt->second->getTypeId().isDerivedFrom(App::PropertyComplexGeoData::getClassTypeId())) {
|
|
||||||
std::vector<Base::Vector3d> aPoints;
|
std::vector<Base::Vector3d> aPoints;
|
||||||
std::vector<Data::ComplexGeoData::Facet> aTopo;
|
std::vector<Base::Vector3d> aNormals;
|
||||||
const Data::ComplexGeoData* data = static_cast<App::PropertyComplexGeoData*>(jt->second)->getComplexData();
|
|
||||||
if (!data)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
data->getFaces(aPoints, aTopo,0.01f);
|
std::vector<App::Property*> List;
|
||||||
|
(*it)->getPropertyList(List);
|
||||||
|
for (std::vector<App::Property*>::iterator jt = List.begin(); jt != List.end(); ++jt) {
|
||||||
|
if ((*jt)->getTypeId().isDerivedFrom(App::PropertyComplexGeoData::getClassTypeId())) {
|
||||||
|
const Data::ComplexGeoData* data = static_cast<App::PropertyComplexGeoData*>(*jt)->getComplexData();
|
||||||
|
if (data) {
|
||||||
|
data->getPoints(aPoints, aNormals, 0.01f);
|
||||||
|
if (!aPoints.empty())
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!aPoints.empty()) {
|
||||||
// get a reference normal for the plane fit
|
// get a reference normal for the plane fit
|
||||||
Base::Vector3f refNormal(0,0,0);
|
Base::Vector3f refNormal(0,0,0);
|
||||||
if (!aTopo.empty()) {
|
if (!aNormals.empty()) {
|
||||||
Data::ComplexGeoData::Facet f = aTopo.front();
|
refNormal = Base::convertTo<Base::Vector3f>(aNormals.front());
|
||||||
Base::Vector3d v1 = aPoints[f.I2] - aPoints[f.I1];
|
|
||||||
Base::Vector3d v2 = aPoints[f.I3] - aPoints[f.I1];
|
|
||||||
refNormal = Base::convertTo<Base::Vector3f>(v1 % v2);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<Base::Vector3f> aData;
|
std::vector<Base::Vector3f> aData;
|
||||||
|
@ -174,7 +176,6 @@ void CmdApproxPlane::activated(int iMsg)
|
||||||
updateActive();
|
updateActive();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CmdApproxPlane::isActive(void)
|
bool CmdApproxPlane::isActive(void)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user