#include <BuildPlugin_Wire.h>
#include <BuildPlugin_Face.h>
#include <BuildPlugin_Shell.h>
+#include <BuildPlugin_SubShapes.h>
#include <BuildPlugin_Validators.h>
// the only created instance of this plugin
new BuildPlugin_ValidatorBaseForWire());
aFactory->registerValidator("BuildPlugin_ValidatorBaseForFace",
new BuildPlugin_ValidatorBaseForFace());
+ aFactory->registerValidator("BuildPlugin_ValidatorSubShapesSelection",
+ new BuildPlugin_ValidatorSubShapesSelection());
// Register this plugin.
ModelAPI_Session::get()->registerPlugin(this);
return FeaturePtr(new BuildPlugin_Face());
} else if(theFeatureID == BuildPlugin_Shell::ID()) {
return FeaturePtr(new BuildPlugin_Shell());
+ } else if(theFeatureID == BuildPlugin_SubShapes::ID()) {
+ return FeaturePtr(new BuildPlugin_SubShapes());
}
// Feature of such kind is not found.
--- /dev/null
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
+// File: BuildPlugin_SubShapes.cpp
+// Created: 14 April 2016
+// Author: Dmitry Bobylev
+
+#include "BuildPlugin_SubShapes.h"
+
+#include <ModelAPI_AttributeSelectionList.h>
+#include <ModelAPI_ResultBody.h>
+#include <ModelAPI_ResultConstruction.h>
+#include <ModelAPI_Session.h>
+#include <ModelAPI_Validator.h>
+
+#include <GeomAPI_Edge.h>
+#include <GeomAPI_ShapeIterator.h>
+#include <GeomAPI_Wire.h>
+
+#include <GeomAlgoAPI_ShapeBuilder.h>
+
+//==================================================================================================
+BuildPlugin_SubShapes::BuildPlugin_SubShapes()
+{
+}
+
+//==================================================================================================
+void BuildPlugin_SubShapes::initAttributes()
+{
+ data()->addAttribute(BASE_SHAPE_ID(), ModelAPI_AttributeSelection::typeId());
+
+ data()->addAttribute(SUB_SHAPES_ID(), ModelAPI_AttributeSelectionList::typeId());
+ ModelAPI_Session::get()->validators()->registerNotObligatory(getKind(), SUB_SHAPES_ID());
+}
+
+void BuildPlugin_SubShapes::attributeChanged(const std::string& theID)
+{
+ ModelAPI_Feature::attributeChanged(theID);
+
+ if(theID == BASE_SHAPE_ID()) {
+ AttributeSelectionPtr aShapeAttrSelection = selection(BASE_SHAPE_ID());
+ AttributeSelectionListPtr aSubShapesAttrList = selectionList(SUB_SHAPES_ID());
+ if(!aShapeAttrSelection.get() || !aSubShapesAttrList.get()) {
+ return;
+ }
+ ResultPtr aContext = aShapeAttrSelection->context();
+
+ aSubShapesAttrList->clear();
+
+ GeomShapePtr aBaseShape = aShapeAttrSelection->value();
+ if(!aBaseShape.get()) {
+ return;
+ }
+ GeomAPI_Shape::ShapeType aBaseShapeType = aBaseShape->shapeType();
+ for(GeomAPI_ShapeIterator anIt(aBaseShape); anIt.more(); anIt.next()) {
+ GeomShapePtr aSubShape = anIt.current();
+ if(aBaseShapeType == GeomAPI_Shape::WIRE) {
+ for(GeomAPI_ShapeIterator aSubIt(aSubShape); aSubIt.more(); aSubIt.next()) {
+ GeomShapePtr aSubOfSubShape = aSubIt.current();
+ if(aSubOfSubShape->orientation() == GeomAPI_Shape::INTERNAL) {
+ aSubShapesAttrList->append(aContext, aSubOfSubShape);
+ }
+ }
+ } else if(aBaseShapeType == GeomAPI_Shape::FACE) {
+ if(aSubShape->shapeType() != GeomAPI_Shape::WIRE) {
+ aSubShapesAttrList->append(aContext, aSubShape);
+ } else if(aSubShape->orientation() == GeomAPI_Shape::INTERNAL) {
+ if(aSubShape->shapeType() == GeomAPI_Shape::WIRE) {
+ for(GeomAPI_ShapeIterator aWireIt(aSubShape); aWireIt.more(); aWireIt.next()) {
+ aSubShapesAttrList->append(aContext, aWireIt.current());
+ }
+ }
+ }
+ }
+ }
+ }
+}
+
+//==================================================================================================
+void BuildPlugin_SubShapes::execute()
+{
+ // Get base shape and sub-shapes list.
+ AttributeSelectionPtr aShapeAttrSelection = selection(BASE_SHAPE_ID());
+ AttributeSelectionListPtr aSubShapesAttrList = selectionList(SUB_SHAPES_ID());
+ if(!aShapeAttrSelection.get() || !aSubShapesAttrList.get()) {
+ return;
+ }
+
+ // Get base shape without internal shapes.
+ GeomShapePtr aBaseShape = aShapeAttrSelection->value();
+ if(!aBaseShape.get()) {
+ return;
+ }
+ GeomAlgoAPI_ShapeBuilder aBuilder;
+ aBuilder.removeInternal(aBaseShape);
+ GeomShapePtr aResultShape = aBuilder.shape();
+
+ // Get list of shapes.
+ ListOfShape aShapesToAdd;
+ for(int anIndex = 0; anIndex < aSubShapesAttrList->size(); ++anIndex) {
+ AttributeSelectionPtr anAttrSelectionInList = aSubShapesAttrList->value(anIndex);
+ aShapesToAdd.push_back(anAttrSelectionInList->value());
+ }
+
+ // Copy sub-shapes from list to new shape.
+ if(!aShapesToAdd.empty()) {
+ aBuilder.add(aResultShape, aShapesToAdd);
+ aResultShape = aBuilder.shape();
+ }
+
+ // Store result.
+ ResultBodyPtr aResultBody = document()->createBody(data());
+ aResultBody->storeModified(aBaseShape, aResultShape);
+ aResultBody->loadAndOrientModifiedShapes(&aBuilder, aBaseShape, GeomAPI_Shape::EDGE, 1,
+ "Modified_Edge", *aBuilder.mapOfSubShapes().get());
+ for(ListOfShape::const_iterator anIt = aShapesToAdd.cbegin(); anIt != aShapesToAdd.cend(); ++anIt) {
+ GeomAPI_Shape::ShapeType aShType = (*anIt)->shapeType();
+ aResultBody->loadAndOrientModifiedShapes(&aBuilder, *anIt, aShType, 1,
+ aShType == GeomAPI_Shape::VERTEX ? "Modified_Vertex" : "Modified_Edge",
+ *aBuilder.mapOfSubShapes().get());
+ }
+ setResult(aResultBody);
+}
--- /dev/null
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
+// File: BuildPlugin_SubShapes.h
+// Created: 14 April 2016
+// Author: Dmitry Bobylev
+
+#ifndef BuildPlugin_SubShapes_H_
+#define BuildPlugin_SubShapes_H_
+
+#include "BuildPlugin.h"
+
+#include <ModelAPI_Feature.h>
+
+/// \class BuildPlugin_SubShapes
+/// \ingroup Plugins
+/// \brief Feature for adding or removing sub-shapes from shape.
+class BuildPlugin_SubShapes: public ModelAPI_Feature
+{
+public:
+ /// Use plugin manager for features creation
+ BuildPlugin_SubShapes();
+
+ /// Feature kind.
+ inline static const std::string& ID()
+ {
+ static const std::string MY_ID("SubShapes");
+ return MY_ID;
+ }
+
+ /// Attribute name of base shape.
+ inline static const std::string& BASE_SHAPE_ID()
+ {
+ static const std::string MY_BASE_SHAPE_ID("base_shape");
+ return MY_BASE_SHAPE_ID;
+ }
+
+ /// Attribute name of sub-shapes.
+ inline static const std::string& SUB_SHAPES_ID()
+ {
+ static const std::string MY_SUB_SHAPES_ID("sub_shapes");
+ return MY_SUB_SHAPES_ID;
+ }
+
+ /// \return the kind of a feature.
+ BUILDPLUGIN_EXPORT virtual const std::string& getKind()
+ {
+ static std::string MY_KIND = BuildPlugin_SubShapes::ID();
+ return MY_KIND;
+ }
+
+ /// Request for initialization of data model of the feature: adding all attributes.
+ BUILDPLUGIN_EXPORT virtual void initAttributes();
+
+ /// Called on change of any argument-attribute of this object.
+ /// \param[in] theID identifier of changed attribute.
+ BUILDPLUGIN_EXPORT virtual void attributeChanged(const std::string& theID);
+
+ /// Creates a new part document if needed.
+ BUILDPLUGIN_EXPORT virtual void execute();
+};
+
+#endif
#include <GeomAlgoAPI_SketchBuilder.h>
#include <GeomAlgoAPI_WireBuilder.h>
+#include <GeomValidators_FeatureKind.h>
#include <GeomValidators_ShapeType.h>
#include <Events_Error.h>
{
// Get base objects list.
if(theAttribute->attributeType() != ModelAPI_AttributeSelectionList::typeId()) {
- Events_Error::send("Error: BuildPlugin_ValidatorBaseForBuild does not support attribute type \"" + theAttribute->attributeType()
- + "\"\n Only \"" + ModelAPI_AttributeSelectionList::typeId() + "\" supported.");
+ Events_Error::send("Error: BuildPlugin_ValidatorBaseForBuild does not support attribute type \""
+ + theAttribute->attributeType() + "\"\n Only \"" + ModelAPI_AttributeSelectionList::typeId()
+ + "\" supported.");
return false;
}
- AttributeSelectionListPtr aSelectionList = std::dynamic_pointer_cast<ModelAPI_AttributeSelectionList>(theAttribute);
+ AttributeSelectionListPtr aSelectionList =
+ std::dynamic_pointer_cast<ModelAPI_AttributeSelectionList>(theAttribute);
if(!aSelectionList.get()) {
theError = "Could not get selection list.";
return false;
{
// Get attribute.
if(theArguments.size() != 1) {
- Events_Error::send("Error: BuildPlugin_ValidatorBaseForWire should be used only with 1 parameter (ID of base objects list).");
+ Events_Error::send("Error: BuildPlugin_ValidatorBaseForWire should be used only with "
+ "1 parameter (ID of base objects list).");
return false;
}
AttributeSelectionListPtr aSelectionList = theFeature->selectionList(theArguments.front());
{
// Get attribute.
if(theArguments.size() != 1) {
- Events_Error::send("Error: BuildPlugin_ValidatorBaseForFace should be used only with 1 parameter (ID of base objects list).");
+ Events_Error::send("Error: BuildPlugin_ValidatorBaseForFace should be used only with "
+ "1 parameter (ID of base objects list).");
return false;
}
AttributeSelectionListPtr aSelectionList = theFeature->selectionList(theArguments.front());
{
return false;
}
+
+//=================================================================================================
+bool BuildPlugin_ValidatorSubShapesSelection::isValid(const AttributePtr& theAttribute,
+ const std::list<std::string>& theArguments,
+ std::string& theError) const
+{
+ if(theArguments.size() != 2) {
+ Events_Error::send("Error: BuildPlugin_ValidatorSubShapesSelection should be used only with "
+ "2 parameters (ID of base shape; Sketch feature id).");
+ return false;
+ }
+
+ // Get base objects list.
+ if(theAttribute->attributeType() != ModelAPI_AttributeSelectionList::typeId()) {
+ Events_Error::send("Error: BuildPlugin_ValidatorSubShapesSelection does not support attribute type \""
+ + theAttribute->attributeType() + "\"\n Only \"" + ModelAPI_AttributeSelectionList::typeId()
+ + "\" supported.");
+ return false;
+ }
+ AttributeSelectionListPtr aSelectionList =
+ std::dynamic_pointer_cast<ModelAPI_AttributeSelectionList>(theAttribute);
+ if(!aSelectionList.get()) {
+ theError = "Could not get selection list.";
+ return false;
+ }
+
+ // Get base shape.
+ FeaturePtr aFeature = ModelAPI_Feature::feature(theAttribute->owner());
+ AttributeSelectionPtr aShapeAttrSelection = aFeature->selection(theArguments.front());
+
+ if(!aShapeAttrSelection.get()) {
+ theError = "Base shape is empty.";
+ return false;
+ }
+
+ ResultPtr aBaseContext = aShapeAttrSelection->context();
+
+ GeomShapePtr aBaseShape = aShapeAttrSelection->value();
+ if(!aBaseShape.get()) {
+ theError = "Base shape is empty.";
+ return false;
+ }
+
+ // If selected shape is wire allow to select only vertices. If face - allow vertices and edges.
+ std::set<GeomAPI_Shape::ShapeType> anAllowedTypes;
+ switch(aBaseShape->shapeType()) {
+ case GeomAPI_Shape::FACE: anAllowedTypes.insert(GeomAPI_Shape::EDGE);
+ case GeomAPI_Shape::WIRE: anAllowedTypes.insert(GeomAPI_Shape::VERTEX);
+ default: break;
+ }
+
+ // Check selected shapes.
+ GeomValidators_FeatureKind aFeatureKindValidator;
+ std::list<std::string> anArguments;
+ anArguments.push_back(theArguments.back());
+ for(int anIndex = 0; anIndex < aSelectionList->size(); ++anIndex) {
+ AttributeSelectionPtr aSelectionAttrInList = aSelectionList->value(anIndex);
+ if(!aSelectionAttrInList.get()) {
+ theError = "Empty attribute in list.";
+ return false;
+ }
+ // If context not same check that it is a selection on Sketch.
+ if(aBaseContext != aSelectionAttrInList->context()) {
+ if(!aFeatureKindValidator.isValid(aSelectionAttrInList, anArguments, theError)) {
+ return false;
+ }
+ }
+
+ // Check shape type.
+ GeomShapePtr aShapeInList = aSelectionAttrInList->value();
+ if(!aShapeInList.get()) {
+ aShapeInList = aSelectionAttrInList->context()->shape();
+ }
+ if(anAllowedTypes.find(aShapeInList->shapeType()) == anAllowedTypes.cend()) {
+ theError = "Selected shape has unacceptable type.";
+ return false;
+ }
+
+ // Check that shape inside wire or face.
+ if(!GeomAlgoAPI_ShapeTools::isSubShapeInShape(aShapeInList, aBaseShape)) {
+ theError = "Selected shape is not inside base face.";
+ return false;
+ }
+ }
+
+ return true;
+}
virtual bool isNotObligatory(std::string theFeature, std::string theAttribute);
};
+/// \class BuildPlugin_ValidatorSubShapesSelection
+/// \ingroup Validators
+/// \brief A validator for selection sub-shapes for SubShape feature.
+class BuildPlugin_ValidatorSubShapesSelection: public ModelAPI_AttributeValidator
+{
+public:
+ //! Returns true if attribute is ok.
+ //! \param[in] theAttribute the checked attribute.
+ //! \param[in] theArguments arguments of the attribute.
+ //! \param[out] theError error message.
+ virtual bool isValid(const AttributePtr& theAttribute,
+ const std::list<std::string>& theArguments,
+ std::string& theError) const;
+};
+
#endif
BuildPlugin_Wire.h
BuildPlugin_Face.h
BuildPlugin_Shell.h
+ BuildPlugin_SubShapes.h
BuildPlugin_Validators.h
)
BuildPlugin_Wire.cpp
BuildPlugin_Face.cpp
BuildPlugin_Shell.cpp
+ BuildPlugin_SubShapes.cpp
BuildPlugin_Validators.cpp
)
wire_widget.xml
face_widget.xml
shell_widget.xml
+ subshapes_widget.xml
)
SET(PROJECT_LIBRARIES
<multi_selector id="base_objects"
label="Edges:"
tooltip="Select edges on sketch or edges objects."
- type_choice="edges objects">
+ type_choice="edges objects"
+ concealment="true">
<validator id="BuildPlugin_ValidatorBaseForBuild" parameters="edge"/>
</multi_selector>
</source>
<multi_selector id="base_objects"
label="Segments and wires:"
tooltip="Select edges on sketch, edges or wires objects."
- type_choice="edges objects">
+ type_choice="edges objects"
+ concealment="true">
<validator id="BuildPlugin_ValidatorBaseForBuild" parameters="edge,wire"/>
</multi_selector>
<validator id="BuildPlugin_ValidatorBaseForFace" parameters="base_objects"/>
<plugin>
<workbench id="Build" document="Part">
- <group id="Shape">
+ <group id="Generate">
<feature id="Vertex" title="Vertex" tooltip ="Create a vertex from sketch vertex and vertex objects" icon="icons/Build/feature_vertex.png">
<source path="vertex_widget.xml"/>
</feature>
<source path="shell_widget.xml"/>
</feature>
</group>
+ <group id="Modify">
+ <feature id="SubShapes" title="Sub-Shapes" tooltip ="Allows to add or to remove sub-shapes of the selected shape" icon="icons/Build/feature_subshapes.png">
+ <source path="subshapes_widget.xml"/>
+ </feature>
+ </group>
</workbench>
</plugin>
<multi_selector id="base_objects"
label="Faces and shells:"
tooltip="Select faces or shells objects."
- type_choice="objects">
+ type_choice="objects"
+ concealment="true">
<validator id="GeomValidators_ShapeType" parameters="face,shell"/>
</multi_selector>
</source>
--- /dev/null
+<!-- Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
+
+<source>
+ <shape_selector id="base_shape"
+ label="Shape:"
+ tooltip="Select a shape to modify."
+ shape_types="objects"
+ concealment="true">
+ <validator id="GeomValidators_ShapeType" parameters="wire,face"/>
+ </shape_selector>
+ <multi_selector id="sub_shapes"
+ label="Sub-Shapes:"
+ tooltip="Select shapes on sketch to add."
+ type_choice="vertices edges"
+ concealment="true">
+ <validator id="BuildPlugin_ValidatorSubShapesSelection" parameters="base_shape,Sketch"/>
+ </multi_selector>
+</source>
<multi_selector id="base_objects"
label="Vertices:"
tooltip="Select vertices on sketch or vertex objects."
- type_choice="vertices objects">
+ type_choice="vertices objects"
+ concealment="true">
<validator id="BuildPlugin_ValidatorBaseForBuild" parameters="vertex"/>
</multi_selector>
</source>
<multi_selector id="base_objects"
label="Segments and wires:"
tooltip="Select edges on sketch, edges or wires objects."
- type_choice="edges objects">
+ type_choice="edges objects"
+ concealment="true">
<validator id="BuildPlugin_ValidatorBaseForBuild" parameters="edge,wire"/>
</multi_selector>
<action id="add_contour"
GeomAPI_Pln.h
GeomAPI_Shape.h
GeomAPI_ShapeExplorer.h
+ GeomAPI_ShapeIterator.h
GeomAPI_Edge.h
GeomAPI_Face.h
GeomAPI_PlanarEdges.h
GeomAPI_Trsf.h
GeomAPI_Angle.h
GeomAPI_Angle2d.h
+ GeomAPI_Wire.h
)
SET(PROJECT_SOURCES
GeomAPI_Pln.cpp
GeomAPI_Shape.cpp
GeomAPI_ShapeExplorer.cpp
+ GeomAPI_ShapeIterator.cpp
GeomAPI_Edge.cpp
GeomAPI_Face.cpp
GeomAPI_PlanarEdges.cpp
GeomAPI_Trsf.cpp
GeomAPI_Angle.cpp
GeomAPI_Angle2d.cpp
+ GeomAPI_Wire.cpp
)
SET(PROJECT_LIBRARIES
%shared_ptr(GeomAPI_Pnt2d)
%shared_ptr(GeomAPI_Shape)
%shared_ptr(GeomAPI_ShapeExplorer)
+%shared_ptr(GeomAPI_ShapeIterator)
%shared_ptr(GeomAPI_Vertex)
%shared_ptr(GeomAPI_XY)
%shared_ptr(GeomAPI_XYZ)
%shared_ptr(GeomAPI_Trsf)
+%shared_ptr(GeomAPI_Wire)
// all supported interfaces
%include "GeomAPI_Pnt.h"
%include "GeomAPI_Pnt2d.h"
%include "GeomAPI_ShapeExplorer.h"
+%include "GeomAPI_ShapeIterator.h"
%include "GeomAPI_Vertex.h"
%include "GeomAPI_XY.h"
%include "GeomAPI_XYZ.h"
%include "GeomAPI_Trsf.h"
+%include "GeomAPI_Wire.h"
const ListOfShape& theItems)
{
const TopoDS_Shape& aKey = theKey->impl<TopoDS_Shape>();
+ if(MY_MAP->IsBound(aKey)) {
+ MY_MAP->ChangeFind(aKey).Clear();
+ }
for(ListOfShape::const_iterator anIt = theItems.cbegin(); anIt != theItems.cend(); anIt++) {
const TopoDS_Shape& anItem = (*anIt)->impl<TopoDS_Shape>();
if(MY_MAP->IsBound(aKey)) {
return MY_MAP->UnBind(aKey) == Standard_True;
}
+//=================================================================================================
+void GeomAPI_DataMapOfShapeMapOfShapes::clear()
+{
+ return MY_MAP->Clear();
+}
+
//=================================================================================================
int GeomAPI_DataMapOfShapeMapOfShapes::size() const
{
#ifndef GeomAPI_DataMapOfShapeMapOfShapes_H_
#define GeomAPI_DataMapOfShapeMapOfShapes_H_
-#include <GeomAPI_Interface.h>
+#include "GeomAPI_Interface.h"
-#include <GeomAPI_Shape.h>
+#include "GeomAPI_Shape.h"
-/**\class GeomAPI_DataMapOfShapeMapOfShapes
- * \ingroup DataModel
- * \brief DataMap of Shape - Map of Shapes defined by TopoDS_Shapes
- */
+/// \class GeomAPI_DataMapOfShapeMapOfShapes
+/// \ingroup DataModel
+/// \brief DataMap of Shape - Map of Shapes defined by TopoDS_Shapes
class GeomAPI_DataMapOfShapeMapOfShapes : public GeomAPI_Interface
{
public:
/// Constructor.Creates empty map.
GEOMAPI_EXPORT GeomAPI_DataMapOfShapeMapOfShapes();
- /** \brief Binds list of shapes to the key shape.
- \param[in] theKey key shape.
- \param[in] theItems list of shapes. If shapes have duplications in list only one will be stored.
- \returns true if items bound successfully.
- */
+ /// \brief Binds list of shapes to the key shape.
+ /// \param[in] theKey key shape.
+ /// \param[in] theItems list of shapes. If shapes have duplications in list only one will be stored.
+ /// \returns true if items bound successfully.
GEOMAPI_EXPORT bool bind(const std::shared_ptr<GeomAPI_Shape> theKey,
const ListOfShape& theItems);
- /** \brief Adds item to the map bounded to the key.
- \param[in] theKey key shape.
- \param[in] theItem item shape.
- \returns true if item bounded successfully. False if it is already bound.
- */
+ /// \brief Adds item to the map bounded to the key.
+ /// \param[in] theKey key shape.
+ /// \param[in] theItem item shape.
+ /// \returns true if item bounded successfully. False if it is already bound.
GEOMAPI_EXPORT bool add(const std::shared_ptr<GeomAPI_Shape> theKey,
const std::shared_ptr<GeomAPI_Shape> theItem);
/// Undinds shapes from theKey.
GEOMAPI_EXPORT bool unBind(const std::shared_ptr<GeomAPI_Shape> theKey);
+ /// Clears map.
+ GEOMAPI_EXPORT void clear();
+
/// \return size of map.
GEOMAPI_EXPORT int size() const;
};
#include <TopoDS_Shape.hxx>
#include <TopoDS_Edge.hxx>
#include <TopoDS.hxx>
+#include <BRep_Builder.hxx>
#include <BRep_Tool.hxx>
#include <Geom_Curve.hxx>
#include <Geom_Line.hxx>
#include <gp_Pln.hxx>
GeomAPI_Edge::GeomAPI_Edge()
- : GeomAPI_Shape()
{
+ TopoDS_Edge* anEdge = new TopoDS_Edge;
+
+ BRep_Builder aBuilder;
+ aBuilder.MakeEdge(*anEdge);
+
+ setImpl(anEdge);
}
GeomAPI_Edge::GeomAPI_Edge(const std::shared_ptr<GeomAPI_Shape>& theShape)
class GeomAPI_Edge : public GeomAPI_Shape
{
public:
- /// Creation of empty (null) shape
+ /// Makes an undefined Edge (no geometry).
GEOMAPI_EXPORT
GeomAPI_Edge();
{
}
+std::shared_ptr<GeomAPI_Shape> GeomAPI_Shape::emptyCopied() const
+{
+ GeomShapePtr aShape(new GeomAPI_Shape());
+ aShape->setImpl(new TopoDS_Shape(MY_SHAPE->EmptyCopied()));
+ return aShape;
+}
+
bool GeomAPI_Shape::isNull() const
{
return MY_SHAPE->IsNull() == Standard_True;
return aShapeTypeStr;
}
+GeomAPI_Shape::Orientation GeomAPI_Shape::orientation() const
+{
+ TopAbs_Orientation anOrientation = MY_SHAPE->Orientation();
+
+ switch(anOrientation) {
+ case TopAbs_FORWARD: return FORWARD;
+ case TopAbs_REVERSED: return REVERSED;
+ case TopAbs_INTERNAL: return INTERNAL;
+ case TopAbs_EXTERNAL: return EXTERNAL;
+ default: return FORWARD;
+ }
+}
+
+void GeomAPI_Shape::setOrientation(const GeomAPI_Shape::Orientation theOrientation)
+{
+ TopAbs_Orientation anOrientation = MY_SHAPE->Orientation();
+
+ switch(theOrientation) {
+ case FORWARD: MY_SHAPE->Orientation(TopAbs_FORWARD); break;
+ case REVERSED: MY_SHAPE->Orientation(TopAbs_REVERSED); break;
+ case INTERNAL: MY_SHAPE->Orientation(TopAbs_INTERNAL); break;
+ case EXTERNAL: MY_SHAPE->Orientation(TopAbs_EXTERNAL); break;
+ }
+}
+
bool GeomAPI_Shape::isSubShape(const std::shared_ptr<GeomAPI_Shape> theShape) const
{
if(!theShape.get()) {
SHAPE
};
+ /// Shape orientation
+ enum Orientation {
+ FORWARD,
+ REVERSED,
+ INTERNAL,
+ EXTERNAL
+ };
+
public:
/// Creation of empty (null) shape
GEOMAPI_EXPORT
GeomAPI_Shape();
+ /// \return a new Shape with the same Orientation and Location and a new TShape with the same
+ /// geometry and no sub-shapes.
+ GEOMAPI_EXPORT std::shared_ptr<GeomAPI_Shape> emptyCopied() const;
+
/// Returns true if the underlied shape is null
GEOMAPI_EXPORT
bool isNull() const;
GEOMAPI_EXPORT
virtual std::string shapeTypeStr() const;
+ /// \return the shape orientation.
+ GEOMAPI_EXPORT virtual Orientation orientation() const;
+
+ /// Sets the shape orientation.
+ GEOMAPI_EXPORT virtual void setOrientation(const Orientation theOrientation);
+
/// \return true if passed shape is a sub-shape of this shape.
/// \param theShape shape to search.
GEOMAPI_EXPORT virtual bool isSubShape(const std::shared_ptr<GeomAPI_Shape> theShape) const;
-
/// Computes boundary dimensions of the shape
/// Returns False if it is not possible
GEOMAPI_EXPORT
--- /dev/null
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
+// File: GeomAPI_ShapeIterator.cpp
+// Created: 27 April 2016
+// Author: Dmitry Bobylev
+
+#include "GeomAPI_ShapeIterator.h"
+
+#include <Standard_NoMoreObject.hxx>
+#include <TopoDS_Iterator.hxx>
+
+#define MY_ITERATOR implPtr<TopoDS_Iterator>()
+
+//==================================================================================================
+GeomAPI_ShapeIterator::GeomAPI_ShapeIterator()
+: GeomAPI_Interface(new TopoDS_Iterator())
+{
+}
+
+//==================================================================================================
+GeomAPI_ShapeIterator::GeomAPI_ShapeIterator(const std::shared_ptr<GeomAPI_Shape> theShape)
+: GeomAPI_Interface(new TopoDS_Iterator())
+{
+ init(theShape);
+}
+
+//==================================================================================================
+void GeomAPI_ShapeIterator::init(const std::shared_ptr<GeomAPI_Shape> theShape)
+{
+ if(!theShape.get()) {
+ return;
+ }
+ MY_ITERATOR->Initialize(theShape->impl<TopoDS_Shape>());
+}
+
+//==================================================================================================
+bool GeomAPI_ShapeIterator::more() const
+{
+ return MY_ITERATOR->More() == Standard_True;
+}
+
+//==================================================================================================
+void GeomAPI_ShapeIterator::next()
+{
+ try {
+ MY_ITERATOR->Next();
+ } catch (Standard_NoMoreObject) {
+ }
+}
+
+//==================================================================================================
+std::shared_ptr<GeomAPI_Shape> GeomAPI_ShapeIterator::current()
+{
+ try {
+ const TopoDS_Shape& aShape = MY_ITERATOR->Value();
+ std::shared_ptr<GeomAPI_Shape> aGeomShape(new GeomAPI_Shape());
+ aGeomShape->setImpl(new TopoDS_Shape(aShape));
+ return aGeomShape;
+ } catch (Standard_NoMoreObject) {
+ return std::shared_ptr<GeomAPI_Shape>();
+ }
+}
--- /dev/null
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
+// File: GeomAPI_ShapeIterator.h
+// Created: 27 April 2016
+// Author: Dmitry Bobylev
+
+#ifndef GeomAPI_ShapeIterator_H_
+#define GeomAPI_ShapeIterator_H_
+
+#include "GeomAPI.h"
+#include "GeomAPI_Shape.h"
+
+/// \class GeomAPI_ShapeIterator
+/// \ingroup DataModel
+/// \brief Iterates on the underlying shape underlying a given GeomAPI_Shape object, providing access
+/// to its component sub-shapes. Each component shape is returned as a GeomAPI_Shape with
+/// an orientation, and a compound of the original values and the relative values.
+class GeomAPI_ShapeIterator : public GeomAPI_Interface
+{
+public:
+ /// Default constructor. Creates an empty iterator, becomes usefull after Init.
+ GEOMAPI_EXPORT GeomAPI_ShapeIterator();
+
+ /// \brief Creates an iterator on theShape sub-shapes.
+ /// \param[in] theShape shape to iterate.
+ GEOMAPI_EXPORT GeomAPI_ShapeIterator(const std::shared_ptr<GeomAPI_Shape> theShape);
+
+ /// \brief Initializes this iterator with theShape.
+ /// \param[in] theShape shape to iterate.
+ GEOMAPI_EXPORT void init(const std::shared_ptr<GeomAPI_Shape> theShape);
+
+ /// \return true if there is another sub-shape in the shape which this iterator is scanning.
+ GEOMAPI_EXPORT bool more() const;
+
+ /// Moves on to the next sub-shape in the shape which this iterator is scanning.
+ GEOMAPI_EXPORT void next();
+
+ /// \return the current sub-shape in the shape which this iterator is scanning.
+ GEOMAPI_EXPORT std::shared_ptr<GeomAPI_Shape> current();
+};
+
+#endif
\ No newline at end of file
--- /dev/null
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
+// File: GeomAPI_Wire.cpp
+// Created: 28 April 2016
+// Author: Dmitry Bobylev
+
+#include "GeomAPI_Wire.h"
+
+#include <BRep_Builder.hxx>
+#include <TopoDS_Wire.hxx>
+
+//==================================================================================================
+GeomAPI_Wire::GeomAPI_Wire()
+{
+ TopoDS_Wire* aWire = new TopoDS_Wire();
+
+ BRep_Builder aBuilder;
+ aBuilder.MakeWire(*aWire);
+
+ this->setImpl(aWire);
+}
--- /dev/null
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
+// File: GeomAPI_Wire.h
+// Created: 28 April 2016
+// Author: Dmitry Bobylev
+
+#ifndef GeomAPI_Wire_H_
+#define GeomAPI_Wire_H_
+
+#include "GeomAPI_Shape.h"
+
+/// \class GeomAPI_Wire
+/// \ingroup DataModel
+/// \brief Interface to the wire object
+class GeomAPI_Wire: public GeomAPI_Shape
+{
+public:
+ /// Makes an undefined Wire.
+ GEOMAPI_EXPORT GeomAPI_Wire();
+};
+
+#endif
+
#include "GeomAPI_Pnt2d.h"
#include "GeomAPI_Shape.h"
#include "GeomAPI_ShapeExplorer.h"
+ #include "GeomAPI_ShapeIterator.h"
#include "GeomAPI_Vertex.h"
#include "GeomAPI_XY.h"
#include "GeomAPI_XYZ.h"
#include "GeomAPI_Trsf.h"
+ #include "GeomAPI_Wire.h"
#include <memory>
#include <string>
GeomAlgoAPI_Pipe.h
GeomAlgoAPI_WireBuilder.h
GeomAlgoAPI_Sewing.h
+ GeomAlgoAPI_ShapeBuilder.h
)
SET(PROJECT_SOURCES
GeomAlgoAPI_Pipe.cpp
GeomAlgoAPI_WireBuilder.cpp
GeomAlgoAPI_Sewing.cpp
+ GeomAlgoAPI_ShapeBuilder.cpp
)
SET(PROJECT_LIBRARIES
%include "GeomAlgoAPI_Pipe.h"
%include "GeomAlgoAPI_WireBuilder.h"
%include "GeomAlgoAPI_Sewing.h"
+%include "GeomAlgoAPI_ShapeBuilder.h"
%typemap(out) std::list< std::shared_ptr< GeomAPI_Shape > >::value_type & {
$result = SWIG_NewPointerObj(SWIG_as_voidptr(new std::shared_ptr<GeomAPI_Shape>(*$1)), $descriptor(std::shared_ptr<GeomAPI_Shape> *), SWIG_POINTER_OWN | 0 );
TopTools_ListOfShape aList;
if(myBuilderType == OCCT_BRepBuilderAPI_MakeShape) {
BRepBuilderAPI_MakeShape* aMakeShape = implPtr<BRepBuilderAPI_MakeShape>();
- aList = aMakeShape->Modified(theShape->impl<TopoDS_Shape>());
+ try {
+ aList = aMakeShape->Modified(theShape->impl<TopoDS_Shape>());
+ } catch(Standard_NoSuchObject) {
+ }
} else if(myBuilderType == OCCT_BOPAlgo_Builder) {
BOPAlgo_Builder* aBOPBuilder = implPtr<BOPAlgo_Builder>();
aList = aBOPBuilder->Modified(theShape->impl<TopoDS_Shape>());
--- /dev/null
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
+// File: GeomAlgoAPI_ShapeBuilder.cpp
+// Created: 27 April 2016
+// Author: Dmitry Bobylev
+
+#include "GeomAlgoAPI_ShapeBuilder.h"
+
+#include "GeomAlgoAPI_MakeShapeCustom.h"
+
+#include <GeomAPI_ShapeIterator.h>
+
+#include <BRep_Builder.hxx>
+#include <BRepBuilderAPI_Copy.hxx>
+#include <BRepExtrema_DistShapeShape.hxx>
+#include <BRepTools_ReShape.hxx>
+#include <Precision.hxx>
+#include <TopExp_Explorer.hxx>
+#include <TopoDS.hxx>
+#include <TopoDS_Edge.hxx>
+#include <TopoDS_Iterator.hxx>
+#include <TopoDS_Shape.hxx>
+
+//==================================================================================================
+void GeomAlgoAPI_ShapeBuilder::add(std::shared_ptr<GeomAPI_Shape> theShape,
+ const std::shared_ptr<GeomAPI_Shape> theShapeToAdd)
+{
+ if(!theShape.get() || !theShapeToAdd.get()) {
+ return;
+ }
+
+ TopoDS_Shape* aShape = theShape->implPtr<TopoDS_Shape>();
+ const TopoDS_Shape& aShapeToAdd = theShapeToAdd->impl<TopoDS_Shape>();
+
+ BRep_Builder aBuilder;
+ aBuilder.Add(*aShape, aShapeToAdd);
+}
+
+
+//==================================================================================================
+void GeomAlgoAPI_ShapeBuilder::remove(std::shared_ptr<GeomAPI_Shape> theShape,
+ const std::shared_ptr<GeomAPI_Shape> theShapeToRemove)
+{
+ if(!theShape.get() || !theShapeToRemove.get()) {
+ return;
+ }
+
+ TopoDS_Shape* aShape = theShape->implPtr<TopoDS_Shape>();
+ const TopoDS_Shape& aShapeToRemove = theShapeToRemove->impl<TopoDS_Shape>();
+
+ BRep_Builder aBuilder;
+ aBuilder.Remove(*aShape, aShapeToRemove);
+}
+
+//==================================================================================================
+GeomAlgoAPI_ShapeBuilder::GeomAlgoAPI_ShapeBuilder()
+{
+}
+
+//==================================================================================================
+void GeomAlgoAPI_ShapeBuilder::removeInternal(const std::shared_ptr<GeomAPI_Shape> theShape)
+{
+ GeomShapePtr aResultShape = theShape->emptyCopied();
+ GeomAPI_Shape::ShapeType aBaseShapeType = theShape->shapeType();
+ std::shared_ptr<GeomAlgoAPI_MakeShapeCustom> aMakeShapeCustom(new GeomAlgoAPI_MakeShapeCustom());
+ for(GeomAPI_ShapeIterator anIter(theShape); anIter.more(); anIter.next()) {
+ GeomShapePtr aSubShape = anIter.current();
+ if(aBaseShapeType == GeomAPI_Shape::WIRE) {
+ GeomShapePtr aSubShapeCopy = aSubShape->emptyCopied();
+ aMakeShapeCustom->addModified(aSubShape, aSubShapeCopy);
+ for(GeomAPI_ShapeIterator aSubIter(aSubShape); aSubIter.more(); aSubIter.next()) {
+ GeomShapePtr aSubOfSubShape = aSubIter.current();
+ if(aSubOfSubShape->orientation() != GeomAPI_Shape::INTERNAL) {
+ GeomAlgoAPI_ShapeBuilder::add(aSubShapeCopy, aSubOfSubShape);
+ }
+ }
+ GeomAlgoAPI_ShapeBuilder::add(aResultShape, aSubShapeCopy);
+ } else if(aBaseShapeType == GeomAPI_Shape::FACE) {
+ if(aSubShape->shapeType() == GeomAPI_Shape::WIRE
+ && aSubShape->orientation() != GeomAPI_Shape::INTERNAL) {
+ GeomAlgoAPI_ShapeBuilder::add(aResultShape, aSubShape);
+ }
+ }
+ }
+
+ this->appendAlgo(aMakeShapeCustom);
+
+ setShape(aResultShape);
+ setDone(true);
+}
+
+//==================================================================================================
+void GeomAlgoAPI_ShapeBuilder::add(const std::shared_ptr<GeomAPI_Shape> theShape,
+ const ListOfShape& theShapesToAdd)
+{
+ // Get base shape.
+ if(!theShape.get()) {
+ return;
+ }
+ const TopoDS_Shape& aBaseShape = theShape->impl<TopoDS_Shape>();
+ TopAbs_ShapeEnum aBaseShapeType = aBaseShape.ShapeType();
+
+ // Copy base shape.
+ BRepBuilderAPI_Copy* aCopyBuilder = new BRepBuilderAPI_Copy(aBaseShape, Standard_False);
+ this->appendAlgo(std::shared_ptr<GeomAlgoAPI_MakeShape>(new GeomAlgoAPI_MakeShape(aCopyBuilder)));
+ if(!aCopyBuilder->IsDone()) {
+ return;
+ }
+ TopoDS_Shape aResultShape = aCopyBuilder->Shape();
+
+ // Copy sub-shapes from list to new shape.
+ BRep_Builder aBuilder;
+ std::shared_ptr<GeomAlgoAPI_MakeShapeCustom> aMakeShapeCustom(new GeomAlgoAPI_MakeShapeCustom());
+ for(ListOfShape::const_iterator anIt = theShapesToAdd.cbegin(); anIt != theShapesToAdd.cend(); ++anIt) {
+ TopoDS_Shape aShapeToAdd = (*anIt)->impl<TopoDS_Shape>();
+ for(TopExp_Explorer aResExp(aResultShape, TopAbs_VERTEX); aResExp.More(); aResExp.Next()) {
+ const TopoDS_Vertex& aVertexInRes = TopoDS::Vertex(aResExp.Current());
+ const gp_Pnt aPntInRes = BRep_Tool::Pnt(aVertexInRes);
+ for(TopExp_Explorer anAddExp(aShapeToAdd, TopAbs_VERTEX); anAddExp.More(); anAddExp.Next()) {
+ const TopoDS_Vertex& aVertexInAdd = TopoDS::Vertex(anAddExp.Current());
+ const gp_Pnt aPntInAdd = BRep_Tool::Pnt(aVertexInAdd);
+ if(aPntInRes.Distance(aPntInAdd) < Precision::Confusion()) {
+ BRepTools_ReShape aReShape;
+ TopoDS_Shape aVertexInResMod = aVertexInRes;
+ aVertexInResMod.Orientation(aVertexInAdd.Orientation());
+ aReShape.Replace(aVertexInAdd, aVertexInResMod);
+ TopoDS_Shape aModShape = aReShape.Apply(aShapeToAdd);
+
+ GeomShapePtr aGeomBaseShape(new GeomAPI_Shape());
+ GeomShapePtr aGeomModShape(new GeomAPI_Shape());
+ aGeomBaseShape->setImpl(new TopoDS_Shape(aShapeToAdd));
+ aGeomModShape->setImpl(new TopoDS_Shape(aModShape));
+ aMakeShapeCustom->addModified(aGeomBaseShape, aGeomModShape);
+ aShapeToAdd = aModShape;
+ }
+ }
+ }
+ TopAbs_ShapeEnum aShapeToAddType = aShapeToAdd.ShapeType();
+ if(aBaseShapeType == TopAbs_WIRE) {
+ if(aShapeToAddType == TopAbs_VERTEX) {
+ // Find on which edge vertex is lie and add to this edge.
+ for(TopExp_Explorer aResultExp(aResultShape, TopAbs_EDGE); aResultExp.More(); aResultExp.Next()) {
+ TopoDS_Shape anEdge = aResultExp.Current();
+ BRepExtrema_DistShapeShape aDist(anEdge, aShapeToAdd);
+ aDist.Perform();
+ if(aDist.IsDone() && aDist.Value() <= Precision::Confusion()) {
+ aShapeToAdd.Orientation(TopAbs_INTERNAL);
+ Standard_Boolean aFreeFlag = anEdge.Free();
+ anEdge.Free(Standard_True);
+ aBuilder.Add(anEdge, aShapeToAdd);
+ anEdge.Free(aFreeFlag);
+ break;
+ }
+ }
+ }
+ } else if(aBaseShapeType == GeomAPI_Shape::FACE) {
+ if(aShapeToAddType == GeomAPI_Shape::EDGE) {
+ aShapeToAdd.Orientation(TopAbs_INTERNAL);
+ TopoDS_Wire aWire;
+ aBuilder.MakeWire(aWire);
+ aBuilder.Add(aWire, aShapeToAdd);
+ aShapeToAdd = aWire;
+ aShapeToAdd.Orientation(TopAbs_INTERNAL);
+ }
+ aBuilder.Add(aResultShape, aShapeToAdd);
+ }
+ }
+ this->appendAlgo(aMakeShapeCustom);
+
+ // Set result.
+ std::shared_ptr<GeomAPI_Shape> aShape(new GeomAPI_Shape());
+ aShape->setImpl(new TopoDS_Shape(aResultShape));
+ setShape(aShape);
+ setDone(true);
+}
--- /dev/null
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
+// File: GeomAlgoAPI_ShapeBuilder.h
+// Created: 27 April 2016
+// Author: Dmitry Bobylev
+
+#ifndef GeomAlgoAPI_ShapeBuilder_H_
+#define GeomAlgoAPI_ShapeBuilder_H_
+
+#include "GeomAlgoAPI.h"
+#include "GeomAlgoAPI_MakeShapeList.h"
+
+#include <GeomAPI_Shape.h>
+
+/// \class GeomAlgoAPI_ShapeBuilder
+/// \ingroup DataAlgo
+/// \brief Allows to add or remove subshapes from a shape.
+class GeomAlgoAPI_ShapeBuilder: public GeomAlgoAPI_MakeShapeList
+{
+ public:
+ /// \brief Adds theShapeToAdd in theShape.
+ /// \param[in] theShape shape to modify.
+ /// \param[in] theShapeToAdd shape which will be added.
+ GEOMALGOAPI_EXPORT static void add(std::shared_ptr<GeomAPI_Shape> theShape,
+ const std::shared_ptr<GeomAPI_Shape> theShapeToAdd);
+
+ /// \brief Removes theShapeToRemove in theShape.
+ /// \param[in] theShape shape to modify.
+ /// \param[in] theShapeToRemove shape which will be removed.
+ GEOMALGOAPI_EXPORT static void remove(std::shared_ptr<GeomAPI_Shape> theShape,
+ const std::shared_ptr<GeomAPI_Shape> theShapeToRemove);
+
+ /// Creates empty builder.
+ GEOMALGOAPI_EXPORT GeomAlgoAPI_ShapeBuilder();
+
+ /// \brief Store new shape as result of removing internal shapes from theShape.
+ /// \param[in] theShape base shape.
+ GEOMALGOAPI_EXPORT void removeInternal(const std::shared_ptr<GeomAPI_Shape> theShape);
+
+ /// \brief Store new shape as result of adding theShapesToAdd to theShape.
+ /// \param[in] theShape base shape.
+ /// \param[in] theShapesToAdd shapes which will be added.
+ GEOMALGOAPI_EXPORT void add(const std::shared_ptr<GeomAPI_Shape> theShape,
+ const ListOfShape& theShapesToAdd);
+};
+
+#endif
#include <Bnd_Box.hxx>
#include <BOPTools.hxx>
#include <BRep_Builder.hxx>
+#include <BRepAdaptor_Curve.hxx>
#include <BRepAlgo_FaceRestrictor.hxx>
#include <BRepBndLib.hxx>
#include <BRepBuilderAPI_FindPlane.hxx>
+#include <BRepBuilderAPI_MakeEdge.hxx>
#include <BRepBuilderAPI_MakeFace.hxx>
+#include <BRepExtrema_DistShapeShape.hxx>
#include <BRepGProp.hxx>
+#include <BRepTopAdaptor_FClass2d.hxx>
+#include <Geom_Curve.hxx>
+#include <Geom2d_Curve.hxx>
+#include <BRepLib_CheckCurveOnSurface.hxx>
#include <BRep_Tool.hxx>
#include <Geom_Plane.hxx>
#include <GeomLib_IsPlanarSurface.hxx>
#include <GeomLib_Tool.hxx>
+#include <GeomProjLib.hxx>
#include <gp_Pln.hxx>
#include <GProp_GProps.hxx>
#include <IntAna_IntConicQuad.hxx>
#include <IntAna_Quadric.hxx>
#include <NCollection_Vector.hxx>
#include <ShapeAnalysis.hxx>
+#include <ShapeAnalysis_Surface.hxx>
#include <TopoDS_Builder.hxx>
#include <TopoDS_Edge.hxx>
#include <TopoDS_Face.hxx>
return aPln;
}
+
+//=================================================================================================
+bool GeomAlgoAPI_ShapeTools::isSubShapeInShape(const std::shared_ptr<GeomAPI_Shape> theSubShape,
+ const std::shared_ptr<GeomAPI_Shape> theBaseShape)
+{
+ if(!theSubShape.get() || !theBaseShape.get()) {
+ return false;
+ }
+
+ const TopoDS_Shape& aSubShape = theSubShape->impl<TopoDS_Shape>();
+ const TopoDS_Shape& aBaseShape = theBaseShape->impl<TopoDS_Shape>();
+
+ if(aSubShape.ShapeType() == TopAbs_VERTEX) {
+ // If sub-shape is a vertex check distance to shape. If it is <= Precision::Confusion() then OK.
+ BRepExtrema_DistShapeShape aDist(aBaseShape, aSubShape);
+ aDist.Perform();
+ if(!aDist.IsDone() || aDist.Value() > Precision::Confusion()) {
+ return false;
+ }
+ } else if (aSubShape.ShapeType() == TopAbs_EDGE) {
+ if(aBaseShape.ShapeType() == TopAbs_FACE) {
+ // Check that edge is on face surface.
+ TopoDS_Face aFace = TopoDS::Face(aBaseShape);
+ TopoDS_Edge anEdge = TopoDS::Edge(aSubShape);
+ BRepLib_CheckCurveOnSurface aCheck(anEdge, aFace);
+ aCheck.Perform();
+ if(!aCheck.IsDone() || aCheck.MaxDistance() > Precision::Confusion()) {
+ return false;
+ }
+
+ // Check intersections.
+ TopoDS_Vertex aV1, aV2;
+ ShapeAnalysis::FindBounds(anEdge, aV1, aV2);
+ gp_Pnt aPnt1 = BRep_Tool::Pnt(aV1);
+ gp_Pnt aPnt2 = BRep_Tool::Pnt(aV2);
+ for(TopExp_Explorer anExp(aBaseShape, TopAbs_EDGE); anExp.More(); anExp.Next()) {
+ const TopoDS_Shape& anEdgeOnFace = anExp.Current();
+ BRepExtrema_DistShapeShape aDist(anEdgeOnFace, anEdge);
+ aDist.Perform();
+ if(aDist.IsDone() && aDist.Value() <= Precision::Confusion()) {
+ // Edge intersect face bound. Check that it is not on edge begin or end.
+ for(Standard_Integer anIndex = 1; anIndex <= aDist.NbSolution(); ++anIndex) {
+ gp_Pnt aPntOnSubShape = aDist.PointOnShape2(anIndex);
+ if(aPntOnSubShape.Distance(aPnt1) > Precision::Confusion()
+ && aPntOnSubShape.Distance(aPnt2) > Precision::Confusion()) {
+ return false;
+ }
+ }
+ }
+ }
+
+ // No intersections found. Edge is inside or outside face. Check it.
+ BRepAdaptor_Curve aCurveAdaptor(anEdge);
+ gp_Pnt aPointToCheck = aCurveAdaptor.Value((aCurveAdaptor.FirstParameter() + aCurveAdaptor.LastParameter()) / 2.0);
+ Handle(Geom_Surface) aSurface = BRep_Tool::Surface(aFace);
+ ShapeAnalysis_Surface aSAS(aSurface);
+ gp_Pnt2d aPointOnFace = aSAS.ValueOfUV(aPointToCheck, Precision::Confusion());
+ BRepTopAdaptor_FClass2d aFClass2d(aFace, Precision::Confusion());
+ if(aFClass2d.Perform(aPointOnFace) == TopAbs_OUT) {
+ return false;
+ }
+
+ } else {
+ return false;
+ }
+ } else {
+ return false;
+ }
+
+ return true;
+}
/// \param[in] theShapes shapes to find plane.
/// \return plane where all shapes lie or empty ptr if they not planar.
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.
+ static bool isSubShapeInShape(const std::shared_ptr<GeomAPI_Shape> theSubShape,
+ const std::shared_ptr<GeomAPI_Shape> theBaseShape);
};
#endif
#include "GeomAlgoAPI_Pipe.h"
#include "GeomAlgoAPI_WireBuilder.h"
#include "GeomAlgoAPI_Sewing.h"
-
+ #include "GeomAlgoAPI_ShapeBuilder.h"
+
#include <memory>
#include <string>
#include <list>