- edge_e2 = aBasicOperations->MakeLineTwoPnt(ve2, vi2);
- if (edge_e2.IsNull()) {
- SetErrorCode("Edge 2 could not be built");
- return false;
- }
- } catch (Standard_Failure) {
- Handle(Standard_Failure) aFail = Standard_Failure::Caught();
- SetErrorCode(aFail->GetMessageString());
- return false;
- }
-
- edge_e1->GetLastFunction()->SetDescription("");
- edge_e2->GetLastFunction()->SetDescription("");
-
- std::list<Handle(GEOM_Object)> edge_e_elist;
- edge_e_elist.push_back(arete_intersect_int);
- edge_e_elist.push_back(edge_e1);
- edge_e_elist.push_back(Handle(GEOM_Object)::DownCast(edges_e->Value(1)));
- edge_e_elist.push_back(edge_e2);
- wire_t = aShapesOperations->MakeWire(edge_e_elist, 1e-7);
- if (wire_t.IsNull()) {
- SetErrorCode("Impossible to build wire");
- return false;
- }
- wire_t->GetLastFunction()->SetDescription("");
- face_t = aShapesOperations->MakeFace(wire_t, false);
- if (face_t.IsNull()) {
- SetErrorCode("Impossible to build face");
- return false;
- }
- face_t->GetLastFunction()->SetDescription("");
- }
- else {
- Handle(GEOM_Object) P1, P2, P3, P4, P5, P6;
- int idP1, idP2, idP3, idP4;
- int PZX, PZY;
- double ZX=0, ZY=0;
- std::vector<int> LX;
- std::vector<int> LY;
-// Handle(TColStd_HSequenceOfTransient) extremVertices;
- Handle(GEOM_Object) box_e = a3DPrimOperations->MakeBoxDXDYDZ(theVertCylinderRadius, theVertCylinderRadius, theHoriCylinderRadius);
- box_e->GetLastFunction()->SetDescription("");
- box_e = aTransformOperations->TranslateDXDYDZ(box_e, -theVertCylinderRadius, -theVertCylinderRadius, 0);
- box_e->GetLastFunction()->SetDescription("");
-
- aFunction = theShape->GetLastFunction();
- theDesc = aFunction->GetDescription();
- Handle(TColStd_HSequenceOfTransient) extremVertices = aShapesOperations->GetShapesOnBox(box_e, theShape, TopAbs_VERTEX, GEOMAlgo_ST_ONIN);
- // Recover previous description to get rid of Propagate dump
- aFunction->SetDescription(theDesc);
-
-// extremVertices = aShapesOperations->GetShapesOnCylinder(theShape, TopAbs_VERTEX, Vector_Z, theVertCylinderRadius, GEOMAlgo_ST_ONIN);
- if (extremVertices.IsNull() || extremVertices->Length() == 0) {
- std::cerr << "extremVertices.IsNull() || extremVertices->Length() == 0" << std::endl;
- if (theRF == 0)
- SetErrorCode("Vertices on chamfer not found");
- else
- SetErrorCode("Vertices on fillet not found");
- return false;
- }
-
-// std::cerr << "Found " << extremVertices->Length() << " vertices" << std::endl;
- theShapes.push_back(theShape);
- theShapes.push_back(box_e);
- if (extremVertices->Length() != 6) {
-// for (int i=1; i<=extremVertices->Length(); i++){
-// theShapes.push_back(Handle(GEOM_Object)::DownCast(extremVertices->Value(i)));
-// }
-// Handle(GEOM_Object) aCompound = aShapesOperations->MakeCompound(theShapes);
-// TopoDS_Shape aCompoundShape = aCompound->GetValue();
-// theShape->GetLastFunction()->SetValue(aCompoundShape);
- SetErrorCode("Bad number of vertices on chamfer found");
- return false;
- }
-
-// std::cerr << "BEGIN of parsing list of vertices" << std::endl;
- for (int i=1; i<=extremVertices->Length(); i++){
- Handle(GEOM_Object) aV = Handle(GEOM_Object)::DownCast(extremVertices->Value(i));
- aV->GetLastFunction()->SetDescription("");
-// std::cerr << "Vertex #" << i << std::endl;
- gp_Pnt aP = BRep_Tool::Pnt(TopoDS::Vertex(aV->GetValue()));
-// std::cerr << "aP.X() " << aP.X() << std::endl;
-// std::cerr << "aP.Y() " << aP.Y() << std::endl;
-// std::cerr << "aP.Z() " << aP.Z() << std::endl;
-// if (Abs(aP.Z() - theL2) < Precision::Confusion()) {
-// // std::cerr << "Vertex = L2 ==> OUT" << std::endl;
-// continue;
-// }
-// if (aP.Z() < 0) {
-// // std::cerr << "Vertex < 0 ==> OUT" << std::endl;
-// continue;
-// }
-
- if (Abs(aP.X()) <= Precision::Confusion()) {
- if (Abs(aP.Y()) - theR2 > Precision::Confusion()) {
- LX.push_back(i);
- if (aP.Z()-ZX > Precision::Confusion()) {
- ZX = aP.Z();
- PZX = i;
- }
- }
- }
- else {
- if (Abs(aP.X()) - theR2 > Precision::Confusion()) {
- LY.push_back(i);
- if (aP.Z() - ZY > Precision::Confusion()) {
- ZY = aP.Z();
- PZY = i;
- }
- }
- }
- }
-// std::cerr << "END of parsing list of vertices" << std::endl;
-// std::cerr << "LX:";
-// for (int i=0;i<LX.size();i++)
-// std::cerr << " " << LX.at(i);
-// std::cerr << std::endl;
-// std::cerr << "LY:";
-// for (int i=0;i<LY.size();i++)
-// std::cerr << " " << LY.at(i);
-// std::cerr << std::endl;
-// std::cerr << "PZX: " << PZX << std::endl;
-// std::cerr << "PZY: " << PZY << std::endl;
-
- idP2 = PZX;
- idP4 = PZY;
- idP1 = LX.at(0);
- if (LX.at(0) == PZX)
- idP1 = LX.at(1);
- idP3 = LY.at(0);
- if (LY.at(0) == PZY)
- idP3 = LY.at(1);
-
-// std::cerr << "idP1: " << idP1 << std::endl;
-// std::cerr << "idP2: " << idP2 << std::endl;
-// std::cerr << "idP3: " << idP3 << std::endl;
-// std::cerr << "idP4: " << idP4 << std::endl;
-
- P1 = Handle(GEOM_Object)::DownCast(extremVertices->Value(idP1));
- P2 = Handle(GEOM_Object)::DownCast(extremVertices->Value(idP2));
- P3 = Handle(GEOM_Object)::DownCast(extremVertices->Value(idP3));
- P4 = Handle(GEOM_Object)::DownCast(extremVertices->Value(idP4));
-
-// std::cerr << "Building edge 1 in thickness" << std::endl;
- Handle(GEOM_Object) Cote_1 = aBasicOperations->MakeLineTwoPnt(P1, vi1);
- if (Cote_1.IsNull()) {
- SetErrorCode("Impossilbe to build edge in thickness");
- return false;
- }
- Cote_1->GetLastFunction()->SetDescription("");
-
-// std::cerr << "Building edge 2 in thickness" << std::endl;
- Handle(GEOM_Object) Cote_2 = aBasicOperations->MakeLineTwoPnt(vi2, P3);
- if (Cote_2.IsNull()) {
- SetErrorCode("Impossilbe to build edge in thickness");
- return false;
- }
- Cote_2->GetLastFunction()->SetDescription("");
-
- // edge_chan_princ = arete du chanfrein (ou raccord) sur le tuyau principal
- // edge_chan_inc = arete du chanfrein (ou raccord) sur le tuyau incident
-// std::cerr << "Getting chamfer edge on main pipe" << std::endl;
- Handle(GEOM_Object) edge_chan_princ = aBlocksOperations->GetEdge(theShape, P1, P3);
- if (edge_chan_princ.IsNull()) {
- SetErrorCode("Impossilbe to find edge on main pipe");
- return false;
- }
- edge_chan_princ->GetLastFunction()->SetDescription("");
-
-// std::cerr << "Getting chamfer edge on incident pipe" << std::endl;
- Handle(GEOM_Object) edge_chan_inc = aBlocksOperations->GetEdge(theShape, P2, P4);
- if (edge_chan_inc.IsNull()) {
- SetErrorCode("Impossilbe to find edge on incident pipe");
- return false;
- }
- edge_chan_inc->GetLastFunction()->SetDescription("");
-
- std::list<Handle(GEOM_Object)> edgeList1;
- edgeList1.push_back(edge_chan_princ);
- edgeList1.push_back(Cote_1);
- edgeList1.push_back(arete_intersect_int);
- edgeList1.push_back(Cote_2);
-
-// std::cerr << "Creating wire 1" << std::endl;
- wire_t = aShapesOperations->MakeWire(edgeList1, 1e-7);
- if (wire_t.IsNull()) {
- SetErrorCode("Impossible to build wire");
- return false;
- }
- wire_t->GetLastFunction()->SetDescription("");
-
-// std::cerr << "Creating face 1" << std::endl;
- face_t = aShapesOperations->MakeFace(wire_t, false);
- if (face_t.IsNull()) {
- SetErrorCode("Impossible to build face");
- return false;
- }
- face_t->GetLastFunction()->SetDescription("");
- theShapes.push_back(face_t);
-
- gp_Pnt aP2 = BRep_Tool::Pnt(TopoDS::Vertex(P2->GetValue()));
- gp_Pnt aP5 = BRep_Tool::Pnt(TopoDS::Vertex(vi1->GetValue()));
- double deltaZ = aP2.Z() - aP5.Z();
-// std::cerr << "Creating new point from vi1 with deltaZ = " << deltaZ << std::endl;
- Handle(GEOM_Object) P5bis = aTransformOperations->TranslateDXDYDZCopy(vi1, 0, 0, deltaZ);
- if (P5bis.IsNull()) {
- SetErrorCode("Impossible to translate vertex");
- return false;
- }
- P5bis->GetLastFunction()->SetDescription("");
-
- gp_Pnt aP4 = BRep_Tool::Pnt(TopoDS::Vertex(P4->GetValue()));
- gp_Pnt aP6 = BRep_Tool::Pnt(TopoDS::Vertex(vi2->GetValue()));
- deltaZ = aP4.Z() - aP6.Z();
-// std::cerr << "Creating new point from vi2 with deltaZ = " << deltaZ << std::endl;
- Handle(GEOM_Object) P6bis = aTransformOperations->TranslateDXDYDZCopy(vi2, 0, 0, deltaZ);
- if (P6bis.IsNull()) {
- SetErrorCode("Impossible to translate vertex");
- return false;
- }
- P6bis->GetLastFunction()->SetDescription("");
-
-// std::cerr << "Creating new line 1 from 2 previous points" << std::endl;
- Handle(GEOM_Object) Cote_3 = aBasicOperations->MakeLineTwoPnt(P5bis, P2);
- if (Cote_3.IsNull()) {
- SetErrorCode("Impossilbe to build edge in thickness");
- return false;
- }
- Cote_3->GetLastFunction()->SetDescription("");
-
-// std::cerr << "Creating new line 2 from 2 previous points" << std::endl;
- Handle(GEOM_Object) Cote_4 = aBasicOperations->MakeLineTwoPnt(P6bis, P4);
- if (Cote_4.IsNull()) {
- SetErrorCode("Impossilbe to build edge in thickness");
- return false;
- }
- Cote_4->GetLastFunction()->SetDescription("");
-
-// std::cerr << "Creating new line 3 from 2 previous points" << std::endl;
- Handle(GEOM_Object) Cote_5 = aBasicOperations->MakeLineTwoPnt(P5bis, P6bis);
- if (Cote_4.IsNull()) {
- SetErrorCode("Impossilbe to build edge in thickness");
- return false;
- }
- Cote_5->GetLastFunction()->SetDescription("");
-
- std::list<Handle(GEOM_Object)> edgeList2;
- edgeList2.push_back(edge_chan_inc);
- edgeList2.push_back(Cote_3);
- edgeList2.push_back(Cote_5);
- edgeList2.push_back(Cote_4);
-// std::cerr << "Creating wire 2" << std::endl;
- wire_t2 = aShapesOperations->MakeWire(edgeList2, 1e-7);
- if (wire_t2.IsNull()) {
- SetErrorCode("Impossible to build wire");
- return false;
- }
- wire_t2->GetLastFunction()->SetDescription("");
-// std::cerr << "Creating face 2" << std::endl;
- face_t2 = aShapesOperations->MakeFace(wire_t2, false);
- if (face_t2.IsNull()) {
- SetErrorCode("Impossible to build face");
- return false;
- }
- face_t2->GetLastFunction()->SetDescription("");
- theShapes.push_back(face_t2);
- }
-
- // Planes
- Handle(GEOM_Object) aP0 = aBasicOperations->MakePointXYZ(0, 0, 0);
- Handle(GEOM_Object) aVZ = aBasicOperations->MakeVectorDXDYDZ(0, 0, 1);
- Handle(GEOM_Object) aVXZ = aBasicOperations->MakeVectorDXDYDZ(aR1Ext, 0, 0.5*(theL1+theVertCylinderRadius));
- Handle(GEOM_Object) aPlnOZ = aBasicOperations->MakePlanePntVec(aP0, aVZ, aSize);
- Handle(GEOM_Object) aPlnOXZ = aBasicOperations->MakePlanePntVec(aP0, aVXZ, aSize);
- aP0->GetLastFunction()->SetDescription("");
- aVZ->GetLastFunction()->SetDescription("");
- aVXZ->GetLastFunction()->SetDescription("");
- aPlnOZ->GetLastFunction()->SetDescription("");
- aPlnOXZ->GetLastFunction()->SetDescription("");
- theShapes.push_back(aPlnOZ);
- theShapes.push_back(aPlnOXZ);
-
- // Partition
- Handle(GEOM_Object) Part0 = aBooleanOperations->MakeHalfPartition(theShape, face_t);
- if (Part0.IsNull()) {
- std::cerr << "Impossible to build partition between TShape and 1st face" << std::endl;
- SetErrorCode("Impossible to build partition between TShape and 1st face");