--- /dev/null
+# Copyright (C) 2014-2020 CEA/DEN, EDF R&D
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+#
+# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+#
+
+"""
+ TestFillet_MultiRadius.py
+ Unit test of ...
+"""
+#=========================================================================
+# Initialization of the test
+#=========================================================================
+
+import salome
+
+import os
+import math
+from tempfile import TemporaryDirectory
+
+import GEOM
+from ModelAPI import *
+from salome.shaper import model
+from salome.geom import geomBuilder
+from GeomAPI import GeomAPI_Shape
+from GeomAlgoAPI import *
+
+#import SALOMEDS
+
+
+__updated__ = "2020-10-10"
+
+salome.salome_init(1)
+
+#=========================================================================
+# Help functions
+#=========================================================================
+def removeFile(theFileName):
+ try: os.remove(theFileName)
+ except OSError: pass
+ assert not os.path.exists(theFileName), \
+ "Can not remove file {0}".format(theFileName)
+
+#=========================================================================
+# test Fillet on a solid with a constant radius
+#=========================================================================
+def testFillet_constant_radius_onsolids():
+
+ model.begin()
+ partSet = model.moduleDocument()
+ ### Create Part
+ Part_1 = model.addPart(partSet)
+ Part_1_doc = Part_1.document()
+
+ ### Create Box
+ Box_1 = model.addBox(Part_1_doc, 20, 30, 10)
+
+ ### Create Fillet
+ Fillet_1 = model.addFillet(Part_1_doc, [model.selection("SOLID", "Box_1_1")], 2)
+
+ ### Create Export
+ Export_1 = model.exportToXAO(Part_1_doc, '/tmp/shaper_exp_cglb.xao', model.selection("SOLID", "Fillet_1_1"), 'XAO')
+
+ model.end()
+
+ # Check results
+ ###
+ ### GEOM component
+ ###
+
+ geompy = geomBuilder.New()
+
+ O = geompy.MakeVertex(0, 0, 0)
+ OX = geompy.MakeVectorDXDYDZ(1, 0, 0)
+ OY = geompy.MakeVectorDXDYDZ(0, 1, 0)
+ OZ = geompy.MakeVectorDXDYDZ(0, 0, 1)
+
+ # where we import the fillet from SHAPER and get its basic properties
+ (imported, Fillet_1_1, [], [], []) = geompy.ImportXAO("/tmp/shaper_exp_cglb.xao")
+ geompy.addToStudy( O, 'O' )
+ geompy.addToStudy( OX, 'OX' )
+ geompy.addToStudy( OY, 'OY' )
+ geompy.addToStudy( OZ, 'OZ' )
+ geompy.addToStudy( Fillet_1_1, 'Fillet_1_1' )
+
+ myDelta = 1e-6
+ Props_shaper = geompy.BasicProperties(Fillet_1_1)
+ print("\nBasic Properties:")
+ print(" Wires length: ", Props_shaper[0])
+ print(" Surface area: ", Props_shaper[1])
+ print(" Volume : ", Props_shaper[2])
+
+ # where we build the same fillet in GEOM for comparison
+ Box_1 = geompy.MakeBoxDXDYDZ(20, 30, 10)
+ Fillet_1 = geompy.MakeFilletAll(Box_1, 2)
+ geompy.addToStudy( Box_1, 'Box_1' )
+ geompy.addToStudy( Fillet_1, 'Fillet_1' )
+
+ Props_geom = geompy.BasicProperties(Fillet_1)
+ print("\nBasic Properties:")
+ print(" Wires length: ", Props_geom[0])
+ print(" Surface area: ", Props_geom[1])
+ print(" Volume : ", Props_geom[2])
+
+ aRefSurface = Props_geom[1]
+ aResSurface = Props_shaper[1]
+ assert (math.fabs(aResSurface - aRefSurface) < myDelta), "The surface is wrong: expected = {0}, real = {1}".format(aRefSurface, aResSurface)
+
+ aRefVolume = Props_geom[2]
+ aResVolume = Props_shaper[2]
+ assert (math.fabs(aResVolume - aRefVolume) < myDelta), "The volume is wrong: expected = {0}, real = {1}".format(aRefVolume, aResVolume)
+
+
+if __name__ == '__main__':
+ with TemporaryDirectory() as tmp_dir:
+
+ testFillet_constant_radius_onsolids()
+ #=========================================================================
+ # End of test
+ #=========================================================================
Test17917
Test18887
Test3195
+ TestFillet_MultiRadius
)
%feature("kwargs") addCommon;
%feature("kwargs") addCut;
%feature("kwargs") addFillet;
-%feature("kwargs") addFilletMultiRadiusBycurvAbs;
-%feature("kwargs") addFilletMultiRadiusByPoints;
+%feature("kwargs") addFilletMultiRadius;
%feature("kwargs") addFuse;
%feature("kwargs") addIntersection;
%feature("kwargs") addMultiRotation;
initialize();
}
-FeaturesAPI_Fillet2D::FeaturesAPI_Fillet2D(const std::shared_ptr<ModelAPI_Feature>& theFeature,
- const std::list<ModelHighAPI_Selection>& theBaseObjects,
- const ModelHighAPI_Double& theRadius)
+FeaturesAPI_Fillet2D::FeaturesAPI_Fillet2D(
+ const std::shared_ptr<ModelAPI_Feature>& theFeature,
+ const std::list<ModelHighAPI_Selection>& theBaseObjects,
+ const ModelHighAPI_Double& theRadius)
: FeaturesAPI_Fillet(theFeature)
{
if (initialize()) {
}
FeaturesAPI_Fillet2D::FeaturesAPI_Fillet2D(const std::shared_ptr<ModelAPI_Feature>& theFeature,
- const std::list<ModelHighAPI_Selection>& theBaseObjects,
+ const std::list<ModelHighAPI_Selection>& theEdgesFaces,
const ModelHighAPI_Double& theRadius1,
const ModelHighAPI_Double& theRadius2)
: FeaturesAPI_Fillet(theFeature)
{
if (initialize()) {
fillAttribute(FeaturesPlugin_Fillet::CREATION_METHOD_VARYING_RADIUS(), mycreationMethod);
- fillAttribute(theBaseObjects, mybaseObjects);
+ fillAttribute(theEdgesFaces, myedgesfacesselected);
fillAttribute(theRadius1, mystartRadius);
fillAttribute(theRadius2, myendRadius);
aBase->selectionList(FeaturesPlugin_Fillet::ARRAY_POINT_RADIUS_BY_POINTS());
AttributeTablesPtr anAttrTable =
aBase->tables(FeaturesPlugin_Fillet::VALUES_ID());
- theDumper << aBase << " = model.addFilletMultiRadiusByPoints("
+ theDumper << aBase << " = model.addFilletMultiRadius("
<< aDocName << ", " << anAttrEdgeSelec;
theDumper << ", " << anAttrPoint ;
theDumper<<", [";
AttributeSelectionListPtr anAttrEdgesFaces =
aBase->selectionList(FeaturesPlugin_Fillet::EDGES_FACES_MULTI_LIST_ID());
AttributeTablesPtr anAttrTable = aBase->tables(FeaturesPlugin_Fillet::VALUES_CURV_ID());
- theDumper << aBase << " = model.addFilletMultiRadiusBycurvAbs("
+ theDumper << aBase << " = model.addFilletMultiRadius("
<< aDocName << ", " << anAttrEdgesFaces;
theDumper << ", ";
theDumper<<"[";
AttributeDoublePtr anAttrRadius2 = aBase->real(FeaturesPlugin_Fillet::END_RADIUS_ID());
theDumper << ", " << anAttrRadius1 << ", " << anAttrRadius2;
}
+ if (!aBase->data()->version().empty())
+ theDumper << ", keepSubResults = True";
}
- if (!aBase->data()->version().empty())
- theDumper << ", keepSubResults = True";
-
theDumper << ")" << std::endl;
}
return aFillet;
}
-FilletPtr addFilletMultiRadiusByPoints(const std::shared_ptr<ModelAPI_Document>& thePart,
- const ModelHighAPI_Selection & theEdgeSelected,
- const std::list<ModelHighAPI_Selection>& thePoint,
- const std::list<ModelHighAPI_Double>& theRadius,
- const bool keepSubResults)
+FilletPtr addFilletMultiRadius(const std::shared_ptr<ModelAPI_Document>& thePart,
+ const ModelHighAPI_Selection & theEdgeSelected,
+ const std::list<ModelHighAPI_Selection>& thePoint,
+ const std::list<ModelHighAPI_Double>& theRadius)
{
FeaturePtr aFeature = thePart->addFeature(FeaturesAPI_Fillet2D::ID());
- if (!keepSubResults)
- aFeature->data()->setVersion("");
+ aFeature->data()->setVersion("");
FilletPtr aFillet;
return aFillet;
}
-FilletPtr addFilletMultiRadiusBycurvAbs(const std::shared_ptr<ModelAPI_Document>& thePart,
+FilletPtr addFilletMultiRadius(const std::shared_ptr<ModelAPI_Document>& thePart,
const std::list<ModelHighAPI_Selection>& theBaseObjects,
const std::list<ModelHighAPI_Double>& thePointCurvCood,
- const std::list<ModelHighAPI_Double>& theRadius,
- const bool keepSubResults)
+ const std::list<ModelHighAPI_Double>& theRadius)
{
FeaturePtr aFeature = thePart->addFeature(FeaturesAPI_Fillet2D::ID());
- if (!keepSubResults)
- aFeature->data()->setVersion("");
+ aFeature->data()->setVersion("");
FilletPtr aFillet;
/// Constructor with values.
FEATURESAPI_EXPORT
explicit FeaturesAPI_Fillet2D(const std::shared_ptr<ModelAPI_Feature>& theFeature,
- const std::list<ModelHighAPI_Selection>& theBaseObjects,
+ const std::list<ModelHighAPI_Selection>& theEdgesFaces,
const ModelHighAPI_Double& theRadius1,
const ModelHighAPI_Double& theRadius2);
/// Constructor with values.
FEATURESAPI_EXPORT
explicit FeaturesAPI_Fillet2D(const std::shared_ptr<ModelAPI_Feature>& theFeature,
- const std::list<ModelHighAPI_Selection>& theBaseObjects,
+ const std::list<ModelHighAPI_Selection>& theEdgesFaces,
const std::list<ModelHighAPI_Double>& thepointCurvCood,
const std::list<ModelHighAPI_Double>& theRadius);
/// Destructor.
/// \ingroup CPPHighAPI
/// \brief Create Fillet feature.
FEATURESAPI_EXPORT
-FilletPtr addFilletMultiRadiusByPoints(const std::shared_ptr<ModelAPI_Document>& thePart,
- const ModelHighAPI_Selection & theEdgeSelected,
- const std::list<ModelHighAPI_Selection>& thePoint,
- const std::list<ModelHighAPI_Double>& theRadius,
- const bool keepSubResults= false);
+FilletPtr addFilletMultiRadius(const std::shared_ptr<ModelAPI_Document>& thePart,
+ const ModelHighAPI_Selection & theEdgeSelected,
+ const std::list<ModelHighAPI_Selection>& thePoint,
+ const std::list<ModelHighAPI_Double>& theRadius);
/// \ingroup CPPHighAPI
/// \brief Create Fillet feature.
FEATURESAPI_EXPORT
-FilletPtr addFilletMultiRadiusBycurvAbs( const std::shared_ptr<ModelAPI_Document>& thePart,
+FilletPtr addFilletMultiRadius( const std::shared_ptr<ModelAPI_Document>& thePart,
const std::list<ModelHighAPI_Selection>& theBaseObjects,
const std::list<ModelHighAPI_Double>& thePointCurvCood,
- const std::list<ModelHighAPI_Double>& theRadius,
- const bool keepSubResults= false);
+ const std::list<ModelHighAPI_Double>& theRadius);
#endif // FeaturesAPI_Fillet_H_
GeomAlgoAPI
GeomValidators
Config
+ ModuleBase
${OpenCASCADE_Visualization_LIBRARIES}
)
aHeaders << "Radius";
myDataTbl->setHorizontalHeaderLabels(aHeaders);
+ myDataTbl->installEventFilter(this);
QTableWidgetItem* anItem;
for(int j =0; j<3;j++)
//**********************************************************************************
bool FeaturesPlugin_WidgetFilletMultiRadiuses::eventFilter(QObject* theObject, QEvent* theEvent)
{
+ if (theEvent->type() == QEvent::KeyPress) {
+ QKeyEvent* akey = static_cast<QKeyEvent*>(theEvent);
+ if ( (akey->key()==Qt::Key_Enter) || (akey->key()==Qt::Key_Return) ) {
+ updateObject(myFeature);
+ }
+ }
return ModuleBase_WidgetSelector::eventFilter(theObject, theEvent);
}
}
myDataTbl->model()->removeRow(anIndex.row());
myDataTbl->blockSignals(false);
-
emit valuesChanged();
+ updateObject(myFeature);
}
}
#=========================================================================
aSession.startOperation()
aFillet1.string("creation_method").setValue("variable_radius")
+anObjects = aFillet1.selectionList("edges_faces_seleted")
+anObjects.append("[Box_1_1/Left][Box_1_1/Top]", "edge")
aFillet1.real("radius1").setValue(5)
aFillet1.real("radius2").setValue(1)
aSession.finishOperation()
import math
from tempfile import TemporaryDirectory
-import GEOM
+
from ModelAPI import *
from salome.shaper import model
-import SHAPERSTUDY
-from salome.geom import geomBuilder
+
from GeomAPI import GeomAPI_Shape
from GeomAlgoAPI import *
-#import SALOMEDS
-
-
__updated__ = "2020-10-10"
-salome.salome_init(1)
-
#=========================================================================
# Help functions
#=========================================================================
assert not os.path.exists(theFileName), \
"Can not remove file {0}".format(theFileName)
-#=========================================================================
-# test Fillet on a solid with a constant radius
-#=========================================================================
-def testFillet_constant_radius_onsolids():
-
- model.begin()
- partSet = model.moduleDocument()
- ### Create Part
- Part_1 = model.addPart(partSet)
- Part_1_doc = Part_1.document()
-
- ### Create Box
- Box_1 = model.addBox(Part_1_doc, 20, 30, 10)
-
- ### Create Fillet
- Fillet_1 = model.addFillet(Part_1_doc, [model.selection("SOLID", "Box_1_1")], 2, keepSubResults = True)
-
- ### Create Export
- Export_1 = model.exportToXAO(Part_1_doc, '/tmp/shaper_exp_cglb.xao', model.selection("SOLID", "Fillet_1_1"), 'XAO')
-
- model.end()
-
- # Check results
- ###
- ### GEOM component
- ###
-
- geompy = geomBuilder.New()
-
- O = geompy.MakeVertex(0, 0, 0)
- OX = geompy.MakeVectorDXDYDZ(1, 0, 0)
- OY = geompy.MakeVectorDXDYDZ(0, 1, 0)
- OZ = geompy.MakeVectorDXDYDZ(0, 0, 1)
-
- # where we import the fillet from SHAPER and get its basic properties
- (imported, Fillet_1_1, [], [], []) = geompy.ImportXAO("/tmp/shaper_exp_cglb.xao")
- geompy.addToStudy( O, 'O' )
- geompy.addToStudy( OX, 'OX' )
- geompy.addToStudy( OY, 'OY' )
- geompy.addToStudy( OZ, 'OZ' )
- geompy.addToStudy( Fillet_1_1, 'Fillet_1_1' )
-
- myDelta = 1e-6
- Props_shaper = geompy.BasicProperties(Fillet_1_1)
- print("\nBasic Properties:")
- print(" Wires length: ", Props_shaper[0])
- print(" Surface area: ", Props_shaper[1])
- print(" Volume : ", Props_shaper[2])
-
- # where we build the same fillet in GEOM for comparison
- Box_1 = geompy.MakeBoxDXDYDZ(20, 30, 10)
- Fillet_1 = geompy.MakeFilletAll(Box_1, 2)
- geompy.addToStudy( Box_1, 'Box_1' )
- geompy.addToStudy( Fillet_1, 'Fillet_1' )
-
- Props_geom = geompy.BasicProperties(Fillet_1)
- print("\nBasic Properties:")
- print(" Wires length: ", Props_geom[0])
- print(" Surface area: ", Props_geom[1])
- print(" Volume : ", Props_geom[2])
-
- aRefSurface = Props_geom[1]
- aResSurface = Props_shaper[1]
- assert (math.fabs(aResSurface - aRefSurface) < myDelta), "The surface is wrong: expected = {0}, real = {1}".format(aRefSurface, aResSurface)
-
- aRefVolume = Props_geom[2]
- aResVolume = Props_shaper[2]
- assert (math.fabs(aResVolume - aRefVolume) < myDelta), "The volume is wrong: expected = {0}, real = {1}".format(aRefVolume, aResVolume)
#=========================================================================
# test Fillet on an edge with multiple radii identified by points
Point_3 = model.addPoint(Part_1_doc, model.selection("EDGE", "[Box_1_1/Left][Box_1_1/Top]"), 0.8, True, False)
### Create Fillet on an edge with 4 radii identified by points
- Fillet_1 = model.addFilletMultiRadiusByPoints(Part_1_doc, model.selection("EDGE", "[Box_1_1/Left][Box_1_1/Top]"), [model.selection("VERTEX", "Point_1"), model.selection("VERTEX", "Point_2")], [0.5, 2, 1, 2], keepSubResults = True)
+ Fillet_1 = model.addFilletMultiRadius(Part_1_doc, model.selection("EDGE", "[Box_1_1/Left][Box_1_1/Top]"), [model.selection("VERTEX", "Point_1"), model.selection("VERTEX", "Point_2")], [0.5, 2, 1, 2])
model.end()
+ model.testNbResults(Fillet_1, 1)
+ model.testResultsVolumes(Fillet_1, [995.3927])
#=========================================================================
# test Fillet on an edge(s) or/and face(s) with multiple radii identified
Box_1 = model.addBox(Part_1_doc, 10, 10, 10)
### Create Fillet
- Fillet_1 = model.addFilletMultiRadiusBycurvAbs(Part_1_doc, [model.selection("EDGE", "[Box_1_1/Left][Box_1_1/Top]")], [0, 0.4, 0.7, 1],[1, 2, 0.5, 2], keepSubResults = True)
+ Fillet_1 = model.addFilletMultiRadius(Part_1_doc, [model.selection("EDGE", "[Box_1_1/Left][Box_1_1/Top]")], [0, 0.4, 0.7, 1],[1, 2, 0.5, 2])
### Create Fillet
- Fillet_2 = model.addFilletMultiRadiusBycurvAbs(Part_1_doc, [model.selection("FACE", "Box_1_1/Right")], [0, 0.5, 1],[1, 0.5, 1], keepSubResults = True)
-
+ Fillet_2 = model.addFilletMultiRadius(Part_1_doc, [model.selection("FACE", "Box_1_1/Right")], [0, 0.5, 1],[1, 0.5, 1])
model.end()
+ model.testNbResults(Fillet_2, 1)
+ model.testResultsVolumes(Fillet_2, [990.974897])
+
if __name__ == '__main__':
with TemporaryDirectory() as tmp_dir:
- testFillet_constant_radius_onsolids()
testFillet_multiradii_bypoints()
testFillet_multiradii_bycurvabs()
-
#=========================================================================
# End of test
#=========================================================================
### Create Point
Point_1 = model.addPoint(Part_1_doc, model.selection("EDGE", "[Box_1_1/Left][Box_1_1/Top]"), 0.5, True, False)
Point_2 = model.addPoint(Part_1_doc, model.selection("EDGE", "[Box_1_1/Left][Box_1_1/Top]"), 0.2, True, False)
-Fillet_1 = model.addFilletMultiRadiusByPoints(Part_1_doc,
+Fillet_1 = model.addFilletMultiRadius(Part_1_doc,
model.selection("EDGE", "[Box_1_1/Left][Box_1_1/Top]"),
[model.selection("VERTEX", "Point_1"), model.selection("VERTEX", "Point_2")],
- [1, 0.5, 0.5, 2], keepSubResults = True)
+ [1, 0.5, 0.5, 2])
model.do()
model.end()
Part_1 = model.addPart(partSet)
Part_1_doc = Part_1.document()
Box_1 = model.addBox(Part_1_doc, 10, 10, 10)
-Fillet_1 = model.model.addFilletMultiRadiusBycurvAbs
+Fillet_1 = model.addFilletMultiRadius
(Part_1_doc, [model.selection("EDGE", "[Box_1_1/Front][Box_1_1/Top]")],
- [0, 0.5, 1],[1, 0.5, 1], keepSubResults = True)
+ [0, 0.5, 1],[1, 0.5, 1])
model.do()
model.end()
**TUI Command**:
-.. py:function:: model.addFillet(Part_doc, shapes, R1, R2)
+.. py:function:: model.addFillet(Part_doc,[face,edge], R1, R2)
:param document Part_doc: The current part object.
- :param list shapes: A list of faces and edges subject to fillet operation in format *model.selection(TYPE, shape)*.
- :param double R1: Start radius value.
- :param double R2: End radius value.
+ :param list: A list of faces and edges subject to fillet operation in format *model.selection(TYPE, shape)*.
+ :param number: Start radius value.
+ :param number: End radius value.
:return: Created object.
Result
**TUI Command**:
-.. py:function:: model.addFilletMultiRadiusBycurvAbs(Part_doc, shapes, listAbsc, listRadius)
+.. py:function:: model.addFilletMultiRadius(Part_doc, [face,edge], [absc1,absc2,...], [r1,r2,...])
:param document Part_doc: The current part object.
- :param list shapes: A list of faces and edges subject to fillet operation in format *model.selection(TYPE, shape)*.
- :param listAbsc: list of curvilinea abscissa.
- :param listRadius: list of radius value.
+ :param list: A list of faces and edges subject to fillet operation in format *model.selection(TYPE, shape)*.
+ :param list number: list of curvilinea abscissa.
+ :param list number: list of radius value.
:return: Created object.
Result
**TUI Command**:
-.. py:function:: model.addFilletMultiRadiusByPoints(Part_doc, edge, Points, ListRadius)
+.. py:function:: model.addFilletMultiRadius(Part_doc, edge, [point],[r1,r2,...])
:param document Part_doc: The current part object.
:param edge: An edge subject to fillet operation in format *model.selection(TYPE, shape)*.
- :param Points: list of point in format *model.selection(TYPE, shape)*.
- :param ListRadius: list of radius value.
+ :param list: list of point in format *model.selection(TYPE, shape)*.
+ :param list number: list of radius value.
:return: Created object.
Result
from FeaturesAPI import addCut, addFuse, addCommon, addSmash, addSplit
from FeaturesAPI import addIntersection, addPartition, addUnion, addRemoveSubShapes
from FeaturesAPI import addRecover
-from FeaturesAPI import addFillet,addFilletMultiRadiusBycurvAbs, addFilletMultiRadiusByPoints, addChamfer
+from FeaturesAPI import addFillet, addFilletMultiRadius, addChamfer
from FeaturesAPI import addFusionFaces
from FeaturesAPI import measureLength, measureDistance, measureRadius, measureAngle
from FeaturesAPI import addRemoveResults