#include <GEOMImpl_Types.hxx>
#include <GEOMImpl_MeasureDriver.hxx>
#include <GEOMImpl_IMeasure.hxx>
+#include <GEOMImpl_IShapesOperations.hxx>
#include <GEOMAlgo_ShapeInfo.hxx>
#include <GEOMAlgo_ShapeInfoFiller.hxx>
// Origin
gp_Pnt aPnt;
- if (theShape.ShapeType() == TopAbs_VERTEX) {
+
+ TopAbs_ShapeEnum aShType = theShape.ShapeType();
+
+ if (aShType == TopAbs_VERTEX) {
aPnt = BRep_Tool::Pnt(TopoDS::Vertex(theShape));
}
else {
+ if (aShType == TopAbs_COMPOUND) {
+ aShType = GEOMImpl_IShapesOperations::GetTypeOfSimplePart(theShape);
+ }
+
GProp_GProps aSystem;
- if (theShape.ShapeType() == TopAbs_EDGE || theShape.ShapeType() == TopAbs_WIRE)
+ if (aShType == TopAbs_EDGE || aShType == TopAbs_WIRE)
BRepGProp::LinearProperties(theShape, aSystem);
- else if (theShape.ShapeType() == TopAbs_FACE || theShape.ShapeType() == TopAbs_SHELL)
+ else if (aShType == TopAbs_FACE || aShType == TopAbs_SHELL)
BRepGProp::SurfaceProperties(theShape, aSystem);
else
BRepGProp::VolumeProperties(theShape, aSystem);
}
return defaultNorm;
}
+}
- //================================================================================
- /*!
- * \brief Return type of shape for explode. In case of compound it will be a type of sub shape.
- */
- //================================================================================
-
- TopAbs_ShapeEnum GetTypeOfSimplePart (const TopoDS_Shape& theShape)
- {
- TopAbs_ShapeEnum aType = theShape.ShapeType();
- if (aType == TopAbs_VERTEX) return TopAbs_VERTEX;
- else if (aType == TopAbs_EDGE || aType == TopAbs_WIRE) return TopAbs_EDGE;
- else if (aType == TopAbs_FACE || aType == TopAbs_SHELL) return TopAbs_FACE;
- else if (aType == TopAbs_SOLID || aType == TopAbs_COMPSOLID) return TopAbs_SOLID;
- else if (aType == TopAbs_COMPOUND) {
- // Only the iType of the first shape in the compound is taken into account
- TopoDS_Iterator It (theShape, Standard_False, Standard_False);
- if (It.More()) {
- return GetTypeOfSimplePart(It.Value());
- }
+//================================================================================
+/*!
+ * \brief Return type of shape for explode. In case of compound it will be a type of sub shape.
+ */
+//================================================================================
+TopAbs_ShapeEnum GEOMImpl_IShapesOperations::GetTypeOfSimplePart (const TopoDS_Shape& theShape)
+{
+ TopAbs_ShapeEnum aType = theShape.ShapeType();
+ if (aType == TopAbs_VERTEX) return TopAbs_VERTEX;
+ else if (aType == TopAbs_EDGE || aType == TopAbs_WIRE) return TopAbs_EDGE;
+ else if (aType == TopAbs_FACE || aType == TopAbs_SHELL) return TopAbs_FACE;
+ else if (aType == TopAbs_SOLID || aType == TopAbs_COMPSOLID) return TopAbs_SOLID;
+ else if (aType == TopAbs_COMPOUND) {
+ // Only the iType of the first shape in the compound is taken into account
+ TopoDS_Iterator It (theShape, Standard_False, Standard_False);
+ if (It.More()) {
+ return GetTypeOfSimplePart(It.Value());
}
- return TopAbs_SHAPE;
}
+ return TopAbs_SHAPE;
}
//=============================================================================
*/
Standard_EXPORT static bool CheckTriangulation (const TopoDS_Shape& theShape);
+ /*!
+ * \brief Return type of shape for explode. In case of compound it will be a type of its first sub shape.
+ * \param theShape The shape to get type of.
+ * \retval TopAbs_ShapeEnum Return type of shape for explode.
+ */
+ Standard_EXPORT static TopAbs_ShapeEnum GetTypeOfSimplePart (const TopoDS_Shape& theShape);
+
private:
Handle(GEOM_Object) MakeShape (std::list<Handle(GEOM_Object)> theShapes,
const Standard_Integer theObjectType,
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
#include <Standard_Stream.hxx>
Standard_NullObject::Raise("Shape for centre of mass calculation is null");
}
- GProp_GProps aSystem;
- gp_Pnt aCenterMass;
-
- if (aShapeBase.ShapeType() == TopAbs_VERTEX) {
- aCenterMass = BRep_Tool::Pnt(TopoDS::Vertex(aShapeBase));
- } else if (aShapeBase.ShapeType() == TopAbs_EDGE || aShapeBase.ShapeType() == TopAbs_WIRE) {
- BRepGProp::LinearProperties(aShapeBase, aSystem);
- aCenterMass = aSystem.CentreOfMass();
- } else if (aShapeBase.ShapeType() == TopAbs_FACE || aShapeBase.ShapeType() == TopAbs_SHELL) {
- BRepGProp::SurfaceProperties(aShapeBase, aSystem);
- aCenterMass = aSystem.CentreOfMass();
- } else {
- BRepGProp::VolumeProperties(aShapeBase, aSystem);
- aCenterMass = aSystem.CentreOfMass();
- }
-
+ gp_Ax3 aPos = GEOMImpl_IMeasureOperations::GetPosition(aShapeBase);
+ gp_Pnt aCenterMass = aPos.Location();
aShape = BRepBuilderAPI_MakeVertex(aCenterMass).Shape();
}
else if (aType == VERTEX_BY_INDEX)
#include <GEOMImpl_IPrism.hxx>
#include <GEOMImpl_IShapesOperations.hxx>
#include <GEOMImpl_IMeasureOperations.hxx>
+#include <GEOMImpl_GlueDriver.hxx>
#include <GEOMImpl_PipeDriver.hxx>
#include <GEOMImpl_Types.hxx>
#include <GEOM_Function.hxx>
#include <BRepPrimAPI_MakePrism.hxx>
+
+#include <BRep_Builder.hxx>
#include <BRepBuilderAPI_MakeEdge.hxx>
#include <BRepBuilderAPI_MakeWire.hxx>
#include <BRepBuilderAPI_MakeVertex.hxx>
+#include <BRepBuilderAPI_Sewing.hxx>
#include <BRepBuilderAPI_Transform.hxx>
+#include <BRepCheck_Shell.hxx>
+#include <BRepClass3d_SolidClassifier.hxx>
#include <BRep_Tool.hxx>
#include <TopAbs.hxx>
#include <TopExp.hxx>
+#include <TopExp_Explorer.hxx>
#include <TopoDS.hxx>
-#include <TopoDS_Shape.hxx>
+#include <TopoDS_Compound.hxx>
#include <TopoDS_Edge.hxx>
+#include <TopoDS_Shape.hxx>
+#include <TopoDS_Shell.hxx>
+#include <TopoDS_Solid.hxx>
#include <TopoDS_Vertex.hxx>
#include <TopTools_HSequenceOfShape.hxx>
#include <TopTools_IndexedDataMapOfShapeListOfShape.hxx>
//=======================================================================
TopoDS_Shape GEOMImpl_PrismDriver::MakeScaledPrism (const TopoDS_Shape& theShapeBase,
const gp_Vec& theVector,
- const Standard_Real theScaleFactor)
+ const Standard_Real theScaleFactor,
+ const gp_Pnt& theCDG,
+ bool isCDG)
{
TopoDS_Shape aShape;
+ BRep_Builder B;
// 1. aCDG = geompy.MakeCDG(theBase)
- gp_Ax3 aPos = GEOMImpl_IMeasureOperations::GetPosition(theShapeBase);
- gp_Pnt aCDG = aPos.Location();
+ gp_Pnt aCDG = theCDG;
+ if (!isCDG) {
+ gp_Ax3 aPos = GEOMImpl_IMeasureOperations::GetPosition(theShapeBase);
+ aCDG = aPos.Location();
+ }
TopoDS_Shape aShapeCDG_1 = BRepBuilderAPI_MakeVertex(aCDG).Shape();
+ // Process case of several given shapes
+ if (theShapeBase.ShapeType() == TopAbs_COMPOUND ||
+ theShapeBase.ShapeType() == TopAbs_SHELL) {
+ int nbSub = 0;
+ TopoDS_Shape aShapeI;
+ TopoDS_Compound aCompound;
+ B.MakeCompound(aCompound);
+ TopoDS_Iterator It (theShapeBase, Standard_True, Standard_True);
+ for (; It.More(); It.Next()) {
+ nbSub++;
+ aShapeI = MakeScaledPrism(It.Value(), theVector, theScaleFactor, aCDG, true);
+ B.Add(aCompound, aShapeI);
+ }
+ if (nbSub == 1)
+ aShape = aShapeI;
+ else if (nbSub > 1)
+ aShape = GEOMImpl_GlueDriver::GlueFaces(aCompound, Precision::Confusion(), Standard_True);
+ return aShape;
+ }
+
// 2. Scale = geompy.MakeScaleTransform(theBase, aCDG, theScaleFactor)
// Bug 6839: Check for standalone (not included in faces) degenerated edges
aLocs->Append(aShapeCDG_2);
aShape = GEOMImpl_PipeDriver::CreatePipeWithDifferentSections(aWirePath, aBases, aLocs, false, false);
+
+ // 7. Make a solid, if possible
+ if (theShapeBase.ShapeType() == TopAbs_FACE) {
+ BRepBuilderAPI_Sewing aSewing (Precision::Confusion()*10.0);
+ TopExp_Explorer expF (aShape, TopAbs_FACE);
+ Standard_Integer ifa = 0;
+ for (; expF.More(); expF.Next()) {
+ aSewing.Add(expF.Current());
+ ifa++;
+ }
+ if (ifa > 0) {
+ aSewing.Perform();
+ TopoDS_Shape aShell;
+
+ TopoDS_Shape sh = aSewing.SewedShape();
+ if (sh.ShapeType() == TopAbs_FACE && ifa == 1) {
+ // case for creation of shell from one face
+ TopoDS_Shell ss;
+ B.MakeShell(ss);
+ B.Add(ss,sh);
+ aShell = ss;
+ }
+ else {
+ TopExp_Explorer exp (sh, TopAbs_SHELL);
+ Standard_Integer ish = 0;
+ for (; exp.More(); exp.Next()) {
+ aShell = exp.Current();
+ ish++;
+ }
+ if (ish != 1)
+ aShell = sh;
+ }
+ BRepCheck_Shell chkShell (TopoDS::Shell(aShell));
+ if (chkShell.Closed() == BRepCheck_NoError) {
+ TopoDS_Solid Sol;
+ B.MakeSolid(Sol);
+ B.Add(Sol, aShell);
+ BRepClass3d_SolidClassifier SC (Sol);
+ SC.PerformInfinitePoint(Precision::Confusion());
+ if (SC.State() == TopAbs_IN) {
+ B.MakeSolid(Sol);
+ B.Add(Sol, aShell.Reversed());
+ }
+ aShape = Sol;
+ }
+ }
+ }
+
return aShape;
}
Standard_EXPORT static TopoDS_Shape MakeScaledPrism (const TopoDS_Shape& theShapeBase,
const gp_Vec& theVector,
- const Standard_Real theScaleFactor);
+ const Standard_Real theScaleFactor,
+ const gp_Pnt& theCDG = gp::Origin(),
+ bool isCDG = false);
// Type management