+ function to create points from mesh
This commit is contained in:
parent
a5e6edff87
commit
288841cf98
|
@ -252,6 +252,16 @@ MeshPoint MeshObject::getPoint(unsigned long index) const
|
|||
return point;
|
||||
}
|
||||
|
||||
void MeshObject::getPoints(std::vector<Base::Vector3d> &Points,
|
||||
float Accuracy, uint16_t flags) const
|
||||
{
|
||||
unsigned long ctpoints = _kernel.CountPoints();
|
||||
Points.reserve(ctpoints);
|
||||
for (unsigned long i=0; i<ctpoints; i++) {
|
||||
Points.push_back(this->getPoint(i));
|
||||
}
|
||||
}
|
||||
|
||||
Mesh::Facet MeshObject::getFacet(unsigned long index) const
|
||||
{
|
||||
Mesh::Facet face(_kernel.GetFacets()[index], const_cast<MeshObject*>(this), index);
|
||||
|
|
|
@ -127,7 +127,10 @@ public:
|
|||
Mesh::Facet getFacet(unsigned long) const;
|
||||
double getSurface() const;
|
||||
double getVolume() const;
|
||||
void getFaces(std::vector<Base::Vector3d> &Points,std::vector<Facet> &Topo,
|
||||
/** Get points from object with given accuracy */
|
||||
virtual void getPoints(std::vector<Base::Vector3d> &Points,
|
||||
float Accuracy, uint16_t flags=0) const;
|
||||
virtual void getFaces(std::vector<Base::Vector3d> &Points,std::vector<Facet> &Topo,
|
||||
float Accuracy, uint16_t flags=0) const;
|
||||
std::vector<unsigned long> getPointsFromFacets(const std::vector<unsigned long>& facets) const;
|
||||
//@}
|
||||
|
|
|
@ -173,6 +173,48 @@ bool CmdPointsTransform::isActive(void)
|
|||
return getSelection().countObjectsOfType(Points::Feature::getClassTypeId()) > 0;
|
||||
}
|
||||
|
||||
DEF_STD_CMD_A(CmdPointsConvert);
|
||||
|
||||
CmdPointsConvert::CmdPointsConvert()
|
||||
:Command("Points_Convert")
|
||||
{
|
||||
sAppModule = "Points";
|
||||
sGroup = QT_TR_NOOP("Points");
|
||||
sMenuText = QT_TR_NOOP("Convert to points");
|
||||
sToolTipText = QT_TR_NOOP("Convert to points");
|
||||
sWhatsThis = QT_TR_NOOP("Convert to points");
|
||||
sStatusTip = QT_TR_NOOP("Convert to points");
|
||||
}
|
||||
|
||||
void CmdPointsConvert::activated(int iMsg)
|
||||
{
|
||||
openCommand("Convert to points");
|
||||
std::vector<App::DocumentObject*> meshes = getSelection().getObjectsOfType(Base::Type::fromName("Mesh::Feature"));
|
||||
for (std::vector<App::DocumentObject*>::iterator it = meshes.begin(); it != meshes.end(); ++it) {
|
||||
App::PropertyComplexGeoData* prop = dynamic_cast<App::PropertyComplexGeoData*>((*it)->getPropertyByName("Mesh"));
|
||||
if (prop) {
|
||||
const Data::ComplexGeoData* data = prop->getComplexData();
|
||||
std::vector<Base::Vector3d> vertexes;
|
||||
data->getPoints(vertexes, 0.0f);
|
||||
if (!vertexes.empty()) {
|
||||
App::Document* doc = (*it)->getDocument();
|
||||
Points::Feature* fea = static_cast<Points::Feature*>(doc->addObject("Points::Feature", "Points"));
|
||||
Points::PointKernel kernel;
|
||||
kernel.reserve(vertexes.size());
|
||||
for (std::vector<Base::Vector3d>::iterator pt = vertexes.begin(); pt != vertexes.end(); ++pt)
|
||||
kernel.push_back(*pt);
|
||||
fea->Points.setValue(kernel);
|
||||
}
|
||||
}
|
||||
}
|
||||
commitCommand();
|
||||
}
|
||||
|
||||
bool CmdPointsConvert::isActive(void)
|
||||
{
|
||||
return getSelection().countObjectsOfType(Base::Type::fromName("Mesh::Feature")) > 0;
|
||||
}
|
||||
|
||||
DEF_STD_CMD_A(CmdPointsPolyCut);
|
||||
|
||||
CmdPointsPolyCut::CmdPointsPolyCut()
|
||||
|
@ -222,5 +264,6 @@ void CreatePointsCommands(void)
|
|||
rcCmdMgr.addCommand(new CmdPointsImport());
|
||||
rcCmdMgr.addCommand(new CmdPointsExport());
|
||||
rcCmdMgr.addCommand(new CmdPointsTransform());
|
||||
rcCmdMgr.addCommand(new CmdPointsConvert());
|
||||
rcCmdMgr.addCommand(new CmdPointsPolyCut());
|
||||
}
|
||||
|
|
|
@ -74,13 +74,9 @@ Gui::MenuItem* Workbench::setupMenuBar() const
|
|||
Gui::MenuItem* item = root->findItem("&Windows");
|
||||
Gui::MenuItem* pnts = new Gui::MenuItem;
|
||||
root->insertItem(item, pnts);
|
||||
|
||||
Gui::MenuItem* test = new Gui::MenuItem;
|
||||
test->setCommand("Test");
|
||||
*test << "Points_Transform";
|
||||
|
||||
pnts->setCommand("&Points");
|
||||
*pnts << test << "Separator" << "Points_Import" << "Points_Export" << "Separator" << "Points_PolyCut";
|
||||
*pnts << "Points_Convert" << "Separator" << "Points_Import" << "Points_Export" << "Separator" << "Points_PolyCut";
|
||||
return root;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user