本文整理汇总了C++中TFunction_Logbook::SetTouched方法的典型用法代码示例。如果您正苦于以下问题:C++ TFunction_Logbook::SetTouched方法的具体用法?C++ TFunction_Logbook::SetTouched怎么用?C++ TFunction_Logbook::SetTouched使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TFunction_Logbook
的用法示例。
在下文中一共展示了TFunction_Logbook::SetTouched方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Execute
//=======================================================================
//function : Execute
//purpose :
//=======================================================================
Standard_Integer GEOMImpl_CylinderDriver::Execute(TFunction_Logbook& log) const
{
if (Label().IsNull()) return 0;
Handle(GEOM_Function) aFunction = GEOM_Function::GetFunction(Label());
GEOMImpl_ICylinder aCI (aFunction);
Standard_Integer aType = aFunction->GetType();
gp_Pnt aP;
gp_Vec aV;
if (aType == CYLINDER_R_H) {
aP = gp::Origin();
aV = gp::DZ();
}
else if (aType == CYLINDER_PNT_VEC_R_H) {
Handle(GEOM_Function) aRefPoint = aCI.GetPoint();
Handle(GEOM_Function) aRefVector = aCI.GetVector();
TopoDS_Shape aShapePnt = aRefPoint->GetValue();
TopoDS_Shape aShapeVec = aRefVector->GetValue();
if (aShapePnt.IsNull() || aShapeVec.IsNull()) {
Standard_NullObject::Raise("Cylinder creation aborted: point or vector is not defined");
}
if (aShapePnt.ShapeType() != TopAbs_VERTEX ||
aShapeVec.ShapeType() != TopAbs_EDGE) {
Standard_TypeMismatch::Raise("Cylinder creation aborted: point or vector shapes has wrong type");
}
aP = BRep_Tool::Pnt(TopoDS::Vertex(aShapePnt));
TopoDS_Edge anE = TopoDS::Edge(aShapeVec);
TopoDS_Vertex V1, V2;
TopExp::Vertices(anE, V1, V2, Standard_True);
if (V1.IsNull() || V2.IsNull()) {
Standard_NullObject::Raise("Cylinder creation aborted: vector is not defined");
}
aV = gp_Vec(BRep_Tool::Pnt(V1), BRep_Tool::Pnt(V2));
}
else {
return 0;
}
if (aCI.GetH() < 0.0) aV.Reverse();
gp_Ax2 anAxes (aP, aV);
BRepPrimAPI_MakeCylinder MC (anAxes, aCI.GetR(), Abs(aCI.GetH()));
MC.Build();
if (!MC.IsDone()) {
StdFail_NotDone::Raise("Cylinder can't be computed from the given parameters");
}
TopoDS_Shape aShape = MC.Shape();
if (aShape.IsNull()) return 0;
aFunction->SetValue(aShape);
log.SetTouched(Label());
return 1;
}
示例2: Execute
//=======================================================================
//function : Execute
//purpose :
//=======================================================================
Standard_Integer GEOM_SubShapeDriver::Execute(TFunction_Logbook& log) const
{
if (Label().IsNull()) return 0;
Handle(GEOM_Function) aFunction = GEOM_Function::GetFunction(Label());
GEOM_ISubShape aCI (aFunction);
TDF_Label aLabel = aCI.GetMainShape()->GetOwnerEntry();
if (aLabel.IsRoot()) return 0;
Handle(GEOM_Object) anObj = GEOM_Object::GetObject(aLabel);
if (anObj.IsNull()) return 0;
TopoDS_Shape aMainShape = anObj->GetValue();
if (aMainShape.IsNull()) return 0;
Handle(TColStd_HArray1OfInteger) anIndices = aCI.GetIndices();
if (anIndices.IsNull() || anIndices->Length() <= 0) return 0;
BRep_Builder B;
TopoDS_Compound aCompound;
TopoDS_Shape aShape;
if (anIndices->Length() == 1 && anIndices->Value(1) == -1) { //The empty sub-shape
B.MakeCompound(aCompound);
aShape = aCompound;
}
else {
TopTools_IndexedMapOfShape aMapOfShapes;
TopExp::MapShapes(aMainShape, aMapOfShapes);
if (anIndices->Length() > 1) {
B.MakeCompound(aCompound);
for (int i = anIndices->Lower(); i <= anIndices->Upper(); i++) {
if (aMapOfShapes.Extent() < anIndices->Value(i))
Standard_NullObject::Raise("GEOM_SubShapeDriver::Execute: Index is out of range");
TopoDS_Shape aSubShape = aMapOfShapes.FindKey(anIndices->Value(i));
if (aSubShape.IsNull()) continue;
B.Add(aCompound,aSubShape);
}
aShape = aCompound;
}
else {
int i = anIndices->Lower();
if (aMapOfShapes.Extent() < anIndices->Value(i))
Standard_NullObject::Raise("GEOM_SubShapeDriver::Execute: Index is out of range");
aShape = aMapOfShapes.FindKey(anIndices->Value(i));
}
}
if (aShape.IsNull()) return 0;
aFunction->SetValue(aShape);
log.SetTouched(Label());
return 1;
}
示例3: Execute
//=======================================================================
//function : Execute
//purpose :
//=======================================================================
Standard_Integer GEOMImpl_BoxDriver::Execute(TFunction_Logbook& log) const
{
if (Label().IsNull()) return 0;
Handle(GEOM_Function) aFunction = GEOM_Function::GetFunction(Label());
GEOMImpl_IBox aBI (aFunction);
Standard_Integer aType = aFunction->GetType();
TopoDS_Shape aShape;
if (aType == BOX_DX_DY_DZ) {
BRepPrimAPI_MakeBox MB (aBI.GetDX(), aBI.GetDY(), aBI.GetDZ());
MB.Build();
if (!MB.IsDone()) {
StdFail_NotDone::Raise("Box with the given dimensions can not be computed");
}
aShape = MB.Shape();
}
else if (aType == BOX_TWO_PNT) {
Handle(GEOM_Function) aRefPoint1 = aBI.GetRef1();
Handle(GEOM_Function) aRefPoint2 = aBI.GetRef2();
TopoDS_Shape aShape1 = aRefPoint1->GetValue();
TopoDS_Shape aShape2 = aRefPoint2->GetValue();
if (aShape1.ShapeType() == TopAbs_VERTEX &&
aShape2.ShapeType() == TopAbs_VERTEX) {
gp_Pnt P1 = BRep_Tool::Pnt(TopoDS::Vertex(aShape1));
gp_Pnt P2 = BRep_Tool::Pnt(TopoDS::Vertex(aShape2));
if (std::abs(P1.X() - P2.X()) < Precision::Confusion() ||
std::abs(P1.Y() - P2.Y()) < Precision::Confusion() ||
std::abs(P1.Z() - P2.Z()) < Precision::Confusion() ) {
StdFail_NotDone::Raise("Box can not be created, the points belong both to one of the OXY, OYZ or OZX planes");
return 0;
}
BRepPrimAPI_MakeBox MB (P1,P2);
MB.Build();
if (!MB.IsDone()) {
StdFail_NotDone::Raise("Box can not be computed from the given point");
}
aShape = MB.Shape();
}
}
else {
}
if (aShape.IsNull()) return 0;
aFunction->SetValue(aShape);
log.SetTouched(Label());
return 1;
}
示例4: Execute
//=======================================================================
//function : Execute
//purpose :
//=======================================================================
Standard_Integer GEOMImpl_HealingDriver::Execute(TFunction_Logbook& log) const
{
if (Label().IsNull()) return 0;
Handle(GEOM_Function) aFunction = GEOM_Function::GetFunction(Label());
if (aFunction.IsNull()) return 0;
GEOMImpl_IHealing HI (aFunction);
Standard_Integer aType = aFunction->GetType();
Handle(GEOM_Function) anOriginalFunction = HI.GetOriginal();
if (anOriginalFunction.IsNull()) return 0;
TopoDS_Shape aShape, anOriginalShape = anOriginalFunction->GetValue();
if (anOriginalShape.IsNull()) return 0;
switch (aType)
{
case SHAPE_PROCESS:
ShapeProcess(&HI, anOriginalShape, aShape);
break;
case SUPPRESS_FACES:
SuppressFaces(&HI, anOriginalShape, aShape);
break;
case CLOSE_CONTOUR:
CloseContour(&HI, anOriginalShape, aShape);
break;
case REMOVE_INT_WIRES:
RemoveIntWires(&HI, anOriginalShape, aShape);
break;
case FILL_HOLES:
RemoveHoles(&HI, anOriginalShape, aShape);
break;
case SEWING:
Sew(&HI, anOriginalShape, aShape);
break;
case DIVIDE_EDGE:
AddPointOnEdge(&HI, anOriginalShape, aShape);
break;
case CHANGE_ORIENTATION:
ChangeOrientation(&HI, anOriginalShape, aShape);
break;
case LIMIT_TOLERANCE:
LimitTolerance(&HI, anOriginalShape, aShape);
break;
default:
return 0;
}
if (aShape.IsNull())
raiseNotDoneExeption( ShHealOper_ErrorExecution );
aFunction->SetValue(aShape);
log.SetTouched(Label());
return 1;
}
示例5: Execute
//=======================================================================
//function : Execute
//purpose :
//=======================================================================
Standard_Integer GEOMImpl_TorusDriver::Execute(TFunction_Logbook& log) const
{
if (Label().IsNull()) return 0;
Handle(GEOM_Function) aFunction = GEOM_Function::GetFunction(Label());
GEOMImpl_ITorus aCI (aFunction);
Standard_Integer aType = aFunction->GetType();
TopoDS_Shape aShape;
if (aType == TORUS_RR) {
aShape = BRepPrimAPI_MakeTorus(aCI.GetRMajor(), aCI.GetRMinor()).Shape();
} else if (aType == TORUS_PNT_VEC_RR) {
Handle(GEOM_Function) aRefPoint = aCI.GetCenter();
Handle(GEOM_Function) aRefVector = aCI.GetVector();
TopoDS_Shape aShapePnt = aRefPoint->GetValue();
TopoDS_Shape aShapeVec = aRefVector->GetValue();
if (aShapePnt.ShapeType() != TopAbs_VERTEX) {
Standard_TypeMismatch::Raise("Torus Center must be a vertex");
}
if (aShapeVec.ShapeType() != TopAbs_EDGE) {
Standard_TypeMismatch::Raise("Torus Axis must be an edge");
}
gp_Pnt aP = BRep_Tool::Pnt(TopoDS::Vertex(aShapePnt));
TopoDS_Edge anE = TopoDS::Edge(aShapeVec);
TopoDS_Vertex V1, V2;
TopExp::Vertices(anE, V1, V2, Standard_True);
if (V1.IsNull() || V2.IsNull()) {
Standard_ConstructionError::Raise("Bad edge for the Torus Axis given");
}
gp_Vec aV (BRep_Tool::Pnt(V1), BRep_Tool::Pnt(V2));
if (aV.Magnitude() < Precision::Confusion()) {
Standard_ConstructionError::Raise
("End vertices of edge, defining the Torus Axis, are too close");
}
gp_Ax2 anAxes (aP, aV);
BRepPrimAPI_MakeTorus MT (anAxes, aCI.GetRMajor(), aCI.GetRMinor());
if (!MT.IsDone()) MT.Build();
if (!MT.IsDone()) StdFail_NotDone::Raise("Torus construction algorithm has failed");
aShape = MT.Shape();
} else {
}
if (aShape.IsNull()) return 0;
aFunction->SetValue(aShape);
log.SetTouched(Label());
return 1;
}
示例6: Execute
//=======================================================================
//function : Execute
//purpose :
//=======================================================================
Standard_Integer GEOMImpl_SphereDriver::Execute(TFunction_Logbook& log) const
{
if (Label().IsNull()) return 0;
Handle(GEOM_Function) aFunction = GEOM_Function::GetFunction(Label());
GEOMImpl_ISphere aCI (aFunction);
Standard_Integer aType = aFunction->GetType();
TopoDS_Shape aShape;
char aMsg[] = "Sphere creation aborted: radius value less than 1e-07 is not acceptable";
double theAngle = aCI.GetAngle();
if (theAngle == 0.)
theAngle = PI * 2.;
double theVCoordStart = aCI.GetVCoordStart();
double theVCoordEnd = aCI.GetVCoordEnd();
if (aType == SPHERE_R) {
double anR = aCI.GetR();
if (anR < Precision::Confusion())
Standard_ConstructionError::Raise(aMsg);
//There seems to be an issue with the BRepPrimAPI_MakeSphere command concerning
//the limitations on V coodinates of its parametric space ... (Will not be used for the moment)
aShape = BRepPrimAPI_MakeSphere(anR /*, theVCoordStart, theVCoordEnd*/ , theAngle).Shape();
}
else if (aType == SPHERE_PNT_R) {
double anR = aCI.GetR();
if (anR < Precision::Confusion())
Standard_ConstructionError::Raise(aMsg);
Handle(GEOM_Function) aRefPoint = aCI.GetPoint();
TopoDS_Shape aShapePnt = aRefPoint->GetValue();
if (aShapePnt.ShapeType() != TopAbs_VERTEX)
Standard_ConstructionError::Raise("Invalid shape given for sphere center: it must be a point");
gp_Pnt aP = BRep_Tool::Pnt(TopoDS::Vertex(aShapePnt));
aShape = BRepPrimAPI_MakeSphere(aP, anR/*, theVCoordStart, theVCoordEnd*/, theAngle).Shape();
}
else {
}
if (aShape.IsNull()) return 0;
aFunction->SetValue(aShape);
log.SetTouched(Label());
return 1;
}
示例7: Execute
//=======================================================================
//function : Execute
//purpose :
//=======================================================================
Standard_Integer GEOMImpl_SphereDriver::Execute(TFunction_Logbook& log) const
{
if (Label().IsNull()) return 0;
Handle(GEOM_Function) aFunction = GEOM_Function::GetFunction(Label());
GEOMImpl_ISphere aCI (aFunction);
Standard_Integer aType = aFunction->GetType();
TopoDS_Shape aShape;
char aMsg[] = "Sphere creation aborted: radius value less than 1e-07 is not acceptable";
if (aType == SPHERE_R) {
double anR = aCI.GetR();
if (anR < Precision::Confusion())
Standard_ConstructionError::Raise(aMsg);
aShape = BRepPrimAPI_MakeSphere(anR).Shape();
}
else if (aType == SPHERE_PNT_R) {
double anR = aCI.GetR();
if (anR < Precision::Confusion())
Standard_ConstructionError::Raise(aMsg);
Handle(GEOM_Function) aRefPoint = aCI.GetPoint();
TopoDS_Shape aShapePnt = aRefPoint->GetValue();
if (aShapePnt.ShapeType() != TopAbs_VERTEX)
Standard_ConstructionError::Raise("Invalid shape given for sphere center: it must be a point");
gp_Pnt aP = BRep_Tool::Pnt(TopoDS::Vertex(aShapePnt));
aShape = BRepPrimAPI_MakeSphere(aP, anR).Shape();
}
else {
}
if (aShape.IsNull()) return 0;
aFunction->SetValue(aShape);
log.SetTouched(Label());
return 1;
}
示例8: Execute
//.........这里部分代码省略.........
if (!V1.IsNull() && !V2.IsNull()) {
aV = gp_Vec(BRep_Tool::Pnt(V1), BRep_Tool::Pnt(V2));
if (aV.Magnitude() < gp::Resolution()) {
Standard_ConstructionError::Raise
("Circle creation aborted: vector of zero length is given");
}
}
}
// Axes
gp_Ax2 anAxes (aP, aV);
// Radius
double anR = aCI.GetRadius();
char aMsg[] = "Circle creation aborted: radius value less than 1e-07 is not acceptable";
if (anR < Precision::Confusion())
Standard_ConstructionError::Raise(aMsg);
// Circle
gp_Circ aCirc (anAxes, anR);
aShape = BRepBuilderAPI_MakeEdge(aCirc).Edge();
}
else if (aType == CIRCLE_CENTER_TWO_PNT) {
Handle(GEOM_Function) aRefPoint1 = aCI.GetPoint1();
Handle(GEOM_Function) aRefPoint2 = aCI.GetPoint2();
Handle(GEOM_Function) aRefPoint3 = aCI.GetPoint3();
TopoDS_Shape aShapePnt1 = aRefPoint1->GetValue();
TopoDS_Shape aShapePnt2 = aRefPoint2->GetValue();
TopoDS_Shape aShapePnt3 = aRefPoint3->GetValue();
if (aShapePnt1.ShapeType() == TopAbs_VERTEX &&
aShapePnt2.ShapeType() == TopAbs_VERTEX &&
aShapePnt3.ShapeType() == TopAbs_VERTEX)
{
gp_Pnt aP1 = BRep_Tool::Pnt(TopoDS::Vertex(aShapePnt1));
gp_Pnt aP2 = BRep_Tool::Pnt(TopoDS::Vertex(aShapePnt2));
gp_Pnt aP3 = BRep_Tool::Pnt(TopoDS::Vertex(aShapePnt3));
if (aP1.Distance(aP2) < gp::Resolution() ||
aP1.Distance(aP3) < gp::Resolution() ||
aP2.Distance(aP3) < gp::Resolution())
Standard_ConstructionError::Raise("Circle creation aborted: coincident points given");
if (gp_Vec(aP1, aP2).IsParallel(gp_Vec(aP1, aP3), Precision::Angular()))
Standard_ConstructionError::Raise("Circle creation aborted: points lay on one line");
double x, y, z, x1, y1, z1, x2, y2, z2, dx, dy, dz, dx2, dy2, dz2, dx3, dy3, dz3, aRadius;
//Calculations for Radius
x = aP1.X(); y = aP1.Y(); z = aP1.Z();
x1 = aP2.X(); y1 = aP2.Y(); z1 = aP2.Z();
dx = x1 - x;
dy = y1 - y;
dz = z1 - z;
aRadius = sqrt(dx*dx + dy*dy + dz*dz);
//Calculations for Plane Vector
x2 = aP3.X(); y2 = aP3.Y(); z2 = aP3.Z();
dx2 = x2 - x; dy2 = y2 - y; dz2 = z2 - z;
dx3 = ((dy*dz2) - (dy2*dz))/100;
dy3 = ((dx2*dz) - (dx*dz2))/100;
dz3 = ((dx*dy2) - (dx2*dy))/100;
//Make Plane Vector
gp_Dir aDir ( dx3, dy3, dz3 );
//Make Circle
gp_Ax2 anAxes (aP1, aDir);
gp_Circ aCirc (anAxes, aRadius);
aShape = BRepBuilderAPI_MakeEdge(aCirc).Edge();
}
}
else if (aType == CIRCLE_THREE_PNT) {
Handle(GEOM_Function) aRefPoint1 = aCI.GetPoint1();
Handle(GEOM_Function) aRefPoint2 = aCI.GetPoint2();
Handle(GEOM_Function) aRefPoint3 = aCI.GetPoint3();
TopoDS_Shape aShapePnt1 = aRefPoint1->GetValue();
TopoDS_Shape aShapePnt2 = aRefPoint2->GetValue();
TopoDS_Shape aShapePnt3 = aRefPoint3->GetValue();
if (aShapePnt1.ShapeType() == TopAbs_VERTEX &&
aShapePnt2.ShapeType() == TopAbs_VERTEX &&
aShapePnt3.ShapeType() == TopAbs_VERTEX) {
gp_Pnt aP1 = BRep_Tool::Pnt(TopoDS::Vertex(aShapePnt1));
gp_Pnt aP2 = BRep_Tool::Pnt(TopoDS::Vertex(aShapePnt2));
gp_Pnt aP3 = BRep_Tool::Pnt(TopoDS::Vertex(aShapePnt3));
if (aP1.Distance(aP2) < gp::Resolution() ||
aP1.Distance(aP3) < gp::Resolution() ||
aP2.Distance(aP3) < gp::Resolution())
Standard_ConstructionError::Raise("Circle creation aborted: coincident points given");
if (gp_Vec(aP1, aP2).IsParallel(gp_Vec(aP1, aP3), Precision::Angular()))
Standard_ConstructionError::Raise("Circle creation aborted: points lay on one line");
Handle(Geom_Circle) aCirc = GC_MakeCircle(aP1, aP2, aP3).Value();
aShape = BRepBuilderAPI_MakeEdge(aCirc).Edge();
}
}
else {
}
if (aShape.IsNull()) return 0;
aFunction->SetValue(aShape);
log.SetTouched(Label());
return 1;
}
示例9: Execute
//=======================================================================
//function : Execute
//purpose :
//=======================================================================
Standard_Integer GEOMImpl_DraftDriver::Execute(TFunction_Logbook& log) const
{
if (Label().IsNull()) return 0;
Handle(GEOM_Function) aFunction = GEOM_Function::GetFunction(Label());
if(aFunction.IsNull()) return 0;
GEOMImpl_IDraft aCI (aFunction);
Standard_Integer aType = aFunction->GetType();
TopoDS_Shape aShape;
TopoDS_Shape aPlaneShape;
gp_Pln theNeutralPlane;
gp_Dir theDirection;
Handle(GEOM_Function) aRefShape = aCI.GetShape();
TopoDS_Shape aShapeBase = aRefShape->GetValue();
//get the reference plane and direction
if (aType == DRAFT_BY_FACE_PLN_ANG) {
Handle(GEOM_Function) aRefPlane = aCI.GetPlane();
if (aRefPlane.IsNull())
return 0;
aPlaneShape = aRefPlane->GetValue();
}
else if (aType == DRAFT_BY_FACE_STA_ANG) {
GEOMImpl_ILocalOperations::GetSubShape(aShapeBase, aCI.GetStationary(), aPlaneShape);
}
if (aPlaneShape.IsNull() || aPlaneShape.ShapeType() != TopAbs_FACE)
return 0;
TopoDS_Face aFace = TopoDS::Face(aPlaneShape);
Handle(Geom_Surface) surf = BRep_Tool::Surface(aFace);
Handle(Geom_Plane) myPlane = Handle(Geom_Plane)::DownCast(surf);
theNeutralPlane = myPlane->Pln();
theDirection = theNeutralPlane.Axis().Direction();
//compute the value
Standard_Real theAngle = aCI.GetAngle();
int aLen = aCI.GetLength();
int ind = 1;
int added = 0;
BRepOffsetAPI_DraftAngle aDraft (aShapeBase);
for (; ind <= aLen; ind++) {
TopoDS_Shape aShapeFace;
if (GEOMImpl_ILocalOperations::GetSubShape(aShapeBase, aCI.GetFace(ind), aShapeFace)) {
TopoDS_Face aFace = TopoDS::Face(aShapeFace);
aDraft.Add(aFace, theDirection, theAngle, theNeutralPlane);
if (aDraft.AddDone())
added++;
else
aDraft.Remove(aFace);
}
}
if (added == 0)
StdFail_NotDone::Raise("None of the faces provided can be used for draft algo");
aDraft.Build();
if (!aDraft.IsDone()) {
StdFail_NotDone::Raise("Draft can't be computed on the given shape with the given parameters");
}
aShape = aDraft.Shape();
if (aShape.IsNull()) return 0;
// Check shape validity
BRepCheck_Analyzer ana (aShape, false);
if (!ana.IsValid()) {
Standard_CString anErrStr("Draft algorythm has produced an invalid shape result");
#ifdef THROW_ON_INVALID_SH
Standard_ConstructionError::Raise(anErrStr);
#else
MESSAGE(anErrStr);
//further processing can be performed here
//...
//in case of failure of automatic treatment
//mark the corresponding GEOM_Object as problematic
TDF_Label aLabel = aFunction->GetOwnerEntry();
if (!aLabel.IsRoot()) {
Handle(GEOM_Object) aMainObj = GEOM_Object::GetObject(aLabel);
if (!aMainObj.IsNull())
aMainObj->SetDirty(Standard_True);
}
#endif
}
aFunction->SetValue(aShape);
log.SetTouched(Label());
return 1;
}
示例10: Execute
//.........这里部分代码省略.........
fill.Add(aD1, aD2, E, F);
}
else
{
double aD = aCI.GetD();
double anAngle = aCI.GetAngle();
if ( (anAngle > 0) && (anAngle < (Standard_PI/2)) )
fill.AddDA(aD, anAngle, E, F);
}
}
}
}
}
}
else if (aType == CHAMFER_SHAPE_EDGES || aType == CHAMFER_SHAPE_EDGES_AD)
{
// chamfer on selected edges with lenght param D1 & D2.
int aLen = aCI.GetLength();
int ind = 1;
TopTools_MapOfShape aMap;
TopTools_IndexedDataMapOfShapeListOfShape M;
GEOMImpl_Block6Explorer::MapShapesAndAncestors(aShapeBase, TopAbs_EDGE, TopAbs_FACE, M);
for (; ind <= aLen; ind++)
{
TopoDS_Shape aShapeEdge;
if (GEOMImpl_ILocalOperations::GetSubShape(aShapeBase, aCI.GetEdge(ind), aShapeEdge))
{
TopoDS_Edge E = TopoDS::Edge(aShapeEdge);
const TopTools_ListOfShape& aFacesList = M.FindFromKey(E);
TopoDS_Face F = TopoDS::Face( aFacesList.First() );
if (aType == CHAMFER_SHAPE_EDGES)
{
double aD1 = aCI.GetD1();
double aD2 = aCI.GetD2();
fill.Add(aD1, aD2, E, F);
}
else
{
double aD = aCI.GetD();
double anAngle = aCI.GetAngle();
if ( (anAngle > 0) && (anAngle < (Standard_PI/2)) )
fill.AddDA(aD, anAngle, E, F);
}
}
}
}
else {
}
fill.Build();
if (!fill.IsDone()) {
StdFail_NotDone::Raise("Chamfer can not be computed on the given shape with the given parameters");
}
aShape = fill.Shape();
}
if (aShape.IsNull()) return 0;
// Check shape validity
BRepCheck_Analyzer ana (aShape, false);
if (!ana.IsValid()) {
// 08.07.2008 added by skl during fixing bug 19761 from Mantis
ShapeFix_ShapeTolerance aSFT;
aSFT.LimitTolerance(aShape, Precision::Confusion(),
Precision::Confusion(), TopAbs_SHAPE);
Handle(ShapeFix_Shape) aSfs = new ShapeFix_Shape(aShape);
aSfs->Perform();
aShape = aSfs->Shape();
// fix SameParameter flag
BRepLib::SameParameter(aShape, 1.E-5, Standard_True);
ana.Init(aShape);
if (!ana.IsValid()) {
Standard_CString anErrStr("Chamfer algorithm has produced an invalid shape result");
#ifdef THROW_ON_INVALID_SH
Standard_ConstructionError::Raise(anErrStr);
#else
MESSAGE(anErrStr);
//further processing can be performed here
//...
//in case of failure of automatic treatment
//mark the corresponding GEOM_Object as problematic
TDF_Label aLabel = aFunction->GetOwnerEntry();
if (!aLabel.IsRoot()) {
Handle(GEOM_Object) aMainObj = GEOM_Object::GetObject(aLabel);
if (!aMainObj.IsNull())
aMainObj->SetDirty(Standard_True);
}
#endif
}
}
aFunction->SetValue(aShape);
log.SetTouched(Label());
return 1;
}
示例11: Execute
//.........这里部分代码省略.........
aGTrsf.SetAffinity(anAx2, aCI.GetFactor());
BRepBuilderAPI_GTransform aBRepGTrsf(aShapeBase, aGTrsf, Standard_False);
aShape = aBRepGTrsf.Shape();
}
else if (aType == SCALE_SHAPE_AXES || aType == SCALE_SHAPE_AXES_COPY) {
Handle(GEOM_Function) aRefShape = aCI.GetShape();
TopoDS_Shape aShapeBase = aRefShape->GetValue();
if (aShapeBase.IsNull()) return 0;
bool isP = false;
gp_Pnt aP (0,0,0);
Handle(GEOM_Function) aRefPoint = aCI.GetPoint();
if (!aRefPoint.IsNull()) {
TopoDS_Shape aShapePnt = aRefPoint->GetValue();
if (aShapePnt.IsNull()) return 0;
if (aShapePnt.ShapeType() != TopAbs_VERTEX) return 0;
aP = BRep_Tool::Pnt(TopoDS::Vertex(aShapePnt));
isP = true;
}
// Bug 6839: Check for standalone (not included in faces) degenerated edges
TopTools_IndexedDataMapOfShapeListOfShape aEFMap;
TopExp::MapShapesAndAncestors(aShapeBase, TopAbs_EDGE, TopAbs_FACE, aEFMap);
Standard_Integer i, nbE = aEFMap.Extent();
for (i = 1; i <= nbE; i++) {
TopoDS_Shape anEdgeSh = aEFMap.FindKey(i);
if (BRep_Tool::Degenerated(TopoDS::Edge(anEdgeSh))) {
const TopTools_ListOfShape& aFaces = aEFMap.FindFromIndex(i);
if (aFaces.IsEmpty())
Standard_ConstructionError::Raise
("Scaling aborted : cannot scale standalone degenerated edge");
}
}
// Perform Scaling
gp_GTrsf aGTrsf;
gp_Mat rot (aCI.GetFactorX(), 0, 0,
0, aCI.GetFactorY(), 0,
0, 0, aCI.GetFactorZ());
aGTrsf.SetVectorialPart(rot);
if (isP) {
gp_Pnt anO (0,0,0);
if (anO.Distance(aP) > Precision::Confusion()) {
gp_GTrsf aGTrsfP0;
aGTrsfP0.SetTranslationPart(anO.XYZ() - aP.XYZ());
gp_GTrsf aGTrsf0P;
aGTrsf0P.SetTranslationPart(aP.XYZ());
//aGTrsf = aGTrsf0P * aGTrsf * aGTrsfP0;
aGTrsf = aGTrsf0P.Multiplied(aGTrsf);
aGTrsf = aGTrsf.Multiplied(aGTrsfP0);
}
}
BRepBuilderAPI_GTransform aBRepGTrsf (aShapeBase, aGTrsf, Standard_False);
if (!aBRepGTrsf.IsDone())
Standard_ConstructionError::Raise("Scaling not done");
aShape = aBRepGTrsf.Shape();
} else {
}
if (aShape.IsNull()) return 0;
// Check shape validity
BRepCheck_Analyzer ana (aShape, false);
if (!ana.IsValid()) {
ShapeFix_ShapeTolerance aSFT;
aSFT.LimitTolerance(aShape,Precision::Confusion(),Precision::Confusion());
Handle(ShapeFix_Shape) aSfs = new ShapeFix_Shape(aShape);
aSfs->SetPrecision(Precision::Confusion());
aSfs->Perform();
aShape = aSfs->Shape();
ana.Init(aShape, Standard_False);
if (!ana.IsValid()) {
Standard_CString anErrStr("Scaling aborted : non valid shape result");
#ifdef THROW_ON_INVALID_SH
Standard_ConstructionError::Raise(anErrStr);
#else
MESSAGE(anErrStr);
//further processing can be performed here
//...
//in case of failure of automatic treatment
//mark the corresponding GEOM_Object as problematic
TDF_Label aLabel = aFunction->GetOwnerEntry();
if (!aLabel.IsRoot()) {
Handle(GEOM_Object) aMainObj = GEOM_Object::GetObject(aLabel);
if (!aMainObj.IsNull())
aMainObj->SetDirty(Standard_True);
}
#endif
}
}
aFunction->SetValue(aShape);
log.SetTouched(Label());
return 1;
}
示例12: Execute
//=======================================================================
//function : Execute
//purpose :
//=======================================================================
Standard_Integer GEOMImpl_MarkerDriver::Execute(TFunction_Logbook& log) const
{
if (Label().IsNull()) return 0;
Handle(GEOM_Function) aFunction = GEOM_Function::GetFunction(Label());
GEOMImpl_IMarker aPI (aFunction);
Standard_Integer aType = aFunction->GetType();
TopoDS_Shape aShape;
if (aType == MARKER_CS) {
double OX, OY, OZ;
double XDX, XDY, XDZ;
double YDX, YDY, YDZ;
aPI.GetOrigin(OX, OY, OZ);
aPI.GetXDir(XDX, XDY, XDZ);
aPI.GetYDir(YDX, YDY, YDZ);
gp_Pnt aPO (OX, OY, OZ);
gp_Vec aVX (XDX, XDY, XDZ);
gp_Vec aVY (YDX, YDY, YDZ);
Standard_Real aTol = Precision::Confusion();
if (aVX.Magnitude() < aTol ||
aVY.Magnitude() < aTol ||
aVX.IsParallel(aVY, Precision::Angular())) {
Standard_ConstructionError::Raise("Degenerated or parallel directions given");
}
gp_Vec aN = aVX ^ aVY;
gp_Ax3 anA (aPO, aN, aVX);
gp_Pln aPln (anA);
double aTrimSize = 100.0;
aShape = BRepBuilderAPI_MakeFace(aPln, -aTrimSize, +aTrimSize, -aTrimSize, +aTrimSize).Shape();
} else if (aType == MARKER_SHAPE) {
Handle(GEOM_Function) aRefShape = aPI.GetShape();
TopoDS_Shape aSh = aRefShape->GetValue();
gp_Ax3 anAx3 = GEOMImpl_IMeasureOperations::GetPosition(aSh);
gp_Pln aPln (anAx3);
double aTrimSize = 100.0;
aShape = BRepBuilderAPI_MakeFace(aPln, -aTrimSize, +aTrimSize, -aTrimSize, +aTrimSize).Shape();
} else if (aType == MARKER_PNT2VEC) {
Handle(GEOM_Function) aRefOrigin = aPI.GetOrigin();
Handle(GEOM_Function) aRefXVec = aPI.GetXVec();
Handle(GEOM_Function) aRefYVec = aPI.GetYVec();
TopoDS_Shape aShapeOrigin = aRefOrigin->GetValue();
TopoDS_Shape aShapeXVec = aRefXVec->GetValue();
TopoDS_Shape aShapeYVec = aRefYVec->GetValue();
if (aShapeOrigin.ShapeType() != TopAbs_VERTEX || aShapeOrigin.IsNull()) return 0;
if (aShapeXVec.ShapeType() != TopAbs_EDGE || aShapeXVec.IsNull()) return 0;
if (aShapeYVec.ShapeType() != TopAbs_EDGE || aShapeYVec.IsNull()) return 0;
gp_Pnt aPO = BRep_Tool::Pnt( TopoDS::Vertex( aShapeOrigin ) );
gp_Pnt aPX1 = BRep_Tool::Pnt( TopExp::FirstVertex( TopoDS::Edge( aShapeXVec ) ) );
gp_Pnt aPX2 = BRep_Tool::Pnt( TopExp::LastVertex( TopoDS::Edge( aShapeXVec ) ) );
gp_Vec aVX( aPX1, aPX2 );
gp_Pnt aPY1 = BRep_Tool::Pnt( TopExp::FirstVertex( TopoDS::Edge( aShapeYVec ) ) );
gp_Pnt aPY2 = BRep_Tool::Pnt( TopExp::LastVertex( TopoDS::Edge( aShapeYVec ) ) );
gp_Vec aVY( aPY1, aPY2 );
if (aVX.Magnitude() < gp::Resolution() || aVY.Magnitude() < gp::Resolution())
Standard_ConstructionError::Raise
("Local CS creation aborted: vector of zero length is given");
if ( aVX.IsParallel(aVY, Precision::Angular()))
Standard_ConstructionError::Raise("Parallel Vectors given");
gp_Vec aN = aVX ^ aVY;
gp_Ax3 anA (aPO, aN, aVX);
gp_Pln aPln (anA);
double aTrimSize = 100.0;
aShape = BRepBuilderAPI_MakeFace(aPln, -aTrimSize, +aTrimSize, -aTrimSize, +aTrimSize).Shape();
} else {
}
if (aShape.IsNull()) return 0;
aFunction->SetValue(aShape);
log.SetTouched(Label());
return 1;
}
示例13: Execute
//.........这里部分代码省略.........
// Point
gp_Pnt p1 (0,0,0);
Handle(GEOM_Function) aPntFunc = aCI.GetPoint();
if (!aPntFunc.IsNull())
{
TopoDS_Shape anOptPnt = aPntFunc->GetValue();
if (anOptPnt.IsNull())
Standard_NullObject::Raise("Invalid shape given for point argument");
p1 = BRep_Tool::Pnt(TopoDS::Vertex(anOptPnt));
}
else
{
gp_Ax3 aPos = GEOMImpl_IMeasureOperations::GetPosition(aFace);
p1 = aPos.Location();
}
// Point parameters on surface
Handle(Geom_Surface) aSurf = BRep_Tool::Surface(aFace);
Handle(ShapeAnalysis_Surface) aSurfAna = new ShapeAnalysis_Surface (aSurf);
gp_Pnt2d pUV = aSurfAna->ValueOfUV(p1, Precision::Confusion());
// Normal direction
gp_Vec Vec1,Vec2;
BRepAdaptor_Surface SF (aFace);
SF.D1(pUV.X(), pUV.Y(), p1, Vec1, Vec2);
if (Vec1.Magnitude() < Precision::Confusion()) {
gp_Vec tmpV;
gp_Pnt tmpP;
SF.D1(pUV.X(), pUV.Y()-0.1, tmpP, Vec1, tmpV);
}
else if (Vec2.Magnitude() < Precision::Confusion()) {
gp_Vec tmpV;
gp_Pnt tmpP;
SF.D1(pUV.X()-0.1, pUV.Y(), tmpP, tmpV, Vec2);
}
gp_Vec V = Vec1.Crossed(Vec2);
Standard_Real mod = V.Magnitude();
if (mod < Precision::Confusion())
Standard_NullObject::Raise("Normal vector of a face has null magnitude");
// Set length of normal vector to average radius of curvature
Standard_Real radius = 0.0;
GeomLProp_SLProps aProperties (aSurf, pUV.X(), pUV.Y(), 2, Precision::Confusion());
if (aProperties.IsCurvatureDefined()) {
Standard_Real radius1 = Abs(aProperties.MinCurvature());
Standard_Real radius2 = Abs(aProperties.MaxCurvature());
if (Abs(radius1) > Precision::Confusion()) {
radius = 1.0 / radius1;
if (Abs(radius2) > Precision::Confusion()) {
radius = (radius + 1.0 / radius2) / 2.0;
}
}
else {
if (Abs(radius2) > Precision::Confusion()) {
radius = 1.0 / radius2;
}
}
}
// Set length of normal vector to average dimension of the face
// (only if average radius of curvature is not appropriate)
if (radius < Precision::Confusion()) {
Bnd_Box B;
Standard_Real Xmin, Xmax, Ymin, Ymax, Zmin, Zmax;
BRepBndLib::Add(aFace, B);
B.Get(Xmin, Ymin, Zmin, Xmax, Ymax, Zmax);
radius = ((Xmax - Xmin) + (Ymax - Ymin) + (Zmax - Zmin)) / 3.0;
}
if (radius < Precision::Confusion())
radius = 1.0;
V *= radius / mod;
// consider the face orientation
if (aFace.Orientation() == TopAbs_REVERSED ||
aFace.Orientation() == TopAbs_INTERNAL) {
V = - V;
}
// Edge
gp_Pnt p2 = p1.Translated(V);
BRepBuilderAPI_MakeEdge aBuilder (p1, p2);
if (!aBuilder.IsDone())
Standard_NullObject::Raise("Vector construction failed");
aShape = aBuilder.Shape();
}
else {
}
if (aShape.IsNull()) return 0;
aFunction->SetValue(aShape);
log.SetTouched(Label());
return 1;
}
示例14: Execute
//.........这里部分代码省略.........
// Start LCS
aStartAx3 = GEOMImpl_IMeasureOperations::GetPosition(aShapeStartLCS);
// Set transformation
aTrsf.SetDisplacement(aStartAx3, aDestAx3);
// Perform transformation
BRepBuilderAPI_Transform aBRepTrsf (aShapeBase, aTrsf, Standard_False);
aShape = aBRepTrsf.Shape();
}
else if (aType == POSITION_SHAPE_FROM_GLOBAL ||
aType == POSITION_SHAPE_FROM_GLOBAL_COPY) {
Handle(GEOM_Function) aRefShape = aCI.GetShape();
Handle(GEOM_Function) aRefEndLCS = aCI.GetEndLCS();
TopoDS_Shape aShapeBase = aRefShape->GetValue();
TopoDS_Shape aShapeEndLCS = aRefEndLCS->GetValue();
if (aShapeBase.IsNull() || aShapeEndLCS.IsNull() ||
aShapeEndLCS.ShapeType() != TopAbs_FACE)
return 0;
gp_Trsf aTrsf;
gp_Ax3 aStartAx3, aDestAx3;
// End LCS
aDestAx3 = GEOMImpl_IMeasureOperations::GetPosition(aShapeEndLCS);
// Set transformation
aTrsf.SetDisplacement(aStartAx3, aDestAx3);
// Perform transformation
BRepBuilderAPI_Transform aBRepTrsf (aShapeBase, aTrsf, Standard_False);
aShape = aBRepTrsf.Shape();
}
else if (aType == POSITION_ALONG_PATH) {
Handle(GEOM_Function) aRefShape = aCI.GetShape();
Handle(GEOM_Function) aPathShape = aCI.GetPath();
Standard_Real aParameter = aCI.GetDistance();
bool aReversed = aCI.GetReverse();
if (aReversed)
aParameter = 1 - aParameter;
TopoDS_Shape aShapeBase = aRefShape->GetValue();
TopoDS_Shape aPath = aPathShape->GetValue();
TopoDS_Wire aWire;
if (aShapeBase.IsNull() || aPath.IsNull())
return 0;
if ( aPath.ShapeType() == TopAbs_EDGE ) {
TopoDS_Edge anEdge = TopoDS::Edge(aPath);
aWire = BRepBuilderAPI_MakeWire(anEdge);
}
else if ( aPath.ShapeType() == TopAbs_WIRE)
aWire = TopoDS::Wire(aPath);
else
return 0;
Handle(GeomFill_TrihedronLaw) TLaw = new GeomFill_CorrectedFrenet();
Handle(GeomFill_CurveAndTrihedron) aLocationLaw = new GeomFill_CurveAndTrihedron( TLaw );
Handle(BRepFill_LocationLaw) aLocation = new BRepFill_Edge3DLaw(aWire, aLocationLaw);
aLocation->TransformInCompatibleLaw( 0.01 );
//Calculate a Parameter
Standard_Real aFirstParam1 = 0, aLastParam1 = 0; // Parameters of the First edge
Standard_Real aFirstParam2 = 0, aLastParam2 = 0; // Parameters of the Last edge
aLocation->CurvilinearBounds(aLocation->NbLaw(), aFirstParam2, aLastParam2);
if ( aLocation->NbLaw() > 1)
aLocation->CurvilinearBounds(1, aFirstParam1, aLastParam1);
else if ( aLocation->NbLaw() == 1 )
aFirstParam1 = aFirstParam2;
else
return 0;
Standard_Real aParam = (aFirstParam1 + (aLastParam2 - aFirstParam1)*aParameter );
TopoDS_Shape CopyShape = aShapeBase;
BRepFill_SectionPlacement Place( aLocation, aShapeBase );
TopLoc_Location Loc2(Place.Transformation()), Loc1;
Loc1 = CopyShape.Location();
CopyShape.Location(Loc2.Multiplied(Loc1));
aLocation->D0( aParam, CopyShape );
aShape = CopyShape;
}
else
return 0;
if (aShape.IsNull()) return 0;
aFunction->SetValue(aShape);
log.SetTouched(Label());
return 1;
}
示例15: Execute
//.........这里部分代码省略.........
int aLen = aCI.GetLength();
int ind = 1;
TopTools_MapOfShape aMap;
TopTools_IndexedDataMapOfShapeListOfShape M;
GEOMImpl_Block6Explorer::MapShapesAndAncestors(aShapeBase, TopAbs_EDGE, TopAbs_FACE, M);
for (; ind <= aLen; ind++)
{
TopoDS_Shape aShapeFace;
if (GEOMImpl_ILocalOperations::GetSubShape(aShapeBase, aCI.GetFace(ind), aShapeFace))
{
TopoDS_Face F = TopoDS::Face(aShapeFace);
TopExp_Explorer Exp (F, TopAbs_EDGE);
for (; Exp.More(); Exp.Next()) {
if (!aMap.Contains(Exp.Current()))
{
TopoDS_Edge E = TopoDS::Edge(Exp.Current());
if (!BRepTools::IsReallyClosed(E, F) &&
!BRep_Tool::Degenerated(E) &&
M.FindFromKey(E).Extent() == 2)
{
if (aType == CHAMFER_SHAPE_FACES)
{
double aD1 = aCI.GetD1();
double aD2 = aCI.GetD2();
fill.Add(aD1, aD2, E, F);
}
else
{
double aD = aCI.GetD();
double anAngle = aCI.GetAngle();
if ( (anAngle > 0) && (anAngle < (M_PI/2.)) )
fill.AddDA(aD, anAngle, E, F);
}
}
}
}
}
}
}
else if (aType == CHAMFER_SHAPE_EDGES || aType == CHAMFER_SHAPE_EDGES_AD)
{
// chamfer on selected edges with lenght param D1 & D2.
int aLen = aCI.GetLength();
int ind = 1;
TopTools_MapOfShape aMap;
TopTools_IndexedDataMapOfShapeListOfShape M;
GEOMImpl_Block6Explorer::MapShapesAndAncestors(aShapeBase, TopAbs_EDGE, TopAbs_FACE, M);
for (; ind <= aLen; ind++)
{
TopoDS_Shape aShapeEdge;
if (GEOMImpl_ILocalOperations::GetSubShape(aShapeBase, aCI.GetEdge(ind), aShapeEdge))
{
TopoDS_Edge E = TopoDS::Edge(aShapeEdge);
const TopTools_ListOfShape& aFacesList = M.FindFromKey(E);
TopoDS_Face F = TopoDS::Face( aFacesList.First() );
if (aType == CHAMFER_SHAPE_EDGES)
{
double aD1 = aCI.GetD1();
double aD2 = aCI.GetD2();
fill.Add(aD1, aD2, E, F);
}
else
{
double aD = aCI.GetD();
double anAngle = aCI.GetAngle();
if ( (anAngle > 0) && (anAngle < (M_PI/2.)) )
fill.AddDA(aD, anAngle, E, F);
}
}
}
}
else {
}
fill.Build();
if (!fill.IsDone()) {
StdFail_NotDone::Raise("Chamfer can not be computed on the given shape with the given parameters");
}
aShape = fill.Shape();
if (aShape.IsNull()) return 0;
// reduce tolerances
ShapeFix_ShapeTolerance aSFT;
aSFT.LimitTolerance(aShape, Precision::Confusion(),
Precision::Confusion(), TopAbs_SHAPE);
Handle(ShapeFix_Shape) aSfs = new ShapeFix_Shape(aShape);
aSfs->Perform();
aShape = aSfs->Shape();
// fix SameParameter flag
BRepLib::SameParameter(aShape, 1.E-5, Standard_True);
aFunction->SetValue(aShape);
log.SetTouched(Label());
return 1;
}