• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C++ TopExp_Explorer类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中TopExp_Explorer的典型用法代码示例。如果您正苦于以下问题:C++ TopExp_Explorer类的具体用法?C++ TopExp_Explorer怎么用?C++ TopExp_Explorer使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了TopExp_Explorer类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: getVerifiedSketch

std::vector<TopoDS_Wire> SketchBased::getSketchWires() const {
    std::vector<TopoDS_Wire> result;

    TopoDS_Shape shape = getVerifiedSketch()->Shape.getShape()._Shape;
    if (shape.IsNull())
        throw Base::Exception("Linked shape object is empty");

    // this is a workaround for an obscure OCC bug which leads to empty tessellations
    // for some faces. Making an explicit copy of the linked shape seems to fix it.
    // The error almost happens when re-computing the shape but sometimes also for the
    // first time
    BRepBuilderAPI_Copy copy(shape);
    shape = copy.Shape();
    if (shape.IsNull())
        throw Base::Exception("Linked shape object is empty");

    TopExp_Explorer ex;
    for (ex.Init(shape, TopAbs_WIRE); ex.More(); ex.Next()) {
        result.push_back(TopoDS::Wire(ex.Current()));
    }
    if (result.empty()) // there can be several wires
        throw Base::Exception("Linked shape object is not a wire");

    return result;
}
开发者ID:Didier94,项目名称:FreeCAD_sf_master,代码行数:25,代码来源:FeatureSketchBased.cpp


示例2: canExtrude

bool DlgExtrusion::canExtrude(const TopoDS_Shape& shape) const
{
    if (shape.IsNull())
        return false;
    TopAbs_ShapeEnum type = shape.ShapeType();
    if (type == TopAbs_VERTEX || type == TopAbs_EDGE ||
            type == TopAbs_WIRE || type == TopAbs_FACE ||
            type == TopAbs_SHELL)
        return true;
    if (type == TopAbs_COMPOUND) {
        TopExp_Explorer xp;
        xp.Init(shape,TopAbs_SOLID);
        while (xp.More()) {
            return false;
        }
        xp.Init(shape,TopAbs_COMPSOLID);
        while (xp.More()) {
            return false;
        }

        return true;
    }

    return false;
}
开发者ID:davidlni,项目名称:FreeCAD,代码行数:25,代码来源:DlgExtrusion.cpp


示例3: findShapes

void DlgRevolution::findShapes()
{
    App::Document* activeDoc = App::GetApplication().getActiveDocument();
    if (!activeDoc) return;
    Gui::Document* activeGui = Gui::Application::Instance->getDocument(activeDoc);

    std::vector<App::DocumentObject*> objs = activeDoc->getObjectsOfType
        (Part::Feature::getClassTypeId());
    for (std::vector<App::DocumentObject*>::iterator it = objs.begin(); it!=objs.end(); ++it) {
        const TopoDS_Shape& shape = static_cast<Part::Feature*>(*it)->Shape.getValue();
        if (shape.IsNull()) continue;

        TopExp_Explorer xp;
        xp.Init(shape,TopAbs_SOLID);
        if (xp.More()) continue; // solids not allowed
        xp.Init(shape,TopAbs_COMPSOLID);
        if (xp.More()) continue; // compound solids not allowed
        // So allowed are: vertex, edge, wire, face, shell and compound
        QTreeWidgetItem* item = new QTreeWidgetItem(ui->treeWidget);
        item->setText(0, QString::fromUtf8((*it)->Label.getValue()));
        item->setData(0, Qt::UserRole, QString::fromLatin1((*it)->getNameInDocument()));
        Gui::ViewProvider* vp = activeGui->getViewProvider(*it);
        if (vp) item->setIcon(0, vp->getIcon());
    }
}
开发者ID:crobarcro,项目名称:FreeCAD,代码行数:25,代码来源:DlgRevolution.cpp


示例4: goSetupResultTypedSelection

void PartGui::goSetupResultTypedSelection(ResultEntry* entry, const TopoDS_Shape& shape, TopAbs_ShapeEnum type)
{
    TopExp_Explorer it;
    for (it.Init(shape, type); it.More(); it.Next())
    {
        QString name = buildSelectionName(entry, (it.Current()));
        if (!name.isEmpty())
            entry->selectionStrings.append(name);
    }
}
开发者ID:3DPrinterGuy,项目名称:FreeCAD,代码行数:10,代码来源:TaskCheckGeometry.cpp


