Mantis issue 0020998: EDF 1572 GEOM: Some limitations to the PipeTShape.

This commit is contained in:
jfa 2010-10-25 12:05:28 +00:00
parent 623c7e262e
commit 3059f9d552

View File

@ -16,10 +16,8 @@
// //
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
// //
// File : GEOMImpl_IAdvancedOperations.cxx // File : GEOMImpl_IAdvancedOperations.cxx
// Author : Vadim SANDLER, Open CASCADE S.A.S. (vadim.sandler@opencascade.com) // Author : Vadim SANDLER, Open CASCADE S.A.S. (vadim.sandler@opencascade.com)
//
#include <Standard_Stream.hxx> #include <Standard_Stream.hxx>
#include "GEOMImpl_Types.hxx" #include "GEOMImpl_Types.hxx"
@ -31,6 +29,7 @@
#include "GEOMImpl_IBlocksOperations.hxx" #include "GEOMImpl_IBlocksOperations.hxx"
#include "GEOMImpl_I3DPrimOperations.hxx" #include "GEOMImpl_I3DPrimOperations.hxx"
#include "GEOMImpl_ILocalOperations.hxx" #include "GEOMImpl_ILocalOperations.hxx"
#include "GEOMImpl_IHealingOperations.hxx"
#include "GEOMImpl_Gen.hxx" #include "GEOMImpl_Gen.hxx"
@ -56,6 +55,7 @@
#include <gp_Ax3.hxx> #include <gp_Ax3.hxx>
#include <BRepBuilderAPI_Transform.hxx> #include <BRepBuilderAPI_Transform.hxx>
#include <BRep_Tool.hxx> #include <BRep_Tool.hxx>
#include <BRepTools.hxx>
#include <cmath> #include <cmath>
#include <TFunction_DriverTable.hxx> #include <TFunction_DriverTable.hxx>
@ -116,9 +116,9 @@ GEOMImpl_IAdvancedOperations::~GEOMImpl_IAdvancedOperations()
*/ */
//============================================================================= //=============================================================================
gp_Trsf GEOMImpl_IAdvancedOperations::GetPositionTrsf(double theL1, double theL2, gp_Trsf GEOMImpl_IAdvancedOperations::GetPositionTrsf(double theL1, double theL2,
Handle(GEOM_Object) theP1, Handle(GEOM_Object) theP1,
Handle(GEOM_Object) theP2, Handle(GEOM_Object) theP2,
Handle(GEOM_Object) theP3) Handle(GEOM_Object) theP3)
{ {
// Old Local Coordinates System oldLCS // Old Local Coordinates System oldLCS
gp_Pnt P0(0, 0, 0); gp_Pnt P0(0, 0, 0);
@ -157,10 +157,10 @@ gp_Trsf GEOMImpl_IAdvancedOperations::GetPositionTrsf(double theL1, double theL2
*/ */
//============================================================================= //=============================================================================
bool GEOMImpl_IAdvancedOperations::CheckCompatiblePosition(double& theL1, double& theL2, bool GEOMImpl_IAdvancedOperations::CheckCompatiblePosition(double& theL1, double& theL2,
Handle(GEOM_Object) theP1, Handle(GEOM_Object) theP1,
Handle(GEOM_Object) theP2, Handle(GEOM_Object) theP2,
Handle(GEOM_Object) theP3, Handle(GEOM_Object) theP3,
double theTolerance) double theTolerance)
{ {
SetErrorCode(KO); SetErrorCode(KO);
gp_Pnt P1 = BRep_Tool::Pnt(TopoDS::Vertex(theP1->GetValue())); gp_Pnt P1 = BRep_Tool::Pnt(TopoDS::Vertex(theP1->GetValue()));
@ -193,7 +193,7 @@ bool GEOMImpl_IAdvancedOperations::CheckCompatiblePosition(double& theL1, double
// //
if (fabs(newL1 - theL1) > Precision::Approximation()) { if (fabs(newL1 - theL1) > Precision::Approximation()) {
if ( (newL1 * (1 - theTolerance) -theL1 <= Precision::Approximation()) && if ( (newL1 * (1 - theTolerance) -theL1 <= Precision::Approximation()) &&
(newL1 * (1 + theTolerance) -theL1 >= Precision::Approximation()) ) { (newL1 * (1 + theTolerance) -theL1 >= Precision::Approximation()) ) {
// std::cerr << "theL1 = newL1" << std::endl; // std::cerr << "theL1 = newL1" << std::endl;
theL1 = newL1; theL1 = newL1;
} else { } else {
@ -208,7 +208,7 @@ bool GEOMImpl_IAdvancedOperations::CheckCompatiblePosition(double& theL1, double
// //
if (fabs(newL2 - theL2) > Precision::Approximation()) { if (fabs(newL2 - theL2) > Precision::Approximation()) {
if ( (newL2 * (1 - theTolerance) -theL2 <= Precision::Approximation()) && if ( (newL2 * (1 - theTolerance) -theL2 <= Precision::Approximation()) &&
(newL2 * (1 + theTolerance) -theL2 >= Precision::Approximation()) ) { (newL2 * (1 + theTolerance) -theL2 >= Precision::Approximation()) ) {
theL2 = newL2; theL2 = newL2;
} else { } else {
theL2 = -1; theL2 = -1;
@ -228,10 +228,10 @@ bool GEOMImpl_IAdvancedOperations::CheckCompatiblePosition(double& theL1, double
*/ */
//============================================================================= //=============================================================================
bool GEOMImpl_IAdvancedOperations::MakeGroups(Handle(GEOM_Object) theShape, int shapeType, bool GEOMImpl_IAdvancedOperations::MakeGroups(Handle(GEOM_Object) theShape, int shapeType,
double theR1, double theW1, double theL1, double theR1, double theW1, double theL1,
double theR2, double theW2, double theL2, double theR2, double theW2, double theL2,
Handle(TColStd_HSequenceOfTransient) theSeq, Handle(TColStd_HSequenceOfTransient) theSeq,
gp_Trsf aTrsf) gp_Trsf aTrsf)
{ {
SetErrorCode(KO); SetErrorCode(KO);
@ -276,7 +276,8 @@ bool GEOMImpl_IAdvancedOperations::MakeGroups(Handle(GEOM_Object) theShape, int
aBox->GetLastFunction()->SetValue(aBoxShapeTrsf); aBox->GetLastFunction()->SetValue(aBoxShapeTrsf);
// Get the shell of the box // Get the shell of the box
Handle(GEOM_Object) aShell = Handle(GEOM_Object)::DownCast(myShapesOperations->MakeExplode(aBox, TopAbs_SHELL, true)->Value(1)); Handle(GEOM_Object) aShell = Handle(GEOM_Object)::DownCast
(myShapesOperations->MakeExplode(aBox, TopAbs_SHELL, true)->Value(1));
aBox->GetLastFunction()->SetDescription(""); aBox->GetLastFunction()->SetDescription("");
aShell->GetLastFunction()->SetDescription(""); aShell->GetLastFunction()->SetDescription("");
// Get the common shapes between shell and shape // Get the common shapes between shell and shape
@ -287,7 +288,8 @@ bool GEOMImpl_IAdvancedOperations::MakeGroups(Handle(GEOM_Object) theShape, int
} }
aCommonCompound->GetLastFunction()->SetDescription(""); aCommonCompound->GetLastFunction()->SetDescription("");
// Explode the faces of common shapes => 3 faces // Explode the faces of common shapes => 3 faces
Handle(TColStd_HSequenceOfTransient) aCommonFaces = myShapesOperations->MakeExplode(aCommonCompound, TopAbs_FACE, true); Handle(TColStd_HSequenceOfTransient) aCommonFaces =
myShapesOperations->MakeExplode(aCommonCompound, TopAbs_FACE, true);
aCommonCompound->GetLastFunction()->SetDescription(""); aCommonCompound->GetLastFunction()->SetDescription("");
std::list<Handle(GEOM_Object)> aCompoundOfFacesList; std::list<Handle(GEOM_Object)> aCompoundOfFacesList;
@ -296,8 +298,8 @@ bool GEOMImpl_IAdvancedOperations::MakeGroups(Handle(GEOM_Object) theShape, int
for (int j = 1 ; j <= 4 ; j++) { for (int j = 1 ; j <= 4 ; j++) {
Handle(GEOM_Object) aFace = Handle(GEOM_Object)::DownCast(aCommonFaces->Value(i+j)); // Junction faces Handle(GEOM_Object) aFace = Handle(GEOM_Object)::DownCast(aCommonFaces->Value(i+j)); // Junction faces
if (!aFace.IsNull()) { if (!aFace.IsNull()) {
aFace->GetLastFunction()->SetDescription(""); aFace->GetLastFunction()->SetDescription("");
aFacesList.push_back(aFace); aFacesList.push_back(aFace);
} }
} }
Handle(GEOM_Object) aCompoundOfFaces = myShapesOperations->MakeCompound(aFacesList); Handle(GEOM_Object) aCompoundOfFaces = myShapesOperations->MakeCompound(aFacesList);
@ -353,7 +355,8 @@ bool GEOMImpl_IAdvancedOperations::MakeGroups(Handle(GEOM_Object) theShape, int
Handle(GEOM_Object) junctionFaces1 = myShapesOperations->GetInPlace(theShape, aPln1); Handle(GEOM_Object) junctionFaces1 = myShapesOperations->GetInPlace(theShape, aPln1);
if (junctionFaces1.IsNull()) if (junctionFaces1.IsNull())
junctionFaces1 = myShapesOperations->GetShapesOnShapeAsCompound(aPln1, theShape, TopAbs_FACE, GEOMAlgo_ST_ONIN); junctionFaces1 = myShapesOperations->GetShapesOnShapeAsCompound
(aPln1, theShape, TopAbs_FACE, GEOMAlgo_ST_ONIN);
if (!junctionFaces1.IsNull()) { if (!junctionFaces1.IsNull()) {
junctionFaces1->GetLastFunction()->SetDescription(""); junctionFaces1->GetLastFunction()->SetDescription("");
junctionFaces1->SetName("JUNCTION_FACE_1"); junctionFaces1->SetName("JUNCTION_FACE_1");
@ -366,7 +369,8 @@ bool GEOMImpl_IAdvancedOperations::MakeGroups(Handle(GEOM_Object) theShape, int
} }
Handle(GEOM_Object) junctionFaces2 = myShapesOperations->GetInPlace(theShape, aPln2); Handle(GEOM_Object) junctionFaces2 = myShapesOperations->GetInPlace(theShape, aPln2);
if (junctionFaces2.IsNull()) if (junctionFaces2.IsNull())
junctionFaces2 = myShapesOperations->GetShapesOnShapeAsCompound(aPln2, theShape, TopAbs_FACE, GEOMAlgo_ST_ONIN); junctionFaces2 = myShapesOperations->GetShapesOnShapeAsCompound
(aPln2, theShape, TopAbs_FACE, GEOMAlgo_ST_ONIN);
if (!junctionFaces2.IsNull()) { if (!junctionFaces2.IsNull()) {
junctionFaces2->GetLastFunction()->SetDescription(""); junctionFaces2->GetLastFunction()->SetDescription("");
junctionFaces2->SetName("JUNCTION_FACE_2"); junctionFaces2->SetName("JUNCTION_FACE_2");
@ -379,7 +383,8 @@ bool GEOMImpl_IAdvancedOperations::MakeGroups(Handle(GEOM_Object) theShape, int
} }
Handle(GEOM_Object) junctionFaces3 = myShapesOperations->GetInPlace(theShape, aPln3); Handle(GEOM_Object) junctionFaces3 = myShapesOperations->GetInPlace(theShape, aPln3);
if (junctionFaces3.IsNull()) if (junctionFaces3.IsNull())
junctionFaces3 = myShapesOperations->GetShapesOnShapeAsCompound(aPln3, theShape, TopAbs_FACE, GEOMAlgo_ST_ONIN); junctionFaces3 = myShapesOperations->GetShapesOnShapeAsCompound
(aPln3, theShape, TopAbs_FACE, GEOMAlgo_ST_ONIN);
if (!junctionFaces3.IsNull()) { if (!junctionFaces3.IsNull()) {
junctionFaces3->GetLastFunction()->SetDescription(""); junctionFaces3->GetLastFunction()->SetDescription("");
junctionFaces3->SetName("JUNCTION_FACE_3"); junctionFaces3->SetName("JUNCTION_FACE_3");
@ -438,144 +443,143 @@ bool GEOMImpl_IAdvancedOperations::MakeGroups(Handle(GEOM_Object) theShape, int
if (shapeType == TSHAPE_BASIC) { if (shapeType == TSHAPE_BASIC) {
if ((nbEdges == 21) || /*R1Ext = R2Ext*/(nbEdges == 17)){ if ((nbEdges == 21) || /*R1Ext = R2Ext*/(nbEdges == 17)){
addGroup = true; addGroup = true;
aGroup->SetName("THICKNESS"); aGroup->SetName("THICKNESS");
} }
else if (nbEdges == 6) { else if (nbEdges == 6) {
if (!circularFoundAndAdded) { if (!circularFoundAndAdded) {
circularFoundAndAdded = true; circularFoundAndAdded = true;
addGroup = true; addGroup = true;
aGroup->SetName("CIRCULAR_QUARTER_PIPE"); aGroup->SetName("CIRCULAR_QUARTER_PIPE");
} }
} }
else if (nbEdges == 8) { else if (nbEdges == 8) {
incidentPipeFound = true; incidentPipeFound = true;
mainPipeFound = false; mainPipeFound = false;
radialFound =false; radialFound =false;
flangeFound = false; flangeFound = false;
TopExp_Explorer Ex(aGroupShapeTrsfInv,TopAbs_VERTEX); TopExp_Explorer Ex(aGroupShapeTrsfInv,TopAbs_VERTEX);
while (Ex.More()) { while (Ex.More()) {
gp_Pnt aP = BRep_Tool::Pnt(TopoDS::Vertex(Ex.Current())); gp_Pnt aP = BRep_Tool::Pnt(TopoDS::Vertex(Ex.Current()));
double x=aP.X(), y=aP.Y(), z=aP.Z(); double x=aP.X(), y=aP.Y(), z=aP.Z();
if ((Abs(x) > aR2Ext + Precision::Confusion()) || if ((Abs(x) > aR2Ext + Precision::Confusion()) ||
(Abs(y) > aR2Ext + Precision::Confusion())) { (Abs(y) > aR2Ext + Precision::Confusion())) {
incidentPipeFound = false; incidentPipeFound = false;
} }
if ( z < -Precision::Confusion()) { if ( z < -Precision::Confusion()) {
// length of main pipe // length of main pipe
mainPipeFound = true; mainPipeFound = true;
if (!mainPipeFoundAndAdded) { if (!mainPipeFoundAndAdded) {
mainPipeFoundAndAdded = true; mainPipeFoundAndAdded = true;
addGroup = true; addGroup = true;
aGroup->SetName("HALF_LENGTH_MAIN_PIPE"); aGroup->SetName("HALF_LENGTH_MAIN_PIPE");
} }
} }
else if (Abs(x) > (theL1-Precision::Confusion())) { else if (Abs(x) > (theL1-Precision::Confusion())) {
// discretisation circulaire // discretisation circulaire
radialFound = true; radialFound = true;
if (!circularFoundAndAdded) { if (!circularFoundAndAdded) {
circularFoundAndAdded = true; circularFoundAndAdded = true;
addGroup = true; addGroup = true;
aGroup->SetName("CIRCULAR_QUARTER_PIPE"); aGroup->SetName("CIRCULAR_QUARTER_PIPE");
} }
} }
Ex.Next(); Ex.Next();
} }
if (incidentPipeFound) { if (incidentPipeFound) {
addGroup = true; addGroup = true;
aGroup->SetName("HALF_LENGTH_INCIDENT_PIPE"); aGroup->SetName("HALF_LENGTH_INCIDENT_PIPE");
} }
if (!addGroup && (!incidentPipeFound && if (!addGroup && (!incidentPipeFound &&
!radialFound && !radialFound &&
!mainPipeFound && !mainPipeFound &&
!flangeFound)) { !flangeFound)) {
// Flange (collerette) // Flange (collerette)
flangeFound = true; flangeFound = true;
addGroup = true; addGroup = true;
aGroup->SetName("FLANGE"); aGroup->SetName("FLANGE");
} }
} }
else else
continue; continue;
} }
else if (shapeType == TSHAPE_CHAMFER || shapeType == TSHAPE_FILLET) { else if (shapeType == TSHAPE_CHAMFER || shapeType == TSHAPE_FILLET) {
if (nbEdges == 25) { if (nbEdges == 25) {
addGroup = true; addGroup = true;
aGroup->SetName("THICKNESS"); aGroup->SetName("THICKNESS");
} }
else if ((nbEdges == 10) || (nbEdges == 6)) { else if ((nbEdges == 10) || (nbEdges == 6)) {
if (!circularFoundAndAdded) { if (!circularFoundAndAdded) {
addGroup = true; addGroup = true;
circularFoundAndAdded = true; circularFoundAndAdded = true;
aGroup->SetName("CIRCULAR_QUARTER_PIPE"); aGroup->SetName("CIRCULAR_QUARTER_PIPE");
} }
} }
else if (nbEdges == 8) { else if (nbEdges == 8) {
incidentPipeFound = true; incidentPipeFound = true;
mainPipeFound = true; mainPipeFound = true;
flangeFound = false; flangeFound = false;
TopExp_Explorer Ex(aGroupShapeTrsfInv,TopAbs_VERTEX); TopExp_Explorer Ex(aGroupShapeTrsfInv,TopAbs_VERTEX);
while (Ex.More()) { while (Ex.More()) {
gp_Pnt aP = BRep_Tool::Pnt(TopoDS::Vertex(Ex.Current())); gp_Pnt aP = BRep_Tool::Pnt(TopoDS::Vertex(Ex.Current()));
double x=aP.X(), y=aP.Y(), z=aP.Z(); double x=aP.X(), y=aP.Y(), z=aP.Z();
// tuy_princ_long_avant & tuy_princ_long_apres // tuy_princ_long_avant & tuy_princ_long_apres
bool isMain = (((z < Precision::Confusion()) || (x < Precision::Confusion())) && bool isMain = (((z < Precision::Confusion()) || (x < Precision::Confusion())) &&
((y <= aR1Ext + Precision::Confusion()) || ((y <= aR1Ext + Precision::Confusion()) ||
(y <= -(aR1Ext + Precision::Confusion())) || (y <= -(aR1Ext + Precision::Confusion())) ||
(y <= theR1 + Precision::Confusion()) || (y <= theR1 + Precision::Confusion()) ||
(y == -(theR1 + Precision::Confusion())))); (y == -(theR1 + Precision::Confusion()))));
if (!isMain) {
mainPipeFound = false;
}
if (!isMain) { // collerette
mainPipeFound = false; if (z < Precision::Confusion()) {
} flangeFound = true;
if (!flangeFoundAndAdded) {
flangeFoundAndAdded = true;
addGroup = true;
aGroup->SetName("FLANGE");
}
}
// collerette // tuyau incident
if (z < Precision::Confusion()) { if ((Abs(x) > aR2Ext + Precision::Confusion()) ||
flangeFound = true; (Abs(y) > aR2Ext + Precision::Confusion())) {
if (!flangeFoundAndAdded) { incidentPipeFound = false;
flangeFoundAndAdded = true; }
addGroup = true; Ex.Next();
aGroup->SetName("FLANGE"); }
} if (mainPipeFound) {
} addGroup = true;
aGroup->SetName("HALF_LENGTH_MAIN_PIPE");
// tuyau incident }
if ((Abs(x) > aR2Ext + Precision::Confusion()) || if (incidentPipeFound) {
(Abs(y) > aR2Ext + Precision::Confusion())) { addGroup = true;
incidentPipeFound = false; aGroup->SetName("HALF_LENGTH_INCIDENT_PIPE");
} }
Ex.Next(); if (!addGroup && (!incidentPipeFound &&
} !mainPipeFound &&
if (mainPipeFound) { !flangeFound &&
addGroup = true; !chamferOrFilletFound)) {
aGroup->SetName("HALF_LENGTH_MAIN_PIPE"); addGroup = true;
} chamferOrFilletFound = true;
if (incidentPipeFound) { if (shapeType == TSHAPE_CHAMFER)
addGroup = true; aGroup->SetName("CHAMFER");
aGroup->SetName("HALF_LENGTH_INCIDENT_PIPE"); else
} aGroup->SetName("FILLET");
if (!addGroup && (!incidentPipeFound && }
!mainPipeFound &&
!flangeFound &&
!chamferOrFilletFound)) {
addGroup = true;
chamferOrFilletFound = true;
if (shapeType == TSHAPE_CHAMFER)
aGroup->SetName("CHAMFER");
else
aGroup->SetName("FILLET");
}
} }
else else
continue; continue;
} }
// Add group to the list // Add group to the list
if (addGroup) if (addGroup)
@ -587,10 +591,10 @@ bool GEOMImpl_IAdvancedOperations::MakeGroups(Handle(GEOM_Object) theShape, int
} }
bool GEOMImpl_IAdvancedOperations::MakePipeTShapePartition(Handle(GEOM_Object) theShape, bool GEOMImpl_IAdvancedOperations::MakePipeTShapePartition(Handle(GEOM_Object) theShape,
double theR1, double theW1, double theL1, double theR1, double theW1, double theL1,
double theR2, double theW2, double theL2, double theR2, double theW2, double theL2,
double theH, double theW, double theH, double theW,
double theRF, bool isNormal) double theRF, bool isNormal)
{ {
SetErrorCode(KO); SetErrorCode(KO);
@ -620,7 +624,8 @@ bool GEOMImpl_IAdvancedOperations::MakePipeTShapePartition(Handle(GEOM_Object) t
Handle(GEOM_Function) aFunction = theShape->GetLastFunction(); Handle(GEOM_Function) aFunction = theShape->GetLastFunction();
TCollection_AsciiString theDesc = aFunction->GetDescription(); TCollection_AsciiString theDesc = aFunction->GetDescription();
Handle(TColStd_HSequenceOfTransient) edges_i = myShapesOperations->GetShapesOnBox(box_i, theShape, TopAbs_EDGE, GEOMAlgo_ST_IN); Handle(TColStd_HSequenceOfTransient) edges_i =
myShapesOperations->GetShapesOnBox(box_i, theShape, TopAbs_EDGE, GEOMAlgo_ST_IN);
// Recover previous description to get rid of Propagate dump // Recover previous description to get rid of Propagate dump
aFunction->SetDescription(theDesc); aFunction->SetDescription(theDesc);
if (edges_i.IsNull() || edges_i->Length() == 0) { if (edges_i.IsNull() || edges_i->Length() == 0) {
@ -636,7 +641,8 @@ bool GEOMImpl_IAdvancedOperations::MakePipeTShapePartition(Handle(GEOM_Object) t
// search for vertices located on both internal pipes // search for vertices located on both internal pipes
aFunction = theShape->GetLastFunction(); aFunction = theShape->GetLastFunction();
theDesc = aFunction->GetDescription(); theDesc = aFunction->GetDescription();
Handle(TColStd_HSequenceOfTransient) vertices_i = myShapesOperations->GetShapesOnBox(box_i, theShape, TopAbs_VERTEX, GEOMAlgo_ST_ONIN); Handle(TColStd_HSequenceOfTransient) vertices_i =
myShapesOperations->GetShapesOnBox(box_i, theShape, TopAbs_VERTEX, GEOMAlgo_ST_ONIN);
// Recover previous description to get rid of Propagate dump // Recover previous description to get rid of Propagate dump
aFunction->SetDescription(theDesc); aFunction->SetDescription(theDesc);
if (vertices_i.IsNull() || vertices_i->Length() == 0) { if (vertices_i.IsNull() || vertices_i->Length() == 0) {
@ -651,10 +657,10 @@ bool GEOMImpl_IAdvancedOperations::MakePipeTShapePartition(Handle(GEOM_Object) t
gp_Pnt aP = BRep_Tool::Pnt(aVertex); gp_Pnt aP = BRep_Tool::Pnt(aVertex);
if (Abs(aP.X()) <= Precision::Confusion()) { if (Abs(aP.X()) <= Precision::Confusion()) {
if (Abs(aP.Y()) - theR2 <= Precision::Confusion()) if (Abs(aP.Y()) - theR2 <= Precision::Confusion())
vi1 = v; vi1 = v;
} else if (Abs(aP.Y()) <= Precision::Confusion()) { } else if (Abs(aP.Y()) <= Precision::Confusion()) {
if (Abs(aP.X()) - theR1 <= Precision::Confusion()) if (Abs(aP.X()) - theR1 <= Precision::Confusion())
vi2 = v; vi2 = v;
} }
} }
@ -670,7 +676,8 @@ bool GEOMImpl_IAdvancedOperations::MakePipeTShapePartition(Handle(GEOM_Object) t
// Common edges on external cylinder // Common edges on external cylinder
aFunction = theShape->GetLastFunction(); aFunction = theShape->GetLastFunction();
theDesc = aFunction->GetDescription(); theDesc = aFunction->GetDescription();
Handle(TColStd_HSequenceOfTransient) edges_e = myShapesOperations->GetShapesOnBox(box_e, theShape, TopAbs_EDGE, GEOMAlgo_ST_IN); Handle(TColStd_HSequenceOfTransient) edges_e =
myShapesOperations->GetShapesOnBox(box_e, theShape, TopAbs_EDGE, GEOMAlgo_ST_IN);
// Recover previous description to get rid of Propagate dump // Recover previous description to get rid of Propagate dump
aFunction->SetDescription(theDesc); aFunction->SetDescription(theDesc);
if (edges_e.IsNull() || edges_e->Length() == 0) { if (edges_e.IsNull() || edges_e->Length() == 0) {
@ -685,7 +692,8 @@ bool GEOMImpl_IAdvancedOperations::MakePipeTShapePartition(Handle(GEOM_Object) t
// search for vertices located on both external pipes // search for vertices located on both external pipes
aFunction = theShape->GetLastFunction(); aFunction = theShape->GetLastFunction();
theDesc = aFunction->GetDescription(); theDesc = aFunction->GetDescription();
Handle(TColStd_HSequenceOfTransient) vertices_e = myShapesOperations->GetShapesOnBox(box_e, theShape, TopAbs_VERTEX, GEOMAlgo_ST_ONIN); Handle(TColStd_HSequenceOfTransient) vertices_e =
myShapesOperations->GetShapesOnBox(box_e, theShape, TopAbs_VERTEX, GEOMAlgo_ST_ONIN);
// Recover previous description to get rid of Propagate dump // Recover previous description to get rid of Propagate dump
aFunction->SetDescription(theDesc); aFunction->SetDescription(theDesc);
if (vertices_e.IsNull() || vertices_e->Length() == 0) { if (vertices_e.IsNull() || vertices_e->Length() == 0) {
@ -699,11 +707,11 @@ bool GEOMImpl_IAdvancedOperations::MakePipeTShapePartition(Handle(GEOM_Object) t
TopoDS_Vertex aVertex = TopoDS::Vertex(v->GetValue()); TopoDS_Vertex aVertex = TopoDS::Vertex(v->GetValue());
gp_Pnt aP = BRep_Tool::Pnt(aVertex); gp_Pnt aP = BRep_Tool::Pnt(aVertex);
if (Abs(aP.X()) <= Precision::Confusion()) { if (Abs(aP.X()) <= Precision::Confusion()) {
if (Abs(aP.Y()) - theR2 > Precision::Confusion()) if (Abs(aP.Y()) - theR2 > Precision::Confusion())
ve1 = v; ve1 = v;
} else if (Abs(aP.Y()) <= Precision::Confusion()) { } else if (Abs(aP.Y()) <= Precision::Confusion()) {
if (Abs(aP.X()) - theR2 > Precision::Confusion()) if (Abs(aP.X()) - theR2 > Precision::Confusion())
ve2 = v; ve2 = v;
} }
} }
Handle(GEOM_Object) edge_e1, edge_e2; Handle(GEOM_Object) edge_e1, edge_e2;
@ -713,8 +721,8 @@ bool GEOMImpl_IAdvancedOperations::MakePipeTShapePartition(Handle(GEOM_Object) t
#endif #endif
edge_e1 = myBasicOperations->MakeLineTwoPnt(ve1, vi1); edge_e1 = myBasicOperations->MakeLineTwoPnt(ve1, vi1);
if (edge_e1.IsNull()) { if (edge_e1.IsNull()) {
SetErrorCode("Edge 1 could not be built"); SetErrorCode("Edge 1 could not be built");
return false; return false;
} }
} catch (Standard_Failure) { } catch (Standard_Failure) {
Handle(Standard_Failure) aFail = Standard_Failure::Caught(); Handle(Standard_Failure) aFail = Standard_Failure::Caught();
@ -728,8 +736,8 @@ bool GEOMImpl_IAdvancedOperations::MakePipeTShapePartition(Handle(GEOM_Object) t
#endif #endif
edge_e2 = myBasicOperations->MakeLineTwoPnt(ve2, vi2); edge_e2 = myBasicOperations->MakeLineTwoPnt(ve2, vi2);
if (edge_e2.IsNull()) { if (edge_e2.IsNull()) {
SetErrorCode("Edge 2 could not be built"); SetErrorCode("Edge 2 could not be built");
return false; return false;
} }
} catch (Standard_Failure) { } catch (Standard_Failure) {
Handle(Standard_Failure) aFail = Standard_Failure::Caught(); Handle(Standard_Failure) aFail = Standard_Failure::Caught();
@ -765,22 +773,25 @@ bool GEOMImpl_IAdvancedOperations::MakePipeTShapePartition(Handle(GEOM_Object) t
double ZX=0, ZY=0; double ZX=0, ZY=0;
std::vector<int> LX; std::vector<int> LX;
std::vector<int> LY; std::vector<int> LY;
Handle(GEOM_Object) box_e = my3DPrimOperations->MakeBoxDXDYDZ(theVertCylinderRadius, theVertCylinderRadius, theHoriCylinderRadius); Handle(GEOM_Object) box_e = my3DPrimOperations->MakeBoxDXDYDZ
(theVertCylinderRadius, theVertCylinderRadius, theHoriCylinderRadius);
box_e->GetLastFunction()->SetDescription(""); box_e->GetLastFunction()->SetDescription("");
box_e = myTransformOperations->TranslateDXDYDZ(box_e, -theVertCylinderRadius, -theVertCylinderRadius, 0); box_e = myTransformOperations->TranslateDXDYDZ
(box_e, -theVertCylinderRadius, -theVertCylinderRadius, 0);
box_e->GetLastFunction()->SetDescription(""); box_e->GetLastFunction()->SetDescription("");
aFunction = theShape->GetLastFunction(); aFunction = theShape->GetLastFunction();
theDesc = aFunction->GetDescription(); theDesc = aFunction->GetDescription();
Handle(TColStd_HSequenceOfTransient) extremVertices = myShapesOperations->GetShapesOnBox(box_e, theShape, TopAbs_VERTEX, GEOMAlgo_ST_ONIN); Handle(TColStd_HSequenceOfTransient) extremVertices =
myShapesOperations->GetShapesOnBox(box_e, theShape, TopAbs_VERTEX, GEOMAlgo_ST_ONIN);
// Recover previous description to get rid of Propagate dump // Recover previous description to get rid of Propagate dump
aFunction->SetDescription(theDesc); aFunction->SetDescription(theDesc);
if (extremVertices.IsNull() || extremVertices->Length() == 0) { if (extremVertices.IsNull() || extremVertices->Length() == 0) {
if (theRF == 0) if (theRF == 0)
SetErrorCode("Vertices on chamfer not found"); SetErrorCode("Vertices on chamfer not found");
else else
SetErrorCode("Vertices on fillet not found"); SetErrorCode("Vertices on fillet not found");
return false; return false;
} }
@ -803,22 +814,22 @@ bool GEOMImpl_IAdvancedOperations::MakePipeTShapePartition(Handle(GEOM_Object) t
gp_Pnt aP = BRep_Tool::Pnt(TopoDS::Vertex(aV->GetValue())); gp_Pnt aP = BRep_Tool::Pnt(TopoDS::Vertex(aV->GetValue()));
if (Abs(aP.X()) <= Precision::Confusion()) { if (Abs(aP.X()) <= Precision::Confusion()) {
if (Abs(aP.Y()) - theR2 > Precision::Confusion()) { if (Abs(aP.Y()) - theR2 > Precision::Confusion()) {
LX.push_back(i); LX.push_back(i);
if (aP.Z()-ZX > Precision::Confusion()) { if (aP.Z()-ZX > Precision::Confusion()) {
ZX = aP.Z(); ZX = aP.Z();
PZX = i; PZX = i;
} }
} }
} }
else { else {
if (Abs(aP.X()) - theR2 > Precision::Confusion()) { if (Abs(aP.X()) - theR2 > Precision::Confusion()) {
LY.push_back(i); LY.push_back(i);
if (aP.Z() - ZY > Precision::Confusion()) { if (aP.Z() - ZY > Precision::Confusion()) {
ZY = aP.Z(); ZY = aP.Z();
PZY = i; PZY = i;
} }
} }
} }
} }
@ -942,14 +953,15 @@ bool GEOMImpl_IAdvancedOperations::MakePipeTShapePartition(Handle(GEOM_Object) t
edgeList2.push_back(Cote_5); edgeList2.push_back(Cote_5);
edgeList2.push_back(Cote_4); edgeList2.push_back(Cote_4);
// std::cerr << "Creating wire 2" << std::endl; // std::cerr << "Creating wire 2" << std::endl;
wire_t2 = myShapesOperations->MakeWire(edgeList2, 1e-7); //wire_t2 = myShapesOperations->MakeWire(edgeList2, 1e-7);
if (wire_t2.IsNull()) { //if (wire_t2.IsNull()) {
SetErrorCode("Impossible to build wire"); // SetErrorCode("Impossible to build wire");
return false; // return false;
} //}
wire_t2->GetLastFunction()->SetDescription(""); //wire_t2->GetLastFunction()->SetDescription("");
// std::cerr << "Creating face 2" << std::endl; // std::cerr << "Creating face 2" << std::endl;
face_t2 = myShapesOperations->MakeFace(wire_t2, false); //face_t2 = myShapesOperations->MakeFace(wire_t2, false);
face_t2 = my3DPrimOperations->MakePrismVecH(edge_chan_inc, Cote_4, - 2.0*theR2);
if (face_t2.IsNull()) { if (face_t2.IsNull()) {
SetErrorCode("Impossible to build face"); SetErrorCode("Impossible to build face");
return false; return false;
@ -972,7 +984,21 @@ bool GEOMImpl_IAdvancedOperations::MakePipeTShapePartition(Handle(GEOM_Object) t
theShapes.push_back(aPlnOZ); theShapes.push_back(aPlnOZ);
theShapes.push_back(aPlnOXZ); theShapes.push_back(aPlnOXZ);
// tmp
/*
BRepTools::Write(theShape->GetValue(),
"/dn25/salome/jfa/DATA/Salome/BUGS/M_0020998_Some_limitations_to_the_PipeTShape/theShape.brep");
BRepTools::Write(aPlnOZ->GetValue(),
"/dn25/salome/jfa/DATA/Salome/BUGS/M_0020998_Some_limitations_to_the_PipeTShape/aPlnOZ.brep");
BRepTools::Write(aPlnOXZ->GetValue(),
"/dn25/salome/jfa/DATA/Salome/BUGS/M_0020998_Some_limitations_to_the_PipeTShape/aPlnOXZ.brep");
BRepTools::Write(face_t->GetValue(),
"/dn25/salome/jfa/DATA/Salome/BUGS/M_0020998_Some_limitations_to_the_PipeTShape/face_t.brep");
BRepTools::Write(face_t2->GetValue(),
"/dn25/salome/jfa/DATA/Salome/BUGS/M_0020998_Some_limitations_to_the_PipeTShape/face_t2.brep");
*/
// Partition
Handle(TColStd_HSequenceOfTransient) partitionShapes = new TColStd_HSequenceOfTransient; Handle(TColStd_HSequenceOfTransient) partitionShapes = new TColStd_HSequenceOfTransient;
Handle(TColStd_HSequenceOfTransient) theTools = new TColStd_HSequenceOfTransient; Handle(TColStd_HSequenceOfTransient) theTools = new TColStd_HSequenceOfTransient;
Handle(TColStd_HSequenceOfTransient) theKeepInside = new TColStd_HSequenceOfTransient; Handle(TColStd_HSequenceOfTransient) theKeepInside = new TColStd_HSequenceOfTransient;
@ -986,7 +1012,9 @@ bool GEOMImpl_IAdvancedOperations::MakePipeTShapePartition(Handle(GEOM_Object) t
if (!isNormal) if (!isNormal)
theTools->Append(face_t2); theTools->Append(face_t2);
Handle(GEOM_Object) Te3 = myBooleanOperations->MakePartition(partitionShapes, theTools, theKeepInside, theRemoveInside, TopAbs_SOLID, false, theMaterials, 0, false); Handle(GEOM_Object) Te3 = myBooleanOperations->MakePartition
(partitionShapes, theTools, theKeepInside, theRemoveInside,
TopAbs_SOLID, false, theMaterials, 0, false);
if (Te3.IsNull()) { if (Te3.IsNull()) {
SetErrorCode("Impossible to build partition of TShape"); SetErrorCode("Impossible to build partition of TShape");
// Handle(GEOM_Object) aCompound = myShapesOperations->MakeCompound(theShapes); // Handle(GEOM_Object) aCompound = myShapesOperations->MakeCompound(theShapes);
@ -1011,8 +1039,8 @@ bool GEOMImpl_IAdvancedOperations::MakePipeTShapePartition(Handle(GEOM_Object) t
// Mirror and glue faces // Mirror and glue faces
bool GEOMImpl_IAdvancedOperations::MakePipeTShapeMirrorAndGlue(Handle(GEOM_Object) theShape, bool GEOMImpl_IAdvancedOperations::MakePipeTShapeMirrorAndGlue(Handle(GEOM_Object) theShape,
double theR1, double theW1, double theL1, double theR1, double theW1, double theL1,
double theR2, double theW2, double theL2) double theR2, double theW2, double theL2)
{ {
SetErrorCode(KO); SetErrorCode(KO);
@ -1099,8 +1127,8 @@ bool GEOMImpl_IAdvancedOperations::MakePipeTShapeMirrorAndGlue(Handle(GEOM_Objec
//============================================================================= //=============================================================================
Handle(TColStd_HSequenceOfTransient) Handle(TColStd_HSequenceOfTransient)
GEOMImpl_IAdvancedOperations::MakePipeTShape(double theR1, double theW1, double theL1, GEOMImpl_IAdvancedOperations::MakePipeTShape(double theR1, double theW1, double theL1,
double theR2, double theW2, double theL2, double theR2, double theW2, double theL2,
bool theHexMesh) bool theHexMesh)
{ {
MESSAGE("GEOMImpl_IAdvancedOperations::MakePipeTShape"); MESSAGE("GEOMImpl_IAdvancedOperations::MakePipeTShape");
SetErrorCode(KO); SetErrorCode(KO);
@ -1180,17 +1208,19 @@ GEOMImpl_IAdvancedOperations::MakePipeTShape(double theR1, double theW1, double
aListRes.Trunc(aListRes.Length() - 2); aListRes.Trunc(aListRes.Length() - 2);
//Make a Python command //Make a Python command
GEOM::TPythonDump(aFunction) << "[" << aShape << ", " << aListRes.ToCString() << "] = geompy.MakePipeTShape(" GEOM::TPythonDump(aFunction)
<< theR1 << ", " << theW1 << ", " << theL1 << ", " << theR2 << ", " << theW2 << ", " << theL2 << ", " << "[" << aShape << ", " << aListRes.ToCString() << "] = geompy.MakePipeTShape("
<< theHexMesh << ")"; << theR1 << ", " << theW1 << ", " << theL1 << ", " << theR2 << ", " << theW2 << ", " << theL2 << ", "
<< theHexMesh << ")";
} }
/* /*
* Get the groups: END * Get the groups: END
*/ */
else { else {
//Make a Python command //Make a Python command
GEOM::TPythonDump(aFunction) << "[" << aShape << "] = geompy.MakePipeTShape(" << theR1 << ", " << theW1 << ", " GEOM::TPythonDump(aFunction)
<< theL1 << ", " << theR2 << ", " << theW2 << ", " << theL2 << ", " << theHexMesh << ")"; << "[" << aShape << "] = geompy.MakePipeTShape(" << theR1 << ", " << theW1 << ", "
<< theL1 << ", " << theR2 << ", " << theW2 << ", " << theL2 << ", " << theHexMesh << ")";
} }
SetErrorCode(OK); SetErrorCode(OK);
@ -1220,11 +1250,11 @@ GEOMImpl_IAdvancedOperations::MakePipeTShape(double theR1, double theW1, double
//============================================================================= //=============================================================================
Handle(TColStd_HSequenceOfTransient) Handle(TColStd_HSequenceOfTransient)
GEOMImpl_IAdvancedOperations::MakePipeTShapeWithPosition(double theR1, double theW1, double theL1, GEOMImpl_IAdvancedOperations::MakePipeTShapeWithPosition(double theR1, double theW1, double theL1,
double theR2, double theW2, double theL2, double theR2, double theW2, double theL2,
bool theHexMesh, bool theHexMesh,
Handle(GEOM_Object) theP1, Handle(GEOM_Object) theP1,
Handle(GEOM_Object) theP2, Handle(GEOM_Object) theP2,
Handle(GEOM_Object) theP3) Handle(GEOM_Object) theP3)
{ {
SetErrorCode(KO); SetErrorCode(KO);
//Add a new object //Add a new object
@ -1318,9 +1348,10 @@ GEOMImpl_IAdvancedOperations::MakePipeTShapeWithPosition(double theR1, double th
aListRes.Trunc(aListRes.Length() - 2); aListRes.Trunc(aListRes.Length() - 2);
//Make a Python command //Make a Python command
GEOM::TPythonDump(aFunction) << "[" << aShape << ", " << aListRes.ToCString() << "] = geompy.MakePipeTShape(" GEOM::TPythonDump(aFunction)
<< theR1 << ", " << theW1 << ", " << theL1 << ", " << theR2 << ", " << theW2 << ", " << theL2 << ", " << "[" << aShape << ", " << aListRes.ToCString() << "] = geompy.MakePipeTShape("
<< theHexMesh << ", " << theP1 << ", " << theP2 << ", " << theP3 << ")"; << theR1 << ", " << theW1 << ", " << theL1 << ", " << theR2 << ", " << theW2 << ", " << theL2 << ", "
<< theHexMesh << ", " << theP1 << ", " << theP2 << ", " << theP3 << ")";
} }
// //
// Get the groups: END // Get the groups: END
@ -1328,9 +1359,10 @@ GEOMImpl_IAdvancedOperations::MakePipeTShapeWithPosition(double theR1, double th
else { else {
//Make a Python command //Make a Python command
GEOM::TPythonDump(aFunction) << "[" << aShape << "] = geompy.MakePipeTShape(" << theR1 << ", " << theW1 << ", " GEOM::TPythonDump(aFunction)
<< theL1 << ", " << theR2 << ", " << theW2 << ", " << theL2 << ", " << theHexMesh << ", " << theP1 << "[" << aShape << "] = geompy.MakePipeTShape(" << theR1 << ", " << theW1 << ", "
<< ", " << theP2 << ", " << theP3 << ")"; << theL1 << ", " << theR2 << ", " << theW2 << ", " << theL2 << ", " << theHexMesh << ", " << theP1
<< ", " << theP2 << ", " << theP3 << ")";
} }
SetErrorCode(OK); SetErrorCode(OK);
@ -1359,9 +1391,9 @@ GEOMImpl_IAdvancedOperations::MakePipeTShapeWithPosition(double theR1, double th
//============================================================================= //=============================================================================
Handle(TColStd_HSequenceOfTransient) Handle(TColStd_HSequenceOfTransient)
GEOMImpl_IAdvancedOperations::MakePipeTShapeChamfer(double theR1, double theW1, double theL1, GEOMImpl_IAdvancedOperations::MakePipeTShapeChamfer(double theR1, double theW1, double theL1,
double theR2, double theW2, double theL2, double theR2, double theW2, double theL2,
double theH, double theW, double theH, double theW,
bool theHexMesh) bool theHexMesh)
{ {
SetErrorCode(KO); SetErrorCode(KO);
//Add a new object //Add a new object
@ -1416,7 +1448,8 @@ GEOMImpl_IAdvancedOperations::MakePipeTShapeChamfer(double theR1, double theW1,
box_e = myTransformOperations->TranslateDXDYDZ(box_e, -(theR2+theW2), -(theR2+theW2), 0); box_e = myTransformOperations->TranslateDXDYDZ(box_e, -(theR2+theW2), -(theR2+theW2), 0);
box_e->GetLastFunction()->SetDescription(""); box_e->GetLastFunction()->SetDescription("");
Handle(TColStd_HSequenceOfInteger) edges_e = myShapesOperations->GetShapesOnBoxIDs(box_e, aShape, TopAbs_EDGE, GEOMAlgo_ST_IN); Handle(TColStd_HSequenceOfInteger) edges_e =
myShapesOperations->GetShapesOnBoxIDs(box_e, aShape, TopAbs_EDGE, GEOMAlgo_ST_IN);
box_e->GetLastFunction()->SetDescription(""); box_e->GetLastFunction()->SetDescription("");
if (edges_e.IsNull() || edges_e->Length() == 0) { if (edges_e.IsNull() || edges_e->Length() == 0) {
@ -1434,8 +1467,8 @@ GEOMImpl_IAdvancedOperations::MakePipeTShapeChamfer(double theR1, double theW1,
iv ++; iv ++;
gp_Pnt aPt = BRep_Tool::Pnt(TopoDS::Vertex(Ex.Current())); gp_Pnt aPt = BRep_Tool::Pnt(TopoDS::Vertex(Ex.Current()));
if (Abs(aPt.Z() - (theR1+theW1)) <= Precision::Confusion()) { if (Abs(aPt.Z() - (theR1+theW1)) <= Precision::Confusion()) {
nbEdgesInChamfer ++; nbEdgesInChamfer ++;
theEdges.push_back(edgeID); theEdges.push_back(edgeID);
} }
Ex.Next(); Ex.Next();
} }
@ -1484,13 +1517,14 @@ GEOMImpl_IAdvancedOperations::MakePipeTShapeChamfer(double theR1, double theW1,
// //
// Get the groups: BEGIN // Get the groups: BEGIN
// //
// if (!MakeGroups(aShape, TSHAPE_CHAMFER, theR1, theW1, theL1, theR2, theW2, theL2, aSeq, gp_Trsf())) { //if (!MakeGroups(aShape, TSHAPE_CHAMFER, theR1, theW1, theL1, theR2, theW2, theL2, aSeq, gp_Trsf())) {
// //Make a Python command // //Make a Python command
// GEOM::TPythonDump(aFunction) << "[" << aShape << "] = geompy.MakePipeTShapeChamfer(" << theR1 << ", " << theW1 // GEOM::TPythonDump(aFunction)
// << ", " << theL1 << ", " << theR2 << ", " << theW2 << ", " << theL2 << ", " << theH << ", " << theW // << "[" << aShape << "] = geompy.MakePipeTShapeChamfer(" << theR1 << ", " << theW1
// << ", " << theHexMesh << ")"; // << ", " << theL1 << ", " << theR2 << ", " << theW2 << ", " << theL2 << ", " << theH << ", " << theW
// } // << ", " << theHexMesh << ")";
// else { //}
//else {
try { try {
if (!MakeGroups(aShape, TSHAPE_CHAMFER, theR1, theW1, theL1, theR2, theW2, theL2, aSeq, gp_Trsf())) if (!MakeGroups(aShape, TSHAPE_CHAMFER, theR1, theW1, theL1, theR2, theW2, theL2, aSeq, gp_Trsf()))
return NULL; return NULL;
@ -1518,19 +1552,21 @@ GEOMImpl_IAdvancedOperations::MakePipeTShapeChamfer(double theR1, double theW1,
aListRes.Trunc(aListRes.Length() - 2); aListRes.Trunc(aListRes.Length() - 2);
//Make a Python command //Make a Python command
GEOM::TPythonDump(aFunction) << "[" << aShape << ", " << aListRes.ToCString() GEOM::TPythonDump(aFunction)
<< "] = geompy.MakePipeTShapeChamfer(" << theR1 << ", " << theW1 << ", " << theL1 << ", " << theR2 << "[" << aShape << ", " << aListRes.ToCString()
<< ", " << theW2 << ", " << theL2 << ", " << theH << ", " << theW << ", " << theHexMesh << ")"; << "] = geompy.MakePipeTShapeChamfer(" << theR1 << ", " << theW1 << ", " << theL1 << ", " << theR2
// } << ", " << theW2 << ", " << theL2 << ", " << theH << ", " << theW << ", " << theHexMesh << ")";
//}
} }
// //
// Get the groups: END // Get the groups: END
// //
else { else {
//Make a Python command //Make a Python command
GEOM::TPythonDump(aFunction) << "[" << aShape << "] = geompy.MakePipeTShapeChamfer(" << theR1 << ", " << theW1 GEOM::TPythonDump(aFunction)
<< ", " << theL1 << ", " << theR2 << ", " << theW2 << ", " << theL2 << ", " << theH << ", " << theW << "[" << aShape << "] = geompy.MakePipeTShapeChamfer(" << theR1 << ", " << theW1
<< ", " << theHexMesh << ")"; << ", " << theL1 << ", " << theR2 << ", " << theW2 << ", " << theL2 << ", " << theH << ", " << theW
<< ", " << theHexMesh << ")";
} }
SetErrorCode(OK); SetErrorCode(OK);
@ -1563,12 +1599,12 @@ GEOMImpl_IAdvancedOperations::MakePipeTShapeChamfer(double theR1, double theW1,
//============================================================================= //=============================================================================
Handle(TColStd_HSequenceOfTransient) Handle(TColStd_HSequenceOfTransient)
GEOMImpl_IAdvancedOperations::MakePipeTShapeChamferWithPosition(double theR1, double theW1, double theL1, GEOMImpl_IAdvancedOperations::MakePipeTShapeChamferWithPosition(double theR1, double theW1, double theL1,
double theR2, double theW2, double theL2, double theR2, double theW2, double theL2,
double theH, double theW, double theH, double theW,
bool theHexMesh, bool theHexMesh,
Handle(GEOM_Object) theP1, Handle(GEOM_Object) theP1,
Handle(GEOM_Object) theP2, Handle(GEOM_Object) theP2,
Handle(GEOM_Object) theP3) Handle(GEOM_Object) theP3)
{ {
SetErrorCode(KO); SetErrorCode(KO);
//Add a new object //Add a new object
@ -1628,7 +1664,8 @@ GEOMImpl_IAdvancedOperations::MakePipeTShapeChamferWithPosition(double theR1, do
box_e = myTransformOperations->TranslateDXDYDZ(box_e, -(theR2+theW2), -(theR2+theW2), 0); box_e = myTransformOperations->TranslateDXDYDZ(box_e, -(theR2+theW2), -(theR2+theW2), 0);
box_e->GetLastFunction()->SetDescription(""); box_e->GetLastFunction()->SetDescription("");
Handle(TColStd_HSequenceOfInteger) edges_e = myShapesOperations->GetShapesOnBoxIDs(box_e, aShape, TopAbs_EDGE, GEOMAlgo_ST_IN); Handle(TColStd_HSequenceOfInteger) edges_e =
myShapesOperations->GetShapesOnBoxIDs(box_e, aShape, TopAbs_EDGE, GEOMAlgo_ST_IN);
box_e->GetLastFunction()->SetDescription(""); box_e->GetLastFunction()->SetDescription("");
if (edges_e.IsNull() || edges_e->Length() == 0) { if (edges_e.IsNull() || edges_e->Length() == 0) {
@ -1644,8 +1681,8 @@ GEOMImpl_IAdvancedOperations::MakePipeTShapeChamferWithPosition(double theR1, do
while (Ex.More()) { while (Ex.More()) {
gp_Pnt aPt = BRep_Tool::Pnt(TopoDS::Vertex(Ex.Current())); gp_Pnt aPt = BRep_Tool::Pnt(TopoDS::Vertex(Ex.Current()));
if (Abs(aPt.Z() - (theR1+theW1)) <= Precision::Confusion()) { if (Abs(aPt.Z() - (theR1+theW1)) <= Precision::Confusion()) {
nbEdgesInChamfer ++; nbEdgesInChamfer ++;
theEdges.push_back(edgeID); theEdges.push_back(edgeID);
} }
Ex.Next(); Ex.Next();
} }
@ -1718,19 +1755,21 @@ GEOMImpl_IAdvancedOperations::MakePipeTShapeChamferWithPosition(double theR1, do
aListRes.Trunc(aListRes.Length() - 2); aListRes.Trunc(aListRes.Length() - 2);
//Make a Python command //Make a Python command
GEOM::TPythonDump(aFunction) << "[" << aShape << ", " << aListRes.ToCString() GEOM::TPythonDump(aFunction)
<< "] = geompy.MakePipeTShapeChamfer(" << theR1 << ", " << theW1 << ", " << theL1 << ", " << theR2 << "[" << aShape << ", " << aListRes.ToCString()
<< ", " << theW2 << ", " << theL2 << ", " << theH << ", " << theW << ", " << theHexMesh << ", " << "] = geompy.MakePipeTShapeChamfer(" << theR1 << ", " << theW1 << ", " << theL1 << ", " << theR2
<< theP1 << ", " << theP2 << ", " << theP3 << ")"; << ", " << theW2 << ", " << theL2 << ", " << theH << ", " << theW << ", " << theHexMesh << ", "
<< theP1 << ", " << theP2 << ", " << theP3 << ")";
} }
/* /*
* Get the groups: END * Get the groups: END
*/ */
else { else {
//Make a Python command //Make a Python command
GEOM::TPythonDump(aFunction) << "[" << aShape << "] = geompy.MakePipeTShapeChamfer(" << theR1 << ", " << theW1 GEOM::TPythonDump(aFunction)
<< ", " << theL1 << ", " << theR2 << ", " << theW2 << ", " << theL2 << ", " << theH << ", " << theW << "[" << aShape << "] = geompy.MakePipeTShapeChamfer(" << theR1 << ", " << theW1
<< ", " << theHexMesh << ", " << theP1 << ", " << theP2 << ", " << theP3 << ")"; << ", " << theL1 << ", " << theR2 << ", " << theW2 << ", " << theL2 << ", " << theH << ", " << theW
<< ", " << theHexMesh << ", " << theP1 << ", " << theP2 << ", " << theP3 << ")";
} }
SetErrorCode(OK); SetErrorCode(OK);
@ -1758,8 +1797,8 @@ GEOMImpl_IAdvancedOperations::MakePipeTShapeChamferWithPosition(double theR1, do
//============================================================================= //=============================================================================
Handle(TColStd_HSequenceOfTransient) Handle(TColStd_HSequenceOfTransient)
GEOMImpl_IAdvancedOperations::MakePipeTShapeFillet(double theR1, double theW1, double theL1, GEOMImpl_IAdvancedOperations::MakePipeTShapeFillet(double theR1, double theW1, double theL1,
double theR2, double theW2, double theL2, double theR2, double theW2, double theL2,
double theRF, bool theHexMesh) double theRF, bool theHexMesh)
{ {
SetErrorCode(KO); SetErrorCode(KO);
//Add a new object //Add a new object
@ -1813,7 +1852,8 @@ GEOMImpl_IAdvancedOperations::MakePipeTShapeFillet(double theR1, double theW1, d
box_e = myTransformOperations->TranslateDXDYDZ(box_e, -(theR2+theW2), -(theR2+theW2), 0); box_e = myTransformOperations->TranslateDXDYDZ(box_e, -(theR2+theW2), -(theR2+theW2), 0);
box_e->GetLastFunction()->SetDescription(""); box_e->GetLastFunction()->SetDescription("");
Handle(TColStd_HSequenceOfInteger) edges_e = myShapesOperations->GetShapesOnBoxIDs(box_e, aShape, TopAbs_EDGE, GEOMAlgo_ST_IN); Handle(TColStd_HSequenceOfInteger) edges_e =
myShapesOperations->GetShapesOnBoxIDs(box_e, aShape, TopAbs_EDGE, GEOMAlgo_ST_IN);
box_e->GetLastFunction()->SetDescription(""); box_e->GetLastFunction()->SetDescription("");
if (edges_e.IsNull() || edges_e->Length() == 0) { if (edges_e.IsNull() || edges_e->Length() == 0) {
@ -1829,8 +1869,8 @@ GEOMImpl_IAdvancedOperations::MakePipeTShapeFillet(double theR1, double theW1, d
while (Ex.More()) { while (Ex.More()) {
gp_Pnt aPt = BRep_Tool::Pnt(TopoDS::Vertex(Ex.Current())); gp_Pnt aPt = BRep_Tool::Pnt(TopoDS::Vertex(Ex.Current()));
if (Abs(aPt.Z() - (theR1+theW1)) <= Precision::Confusion()) { if (Abs(aPt.Z() - (theR1+theW1)) <= Precision::Confusion()) {
nbEdgesInFillet ++; nbEdgesInFillet ++;
theEdges.push_back(edgeID); theEdges.push_back(edgeID);
} }
Ex.Next(); Ex.Next();
} }
@ -1848,7 +1888,7 @@ GEOMImpl_IAdvancedOperations::MakePipeTShapeFillet(double theR1, double theW1, d
return NULL; return NULL;
} }
if (aFillet.IsNull()) { if (aFillet.IsNull()) {
// SetErrorCode("Fillet can not be computed on the given shape with the given parameters"); //SetErrorCode("Fillet can not be computed on the given shape with the given parameters");
SetErrorCode(myLocalOperations->GetErrorCode()); SetErrorCode(myLocalOperations->GetErrorCode());
return NULL; return NULL;
} }
@ -1858,6 +1898,15 @@ GEOMImpl_IAdvancedOperations::MakePipeTShapeFillet(double theR1, double theW1, d
aFunction->SetValue(aFilletShape); aFunction->SetValue(aFilletShape);
// END of fillet // END of fillet
// BEGIN: Limit tolerances (debug)
GEOMImpl_IHealingOperations myHealingOperations (GetEngine(), GetDocID());
Handle(GEOM_Object) aCorr1 = myHealingOperations.LimitTolerance(aShape, 1e-07);
TopoDS_Shape aCorr1Shape = aCorr1->GetValue();
aShape->GetLastFunction()->SetValue(aCorr1Shape);
aCorr1->GetLastFunction()->SetDescription("");
// END: Limit tolerances (debug)
if (theHexMesh) { if (theHexMesh) {
if (!MakePipeTShapePartition(aShape, theR1, theW1, theL1, theR2, theW2, theL2, 0, 0, theRF, false)) if (!MakePipeTShapePartition(aShape, theR1, theW1, theL1, theR2, theW2, theL2, 0, 0, theRF, false))
return NULL; return NULL;
@ -1898,25 +1947,25 @@ GEOMImpl_IAdvancedOperations::MakePipeTShapeFillet(double theR1, double theW1, d
aListRes.Trunc(aListRes.Length() - 2); aListRes.Trunc(aListRes.Length() - 2);
//Make a Python command //Make a Python command
GEOM::TPythonDump(aFunction) << "[" << aShape << ", " << aListRes.ToCString() GEOM::TPythonDump(aFunction)
<< "] = geompy.MakePipeTShapeFillet(" << theR1 << ", " << theW1 << ", " << theL1 << ", " << theR2 << "[" << aShape << ", " << aListRes.ToCString()
<< ", " << theW2 << ", " << theL2 << ", " << theRF << ", " << theHexMesh << ")"; << "] = geompy.MakePipeTShapeFillet(" << theR1 << ", " << theW1 << ", " << theL1 << ", " << theR2
<< ", " << theW2 << ", " << theL2 << ", " << theRF << ", " << theHexMesh << ")";
} }
/* /*
* Get the groups: END * Get the groups: END
*/ */
else { else {
//Make a Python command //Make a Python command
GEOM::TPythonDump(aFunction) << "[" << aShape << "] = geompy.MakePipeTShapeFillet(" << theR1 << ", " << theW1 GEOM::TPythonDump(aFunction)
<< ", " << theL1 << ", " << theR2 << ", " << theW2 << ", " << theL2 << ", " << theRF << ", " << "[" << aShape << "] = geompy.MakePipeTShapeFillet(" << theR1 << ", " << theW1
<< theHexMesh << ")"; << ", " << theL1 << ", " << theR2 << ", " << theW2 << ", " << theL2 << ", " << theRF << ", "
<< theHexMesh << ")";
} }
SetErrorCode(OK); SetErrorCode(OK);
return aSeq; return aSeq;
} }
//============================================================================= //=============================================================================
@ -1943,11 +1992,11 @@ GEOMImpl_IAdvancedOperations::MakePipeTShapeFillet(double theR1, double theW1, d
//============================================================================= //=============================================================================
Handle(TColStd_HSequenceOfTransient) Handle(TColStd_HSequenceOfTransient)
GEOMImpl_IAdvancedOperations::MakePipeTShapeFilletWithPosition(double theR1, double theW1, double theL1, GEOMImpl_IAdvancedOperations::MakePipeTShapeFilletWithPosition(double theR1, double theW1, double theL1,
double theR2, double theW2, double theL2, double theR2, double theW2, double theL2,
double theRF, bool theHexMesh, double theRF, bool theHexMesh,
Handle(GEOM_Object) theP1, Handle(GEOM_Object) theP1,
Handle(GEOM_Object) theP2, Handle(GEOM_Object) theP2,
Handle(GEOM_Object) theP3) Handle(GEOM_Object) theP3)
{ {
SetErrorCode(KO); SetErrorCode(KO);
//Add a new object //Add a new object
@ -2006,7 +2055,8 @@ GEOMImpl_IAdvancedOperations::MakePipeTShapeFilletWithPosition(double theR1, dou
box_e = myTransformOperations->TranslateDXDYDZ(box_e, -(theR2+theW2), -(theR2+theW2), 0); box_e = myTransformOperations->TranslateDXDYDZ(box_e, -(theR2+theW2), -(theR2+theW2), 0);
box_e->GetLastFunction()->SetDescription(""); box_e->GetLastFunction()->SetDescription("");
Handle(TColStd_HSequenceOfInteger) edges_e = myShapesOperations->GetShapesOnBoxIDs(box_e, aShape, TopAbs_EDGE, GEOMAlgo_ST_IN); Handle(TColStd_HSequenceOfInteger) edges_e =
myShapesOperations->GetShapesOnBoxIDs(box_e, aShape, TopAbs_EDGE, GEOMAlgo_ST_IN);
box_e->GetLastFunction()->SetDescription(""); box_e->GetLastFunction()->SetDescription("");
if (edges_e.IsNull() || edges_e->Length() == 0) { if (edges_e.IsNull() || edges_e->Length() == 0) {
@ -2022,8 +2072,8 @@ GEOMImpl_IAdvancedOperations::MakePipeTShapeFilletWithPosition(double theR1, dou
while (Ex.More()) { while (Ex.More()) {
gp_Pnt aPt = BRep_Tool::Pnt(TopoDS::Vertex(Ex.Current())); gp_Pnt aPt = BRep_Tool::Pnt(TopoDS::Vertex(Ex.Current()));
if (Abs(aPt.Z() - (theR1+theW1)) <= Precision::Confusion()) { if (Abs(aPt.Z() - (theR1+theW1)) <= Precision::Confusion()) {
nbEdgesInFillet ++; nbEdgesInFillet ++;
theEdges.push_back(edgeID); theEdges.push_back(edgeID);
} }
Ex.Next(); Ex.Next();
} }
@ -2097,19 +2147,21 @@ GEOMImpl_IAdvancedOperations::MakePipeTShapeFilletWithPosition(double theR1, dou
aListRes.Trunc(aListRes.Length() - 2); aListRes.Trunc(aListRes.Length() - 2);
//Make a Python command //Make a Python command
GEOM::TPythonDump(aFunction) << "[" << aShape << ", " << aListRes.ToCString() GEOM::TPythonDump(aFunction)
<< "] = geompy.MakePipeTShapeFillet(" << theR1 << ", " << theW1 << ", " << theL1 << ", " << theR2 << "[" << aShape << ", " << aListRes.ToCString()
<< ", " << theW2 << ", " << theL2 << ", " << theRF << ", " << theHexMesh << ", " << theP1 << ", " << "] = geompy.MakePipeTShapeFillet(" << theR1 << ", " << theW1 << ", " << theL1 << ", " << theR2
<< theP2 << ", " << theP3 << ")"; << ", " << theW2 << ", " << theL2 << ", " << theRF << ", " << theHexMesh << ", " << theP1 << ", "
<< theP2 << ", " << theP3 << ")";
} }
/* /*
* Get the groups: END * Get the groups: END
*/ */
else { else {
//Make a Python command //Make a Python command
GEOM::TPythonDump(aFunction) << "[" << aShape << "] = geompy.MakePipeTShapeFillet(" << theR1 << ", " << theW1 GEOM::TPythonDump(aFunction)
<< ", " << theL1 << ", " << theR2 << ", " << theW2 << ", " << theL2 << ", " << theRF << ", " << "[" << aShape << "] = geompy.MakePipeTShapeFillet(" << theR1 << ", " << theW1
<< theHexMesh << ", " << theP1 << ", " << theP2 << ", " << theP3 << ")"; << ", " << theL1 << ", " << theR2 << ", " << theW2 << ", " << theL2 << ", " << theRF << ", "
<< theHexMesh << ", " << theP1 << ", " << theP2 << ", " << theP3 << ")";
} }
SetErrorCode(OK); SetErrorCode(OK);