当前位置: 首页>>代码示例>>C++>>正文


C++ TopoDS_Face类代码示例

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


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

示例1: GetFaceNormalAtUV

gp_Dir GetFaceNormalAtUV(const TopoDS_Face &face, double u, double v, gp_Pnt *pos){
	if(face.IsNull()) return gp_Dir(0, 0, 1);

	try
	{
		Handle(Geom_Surface) surf=BRep_Tool::Surface(face);          // get surface properties
		GeomLProp_SLProps props(surf, u, v, 1, 0.01);          // get surface normal
		if(!props.IsNormalDefined())return gp_Dir(0, 0, 1);
		gp_Dir norm=props.Normal();                         // check orientation
		if(pos)*pos = props.Value();
		if(face.Orientation()==TopAbs_REVERSED) norm.Reverse();
		return norm;
	}
	catch (Standard_Failure) {
		Handle_Standard_Failure e = Standard_Failure::Caught();
		wxMessageBox(wxString(_("Error in GetFaceNormalAtUV")) + _T(": ") + Ctt(e->GetMessageString()));
		return gp_Dir(0, 0, 1);
	}
	catch (const char* str)
	{
		wxMessageBox(wxString(_("Error in GetFaceNormalAtUV")) + _T(": ") + Ctt(str));
		return gp_Dir(0, 0, 1);
	}
	catch (...)
	{
		wxMessageBox(_("Error in GetFaceNormalAtUV"));
		return gp_Dir(0, 0, 1);
	}
}
开发者ID:CarlosGS,项目名称:heekscad,代码行数:29,代码来源:FaceTools.cpp

示例2: assert