示例5: GetCentralFacePoint

gp_Pnt GetCentralFacePoint(const TopoDS_Face& face)
{
    // compute point on face
    Standard_Real umin, umax, vmin, vmax;

    gp_Pnt p;

    Handle(Geom_Surface) surface = BRep_Tool::Surface(face);
    BRepTools::UVBounds(face, umin, umax, vmin, vmax);
    Standard_Real umean = 0.5*(umin+umax);
    Standard_Real vmean = 0.5*(vmin+vmax);


    // compute intersection of u-iso line with face boundaries
    Handle(Geom2d_Curve) uiso = new Geom2d_Line(
                gp_Pnt2d(umean,0.),
                gp_Dir2d(0., 1.)
                );

    TopExp_Explorer exp (face,TopAbs_EDGE);
    std::list<double> intersections;
    for (; exp.More(); exp.Next()) {
        TopoDS_Edge edge = TopoDS::Edge(exp.Current());
        Standard_Real first, last;

        // Get geomteric curve from edge
        Handle(Geom2d_Curve) hcurve = BRep_Tool::CurveOnSurface(edge, face, first, last);
        hcurve = new Geom2d_TrimmedCurve(hcurve, first, last);

        Geom2dAPI_InterCurveCurve intersector(uiso, hcurve);
        for (int ipoint = 0; ipoint < intersector.NbPoints(); ++ipoint) {
            gp_Pnt2d p = intersector.Point(ipoint+1);
            intersections.push_back(p.Y());
        }
    }

    // remove duplicate solutions defined by tolerance
    double tolerance = 1e-5;
    intersections.sort();
    intersections.unique(IsSame((vmax-vmin)*tolerance));

    // normally we should have at least two intersections
    // also the number of sections should be even - else something is really strange
    //assert(intersections.size() % 2 == 0);
    if (intersections.size() >= 2) {
        std::list<double>::iterator it = intersections.begin();
        double int1 = *it++;
        double int2 = *it;
        vmean = (int1 + int2)/2.;
    }

    surface->D0(umean, vmean, p);

    return p;
}
开发者ID:Felipeasg,项目名称:tigl,代码行数:55,代码来源:tiglcommonfunctions.cpp


示例6: getSelection

void CmdPartDesignPad::activated(int iMsg)
{
    unsigned int n = getSelection().countObjectsOfType(Part::Part2DObject::getClassTypeId());
    if (n != 1) {
        QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Wrong selection"),
            QObject::tr("Select a sketch or 2D object."));
        return;
    }

    std::string FeatName = getUniqueObjectName("Pad");

    std::vector<App::DocumentObject*> Sel = getSelection().getObjectsOfType(Part::Part2DObject::getClassTypeId());
    Part::Part2DObject* sketch = static_cast<Part::Part2DObject*>(Sel.front());
    const TopoDS_Shape& shape = sketch->Shape.getValue();
    if (shape.IsNull()) {
        QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Wrong selection"),
            QObject::tr("The shape of the selected object is empty."));
        return;
    }

    // count free wires
    int ctWires=0;
    TopExp_Explorer ex;
    for (ex.Init(shape, TopAbs_WIRE); ex.More(); ex.Next()) {
        ctWires++;
    }
    if (ctWires == 0) {
        QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Wrong selection"),
            QObject::tr("The shape of the selected object is not a wire."));
        return;
    }

    App::DocumentObject* support = sketch->Support.getValue();

    openCommand("Make Pad");
    doCommand(Doc,"App.activeDocument().addObject(\"PartDesign::Pad\",\"%s\")",FeatName.c_str());
    doCommand(Doc,"App.activeDocument().%s.Sketch = App.activeDocument().%s",FeatName.c_str(),sketch->getNameInDocument());
    doCommand(Doc,"App.activeDocument().%s.Length = 10.0",FeatName.c_str());
    updateActive();
    if (isActiveObjectValid()) {
        doCommand(Gui,"Gui.activeDocument().hide(\"%s\")",sketch->getNameInDocument());
        if (support)
            doCommand(Gui,"Gui.activeDocument().hide(\"%s\")",support->getNameInDocument());
    }
    doCommand(Gui,"Gui.activeDocument().setEdit('%s')",FeatName.c_str());

    //commitCommand();
    adjustCameraPosition();

    if (support) {
        copyVisual(FeatName.c_str(), "ShapeColor", support->getNameInDocument());
        copyVisual(FeatName.c_str(), "LineColor", support->getNameInDocument());
        copyVisual(FeatName.c_str(), "PointColor", support->getNameInDocument());
    }
}
开发者ID:h4ck3rm1k3,项目名称:FreeCAD,代码行数:55,代码来源:Command.cpp


