#include <ModelHighAPI_Tools.h>
//=================================================================================================
-FeaturesAPI_NormalToFace::
- FeaturesAPI_NormalToFace(const std::shared_ptr<ModelAPI_Feature>& theFeature)
+FeaturesAPI_NormalToFace::FeaturesAPI_NormalToFace(
+ const std::shared_ptr<ModelAPI_Feature>& theFeature)
: ModelHighAPI_Interface(theFeature)
{
initialize();
FeaturesAPI_NormalToFace::FeaturesAPI_NormalToFace(
const std::shared_ptr<ModelAPI_Feature>& theFeature,
const ModelHighAPI_Selection& theBaseFace,
- const ModelHighAPI_Selection& theOptionnelPoint )
+ const ModelHighAPI_Selection& theOptionnelPoint)
:ModelHighAPI_Interface(theFeature)
{
if (initialize()) {
const ModelHighAPI_Selection& theOptionnelPoint)
{
- FeaturePtr aFeature =
- thePart->addFeature(FeaturesPlugin_CreateNormalToFace::ID());
+ FeaturePtr aFeature = thePart->addFeature(FeaturesPlugin_CreateNormalToFace::ID());
NormalPtr aNormalToface;
const ModelHighAPI_Selection& theBaseFace)
{
- FeaturePtr aFeature =
- thePart->addFeature(FeaturesPlugin_CreateNormalToFace::ID());
+ FeaturePtr aFeature = thePart->addFeature(FeaturesPlugin_CreateNormalToFace::ID());
NormalPtr aNormalToface;
FEATURESAPI_EXPORT
explicit FeaturesAPI_NormalToFace(const std::shared_ptr<ModelAPI_Feature>& theFeature,
const ModelHighAPI_Selection& theBaseFace,
- const ModelHighAPI_Selection& theOptionnelPoint );
+ const ModelHighAPI_Selection& theOptionnelPoint);
FEATURESAPI_EXPORT
explicit FeaturesAPI_NormalToFace(const std::shared_ptr<ModelAPI_Feature>& theFeature,
fillet_widget.xml
fillet1d_widget.xml
measurement_widget.xml
- NormalToFace_widget.xml
- CreateNormalToFace_widget.xml
+ normal_to_face_widget.xml
+ create_normal_to_face_widget.xml
fusion_faces_widget.xml
chamfer_widget.xml
copy_widget.xml
+++ /dev/null
-<source>
- <shape_selector id="face"
- label="Face"
- tooltip="Select a face"
- shape_types="face"
- default=""
- geometrical_selection="true">
- <validator id="PartSet_DifferentObjects"/>
- <validator id="GeomValidators_ShapeType" parameters="wire,face"/>
- </shape_selector>
- <optionalbox id="vertex_option" title="Option">
- <shape_selector id="vertex"
- label="Vertex"
- tooltip="Select a vertex"
- shape_types="vertex"
- default=""
- geometrical_selection="true">
- <validator id="PartSet_DifferentObjects"/>
- </shape_selector>
- </optionalbox>
-</source>
GeomShapePtr aShape;
GeomShapePtr aShapePoint;
- if(!string(VERTEX_OPTION_ID())->value().empty())
- {
+ if (!string(VERTEX_OPTION_ID())->value().empty()) {
if (aSelectionPoint && aSelectionPoint->isInitialized()) {
aShapePoint = aSelectionPoint->value();
if (!aShapePoint && aSelectionPoint->context())
if (aShape) {
std::string aError;
std::shared_ptr<GeomAPI_Edge> theNormal(new GeomAPI_Edge);
- if( !GeomAlgoAPI_NormalToFace::normal(aShape,
+ if (!GeomAlgoAPI_NormalToFace::normal(aShape,
aShapePoint,
theNormal,
aError))
return MY_ID;
}
- /// \return the kind of a feature.
- virtual const std::string& getKind()
- {
- return ID();
- }
-
/// Attribute name for face selected.
inline static const std::string& FACE_SELECTED_ID()
{
return MY_VERTEX_OPTION_ID;
}
+ /// \return the kind of a feature.
+ virtual const std::string& getKind()
+ {
+ return ID();
+ }
+
/// Performs the algorithm and stores results it in the data structure.
FEATURESPLUGIN_EXPORT virtual void execute();
if (aShape) {
std::string aError;
std::shared_ptr<GeomAPI_Edge> theNormal(new GeomAPI_Edge);
- if( !GeomAlgoAPI_NormalToFace::normal(aShape,
+ if (!GeomAlgoAPI_NormalToFace::normal(aShape,
aShapePoint,
theNormal,
aError))
void FeaturesPlugin_NormalToFace::updateNormal()
{
myCreateFeature->selection(FeaturesPlugin_CreateNormalToFace::FACE_SELECTED_ID())
- ->setValue( selection(FACE_SELECTED_ID())->context() ,
- selection(FACE_SELECTED_ID())->value() );
+ ->setValue(selection(FACE_SELECTED_ID())->context() ,
+ selection(FACE_SELECTED_ID())->value());
myCreateFeature->string(FeaturesPlugin_CreateNormalToFace::VERTEX_OPTION_ID())
- ->setValue( string(VERTEX_OPTION_ID())->value());
+ ->setValue(string(VERTEX_OPTION_ID())->value());
if (!string(VERTEX_OPTION_ID())->value().empty()) {
myCreateFeature->selection(FeaturesPlugin_CreateNormalToFace::VERTEX_SELECTED_ID())
- ->setValue( selection(VERTEX_SELECTED_ID())->context() ,
- selection(VERTEX_SELECTED_ID())->value() );
+ ->setValue(selection(VERTEX_SELECTED_ID())->context() ,
+ selection(VERTEX_SELECTED_ID())->value());
}
myCreateFeature->execute();
return MY_ID;
}
- /// \return the kind of a feature.
- virtual const std::string& getKind()
- {
- return ID();
- }
-
/// Attribute name for face selected.
inline static const std::string& FACE_SELECTED_ID()
{
return MY_VERTEX_OPTION_ID;
}
+ /// \return the kind of a feature.
+ virtual const std::string& getKind()
+ {
+ return ID();
+ }
+
/// Performs the algorithm and stores results it in the data structure.
FEATURESPLUGIN_EXPORT virtual void execute();
FeaturesPlugin_NormalToFace();
private:
-
+ /// Create normal in feature
void createNormal();
+ /// Update normal in feature
void updateNormal();
+ /// Feature to create normal
FeaturePtr myCreateFeature;
};
+++ /dev/null
-<source>
- <shape_selector id="face"
- label="Face"
- tooltip="Select a face"
- shape_types="face"
- default=""
- geometrical_selection="true">
- <validator id="PartSet_DifferentObjects"/>
- <validator id="GeomValidators_ShapeType" parameters="wire,face"/>
- </shape_selector>
- <optionalbox id="vertex_option" title="Option">
- <shape_selector id="vertex"
- label="Vertex"
- tooltip="Select a vertex"
- shape_types="vertex"
- default=""
- geometrical_selection="true">
- <validator id="PartSet_DifferentObjects"/>
- </shape_selector>
- </optionalbox>
- <boolvalue id="createnormal" label="Create normal" default="false"/>
-</source>
--- /dev/null
+<source>
+ <shape_selector id="face"
+ label="Face"
+ tooltip="Select a face"
+ shape_types="face"
+ default=""
+ geometrical_selection="true">
+ <validator id="GeomValidators_ShapeType" parameters="wire,face"/>
+ </shape_selector>
+ <optionalbox id="vertex_option" title="Option">
+ <shape_selector id="vertex"
+ label="Vertex"
+ tooltip="Select a vertex"
+ shape_types="vertex"
+ default=""
+ geometrical_selection="true">
+ <validator id="GeomValidators_ShapeType" parameters="vertex"/>
+ </shape_selector>
+ </optionalbox>
+</source>
+++ /dev/null
-
- .. _tui_create_Normal_To_Face:
-
-Create Normal to a face
-=======================
-
-.. literalinclude:: examples/createNormalToFace.py
- :linenos:
- :language: python
-
-:download:`Download this script <examples/createNormalToFace.py>`
-
- .. _tui_create_Normal_To_Face_At_Vertex:
-
-Create Normal to a face at vertex
-=================================
-
-.. literalinclude:: examples/createNormalToFaceAtVertex.py
- :linenos:
- :language: python
-
-:download:`Download this script <examples/createNormalToFaceAtVertex.py>`
\ No newline at end of file
--- /dev/null
+
+ .. _tui_create_normal_to_face:
+
+Create normal to a face
+=======================
+
+.. literalinclude:: examples/createNormalToFace.py
+ :linenos:
+ :language: python
+
+:download:`Download this script <examples/createNormalToFace.py>`
+
+ .. _tui_create_normal_to_face_at_vertex:
+
+Create normal to a face at vertex
+=================================
+
+.. literalinclude:: examples/createNormalToFaceAtVertex.py
+ :linenos:
+ :language: python
+
+:download:`Download this script <examples/createNormalToFaceAtVertex.py>`
\ No newline at end of file
Normal to a face
-**See Also** a sample TUI Script of :ref:`tui_create_Normal_To_Face` operation.
+**See Also** a sample TUI Script of :ref:`tui_create_normal_to_face` operation.
**TUI Command**:
Normal to a face at vertex
-**See Also** a sample TUI Script of :ref:`tui_create_Normal_To_Face_At_Vertex` operation.
\ No newline at end of file
+**See Also** a sample TUI Script of :ref:`tui_create_normal_to_face_at_vertex` operation.
\ No newline at end of file
--- /dev/null
+<source>
+ <shape_selector id="face"
+ label="Face"
+ tooltip="Select a face"
+ shape_types="face"
+ default=""
+ geometrical_selection="true">
+ <validator id="GeomValidators_ShapeType" parameters="wire,face"/>
+ </shape_selector>
+ <optionalbox id="vertex_option" title="Option">
+ <shape_selector id="vertex"
+ label="Vertex"
+ tooltip="Select a vertex"
+ shape_types="vertex"
+ default=""
+ geometrical_selection="true">
+ <validator id="GeomValidators_ShapeType" parameters="vertex"/>
+ </shape_selector>
+ </optionalbox>
+ <boolvalue id="createnormal" label="Create normal" default="false"/>
+</source>
<group id="Face">
<feature id="NormalMacro" title="Normal to a face" tooltip="Calculate the normal to a face" auto_preview="true"
icon="icons/Features/normale.png" helpfile="normalToFaceFeature.html">
- <source path="NormalToFace_widget.xml"/>
+ <source path="normal_to_face_widget.xml"/>
</feature>
<feature id="Normal" title="Normal to a face" tooltip="Calculate the normal to a face" auto_preview="true"
icon="icons/Features/axis.png" helpfile="normalToFaceFeature.html" internal="1">
- <source path="CreateNormalToFace_widget.xml"/>
+ <source path="create_normal_to_face_widget.xml"/>
</feature>
</group>
</workbench>
* \param theShape The shape to get type of.
* \retval TopAbs_ShapeEnum Return type of shape for explode.
*/
-TopAbs_ShapeEnum GetTypeOfSimplePart (const TopoDS_Shape& theShape)
+TopAbs_ShapeEnum GetTypeOfSimplePart(const TopoDS_Shape& theShape)
{
TopAbs_ShapeEnum aType = theShape.ShapeType();
if (aType == TopAbs_VERTEX) return TopAbs_VERTEX;
* Axes of the LCS are obtained from shape's location or,
* if the shape is a planar face, from position of its plane.
*/
-gp_Ax3 GetPosition (const TopoDS_Shape& theShape)
+gp_Ax3 GetPosition(const TopoDS_Shape& theShape)
{
gp_Ax3 aResult;
aResult = aPln.Position();
// In case of reverse orinetation of the face invert the plane normal
// (the face's normal does not mathc the plane's normal in this case)
- if(theShape.Orientation() == TopAbs_REVERSED)
- {
+ if (theShape.Orientation() == TopAbs_REVERSED) {
gp_Dir Vx = aResult.XDirection();
gp_Dir N = aResult.Direction().Mirrored(Vx);
gp_Pnt P = aResult.Location();
if (aShType == TopAbs_VERTEX) {
aPnt = BRep_Tool::Pnt(TopoDS::Vertex(theShape));
- }
- else {
+ } else {
if (aShType == TopAbs_COMPOUND) {
aShType = GetTypeOfSimplePart(theShape);
}
TopoDS_Shape aShape = theFace->impl<TopoDS_Shape>();
if (aShape.ShapeType() != TopAbs_FACE) {
- theError = "Shape for normale calculation is not a face";
- return false;
+ theError = "Shape for normale calculation is not a face";
+ return false;
}
TopoDS_Face aFace = TopoDS::Face(aShape);
if (theOptionnelPoint.get()) {
TopoDS_Shape anOptPnt = theOptionnelPoint->impl<TopoDS_Shape>();
- if (anOptPnt.IsNull()){
+ if (anOptPnt.IsNull()) {
theError = "Invalid shape given for point argument";
return false;
}
p1 = BRep_Tool::Pnt(TopoDS::Vertex(anOptPnt));
- }
- else
- {
- gp_Ax3 aPos = GetPosition(aFace);
- p1 = aPos.Location();
+ } else {
+ gp_Ax3 aPos = GetPosition(aFace);
+ p1 = aPos.Location();
}
- // Point parameters on surface
- Handle(Geom_Surface) aSurf = BRep_Tool::Surface(aFace);
- Handle(ShapeAnalysis_Surface) aSurfAna = new ShapeAnalysis_Surface (aSurf);
- gp_Pnt2d pUV = aSurfAna->ValueOfUV(p1, Precision::Confusion());
-
- // Normal direction
- gp_Vec Vec1,Vec2;
- BRepAdaptor_Surface SF (aFace);
- SF.D1(pUV.X(), pUV.Y(), p1, Vec1, Vec2);
- if (Vec1.Magnitude() < Precision::Confusion()) {
- gp_Vec tmpV;
- gp_Pnt tmpP;
- SF.D1(pUV.X(), pUV.Y()-0.1, tmpP, Vec1, tmpV);
- }
- else if (Vec2.Magnitude() < Precision::Confusion()) {
- gp_Vec tmpV;
- gp_Pnt tmpP;
- SF.D1(pUV.X()-0.1, pUV.Y(), tmpP, tmpV, Vec2);
- }
+ // Point parameters on surface
+ Handle(Geom_Surface) aSurf = BRep_Tool::Surface(aFace);
+ Handle(ShapeAnalysis_Surface) aSurfAna = new ShapeAnalysis_Surface (aSurf);
+ gp_Pnt2d pUV = aSurfAna->ValueOfUV(p1, Precision::Confusion());
+
+ // Normal direction
+ gp_Vec Vec1,Vec2;
+ BRepAdaptor_Surface SF (aFace);
+ SF.D1(pUV.X(), pUV.Y(), p1, Vec1, Vec2);
+ if (Vec1.Magnitude() < Precision::Confusion()) {
+ gp_Vec tmpV;
+ gp_Pnt tmpP;
+ SF.D1(pUV.X(), pUV.Y()-0.1, tmpP, Vec1, tmpV);
+ }
+ else if (Vec2.Magnitude() < Precision::Confusion()) {
+ gp_Vec tmpV;
+ gp_Pnt tmpP;
+ SF.D1(pUV.X()-0.1, pUV.Y(), tmpP, tmpV, Vec2);
+ }
- gp_Vec V = Vec1.Crossed(Vec2);
- Standard_Real mod = V.Magnitude();
- if (mod < Precision::Confusion())
- Standard_NullObject::Raise("Normal vector of a face has null magnitude");
-
- // Set length of normal vector to average radius of curvature
- Standard_Real radius = 0.0;
- GeomLProp_SLProps aProperties (aSurf, pUV.X(), pUV.Y(), 2, Precision::Confusion());
- if (aProperties.IsCurvatureDefined()) {
- Standard_Real radius1 = Abs(aProperties.MinCurvature());
- Standard_Real radius2 = Abs(aProperties.MaxCurvature());
- if (Abs(radius1) > Precision::Confusion()) {
- radius = 1.0 / radius1;
- if (Abs(radius2) > Precision::Confusion()) {
- radius = (radius + 1.0 / radius2) / 2.0;
- }
+ gp_Vec V = Vec1.Crossed(Vec2);
+ Standard_Real mod = V.Magnitude();
+ if (mod < Precision::Confusion())
+ Standard_NullObject::Raise("Normal vector of a face has null magnitude");
+
+ // Set length of normal vector to average radius of curvature
+ Standard_Real radius = 0.0;
+ GeomLProp_SLProps aProperties (aSurf, pUV.X(), pUV.Y(), 2, Precision::Confusion());
+ if (aProperties.IsCurvatureDefined()) {
+ Standard_Real radius1 = Abs(aProperties.MinCurvature());
+ Standard_Real radius2 = Abs(aProperties.MaxCurvature());
+ if (Abs(radius1) > Precision::Confusion()) {
+ radius = 1.0 / radius1;
+ if (Abs(radius2) > Precision::Confusion()) {
+ radius = (radius + 1.0 / radius2) / 2.0;
}
- else {
- if (Abs(radius2) > Precision::Confusion()) {
- radius = 1.0 / radius2;
- }
+ } else {
+ if (Abs(radius2) > Precision::Confusion()) {
+ radius = 1.0 / radius2;
}
}
+ }
- // Set length of normal vector to average dimension of the face
- // (only if average radius of curvature is not appropriate)
- if (radius < Precision::Confusion()) {
- Bnd_Box B;
- Standard_Real Xmin, Xmax, Ymin, Ymax, Zmin, Zmax;
- BRepBndLib::Add(aFace, B);
- B.Get(Xmin, Ymin, Zmin, Xmax, Ymax, Zmax);
- radius = ((Xmax - Xmin) + (Ymax - Ymin) + (Zmax - Zmin)) / 3.0;
- }
-
- if (radius < Precision::Confusion())
- radius = 1.0;
+ // Set length of normal vector to average dimension of the face
+ // (only if average radius of curvature is not appropriate)
+ if (radius < Precision::Confusion()) {
+ Bnd_Box B;
+ Standard_Real Xmin, Xmax, Ymin, Ymax, Zmin, Zmax;
+ BRepBndLib::Add(aFace, B);
+ B.Get(Xmin, Ymin, Zmin, Xmax, Ymax, Zmax);
+ radius = ((Xmax - Xmin) + (Ymax - Ymin) + (Zmax - Zmin)) / 3.0;
+ }
- V *= radius / mod;
+ if (radius < Precision::Confusion())
+ radius = 1.0;
- // consider the face orientation
- if (aFace.Orientation() == TopAbs_REVERSED ||
- aFace.Orientation() == TopAbs_INTERNAL) {
- V = - V;
- }
+ V *= radius / mod;
- // Edge
- gp_Pnt p2 = p1.Translated(V);
- BRepBuilderAPI_MakeEdge aBuilder (p1, p2);
- if (!aBuilder.IsDone())
- Standard_NullObject::Raise("Vector construction failed");
- aShape = aBuilder.Shape();
+ // consider the face orientation
+ if (aFace.Orientation() == TopAbs_REVERSED ||
+ aFace.Orientation() == TopAbs_INTERNAL) {
+ V = - V;
+ }
- theNormal->setImpl(new TopoDS_Shape(aShape));
+ // Edge
+ gp_Pnt p2 = p1.Translated(V);
+ BRepBuilderAPI_MakeEdge aBuilder (p1, p2);
+ if (!aBuilder.IsDone())
+ Standard_NullObject::Raise("Vector construction failed");
+ aShape = aBuilder.Shape();
- return true;
+ theNormal->setImpl(new TopoDS_Shape(aShape));
+ return true;
}
#include <GeomAlgoAPI.h>
#include <GeomAPI_Edge.h>
-#include <GeomAPI_Pnt.h>
#include <GeomAPI_Face.h>
-#include <Standard_TypeDef.hxx>
/**\class GeomAlgoAPI_NormalToFace
* \ingroup DataAlgo
class GEOMALGOAPI_EXPORT GeomAlgoAPI_NormalToFace
{
public:
- /// get the boundin box of theshape.
+ /// get the normal to face-shapes
/// \param theface the face
/// \param theOptionnelPoint the optionnel point
+ /// \param theNormal the normal
+ /// \param theError the error
static bool GeomAlgoAPI_NormalToFace::normal(GeomShapePtr theFace,
GeomShapePtr theOptionnelPoint,
GeomEdgePtr theNormal,