NPAL16173: EDF454: Result of revolving a shell should be a compound.

This commit is contained in:
jfa 2007-06-07 08:08:54 +00:00
parent 81200c50e6
commit 97fc7b1c06
6 changed files with 131 additions and 63 deletions

View File

@ -864,7 +864,7 @@ Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeRevolutionAxisAngle (Handle(
} }
//Make a Python command //Make a Python command
GEOM::TPythonDump(aFunction) << aRevolution << " = geompy.MakeRevolution(" GEOM::TPythonDump(aFunction) << aRevolution << " = geompy.MakeRevolutionAxisAngle("
<< theBase << ", " << theAxis << ", " << theAngle * 180.0 / PI << "*math.pi/180.0)"; << theBase << ", " << theAxis << ", " << theAngle * 180.0 / PI << "*math.pi/180.0)";
SetErrorCode(OK); SetErrorCode(OK);

View File

@ -42,7 +42,6 @@
#include "GEOMAlgo_FinderShapeOnQuad.hxx" #include "GEOMAlgo_FinderShapeOnQuad.hxx"
#include "GEOMAlgo_FinderShapeOn2.hxx" #include "GEOMAlgo_FinderShapeOn2.hxx"
#include "GEOMAlgo_ClsfBox.hxx" #include "GEOMAlgo_ClsfBox.hxx"
//#include "GEOMAlgo_ClsfSurf.hxx"
#include "GEOMAlgo_Gluer1.hxx" #include "GEOMAlgo_Gluer1.hxx"
#include "GEOMAlgo_ListIteratorOfListOfCoupleOfShapes.hxx" #include "GEOMAlgo_ListIteratorOfListOfCoupleOfShapes.hxx"
#include "GEOMAlgo_CoupleOfShapes.hxx" #include "GEOMAlgo_CoupleOfShapes.hxx"
@ -62,6 +61,7 @@
#include <BRepExtrema_ExtCF.hxx> #include <BRepExtrema_ExtCF.hxx>
#include <BRep_Tool.hxx> #include <BRep_Tool.hxx>
#include <BRep_Builder.hxx>
#include <BRepTools.hxx> #include <BRepTools.hxx>
#include <BRepGProp.hxx> #include <BRepGProp.hxx>
#include <BRepAdaptor_Curve.hxx> #include <BRepAdaptor_Curve.hxx>
@ -78,6 +78,7 @@
#include <TopoDS_Face.hxx> #include <TopoDS_Face.hxx>
#include <TopoDS_Edge.hxx> #include <TopoDS_Edge.hxx>
#include <TopoDS_Vertex.hxx> #include <TopoDS_Vertex.hxx>
#include <TopoDS_Compound.hxx>
#include <TopoDS_Iterator.hxx> #include <TopoDS_Iterator.hxx>
#include <TopExp_Explorer.hxx> #include <TopExp_Explorer.hxx>
#include <TopLoc_Location.hxx> #include <TopLoc_Location.hxx>
@ -1587,8 +1588,10 @@ Handle(TColStd_HSequenceOfInteger)
Handle(TColStd_HSequenceOfInteger) aSeqOfIDs; Handle(TColStd_HSequenceOfInteger) aSeqOfIDs;
// Check presence of triangulation, build if need // Check presence of triangulation, build if need
if (!CheckTriangulation(theShape)) if (!CheckTriangulation(theShape)) {
SetErrorCode("Cannot build triangulation on the shape");
return aSeqOfIDs; return aSeqOfIDs;
}
// Call algo // Call algo
GEOMAlgo_FinderShapeOn1 aFinder; GEOMAlgo_FinderShapeOn1 aFinder;
@ -2207,8 +2210,10 @@ Handle(TColStd_HSequenceOfInteger)
Handle(TColStd_HSequenceOfInteger) aSeqOfIDs; Handle(TColStd_HSequenceOfInteger) aSeqOfIDs;
// Check presence of triangulation, build if need // Check presence of triangulation, build if need
if (!CheckTriangulation(aShape)) if (!CheckTriangulation(aShape)) {
SetErrorCode("Cannot build triangulation on the shape");
return aSeqOfIDs; return aSeqOfIDs;
}
// Call algo // Call algo
gp_Pnt aPntTL = BRep_Tool::Pnt(TopoDS::Vertex(aTL)); gp_Pnt aPntTL = BRep_Tool::Pnt(TopoDS::Vertex(aTL));
@ -2651,6 +2656,33 @@ void GEOMImpl_IShapesOperations::SortShapes(TopTools_ListOfShape& SL)
SL.Append( aShapes( OrderInd(Index) )); SL.Append( aShapes( OrderInd(Index) ));
} }
//=======================================================================
//function : CompsolidToCompound
//purpose :
//=======================================================================
TopoDS_Shape GEOMImpl_IShapesOperations::CompsolidToCompound (const TopoDS_Shape& theCompsolid)
{
if (theCompsolid.ShapeType() != TopAbs_COMPSOLID) {
return theCompsolid;
}
TopoDS_Compound aCompound;
BRep_Builder B;
B.MakeCompound(aCompound);
TopTools_MapOfShape mapShape;
TopoDS_Iterator It (theCompsolid, Standard_True, Standard_True);
for (; It.More(); It.Next()) {
TopoDS_Shape aShape_i = It.Value();
if (mapShape.Add(aShape_i)) {
B.Add(aCompound, aShape_i);
}
}
return aCompound;
}
//======================================================================= //=======================================================================
//function : CheckTriangulation //function : CheckTriangulation
//purpose : //purpose :
@ -2659,7 +2691,6 @@ bool GEOMImpl_IShapesOperations::CheckTriangulation (const TopoDS_Shape& aShape)
{ {
TopExp_Explorer exp (aShape, TopAbs_FACE); TopExp_Explorer exp (aShape, TopAbs_FACE);
if (!exp.More()) { if (!exp.More()) {
SetErrorCode("Shape without faces given");
return false; return false;
} }

View File

@ -36,7 +36,8 @@ class GEOM_Engine;
class Handle(GEOM_Object); class Handle(GEOM_Object);
class Handle(TColStd_HArray1OfInteger); class Handle(TColStd_HArray1OfInteger);
class GEOMImpl_IShapesOperations : public GEOM_IOperations { class GEOMImpl_IShapesOperations : public GEOM_IOperations
{
public: public:
Standard_EXPORT GEOMImpl_IShapesOperations(GEOM_Engine* theEngine, int theDocID); Standard_EXPORT GEOMImpl_IShapesOperations(GEOM_Engine* theEngine, int theDocID);
Standard_EXPORT ~GEOMImpl_IShapesOperations(); Standard_EXPORT ~GEOMImpl_IShapesOperations();
@ -112,22 +113,25 @@ class GEOMImpl_IShapesOperations : public GEOM_IOperations {
const GEOMAlgo_State theState); const GEOMAlgo_State theState);
Standard_EXPORT Handle(TColStd_HSequenceOfTransient) GetShapesOnCylinder (const Handle(GEOM_Object)& theShape, Standard_EXPORT Handle(TColStd_HSequenceOfTransient)
const Standard_Integer theShapeType, GetShapesOnCylinder (const Handle(GEOM_Object)& theShape,
const Handle(GEOM_Object)& theAxis, const Standard_Integer theShapeType,
const Standard_Real theRadius, const Handle(GEOM_Object)& theAxis,
const GEOMAlgo_State theState); const Standard_Real theRadius,
const GEOMAlgo_State theState);
Standard_EXPORT Handle(TColStd_HSequenceOfTransient) GetShapesOnSphere (const Handle(GEOM_Object)& theShape, Standard_EXPORT Handle(TColStd_HSequenceOfTransient)
const Standard_Integer theShapeType, GetShapesOnSphere (const Handle(GEOM_Object)& theShape,
const Handle(GEOM_Object)& theCenter, const Standard_Integer theShapeType,
const Standard_Real theRadius, const Handle(GEOM_Object)& theCenter,
const GEOMAlgo_State theState); const Standard_Real theRadius,
const GEOMAlgo_State theState);
Standard_EXPORT Handle(TColStd_HSequenceOfInteger) GetShapesOnPlaneIDs (const Handle(GEOM_Object)& theShape, Standard_EXPORT Handle(TColStd_HSequenceOfInteger)
const Standard_Integer theShapeType, GetShapesOnPlaneIDs (const Handle(GEOM_Object)& theShape,
const Handle(GEOM_Object)& theAx1, const Standard_Integer theShapeType,
const GEOMAlgo_State theState); const Handle(GEOM_Object)& theAx1,
const GEOMAlgo_State theState);
Standard_EXPORT Handle(TColStd_HSequenceOfInteger) Standard_EXPORT Handle(TColStd_HSequenceOfInteger)
GetShapesOnPlaneWithLocationIDs (const Handle(GEOM_Object)& theShape, GetShapesOnPlaneWithLocationIDs (const Handle(GEOM_Object)& theShape,
@ -136,17 +140,19 @@ class GEOMImpl_IShapesOperations : public GEOM_IOperations {
const Handle(GEOM_Object)& thePnt, const Handle(GEOM_Object)& thePnt,
const GEOMAlgo_State theState); const GEOMAlgo_State theState);
Standard_EXPORT Handle(TColStd_HSequenceOfInteger) GetShapesOnCylinderIDs (const Handle(GEOM_Object)& theShape, Standard_EXPORT Handle(TColStd_HSequenceOfInteger)
const Standard_Integer theShapeType, GetShapesOnCylinderIDs (const Handle(GEOM_Object)& theShape,
const Handle(GEOM_Object)& theAxis, const Standard_Integer theShapeType,
const Standard_Real theRadius, const Handle(GEOM_Object)& theAxis,
const GEOMAlgo_State theState); const Standard_Real theRadius,
const GEOMAlgo_State theState);
Standard_EXPORT Handle(TColStd_HSequenceOfInteger) GetShapesOnSphereIDs (const Handle(GEOM_Object)& theShape, Standard_EXPORT Handle(TColStd_HSequenceOfInteger)
const Standard_Integer theShapeType, GetShapesOnSphereIDs (const Handle(GEOM_Object)& theShape,
const Handle(GEOM_Object)& theCenter, const Standard_Integer theShapeType,
const Standard_Real theRadius, const Handle(GEOM_Object)& theCenter,
const GEOMAlgo_State theState); const Standard_Real theRadius,
const GEOMAlgo_State theState);
/*! /*!
* \brief Find subshapes complying with given status about quadrangle * \brief Find subshapes complying with given status about quadrangle
@ -201,8 +207,6 @@ class GEOMImpl_IShapesOperations : public GEOM_IOperations {
Standard_EXPORT Handle(GEOM_Object) GetInPlace (Handle(GEOM_Object) theShapeWhere, Standard_EXPORT Handle(GEOM_Object) GetInPlace (Handle(GEOM_Object) theShapeWhere,
Handle(GEOM_Object) theShapeWhat); Handle(GEOM_Object) theShapeWhat);
Standard_EXPORT static void SortShapes (TopTools_ListOfShape& SL);
/*! /*!
* \brief Searches a shape equal to theWhat in the context of theWhere * \brief Searches a shape equal to theWhat in the context of theWhere
* \param theShapeWhere - a context shap * \param theShapeWhere - a context shap
@ -240,6 +244,30 @@ class GEOMImpl_IShapesOperations : public GEOM_IOperations {
const Standard_Integer theShapeType, const Standard_Integer theShapeType,
GEOMAlgo_State theState); GEOMAlgo_State theState);
public:
/*!
* \brief Sort shapes in the list by their coordinates.
* \param SL The list of shapes to sort.
*/
Standard_EXPORT static void SortShapes (TopTools_ListOfShape& SL);
/*!
* \brief Convert TopoDS_COMPSOLID to TopoDS_COMPOUND.
*
* If the argument shape is not of type TopoDS_COMPSOLID, this method returns it as is.
*
* \param theCompsolid The compsolid to be converted.
* \retval TopoDS_Shape Returns the resulting compound.
*/
Standard_EXPORT static TopoDS_Shape CompsolidToCompound (const TopoDS_Shape& theCompsolid);
/*!
* \brief Build a triangulation on \a theShape if it is absent.
* \param theShape The shape to check/build triangulation on.
* \retval bool Returns false if the shape has no faces, i.e. impossible to build triangulation.
*/
Standard_EXPORT static bool CheckTriangulation (const TopoDS_Shape& theShape);
private: private:
Handle(GEOM_Object) MakeShape (list<Handle(GEOM_Object)> theShapes, Handle(GEOM_Object) MakeShape (list<Handle(GEOM_Object)> theShapes,
const Standard_Integer theObjectType, const Standard_Integer theObjectType,
@ -247,11 +275,9 @@ class GEOMImpl_IShapesOperations : public GEOM_IOperations {
const TCollection_AsciiString& theMethodName); const TCollection_AsciiString& theMethodName);
// ---------------------------------------------------- // ----------------------------------------------------
// methods common for all GetShapesOnXXX() functions // methods common for all GetShapesOnXXX() functions
// ---------------------------------------------------- // ----------------------------------------------------
bool CheckTriangulation (const TopoDS_Shape& aShape);
/*! /*!
* \brief Checks if theShapeType parameter of GetShapesOnXXX() is OK * \brief Checks if theShapeType parameter of GetShapesOnXXX() is OK
* \param theShapeType - the shape type to check * \param theShapeType - the shape type to check

View File

@ -21,16 +21,28 @@
#include <Standard_Stream.hxx> #include <Standard_Stream.hxx>
#include <GEOMImpl_PipeDriver.hxx> #include <GEOMImpl_PipeDriver.hxx>
#include <GEOMImpl_IShapesOperations.hxx>
#include <GEOMImpl_IPipeDiffSect.hxx>
#include <GEOMImpl_IPipeShellSect.hxx>
#include <GEOMImpl_IPipe.hxx> #include <GEOMImpl_IPipe.hxx>
#include <GEOMImpl_Types.hxx> #include <GEOMImpl_Types.hxx>
#include <GEOM_Function.hxx> #include <GEOM_Function.hxx>
#include <ShapeAnalysis_FreeBounds.hxx>
#include <ShapeAnalysis_Edge.hxx>
#include <BRep_Tool.hxx> #include <BRep_Tool.hxx>
#include <BRep_Builder.hxx>
#include <BRepBuilderAPI_MakeWire.hxx>
#include <BRepBuilderAPI_Sewing.hxx>
#include <BRepCheck_Analyzer.hxx> #include <BRepCheck_Analyzer.hxx>
#include <BRepOffsetAPI_MakePipe.hxx> #include <BRepOffsetAPI_MakePipe.hxx>
#include <BRepBuilderAPI_MakeWire.hxx> #include <BRepOffsetAPI_MakePipeShell.hxx>
#include <TopAbs.hxx> #include <TopAbs.hxx>
#include <TopExp.hxx>
#include <TopExp_Explorer.hxx>
#include <TopoDS.hxx> #include <TopoDS.hxx>
#include <TopoDS_Wire.hxx> #include <TopoDS_Wire.hxx>
#include <TopoDS_Edge.hxx> #include <TopoDS_Edge.hxx>
@ -38,32 +50,24 @@
#include <TopoDS_Solid.hxx> #include <TopoDS_Solid.hxx>
#include <TopoDS_Shell.hxx> #include <TopoDS_Shell.hxx>
#include <TopoDS_Face.hxx> #include <TopoDS_Face.hxx>
#include <BRepOffsetAPI_MakePipeShell.hxx> #include <TopoDS_Compound.hxx>
#include <TColStd_HSequenceOfTransient.hxx> #include <TopTools_SequenceOfShape.hxx>
#include <GEOMImpl_IPipeDiffSect.hxx> #include <TopTools_IndexedDataMapOfShapeShape.hxx>
#include <GEOMImpl_IPipeShellSect.hxx> #include <TopTools_IndexedDataMapOfShapeListOfShape.hxx>
#include <TopTools_ListIteratorOfListOfShape.hxx>
#include <GeomAPI_ProjectPointOnCurve.hxx>
#include <Geom_TrimmedCurve.hxx>
#include <TColgp_SequenceOfPnt.hxx>
#include <TColStd_HSequenceOfTransient.hxx>
#include <Precision.hxx>
#include <Standard_NullObject.hxx> #include <Standard_NullObject.hxx>
#include <Standard_TypeMismatch.hxx> #include <Standard_TypeMismatch.hxx>
#include <Standard_ConstructionError.hxx> #include <Standard_ConstructionError.hxx>
#include "utilities.h"
#include <TopExp_Explorer.hxx>
#include <TopTools_SequenceOfShape.hxx>
#include <BRep_Builder.hxx>
#include <TopoDS_Compound.hxx>
#include <ShapeAnalysis_FreeBounds.hxx>
#include <TColgp_SequenceOfPnt.hxx>
#include <ShapeAnalysis_Edge.hxx>
#include <TopTools_IndexedDataMapOfShapeShape.hxx>
#include <TopTools_IndexedDataMapOfShapeListOfShape.hxx>
#include <TopExp.hxx>
#include <TopTools_ListIteratorOfListOfShape.hxx>
#include <GeomAPI_ProjectPointOnCurve.hxx>
#include <Precision.hxx>
#include <Geom_TrimmedCurve.hxx>
#include <BRepBuilderAPI_Sewing.hxx>
//#include <BRepTools.hxx> #include "utilities.h"
//======================================================================= //=======================================================================
@ -345,7 +349,6 @@ static void FindNextPairOfFaces(const TopoDS_Shape& aCurFace,
} }
FindNextPairOfFaces(F1other, aMapEdgeFaces1, aMapEdgeFaces2, FF, aCI); FindNextPairOfFaces(F1other, aMapEdgeFaces1, aMapEdgeFaces2, FF, aCI);
} }
} }
@ -1250,7 +1253,8 @@ Standard_Integer GEOMImpl_PipeDriver::Execute(TFunction_Logbook& log) const
Standard_ConstructionError::Raise("Algorithm have produced an invalid shape result"); Standard_ConstructionError::Raise("Algorithm have produced an invalid shape result");
} }
aFunction->SetValue(aShape); TopoDS_Shape aRes = GEOMImpl_IShapesOperations::CompsolidToCompound(aShape);
aFunction->SetValue(aRes);
log.SetTouched(Label()); log.SetTouched(Label());
if(aCI) delete aCI; if(aCI) delete aCI;

View File

@ -21,6 +21,8 @@
#include <Standard_Stream.hxx> #include <Standard_Stream.hxx>
#include <GEOMImpl_PrismDriver.hxx> #include <GEOMImpl_PrismDriver.hxx>
#include <GEOMImpl_IShapesOperations.hxx>
#include <GEOMImpl_IPrism.hxx> #include <GEOMImpl_IPrism.hxx>
#include <GEOMImpl_Types.hxx> #include <GEOMImpl_Types.hxx>
#include <GEOM_Function.hxx> #include <GEOM_Function.hxx>
@ -114,7 +116,8 @@ Standard_Integer GEOMImpl_PrismDriver::Execute(TFunction_Logbook& log) const
if (aShape.IsNull()) return 0; if (aShape.IsNull()) return 0;
aFunction->SetValue(aShape); TopoDS_Shape aRes = GEOMImpl_IShapesOperations::CompsolidToCompound(aShape);
aFunction->SetValue(aRes);
log.SetTouched(Label()); log.SetTouched(Label());

View File

@ -21,6 +21,8 @@
#include <Standard_Stream.hxx> #include <Standard_Stream.hxx>
#include <GEOMImpl_RevolutionDriver.hxx> #include <GEOMImpl_RevolutionDriver.hxx>
#include <GEOMImpl_IShapesOperations.hxx>
#include <GEOMImpl_IRevolution.hxx> #include <GEOMImpl_IRevolution.hxx>
#include <GEOMImpl_Types.hxx> #include <GEOMImpl_Types.hxx>
#include <GEOM_Function.hxx> #include <GEOM_Function.hxx>
@ -114,11 +116,13 @@ Standard_Integer GEOMImpl_RevolutionDriver::Execute(TFunction_Logbook& log) cons
} }
if (aShape.IsNull()) return 0; if (aShape.IsNull()) return 0;
aFunction->SetValue(aShape);
log.SetTouched(Label()); TopoDS_Shape aRes = GEOMImpl_IShapesOperations::CompsolidToCompound(aShape);
aFunction->SetValue(aRes);
return 1; log.SetTouched(Label());
return 1;
} }