示例7: getSolid

TopoDS_Shape Feature::getSolid(const TopoDS_Shape& shape)
{
    if (shape.IsNull())
        Standard_Failure::Raise("Shape is null");
    TopExp_Explorer xp;
    xp.Init(shape,TopAbs_SOLID);
    for (;xp.More(); xp.Next()) {
        return xp.Current();
    }

    return TopoDS_Shape();
}
开发者ID:3DPrinterGuy,项目名称:FreeCAD,代码行数:12,代码来源:Feature.cpp


示例8: getBaseObject

const TopoDS_Shape& Feature::getBaseShape() const {
    const Part::Feature* BaseObject = getBaseObject();

    const TopoDS_Shape& result = BaseObject->Shape.getValue();
    if (result.IsNull())
        throw Base::Exception("Base feature's shape is invalid");
    TopExp_Explorer xp (result, TopAbs_SOLID);
    if (!xp.More())
        throw Base::Exception("Base feature's shape is not a solid");

    return result;
}
开发者ID:3DPrinterGuy,项目名称:FreeCAD,代码行数:12,代码来源:Feature.cpp


示例9: Perform

void Edgesort::Perform()
{
    if ( m_shape.IsNull() )
        return;

    //adds all the vertices to a map, and store the associated edges
    TopExp_Explorer explorer;
    Standard_Integer nbEdges = 0;
    Standard_Integer nbNonEdges = 0;
    for ( explorer.Init(m_shape,TopAbs_EDGE) ; explorer.More() ; explorer.Next() )
    {
        const TopoDS_Edge& currentEdge = TopoDS::Edge(explorer.Current());
        if (IsValidEdge(currentEdge))
        {
            Perform(currentEdge);
            nbEdges++;
        }
        else
        {
            nbNonEdges++;
        }
    }

    //now, iterate through the edges to sort them



    do
    {
        m_edges.clear();
        tMapPntEdge::iterator iter = m_vertices.begin();
        const gp_Pnt& firstPoint = iter->first;
        gp_Pnt currentPoint = firstPoint;
        Standard_Boolean toContinue;
        do
        {
            toContinue = PerformEdges(currentPoint);
        }
        while (toContinue == Standard_True);

        tEdgeBBoxPair aTempPair;
        aTempPair.first = getBoundingBox(m_edges);
        aTempPair.second = m_edges;
        m_EdgeBBoxMap.insert(aTempPair);
    }
    while (!m_vertices.empty());



    m_done = true;

}
开发者ID:3DPrinterGuy,项目名称:FreeCAD,代码行数:52,代码来源:edgesort.cpp


示例10: split

void FaceTypeSplitter::split()
{
    TopExp_Explorer shellIt;
    for (shellIt.Init(shell, TopAbs_FACE); shellIt.More(); shellIt.Next())
    {
        TopoDS_Face tempFace(TopoDS::Face(shellIt.Current()));
        GeomAbs_SurfaceType currentType = FaceTypedBase::getFaceType(tempFace);
        SplitMapType::iterator mapIt = typeMap.find(currentType);
        if (mapIt == typeMap.end())
            continue;
        (*mapIt).second.push_back(tempFace);
    }
}
开发者ID:JonasThomas,项目名称:free-cad,代码行数:13,代码来源:modelRefine.cpp


示例11: Add