// TODO: This code is taken from and duplicates code in Part2DObject::positionBySupport()
// Note: We cannot return a reference, because it will become Null.
// Not clear where, because we check for IsNull() here, but as soon as it is passed out of
// this method, it becomes null!
const TopoDS_Face SketchBased::getSupportFace() const {
    const App::PropertyLinkSub& Support = static_cast<Part::Part2DObject*>(Sketch.getValue())->Support;
    Part::Feature *part = static_cast<Part::Feature*>(Support.getValue());
    if (!part || !part->getTypeId().isDerivedFrom(Part::Feature::getClassTypeId()))
        throw Base::Exception("Sketch has no support shape");

    const std::vector<std::string> &sub = Support.getSubValues();
    assert(sub.size()==1);
    // get the selected sub shape (a Face)
    const Part::TopoShape &shape = part->Shape.getShape();
    if (shape._Shape.IsNull())
        throw Base::Exception("Sketch support shape is empty!");

    TopoDS_Shape sh = shape.getSubShape(sub[0].c_str());
    if (sh.IsNull())
        throw Base::Exception("Null shape in SketchBased::getSupportFace()!");

    const TopoDS_Face face = TopoDS::Face(sh);
    if (face.IsNull())
        throw Base::Exception("Null face in SketchBased::getSupportFace()!");

    BRepAdaptor_Surface adapt(face);
    if (adapt.GetType() != GeomAbs_Plane)
        throw Base::Exception("No planar face in SketchBased::getSupportFace()!");

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

示例3: ubTreeFiller

void PointOnFacesProjector::prepare(const TopoDS_Shape& faces)
{
  d->clear();
  // Build the UB tree for binary search of points
  internal::UBTreeOfNodeIndicesFiller_t ubTreeFiller(d->m_ubTree, Standard_False);
  for (TopExp_Explorer exp(faces, TopAbs_FACE); exp.More(); exp.Next()) {
    const TopoDS_Face face = TopoDS::Face(exp.Current());
    if (!face.IsNull()) {
      TopLoc_Location loc;
      const Handle_Poly_Triangulation& triangulation = BRep_Tool::Triangulation(face, loc);
      if (!triangulation.IsNull()) {
        d->insertMapping(triangulation, face);
        const gp_Trsf& trsf = loc.Transformation();
        const TColgp_Array1OfPnt& nodes = triangulation->Nodes();
        for (int i = nodes.Lower(); i <= nodes.Upper(); ++i) {
          const gp_Pnt iNode(nodes(i).Transformed(trsf));
          Bnd_Box ibb;
          ibb.Set(iNode);
          ubTreeFiller.Add(std::make_pair(i, triangulation), ibb);
        }
      }
    }
  }
  ubTreeFiller.Fill();
}
开发者ID:Alexandr-Galko,项目名称:fougtools,代码行数:25,代码来源:point_on_faces_projector.cpp

示例4: replaceFacesInternal

void OCCRegion::replaceFacesInternal(std::list<GFace*> &new_faces)
{
  // we simply replace old faces by new faces in the structure
  TopExp_Explorer aExpS, aExpF;
  BRep_Builder aBB;
  TopoDS_Compound aCmp;
  aBB.MakeCompound(aCmp);
  TopoDS_Solid _s_replacement;
  aBB.MakeSolid(_s_replacement);
  _s_replacement.Orientation(s.Orientation());
  aExpS.Init(s, TopAbs_SHELL);
  for (; aExpS.More(); aExpS.Next()) {
    const TopoDS_Shell& _shell=TopoDS::Shell(aExpS.Current());
    TopoDS_Shell _shell_replacement;
    aBB.MakeShell(_shell_replacement);
    _shell_replacement.Orientation(_shell.Orientation());
    aExpF.Init(_shell, TopAbs_FACE);
    for (; aExpF.More(); aExpF.Next()) {
      const TopoDS_Face& _face=TopoDS::Face(aExpF.Current());
      TopoDS_Face _face_replacement;

      std::list<GFace*>::iterator it  = l_faces.begin();
      std::list<GFace*>::iterator it2 = new_faces.begin();

      for ( ; it != l_faces.end() ; ++it,++it2){
	OCCFace *occF = dynamic_cast<OCCFace*>(*it);
	if (occF){
	  TopoDS_Face oldf = occF->getTopoDS_Face();
	  if (oldf.IsSame(_face)){
	    _face_replacement = *((TopoDS_Face*)(*it2)->getNativePtr());
	  }
	  else {
	    oldf = occF->getTopoDS_FaceOld();
	    if (oldf.IsSame(_face)){
	      _face_replacement = *((TopoDS_Face*)(*it2)->getNativePtr());
	    }
	  }
	}
      }
      if (_face_replacement.IsNull()){
	Msg::Error("cannot find an face for gluing a region");
      }

      if (_face_replacement.IsSame(_face)) {
	aBB.Add(_shell_replacement, _face);
      }
      else {
	if(FaceHaveDifferentOrientations(_face, _face_replacement))
          _face_replacement.Reverse();
	aBB.Add(_shell_replacement, _face_replacement);
      }
    }
    aBB.Add(_s_replacement, _shell_replacement);
  }
  s = _s_replacement;
  setup();
}
开发者ID:iyer-arvind,项目名称:gmsh,代码行数:57,代码来源:OCCRegion.cpp

示例5: OCC2VTK

void  
GEOM_WireframeFace:: 
OCC2VTK(const TopoDS_Face& theFace,
        vtkPolyData* thePolyData,
                    vtkPoints* thePts,  
        const int theNbIso[2], 
        const int theDiscret) 
{ 
  TopoDS_Face aFace = theFace; 
  aFace.Orientation(TopAbs_FORWARD);
  CreateIso(aFace,theNbIso,theDiscret,thePolyData,thePts);
}
开发者ID:triggerfish1,项目名称:pythonocc,代码行数:12,代码来源:GEOM_WireframeFace.cpp

示例6: GetNodeUVneedInFaceNode

bool SMESH_MesherHelper::GetNodeUVneedInFaceNode(const TopoDS_Face& F) const
{
  if ( F.IsNull() ) return !mySeamShapeIds.empty();

  if ( !F.IsNull() && !myShape.IsNull() && myShape.IsSame( F ))
    return !mySeamShapeIds.empty();

  Handle(Geom_Surface) aSurface = BRep_Tool::Surface( F );
  if ( !aSurface.IsNull() )
    return ( aSurface->IsUPeriodic() || aSurface->IsVPeriodic() );

  return false;
}
开发者ID:5263,项目名称:FreeCAD,代码行数:13,代码来源:SMESH_MesherHelper.cpp

示例7: TopoDS_Face

void OCCSurface::set_TopoDS_Face(TopoDS_Face& face)
{
  if(face.IsEqual(*myTopoDSFace))
    return;

  TopoDS_Face* face_ptr = new TopoDS_Face(face);
  if(myTopoDSFace)
    delete (TopoDS_Face*)myTopoDSFace;
  myTopoDSFace = face_ptr ; 
}
开发者ID:tenpercent,项目名称:cp-sandbox,代码行数:10,代码来源:OCCSurface.cpp

示例8: Handle

//=======================================================================
// function: CopyFace
// purpose: 
//=======================================================================
  void GEOMAlgo_Tools3D::CopyFace (const TopoDS_Face& theF1,
                                  TopoDS_Face& theF2)
{
  Standard_Real aTol;
  TopLoc_Location aLoc;
  TopAbs_Orientation aOr;
  TopoDS_Iterator aIt;
  BRep_Builder aBB;
  //
  Handle(Geom_Surface) aSurface=BRep_Tool::Surface(theF1, aLoc);
  aTol=BRep_Tool::Tolerance(theF1);
  aOr=theF1.Orientation();
  //
  aBB.MakeFace (theF2, aSurface, aLoc, aTol);
  theF2.Orientation(aOr);
  //
  aIt.Initialize(theF1);
  for (; aIt.More(); aIt.Next()) {
    const TopoDS_Shape& aW=aIt.Value();
    aBB.Add(theF2, aW);
  }
}
开发者ID:dbarbier,项目名称:pythonocc,代码行数:26,代码来源:GEOMAlgo_Tools3D.cpp

示例9: boundarySplit

TopoDS_Face FaceTypedCylinder::buildFace(const FaceVectorType &faces) const
{
    std::vector<EdgeVectorType> boundaries;
    boundarySplit(faces, boundaries);
    static TopoDS_Face dummy;
    if (boundaries.size() < 1)
        return dummy;

    //take one face and remove all the wires.
    TopoDS_Face workFace = faces.at(0);
    ShapeBuild_ReShape reshaper;
    TopExp_Explorer it;
    for (it.Init(workFace, TopAbs_WIRE); it.More(); it.Next())
        reshaper.Remove(it.Current());
    workFace = TopoDS::Face(reshaper.Apply(workFace));
    if (workFace.IsNull())
        return TopoDS_Face();

    ShapeFix_Face faceFixer(workFace);

    //makes wires
    std::vector<EdgeVectorType>::iterator boundaryIt;
    for (boundaryIt = boundaries.begin(); boundaryIt != boundaries.end(); ++boundaryIt)
    {
        BRepLib_MakeWire wireMaker;
        EdgeVectorType::iterator it;
        for (it = (*boundaryIt).begin(); it != (*boundaryIt).end(); ++it)
            wireMaker.Add(*it);
        if (wireMaker.Error() != BRepLib_WireDone)
            continue;
        faceFixer.Add(wireMaker.Wire());
    }
    if (faceFixer.Perform() > ShapeExtend_DONE5)
        return TopoDS_Face();
    faceFixer.FixOrientation();
    if (faceFixer.Perform() > ShapeExtend_DONE5)
        return TopoDS_Face();
    return faceFixer.Face();
}
开发者ID:JonasThomas,项目名称:free-cad,代码行数:39,代码来源:modelRefine.cpp

示例10: 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

示例11: normalToFaceAtUV

gp_Vec normalToFaceAtUV(const TopoDS_Face& face, double u, double v)
{
  BRepLProp_SLProps localSurfaceProps(1, 1e-6);
  localSurfaceProps.SetSurface(BRepAdaptor_Surface(face));
  localSurfaceProps.SetParameters(u, v);
  if (localSurfaceProps.IsNormalDefined()) {
    const gp_Dir& nc = localSurfaceProps.Normal();
    if (face.Orientation() == TopAbs_REVERSED)
      return gp_Vec(-nc.X(), -nc.Y(), -nc.Z());
    else
      return gp_Vec(nc.X(), nc.Y(), nc.Z());
  }
  return gp_Vec(0., 0., 1.);
  //return normalToSurfaceAtUV(BRep_Tool::Surface(face), u, v);
}
开发者ID:neoplacer,项目名称:fougtools,代码行数:15,代码来源:utils.cpp

示例12: SamePnt2d

//=======================================================================
//function : SamePnt2d
//purpose  : 
//=======================================================================
static Standard_Boolean  SamePnt2d(TopoDS_Vertex  V,
				   TopoDS_Edge&   E1,
				   TopoDS_Edge&   E2,
				   TopoDS_Face&   F)
{
  Standard_Real   f1,f2,l1,l2;
  gp_Pnt2d        P1,P2;
  TopoDS_Shape aLocalF = F.Oriented(TopAbs_FORWARD);
  TopoDS_Face FF = TopoDS::Face(aLocalF);
  Handle(Geom2d_Curve) C1 = BRep_Tool::CurveOnSurface(E1,FF,f1,l1);  
  Handle(Geom2d_Curve) C2 = BRep_Tool::CurveOnSurface(E2,FF,f2,l2);  
  if (E1.Orientation () == TopAbs_FORWARD) P1 = C1->Value(f1);
  else                                     P1 = C1->Value(l1);
  
  if (E2.Orientation () == TopAbs_FORWARD) P2 = C2->Value(l2);
  else                                     P2 = C2->Value(f2);
  Standard_Real Tol  = 100*BRep_Tool::Tolerance(V);
  Standard_Real Dist = P1.Distance(P2);
  return Dist < Tol; 
}
开发者ID:hmeyer,项目名称:salome-geom,代码行数:24,代码来源:Partition_Loop.cpp

示例13: convert_to_ifc

int convert_to_ifc(const TopoDS_Face& f, IfcSchema::IfcFace*& face, bool advanced) {
	Handle_Geom_Surface surf = BRep_Tool::Surface(f);
	TopExp_Explorer exp(f, TopAbs_WIRE);
	IfcSchema::IfcFaceBound::list::ptr bounds(new IfcSchema::IfcFaceBound::list);
	int index = 0;
	for (; exp.More(); exp.Next(), ++index) {
		IfcSchema::IfcLoop* loop;
		if (!convert_to_ifc(TopoDS::Wire(exp.Current()), loop, advanced)) {
			return 0;
		}
		IfcSchema::IfcFaceBound* bnd;
		if (index == 0) {
			bnd = new IfcSchema::IfcFaceOuterBound(loop, true);
		} else {
			bnd = new IfcSchema::IfcFaceBound(loop, true);
		}
		bounds->push(bnd);
	}

	const bool is_planar = surf->DynamicType() == STANDARD_TYPE(Geom_Plane);

	if (!is_planar && !advanced) {
		return 0;
	}
	if (is_planar && !advanced) {
		face = new IfcSchema::IfcFace(bounds);
		return 1;
	} else {
#ifdef USE_IFC4
		IfcSchema::IfcSurface* surface;
		if (!convert_to_ifc(surf, surface, advanced)) {
			return 0;
		}
		face = new IfcSchema::IfcAdvancedFace(bounds, surface, f.Orientation() == TopAbs_FORWARD);
		return 1;
#else
		// No IfcAdvancedFace in Ifc2x3
		return 0;
#endif
	}
}
开发者ID:berndhahnebach,项目名称:IfcOpenShell,代码行数:41,代码来源:IfcGeomSerialisation.cpp

示例14: getBaseShape


//.........这里部分代码省略.........
                    continue;
                Handle(Geom_Curve) icurve = intersector.Line(1);
                if (!icurve->IsKind(STANDARD_TYPE(Geom_Line)))
                    continue;
                // TODO: How to extract the line from icurve without creating an edge first?
                TopoDS_Edge edge = BRepBuilderAPI_MakeEdge(icurve);
                BRepAdaptor_Curve c(edge);
                neutralPlane = gp_Pln(pm, c.Line().Direction());
                found = true;
                break;
            }
        }

        if (!found)
            throw Base::Exception("No neutral plane specified and none can be guessed");
    } else {
        if (refPlane->getTypeId().isDerivedFrom(PartDesign::Plane::getClassTypeId())) {
            PartDesign::Plane* plane = static_cast<PartDesign::Plane*>(refPlane);
            Base::Vector3d b = plane->getBasePoint();
            Base::Vector3d n = plane->getNormal();
            neutralPlane = gp_Pln(gp_Pnt(b.x, b.y, b.z), gp_Dir(n.x, n.y, n.z));
        } else if (refPlane->getTypeId().isDerivedFrom(App::Plane::getClassTypeId())) {
            neutralPlane = Feature::makePlnFromPlane(refPlane);
        } else if (refPlane->getTypeId().isDerivedFrom(Part::Feature::getClassTypeId())) {
            std::vector<std::string> subStrings = NeutralPlane.getSubValues();
            if (subStrings.empty() || subStrings[0].empty())
                throw Base::Exception("No neutral plane reference specified");

            Part::Feature* refFeature = static_cast<Part::Feature*>(refPlane);
            Part::TopoShape refShape = refFeature->Shape.getShape();
            TopoDS_Shape ref = refShape.getSubShape(subStrings[0].c_str());

            if (ref.ShapeType() == TopAbs_FACE) {
                TopoDS_Face refFace = TopoDS::Face(ref);
                if (refFace.IsNull())
                    throw Base::Exception("Failed to extract neutral plane reference face");
                BRepAdaptor_Surface adapt(refFace);
                if (adapt.GetType() != GeomAbs_Plane)
                    throw Base::Exception("Neutral plane reference face must be planar");

                neutralPlane = adapt.Plane();
            } else if (ref.ShapeType() == TopAbs_EDGE) {
                if (refDirection != NULL) {
                    // Create neutral plane through edge normal to pull direction
                    TopoDS_Edge refEdge = TopoDS::Edge(ref);
                    if (refEdge.IsNull())
                        throw Base::Exception("Failed to extract neutral plane reference edge");
                    BRepAdaptor_Curve c(refEdge);
                    if (c.GetType() != GeomAbs_Line)
                        throw Base::Exception("Neutral plane reference edge must be linear");
                    double a = c.Line().Angle(gp_Lin(c.Value(c.FirstParameter()), pullDirection));
                    if (std::fabs(a - M_PI_2) > Precision::Confusion())
                        throw Base::Exception("Neutral plane reference edge must be normal to pull direction");
                    neutralPlane = gp_Pln(c.Value(c.FirstParameter()), pullDirection);
                } else {
                    throw Base::Exception("Neutral plane reference can only be an edge if pull direction is defined");
                }
            } else {
                throw Base::Exception("Neutral plane reference must be a face");
            }
        } else {
            throw Base::Exception("Neutral plane reference must be face of a feature or a datum plane");
        }

        TopLoc_Location invObjLoc = this->getLocation().Inverted();
        neutralPlane.Transform(invObjLoc.Transformation());
开发者ID:crobarcro,项目名称:FreeCAD,代码行数:67,代码来源:FeatureDraft.cpp

示例15: update_OCC_entity

//----------------------------------------------------------------
// Function: TopoDS_Shape level function to update the core Surface
//           for any movement  or Boolean operation of the body.
// Author: Jane Hu
//----------------------------------------------------------------
CubitStatus OCCSurface::update_OCC_entity(TopoDS_Face& old_surface,
                                          TopoDS_Shape& new_surface,
                                          BRepBuilderAPI_MakeShape *op,
                                          TopoDS_Vertex* removed_vertex,
                                          LocOpe_SplitShape* sp) 
{
  //set the Wires
  TopTools_IndexedMapOfShape M, M2;
  TopoDS_Shape shape, shape2, shape_edge, shape_vertex;
  TopExp::MapShapes(old_surface, TopAbs_WIRE, M);

  TopTools_ListOfShape shapes;  
  BRepFilletAPI_MakeFillet2d* test_op = NULL;

  for (int ii=1; ii<=M.Extent(); ii++) 
  {
     TopoDS_Wire wire = TopoDS::Wire(M(ii));
     TopTools_ListOfShape shapes;
     if(op)
     {
       test_op = dynamic_cast<BRepFilletAPI_MakeFillet2d*>(op);
       if(!test_op)
         shapes.Assign(op->Modified(wire));
       if(shapes.Extent() == 0)
         shapes.Assign(op->Generated(wire));
       if(!new_surface.IsNull())
         TopExp::MapShapes(new_surface,TopAbs_WIRE, M2);
     }
     else if(sp)
       shapes.Assign(sp->DescendantShapes(wire));

     if (shapes.Extent() == 1)
     {
       shape = shapes.First();
       if(M2.Extent() == 1)
       {
         shape2 = TopoDS::Wire(M2(1));
         if(!shape.IsSame(shape2))
           shape = shape2;
       }
       else if(M2.Extent() > 1)
         shape.Nullify();
     }
     else if(shapes.Extent() > 1)
       shape.Nullify();
     else if(op->IsDeleted(wire) || shapes.Extent() == 0)
     {
       TopTools_IndexedMapOfShape M_new;
       TopExp::MapShapes(new_surface, TopAbs_WIRE, M_new);
       if (M_new.Extent()== 1)
         shape = M_new(1);
       else
         shape.Nullify();
     }
     else
     {
       shape = wire;
       continue;
     }

     //set curves
     BRepTools_WireExplorer Ex;
      
     for(Ex.Init(wire); Ex.More();Ex.Next())
     {
       TopoDS_Edge edge = Ex.Current();
       if(op && !test_op)
       {
         shapes.Assign(op->Modified(edge));
         if(shapes.Extent() == 0)
           shapes.Assign(op->Generated(edge));
       }
         
       else if(sp)
         shapes.Assign(sp->DescendantShapes(edge));

       if (shapes.Extent() == 1)
       {
        //in fillet creating mothod, one edge could generated a face, so check
        //it here.
         TopAbs_ShapeEnum type = shapes.First().TShape()->ShapeType(); 
         if(type != TopAbs_EDGE)
           shape_edge.Nullify();
         else
           shape_edge = shapes.First();
       }
       else if (shapes.Extent() > 1)
       {
         //update all attributes first.
         TopTools_ListIteratorOfListOfShape it;
         it.Initialize(shapes);
         for(; it.More(); it.Next())
         {
           shape_edge = it.Value();
           OCCQueryEngine::instance()->copy_attributes(edge, shape_edge);
//.........这里部分代码省略.........
开发者ID:tenpercent,项目名称:cp-sandbox,代码行数:101,代码来源:OCCSurface.cpp


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