-// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2007-2014 CEA/DEN, EDF R&D, OPEN CASCADE
//
// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
-// version 2.1 of the License.
+// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
return theMode;
}
+//=======================================================================
+//function : BuildPipeShell
+//purpose : Builds a pipe shell. If failed, try to build in Descrete Trihedron
+// mode. Returns Standard_True if the building is done successfully.
+//=======================================================================
+static Standard_Boolean BuildPipeShell(BRepOffsetAPI_MakePipeShell &theBuilder)
+{
+ theBuilder.Build();
+
+ Standard_Boolean isDone = theBuilder.IsDone();
+
+ if (!isDone) {
+ // Try to use Descrete Trihedron mode.
+ theBuilder.SetDiscreteMode();
+ theBuilder.Build();
+ isDone = theBuilder.IsDone();
+ }
+
+ return isDone;
+}
//=======================================================================
//function : FillForOtherEdges
if (!aBuilder.IsReady()) {
return false;
}
- aBuilder.Build();
+
+ BuildPipeShell(aBuilder);
+
TopoDS_Shape aShape = aBuilder.Shape();
/*
TopoDS_Compound C;
TopTools_SequenceOfShape aSeqBases;
TopTools_SequenceOfShape aSeqLocs;
TopTools_SequenceOfShape aSeqFaces;
+ Standard_Boolean NeedCreateSolid = Standard_False;
Standard_Integer i = 1;
for (i = 1; i <= nbBases; i++) {
//if for section was specified face with a few wires then a few
// pipes were build and make solid
- Standard_Boolean NeedCreateSolid = Standard_False;
if (aTypeBase == TopAbs_SHELL) {
// create wire as boundary contour if shell is no closed
// get free boundary shapes
if (!aBuilder.IsReady()) {
Standard_ConstructionError::Raise("Invalid input data for building PIPE: bases are invalid");
}
- aBuilder.Build();
+
+ BuildPipeShell(aBuilder);
+
TopoDS_Shape resShape = aBuilder.Shape();
aSeqRes.Append(resShape);
}
if (!aBuilder.IsReady()) {
Standard_ConstructionError::Raise("Invalid input data for building PIPE: bases are invalid");
}
- aBuilder.Build();
+
+ BuildPipeShell(aBuilder);
+
TopoDS_Shape resShape = aBuilder.Shape();
aSeqRes.Append(resShape);
// make sewing for result
aBuilder.SetTolerance(aTolConf, aTolConf, aTolAng);
- aBuilder.Build();
+ Standard_Boolean isDone = BuildPipeShell(aBuilder);
+
+ if (isDone && NeedCreateSolid) {
+ isDone = aBuilder.MakeSolid();
+ }
+
+ if (!isDone) {
+ Standard_ConstructionError::Raise("Pipe construction failure");
+ }
aShape = aBuilder.Shape();
aSeqFaces.Append(aShape);
for (j = 1; j <=usedBases.Length(); j++)
aBuilder.Delete(usedBases.Value(j));
}
-
- //for case if section is face
- if (aSeqFaces.Length() >1) {
- BRep_Builder aB;
- TopoDS_Compound aComp;
- aB.MakeCompound(aComp);
- for (i = 1; i <= aSeqFaces.Length(); i++)
- aB.Add(aComp,aSeqFaces.Value(i));
- aShape = aComp;
- }
}
return aShape;
if (aCI) delete aCI;
Standard_ConstructionError::Raise("Invalid input data for building PIPE: bases are invalid");
}
- aBuilder.Build();
+
+ BuildPipeShell(aBuilder);
+
TopoDS_Shape aShape = aBuilder.Shape();
TopoDS_Shell aShell;
B.MakeShell(aShell);
if (aCI) delete aCI;
Standard_ConstructionError::Raise("Invalid input data for building PIPE: bases are invalid");
}
- aBuilder.Build();
+
+ BuildPipeShell(aBuilder);
+
TopoDS_Shape aShape = aBuilder.Shape();
TopoDS_Shell aShell;
B.MakeShell(aShell);
gp_Vec aVec(BRep_Tool::Pnt(V1), BRep_Tool::Pnt(V2));
gp_Dir BiNormal(aVec);
PipeBuilder.SetMode(BiNormal);
- PipeBuilder.Build();
- if (aShapeBase.ShapeType() == TopAbs_FACE) {
+
+ Standard_Boolean isDone = BuildPipeShell(PipeBuilder);
+
+ if (isDone && aShapeBase.ShapeType() == TopAbs_FACE) {
PipeBuilder.MakeSolid();
}
if (FaceBuilder.IsDone())
Sweep.SetMode(FaceBuilder.Face());
Sweep.Add(Profile);
- Sweep.Build();
-
- if (!Sweep.IsDone())
+
+ Standard_Boolean isDone = BuildPipeShell(Sweep);
+
+ if (!isDone)
{
if (aCI) delete aCI;
Standard_ConstructionError::Raise("MakePipeShell failed");
else
{
GeomFill_Trihedron theBestMode = EvaluateBestSweepMode(aWirePath);
- aShape = BRepOffsetAPI_MakePipe(aWirePath, aShapeBase, theBestMode);
+ BRepOffsetAPI_MakePipe aMkPipe(aWirePath, aShapeBase, theBestMode);
+
+ if (aMkPipe.IsDone()) {
+ aShape = aMkPipe.Shape();
+ } else if (theBestMode != GeomFill_IsDiscreteTrihedron) {
+ // Try to use Descrete Trihedron mode.
+ BRepOffsetAPI_MakePipe aMkPipeDescrete
+ (aWirePath, aShapeBase, GeomFill_IsDiscreteTrihedron);
+
+ if (aMkPipeDescrete.IsDone()) {
+ aShape = aMkPipeDescrete.Shape();
+ }
+ }
}
}