1 // Copyright (C) 2007-2014 CEA/DEN, EDF R&D, OPEN CASCADE
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // Lesser General Public License for more details.
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 #include "AdvancedEngine_PipeTShapeDriver.hxx"
21 #include "AdvancedEngine_IPipeTShape.hxx"
22 #include "AdvancedEngine_Types.hxx"
23 #include "AdvancedEngine_IOperations.hxx"
25 #include "GEOMImpl_Block6Explorer.hxx"
26 #include "GEOM_Function.hxx"
27 #include "GEOM_IOperations.hxx"
28 #include "GEOMUtils.hxx"
29 #include "GEOMAlgo_FinderShapeOn1.hxx"
30 #include "GEOMAlgo_FinderShapeOn2.hxx"
31 #include "GEOMAlgo_ClsfBox.hxx"
32 #include "GEOMAlgo_Splitter.hxx"
34 #include "Geom_CylindricalSurface.hxx"
40 #include <gp_Trsf.hxx>
41 #include <TFunction_Logbook.hxx>
42 #include <StdFail_NotDone.hxx>
43 #include <BRepPrimAPI_MakeCone.hxx>
44 #include <BRepPrimAPI_MakeCylinder.hxx>
45 #include <BRepAlgoAPI_Fuse.hxx>
46 #include <BRepAlgoAPI_Cut.hxx>
47 #include <BRepPrimAPI_MakeBox.hxx>
48 #include <BRepBuilderAPI_MakeEdge.hxx>
49 #include <BRepBuilderAPI_MakeFace.hxx>
50 #include <BRepBuilderAPI_MakeWire.hxx>
51 #include <BRepBuilderAPI_Transform.hxx>
52 #include <BRepFilletAPI_MakeFillet.hxx>
53 #include <BRepFilletAPI_MakeChamfer.hxx>
54 #include <BRep_Builder.hxx>
55 #include <TopoDS_Compound.hxx>
57 #include <TopExp_Explorer.hxx>
58 #include <BRep_Tool.hxx>
59 #include <BRepTools.hxx>
61 #include <TopTools_IndexedMapOfShape.hxx>
62 #include <TopTools_ListIteratorOfListOfShape.hxx>
66 // Undefine below macro to enable workaround about problem with wrong
67 // tolerances of intersection curves in MakePipeTShape and MakeQuarterPipeTShape
68 // VSR 30/12/2014: macro enabled
69 #define FIX_CURVES_TOLERANCES
71 //=======================================================================
74 //=======================================================================
75 const Standard_GUID& AdvancedEngine_PipeTShapeDriver::GetID()
77 static Standard_GUID aGUID("1C3A0F3F-729D-4E83-8232-78E74FC5637C");
81 //=======================================================================
82 //function : AdvancedEngine_PipeTShapeDriver
84 //=======================================================================
85 AdvancedEngine_PipeTShapeDriver::AdvancedEngine_PipeTShapeDriver()
89 //=======================================================================
90 //function : getShapesOnBoxIDs
92 * \brief Find IDs of sub-shapes complying with given status about surface
93 * \param theBox - the box to check state of sub-shapes against
94 * \param theShape - the shape to explore
95 * \param theShapeType - type of sub-shape of theShape
96 * \param theState - required state
97 * \retval Handle(TColStd_HSequenceOfInteger) - IDs of found sub-shapes
99 //=======================================================================
100 Handle(TColStd_HSequenceOfInteger)
101 AdvancedEngine_PipeTShapeDriver::GetShapesOnBoxIDs(const TopoDS_Shape& aBox,
102 const TopoDS_Shape& aShape,
103 const Standard_Integer theShapeType,
104 GEOMAlgo_State theState) const
106 Handle(TColStd_HSequenceOfInteger) aSeqOfIDs;
108 // Check presence of triangulation, build if need
109 if (!GEOMUtils::CheckTriangulation(aShape)) {
110 StdFail_NotDone::Raise("Cannot build triangulation on the shape");
115 GEOMAlgo_FinderShapeOn2 aFinder;
116 Standard_Real aTol = 0.0001; // default value
118 Handle(GEOMAlgo_ClsfBox) aClsfBox = new GEOMAlgo_ClsfBox;
119 aClsfBox->SetBox(aBox);
121 aFinder.SetShape(aShape);
122 aFinder.SetTolerance(aTol);
123 aFinder.SetClsf(aClsfBox);
124 aFinder.SetShapeType( (TopAbs_ShapeEnum)theShapeType );
125 aFinder.SetState(theState);
128 // Interprete results
129 Standard_Integer iErr = aFinder.ErrorStatus();
130 // the detailed description of error codes is in GEOMAlgo_FinderShapeOn1.cxx
132 TCollection_AsciiString aMsg (" iErr : ");
133 aMsg += TCollection_AsciiString(iErr);
134 StdFail_NotDone::Raise(aMsg.ToCString());
139 const TopTools_ListOfShape& listSS = aFinder.Shapes(); // the result
141 if (listSS.Extent() < 1) {
142 StdFail_NotDone::Raise(NOT_FOUND_ANY); // NPAL18017
146 // Fill sequence of object IDs
147 aSeqOfIDs = new TColStd_HSequenceOfInteger;
149 TopTools_IndexedMapOfShape anIndices;
150 TopExp::MapShapes(aShape, anIndices);
152 TopTools_ListIteratorOfListOfShape itSub (listSS);
153 for (int index = 1; itSub.More(); itSub.Next(), ++index) {
154 int id = anIndices.FindIndex(itSub.Value());
155 // std::cerr << "Shape with ID " << id << " found" << std::endl;
156 aSeqOfIDs->Append(id);
162 //=======================================================================
163 //function : GetShapesOnSurfaceIDs
165 * \brief Find IDs of sub-shapes complying with given status about surface
166 * \param theSurface - the surface to check state of sub-shapes against
167 * \param theShape - the shape to explore
168 * \param theShapeType - type of sub-shape of theShape
169 * \param theState - required state
170 * \retval Handle(TColStd_HSequenceOfInteger) - IDs of found sub-shapes
172 //=======================================================================
173 Handle(TColStd_HSequenceOfInteger)
174 AdvancedEngine_PipeTShapeDriver::GetShapesOnSurfaceIDs(const Handle(Geom_Surface)& theSurface,
175 const TopoDS_Shape& theShape,
176 TopAbs_ShapeEnum theShapeType,
177 GEOMAlgo_State theState) const
179 Handle(TColStd_HSequenceOfInteger) aSeqOfIDs;
181 // Check presence of triangulation, build if need
182 if (!GEOMUtils::CheckTriangulation(theShape)) {
183 StdFail_NotDone::Raise("Cannot build triangulation on the shape");
188 GEOMAlgo_FinderShapeOn1 aFinder;
189 Standard_Real aTol = 1e-6;
191 aFinder.SetShape(theShape);
192 aFinder.SetTolerance(aTol);
193 aFinder.SetSurface(theSurface);
194 aFinder.SetShapeType(theShapeType);
195 aFinder.SetState(theState);
197 // Sets the minimal number of inner points for the faces that do not have own
198 // inner points at all (for e.g. rectangular planar faces have just 2 triangles).
200 aFinder.SetNbPntsMin(3);
201 // Sets the maximal number of inner points for edges or faces.
202 // It is usefull for the cases when this number is very big (e.g =2000) to improve
203 // the performance. If this value =0, all inner points will be taken into account.
205 aFinder.SetNbPntsMax(0);
209 // Interprete results
210 Standard_Integer iErr = aFinder.ErrorStatus();
211 // the detailed description of error codes is in GEOMAlgo_FinderShapeOn1.cxx
213 // MESSAGE(" iErr : " << iErr);
214 TCollection_AsciiString aMsg (" iErr : ");
215 aMsg += TCollection_AsciiString(iErr);
216 StdFail_NotDone::Raise(aMsg.ToCString());
219 // Standard_Integer iWrn = aFinder.WarningStatus();
220 // the detailed description of warning codes is in GEOMAlgo_FinderShapeOn1.cxx
222 // MESSAGE(" *** iWrn : " << iWrn);
225 const TopTools_ListOfShape& listSS = aFinder.Shapes(); // the result
227 if (listSS.Extent() < 1) {
228 //StdFail_NotDone::Raise("Not a single sub-shape of the requested type found on the given surface");
229 StdFail_NotDone::Raise(NOT_FOUND_ANY); // NPAL18017
233 // Fill sequence of object IDs
234 aSeqOfIDs = new TColStd_HSequenceOfInteger;
236 TopTools_IndexedMapOfShape anIndices;
237 TopExp::MapShapes(theShape, anIndices);
239 TopTools_ListIteratorOfListOfShape itSub (listSS);
240 for (int index = 1; itSub.More(); itSub.Next(), ++index) {
241 int id = anIndices.FindIndex(itSub.Value());
242 aSeqOfIDs->Append(id);
248 //=======================================================================
249 //function : GetCommonShapesOnCylinders
250 //purpose : return the common shapes between 2 cylindrical surfaces
252 //=======================================================================
253 void AdvancedEngine_PipeTShapeDriver::GetCommonShapesOnCylinders(const TopoDS_Shape& theShape,
254 TopAbs_ShapeEnum theShapeType,
257 Handle(TopTools_HSequenceOfShape)& commonShapes) const
259 gp_Pnt aP0 (0, 0, 0);
260 gp_Vec aVX = gp::DX(), aVZ = gp::DZ();
261 gp_Ax3 anAxis1 (aP0, aVX, aVZ), anAxis2 (aP0, aVZ, aVX);
263 TopTools_IndexedMapOfShape aMapOfShapes;
264 aMapOfShapes.Clear();
265 TopExp::MapShapes(theShape, aMapOfShapes);
267 commonShapes->Clear();
272 // Create a cylinder surface
273 Handle(Geom_Surface) aC1Ext = new Geom_CylindricalSurface(anAxis1, r1);
274 if ( aC1Ext.IsNull() )
275 StdFail_NotDone::Raise("Couldn't build main cylindrical surface");
277 Handle(TColStd_HSequenceOfInteger) aSeqExt1 = GetShapesOnSurfaceIDs( aC1Ext, theShape, theShapeType, GEOMAlgo_ST_ON );
278 // Create a cylinder surface
279 Handle(Geom_Surface) aC2Ext = new Geom_CylindricalSurface(anAxis2, r2);
280 if ( aC2Ext.IsNull() )
281 StdFail_NotDone::Raise("Couldn't build incident cylindrical surface");
283 Handle(TColStd_HSequenceOfInteger) aSeqExt2 = GetShapesOnSurfaceIDs( aC2Ext, theShape, theShapeType, GEOMAlgo_ST_ON );
284 // # Recherche (dans le quart de Te) de l'arete d'intersection des 2 cylindres
285 // # Search in theShape for common shape of type theShapeType on the intersection of 2 pipes
287 for (int i=1; i<=aSeqExt2->Length();i++) {
288 // std::cerr << "aSeqExt2->Value(i): " << aSeqExt2->Value(i) << std::endl;
289 for (int j=1; j<=aSeqExt1->Length();j++) {
290 // std::cerr << "aSeqExt1->Value(j): " << aSeqExt1->Value(j) << std::endl;
291 if (aSeqExt1->Value(j) == aSeqExt2->Value(i)) {
292 myID = aSeqExt1->Value(j);
293 commonShapes->Append(aMapOfShapes.FindKey(myID));
299 StdFail_NotDone::Raise("Common shapes couldn't be found");
302 //=======================================================================
303 //function : MakePipeTShape
305 //=======================================================================
306 TopoDS_Shape AdvancedEngine_PipeTShapeDriver::MakePipeTShape (const double r1, const double w1, const double l1,
307 const double r2, const double w2, const double l2) const
309 double r1Ext = r1 + w1;
310 double r2Ext = r2 + w2;
312 gp_Pnt aP0 (0, 0, 0);
313 gp_Pnt aP1 (-l1, 0, 0);
314 gp_Vec aVX = gp::DX(), aVY = gp::DY(), aVZ = gp::DZ();
315 gp_Ax2 anAxes1 (aP1, aVX, aVZ);
316 gp_Ax2 anAxes2 (aP0, aVZ, aVX);
318 // Build the initial pipes
319 BRepPrimAPI_MakeCylinder C1Int (anAxes1, r1, Abs(2 * l1));
320 BRepPrimAPI_MakeCylinder C1Ext (anAxes1, r1Ext, Abs(2 * l1));
321 BRepPrimAPI_MakeCylinder C2Int (anAxes2, r2, Abs(l2));
322 BRepPrimAPI_MakeCylinder C2Ext (anAxes2, r2Ext, Abs(l2));
327 if (!C1Int.IsDone() || !C1Ext.IsDone() || !C2Int.IsDone() || !C2Ext.IsDone()) {
328 StdFail_NotDone::Raise("Cannot build cylinders");
332 BRepAlgoAPI_Fuse fuse1 (C1Ext.Shape(), C2Ext.Shape());
333 if (!fuse1.IsDone()) {
334 StdFail_NotDone::Raise("Cannot fuse cylinders");
337 // Remove small radius main pipe
338 BRepAlgoAPI_Cut cut1 (fuse1.Shape(), C1Int.Shape());
339 if (!cut1.IsDone()) {
340 StdFail_NotDone::Raise("Coudn't cut cylinders");
343 // Remove small radius incident pipe => Te
344 BRepAlgoAPI_Cut Te (cut1.Shape(), C2Int.Shape());
346 StdFail_NotDone::Raise("Coudn't cut cylinders");
349 TopoDS_Shape aShape = Te.Shape();
351 // VSR: 30/12/2014: temporary workaround about intersection curves problem
352 #ifdef FIX_CURVES_TOLERANCES
353 GEOMUtils::FixShapeCurves(aShape);
359 //=======================================================================
360 //function : MakeQuarterPipeTShape
362 //=======================================================================
363 TopoDS_Shape AdvancedEngine_PipeTShapeDriver::MakeQuarterPipeTShape (const double r1, const double w1, const double l1,
364 const double r2, const double w2, const double l2) const
366 TopoDS_Shape Te = MakePipeTShape(r1, w1, l1, r2, w2, l2);
368 StdFail_NotDone::Raise("Couldn't build Pipe TShape");
370 // Get a quarter of shape => Te2
371 double r1Ext = r1 + w1;
372 BRepPrimAPI_MakeBox box1 (gp_Pnt(0, -2*r1Ext, -2*r1Ext), gp_Pnt( Abs(2 * l1), 2*r1Ext, Abs(2*l2)));
373 BRepPrimAPI_MakeBox box2 (gp_Pnt(0, 2*r1Ext, -2*r1Ext), gp_Pnt(-Abs(2 * l1), 0, Abs(2*l2)));
376 if (!box1.IsDone() || !box2.IsDone()) {
377 StdFail_NotDone::Raise("Couldn't build boxes");
379 BRepAlgoAPI_Cut cut3 (Te, box1.Shape());
380 if (!cut3.IsDone()) {
381 StdFail_NotDone::Raise("Couldn't cut Pipe Tshape with box");
383 BRepAlgoAPI_Cut Te4 (cut3.Shape(), box2.Shape());
385 StdFail_NotDone::Raise("Couldn't cut Pipe Tshape with box");
388 TopoDS_Shape aShape = Te4.Shape();
390 // VSR: 30/12/2014: temporary workaround about intersection curves problem
391 #ifdef FIX_CURVES_TOLERANCES
392 GEOMUtils::FixShapeCurves(aShape);
398 //=======================================================================
401 //=======================================================================
402 Standard_Integer AdvancedEngine_PipeTShapeDriver::Execute (TFunction_Logbook& log) const
404 if (Label().IsNull()) return 0;
405 Handle(GEOM_Function) aFunction = GEOM_Function::GetFunction(Label());
407 AdvancedEngine_IPipeTShape aData (aFunction);
408 Standard_Integer aType = aFunction->GetType();
410 TopoDS_Shape aShape, Te4, Te4Part;
411 //TopoDS_Edge arete_intersect_int;
412 //Handle(TopTools_HSequenceOfShape) edges_e = new TopTools_HSequenceOfShape;
413 Handle(TColStd_HSequenceOfInteger) edges_e;
414 //Handle(TopTools_HSequenceOfShape) edges_i = new TopTools_HSequenceOfShape;
415 //gp_Pnt aP0 (0, 0, 0);
416 //gp_Vec aVX = gp::DX(), aVY = gp::DY(), aVZ = gp::DZ();
417 bool hexMesh = (bool) aData.GetHexMesh();
420 //double aSize = 2*(aData.GetL1() + aData.GetL2());
421 double epsilon = Precision::Approximation();
422 double aR1Ext = aData.GetR1() + aData.GetW1();
423 double aR2Ext = aData.GetR2() + aData.GetW2();
425 if (aData.GetR2() > aData.GetR1() + epsilon) {
426 StdFail_NotDone::Raise("TShape cannot be computed if R2 > R1");
429 if (aR2Ext > aR1Ext + epsilon) {
430 StdFail_NotDone::Raise("TShape cannot be computed if R2+W2 > R1+W1");
433 // external radius are equal
434 if (fabs(aR2Ext - aR1Ext) < epsilon) {
435 if (aType == TSHAPE_CHAMFER)
436 StdFail_NotDone::Raise("TShape with chamfer cannot be computed if R2+W2 = R1+W1");
437 if (aType == TSHAPE_FILLET)
438 StdFail_NotDone::Raise("TShape with fillet cannot be computed if R2+W2 = R1+W1");
439 // internal radius are different => not possible
440 if (fabs(aData.GetR2() - aData.GetR1()) > epsilon) {
441 StdFail_NotDone::Raise("TShape cannot be computed if R2+W2 = R1+W1 and R2 != R1");
445 if (aR1Ext >= aData.GetL2() + epsilon) {
446 StdFail_NotDone::Raise("TShape cannot be computed if R1+W1 >= L2");
448 if (aR2Ext >= aData.GetL1() + epsilon) {
449 StdFail_NotDone::Raise("TShape cannot be computed if R2+W2 >= L1");
452 if (aType == TSHAPE_CHAMFER) {
453 if (aData.GetH() >= (aData.GetL2() - aR1Ext + epsilon)) {
454 StdFail_NotDone::Raise("TShape cannot be computed: height of chamfer is too high");
457 if (aData.GetW() >= (aData.GetL1() - aR2Ext + epsilon))
458 StdFail_NotDone::Raise("TShape cannot be computed: width of chamfer is too high");
461 if (aType == TSHAPE_FILLET) {
462 if (aData.GetRF() >= (aData.GetL2() - aR1Ext + epsilon) ||
463 aData.GetRF() >= (aData.GetL1() - aR2Ext + epsilon))
464 StdFail_NotDone::Raise("TShape cannot be computed: radius of fillet is too high");
468 // Create a quarter of a basic T-Shape pipe
469 //std::cerr << "Create a quarter of a basic T-Shape pipe" << std::endl;
470 Te4 = MakeQuarterPipeTShape(aData.GetR1(), aData.GetW1(), aData.GetL1(),
471 aData.GetR2(), aData.GetW2(), aData.GetL2());
474 // No need to cut pipe t-shape
475 //std::cerr << "Create a basic T-Shape pipe" << std::endl;
476 Te4 = MakePipeTShape(aData.GetR1(), aData.GetW1(), aData.GetL1(),
477 aData.GetR2(), aData.GetW2(), aData.GetL2());
481 if (aType == TSHAPE_BASIC) {
483 // aShape = MakeQuarterPipeTShape(aData.GetR1(), aData.GetW1(), aData.GetL1(),
484 // aData.GetR2(), aData.GetW2(), aData.GetL2());
486 else if (aType == TSHAPE_CHAMFER) {
487 // TShape with chamfer
489 // TopoDS_Compound CC;
490 // BB.MakeCompound(CC);
491 // Create chamfer on the edges edges_e
492 BRepFilletAPI_MakeChamfer chamfer (Te4);
493 TopTools_IndexedMapOfShape anEdgesIndices;
494 TopExp::MapShapes(Te4, anEdgesIndices);
498 BRepPrimAPI_MakeBox aBox (gp_Pnt(0,0,0),gp_Pnt(-aR2Ext, -aR2Ext, aR1Ext));
500 if (!aBox.IsDone()) {
501 StdFail_NotDone::Raise("Couldn't build box");
503 theBox = aBox.Shape();
506 BRepPrimAPI_MakeBox aBox (gp_Pnt(aR2Ext,aR2Ext,0),gp_Pnt(-aR2Ext, -aR2Ext, aR1Ext));
508 if (!aBox.IsDone()) {
509 StdFail_NotDone::Raise("Couldn't build box");
511 theBox = aBox.Shape();
513 Handle(TColStd_HSequenceOfInteger) edges_e = new TColStd_HSequenceOfInteger;
514 edges_e = GetShapesOnBoxIDs(theBox, Te4, TopAbs_EDGE, GEOMAlgo_ST_IN);
515 if (edges_e.IsNull() || edges_e->Length() == 0) {
516 StdFail_NotDone::Raise("Common edges not found");
519 TopTools_IndexedDataMapOfShapeListOfShape M;
520 GEOMImpl_Block6Explorer::MapShapesAndAncestors(Te4, TopAbs_EDGE, TopAbs_FACE, M);
521 // std::cerr << "Number of IDs: " << edges_e->Length() << std::endl;
522 int nbEdgesInChamfer = 0;
523 for (int i=1;i<=edges_e->Length();i++) {
524 // std::cerr << "Get Edge with ID #" << i << std::endl;
525 int theId = edges_e->Value(i);
526 // std::cerr << "ID #" << i << "= " << theId << std::endl;
527 // std::cerr << "Search for edge in shape" << std::endl;
528 TopoDS_Edge theEdge = TopoDS::Edge(anEdgesIndices.FindKey(theId));
529 // std::cerr << "Found" << std::endl;
530 // std::cerr << "Keep only edges with a vertex on (x, x, re1)" << std::endl;
531 TopExp_Explorer ExVertices;
532 for (ExVertices.Init(theEdge,TopAbs_VERTEX); ExVertices.More(); ExVertices.Next()) {
533 gp_Pnt aPt = BRep_Tool::Pnt(TopoDS::Vertex(ExVertices.Current()));
534 if (aPt.Z() - aR1Ext <= epsilon) {
535 // std::cerr << "aPt.Z() = aR1Ext => keep this edge" << std::endl;
537 const TopTools_ListOfShape& aFL = M.FindFromKey(theEdge);
538 TopoDS_Face F = TopoDS::Face( aFL.First() );
540 chamfer.Add(aData.GetH(), aData.GetW(), theEdge, F);
542 chamfer.Add(aData.GetW(), aData.GetH(), theEdge, F);
546 // std::cerr << "Test if hexMesh: ";
547 if (hexMesh && nbEdgesInChamfer == 1) {
548 // std::cerr << "Yes => stop after 1 edge" << std::endl;
551 // std::cerr << "No => continue for other edges" << std::endl;
552 // BB.Add(CC, edges_e->Value(i));
553 // const TopTools_ListOfShape& aFL = M.FindFromKey(TopoDS::Edge(edges_e->Value(i)));
554 // chamfer.Add(aData.GetW(), aData.GetH(), TopoDS::Edge(edges_e->Value(i)), F);
556 // std::cerr << "Build chamfer with " << nbEdgesInChamfer << " edges" << std::endl;
559 if (!chamfer.IsDone()) {
560 StdFail_NotDone::Raise("Chamfer can not be computed on the given shape with the given parameters");
563 // BB.Add(CC, chamfer.Shape());
566 aShape = chamfer.Shape();
568 else if (aType == TSHAPE_FILLET) {
569 // TShape with fillet
570 // Create fillet on the edge arete_intersect_ext
571 BRepFilletAPI_MakeFillet fill (Te4);
573 TopTools_IndexedMapOfShape anIndices;
574 TopExp::MapShapes(Te4, anIndices);
578 BRepPrimAPI_MakeBox aBox (gp_Pnt(0,0,0),gp_Pnt(-aR2Ext, -aR2Ext, aR1Ext));
580 if (!aBox.IsDone()) {
581 StdFail_NotDone::Raise("Couldn't build box");
583 theBox = aBox.Shape();
586 BRepPrimAPI_MakeBox aBox (gp_Pnt(aR2Ext,aR2Ext,0),gp_Pnt(-aR2Ext, -aR2Ext, aR1Ext));
588 if (!aBox.IsDone()) {
589 StdFail_NotDone::Raise("Couldn't build box");
591 theBox = aBox.Shape();
593 Handle(TColStd_HSequenceOfInteger) edges_e = new TColStd_HSequenceOfInteger;
594 edges_e = GetShapesOnBoxIDs(theBox, Te4, TopAbs_EDGE, GEOMAlgo_ST_IN);
595 if (edges_e.IsNull() || edges_e->Length() == 0) {
596 StdFail_NotDone::Raise("Common edges not found");
599 // fill.Add(TopoDS::Edge(edges_e->Value(1)));
601 for (int i=1;i<=edges_e->Length();i++) {
602 if (hexMesh && (i > 1))
604 TopoDS_Edge theEdge = TopoDS::Edge(anIndices.FindKey(edges_e->Value(i)));
606 // fill.Add(TopoDS::Edge(edges_e->Value(i)));
609 fill.SetRadius(aData.GetRF(), 1, 1);
611 if (!fill.IsDone()) {
612 StdFail_NotDone::Raise("Fillet can't be computed on the given shape with the given radius");
615 aShape = fill.Shape();
618 // other construction modes here
621 if (aShape.IsNull()) return 0;
623 aFunction->SetValue(aShape);
625 log.SetTouched(Label());
630 //================================================================================
632 * \brief Returns a name of creation operation and names and values of creation parameters
634 //================================================================================
636 bool AdvancedEngine_PipeTShapeDriver::
637 GetCreationInformation(std::string& theOperationName,
638 std::vector<GEOM_Param>& theParams)
640 if (Label().IsNull()) return 0;
641 Handle(GEOM_Function) function = GEOM_Function::GetFunction(Label());
643 AdvancedEngine_IPipeTShape aCI( function );
644 Standard_Integer aType = function->GetType();
646 theOperationName = "PIPETSHAPE";
650 AddParam( theParams, "Main radius", aCI.GetR1() );
651 AddParam( theParams, "Main width", aCI.GetW1() );
652 AddParam( theParams, "Main half-length", aCI.GetL1() );
653 AddParam( theParams, "Incident pipe radius", aCI.GetR2() );
654 AddParam( theParams, "Incident pipe width", aCI.GetW2() );
655 AddParam( theParams, "Incident pipe half-length", aCI.GetL2() );
656 AddParam( theParams, "For hex mesh", aCI.GetHexMesh() );
659 AddParam( theParams, "Main radius", aCI.GetR1() );
660 AddParam( theParams, "Main width", aCI.GetW1() );
661 AddParam( theParams, "Main half-length", aCI.GetL1() );
662 AddParam( theParams, "Incident pipe radius", aCI.GetR2() );
663 AddParam( theParams, "Incident pipe width", aCI.GetW2() );
664 AddParam( theParams, "Incident pipe half-length", aCI.GetL2() );
665 AddParam( theParams, "Chamfer height", aCI.GetH() );
666 AddParam( theParams, "Chamfer width", aCI.GetW() );
667 AddParam( theParams, "For hex mesh", aCI.GetHexMesh() );
670 AddParam( theParams, "Main radius", aCI.GetR1() );
671 AddParam( theParams, "Main width", aCI.GetW1() );
672 AddParam( theParams, "Main half-length", aCI.GetL1() );
673 AddParam( theParams, "Incident pipe radius", aCI.GetR2() );
674 AddParam( theParams, "Incident pipe width", aCI.GetW2() );
675 AddParam( theParams, "Incident pipe half-length", aCI.GetL2() );
676 AddParam( theParams, "Fillet radius", aCI.GetRF() );
677 AddParam( theParams, "For hex mesh", aCI.GetHexMesh() );
686 IMPLEMENT_STANDARD_HANDLE (AdvancedEngine_PipeTShapeDriver,GEOM_BaseDriver);
687 IMPLEMENT_STANDARD_RTTIEXT (AdvancedEngine_PipeTShapeDriver,GEOM_BaseDriver);