//=======================================================================
//function : Add
//purpose  : 
//=======================================================================
  void GEOMAlgo_ShapeSet::Add(const TopoDS_Shape& theShape,
			      const TopAbs_ShapeEnum theType)
{
  TopExp_Explorer aExp;
  //
  aExp.Init(theShape, theType);
  for (; aExp.More(); aExp.Next()) {
    const TopoDS_Shape& aS=aExp.Current();
    if (myMap.Add(aS)) {
      myList.Append(aS);
    }
  }
}
开发者ID:dbarbier,项目名称:pythonocc,代码行数:17,代码来源:GEOMAlgo_ShapeSet.cpp


示例12: cs

std::list<TopoDS_Wire> CrossSection::section(double d) const
{
    std::list<TopoDS_Wire> wires;
    BRepAlgoAPI_Section cs(s, gp_Pln(a,b,c,-d));
    if (cs.IsDone()) {
        std::list<TopoDS_Edge> edges;
        TopExp_Explorer xp;
        for (xp.Init(cs.Shape(), TopAbs_EDGE); xp.More(); xp.Next())
            edges.push_back(TopoDS::Edge(xp.Current()));
        connectEdges(edges, wires);
    }

    return wires;
}
开发者ID:Daedalus12,项目名称:FreeCAD_sf_master,代码行数:14,代码来源:CrossSection.cpp


示例13: GetFaces

bool Geometry::GetFaces(const TopoDS_Shape &brep, Geometry::FaceSet &faces) {
    TopExp_Explorer Ex;
    int count=0;
    for (Ex.Init(brep,TopAbs_FACE); Ex.More(); Ex.Next()) {
        faces.push_back(new TopoDS_Face);
        faces.at(faces.size()-1)= TopoDS::Face(Ex.Current());
        count++;
    }
//    if(count>=1)
//        cout<<"element: has "<<boost::lexical_cast<string>(count)<<" faces"<<endl;
    if(count < 1)
        cout<<"error! no face is found in this building element"<<endl;
    return count>0;
}
开发者ID:lorinma,项目名称:EaSTBIM,代码行数:14,代码来源:Geometry.cpp


示例14: GetShells

bool Geometry::GetShells(const TopoDS_Shape &brep, Geometry::ShellSet &shells) {
    TopExp_Explorer Ex;
    int count=0;
    for (Ex.Init(brep,TopAbs_SHELL); Ex.More(); Ex.Next()) {
        shells.push_back(new TopoDS_Shell);
        shells.at(shells.size()-1)= TopoDS::Shell(Ex.Current());
        count++;
    }
//    if(count>=1)
//        cout<<"element: has "<<boost::lexical_cast<string>(count)<<" shells"<<endl;
    if(count < 1)
        cout<<"error! no shell is found in this building element"<<endl;
    return count>0;
}
开发者ID:lorinma,项目名称:EaSTBIM,代码行数:14,代码来源:Geometry.cpp


示例15: getPointFromFace

const gp_Pnt Feature::getPointFromFace(const TopoDS_Face& f)
{
    if (!f.Infinite()) {
        TopExp_Explorer exp;
        exp.Init(f, TopAbs_VERTEX);
        if (exp.More())
            return BRep_Tool::Pnt(TopoDS::Vertex(exp.Current()));
        // Else try the other method
    }

    // TODO: Other method, e.g. intersect X,Y,Z axis with the (unlimited?) face?
    // Or get a "corner" point if the face is limited?
    throw Base::Exception("getPointFromFace(): Not implemented yet for this case");
}
开发者ID:3DPrinterGuy,项目名称:FreeCAD,代码行数:14,代码来源:Feature.cpp


示例16: getSupport

const TopoDS_Shape& SketchBased::getSupportShape() const {
    Part::Feature* SupportObject = getSupport();
    if (SupportObject == NULL)
        throw Base::Exception("No support in Sketch!");

    const TopoDS_Shape& result = SupportObject->Shape.getValue();
    if (result.IsNull())
        throw Base::Exception("Support shape is invalid");
    TopExp_Explorer xp (result, TopAbs_SOLID);
    if (!xp.More())
        throw Base::Exception("Support shape is not a solid");

    return result;
}
开发者ID:Didier94,项目名称:FreeCAD_sf_master,代码行数:14,代码来源:FeatureSketchBased.cpp


示例17: Do

