本文整理汇总了C++中BRepBuilderAPI_MakeWire类的典型用法代码示例。如果您正苦于以下问题:C++ BRepBuilderAPI_MakeWire类的具体用法?C++ BRepBuilderAPI_MakeWire怎么用?C++ BRepBuilderAPI_MakeWire使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了BRepBuilderAPI_MakeWire类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
bool IfcGeom::Kernel::convert(const IfcSchema::IfcEdge* l, TopoDS_Wire& result) {
if (!l->EdgeStart()->is(IfcSchema::Type::IfcVertexPoint) || !l->EdgeEnd()->is(IfcSchema::Type::IfcVertexPoint)) {
Logger::Message(Logger::LOG_ERROR, "Only IfcVertexPoints are supported for EdgeStart and -End", l->entity);
return false;
}
IfcSchema::IfcPoint* pnt1 = ((IfcSchema::IfcVertexPoint*) l->EdgeStart())->VertexGeometry();
IfcSchema::IfcPoint* pnt2 = ((IfcSchema::IfcVertexPoint*) l->EdgeEnd())->VertexGeometry();
if (!pnt1->is(IfcSchema::Type::IfcCartesianPoint) || !pnt2->is(IfcSchema::Type::IfcCartesianPoint)) {
Logger::Message(Logger::LOG_ERROR, "Only IfcCartesianPoints are supported for VertexGeometry", l->entity);
return false;
}
gp_Pnt p1, p2;
if (!convert(((IfcSchema::IfcCartesianPoint*)pnt1), p1) ||
!convert(((IfcSchema::IfcCartesianPoint*)pnt2), p2))
{
return false;
}
BRepBuilderAPI_MakeWire mw;
mw.Add(BRepBuilderAPI_MakeEdge(p1, p2));
result = mw.Wire();
return true;
}
示例2: getValue
bool IfcGeom::Kernel::convert(const IfcSchema::IfcCircleProfileDef* l, TopoDS_Shape& face) {
const double r = l->Radius() * getValue(GV_LENGTH_UNIT);
if ( r == 0.0f ) {
Logger::Message(Logger::LOG_NOTICE,"Skipping zero sized profile:",l->entity);
return false;
}
gp_Trsf2d trsf2d;
bool has_position = true;
#ifdef USE_IFC4
has_position = l->hasPosition();
#endif
if (has_position) {
IfcGeom::Kernel::convert(l->Position(), trsf2d);
}
gp_Ax2 ax = gp_Ax2().Transformed(trsf2d);
Handle(Geom_Circle) circle = new Geom_Circle(ax, r);
TopoDS_Edge edge = BRepBuilderAPI_MakeEdge(circle);
BRepBuilderAPI_MakeWire w;
w.Add(edge);
TopoDS_Face f;
bool success = convert_wire_to_face(w, f);
if (success) face = f;
return success;
}
示例3: makeCleanWire
//! make a clean wire with sorted, oriented, connected, etc edges
TopoDS_Wire EdgeWalker::makeCleanWire(std::vector<TopoDS_Edge> edges, double tol)
{
TopoDS_Wire result;
BRepBuilderAPI_MakeWire mkWire;
ShapeFix_ShapeTolerance sTol;
Handle(ShapeExtend_WireData) wireData = new ShapeExtend_WireData();
for (auto e:edges) {
wireData->Add(e);
}
Handle(ShapeFix_Wire) fixer = new ShapeFix_Wire;
fixer->Load(wireData);
fixer->Perform();
fixer->FixReorder();
fixer->SetMaxTolerance(tol);
fixer->ClosedWireMode() = Standard_True;
fixer->FixConnected(Precision::Confusion());
fixer->FixClosed(Precision::Confusion());
for (int i = 1; i <= wireData->NbEdges(); i ++) {
TopoDS_Edge edge = fixer->WireData()->Edge(i);
sTol.SetTolerance(edge, tol, TopAbs_VERTEX);
mkWire.Add(edge);
}
result = mkWire.Wire();
return result;
}
示例4: mkWire1
static TopoDS_Wire mkWire1()
{
BRepBuilderAPI_MakeEdge aMkEdge1 (mkCurve2());
BRepBuilderAPI_MakeEdge aMkEdge2 (mkCurve3());
BRepBuilderAPI_MakeWire aMkWire (aMkEdge1, aMkEdge2);
return aMkWire.Wire();
}
示例5: getValue
bool IfcGeom::Kernel::convert(const IfcSchema::IfcEllipseProfileDef* l, TopoDS_Shape& face) {
double rx = l->SemiAxis1() * getValue(GV_LENGTH_UNIT);
double ry = l->SemiAxis2() * getValue(GV_LENGTH_UNIT);
if ( rx < ALMOST_ZERO || ry < ALMOST_ZERO ) {
Logger::Message(Logger::LOG_NOTICE,"Skipping zero sized profile:",l->entity);
return false;
}
const bool rotated = ry > rx;
gp_Trsf2d trsf;
convert(l->Position(),trsf);
gp_Ax2 ax = gp_Ax2();
if (rotated) {
ax.Rotate(ax.Axis(), M_PI / 2.);
std::swap(rx, ry);
}
ax.Transform(trsf);
BRepBuilderAPI_MakeWire w;
Handle(Geom_Ellipse) ellipse = new Geom_Ellipse(ax, rx, ry);
TopoDS_Edge edge = BRepBuilderAPI_MakeEdge(ellipse);
w.Add(edge);
TopoDS_Face f;
bool success = convert_wire_to_face(w, f);
if (success) face = f;
return success;
}
示例6:
bool IfcGeom::Kernel::convert(const IfcSchema::IfcEdgeLoop* l, TopoDS_Wire& result) {
IfcSchema::IfcOrientedEdge::list::ptr li = l->EdgeList();
BRepBuilderAPI_MakeWire mw;
for (IfcSchema::IfcOrientedEdge::list::it it = li->begin(); it != li->end(); ++it) {
IfcSchema::IfcOrientedEdge* e = *it;
IfcSchema::IfcPoint* pnt1 = ((IfcSchema::IfcVertexPoint*) e->EdgeStart())->VertexGeometry();
IfcSchema::IfcPoint* pnt2 = ((IfcSchema::IfcVertexPoint*) e->EdgeEnd())->VertexGeometry();
if (!pnt1->is(IfcSchema::Type::IfcCartesianPoint) || !pnt2->is(IfcSchema::Type::IfcCartesianPoint)) {
Logger::Message(Logger::LOG_ERROR, "Only IfcCartesianPoints are supported for VertexGeometry", l->entity);
return false;
}
gp_Pnt p1, p2;
if (!IfcGeom::Kernel::convert(((IfcSchema::IfcCartesianPoint*)pnt1), p1) ||
!IfcGeom::Kernel::convert(((IfcSchema::IfcCartesianPoint*)pnt2), p2))
{
return false;
}
mw.Add(BRepBuilderAPI_MakeEdge(p1, p2));
continue;
IfcSchema::IfcEdge* base = e->EdgeElement();
TopoDS_Wire w;
if (convert_wire(e->EdgeElement(), w)) {
if (!e->Orientation()) w.Reverse();
mw.Add(w);
}
}
result = mw;
return true;
}
示例7: xy
bool IfcGeom::profile_helper(int numVerts, double* verts, int numFillets, int* filletIndices, double* filletRadii, gp_Trsf2d trsf, TopoDS_Face& face) {
TopoDS_Vertex* vertices = new TopoDS_Vertex[numVerts];
for ( int i = 0; i < numVerts; i ++ ) {
gp_XY xy (verts[2*i],verts[2*i+1]);
trsf.Transforms(xy);
vertices[i] = BRepBuilderAPI_MakeVertex(gp_Pnt(xy.X(),xy.Y(),0.0f));
}
BRepBuilderAPI_MakeWire w;
for ( int i = 0; i < numVerts; i ++ )
w.Add(BRepBuilderAPI_MakeEdge(vertices[i],vertices[(i+1)%numVerts]));
IfcGeom::convert_wire_to_face(w.Wire(),face);
if ( numFillets && *std::max_element(filletRadii, filletRadii + numFillets) > 1e-7 ) {
BRepFilletAPI_MakeFillet2d fillet (face);
for ( int i = 0; i < numFillets; i ++ ) {
const double radius = filletRadii[i];
if ( radius <= 1e-7 ) continue;
fillet.AddFillet(vertices[filletIndices[i]],radius);
}
fillet.Build();
if (fillet.IsDone()) {
face = TopoDS::Face(fillet.Shape());
} else {
Logger::Message(Logger::LOG_WARNING, "Failed to process profile fillets");
}
}
delete[] vertices;
return true;
}
示例8: xp
void BRepOffsetAPI_MakeOffsetFix::AddWire(const TopoDS_Wire& Spine)
{
TopoDS_Wire wire = Spine;
int numEdges = 0;
TopExp_Explorer xp(wire, TopAbs_EDGE);
while (xp.More()) {
numEdges++;
xp.Next();
}
if (numEdges == 1) {
TopLoc_Location edgeLocation;
BRepBuilderAPI_MakeWire mkWire;
TopExp_Explorer xp(wire, TopAbs_EDGE);
while (xp.More()) {
// The trick is to reset the placement of an edge before
// passing it to BRepOffsetAPI_MakeOffset because then it
// will create the expected result.
// Afterwards apply the placement again on the result shape.
// See the method MakeWire()
TopoDS_Edge edge = TopoDS::Edge(xp.Current());
edgeLocation = edge.Location();
edge.Location(TopLoc_Location());
mkWire.Add(edge);
myLocations.push_back(std::make_pair(edge, edgeLocation));
xp.Next();
}
wire = mkWire.Wire();
}
mkOffset.AddWire(wire);
myResult.Nullify();
}
示例9: catch
bool SweepWidget::isPathValid(const Gui::SelectionObject& sel) const
{
const App::DocumentObject* path = sel.getObject();
if (!(path && path->getTypeId().isDerivedFrom(Part::Feature::getClassTypeId())))
return false;
const std::vector<std::string>& sub = sel.getSubNames();
TopoDS_Shape pathShape;
const Part::TopoShape& shape = static_cast<const Part::Feature*>(path)->Shape.getValue();
if (!sub.empty()) {
try {
BRepBuilderAPI_MakeWire mkWire;
for (std::vector<std::string>::const_iterator it = sub.begin(); it != sub.end(); ++it) {
TopoDS_Shape subshape = shape.getSubShape(it->c_str());
mkWire.Add(TopoDS::Edge(subshape));
}
pathShape = mkWire.Wire();
}
catch (...) {
return false;
}
}
else if (shape._Shape.ShapeType() == TopAbs_EDGE) {
pathShape = shape._Shape;
}
else if (shape._Shape.ShapeType() == TopAbs_WIRE) {
BRepBuilderAPI_MakeWire mkWire(TopoDS::Wire(shape._Shape));
pathShape = mkWire.Wire();
}
return (!pathShape.IsNull());
}
示例10: catch
bool SweepWidget::isPathValid(const Gui::SelectionObject& sel) const
{
const App::DocumentObject* path = sel.getObject();
if (!(path && path->getTypeId().isDerivedFrom(Part::Feature::getClassTypeId())))
return false;
const std::vector<std::string>& sub = sel.getSubNames();
TopoDS_Shape pathShape;
const Part::TopoShape& shape = static_cast<const Part::Feature*>(path)->Shape.getValue();
if (!sub.empty()) {
try {
BRepBuilderAPI_MakeWire mkWire;
for (std::vector<std::string>::const_iterator it = sub.begin(); it != sub.end(); ++it) {
TopoDS_Shape subshape = shape.getSubShape(it->c_str());
mkWire.Add(TopoDS::Edge(subshape));
}
pathShape = mkWire.Wire();
}
catch (...) {
return false;
}
}
else if (shape._Shape.ShapeType() == TopAbs_EDGE) {
pathShape = shape._Shape;
}
else if (shape._Shape.ShapeType() == TopAbs_WIRE) {
BRepBuilderAPI_MakeWire mkWire(TopoDS::Wire(shape._Shape));
pathShape = mkWire.Wire();
}
else if (shape._Shape.ShapeType() == TopAbs_COMPOUND) {
try {
TopoDS_Iterator it(shape._Shape);
for (; it.More(); it.Next()) {
if ((it.Value().ShapeType() != TopAbs_EDGE) &&
(it.Value().ShapeType() != TopAbs_WIRE)) {
return false;
}
}
Handle(TopTools_HSequenceOfShape) hEdges = new TopTools_HSequenceOfShape();
Handle(TopTools_HSequenceOfShape) hWires = new TopTools_HSequenceOfShape();
for (TopExp_Explorer xp(shape._Shape, TopAbs_EDGE); xp.More(); xp.Next())
hEdges->Append(xp.Current());
ShapeAnalysis_FreeBounds::ConnectEdgesToWires(hEdges, Precision::Confusion(), Standard_True, hWires);
int len = hWires->Length();
if (len != 1)
return false;
pathShape = hWires->Value(1);
}
catch (...) {
return false;
}
}
return (!pathShape.IsNull());
}
示例11: mkWire9
static TopoDS_Wire mkWire9()
{
Standard_Real aCoords[][3] = {
{0,-1,0},{0,-2,2},{0,0,1},{0,2,2},{0,1,0},{0,2,-2},{0,0,-1},{0,-2,-2}
};
Standard_Integer nPoles = sizeof(aCoords)/(sizeof(Standard_Real)*3);
Handle(Geom_Curve) aCurve = mkPBSplineCurve (nPoles, aCoords);
BRepBuilderAPI_MakeEdge aMkEdge (aCurve);
BRepBuilderAPI_MakeWire aMkWire (aMkEdge);
return aMkWire.Wire();
}
示例12: pt1
TopoDS_Shape OCCPartFactory::makeCube( const Standard_Real width,
const Standard_Real height,
const Standard_Real depth)
{
// define points
gp_Pnt pt1( -width / 2.0, 0.0, 0.0 );
gp_Pnt pt2( -width / 2.0, -depth / 2.0, 0.0 );
gp_Pnt pt3( width / 2.0, -depth / 2.0, 0.0 );
gp_Pnt pt4( width /2.0, 0.0, 0.0 );
// define segments
Handle_Geom_TrimmedCurve seg1 = GC_MakeSegment( pt1, pt2 );
Handle_Geom_TrimmedCurve seg2 = GC_MakeSegment( pt2, pt3 );
Handle_Geom_TrimmedCurve seg3 = GC_MakeSegment( pt3, pt4 );
// make edge
TopoDS_Edge edge1 = BRepBuilderAPI_MakeEdge( seg1 );
TopoDS_Edge edge2 = BRepBuilderAPI_MakeEdge( seg2 );
TopoDS_Edge edge3 = BRepBuilderAPI_MakeEdge( seg3 );
// make wire
TopoDS_Wire wire1 = BRepBuilderAPI_MakeWire( edge1, edge2, edge3 );
//Complete Profile
gp_Ax1 xAxis = gp::OX();
gp_Trsf transfer;
transfer.SetMirror( xAxis );
BRepBuilderAPI_Transform aBRepTrsf( wire1 , transfer );
TopoDS_Shape mirroredShape = aBRepTrsf.Shape();
TopoDS_Wire mirroredWire1 = TopoDS::Wire( mirroredShape );
BRepBuilderAPI_MakeWire mkWire;
mkWire.Add( wire1 );
mkWire.Add( mirroredWire1 );
TopoDS_Wire wireProfile = mkWire.Wire();
//Body : Prism the Profile
TopoDS_Face faceProfile = BRepBuilderAPI_MakeFace( wireProfile );
gp_Vec prismVec( 0.0 , 0.0 , height );
TopoDS_Shape cube = BRepPrimAPI_MakePrism( faceProfile, prismVec);
// cube.setMaterial( Graphic3d_NOM_JADE );
// Handle_AIS_Shape shape = new AIS_Shape( cube );
// shape->SetColor( Quantity_NOC_RED );
// return shape;
return cube;
}
示例13: mkWire3
static TopoDS_Wire mkWire3()
{
BRepBuilderAPI_MakeEdge aMkEdge1 (mkCurve1());
Standard_Real aCoords[][3] = {
{0,10,20},{0,20,10},{0,20,0},{0,0,0}
};
Standard_Integer nPoles = sizeof(aCoords)/(sizeof(Standard_Real)*3);
Handle(Geom_Curve) aCurve = mkBezierCurve (nPoles, aCoords);
BRepBuilderAPI_MakeEdge aMkEdge2 (aCurve);
BRepBuilderAPI_MakeWire aMkWire (aMkEdge1, aMkEdge2);
return aMkWire.Wire();
}
示例14: if
void Pipe::buildPipePath(const Part::TopoShape& shape, const std::vector< std::string >& subedge, TopoDS_Shape& path) {
if (!shape._Shape.IsNull()) {
try {
if (!subedge.empty()) {
//if(SpineTangent.getValue())
//getContiniusEdges(shape, subedge);
BRepBuilderAPI_MakeWire mkWire;
for (std::vector<std::string>::const_iterator it = subedge.begin(); it != subedge.end(); ++it) {
TopoDS_Shape subshape = shape.getSubShape(it->c_str());
mkWire.Add(TopoDS::Edge(subshape));
}
path = mkWire.Wire();
}
else if (shape._Shape.ShapeType() == TopAbs_EDGE) {
path = shape._Shape;
}
else if (shape._Shape.ShapeType() == TopAbs_WIRE) {
BRepBuilderAPI_MakeWire mkWire(TopoDS::Wire(shape._Shape));
path = mkWire.Wire();
}
else if (shape._Shape.ShapeType() == TopAbs_COMPOUND) {
TopoDS_Iterator it(shape._Shape);
for (; it.More(); it.Next()) {
if (it.Value().IsNull())
throw Base::Exception("In valid element in spine.");
if ((it.Value().ShapeType() != TopAbs_EDGE) &&
(it.Value().ShapeType() != TopAbs_WIRE)) {
throw Base::Exception("Element in spine is neither an edge nor a wire.");
}
}
Handle(TopTools_HSequenceOfShape) hEdges = new TopTools_HSequenceOfShape();
Handle(TopTools_HSequenceOfShape) hWires = new TopTools_HSequenceOfShape();
for (TopExp_Explorer xp(shape._Shape, TopAbs_EDGE); xp.More(); xp.Next())
hEdges->Append(xp.Current());
ShapeAnalysis_FreeBounds::ConnectEdgesToWires(hEdges, Precision::Confusion(), Standard_True, hWires);
int len = hWires->Length();
if (len != 1)
throw Base::Exception("Spine is not connected.");
path = hWires->Value(1);
}
else {
throw Base::Exception("Spine is neither an edge nor a wire.");
}
}
catch (Standard_Failure) {
throw Base::Exception("Invalid spine.");
}
}
}
示例15: Update
TopoDS_Wire CCPACSWingProfile::GetWire()
{
Update();
// rebuild closed wire
BRepBuilderAPI_MakeWire closedWireBuilder;
closedWireBuilder.Add(profileAlgo->GetUpperLowerWire());
if (!profileAlgo->GetTrailingEdge().IsNull()) {
closedWireBuilder.Add(profileAlgo->GetTrailingEdge());
}
return closedWireBuilder.Wire();
}