#include <Geom_Line.hxx>
#include <Geom_Circle.hxx>
#include <Geom_Ellipse.hxx>
+#include <Geom_Plane.hxx>
+#include <GeomAPI_IntCS.hxx>
#include <GeomAdaptor_Curve.hxx>
#include <gp_Ax1.hxx>
#include <gp_Pln.hxx>
return inPlane;
}
+std::list<std::shared_ptr<GeomAPI_Pnt>> GeomAPI_Edge::intersectWithPlane(
+ const std::shared_ptr<GeomAPI_Pln> thePlane) const
+{
+ std::list<GeomPointPtr> aResList;
+ double aFirst, aLast;
+ const TopoDS_Shape& aShape = const_cast<GeomAPI_Edge*>(this)->impl<TopoDS_Shape>();
+ Handle(Geom_Curve) aCurve = BRep_Tool::Curve((const TopoDS_Edge&)aShape, aFirst, aLast);
+ if (!aCurve.IsNull()) {
+ double A, B, C, D;
+ thePlane->coefficients(A, B, C, D);
+ gp_Pln aPln(A, B, C, D);
+
+ Handle(Geom_Plane) aPlane = new Geom_Plane(aPln);
+ GeomAPI_IntCS aIntersect;
+ aIntersect.Perform(aCurve, aPlane);
+ if (aIntersect.IsDone() && (aIntersect.NbPoints() > 0)) {
+ gp_Pnt aPnt;
+ for (int i = 1; i <= aIntersect.NbPoints(); i++) {
+ aPnt = aIntersect.Point(i);
+ std::shared_ptr<GeomAPI_Pnt> aPntPtr(new GeomAPI_Pnt(aPnt.X(), aPnt.Y(), aPnt.Z()));
+ aResList.push_back(aPntPtr);
+ }
+ }
+ }
+ return aResList;
+}
+
double GeomAPI_Edge::length() const
{
const TopoDS_Edge& anEdge = TopoDS::Edge(impl<TopoDS_Shape>());
void getRange(double& theFirst, double& theLast) const;
/// Returns true, if the edge is fully placed in the specified plane
+ /// \param thePlane a plane for intersection
GEOMAPI_EXPORT
bool isInPlane(const std::shared_ptr<GeomAPI_Pln> thePlane) const;
+ /// Returns list of intersection points if the edge has intersections with the given plane
+ /// \param thePlane a plane for intersection
+ GEOMAPI_EXPORT
+ std::list<std::shared_ptr<GeomAPI_Pnt>>
+ intersectWithPlane(const std::shared_ptr<GeomAPI_Pln> thePlane) const;
+
/// Returns edge length.
GEOMAPI_EXPORT
double length() const;
new PartSet_MultyTranslationSelection);
aFactory->registerValidator("PartSet_SplitSelection", new PartSet_SplitSelection);
aFactory->registerValidator("PartSet_ProjectionSelection", new PartSet_ProjectionSelection);
+ aFactory->registerValidator("PartSet_IntersectionSelection", new PartSet_IntersectionSelection);
}
//******************************************************
}
}
+bool PartSet_IntersectionSelection::isValid(const ModuleBase_ISelection* theSelection,
+ ModuleBase_Operation* theOperation) const
+{
+ if (theSelection->getSelected(ModuleBase_ISelection::Viewer).size() == 0) {
+ return isEmptySelectionValid(theOperation);
+ } else {
+ int aCount = shapesNbLines(theSelection);
+ return aCount == 0;
+ }
+}
+
std::string PartSet_DifferentObjectsValidator::errorMessage(
const PartSet_DifferentObjectsValidator::ErrorType& theType,
ModuleBase_Operation* theOperation) const;
};
+//! \ingroup Validators
+//! A class to validate a selection for intersection operation
+class PartSet_IntersectionSelection : public ModuleBase_SelectionValidator
+{
+public:
+ PARTSET_EXPORT virtual bool isValid(const ModuleBase_ISelection* theSelection,
+ ModuleBase_Operation* theOperation) const;
+};
+
////////////// Attribute validators ////////////////
SketchPlugin_Tools.h
SketchPlugin_Trim.h
SketchPlugin_Validators.h
+ SketchPlugin_Intersection.h
)
SET(PROJECT_SOURCES
SketchPlugin_Tools.cpp
SketchPlugin_Trim.cpp
SketchPlugin_Validators.cpp
+ SketchPlugin_Intersection.cpp
)
SET(PROJECT_LIBRARIES
#include <SketchPlugin_Circle.h>
#include <SketchPlugin_Arc.h>
#include <SketchPlugin_Projection.h>
+#include <SketchPlugin_Intersection.h>
#include <SketchPlugin_ConstraintAngle.h>
#include <SketchPlugin_ConstraintCoincidence.h>
#include <SketchPlugin_ConstraintCollinear.h>
return FeaturePtr(new SketchPlugin_Arc);
} else if (theFeatureID == SketchPlugin_Projection::ID()) {
return FeaturePtr(new SketchPlugin_Projection);
+ } else if (theFeatureID == SketchPlugin_Intersection::ID()) {
+ return FeaturePtr(new SketchPlugin_Intersection);
} else if (theFeatureID == SketchPlugin_ConstraintCoincidence::ID()) {
return FeaturePtr(new SketchPlugin_ConstraintCoincidence);
} else if (theFeatureID == SketchPlugin_ConstraintCollinear::ID()) {
nested="SketchPoint SketchIntersectionPoint SketchLine
SketchCircle SketchMacroCircle SketchArc SketchMacroArc
SketchRectangle
- SketchProjection
+ SketchProjection SketchIntersection
SketchConstraintLength SketchConstraintRadius SketchConstraintDistance SketchConstraintDistanceHorizontal SketchConstraintDistanceVertical
SketchConstraintParallel SketchConstraintPerpendicular
SketchConstraintRigid SketchConstraintHorizontal SketchConstraintVertical
<boolvalue id="IncludeToResult" label="Include into the sketch result" default="true" tooltip="Include projected feature into the sketch result"/>
<validator id="PartSet_ProjectionSelection"/>
</feature>
+
+ <!-- Intersection feature -->
+ <feature
+ id="SketchIntersection"
+ title="Intersection"
+ tooltip="Intersect edge with sketch plane"
+ icon="icons/Sketch/intersection.png">
+ <sketch_shape_selector
+ id="ExternalFeature"
+ label="Object"
+ tooltip="Select external edge."
+ shape_types="edge"
+ use_external="true"
+ can_create_external="false"
+ use_sketch_plane="false">
+ <validator id="SketchPlugin_ProjectionValidator"/>
+ </sketch_shape_selector>
+ <boolvalue id="IncludeToResult" label="Include into the sketch result" default="true" tooltip="Include projected feature into the sketch result"/>
+ <validator id="PartSet_IntersectionSelection"/>
+ </feature>
</group>
<group id="Replication">