本文整理汇总了C++中BRepBuilderAPI_MakeWire::IsDone方法的典型用法代码示例。如果您正苦于以下问题:C++ BRepBuilderAPI_MakeWire::IsDone方法的具体用法?C++ BRepBuilderAPI_MakeWire::IsDone怎么用?C++ BRepBuilderAPI_MakeWire::IsDone使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BRepBuilderAPI_MakeWire
的用法示例。
在下文中一共展示了BRepBuilderAPI_MakeWire::IsDone方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: edgesToWire
// Make a TopoDS_Wire from a list of TopoDS_Edges
TopoDS_Wire edgesToWire(std::vector<TopoDS_Edge> Edges) {
TopoDS_Wire occwire;
std::vector<TopoDS_Edge>::iterator iEdge;
BRepBuilderAPI_MakeWire mkWire;
for (iEdge = Edges.begin(); iEdge != Edges.end(); ++iEdge){
mkWire.Add(*iEdge);
if (!mkWire.IsDone()) {
Base::Console().Message("FT2FC Trace edgesToWire failed to add wire\n");
}
}
occwire = mkWire.Wire();
BRepLib::BuildCurves3d(occwire);
return(occwire);
}
示例2: GetSplitWire
// Returns the wing profile lower and upper wire fused
TopoDS_Wire CCPACSWingProfile::GetSplitWire()
{
Update();
// rebuild closed wire
BRepBuilderAPI_MakeWire closedWireBuilder;
closedWireBuilder.Add(profileAlgo->GetLowerWire());
closedWireBuilder.Add(profileAlgo->GetUpperWire());
if (!profileAlgo->GetTrailingEdge().IsNull()) {
closedWireBuilder.Add(profileAlgo->GetTrailingEdge());
}
closedWireBuilder.Build();
if (!closedWireBuilder.IsDone()) {
throw CTiglError("Error creating closed wing profile");
}
return closedWireBuilder.Wire();
}
示例3: e
bool IfcGeom::Kernel::convert(const IfcSchema::IfcTrimmedCurve* l, TopoDS_Wire& wire) {
IfcSchema::IfcCurve* basis_curve = l->BasisCurve();
bool isConic = basis_curve->is(IfcSchema::Type::IfcConic);
double parameterFactor = isConic ? getValue(GV_PLANEANGLE_UNIT) : getValue(GV_LENGTH_UNIT);
Handle(Geom_Curve) curve;
if ( !convert_curve(basis_curve,curve) ) return false;
bool trim_cartesian = l->MasterRepresentation() == IfcSchema::IfcTrimmingPreference::IfcTrimmingPreference_CARTESIAN;
IfcEntityList::ptr trims1 = l->Trim1();
IfcEntityList::ptr trims2 = l->Trim2();
bool trimmed1 = false;
bool trimmed2 = false;
unsigned sense_agreement = l->SenseAgreement() ? 0 : 1;
double flts[2];
gp_Pnt pnts[2];
bool has_flts[2] = {false,false};
bool has_pnts[2] = {false,false};
BRepBuilderAPI_MakeWire w;
for ( IfcEntityList::it it = trims1->begin(); it != trims1->end(); it ++ ) {
IfcUtil::IfcBaseClass* i = *it;
if ( i->is(IfcSchema::Type::IfcCartesianPoint) ) {
IfcGeom::Kernel::convert((IfcSchema::IfcCartesianPoint*)i, pnts[sense_agreement] );
has_pnts[sense_agreement] = true;
} else if ( i->is(IfcSchema::Type::IfcParameterValue) ) {
const double value = *((IfcSchema::IfcParameterValue*)i);
flts[sense_agreement] = value * parameterFactor;
has_flts[sense_agreement] = true;
}
}
for ( IfcEntityList::it it = trims2->begin(); it != trims2->end(); it ++ ) {
IfcUtil::IfcBaseClass* i = *it;
if ( i->is(IfcSchema::Type::IfcCartesianPoint) ) {
IfcGeom::Kernel::convert((IfcSchema::IfcCartesianPoint*)i, pnts[1-sense_agreement] );
has_pnts[1-sense_agreement] = true;
} else if ( i->is(IfcSchema::Type::IfcParameterValue) ) {
const double value = *((IfcSchema::IfcParameterValue*)i);
flts[1-sense_agreement] = value * parameterFactor;
has_flts[1-sense_agreement] = true;
}
}
trim_cartesian &= has_pnts[0] && has_pnts[1];
bool trim_cartesian_failed = !trim_cartesian;
if ( trim_cartesian ) {
if ( pnts[0].Distance(pnts[1]) < getValue(GV_WIRE_CREATION_TOLERANCE) ) {
Logger::Message(Logger::LOG_WARNING,"Skipping segment with length below tolerance level:",l->entity);
return false;
}
ShapeFix_ShapeTolerance FTol;
TopoDS_Vertex v1 = BRepBuilderAPI_MakeVertex(pnts[0]);
TopoDS_Vertex v2 = BRepBuilderAPI_MakeVertex(pnts[1]);
FTol.SetTolerance(v1, getValue(GV_WIRE_CREATION_TOLERANCE), TopAbs_VERTEX);
FTol.SetTolerance(v2, getValue(GV_WIRE_CREATION_TOLERANCE), TopAbs_VERTEX);
BRepBuilderAPI_MakeEdge e (curve,v1,v2);
if ( ! e.IsDone() ) {
BRepBuilderAPI_EdgeError err = e.Error();
if ( err == BRepBuilderAPI_PointProjectionFailed ) {
Logger::Message(Logger::LOG_WARNING,"Point projection failed for:",l->entity);
trim_cartesian_failed = true;
}
} else {
w.Add(e.Edge());
}
}
if ( (!trim_cartesian || trim_cartesian_failed) && (has_flts[0] && has_flts[1]) ) {
// The Geom_Line is constructed from a gp_Pnt and gp_Dir, whereas the IfcLine
// is defined by an IfcCartesianPoint and an IfcVector with Magnitude. Because
// the vector is normalised when passed to Geom_Line constructor the magnitude
// needs to be factored in with the IfcParameterValue here.
if ( basis_curve->is(IfcSchema::Type::IfcLine) ) {
IfcSchema::IfcLine* line = static_cast<IfcSchema::IfcLine*>(basis_curve);
const double magnitude = line->Dir()->Magnitude();
flts[0] *= magnitude; flts[1] *= magnitude;
}
if ( basis_curve->is(IfcSchema::Type::IfcEllipse) ) {
IfcSchema::IfcEllipse* ellipse = static_cast<IfcSchema::IfcEllipse*>(basis_curve);
double x = ellipse->SemiAxis1() * getValue(GV_LENGTH_UNIT);
double y = ellipse->SemiAxis2() * getValue(GV_LENGTH_UNIT);
const bool rotated = y > x;
if (rotated) {
flts[0] -= M_PI / 2.;
flts[1] -= M_PI / 2.;
}
}
if ( isConic && ALMOST_THE_SAME(fmod(flts[1]-flts[0],(double)(M_PI*2.0)),0.0f) ) {
w.Add(BRepBuilderAPI_MakeEdge(curve));
} else {
BRepBuilderAPI_MakeEdge e (curve,flts[0],flts[1]);
w.Add(e.Edge());
}
} else if ( trim_cartesian_failed && (has_pnts[0] && has_pnts[1]) ) {
w.Add(BRepBuilderAPI_MakeEdge(pnts[0],pnts[1]));
}
if ( w.IsDone() ) {
wire = w.Wire();
return true;
} else {
return false;
}
}
示例4: aCI
//.........这里部分代码省略.........
int aLen = aCI.GetLength();
if ( aLen > 0 ) {
for (int ind = 1; ind <= aLen; ind++) {
TopoDS_Shape aShapeVertex;
if (GEOMImpl_ILocalOperations::GetSubShape
(aWire, aCI.GetVertex(ind), aShapeVertex))
if (mapShape.Add(aShapeVertex))
aVertexList.Append( aShapeVertex );
}
} else { // get all vertices from wire
TopExp_Explorer anExp( aWire, TopAbs_VERTEX );
for ( ; anExp.More(); anExp.Next() ) {
if (mapShape.Add(anExp.Current()))
aVertexList.Append( anExp.Current() );
}
}
if (aVertexList.IsEmpty())
Standard_ConstructionError::Raise("Invalid input no vertices to make fillet");
//INFO: this algorithm implemented in assumption that user can select both
// vertices of some edges to make fillet. In this case we should remember
// already modified initial edges to take care in next fillet step
TopTools_DataMapOfShapeShape anEdgeToEdgeMap;
//iterates on vertices, and make fillet on each couple of edges
//collect result fillet edges in list
TopTools_ListOfShape aListOfNewEdge;
// remember relation between initial and modified map
TopTools_IndexedDataMapOfShapeListOfShape aMapVToEdges;
TopExp::MapShapesAndAncestors( aWire, TopAbs_VERTEX, TopAbs_EDGE, aMapVToEdges );
TopTools_ListIteratorOfListOfShape anIt( aVertexList );
for ( ; anIt.More(); anIt.Next() ) {
TopoDS_Vertex aV = TopoDS::Vertex( anIt.Value() );
if ( aV.IsNull() || !aMapVToEdges.Contains( aV ) )
continue;
const TopTools_ListOfShape& aVertexEdges = aMapVToEdges.FindFromKey( aV );
if ( aVertexEdges.Extent() != 2 )
continue; // no input data to make fillet
TopoDS_Edge anEdge1 = TopoDS::Edge( aVertexEdges.First() );
TopoDS_Edge anEdge2 = TopoDS::Edge( aVertexEdges.Last() );
// check if initial edges already modified in previous fillet operation
if ( anEdgeToEdgeMap.IsBound( anEdge1 ) ) anEdge1 = TopoDS::Edge(anEdgeToEdgeMap.Find( anEdge1 ));
if ( anEdgeToEdgeMap.IsBound( anEdge2 ) ) anEdge2 = TopoDS::Edge(anEdgeToEdgeMap.Find( anEdge2 ));
if ( anEdge1.IsNull() || anEdge2.IsNull() || anEdge1.IsSame( anEdge2 ) )
continue; //no input data to make fillet
// create plane on 2 edges
gp_Pln aPlane;
if ( !takePlane(anEdge1, anEdge2, aV, aPlane) )
continue; // seems edges does not belong to same plane or parallel (fillet can not be build)
GEOMImpl_Fillet1d aFilletAlgo(anEdge1, anEdge2, aPlane);
if ( !aFilletAlgo.Perform(rad) )
continue; // can not create fillet with given radius
// take fillet result in given vertex
TopoDS_Edge aModifE1, aModifE2;
TopoDS_Edge aNewE = aFilletAlgo.Result(BRep_Tool::Pnt(aV), aModifE1, aModifE2);
if (aNewE.IsNull())
continue; // no result found
// add new created edges and take modified edges
aListOfNewEdge.Append( aNewE );
// check if face edges modified,
// if yes, than map to original edges (from vertex-edges list), because edges can be modified before
if (aModifE1.IsNull() || !anEdge1.IsSame( aModifE1 ))
addEdgeRelation( anEdgeToEdgeMap, TopoDS::Edge(aVertexEdges.First()), aModifE1 );
if (aModifE2.IsNull() || !anEdge2.IsSame( aModifE2 ))
addEdgeRelation( anEdgeToEdgeMap, TopoDS::Edge(aVertexEdges.Last()), aModifE2 );
}
if ( anEdgeToEdgeMap.IsEmpty() && aListOfNewEdge.IsEmpty() ) {
StdFail_NotDone::Raise("1D Fillet can't be computed on the given shape with the given radius");
return 0;
}
// create new wire instead of original
for ( TopExp_Explorer anExp( aWire, TopAbs_EDGE ); anExp.More(); anExp.Next() ) {
TopoDS_Shape anEdge = anExp.Current();
if ( !anEdgeToEdgeMap.IsBound( anEdge ) )
aListOfNewEdge.Append( anEdge );
else if (!anEdgeToEdgeMap.Find( anEdge ).IsNull())
aListOfNewEdge.Append( anEdgeToEdgeMap.Find( anEdge ) );
}
GEOMImpl_IShapesOperations::SortShapes( aListOfNewEdge );
BRepBuilderAPI_MakeWire aWireTool;
aWireTool.Add( aListOfNewEdge );
aWireTool.Build();
if (!aWireTool.IsDone())
return 0;
aWire = aWireTool.Wire();
aFunction->SetValue(aWire);
log.SetTouched(Label());
return 1;
}
示例5: DummyHP
//.........这里部分代码省略.........
move = none;
break;
}
case 'W':
{
if (a(0) == "WW")
close = Standard_True;
else if(a(0) == "WF") {
close = Standard_True;
face = Standard_True;
}
i = n - 1;
break;
}
default:
{
MESSAGE("profile : unknown code " << a(i));
return;
}
}
again :
switch (move)
{
case line :
{
if (length < 0) {
length = -length;
dx = -dx;
dy = -dy;
}
Handle(Geom2d_Line) l = new Geom2d_Line(gp_Pnt2d(x,y),gp_Dir2d(dx,dy));
BRepBuilderAPI_MakeEdge ME (GeomAPI::To3d(l,P),0,length);
if (!ME.IsDone())
return;
MW.Add(ME);
x += length*dx;
y += length*dy;
break;
}
case circle :
{
Standard_Boolean sense = Standard_True;
if (radius < 0) {
radius = -radius;
sense = !sense;
dx = -dx;
dy = -dy;
}
gp_Ax2d ax(gp_Pnt2d(x-radius*dy,y+radius*dx),gp_Dir2d(dy,-dx));
if (angle < 0) {
angle = -angle;
sense = !sense;
}
Handle(Geom2d_Circle) c = new Geom2d_Circle(ax,radius,sense);
BRepBuilderAPI_MakeEdge ME (GeomAPI::To3d(c,P),0,angle);
if (!ME.IsDone())
return;
MW.Add(ME);
gp_Pnt2d p;
gp_Vec2d v;
c->D1(angle,p,v);
x = p.X();
y = p.Y();
dx = v.X() / radius;
dy = v.Y() / radius;
示例6: convert
bool IfcGeom::convert(const Ifc2x3::IfcTrimmedCurve::ptr l, TopoDS_Wire& wire) {
Ifc2x3::IfcCurve::ptr basis_curve = l->BasisCurve();
bool isConic = basis_curve->is(Ifc2x3::Type::IfcConic);
double parameterFactor = isConic ? IfcGeom::GetValue(GV_PLANEANGLE_UNIT) : IfcGeom::GetValue(GV_LENGTH_UNIT);
Handle(Geom_Curve) curve;
if ( ! IfcGeom::convert_curve(basis_curve,curve) ) return false;
bool trim_cartesian = l->MasterRepresentation() == Ifc2x3::IfcTrimmingPreference::IfcTrimmingPreference_CARTESIAN;
IfcUtil::IfcAbstractSelect::list trims1 = l->Trim1();
IfcUtil::IfcAbstractSelect::list trims2 = l->Trim2();
bool trimmed1 = false;
bool trimmed2 = false;
unsigned sense_agreement = l->SenseAgreement() ? 0 : 1;
double flts[2];
gp_Pnt pnts[2];
bool has_flts[2] = {false,false};
bool has_pnts[2] = {false,false};
BRepBuilderAPI_MakeWire w;
for ( IfcUtil::IfcAbstractSelect::it it = trims1->begin(); it != trims1->end(); it ++ ) {
const IfcUtil::IfcAbstractSelect::ptr i = *it;
if ( i->is(Ifc2x3::Type::IfcCartesianPoint) ) {
IfcGeom::convert(reinterpret_pointer_cast<IfcUtil::IfcAbstractSelect,Ifc2x3::IfcCartesianPoint>(i), pnts[sense_agreement] );
has_pnts[sense_agreement] = true;
} else if ( i->is(Ifc2x3::Type::IfcParameterValue) ) {
const double value = *reinterpret_pointer_cast<IfcUtil::IfcAbstractSelect,IfcUtil::IfcArgumentSelect>(i)->wrappedValue();
flts[sense_agreement] = value * parameterFactor;
has_flts[sense_agreement] = true;
}
}
for ( IfcUtil::IfcAbstractSelect::it it = trims2->begin(); it != trims2->end(); it ++ ) {
const IfcUtil::IfcAbstractSelect::ptr i = *it;
if ( i->is(Ifc2x3::Type::IfcCartesianPoint) ) {
IfcGeom::convert(reinterpret_pointer_cast<IfcUtil::IfcAbstractSelect,Ifc2x3::IfcCartesianPoint>(i), pnts[1-sense_agreement] );
has_pnts[1-sense_agreement] = true;
} else if ( i->is(Ifc2x3::Type::IfcParameterValue) ) {
const double value = *reinterpret_pointer_cast<IfcUtil::IfcAbstractSelect,IfcUtil::IfcArgumentSelect>(i)->wrappedValue();
flts[1-sense_agreement] = value * parameterFactor;
has_flts[1-sense_agreement] = true;
}
}
trim_cartesian &= has_pnts[0] && has_pnts[1];
bool trim_cartesian_failed = !trim_cartesian;
if ( trim_cartesian ) {
if ( pnts[0].Distance(pnts[1]) < GetValue(GV_WIRE_CREATION_TOLERANCE) ) {
Logger::Message(Logger::LOG_WARNING,"Skipping segment with length below tolerance level:",l->entity);
return false;
}
ShapeFix_ShapeTolerance FTol;
TopoDS_Vertex v1 = BRepBuilderAPI_MakeVertex(pnts[0]);
TopoDS_Vertex v2 = BRepBuilderAPI_MakeVertex(pnts[1]);
FTol.SetTolerance(v1, GetValue(GV_WIRE_CREATION_TOLERANCE), TopAbs_VERTEX);
FTol.SetTolerance(v2, GetValue(GV_WIRE_CREATION_TOLERANCE), TopAbs_VERTEX);
BRepBuilderAPI_MakeEdge e (curve,v1,v2);
if ( ! e.IsDone() ) {
BRepBuilderAPI_EdgeError err = e.Error();
if ( err == BRepBuilderAPI_PointProjectionFailed ) {
Logger::Message(Logger::LOG_WARNING,"Point projection failed for:",l->entity);
trim_cartesian_failed = true;
}
} else {
w.Add(e.Edge());
}
}
if ( (!trim_cartesian || trim_cartesian_failed) && (has_flts[0] && has_flts[1]) ) {
if ( isConic && ALMOST_THE_SAME(fmod(flts[1]-flts[0],(double)(M_PI*2.0)),0.0f) ) {
w.Add(BRepBuilderAPI_MakeEdge(curve));
} else {
BRepBuilderAPI_MakeEdge e (curve,flts[0],flts[1]);
w.Add(e.Edge());
}
} else if ( trim_cartesian_failed && (has_pnts[0] && has_pnts[1]) ) {
w.Add(BRepBuilderAPI_MakeEdge(pnts[0],pnts[1]));
}
if ( w.IsDone() ) {
wire = w.Wire();
return true;
} else {
return false;
}
}
示例7: Execute
//=======================================================================
//function : Execute
//purpose :
//=======================================================================
Standard_Integer GEOMImpl_ChamferDriver::Execute(TFunction_Logbook& log) const
{
if (Label().IsNull()) return 0;
Handle(GEOM_Function) aFunction = GEOM_Function::GetFunction(Label());
GEOMImpl_IChamfer aCI (aFunction);
Standard_Integer aType = aFunction->GetType();
TopoDS_Shape aShape;
Handle(GEOM_Function) aRefShape = aCI.GetShape();
TopoDS_Shape aShapeBase = aRefShape->GetValue();
if (aType == CHAMFER_SHAPE_EDGES_2D)
{
BRepFilletAPI_MakeFillet2d fill;
TopoDS_Face aFace;
Standard_Boolean aWireFlag = Standard_False;
if (aShapeBase.ShapeType() == TopAbs_FACE)
aFace = TopoDS::Face(aShapeBase);
else if (aShapeBase.ShapeType() == TopAbs_WIRE)
{
TopoDS_Wire aWire = TopoDS::Wire(aShapeBase);
BRepBuilderAPI_MakeFace aMF(aWire);
aMF.Build();
if (!aMF.IsDone()) {
StdFail_NotDone::Raise("Cannot build initial face from given wire");
}
aFace = aMF.Face();
aWireFlag = Standard_True;
}
else
StdFail_NotDone::Raise("Base shape is neither a face or a wire !");
fill.Init(aFace);
double aD1_2D = aCI.GetD1();
double aD2_2D = aCI.GetD2();
TopoDS_Shape aShapeFace1, aShapeFace2;
if (GEOMImpl_ILocalOperations::GetSubShape(aShapeBase, aCI.Get2DEdge1(), aShapeFace1) &&
GEOMImpl_ILocalOperations::GetSubShape(aShapeBase, aCI.Get2DEdge2(), aShapeFace2))
{
fill.AddChamfer(TopoDS::Edge(aShapeFace1), TopoDS::Edge(aShapeFace2), aD1_2D, aD2_2D);
}
else
StdFail_NotDone::Raise("Cannot get 2d egde from sub-shape index!");
fill.Build();
if (!fill.IsDone()) {
StdFail_NotDone::Raise("Chamfer can not be computed on the given shape with the given parameters");
}
if (aWireFlag)
{
BRepBuilderAPI_MakeWire MW;
TopExp_Explorer exp (fill.Shape(), TopAbs_EDGE);
for (; exp.More(); exp.Next())
MW.Add(TopoDS::Edge(exp.Current()));
MW.Build();
if (!MW.IsDone())
StdFail_NotDone::Raise("Resulting wire cannot be built");
aShape = MW.Shape();
}
else
aShape = fill.Shape();
}
else
{
// Check the shape type. It have to be shell
// or solid, or compsolid, or compound of these shapes.
if (!isGoodForChamfer(aShapeBase)) {
StdFail_NotDone::Raise
("Wrong shape. Must be shell or solid, or compsolid or compound of these shapes");
}
BRepFilletAPI_MakeChamfer fill (aShapeBase);
if (aType == CHAMFER_SHAPE_ALL) {
// symmetric chamfer on all edges
double aD = aCI.GetD();
TopTools_IndexedDataMapOfShapeListOfShape M;
GEOMImpl_Block6Explorer::MapShapesAndAncestors(aShapeBase, TopAbs_EDGE, TopAbs_FACE, M);
for (int i = 1; i <= M.Extent(); i++) {
TopoDS_Edge E = TopoDS::Edge(M.FindKey(i));
TopoDS_Face F = TopoDS::Face(M.FindFromIndex(i).First());
if (!BRepTools::IsReallyClosed(E, F) &&
!BRep_Tool::Degenerated(E) &&
M.FindFromIndex(i).Extent() == 2)
fill.Add(aD, E, F);
}
//.........这里部分代码省略.........