本文整理汇总了C++中part::Feature::purgeTouched方法的典型用法代码示例。如果您正苦于以下问题:C++ Feature::purgeTouched方法的具体用法?C++ Feature::purgeTouched怎么用?C++ Feature::purgeTouched使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类part::Feature
的用法示例。
在下文中一共展示了Feature::purgeTouched方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: apply
void CrossSections::apply()
{
std::vector<App::DocumentObject*> obj = Gui::Selection().
getObjectsOfType(Part::Feature::getClassTypeId());
std::vector<double> d;
if (ui->sectionsBox->isChecked())
d = getPlanes();
else
d.push_back(ui->position->value().getValue());
double a=0,b=0,c=0;
switch (plane()) {
case CrossSections::XY:
c = 1.0;
break;
case CrossSections::XZ:
b = 1.0;
break;
case CrossSections::YZ:
a = 1.0;
break;
}
#ifdef CS_FUTURE
Standard::SetReentrant(Standard_True);
for (std::vector<App::DocumentObject*>::iterator it = obj.begin(); it != obj.end(); ++it) {
Part::CrossSection cs(a,b,c,static_cast<Part::Feature*>(*it)->Shape.getValue());
QFuture< std::list<TopoDS_Wire> > future = QtConcurrent::mapped
(d, boost::bind(&Part::CrossSection::section, &cs, _1));
future.waitForFinished();
QFuture< std::list<TopoDS_Wire> >::const_iterator ft;
TopoDS_Compound comp;
BRep_Builder builder;
builder.MakeCompound(comp);
for (ft = future.begin(); ft != future.end(); ++ft) {
const std::list<TopoDS_Wire>& w = *ft;
for (std::list<TopoDS_Wire>::const_iterator wt = w.begin(); wt != w.end(); ++wt) {
if (!wt->IsNull())
builder.Add(comp, *wt);
}
}
App::Document* doc = (*it)->getDocument();
std::string s = (*it)->getNameInDocument();
s += "_cs";
Part::Feature* section = static_cast<Part::Feature*>
(doc->addObject("Part::Feature",s.c_str()));
section->Shape.setValue(comp);
section->purgeTouched();
}
#else
Base::SequencerLauncher seq("Cross-sections...", obj.size() * (d.size() +1));
Gui::Command::runCommand(Gui::Command::App, "import Part\n");
Gui::Command::runCommand(Gui::Command::App, "from FreeCAD import Base\n");
for (std::vector<App::DocumentObject*>::iterator it = obj.begin(); it != obj.end(); ++it) {
App::Document* doc = (*it)->getDocument();
std::string s = (*it)->getNameInDocument();
s += "_cs";
Gui::Command::runCommand(Gui::Command::App, QString::fromLatin1(
"wires=list()\n"
"shape=FreeCAD.getDocument(\"%1\").%2.Shape\n")
.arg(QLatin1String(doc->getName()))
.arg(QLatin1String((*it)->getNameInDocument())).toLatin1());
for (std::vector<double>::iterator jt = d.begin(); jt != d.end(); ++jt) {
Gui::Command::runCommand(Gui::Command::App, QString::fromLatin1(
"for i in shape.slice(Base.Vector(%1,%2,%3),%4):\n"
" wires.append(i)\n"
).arg(a).arg(b).arg(c).arg(*jt).toLatin1());
seq.next();
}
Gui::Command::runCommand(Gui::Command::App, QString::fromLatin1(
"comp=Part.Compound(wires)\n"
"slice=FreeCAD.getDocument(\"%1\").addObject(\"Part::Feature\",\"%2\")\n"
"slice.Shape=comp\n"
"slice.purgeTouched()\n"
"del slice,comp,wires,shape")
.arg(QLatin1String(doc->getName()))
.arg(QLatin1String(s.c_str())).toLatin1());
seq.next();
}
#endif
}