本文整理汇总了C++中sketcher::SketchObject::getInternalGeometry方法的典型用法代码示例。如果您正苦于以下问题:C++ SketchObject::getInternalGeometry方法的具体用法?C++ SketchObject::getInternalGeometry怎么用?C++ SketchObject::getInternalGeometry使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sketcher::SketchObject
的用法示例。
在下文中一共展示了SketchObject::getInternalGeometry方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: activated
void CmdSketcherMirrorSketch::activated(int iMsg)
{
std::vector<Gui::SelectionObject> selection = getSelection().getSelectionEx(0, Sketcher::SketchObject::getClassTypeId());
if (selection.size() < 1) {
QMessageBox::warning(Gui::getMainWindow(),
qApp->translate("CmdSketcherMirrorSketch", "Wrong selection"),
qApp->translate("CmdSketcherMirrorSketch", "Select one or more sketches, please."));
return;
}
// Ask the user which kind of mirroring he wants
SketchMirrorDialog * smd = new SketchMirrorDialog();
int refgeoid=-1;
Sketcher::PointPos refposid=Sketcher::none;
if( smd->exec() == QDialog::Accepted ){
refgeoid=smd->RefGeoid;
refposid=smd->RefPosid;
delete smd;
}
else {
delete smd;
return;
}
App::Document* doc = App::GetApplication().getActiveDocument();
openCommand("Create a mirror Sketch for each sketch");
for (std::vector<Gui::SelectionObject>::const_iterator it=selection.begin(); it != selection.end(); ++it) {
// create Sketch
std::string FeatName = getUniqueObjectName("MirroredSketch");
doCommand(Doc,"App.activeDocument().addObject('Sketcher::SketchObject','%s')",FeatName.c_str());
Sketcher::SketchObject* mirrorsketch = static_cast<Sketcher::SketchObject*>(doc->getObject(FeatName.c_str()));
const Sketcher::SketchObject* Obj = static_cast<const Sketcher::SketchObject*>((*it).getObject());
Base::Placement pl = Obj->Placement.getValue();
Base::Vector3d p = pl.getPosition();
Base::Rotation r = pl.getRotation();
doCommand(Doc,"App.activeDocument().%s.Placement = App.Placement(App.Vector(%f,%f,%f),App.Rotation(%f,%f,%f,%f))",
FeatName.c_str(),
p.x,p.y,p.z,r[0],r[1],r[2],r[3]);
Sketcher::SketchObject* tempsketch = new Sketcher::SketchObject();
int addedGeometries=tempsketch->addGeometry(Obj->getInternalGeometry());
int addedConstraints=tempsketch->addConstraints(Obj->Constraints.getValues());
std::vector<int> geoIdList;
for(int i=0;i<=addedGeometries;i++)
geoIdList.push_back(i);
tempsketch->addSymmetric(geoIdList, refgeoid, refposid);
std::vector<Part::Geometry *> tempgeo = tempsketch->getInternalGeometry();
std::vector<Sketcher::Constraint *> tempconstr = tempsketch->Constraints.getValues();
std::vector<Part::Geometry *> mirrorgeo (tempgeo.begin()+addedGeometries+1,tempgeo.end());
std::vector<Sketcher::Constraint *> mirrorconstr (tempconstr.begin()+addedConstraints+1,tempconstr.end());
for(std::vector<Sketcher::Constraint *>::const_iterator itc=mirrorconstr.begin(); itc != mirrorconstr.end(); ++itc) {
if((*itc)->First!=Sketcher::Constraint::GeoUndef || (*itc)->First==-1 || (*itc)->First==-2) // not x, y axes or origin
(*itc)->First-=(addedGeometries+1);
if((*itc)->Second!=Sketcher::Constraint::GeoUndef || (*itc)->Second==-1 || (*itc)->Second==-2) // not x, y axes or origin
(*itc)->Second-=(addedGeometries+1);
if((*itc)->Third!=Sketcher::Constraint::GeoUndef || (*itc)->Third==-1 || (*itc)->Third==-2) // not x, y axes or origin
(*itc)->Third-=(addedGeometries+1);
}
mirrorsketch->addGeometry(mirrorgeo);
mirrorsketch->addConstraints(mirrorconstr);
delete tempsketch;
}
doCommand(Gui,"App.activeDocument().recompute()");
}