void CurveProjectorShape::Do(void)
{
  TopExp_Explorer Ex;
  TopoDS_Shape Edge;

  for (Ex.Init(_Shape, TopAbs_EDGE); Ex.More(); Ex.Next())
  {
	  const TopoDS_Edge& aEdge = TopoDS::Edge(Ex.Current());

    //std::vector<FaceSplitEdge> vSplitEdges;
    projectCurve(aEdge, mvEdgeSplitPoints[aEdge]);

  }

}
开发者ID:peterl94,项目名称:FreeCAD_sf_master,代码行数:15,代码来源:CurveProjector.cpp


示例18: writeShapeCSV

void PovTools::writeShapeCSV(const char *FileName,
                             const TopoDS_Shape& Shape,
                             float fMeshDeviation,
                             float fLength)
{
    const char cSeperator = ',';

    Base::Console().Log("Meshing with Deviation: %f\n",fMeshDeviation);

    TopExp_Explorer ex;
    BRepMesh_IncrementalMesh MESH(Shape,fMeshDeviation);

    // open the file and write
    std::ofstream fout(FileName);

    // counting faces and start sequencer
    int l = 1;
    for (ex.Init(Shape, TopAbs_FACE); ex.More(); ex.Next(),l++) {}
    Base::SequencerLauncher seq("Writing file", l);

    // write the file
    l = 1;
    for (ex.Init(Shape, TopAbs_FACE); ex.More(); ex.Next(),l++) {

        // get the shape and mesh it
        const TopoDS_Face& aFace = TopoDS::Face(ex.Current());

        // this block mesh the face and transfers it in a C array of vertices and face indexes
        Standard_Integer nbNodesInFace,nbTriInFace;
        gp_Vec* vertices=0;
        gp_Vec* vertexnormals=0;
        long* cons=0;

        transferToArray(aFace,&vertices,&vertexnormals,&cons,nbNodesInFace,nbTriInFace);

        if (!vertices) break;
        // writing per face header
        // writing vertices
        for (int i=0; i < nbNodesInFace; i++) {
            fout << vertices[i].X() << cSeperator
            << vertices[i].Z() << cSeperator
            << vertices[i].Y() << cSeperator
            << vertexnormals[i].X() * fLength <<cSeperator
            << vertexnormals[i].Z() * fLength <<cSeperator
            << vertexnormals[i].Y() * fLength <<cSeperator
            << endl;
        }

        delete [] vertexnormals;
        delete [] vertices;
        delete [] cons;

        seq.next();

    } // end of face loop

    fout.close();
}
开发者ID:zhangli1049,项目名称:FreeCAD,代码行数:58,代码来源:PovTools.cpp


示例19: Contains

// Modified  Thu Sep 14 14:35:18 2006
// Contribution of Samtech www.samcef.com BEGIN
//=======================================================================
//function : Contains
//purpose  :
//=======================================================================
Standard_Boolean Contains(const TopoDS_Face& aF,
                          const TopoDS_Vertex& aV)
{
  Standard_Boolean bRet;
  TopExp_Explorer aExp;
  //
  bRet=Standard_False;
  aExp.Init(aF, TopAbs_VERTEX);
  for (; aExp.More(); aExp.Next()) {
    const TopoDS_Shape& aVF=aExp.Current();
    if (aVF.IsSame(aV)) {
      bRet=!bRet;
      break;
    }
  }
  return bRet;
}
开发者ID:triggerfish1,项目名称:pythonocc,代码行数:23,代码来源:NMTTools_PaveFiller_3.cpp


示例20: GetBiggestSolid

bool GetBiggestSolid(TopoDS_Shape& solid)
{
     TopExp_Explorer solidExp;
     TopoDS_Shape     aSolid;
     double maxVolume = 0;
     double volume;
     for (solidExp.Init(solid,TopAbs_SOLID); solidExp.More(); solidExp.Next())
     {
          aSolid = solidExp.Current();
          volume = GetVolume(aSolid);
          if (maxVolume < volume)
          {
               maxVolume = volume;
               solid = aSolid;
          }          
     }
     return true;
}
开发者ID:jf---,项目名称:openshapefactory,代码行数:18,代码来源:utilityfunctions.cpp



注:本文中的TopExp_Explorer类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ TopLoc_Location类代码示例发布时间:2022-05-31
下一篇:
C++ ToonzScene类代码示例发布时间:2022-05-31
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap