const std::list<std::string>& theArguments,
std::string& theError) const
{
- GeomValidators_BodyShapes aBodyValidator;
- if(aBodyValidator.isValid(theAttribute, theArguments, theError)) {
- return true;
- }
+ std::string anAttributeType = theAttribute->attributeType();
+ if(anAttributeType == ModelAPI_AttributeSelectionList::typeId()) {
+ AttributeSelectionListPtr aSelectionListAttr =
+ std::dynamic_pointer_cast<ModelAPI_AttributeSelectionList>(theAttribute);
- GeomValidators_FeatureKind aFeatureKindValidator;
- if(aFeatureKindValidator.isValid(theAttribute, theArguments, theError)) {
- return true;
+ for(int anIndex = 0; anIndex < aSelectionListAttr->size(); ++anIndex) {
+ AttributeSelectionPtr aSelectAttr = aSelectionListAttr->value(anIndex);
+
+ GeomValidators_BodyShapes aBodyValidator;
+ if(aBodyValidator.isValid(aSelectAttr, theArguments, theError)) {
+ continue;
+ }
+
+ GeomValidators_FeatureKind aFeatureKindValidator;
+ if(aFeatureKindValidator.isValid(aSelectAttr, theArguments, theError)) {
+ continue;
+ }
+
+ theError = "Only body shapes and construction planes are allowed for selection.";
+ return false;
+ }
+ } else {
+ theError = "This validator supports only " + ModelAPI_AttributeSelectionList::typeId() + " attribute type.";
+ return false;
}
- theError = "Only body shapes and construction planes are allowed for selection.";
- return false;
+ return true;
}
aSession.startOperation()
aPartitionFt = aPart.addFeature("Partition")
assert (aPartitionFt.getKind() == "Partition")
-aPartitionFt.selectionList("main_objects").append(anExtrusionResult, anExtrusionResult.shape())
-aPartitionFt.selectionList("tool_objects").append(aPlaneResult, None)
-aPartitionFt.boolean("partition_combine").setValue(True)
+aPartitionFt.selectionList("base_objects").append(anExtrusionResult, anExtrusionResult.shape())
+aPartitionFt.selectionList("base_objects").append(aPlaneResult, None)
aPartitionFt.execute()
aSession.finishOperation()
aSession.startOperation()
aPartitionFt = aPart.addFeature("Partition")
assert (aPartitionFt.getKind() == "Partition")
-aPartitionFt.selectionList("main_objects").append(anExtrusionResult, anExtrusionResult.shape())
-aPartitionFt.selectionList("tool_objects").append(aPlaneResult, None)
-aPartitionFt.boolean("partition_combine").setValue(False)
+aPartitionFt.selectionList("base_objects").append(anExtrusionResult, anExtrusionResult.shape())
+aPartitionFt.selectionList("base_objects").append(aPlaneResult, None)
aPartitionFt.execute()
aSession.finishOperation()
tooltip="Select objects for partitioning."
type_choice="objects"
concealment="true">
- <validator id="FeaturesPlugin_ValidatorPartitionSelection"/>
+ <validator id="FeaturesPlugin_ValidatorPartitionSelection" parameters="Plane"/>
</multi_selector>
- <!--<validator id="GeomValidators_PartitionArguments" parameters="main_objects,tool_objects,partition_combine"/>-->
</source>
#include <TopoDS.hxx>
#include <TopExp_Explorer.hxx>
-namespace GeomAlgoAPI_ShapeTools {
//==================================================================================================
-double volume(const std::shared_ptr<GeomAPI_Shape> theShape)
+double GeomAlgoAPI_ShapeTools::volume(const std::shared_ptr<GeomAPI_Shape> theShape)
{
GProp_GProps aGProps;
if(!theShape.get()) {
}
//==================================================================================================
-std::shared_ptr<GeomAPI_Pnt> centreOfMass(const std::shared_ptr<GeomAPI_Shape> theShape)
+std::shared_ptr<GeomAPI_Pnt> GeomAlgoAPI_ShapeTools::centreOfMass(const std::shared_ptr<GeomAPI_Shape> theShape)
{
GProp_GProps aGProps;
if(!theShape) {
}
//==================================================================================================
-std::shared_ptr<GeomAPI_Shape> combineShapes(const std::shared_ptr<GeomAPI_Shape> theCompound,
- const GeomAPI_Shape::ShapeType theType,
- ListOfShape& theCombinedShapes,
- ListOfShape& theFreeShapes)
+std::shared_ptr<GeomAPI_Shape> GeomAlgoAPI_ShapeTools::combineShapes(const std::shared_ptr<GeomAPI_Shape> theCompound,
+ const GeomAPI_Shape::ShapeType theType,
+ ListOfShape& theCombinedShapes,
+ ListOfShape& theFreeShapes)
{
GeomShapePtr aResult = theCompound;
}
//==================================================================================================
-std::shared_ptr<GeomAPI_Shape> groupSharedTopology(const std::shared_ptr<GeomAPI_Shape> theCompound)
+std::shared_ptr<GeomAPI_Shape> GeomAlgoAPI_ShapeTools::groupSharedTopology(const std::shared_ptr<GeomAPI_Shape> theCompound)
{
GeomShapePtr aResult = theCompound;
}
//==================================================================================================
-std::list<std::shared_ptr<GeomAPI_Pnt> > getBoundingBox(const ListOfShape& theShapes, const double theEnlarge)
+std::list<std::shared_ptr<GeomAPI_Pnt> > GeomAlgoAPI_ShapeTools::getBoundingBox(const ListOfShape& theShapes, const double theEnlarge)
{
// Bounding box of all objects.
Bnd_Box aBndBox;
}
//==================================================================================================
-std::shared_ptr<GeomAPI_Shape> faceToInfinitePlane(const std::shared_ptr<GeomAPI_Shape> theFace)
+std::shared_ptr<GeomAPI_Shape> GeomAlgoAPI_ShapeTools::faceToInfinitePlane(const std::shared_ptr<GeomAPI_Shape> theFace)
{
if (!theFace.get())
return std::shared_ptr<GeomAPI_Shape>();
}
//==================================================================================================
-std::shared_ptr<GeomAPI_Shape> fitPlaneToBox(const std::shared_ptr<GeomAPI_Shape> thePlane,
- const std::list<std::shared_ptr<GeomAPI_Pnt> >& thePoints)
+std::shared_ptr<GeomAPI_Shape> GeomAlgoAPI_ShapeTools::fitPlaneToBox(const std::shared_ptr<GeomAPI_Shape> thePlane,
+ const std::list<std::shared_ptr<GeomAPI_Pnt> >& thePoints)
{
std::shared_ptr<GeomAPI_Shape> aResultShape;
}
//==================================================================================================
-void findBounds(const std::shared_ptr<GeomAPI_Shape> theShape,
- std::shared_ptr<GeomAPI_Vertex>& theV1,
- std::shared_ptr<GeomAPI_Vertex>& theV2)
+void GeomAlgoAPI_ShapeTools::findBounds(const std::shared_ptr<GeomAPI_Shape> theShape,
+ std::shared_ptr<GeomAPI_Vertex>& theV1,
+ std::shared_ptr<GeomAPI_Vertex>& theV2)
{
if(!theShape.get()) {
std::shared_ptr<GeomAPI_Vertex> aVertex(new GeomAPI_Vertex);
}
//==================================================================================================
-void makeFacesWithHoles(const std::shared_ptr<GeomAPI_Pnt> theOrigin,
- const std::shared_ptr<GeomAPI_Dir> theDirection,
- const ListOfShape& theWires,
- ListOfShape& theFaces)
+void GeomAlgoAPI_ShapeTools::makeFacesWithHoles(const std::shared_ptr<GeomAPI_Pnt> theOrigin,
+ const std::shared_ptr<GeomAPI_Dir> theDirection,
+ const ListOfShape& theWires,
+ ListOfShape& theFaces)
{
BRepBuilderAPI_MakeFace aMKFace(gp_Pln(theOrigin->impl<gp_Pnt>(),
theDirection->impl<gp_Dir>()));
}
//==================================================================================================
-std::shared_ptr<GeomAPI_Pln> findPlane(const ListOfShape& theShapes)
+std::shared_ptr<GeomAPI_Pln> GeomAlgoAPI_ShapeTools::findPlane(const ListOfShape& theShapes)
{
TopoDS_Compound aCompound;
BRep_Builder aBuilder;
}
//==================================================================================================
-bool isSubShapeInsideShape(const std::shared_ptr<GeomAPI_Shape> theSubShape,
- const std::shared_ptr<GeomAPI_Shape> theBaseShape)
+bool GeomAlgoAPI_ShapeTools::isSubShapeInsideShape(const std::shared_ptr<GeomAPI_Shape> theSubShape,
+ const std::shared_ptr<GeomAPI_Shape> theBaseShape)
{
if(!theSubShape.get() || !theBaseShape.get()) {
return false;
return true;
}
-} //namespace GeomAlgoAPI_ShapeTools
class GeomAPI_Pln;
class GeomAPI_Pnt;
-/// \namespace GeomAlgoAPI_ShapeTools
+/// \class GeomAlgoAPI_ShapeTools
/// \ingroup DataAlgo
/// \brief Useful tools for working with shapes.
-namespace GeomAlgoAPI_ShapeTools
+class GeomAlgoAPI_ShapeTools
{
+public:
/// \return the total volume of the solids of the current shape or 0.0 if it can be computed.
- GEOMALGOAPI_EXPORT double volume(const std::shared_ptr<GeomAPI_Shape> theShape);
+ GEOMALGOAPI_EXPORT static double volume(const std::shared_ptr<GeomAPI_Shape> theShape);
/// \return the centre of mass of the current face. The coordinates returned for the center of mass
/// are expressed in the absolute Cartesian coordinate system. (This function works only for surfaces).
- GEOMALGOAPI_EXPORT std::shared_ptr<GeomAPI_Pnt> centreOfMass(const std::shared_ptr<GeomAPI_Shape> theShape);
+ GEOMALGOAPI_EXPORT static std::shared_ptr<GeomAPI_Pnt> centreOfMass(const std::shared_ptr<GeomAPI_Shape> theShape);
/// \brief Combines faces with common edges to shells, or solids to compsolids.
/// \param[in] theCompound compound of shapes.
/// \param[in] theType type of combine.
/// \param[out] theCombinedShapes resulting shapes.
/// \param[out] theFreeShapes shapes that does not have common subshapes.
- GEOMALGOAPI_EXPORT std::shared_ptr<GeomAPI_Shape> combineShapes(const std::shared_ptr<GeomAPI_Shape> theCompound,
- const GeomAPI_Shape::ShapeType theType,
- ListOfShape& theCombinedShapes,
- ListOfShape& theFreeShapes);
+ GEOMALGOAPI_EXPORT static std::shared_ptr<GeomAPI_Shape> combineShapes(const std::shared_ptr<GeomAPI_Shape> theCompound,
+ const GeomAPI_Shape::ShapeType theType,
+ ListOfShape& theCombinedShapes,
+ ListOfShape& theFreeShapes);
/// \brief Groups shapes with shared topology to compounds.
/// \param[in] theCompound compound of shapes.
/// \return compound of compounds with shared topology.
- GEOMALGOAPI_EXPORT std::shared_ptr<GeomAPI_Shape> groupSharedTopology(const std::shared_ptr<GeomAPI_Shape> theCompound);
+ GEOMALGOAPI_EXPORT static std::shared_ptr<GeomAPI_Shape> groupSharedTopology(const std::shared_ptr<GeomAPI_Shape> theCompound);
/// \brief Calculates bounding box for theShapes
/// \return list of eight points.
/// \param[in] theShapes list of shapes.
/// \param[in] theEnlarge enlarges bounding box size.
- GEOMALGOAPI_EXPORT std::list<std::shared_ptr<GeomAPI_Pnt> > getBoundingBox(const ListOfShape& theShapes, const double theEnlarge = 0.0);
+ GEOMALGOAPI_EXPORT static std::list<std::shared_ptr<GeomAPI_Pnt> > getBoundingBox(const ListOfShape& theShapes, const double theEnlarge = 0.0);
/// \return infinite plane received from theFace plane.
- GEOMALGOAPI_EXPORT std::shared_ptr<GeomAPI_Shape> faceToInfinitePlane(const std::shared_ptr<GeomAPI_Shape> theFace);
+ GEOMALGOAPI_EXPORT static std::shared_ptr<GeomAPI_Shape> faceToInfinitePlane(const std::shared_ptr<GeomAPI_Shape> theFace);
/// \brief Enlarges or reduces plane to fit bounding box.
/// \return plane that fits to bounding box.
/// \param[in] thePlane base plane.
/// \param[in] thePoints bounding box points (shoud be eight).
- GEOMALGOAPI_EXPORT std::shared_ptr<GeomAPI_Shape> fitPlaneToBox(const std::shared_ptr<GeomAPI_Shape> thePlane,
- const std::list<std::shared_ptr<GeomAPI_Pnt> >& thePoints);
+ GEOMALGOAPI_EXPORT static std::shared_ptr<GeomAPI_Shape> fitPlaneToBox(const std::shared_ptr<GeomAPI_Shape> thePlane,
+ const std::list<std::shared_ptr<GeomAPI_Pnt> >& thePoints);
/// \brief Finds the start and end vertices of theShape. theShape can be of the following type:\n
/// Vertex: theV1 and theV2 are the same and equal to theShape;\n
/// Wire : theV1 is start vertex of the first edge, theV2 is end vertex of the last edge. If wire
/// contains no edges theV1 and theV2 are nullified.\n
/// If none of the above theV1 and theV2 are nullified.
- GEOMALGOAPI_EXPORT void findBounds(const std::shared_ptr<GeomAPI_Shape> theShape,
- std::shared_ptr<GeomAPI_Vertex>& theV1,
- std::shared_ptr<GeomAPI_Vertex>& theV2);
+ GEOMALGOAPI_EXPORT static void findBounds(const std::shared_ptr<GeomAPI_Shape> theShape,
+ std::shared_ptr<GeomAPI_Vertex>& theV1,
+ std::shared_ptr<GeomAPI_Vertex>& theV2);
/// \brief Creates faces with holes from wires.
/// \param[in] theWires base wires.
/// \param[out] theFaces resulting faces.
- GEOMALGOAPI_EXPORT void makeFacesWithHoles(const std::shared_ptr<GeomAPI_Pnt> theOrigin,
- const std::shared_ptr<GeomAPI_Dir> theDirection,
- const ListOfShape& theWires,
- ListOfShape& theFaces);
+ GEOMALGOAPI_EXPORT static void makeFacesWithHoles(const std::shared_ptr<GeomAPI_Pnt> theOrigin,
+ const std::shared_ptr<GeomAPI_Dir> theDirection,
+ const ListOfShape& theWires,
+ ListOfShape& theFaces);
/// \brief Return a plane for list of shapes if they are all planar.
/// \param[in] theShapes shapes to find plane.
/// \return plane where all shapes lie or empty ptr if they not planar.
- GEOMALGOAPI_EXPORT std::shared_ptr<GeomAPI_Pln> findPlane(const ListOfShape& theShapes);
+ GEOMALGOAPI_EXPORT static std::shared_ptr<GeomAPI_Pln> findPlane(const ListOfShape& theShapes);
/// \brief Checks that vertex/edge is inside face or vertext inside wire.
/// \param[in] theSubShape shape that should be inside.
/// \param[in] theBaseShape base shape.
/// \return true if edge inside the face.
- GEOMALGOAPI_EXPORT bool isSubShapeInsideShape(const std::shared_ptr<GeomAPI_Shape> theSubShape,
- const std::shared_ptr<GeomAPI_Shape> theBaseShape);
+ GEOMALGOAPI_EXPORT static bool isSubShapeInsideShape(const std::shared_ptr<GeomAPI_Shape> theSubShape,
+ const std::shared_ptr<GeomAPI_Shape> theBaseShape);
};
#endif