本文整理汇总了C++中BRepBuilderAPI_MakeWire::Add方法的典型用法代码示例。如果您正苦于以下问题:C++ BRepBuilderAPI_MakeWire::Add方法的具体用法?C++ BRepBuilderAPI_MakeWire::Add怎么用?C++ BRepBuilderAPI_MakeWire::Add使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BRepBuilderAPI_MakeWire
的用法示例。
在下文中一共展示了BRepBuilderAPI_MakeWire::Add方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
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;
}
示例2: mf
bool IfcGeom::Kernel::convert(const IfcSchema::IfcCircleHollowProfileDef* l, TopoDS_Shape& face) {
const double r = l->Radius() * getValue(GV_LENGTH_UNIT);
const double t = l->WallThickness() * getValue(GV_LENGTH_UNIT);
if ( r == 0.0f || t == 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);
BRepBuilderAPI_MakeWire outer;
Handle(Geom_Circle) outerCircle = new Geom_Circle(ax, r);
outer.Add(BRepBuilderAPI_MakeEdge(outerCircle));
BRepBuilderAPI_MakeFace mf(outer.Wire(), false);
BRepBuilderAPI_MakeWire inner;
Handle(Geom_Circle) innerCirlce = new Geom_Circle(ax, r-t);
inner.Add(BRepBuilderAPI_MakeEdge(innerCirlce));
mf.Add(inner);
ShapeFix_Shape sfs(mf.Face());
sfs.Perform();
face = TopoDS::Face(sfs.Shape());
return true;
}
示例3: exp
bool IfcGeom::Kernel::convert(const IfcSchema::IfcEdgeCurve* l, TopoDS_Wire& result) {
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 (!IfcGeom::Kernel::convert(((IfcSchema::IfcCartesianPoint*)pnt1), p1) ||
!IfcGeom::Kernel::convert(((IfcSchema::IfcCartesianPoint*)pnt2), p2))
{
return false;
}
BRepBuilderAPI_MakeWire mw;
Handle_Geom_Curve crv;
// The lack of a clear separation between topological and geometrical entities
// is starting to get problematic. If the underlying curve is bounded it is
// assumed that a topological wire can be crafted from it. After which an
// attempt is made to reconstruct it from the individual curves and the vertices
// of the IfcEdgeCurve.
const bool is_bounded = l->EdgeGeometry()->is(IfcSchema::Type::IfcBoundedCurve);
if (!is_bounded && convert_curve(l->EdgeGeometry(), crv)) {
mw.Add(BRepBuilderAPI_MakeEdge(crv, p1, p2));
result = mw;
return true;
} else if (is_bounded && convert_wire(l->EdgeGeometry(), result)) {
if (!l->SameSense()) std::swap(pnt1, pnt2);
TopExp_Explorer exp(result, TopAbs_EDGE);
bool first = true;
while (exp.More()) {
const TopoDS_Edge& ed = TopoDS::Edge(exp.Current());
Standard_Real u1, u2;
Handle(Geom_Curve) ecrv = BRep_Tool::Curve(ed, u1, u2);
exp.Next();
const bool last = !exp.More();
first = false;
if (first && last) {
mw.Add(BRepBuilderAPI_MakeEdge(ecrv, p1, p2));
} else if (first) {
gp_Pnt pu;
ecrv->D0(u2, pu);
mw.Add(BRepBuilderAPI_MakeEdge(ecrv, p1, pu));
} else if (last) {
gp_Pnt pu;
ecrv->D0(u1, pu);
mw.Add(BRepBuilderAPI_MakeEdge(ecrv, pu, p2));
} else {
mw.Add(BRepBuilderAPI_MakeEdge(ecrv, u1, u2));
}
}
result = mw;
return true;
} else {
return false;
}
}
示例4: connectEdges
void CrossSection::connectEdges (const std::list<TopoDS_Edge>& edges, std::list<TopoDS_Wire>& wires) const
{
std::list<TopoDS_Edge> edge_list = edges;
while (edge_list.size() > 0) {
BRepBuilderAPI_MakeWire mkWire;
// add and erase first edge
mkWire.Add(edge_list.front());
edge_list.erase(edge_list.begin());
TopoDS_Wire new_wire = mkWire.Wire(); // current new wire
// try to connect each edge to the wire, the wire is complete if no more egdes are connectible
bool found = false;
do {
found = false;
for (std::list<TopoDS_Edge>::iterator pE = edge_list.begin(); pE != edge_list.end();++pE) {
mkWire.Add(*pE);
if (mkWire.Error() != BRepBuilderAPI_DisconnectedWire) {
// edge added ==> remove it from list
found = true;
edge_list.erase(pE);
new_wire = mkWire.Wire();
break;
}
}
}
while (found);
wires.push_back(new_wire);
}
}
示例5: makeCube
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;
}
示例6: GetWire
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();
}
示例7: exp
bool IfcGeom::Kernel::convert(const IfcSchema::IfcCenterLineProfileDef* l, TopoDS_Shape& face) {
const double d = l->Thickness() * getValue(GV_LENGTH_UNIT) / 2.;
TopoDS_Wire wire;
if (!convert_wire(l->Curve(), wire)) return false;
// BRepOffsetAPI_MakeOffset insists on creating circular arc
// segments for joining the curves that constitute the center
// line. This is probably not in accordance with the IFC spec.
// Although it does not specify a method to join segments
// explicitly, it does dictate 'a constant thickness along the
// curve'. Therefore for simple singular wires a quick
// alternative is provided that uses a straight join.
TopExp_Explorer exp(wire, TopAbs_EDGE);
TopoDS_Edge edge = TopoDS::Edge(exp.Current());
exp.Next();
if (!exp.More()) {
double u1, u2;
Handle(Geom_Curve) curve = BRep_Tool::Curve(edge, u1, u2);
Handle(Geom_TrimmedCurve) trim = new Geom_TrimmedCurve(curve, u1, u2);
Handle(Geom_OffsetCurve) c1 = new Geom_OffsetCurve(trim, d, gp::DZ());
Handle(Geom_OffsetCurve) c2 = new Geom_OffsetCurve(trim, -d, gp::DZ());
gp_Pnt c1a, c1b, c2a, c2b;
c1->D0(c1->FirstParameter(), c1a);
c1->D0(c1->LastParameter(), c1b);
c2->D0(c2->FirstParameter(), c2a);
c2->D0(c2->LastParameter(), c2b);
BRepBuilderAPI_MakeWire mw;
mw.Add(BRepBuilderAPI_MakeEdge(c1));
mw.Add(BRepBuilderAPI_MakeEdge(c1a, c2a));
mw.Add(BRepBuilderAPI_MakeEdge(c2));
mw.Add(BRepBuilderAPI_MakeEdge(c2b, c1b));
face = BRepBuilderAPI_MakeFace(mw.Wire());
} else {
BRepOffsetAPI_MakeOffset offset(BRepBuilderAPI_MakeFace(gp_Pln(gp::Origin(), gp::DZ())));
offset.AddWire(wire);
offset.Perform(d);
face = BRepBuilderAPI_MakeFace(TopoDS::Wire(offset));
}
return true;
}
示例8: 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;
}
示例9: isPathValid
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: 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;
}
示例11: AddWire
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();
}
示例12: 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;
}
示例13: profile_helper
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;
}
示例14:
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;
}
示例15: MakeWire
void BRepOffsetAPI_MakeOffsetFix::MakeWire(TopoDS_Shape& wire)
{
// get the edges of the wire and check which of the stored edges
// serve as input of the wire
TopTools_MapOfShape aMap;
TopExp_Explorer xp(wire, TopAbs_EDGE);
while (xp.More()) {
aMap.Add(xp.Current());
xp.Next();
}
std::list<TopoDS_Edge> edgeList;
for (auto itLoc : myLocations) {
const TopTools_ListOfShape& newShapes = mkOffset.Generated(itLoc.first);
for (TopTools_ListIteratorOfListOfShape it(newShapes); it.More(); it.Next()) {
TopoDS_Shape newShape = it.Value();
if (aMap.Contains(newShape)) {
newShape.Move(itLoc.second);
edgeList.push_back(TopoDS::Edge(newShape));
}
}
}
if (!edgeList.empty()) {
BRepBuilderAPI_MakeWire mkWire;
mkWire.Add(edgeList.front());
edgeList.pop_front();
wire = mkWire.Wire();
bool found = false;
do {
found = false;
for (std::list<TopoDS_Edge>::iterator pE = edgeList.begin(); pE != edgeList.end(); ++pE) {
mkWire.Add(*pE);
if (mkWire.Error() != BRepBuilderAPI_DisconnectedWire) {
// edge added ==> remove it from list
found = true;
edgeList.erase(pE);
wire = mkWire.Wire();
break;
}
}
}
while (found);
}
}