1 // Copyright (C) 2007-2015 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_FinderShapeOn2.hxx"
30 #include "GEOMAlgo_ClsfBox.hxx"
31 #include "GEOMAlgo_ClsfSurf.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_FinderShapeOn2.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_FinderShapeOn2 aFinder;
189 Handle(GEOMAlgo_ClsfSurf) aClsfSurf = new GEOMAlgo_ClsfSurf;
190 Standard_Real aTol = 1e-6;
192 aClsfSurf->SetSurface(theSurface);
193 aFinder.SetShape(theShape);
194 aFinder.SetTolerance(aTol);
195 aFinder.SetClsf(aClsfSurf);
196 aFinder.SetShapeType(theShapeType);
197 aFinder.SetState(theState);
199 // Sets the minimal number of inner points for the faces that do not have own
200 // inner points at all (for e.g. rectangular planar faces have just 2 triangles).
202 aFinder.SetNbPntsMin(3);
203 // Sets the maximal number of inner points for edges or faces.
204 // It is usefull for the cases when this number is very big (e.g =2000) to improve
205 // the performance. If this value =0, all inner points will be taken into account.
207 aFinder.SetNbPntsMax(0);
211 // Interprete results
212 Standard_Integer iErr = aFinder.ErrorStatus();
213 // the detailed description of error codes is in GEOMAlgo_FinderShapeOn2.cxx
215 // MESSAGE(" iErr : " << iErr);
216 TCollection_AsciiString aMsg (" iErr : ");
217 aMsg += TCollection_AsciiString(iErr);
218 StdFail_NotDone::Raise(aMsg.ToCString());
221 // Standard_Integer iWrn = aFinder.WarningStatus();
222 // the detailed description of warning codes is in GEOMAlgo_FinderShapeOn2.cxx
224 // MESSAGE(" *** iWrn : " << iWrn);
227 const TopTools_ListOfShape& listSS = aFinder.Shapes(); // the result
229 if (listSS.Extent() < 1) {
230 //StdFail_NotDone::Raise("Not a single sub-shape of the requested type found on the given surface");
231 StdFail_NotDone::Raise(NOT_FOUND_ANY); // NPAL18017
235 // Fill sequence of object IDs
236 aSeqOfIDs = new TColStd_HSequenceOfInteger;
238 TopTools_IndexedMapOfShape anIndices;
239 TopExp::MapShapes(theShape, anIndices);
241 TopTools_ListIteratorOfListOfShape itSub (listSS);
242 for (int index = 1; itSub.More(); itSub.Next(), ++index) {
243 int id = anIndices.FindIndex(itSub.Value());
244 aSeqOfIDs->Append(id);
250 //=======================================================================
251 //function : GetCommonShapesOnCylinders
252 //purpose : return the common shapes between 2 cylindrical surfaces
254 //=======================================================================
255 void AdvancedEngine_PipeTShapeDriver::GetCommonShapesOnCylinders(const TopoDS_Shape& theShape,
256 TopAbs_ShapeEnum theShapeType,
259 Handle(TopTools_HSequenceOfShape)& commonShapes) const
261 gp_Pnt aP0 (0, 0, 0);
262 gp_Vec aVX = gp::DX(), aVZ = gp::DZ();
263 gp_Ax3 anAxis1 (aP0, aVX, aVZ), anAxis2 (aP0, aVZ, aVX);
265 TopTools_IndexedMapOfShape aMapOfShapes;
266 aMapOfShapes.Clear();
267 TopExp::MapShapes(theShape, aMapOfShapes);
269 commonShapes->Clear();
274 // Create a cylinder surface
275 Handle(Geom_Surface) aC1Ext = new Geom_CylindricalSurface(anAxis1, r1);
276 if ( aC1Ext.IsNull() )
277 StdFail_NotDone::Raise("Couldn't build main cylindrical surface");
279 Handle(TColStd_HSequenceOfInteger) aSeqExt1 = GetShapesOnSurfaceIDs( aC1Ext, theShape, theShapeType, GEOMAlgo_ST_ON );
280 // Create a cylinder surface
281 Handle(Geom_Surface) aC2Ext = new Geom_CylindricalSurface(anAxis2, r2);
282 if ( aC2Ext.IsNull() )
283 StdFail_NotDone::Raise("Couldn't build incident cylindrical surface");
285 Handle(TColStd_HSequenceOfInteger) aSeqExt2 = GetShapesOnSurfaceIDs( aC2Ext, theShape, theShapeType, GEOMAlgo_ST_ON );
286 // # Recherche (dans le quart de Te) de l'arete d'intersection des 2 cylindres
287 // # Search in theShape for common shape of type theShapeType on the intersection of 2 pipes
289 for (int i=1; i<=aSeqExt2->Length();i++) {
290 // std::cerr << "aSeqExt2->Value(i): " << aSeqExt2->Value(i) << std::endl;
291 for (int j=1; j<=aSeqExt1->Length();j++) {
292 // std::cerr << "aSeqExt1->Value(j): " << aSeqExt1->Value(j) << std::endl;
293 if (aSeqExt1->Value(j) == aSeqExt2->Value(i)) {
294 myID = aSeqExt1->Value(j);
295 commonShapes->Append(aMapOfShapes.FindKey(myID));
301 StdFail_NotDone::Raise("Common shapes couldn't be found");
304 //=======================================================================
305 //function : MakePipeTShape
307 //=======================================================================
308 TopoDS_Shape AdvancedEngine_PipeTShapeDriver::MakePipeTShape (const double r1, const double w1, const double l1,
309 const double r2, const double w2, const double l2) const
311 double r1Ext = r1 + w1;
312 double r2Ext = r2 + w2;
314 gp_Pnt aP0 (0, 0, 0);
315 gp_Pnt aP1 (-l1, 0, 0);
316 gp_Vec aVX = gp::DX(), aVY = gp::DY(), aVZ = gp::DZ();
317 gp_Ax2 anAxes1 (aP1, aVX, aVZ);
318 gp_Ax2 anAxes2 (aP0, aVZ, aVX);
320 // Build the initial pipes
321 BRepPrimAPI_MakeCylinder C1Int (anAxes1, r1, Abs(2 * l1));
322 BRepPrimAPI_MakeCylinder C1Ext (anAxes1, r1Ext, Abs(2 * l1));
323 BRepPrimAPI_MakeCylinder C2Int (anAxes2, r2, Abs(l2));
324 BRepPrimAPI_MakeCylinder C2Ext (anAxes2, r2Ext, Abs(l2));
329 if (!C1Int.IsDone() || !C1Ext.IsDone() || !C2Int.IsDone() || !C2Ext.IsDone()) {
330 StdFail_NotDone::Raise("Cannot build cylinders");
334 BRepAlgoAPI_Fuse fuse1 (C1Ext.Shape(), C2Ext.Shape());
335 if (!fuse1.IsDone()) {
336 StdFail_NotDone::Raise("Cannot fuse cylinders");
339 // Remove small radius main pipe
340 BRepAlgoAPI_Cut cut1 (fuse1.Shape(), C1Int.Shape());
341 if (!cut1.IsDone()) {
342 StdFail_NotDone::Raise("Coudn't cut cylinders");
345 // Remove small radius incident pipe => Te
346 BRepAlgoAPI_Cut Te (cut1.Shape(), C2Int.Shape());
348 StdFail_NotDone::Raise("Coudn't cut cylinders");
351 TopoDS_Shape aShape = Te.Shape();
353 // VSR: 30/12/2014: temporary workaround about intersection curves problem
354 #ifdef FIX_CURVES_TOLERANCES
355 GEOMUtils::FixShapeCurves(aShape);
361 //=======================================================================
362 //function : MakeQuarterPipeTShape
364 //=======================================================================
365 TopoDS_Shape AdvancedEngine_PipeTShapeDriver::MakeQuarterPipeTShape (const double r1, const double w1, const double l1,
366 const double r2, const double w2, const double l2) const
368 TopoDS_Shape Te = MakePipeTShape(r1, w1, l1, r2, w2, l2);
370 StdFail_NotDone::Raise("Couldn't build Pipe TShape");
372 // Get a quarter of shape => Te2
373 double r1Ext = r1 + w1;
374 BRepPrimAPI_MakeBox box1 (gp_Pnt(0, -2*r1Ext, -2*r1Ext), gp_Pnt( Abs(2 * l1), 2*r1Ext, Abs(2*l2)));
375 BRepPrimAPI_MakeBox box2 (gp_Pnt(0, 2*r1Ext, -2*r1Ext), gp_Pnt(-Abs(2 * l1), 0, Abs(2*l2)));
378 if (!box1.IsDone() || !box2.IsDone()) {
379 StdFail_NotDone::Raise("Couldn't build boxes");
381 BRepAlgoAPI_Cut cut3 (Te, box1.Shape());
382 if (!cut3.IsDone()) {
383 StdFail_NotDone::Raise("Couldn't cut Pipe Tshape with box");
385 BRepAlgoAPI_Cut Te4 (cut3.Shape(), box2.Shape());
387 StdFail_NotDone::Raise("Couldn't cut Pipe Tshape with box");
390 TopoDS_Shape aShape = Te4.Shape();
392 // VSR: 30/12/2014: temporary workaround about intersection curves problem
393 #ifdef FIX_CURVES_TOLERANCES
394 GEOMUtils::FixShapeCurves(aShape);
400 //=======================================================================
403 //=======================================================================
404 Standard_Integer AdvancedEngine_PipeTShapeDriver::Execute (TFunction_Logbook& log) const
406 if (Label().IsNull()) return 0;
407 Handle(GEOM_Function) aFunction = GEOM_Function::GetFunction(Label());
409 AdvancedEngine_IPipeTShape aData (aFunction);
410 Standard_Integer aType = aFunction->GetType();
412 TopoDS_Shape aShape, Te4, Te4Part;
413 //TopoDS_Edge arete_intersect_int;
414 //Handle(TopTools_HSequenceOfShape) edges_e = new TopTools_HSequenceOfShape;
415 Handle(TColStd_HSequenceOfInteger) edges_e;
416 //Handle(TopTools_HSequenceOfShape) edges_i = new TopTools_HSequenceOfShape;
417 //gp_Pnt aP0 (0, 0, 0);
418 //gp_Vec aVX = gp::DX(), aVY = gp::DY(), aVZ = gp::DZ();
419 bool hexMesh = (bool) aData.GetHexMesh();
422 //double aSize = 2*(aData.GetL1() + aData.GetL2());
423 double epsilon = Precision::Approximation();
424 double aR1Ext = aData.GetR1() + aData.GetW1();
425 double aR2Ext = aData.GetR2() + aData.GetW2();
427 if (aData.GetR2() > aData.GetR1() + epsilon) {
428 StdFail_NotDone::Raise("TShape cannot be computed if R2 > R1");
431 if (aR2Ext > aR1Ext + epsilon) {
432 StdFail_NotDone::Raise("TShape cannot be computed if R2+W2 > R1+W1");
435 // external radius are equal
436 if (fabs(aR2Ext - aR1Ext) < epsilon) {
437 if (aType == TSHAPE_CHAMFER)
438 StdFail_NotDone::Raise("TShape with chamfer cannot be computed if R2+W2 = R1+W1");
439 if (aType == TSHAPE_FILLET)
440 StdFail_NotDone::Raise("TShape with fillet cannot be computed if R2+W2 = R1+W1");
441 // internal radius are different => not possible
442 if (fabs(aData.GetR2() - aData.GetR1()) > epsilon) {
443 StdFail_NotDone::Raise("TShape cannot be computed if R2+W2 = R1+W1 and R2 != R1");
447 if (aR1Ext >= aData.GetL2() + epsilon) {
448 StdFail_NotDone::Raise("TShape cannot be computed if R1+W1 >= L2");
450 if (aR2Ext >= aData.GetL1() + epsilon) {
451 StdFail_NotDone::Raise("TShape cannot be computed if R2+W2 >= L1");
454 if (aType == TSHAPE_CHAMFER) {
455 if (aData.GetH() >= (aData.GetL2() - aR1Ext + epsilon)) {
456 StdFail_NotDone::Raise("TShape cannot be computed: height of chamfer is too high");
459 if (aData.GetW() >= (aData.GetL1() - aR2Ext + epsilon))
460 StdFail_NotDone::Raise("TShape cannot be computed: width of chamfer is too high");
463 if (aType == TSHAPE_FILLET) {
464 if (aData.GetRF() >= (aData.GetL2() - aR1Ext + epsilon) ||
465 aData.GetRF() >= (aData.GetL1() - aR2Ext + epsilon))
466 StdFail_NotDone::Raise("TShape cannot be computed: radius of fillet is too high");
470 // Create a quarter of a basic T-Shape pipe
471 //std::cerr << "Create a quarter of a basic T-Shape pipe" << std::endl;
472 Te4 = MakeQuarterPipeTShape(aData.GetR1(), aData.GetW1(), aData.GetL1(),
473 aData.GetR2(), aData.GetW2(), aData.GetL2());
476 // No need to cut pipe t-shape
477 //std::cerr << "Create a basic T-Shape pipe" << std::endl;
478 Te4 = MakePipeTShape(aData.GetR1(), aData.GetW1(), aData.GetL1(),
479 aData.GetR2(), aData.GetW2(), aData.GetL2());
483 if (aType == TSHAPE_BASIC) {
485 // aShape = MakeQuarterPipeTShape(aData.GetR1(), aData.GetW1(), aData.GetL1(),
486 // aData.GetR2(), aData.GetW2(), aData.GetL2());
488 else if (aType == TSHAPE_CHAMFER) {
489 // TShape with chamfer
491 // TopoDS_Compound CC;
492 // BB.MakeCompound(CC);
493 // Create chamfer on the edges edges_e
494 BRepFilletAPI_MakeChamfer chamfer (Te4);
495 TopTools_IndexedMapOfShape anEdgesIndices;
496 TopExp::MapShapes(Te4, anEdgesIndices);
500 BRepPrimAPI_MakeBox aBox (gp_Pnt(0,0,0),gp_Pnt(-aR2Ext, -aR2Ext, aR1Ext));
502 if (!aBox.IsDone()) {
503 StdFail_NotDone::Raise("Couldn't build box");
505 theBox = aBox.Shape();
508 BRepPrimAPI_MakeBox aBox (gp_Pnt(aR2Ext,aR2Ext,0),gp_Pnt(-aR2Ext, -aR2Ext, aR1Ext));
510 if (!aBox.IsDone()) {
511 StdFail_NotDone::Raise("Couldn't build box");
513 theBox = aBox.Shape();
515 Handle(TColStd_HSequenceOfInteger) edges_e = new TColStd_HSequenceOfInteger;
516 edges_e = GetShapesOnBoxIDs(theBox, Te4, TopAbs_EDGE, GEOMAlgo_ST_IN);
517 if (edges_e.IsNull() || edges_e->Length() == 0) {
518 StdFail_NotDone::Raise("Common edges not found");
521 TopTools_IndexedDataMapOfShapeListOfShape M;
522 GEOMImpl_Block6Explorer::MapShapesAndAncestors(Te4, TopAbs_EDGE, TopAbs_FACE, M);
523 // std::cerr << "Number of IDs: " << edges_e->Length() << std::endl;
524 int nbEdgesInChamfer = 0;
525 for (int i=1;i<=edges_e->Length();i++) {
526 // std::cerr << "Get Edge with ID #" << i << std::endl;
527 int theId = edges_e->Value(i);
528 // std::cerr << "ID #" << i << "= " << theId << std::endl;
529 // std::cerr << "Search for edge in shape" << std::endl;
530 TopoDS_Edge theEdge = TopoDS::Edge(anEdgesIndices.FindKey(theId));
531 // std::cerr << "Found" << std::endl;
532 // std::cerr << "Keep only edges with a vertex on (x, x, re1)" << std::endl;
533 TopExp_Explorer ExVertices;
534 for (ExVertices.Init(theEdge,TopAbs_VERTEX); ExVertices.More(); ExVertices.Next()) {
535 gp_Pnt aPt = BRep_Tool::Pnt(TopoDS::Vertex(ExVertices.Current()));
536 if (aPt.Z() - aR1Ext <= epsilon) {
537 // std::cerr << "aPt.Z() = aR1Ext => keep this edge" << std::endl;
539 const TopTools_ListOfShape& aFL = M.FindFromKey(theEdge);
540 TopoDS_Face F = TopoDS::Face( aFL.First() );
542 chamfer.Add(aData.GetH(), aData.GetW(), theEdge, F);
544 chamfer.Add(aData.GetW(), aData.GetH(), theEdge, F);
548 // std::cerr << "Test if hexMesh: ";
549 if (hexMesh && nbEdgesInChamfer == 1) {
550 // std::cerr << "Yes => stop after 1 edge" << std::endl;
553 // std::cerr << "No => continue for other edges" << std::endl;
554 // BB.Add(CC, edges_e->Value(i));
555 // const TopTools_ListOfShape& aFL = M.FindFromKey(TopoDS::Edge(edges_e->Value(i)));
556 // chamfer.Add(aData.GetW(), aData.GetH(), TopoDS::Edge(edges_e->Value(i)), F);
558 // std::cerr << "Build chamfer with " << nbEdgesInChamfer << " edges" << std::endl;
561 if (!chamfer.IsDone()) {
562 StdFail_NotDone::Raise("Chamfer can not be computed on the given shape with the given parameters");
565 // BB.Add(CC, chamfer.Shape());
568 aShape = chamfer.Shape();
570 else if (aType == TSHAPE_FILLET) {
571 // TShape with fillet
572 // Create fillet on the edge arete_intersect_ext
573 BRepFilletAPI_MakeFillet fill (Te4);
575 TopTools_IndexedMapOfShape anIndices;
576 TopExp::MapShapes(Te4, anIndices);
580 BRepPrimAPI_MakeBox aBox (gp_Pnt(0,0,0),gp_Pnt(-aR2Ext, -aR2Ext, aR1Ext));
582 if (!aBox.IsDone()) {
583 StdFail_NotDone::Raise("Couldn't build box");
585 theBox = aBox.Shape();
588 BRepPrimAPI_MakeBox aBox (gp_Pnt(aR2Ext,aR2Ext,0),gp_Pnt(-aR2Ext, -aR2Ext, aR1Ext));
590 if (!aBox.IsDone()) {
591 StdFail_NotDone::Raise("Couldn't build box");
593 theBox = aBox.Shape();
595 Handle(TColStd_HSequenceOfInteger) edges_e = new TColStd_HSequenceOfInteger;
596 edges_e = GetShapesOnBoxIDs(theBox, Te4, TopAbs_EDGE, GEOMAlgo_ST_IN);
597 if (edges_e.IsNull() || edges_e->Length() == 0) {
598 StdFail_NotDone::Raise("Common edges not found");
601 // fill.Add(TopoDS::Edge(edges_e->Value(1)));
603 for (int i=1;i<=edges_e->Length();i++) {
604 if (hexMesh && (i > 1))
606 TopoDS_Edge theEdge = TopoDS::Edge(anIndices.FindKey(edges_e->Value(i)));
608 // fill.Add(TopoDS::Edge(edges_e->Value(i)));
611 fill.SetRadius(aData.GetRF(), 1, 1);
613 if (!fill.IsDone()) {
614 StdFail_NotDone::Raise("Fillet can't be computed on the given shape with the given radius");
617 aShape = fill.Shape();
620 // other construction modes here
623 if (aShape.IsNull()) return 0;
625 aFunction->SetValue(aShape);
627 log.SetTouched(Label());
632 //================================================================================
634 * \brief Returns a name of creation operation and names and values of creation parameters
636 //================================================================================
638 bool AdvancedEngine_PipeTShapeDriver::
639 GetCreationInformation(std::string& theOperationName,
640 std::vector<GEOM_Param>& theParams)
642 if (Label().IsNull()) return 0;
643 Handle(GEOM_Function) function = GEOM_Function::GetFunction(Label());
645 AdvancedEngine_IPipeTShape aCI( function );
646 Standard_Integer aType = function->GetType();
648 theOperationName = "PIPETSHAPE";
652 AddParam( theParams, "Main radius", aCI.GetR1() );
653 AddParam( theParams, "Main width", aCI.GetW1() );
654 AddParam( theParams, "Main half-length", aCI.GetL1() );
655 AddParam( theParams, "Incident pipe radius", aCI.GetR2() );
656 AddParam( theParams, "Incident pipe width", aCI.GetW2() );
657 AddParam( theParams, "Incident pipe half-length", aCI.GetL2() );
658 AddParam( theParams, "For hex mesh", aCI.GetHexMesh() );
661 AddParam( theParams, "Main radius", aCI.GetR1() );
662 AddParam( theParams, "Main width", aCI.GetW1() );
663 AddParam( theParams, "Main half-length", aCI.GetL1() );
664 AddParam( theParams, "Incident pipe radius", aCI.GetR2() );
665 AddParam( theParams, "Incident pipe width", aCI.GetW2() );
666 AddParam( theParams, "Incident pipe half-length", aCI.GetL2() );
667 AddParam( theParams, "Chamfer height", aCI.GetH() );
668 AddParam( theParams, "Chamfer width", aCI.GetW() );
669 AddParam( theParams, "For hex mesh", aCI.GetHexMesh() );
672 AddParam( theParams, "Main radius", aCI.GetR1() );
673 AddParam( theParams, "Main width", aCI.GetW1() );
674 AddParam( theParams, "Main half-length", aCI.GetL1() );
675 AddParam( theParams, "Incident pipe radius", aCI.GetR2() );
676 AddParam( theParams, "Incident pipe width", aCI.GetW2() );
677 AddParam( theParams, "Incident pipe half-length", aCI.GetL2() );
678 AddParam( theParams, "Fillet radius", aCI.GetRF() );
679 AddParam( theParams, "For hex mesh", aCI.GetHexMesh() );
688 IMPLEMENT_STANDARD_HANDLE (AdvancedEngine_PipeTShapeDriver,GEOM_BaseDriver);
689 IMPLEMENT_STANDARD_RTTIEXT (AdvancedEngine_PipeTShapeDriver,GEOM_BaseDriver);