本文整理汇总了C++中base::BoundBox3d::GetCenter方法的典型用法代码示例。如果您正苦于以下问题:C++ BoundBox3d::GetCenter方法的具体用法?C++ BoundBox3d::GetCenter怎么用?C++ BoundBox3d::GetCenter使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类base::BoundBox3d
的用法示例。
在下文中一共展示了BoundBox3d::GetCenter方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: setEdit
bool ViewProviderMirror::setEdit(int ModNum)
{
if (ModNum == ViewProvider::Default) {
// get the properties from the mirror feature
Part::Mirroring* mf = static_cast<Part::Mirroring*>(getObject());
Base::BoundBox3d bbox = mf->Shape.getBoundingBox();
float len = (float)bbox.CalcDiagonalLength();
Base::Vector3d base = mf->Base.getValue();
Base::Vector3d norm = mf->Normal.getValue();
Base::Vector3d cent = bbox.GetCenter();
base = cent.ProjToPlane(base, norm);
// setup the graph for editing the mirror plane
SoTransform* trans = new SoTransform;
SbRotation rot(SbVec3f(0,0,1), SbVec3f(norm.x,norm.y,norm.z));
trans->rotation.setValue(rot);
trans->translation.setValue(base.x,base.y,base.z);
trans->center.setValue(0.0f,0.0f,0.0f);
SoMaterial* color = new SoMaterial();
color->diffuseColor.setValue(0,0,1);
color->transparency.setValue(0.5);
SoCoordinate3* points = new SoCoordinate3();
points->point.setNum(4);
points->point.set1Value(0, -len/2,-len/2,0);
points->point.set1Value(1, len/2,-len/2,0);
points->point.set1Value(2, len/2, len/2,0);
points->point.set1Value(3, -len/2, len/2,0);
SoFaceSet* face = new SoFaceSet();
pcEditNode->addChild(trans);
pcEditNode->addChild(color);
pcEditNode->addChild(points);
pcEditNode->addChild(face);
// Now we replace the SoTransform node by a manipulator
// Note: Even SoCenterballManip inherits from SoTransform
// we cannot use it directly (in above code) because the
// translation and center fields are overridden.
SoSearchAction sa;
sa.setInterest(SoSearchAction::FIRST);
sa.setSearchingAll(FALSE);
sa.setNode(trans);
sa.apply(pcEditNode);
SoPath * path = sa.getPath();
if (path) {
SoCenterballManip * manip = new SoCenterballManip;
manip->replaceNode(path);
SoDragger* dragger = manip->getDragger();
dragger->addStartCallback(dragStartCallback, this);
dragger->addFinishCallback(dragFinishCallback, this);
dragger->addMotionCallback(dragMotionCallback, this);
}
pcRoot->addChild(pcEditNode);
}
else {
ViewProviderPart::setEdit(ModNum);
}
return true;
}
示例2: execute
App::DocumentObjectExecReturn *DrawViewSection::execute(void)
{
App::DocumentObject* link = Source.getValue();
App::DocumentObject* base = BaseView.getValue();
if (!link || !base) {
Base::Console().Log("INFO - DVS::execute - No Source or Link - creation?\n");
return DrawView::execute();
}
if (!link->getTypeId().isDerivedFrom(Part::Feature::getClassTypeId()))
return new App::DocumentObjectExecReturn("Source object is not a Part object");
if (!base->getTypeId().isDerivedFrom(TechDraw::DrawViewPart::getClassTypeId()))
return new App::DocumentObjectExecReturn("BaseView object is not a DrawViewPart object");
//Base::Console().Message("TRACE - DVS::execute() - %s/%s\n",getNameInDocument(),Label.getValue());
const Part::TopoShape &partTopo = static_cast<Part::Feature*>(link)->Shape.getShape();
if (partTopo.getShape().IsNull())
return new App::DocumentObjectExecReturn("Linked shape object is empty");
(void) DrawView::execute(); //make sure Scale is up to date
gp_Pln pln = getSectionPlane();
gp_Dir gpNormal = pln.Axis().Direction();
Base::Vector3d orgPnt = SectionOrigin.getValue();
Base::BoundBox3d bb = partTopo.getBoundBox();
if(!isReallyInBox(orgPnt, bb)) {
Base::Console().Warning("DVS: Section Plane doesn't intersect part in %s\n",getNameInDocument());
Base::Console().Warning("DVS: Using center of bounding box.\n");
orgPnt = bb.GetCenter();
SectionOrigin.setValue(orgPnt);
}
// Make the extrusion face
double dMax = bb.CalcDiagonalLength();
BRepBuilderAPI_MakeFace mkFace(pln, -dMax,dMax,-dMax,dMax);
TopoDS_Face aProjFace = mkFace.Face();
if(aProjFace.IsNull())
return new App::DocumentObjectExecReturn("DrawViewSection - Projected face is NULL");
gp_Vec extrudeDir = dMax * gp_Vec(gpNormal);
TopoDS_Shape prism = BRepPrimAPI_MakePrism(aProjFace, extrudeDir, false, true).Shape();
// We need to copy the shape to not modify the BRepstructure
BRepBuilderAPI_Copy BuilderCopy(partTopo.getShape());
TopoDS_Shape myShape = BuilderCopy.Shape();
BRepAlgoAPI_Cut mkCut(myShape, prism);
if (!mkCut.IsDone())
return new App::DocumentObjectExecReturn("Section cut has failed");
TopoDS_Shape rawShape = mkCut.Shape();
Bnd_Box testBox;
BRepBndLib::Add(rawShape, testBox);
testBox.SetGap(0.0);
if (testBox.IsVoid()) { //prism & input don't intersect. rawShape is garbage, don't bother.
Base::Console().Log("INFO - DVS::execute - prism & input don't intersect\n");
return DrawView::execute();
}
gp_Pnt inputCenter;
try {
inputCenter = TechDrawGeometry::findCentroid(rawShape,
Direction.getValue());
TopoDS_Shape mirroredShape = TechDrawGeometry::mirrorShape(rawShape,
inputCenter,
Scale.getValue());
geometryObject = buildGeometryObject(mirroredShape,inputCenter); //this is original shape after cut by section prism
#if MOD_TECHDRAW_HANDLE_FACES
extractFaces();
#endif //#if MOD_TECHDRAW_HANDLE_FACES
}
catch (Standard_Failure) {
Handle_Standard_Failure e1 = Standard_Failure::Caught();
Base::Console().Log("LOG - DVS::execute - base shape failed for %s - %s **\n",getNameInDocument(),e1->GetMessageString());
return new App::DocumentObjectExecReturn(e1->GetMessageString());
}
try {
TopoDS_Compound sectionCompound = findSectionPlaneIntersections(rawShape);
TopoDS_Shape mirroredSection = TechDrawGeometry::mirrorShape(sectionCompound,
inputCenter,
Scale.getValue());
TopoDS_Compound newFaces;
BRep_Builder builder;
builder.MakeCompound(newFaces);
TopExp_Explorer expl(mirroredSection, TopAbs_FACE);
for (; expl.More(); expl.Next()) {
const TopoDS_Face& face = TopoDS::Face(expl.Current());
TopoDS_Face pFace = projectFace(face,
inputCenter,
Direction.getValue());
if (!pFace.IsNull()) {
builder.Add(newFaces,pFace);
}
}
//.........这里部分代码省略.........
示例3: SearchNearestFromPoint
void PointsGrid::SearchNearestFromPoint (const Base::Vector3d &rclPt, std::set<unsigned long> &raclInd) const
{
raclInd.clear();
Base::BoundBox3d clBB = GetBoundBox();
if (clBB.IsInBox(rclPt) == true)
{ // Punkt liegt innerhalb
unsigned long ulX, ulY, ulZ;
Position(rclPt, ulX, ulY, ulZ);
//int nX = ulX, nY = ulY, nZ = ulZ;
unsigned long ulLevel = 0;
while (raclInd.size() == 0)
GetHull(ulX, ulY, ulZ, ulLevel++, raclInd);
GetHull(ulX, ulY, ulZ, ulLevel, raclInd);
}
else
{ // Punkt ausserhalb
Base::BoundBox3d::SIDE tSide = clBB.GetSideFromRay(rclPt, clBB.GetCenter() - rclPt);
switch (tSide)
{
case Base::BoundBox3d::RIGHT:
{
int nX = 0;
while (raclInd.size() == 0)
{
for (unsigned long i = 0; i < _ulCtGridsY; i++)
{
for (unsigned long j = 0; j < _ulCtGridsZ; j++)
raclInd.insert(_aulGrid[nX][i][j].begin(), _aulGrid[nX][i][j].end());
}
nX++;
}
break;
}
case Base::BoundBox3d::LEFT:
{
int nX = _ulCtGridsX - 1;
while (raclInd.size() == 0)
{
for (unsigned long i = 0; i < _ulCtGridsY; i++)
{
for (unsigned long j = 0; j < _ulCtGridsZ; j++)
raclInd.insert(_aulGrid[nX][i][j].begin(), _aulGrid[nX][i][j].end());
}
nX++;
}
break;
}
case Base::BoundBox3d::TOP:
{
int nY = 0;
while (raclInd.size() == 0)
{
for (unsigned long i = 0; i < _ulCtGridsX; i++)
{
for (unsigned long j = 0; j < _ulCtGridsZ; j++)
raclInd.insert(_aulGrid[i][nY][j].begin(), _aulGrid[i][nY][j].end());
}
nY++;
}
break;
}
case Base::BoundBox3d::BOTTOM:
{
int nY = _ulCtGridsY - 1;
while (raclInd.size() == 0)
{
for (unsigned long i = 0; i < _ulCtGridsX; i++)
{
for (unsigned long j = 0; j < _ulCtGridsZ; j++)
raclInd.insert(_aulGrid[i][nY][j].begin(), _aulGrid[i][nY][j].end());
}
nY--;
}
break;
}
case Base::BoundBox3d::BACK:
{
int nZ = 0;
while (raclInd.size() == 0)
{
for (unsigned long i = 0; i < _ulCtGridsX; i++)
{
for (unsigned long j = 0; j < _ulCtGridsY; j++)
raclInd.insert(_aulGrid[i][j][nZ].begin(), _aulGrid[i][j][nZ].end());
}
nZ++;
}
break;
}
case Base::BoundBox3d::FRONT:
{
int nZ = _ulCtGridsZ - 1;
while (raclInd.size() == 0)
{
for (unsigned long i = 0; i < _ulCtGridsX; i++)
{
for (unsigned long j = 0; j < _ulCtGridsY; j++)
raclInd.insert(_aulGrid[i][j][nZ].begin(), _aulGrid[i][j][nZ].end());
}
//.........这里部分代码省略.........