ADD_CUSTOM_TARGET(run_compatibility_tests COMMAND ${CMAKE_CTEST_COMMAND} -C "${CMAKE_BUILD_TYPE}" -LE "tests_compatibility")
ENDIF(ADD_COMPATIBILITY_TESTS)
+IF(ADD_HDF_TESTS)
+ ADD_SUBDIRECTORY (test.hdfs)
+ENDIF(ADD_HDF_TESTS)
+
IF(SHAPER_BUILD_DOC)
INCLUDE(FindSphinx)
ADD_SUBDIRECTORY (doc)
# Step5. Extrusion.
Wire = model.selection("WIRE", "Sketch_1/Face-SketchLine_5r-SketchLine_6r-SketchLine_7r-SketchLine_8r-SketchLine_9r-SketchLine_1r_wire")
-To = model.selection("FACE", "Revolution_1_1/Generated_Face&Face_1_1/Edge_2")
-From = model.selection("FACE", "Revolution_1_1/Generated_Face&Face_1_1/Edge_7")
+To = model.selection("FACE", "Revolution_1_1/Generated_Face&Point_4/Point_4")
+From = model.selection("FACE", "Revolution_1_1/Generated_Face&Point_1/Point_1")
Extrusion_1 = model.addExtrusion(Part_1_doc, [Wire], model.selection("EDGE", "PartSet/OZ"), To, 0, From, 0)
Common_1 = model.addCommon(Part_1_doc, [model.selection("SOLID", "Revolution_1_1"), model.selection("SOLID", "Extrusion_1_1")])
# Step7. Fillet.
-Fillet_1 = model.addFillet(Part_1_doc, [model.selection("EDGE", "[Revolution_1_1/Generated_Face&Face_1_1/Edge_3][Common_1_1/Modified_Face&Face_1_1/Edge_4]")], 10)
+Fillet_1 = model.addFillet(Part_1_doc, [model.selection("EDGE", "[Revolution_1_1/Generated_Face&Point_6/Point_6][Common_1_1/Modified_Face&Point_7/Point_7]")], 10)
# Step8. Box.
Box_1 = model.addBox(Part_1_doc, 20, 120, 20)
Cut_1 = model.addCut(Part_1_doc, [model.selection("SOLID", "Fillet_1_1")], [model.selection("COMPOUND", "AngularCopy_1_1")])
Cut_1.result().setColor(255, 214, 0)
-model.do()
model.end()
ADD_COMPATIBILITY_TESTS=TRUE
shift
;;
+ hdf|test-hdf-models)
+ ADD_HDF_TESTS=TRUE
+ shift
+ ;;
*)
shift
;;
CMAKE_ARGS="${CMAKE_ARGS} -DUSE_TEST_COVERAGE=${USE_TEST_COVERAGE:-OFF}"
CMAKE_ARGS="${CMAKE_ARGS} -DADD_MODELS_TESTS=${ADD_MODELS_TESTS:-FALSE}"
CMAKE_ARGS="${CMAKE_ARGS} -DADD_COMPATIBILITY_TESTS=${ADD_COMPATIBILITY_TESTS:-FALSE}"
+CMAKE_ARGS="${CMAKE_ARGS} -DADD_HDF_TESTS=${ADD_HDF_TESTS:-FALSE}"
CMAKE_ARGS="${CMAKE_ARGS} -DCMAKE_INSTALL_PREFIX:PATH=${SHAPER_ROOT_DIR}"
CMAKE_ARGS="${CMAKE_ARGS} ${SOURCES_DIR}"
Events_InfoMessage& theError) const
{
if(theArguments.size() != 1) {
+ // LCOV_EXCL_START
std::string aMsg = "Error: BuildPlugin_ValidatorSubShapesSelection should be used only with "
"1 parameter(Sketch feature id).";
Events_InfoMessage("BuildPlugin_Validators", aMsg).send();
return false;
+ // LCOV_EXCL_STOP
}
// Get base objects list.
if(theAttribute->attributeType() != ModelAPI_AttributeSelectionList::typeId()) {
+ // LCOV_EXCL_START
std::string aMsg =
"Error: BuildPlugin_ValidatorSubShapesSelection does not support attribute type \""
"%1\"\n Only \"%2\" supported.";
Events_InfoMessage("BuildPlugin_Validators", aMsg).
arg(theAttribute->attributeType()).arg(ModelAPI_AttributeSelectionList::typeId()).send();
return false;
+ // LCOV_EXCL_STOP
}
AttributeSelectionListPtr aSelectionList =
std::dynamic_pointer_cast<ModelAPI_AttributeSelectionList>(theAttribute);
{
// Get base objects list.
if (theAttribute->attributeType() != ModelAPI_AttributeSelectionList::typeId()) {
+ // LCOV_EXCL_START
std::string aMsg =
"Error: BuildPlugin_ValidatorFillingSelection does not support attribute type \""
"%1\"\n Only \"%2\" supported.";
Events_InfoMessage("BuildPlugin_Validators", aMsg).
arg(theAttribute->attributeType()).arg(ModelAPI_AttributeSelectionList::typeId()).send();
return false;
+ // LCOV_EXCL_STOP
}
AttributeSelectionListPtr aSelectionList =
std::dynamic_pointer_cast<ModelAPI_AttributeSelectionList>(theAttribute);
myUseInput = false;
myNestedFeatures = "";
myModal = false;
+ myIsTitleInToolbar = true;
myIsApplyContinue = false;
}
return myIsAutoPreview;
}
+bool Config_FeatureMessage::isTitleInToolbar() const
+{
+ return myIsTitleInToolbar;
+}
+
bool Config_FeatureMessage::isModal() const
{
return myModal;
void Config_FeatureMessage::setHelpFileName(const std::string& aName)
{
myHelpFile = aName;
-}
\ No newline at end of file
+}
+
+void Config_FeatureMessage::setTitleInToolbar(bool theValue)
+{
+ myIsTitleInToolbar = theValue;
+}
bool myInternal; ///<Internal feature without GUI representation
bool myModal; ///<True if the feature has to be represented by modal dialog box
bool myIsAutoPreview; ///< Preview computation is performed automatically
+ bool myIsTitleInToolbar; ///< False if title should not be displayed in the toolbar
/// True if the feature can have Apply/Continue button in its property panel
bool myIsApplyContinue;
CONFIG_EXPORT bool isModal() const;
/// If true - the feature can have Apply/Continue button in its property panel
CONFIG_EXPORT bool isApplyContinue() const;
-
-
-
/// If true - preview of the feature is done by any modification of the feature attributes
CONFIG_EXPORT bool isAutoPreview() const;
+ /// If true - title should normally be displayed in the toolbar
+ CONFIG_EXPORT bool isTitleInToolbar() const;
///Set feature's Id
CONFIG_EXPORT void setId(const std::string& id);
CONFIG_EXPORT void setAutoPreview(bool isAutoPreview);
///Set modality state; If true - the feature will be represented by modal dialog box GUI
CONFIG_EXPORT void setModal(bool isModal);
+ ///Set flag to display title in toolbar
+ CONFIG_EXPORT void setTitleInToolbar(bool theValue);
///Set Apply/Continue state;
///If true - the feature can have Apply/Continue button in its property panel
CONFIG_EXPORT void setApplyContinue(bool isModal);
std::string aText = Config_Translator::translate(anId, getProperty(theFeatureNode, FEATURE_TEXT));
outFeatureMessage->setText(aText);
- std::string aToolTip = Config_Translator::translate(anId,
- getProperty(theFeatureNode, FEATURE_TOOLTIP));
+ bool isTitleInToolbar = getBooleanAttribute(theFeatureNode, FEATURE_TITLE_IN_TOOLBAR, true);
+ outFeatureMessage->setTitleInToolbar(isTitleInToolbar);
+ //std::string aToolTip = Config_Translator::translate(
+ // anId, getProperty(theFeatureNode, FEATURE_TOOLTIP));
+ //outFeatureMessage->setTooltip(aToolTip);
outFeatureMessage->setIcon(getProperty(theFeatureNode, FEATURE_ICON));
outFeatureMessage->setKeysequence(getProperty(theFeatureNode, FEATURE_KEYSEQUENCE));
std::string aHelpFile = getProperty(theFeatureNode, HELP_FILE);
const static char* FEATURE_MODAL = "modal";
const static char* FEATURE_APPLY_CONTINUE = "apply_continue";
const static char* FEATURE_AUTO_PREVIEW = "auto_preview";
+const static char* FEATURE_TITLE_IN_TOOLBAR = "titleInToolbar";
// NODE_VALIDATOR properties
const static char* _PARAMETERS = "parameters";
//==================================================================================================
ConstructionAPI_Point::ConstructionAPI_Point(const std::shared_ptr<ModelAPI_Feature>& theFeature,
const ModelHighAPI_Selection& theObject,
- const bool theIsCircularEdge)
+ const bool theIsCircularEdge,
+ const bool theIsXYZSelection)
: ModelHighAPI_Interface(theFeature)
{
if (initialize())
{
if (theIsCircularEdge) {
setByCenterOfCircle(theObject);
- } else if (theObject.shapeType() == "VERTEX") {
+ } else if (theObject.shapeType() == "VERTEX" && theIsXYZSelection) {
// This is tricky way to get vertex shape.
fillAttribute(theObject, mypointToProject);
GeomShapePtr aShape = mypointToProject->value();
const ModelHighAPI_Double& theY,
const ModelHighAPI_Double& theZ)
{
- //fillAttribute(ConstructionPlugin_Point::CREATION_METHOD_BY_XYZ(), mycreationMethod);
-
- // TODO: Fill point attribute
- //fillAttribute(theX, myx);
- //fillAttribute(theY, myy);
- //fillAttribute(theZ, myz);
-
fillAttribute(ConstructionPlugin_Point::CREATION_METHOD_BY_XYZ(), mycreationMethod);
fillAttribute(theX, theY, theZ, mypoint);
fillAttribute(ConstructionPlugin_Point::GEOMETRICAL_PROPERTY_TYPE_BY_CENTER_OF_GRAVITY(),
mygeometricalPropertyType);
fillAttribute(theObject, myobjectForCenterOfGravity);
+
+ execute();
}
//==================================================================================================
fillAttribute(ConstructionPlugin_Point::GEOMETRICAL_PROPERTY_TYPE_BY_CENTER_OF_CIRCLE(),
mygeometricalPropertyType);
fillAttribute(theObject, myobjectForCenterOfCircle);
+
+ execute();
}
//==================================================================================================
std::shared_ptr<ModelAPI_Feature> aFeature = thePart->addFeature(ConstructionAPI_Point::ID());
return PointPtr(new ConstructionAPI_Point(aFeature, theObject, theIsCircularEdge));
}
+
+//==================================================================================================
+PointPtr addPointXYZ(const std::shared_ptr<ModelAPI_Document> & thePart,
+ const ModelHighAPI_Selection& theObject)
+{
+ std::shared_ptr<ModelAPI_Feature> aFeature = thePart->addFeature(ConstructionAPI_Point::ID());
+ return PointPtr(new ConstructionAPI_Point(aFeature, theObject, false, true));
+}
const ModelHighAPI_Selection& theObject3);
/// Constructor with values: object and circular edge flag.
+ /// May be used for creation of point by coordinates using selection-vertex.
CONSTRUCTIONAPI_EXPORT
ConstructionAPI_Point(const std::shared_ptr<ModelAPI_Feature>& theFeature,
const ModelHighAPI_Selection& theObject,
- const bool theIsCircularEdge = false);
+ const bool theIsCircularEdge = false,
+ const bool theIsXYZSelection = false);
/// Destructor.
CONSTRUCTIONAPI_EXPORT
const ModelHighAPI_Selection& theObject,
const bool theIsCircularEdge = false);
+/// \ingroup CPPHighAPI
+/// \brief Create Point feature by coordinates using the selected vertex.
+CONSTRUCTIONAPI_EXPORT
+PointPtr addPointXYZ(const std::shared_ptr<ModelAPI_Document> & thePart,
+ const ModelHighAPI_Selection& theObject);
+
#endif /* SRC_CONSTRUCTIONAPI_CONSTRUCTIONAPI_POINT_H_ */
# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
#
+from SketchAPI import *
from salome.shaper import model
model.begin()
partSet = model.moduleDocument()
Part_1 = model.addPart(partSet)
Part_1_doc = Part_1.document()
-Box_1 = model.addBox(Part_1_doc, 10, 10, 10)
-Point_2 = model.addPoint(Part_1_doc, 10, 0, 10)
+
+Sketch_1 = model.addSketch(Part_1_doc, model.defaultPlane("YOZ"))
+SketchLine_1 = Sketch_1.addLine(10, 10, 0, 10)
+SketchLine_2 = Sketch_1.addLine(0, 10, 0, 0)
+SketchLine_3 = Sketch_1.addLine(0, 0, 10, 0)
+SketchLine_4 = Sketch_1.addLine(10, 0, 10, 10)
+SketchConstraintCoincidence_1 = Sketch_1.setCoincident(SketchLine_4.endPoint(), SketchLine_1.startPoint())
+SketchConstraintCoincidence_2 = Sketch_1.setCoincident(SketchLine_1.endPoint(), SketchLine_2.startPoint())
+SketchConstraintCoincidence_3 = Sketch_1.setCoincident(SketchLine_2.endPoint(), SketchLine_3.startPoint())
+SketchConstraintCoincidence_4 = Sketch_1.setCoincident(SketchLine_3.endPoint(), SketchLine_4.startPoint())
+SketchConstraintHorizontal_1 = Sketch_1.setHorizontal(SketchLine_1.result())
+SketchConstraintVertical_1 = Sketch_1.setVertical(SketchLine_2.result())
+SketchConstraintHorizontal_2 = Sketch_1.setHorizontal(SketchLine_3.result())
+SketchConstraintVertical_2 = Sketch_1.setVertical(SketchLine_4.result())
+SketchConstraintLength_1 = Sketch_1.setLength(SketchLine_1.result(), 10)
+SketchConstraintLength_2 = Sketch_1.setLength(SketchLine_4.result(), 10)
+SketchProjection_1 = Sketch_1.addProjection(model.selection("VERTEX", "PartSet/Origin"), False)
+SketchPoint_1 = SketchProjection_1.createdFeature()
+SketchConstraintCoincidence_5 = Sketch_1.setCoincident(SketchLine_2.endPoint(), SketchAPI_Point(SketchPoint_1).coordinates())
model.do()
+Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("FACE", "Sketch_1/Face-SketchLine_1r-SketchLine_2f-SketchLine_3f-SketchLine_4f")], model.selection(), 10, 0)
+Point_2 = model.addPointXYZ(Part_1_doc, model.selection("VERTEX", "[Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_1][Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_2][Extrusion_1_1/To_Face]"))
model.end()
from GeomAPI import GeomAPI_Vertex
#=========================================================================
# Export a shape into STEP
#=========================================================================
- testExport("STEP", "STEP", os.path.join(tmp_dir, "screw_export.step"), 3.78825807533e-06, 10 ** -17)
- testExport("STP", "STEP", os.path.join(tmp_dir, "screw_export.stp"), 3.78825807533e-06, 10 ** -17)
- testExport("Regular", "", os.path.join(tmp_dir, "screw_export.step"), 3.78825807533e-06, 10 ** -17)
+ testExport("STEP", "STEP", os.path.join(tmp_dir, "screw_export.step"), 3.788258075329978e-06, 10 ** -17)
+ testExport("STP", "STEP", os.path.join(tmp_dir, "screw_export.stp"), 3.788258075329978e-06, 10 ** -17)
+ testExport("Regular", "", os.path.join(tmp_dir, "screw_export.step"), 3.788258075329978e-06, 10 ** -17)
#=========================================================================
# Export a shape into IGES
#=========================================================================
- testExport("IGES-5.1", "IGES-5.1", os.path.join(tmp_dir, "screw_export-5.1.iges"), 3.78829613776e-06, 10 ** -17)
- testExport("IGS-5.1", "IGES-5.1", os.path.join(tmp_dir, "screw_export-5.1.igs"), 3.78829613776e-06, 10 ** -17)
- testExport("Regular", "", os.path.join(tmp_dir, "screw_export-5.1.iges"), 3.78829613776e-06, 10 ** -17)
+ testExport("IGES-5.1", "IGES-5.1", os.path.join(tmp_dir, "screw_export-5.1.iges"), 0.0019293313766693052, 10 ** -17)
+ testExport("IGS-5.1", "IGES-5.1", os.path.join(tmp_dir, "screw_export-5.1.igs"), 0.0019293313766693052, 10 ** -17)
+ testExport("Regular", "", os.path.join(tmp_dir, "screw_export-5.1.iges"), 0.0019293313766693052, 10 ** -17)
testExport("IGES-5.3", "IGES-5.3", os.path.join(tmp_dir, "screw_export-5.3.iges"), 3.78827401651e-06, 10 ** -17)
testExport("IGS-5.3", "IGES-5.3", os.path.join(tmp_dir, "screw_export-5.3.igs"), 3.78827401651e-06, 10 ** -17)
#=========================================================================
# Create a shape imported from IGES
#=========================================================================
shape_path = getShapePath("Iges/bearing.igs")
- testImport("IGES", shape_path, 6.86970803067e-14, 10 ** -25)
+ testImport("IGES", shape_path, 1.3407098545036494e-08, 10 ** -25)
shape_path = shutil.copyfile(shape_path, os.path.join(tmp_dir, "bearing.iges"))
- testImport("IGS", shape_path, 6.86970803067e-14, 10 ** -25)
+ testImport("IGS", shape_path, 1.3407098545036494e-08, 10 ** -25)
#=========================================================================
# Create a shape imported from XAO
}
myChangedInCode = true;
+ if (theID == BASE_SHAPE_ID() || theID == SUBSHAPES_TO_KEEP_ID() ||
+ theID == SUBSHAPES_TO_REMOVE_ID()) {
+ std::list<ResultPtr> anAllSubs;
+ ModelAPI_Tools::allSubs(aResultBody, anAllSubs);
- if(theID == BASE_SHAPE_ID()) {
- aSubShapesToKeepAttrList->clear();
- aSubShapesToRemoveAttrList->clear();
+ if(theID == BASE_SHAPE_ID()) {
+ aSubShapesToKeepAttrList->clear();
+ aSubShapesToRemoveAttrList->clear();
- if (!aBaseShape.get()) {
- return;
- }
+ if (!aBaseShape.get()) {
+ return;
+ }
- std::list<GeomShapePtr> aSubShapes = GeomAlgoAPI_ShapeTools::getLowLevelSubShapes(aBaseShape);
- for (ListOfShape::const_iterator anIt = aSubShapes.cbegin(); anIt != aSubShapes.cend(); ++anIt)
- {
- GeomShapePtr aSubShape = *anIt;
- if(!isHasSubs) {
- aSubShapesToKeepAttrList->append(aContext, aSubShape);
- } else {
- std::list<ResultPtr> anAllSubs;
- ModelAPI_Tools::allSubs(aResultBody, anAllSubs);
- std::list<ResultPtr>::iterator aSubsIt = anAllSubs.begin();
- for(; aSubsIt != anAllSubs.end(); aSubsIt++) {
- ResultBodyPtr aSub = std::dynamic_pointer_cast<ModelAPI_ResultBody>(*aSubsIt);
- if (aSub && aSub->shape().get() && aSub->shape()->isSubShape(aSubShape)) {
- aSubShapesToKeepAttrList->append(aSub, aSubShape);
- break;
+ std::list<GeomShapePtr> aSubShapes = GeomAlgoAPI_ShapeTools::getLowLevelSubShapes(aBaseShape);
+ ListOfShape::const_iterator anIt = aSubShapes.cbegin();
+ for (; anIt != aSubShapes.cend(); ++anIt)
+ {
+ GeomShapePtr aSubShape = *anIt;
+ if(!isHasSubs) {
+ aSubShapesToKeepAttrList->append(aContext, aSubShape);
+ } else {
+ std::list<ResultPtr>::iterator aSubsIt = anAllSubs.begin();
+ for(; aSubsIt != anAllSubs.end(); aSubsIt++) {
+ ResultBodyPtr aSub = std::dynamic_pointer_cast<ModelAPI_ResultBody>(*aSubsIt);
+ if (aSub && aSub->shape().get() && aSub->shape()->isSubShape(aSubShape)) {
+ aSubShapesToKeepAttrList->append(aSub, aSubShape);
+ break;
+ }
}
}
}
}
- }
- else if (theID == SUBSHAPES_TO_KEEP_ID())
- {
- aSubShapesToRemoveAttrList->clear();
+ else if (theID == SUBSHAPES_TO_KEEP_ID())
+ {
+ aSubShapesToRemoveAttrList->clear();
- if (!aBaseShape.get()) {
- return;
- }
+ if (!aBaseShape.get()) {
+ return;
+ }
- int anIndex;
- const int aSubsToKeepNb = aSubShapesToKeepAttrList->size();
- std::list<GeomShapePtr> aSubShapes = GeomAlgoAPI_ShapeTools::getLowLevelSubShapes(aBaseShape);
- for (ListOfShape::const_iterator anIt = aSubShapes.cbegin(); anIt != aSubShapes.cend(); ++anIt)
- {
- GeomShapePtr aSubShape = *anIt;
+ int anIndex;
+ // optimization: collect selection attribute values into a map
+ const int aSubsToKeepNb = aSubShapesToKeepAttrList->size();
+ GeomAPI_DataMapOfShapeShape aSubShapesToKeep;
for(anIndex = 0; anIndex < aSubsToKeepNb; ++anIndex) {
AttributeSelectionPtr anAttrSelectionInList = aSubShapesToKeepAttrList->value(anIndex);
GeomShapePtr aSubShapeToKeep = anAttrSelectionInList->value();
- if (aSubShapeToKeep.get() && aSubShapeToKeep->isEqual(aSubShape)) {
- break;
- }
+ if (aSubShapeToKeep.get())
+ aSubShapesToKeep.bind(aSubShapeToKeep, aSubShapeToKeep);
}
- if (anIndex == aSubsToKeepNb) {
+ std::list<GeomShapePtr> aSubShapes = GeomAlgoAPI_ShapeTools::getLowLevelSubShapes(aBaseShape);
+ ListOfShape::const_iterator anIt = aSubShapes.cbegin();
+ for (; anIt != aSubShapes.cend(); ++anIt)
+ {
+ GeomShapePtr aSubShape = *anIt;
+ if (aSubShapesToKeep.isBound(aSubShape))
+ continue;
+
if(!isHasSubs) {
aSubShapesToRemoveAttrList->append(aContext, aSubShape);
- } else {
- std::list<ResultPtr> anAllSubs;
- ModelAPI_Tools::allSubs(aResultBody, anAllSubs);
+ }
+ else {
std::list<ResultPtr>::iterator aSubsIt = anAllSubs.begin();
- for(; aSubsIt != anAllSubs.end(); aSubsIt++) {
+ for (; aSubsIt != anAllSubs.end(); aSubsIt++) {
ResultBodyPtr aSub = std::dynamic_pointer_cast<ModelAPI_ResultBody>(*aSubsIt);
if (aSub && aSub->shape().get() && aSub->shape()->isSubShape(aSubShape)) {
aSubShapesToRemoveAttrList->append(aSub, aSubShape);
}
}
}
- }
- else if (theID == SUBSHAPES_TO_REMOVE_ID())
- {
- aSubShapesToKeepAttrList->clear();
+ else if (theID == SUBSHAPES_TO_REMOVE_ID())
+ {
+ aSubShapesToKeepAttrList->clear();
- if (!aBaseShape.get()) {
- return;
- }
+ if (!aBaseShape.get()) {
+ return;
+ }
- int anIndex;
- const int aSubsToRemoveNb = aSubShapesToRemoveAttrList->size();
- std::list<GeomShapePtr> aSubShapes = GeomAlgoAPI_ShapeTools::getLowLevelSubShapes(aBaseShape);
- for (ListOfShape::const_iterator anIt = aSubShapes.cbegin(); anIt != aSubShapes.cend(); ++anIt)
- {
- GeomShapePtr aSubShape = *anIt;
+ int anIndex;
+ const int aSubsToRemoveNb = aSubShapesToRemoveAttrList->size();
+ GeomAPI_DataMapOfShapeShape aSubShapesToRemove;
for(anIndex = 0; anIndex < aSubsToRemoveNb; ++anIndex) {
AttributeSelectionPtr anAttrSelectionInList = aSubShapesToRemoveAttrList->value(anIndex);
GeomShapePtr aSubShapeToRemove = anAttrSelectionInList->value();
- if (aSubShapeToRemove.get() && aSubShapeToRemove->isEqual(aSubShape)) {
- break;
- }
+ if (aSubShapeToRemove.get())
+ aSubShapesToRemove.bind(aSubShapeToRemove, aSubShapeToRemove);
}
- if (anIndex == aSubsToRemoveNb) {
- if(!isHasSubs) {
+
+ std::list<GeomShapePtr> aSubShapes = GeomAlgoAPI_ShapeTools::getLowLevelSubShapes(aBaseShape);
+ ListOfShape::const_iterator anIt = aSubShapes.cbegin();
+ for (; anIt != aSubShapes.cend(); ++anIt)
+ {
+ GeomShapePtr aSubShape = *anIt;
+ if (aSubShapesToRemove.isBound(aSubShape))
+ continue;
+
+ if (!isHasSubs) {
aSubShapesToKeepAttrList->append(aContext, aSubShape);
- } else {
- std::list<ResultPtr> anAllSubs;
- ModelAPI_Tools::allSubs(aResultBody, anAllSubs);
+ }
+ else {
std::list<ResultPtr>::iterator aSubsIt = anAllSubs.begin();
- for(; aSubsIt != anAllSubs.end(); aSubsIt++) {
+ for (; aSubsIt != anAllSubs.end(); aSubsIt++) {
ResultBodyPtr aSub = std::dynamic_pointer_cast<ModelAPI_ResultBody>(*aSubsIt);
if (aSub && aSub->shape().get() && aSub->shape()->isSubShape(aSubShape)) {
aSubShapesToKeepAttrList->append(aSub, aSubShape);
model.testNbSubResults(Partition_1, [2])
model.testNbSubShapes(Partition_1, GeomAPI_Shape.SOLID, [4])
model.testNbSubShapes(Partition_1, GeomAPI_Shape.FACE, [26])
-model.testResultsVolumes(Partition_1, [61838.592736754246288910508155823])
+model.testResultsVolumes(Partition_1, [58449.978430461182142607867717743])
# update extrusion and check partition
Param_ExtrusionMin.setValue(-5)
model.testNbSubResults(Partition_1, [2])
model.testNbSubShapes(Partition_1, GeomAPI_Shape.SOLID, [3])
model.testNbSubShapes(Partition_1, GeomAPI_Shape.FACE, [23])
-model.testResultsVolumes(Partition_1, [60961.060159030253998935222625732])
+model.testResultsVolumes(Partition_1, [58449.978432491210696753114461899])
# change radius of a circle and check partition
Param_Radius.setValue(50)
model.testNbSubResults(Partition_1, [2])
model.testNbSubShapes(Partition_1, GeomAPI_Shape.SOLID, [3])
model.testNbSubShapes(Partition_1, GeomAPI_Shape.FACE, [23])
-model.testResultsVolumes(Partition_1, [83608.865629965730477124452590942])
+model.testResultsVolumes(Partition_1, [81554.943249323987402021884918213])
# check naming
model.testHaveNamingSubshapes(Partition_1, model, Part_1_doc)
model.testNbSubResults(Partition_1, [2])
model.testNbSubShapes(Partition_1, GeomAPI_Shape.SOLID, [3])
model.testNbSubShapes(Partition_1, GeomAPI_Shape.FACE, [22])
-model.testResultsVolumes(Partition_1, [61945.742345225989993195980787277])
+model.testResultsVolumes(Partition_1, [58449.978430083079729229211807251])
# update extrusion and check partition
Param_ExtrusionMin.setValue(-5)
model.testNbSubResults(Partition_1, [2])
model.testNbSubShapes(Partition_1, GeomAPI_Shape.SOLID, [3])
model.testNbSubShapes(Partition_1, GeomAPI_Shape.FACE, [21])
-model.testResultsVolumes(Partition_1, [60999.340090954778133891522884369])
+model.testResultsVolumes(Partition_1, [58449.978432399570010602474212646])
# change radius of a circle and check partition
Param_Radius.setValue(50)
model.testNbSubResults(Partition_1, [2])
model.testNbSubShapes(Partition_1, GeomAPI_Shape.SOLID, [3])
model.testNbSubShapes(Partition_1, GeomAPI_Shape.FACE, [21])
-model.testResultsVolumes(Partition_1, [83593.613567417080048471689224243])
+model.testResultsVolumes(Partition_1, [81554.943249112344346940517425537])
# check naming
model.testHaveNamingSubshapes(Partition_1, model, Part_1_doc)
model.testNbSubResults(Partition_1, [2])
model.testNbSubShapes(Partition_1, GeomAPI_Shape.SOLID, [4])
model.testNbSubShapes(Partition_1, GeomAPI_Shape.FACE, [24])
-model.testResultsVolumes(Partition_1, [61517.614401630766224116086959839])
+model.testResultsVolumes(Partition_1, [58449.978431462892331182956695557])
# update extrusion and check partition
Param_ExtrusionMin.setValue(-5)
model.testNbSubResults(Partition_1, [2])
model.testNbSubShapes(Partition_1, GeomAPI_Shape.SOLID, [4])
model.testNbSubShapes(Partition_1, GeomAPI_Shape.FACE, [24])
-model.testResultsVolumes(Partition_1, [60866.055096277588745579123497009])
+model.testResultsVolumes(Partition_1, [58449.978433344353106804192066193])
# change radius of a circle and check partition
Param_Radius.setValue(50)
model.testNbSubResults(Partition_1, [2])
model.testNbSubShapes(Partition_1, GeomAPI_Shape.SOLID, [4])
model.testNbSubShapes(Partition_1, GeomAPI_Shape.FACE, [24])
-model.testResultsVolumes(Partition_1, [83526.053426235652295872569084167])
+model.testResultsVolumes(Partition_1, [81554.943249494404881261289119720])
# check naming
model.testHaveNamingSubshapes(Partition_1, model, Part_1_doc)
model.testNbSubResults(Partition_1, [2])
model.testNbSubShapes(Partition_1, GeomAPI_Shape.SOLID, [4])
model.testNbSubShapes(Partition_1, GeomAPI_Shape.FACE, [27])
-model.testResultsVolumes(Partition_1, [61887.558125601033680140972137451])
+model.testResultsVolumes(Partition_1, [58449.978429485141532495617866516])
# update extrusion and check partition
Param_ExtrusionMin.setValue(-5)
model.testNbSubResults(Partition_1, [2])
model.testNbSubShapes(Partition_1, GeomAPI_Shape.SOLID, [4])
model.testNbSubShapes(Partition_1, GeomAPI_Shape.FACE, [25])
-model.testResultsVolumes(Partition_1, [60989.714891709969379007816314697])
+model.testResultsVolumes(Partition_1, [58449.978433180862339213490486145])
# change radius of a circle and check partition
Param_Radius.setValue(50)
model.testNbSubResults(Partition_1, [2])
model.testNbSubShapes(Partition_1, GeomAPI_Shape.SOLID, [4])
model.testNbSubShapes(Partition_1, GeomAPI_Shape.FACE, [25])
-model.testResultsVolumes(Partition_1, [83670.313521821837639436125755310])
+model.testResultsVolumes(Partition_1, [81554.943249094052589498460292816])
# check naming
model.testHaveNamingSubshapes(Partition_1, model, Part_1_doc)
model.testNbSubResults(Partition_1, [2])
model.testNbSubShapes(Partition_1, GeomAPI_Shape.SOLID, [5])
model.testNbSubShapes(Partition_1, GeomAPI_Shape.FACE, [29])
-model.testResultsVolumes(Partition_1, [61804.7209520386313670314848423])
+model.testResultsVolumes(Partition_1, [58449.978429877664893865585327148])
# update extrusion and check partition
Param_ExtrusionMin.setValue(-5)
model.testNbSubResults(Partition_1, [2])
model.testNbSubShapes(Partition_1, GeomAPI_Shape.SOLID, [4])
model.testNbSubShapes(Partition_1, GeomAPI_Shape.FACE, [25])
-model.testResultsVolumes(Partition_1, [60965.634801387262996286153793335])
+model.testResultsVolumes(Partition_1, [58449.978433183350716717541217804])
# change radius of a circle and check partition
Param_Radius.setValue(50)
model.testNbSubResults(Partition_1, [2])
model.testNbSubShapes(Partition_1, GeomAPI_Shape.SOLID, [4])
model.testNbSubShapes(Partition_1, GeomAPI_Shape.FACE, [25])
-model.testResultsVolumes(Partition_1, [83661.21013607898203190416097641])
+model.testResultsVolumes(Partition_1, [81554.943249191215727478265762329])
# check naming
model.testHaveNamingSubshapes(Partition_1, model, Part_1_doc)
//==================================================================================================
double GeomAlgoAPI_ShapeTools::volume(const std::shared_ptr<GeomAPI_Shape> theShape)
{
- GProp_GProps aGProps;
if(!theShape.get()) {
return 0.0;
}
return 0.0;
}
const Standard_Real anEps = 1.e-6;
- if (aShape.ShapeType() <= TopAbs_SOLID)
- BRepGProp::VolumeProperties(aShape, aGProps, anEps);
- else
- BRepGProp::SurfaceProperties(aShape, aGProps, anEps);
+ TopExp_Explorer anExp(aShape, TopAbs_SOLID);
+ if (anExp.More()) { // return volume if there is at least one solid
+ double aVolume = 0.0;
+ for (; anExp.More(); anExp.Next()) {
+ GProp_GProps aGProps;
+ BRepGProp::VolumeProperties(anExp.Current(), aGProps, anEps);
+ aVolume += aGProps.Mass();
+ }
+ return aVolume;
+ }
+ // return surfaces area
+ GProp_GProps aGProps;
+ BRepGProp::SurfaceProperties(aShape, aGProps, anEps);
return aGProps.Mass();
}
myWasChangedButBlocked.push_back(theAttr);
}
} else {
- // trim: need to redisplay
- if (myObject && theAttr->attributeType() == "Point2D") {
+ // trim: need to redisplay or set color in the python script
+ if (myObject && (theAttr->attributeType() == "Point2D" || theAttr->id() == "Color")) {
static const Events_ID anEvent = Events_Loop::eventByName(EVENT_OBJECT_TO_REDISPLAY);
ModelAPI_EventCreator::get()->sendUpdated(myObject, anEvent);
}
int n = aWords.count();
QString aLine;
for (int i = 0; i < n; i++) {
- QString aLineExt = aLine + " " + aWords[i];
+ QString aLineExt = i == 0 ? aWords[i] : aLine + " " + aWords[i];
qreal anWidthNonExt = tfm.boundingRect(aLine).width();
qreal anWidthExt = tfm.boundingRect(aLineExt).width();
qreal aDeltaNonExt = fabs(anWidthNonExt-aGoldWidth);
"""Package for Construction plugin for the Parametric Geometry API of the Modeler.
"""
-from ConstructionAPI import addAxis, addPlane, addPoint
+from ConstructionAPI import addAxis, addPlane, addPoint, addPointXYZ
if ((*aIt)->isInHistory())
aCreated.append(*aIt);
}
+ if (aCreated.length() == 0)
+ return;
QTreeNodesList aNodes = myRoot->objectCreated(aCreated);
ModuleBase_ITreeNode* aParent;
int aRow = 0;
--- /dev/null
+# Copyright (C) 2014-2019 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
+#
+
+ENABLE_TESTING()
+
+SET(RESTRICTED_ROOT_DIR $ENV{RESTRICTED_ROOT_DIR} CACHE PATH "Path to the restricted repository")
+
+if (EXISTS ${RESTRICTED_ROOT_DIR})
+ file(GLOB hdfFilesRestr "${RESTRICTED_ROOT_DIR}/SHAPER/test.hdfs/*.hdf")
+
+ if (WIN32) # different separators and path to libraries variable name
+ SET(_JUSTPATH "${CMAKE_INSTALL_PREFIX}/${SHAPER_INSTALL_BIN};${CMAKE_INSTALL_PREFIX}/${SHAPER_INSTALL_SWIG};${CMAKE_INSTALL_PREFIX}/${SHAPER_INSTALL_PLUGIN_FILES};${SUIT_LIB_DIR};$ENV{PATH}")
+ STRING(REPLACE "\\" "/" _JUSTPATH "${_JUSTPATH}")
+ STRING(REPLACE ";" "\\;" _JUSTPATH "${_JUSTPATH}")
+ SET(_PYTHONPATH "${CMAKE_INSTALL_PREFIX}/${SHAPER_INSTALL_SWIG};${CMAKE_INSTALL_PREFIX}/${SHAPER_INSTALL_PLUGIN_FILES};${CMAKE_INSTALL_PREFIX}/${SHAPER_INSTALL_ADDONS};$ENV{PYTHONPATH}")
+ STRING(REPLACE "\\" "/" _PYTHONPATH "${_PYTHONPATH}")
+ STRING(REPLACE ";" "\\;" _PYTHONPATH "${_PYTHONPATH}")
+ else()
+ SET(_LD_LIBRARY_PATH "${CMAKE_INSTALL_PREFIX}/${SHAPER_INSTALL_BIN}:${CMAKE_INSTALL_PREFIX}/${SHAPER_INSTALL_SWIG}:${CMAKE_INSTALL_PREFIX}/${SHAPER_INSTALL_PLUGIN_FILES}:${SUIT_LIB_DIR}:$ENV{LD_LIBRARY_PATH}")
+ SET(_PYTHONPATH "${CMAKE_INSTALL_PREFIX}/${SHAPER_INSTALL_SWIG}:${CMAKE_INSTALL_PREFIX}/${SHAPER_INSTALL_PLUGIN_FILES}:${CMAKE_INSTALL_PREFIX}/${SHAPER_INSTALL_ADDONS}:$ENV{PYTHONPATH}")
+ endif()
+
+ foreach(eachFilePath ${hdfFilesRestr})
+ # Strip the ".hdf" suffix
+ GET_FILENAME_COMPONENT(aTestName ${eachFilePath} NAME_WE)
+ # Check corresponding ".py" file with reference data exists
+ IF(NOT EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/${aTestName}.py")
+ MESSGAGE(WARNING "File ${aTestName}.py containing reference data does not exist")
+ ENDIF()
+
+ # Add "SubprojectName_" prefix
+ GET_FILENAME_COMPONENT(aSubprojectName ${CMAKE_CURRENT_SOURCE_DIR} NAME)
+ SET(aTestName "${aSubprojectName}_${aTestName}")
+
+ # Full path to the python test file being executed
+ SET(aTestFilePath "${eachFilePath}")
+ IF(EXISTS ${aTestFilePath})
+ ADD_TEST(NAME ${aTestName} COMMAND ${PYTHON_EXECUTABLE} "${CMAKE_CURRENT_SOURCE_DIR}/test.py" "$ENV{KERNEL_ROOT_DIR}" "${CMAKE_CURRENT_SOURCE_DIR}" "${aTestFilePath}")
+ if (WIN32) # different path to libraries variable name
+ SET_TESTS_PROPERTIES(${aTestName} PROPERTIES ENVIRONMENT "PATH=${_JUSTPATH};PYTHONPATH=${_PYTHONPATH}"
+ LABELS "models_hdf")
+ else()
+ SET_TESTS_PROPERTIES(${aTestName} PROPERTIES ENVIRONMENT "LD_LIBRARY_PATH=${_LD_LIBRARY_PATH};PYTHONPATH=${_PYTHONPATH}"
+ LABELS "models_hdf")
+ endif()
+ # Debug output...
+ # MESSAGE(STATUS "Test added: ${aTestName} file: ${aTestFilePath}")
+ ELSE(EXISTS ${aTestFilePath})
+ MESSAGE(WARNING "Can not find the test file: ${aTestFilePath}")
+ ENDIF(EXISTS ${aTestFilePath})
+ endforeach(eachFilePath ${ARGN})
+
+ ADD_CUSTOM_TARGET(run_hdf_tests COMMAND ${CMAKE_CTEST_COMMAND} -C "${CMAKE_BUILD_TYPE}" -L "models_hdf")
+endif()
--- /dev/null
+# Copyright (C) 2014-2019 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
+#
+
+if __name__ == "__main__":
+ model.testNbResults(aPartFeature, 1)
+ model.testNbSubResults(aPartFeature, [0])
+ model.testNbSubShapes(aPartFeature, GeomAPI_Shape.SOLID, [319])
+ model.testNbSubShapes(aPartFeature, GeomAPI_Shape.FACE, [2138])
+ model.testNbSubShapes(aPartFeature, GeomAPI_Shape.EDGE, [9022])
+ model.testNbSubShapes(aPartFeature, GeomAPI_Shape.VERTEX, [18044])
+ model.testResultsVolumes(aPartFeature, [0.0837941287])
--- /dev/null
+# Copyright (C) 2014-2019 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
+#
+
+if __name__ == "__main__":
+ model.testNbResults(aPartFeature, 1)
+ model.testNbSubResults(aPartFeature, [0])
+ model.testNbSubShapes(aPartFeature, GeomAPI_Shape.SOLID, [32])
+ model.testNbSubShapes(aPartFeature, GeomAPI_Shape.FACE, [875])
+ model.testNbSubShapes(aPartFeature, GeomAPI_Shape.EDGE, [4665])
+ model.testNbSubShapes(aPartFeature, GeomAPI_Shape.VERTEX, [9330])
+ model.testResultsVolumes(aPartFeature, [145241798.705457538])
--- /dev/null
+# Copyright (C) 2014-2019 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
+#
+
+if __name__ == "__main__":
+ model.testNbResults(aPartFeature, 1)
+ model.testNbSubResults(aPartFeature, [0])
+ model.testNbSubShapes(aPartFeature, GeomAPI_Shape.SOLID, [30])
+ model.testNbSubShapes(aPartFeature, GeomAPI_Shape.FACE, [231])
+ model.testNbSubShapes(aPartFeature, GeomAPI_Shape.EDGE, [968])
+ model.testNbSubShapes(aPartFeature, GeomAPI_Shape.VERTEX, [1936])
+ model.testResultsVolumes(aPartFeature, [1429610.103267467])
--- /dev/null
+# Copyright (C) 2014-2019 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
+#
+
+if __name__ == "__main__":
+ model.testNbResults(aPartFeature, 1)
+ model.testNbSubResults(aPartFeature, [0])
+ model.testNbSubShapes(aPartFeature, GeomAPI_Shape.SOLID, [48])
+ model.testNbSubShapes(aPartFeature, GeomAPI_Shape.FACE, [292])
+ model.testNbSubShapes(aPartFeature, GeomAPI_Shape.EDGE, [1176])
+ model.testNbSubShapes(aPartFeature, GeomAPI_Shape.VERTEX, [2352])
+ model.testResultsVolumes(aPartFeature, [6468345.48144548386])
--- /dev/null
+#!/usr/bin/env python
+if __name__ == '__main__':
+
+ from subprocess import Popen
+ from time import sleep
+ import sys, os
+
+ salomeKernelDir = sys.argv[1]
+ sourceDir = sys.argv[2]
+ testfile = sys.argv[3]
+
+ portlogfile = os.getcwd() + "/.salome_port"
+ testlogfile = os.getcwd() + "/test.log"
+ # remove port file if any
+ try:
+ os.remove(portlogfile)
+ except:
+ pass
+
+ proc = Popen([salomeKernelDir + "/bin/salome/runSalome.py", "--modules", "SHAPER,GEOM", "--gui", "--ns-port-log=" + portlogfile, sourceDir + "/test_hdf.py", "args:" + testfile + "," + portlogfile + "," + testlogfile + "," + salomeKernelDir + "," + sourceDir])
+
+ iter = 0
+ while not os.path.exists(portlogfile) and iter < 100:
+ sleep(0.1)
+ iter += 1
+
+ while os.path.exists(portlogfile):
+ sleep(0.1)
+
+ isOk = True
+ with open(testlogfile, 'r') as inputFile:
+ s = inputFile.read()
+ print(s)
+ for line in s:
+ isOk = isOk and s.find("FAIL") < 0
+ try:
+ os.remove(testlogfile)
+ except:
+ pass
+
+ assert isOk, "Test failed"
--- /dev/null
+# Copyright (C) 2014-2019 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
+#
+
+import salome, os, sys
+import SalomePyQt
+
+import unittest
+import subprocess
+
+import ModelHighAPI, ModelAPI, PartSetAPI
+from GeomAPI import GeomAPI_Shape
+from salome.shaper import model
+
+class TestHDF(unittest.TestCase):
+ testfile = ""
+ reffile = ""
+
+ def setUp(self):
+ salome.salome_close()
+
+ # leave file name only (trim path and extension)
+ fileName = os.path.basename(self.testfile)
+ self.reffile = self.reffile + "/" + os.path.splitext(fileName)[0] + ".py"
+
+ salome.salome_init(self.testfile, embedded=1)
+ myStudyName = salome.myStudy._get_Name()
+ self.session = salome.naming_service.Resolve('/Kernel/Session')
+ self.session.emitMessage("connect_to_study")
+
+ self.sg = SalomePyQt.SalomePyQt()
+ self.sg.activateModule("Shaper")
+ self.session = ModelAPI.ModelAPI_Session.get()
+ self.partSet = self.session.moduleDocument()
+
+ def tearDown(self):
+ salome.sg.UpdateView()
+ self.sg.processEvents()
+ salome.sg.FitAll()
+
+ def test_hdf_file(self):
+ self.assertTrue(self.partSet.size("Parts") > 0)
+ aPartsList = []
+ for aPartIndex in range(self.partSet.size("Parts")):
+ self.session.startOperation()
+ aPart = ModelAPI.modelAPI_ResultPart(ModelAPI.objectToResult(self.partSet.object("Parts", aPartIndex)))
+ aPart.activate()
+ self.session.finishOperation()
+
+ aPartFeature = PartSetAPI.PartSetAPI_Part(self.partSet.currentFeature(True))
+ # check reference data
+ exec(open(self.reffile, "rb").read())
+
+
+if __name__ == "__main__":
+ if len(sys.argv) > 1:
+ TestHDF.testfile = sys.argv[1]
+ if len(sys.argv) > 2:
+ salomePortFile = sys.argv[2]
+ if len(sys.argv) > 3:
+ errFile = open(sys.argv[3], 'w')
+ if len(sys.argv) > 4:
+ salomeKernelDir = sys.argv[4]
+ if len(sys.argv) > 5:
+ TestHDF.reffile = sys.argv[5]
+
+ aTest = unittest.TestLoader().loadTestsFromTestCase(TestHDF)
+ unittest.TextTestRunner(stream=errFile).run(aTest)
+ errFile.close()
+
+ # close Salome GUI
+ proc = subprocess.Popen(salomeKernelDir + "/bin/salome/killSalome.py")
+
+ try:
+ os.remove(salomePortFile)
+ except:
+ print("Cannot remove file", file=f)
--- /dev/null
+# Copyright (C) 2014-2019 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
+#
+
+if __name__ == "__main__":
+ model.testNbResults(aPartFeature, 1)
+ model.testNbSubResults(aPartFeature, [0])
+ model.testNbSubShapes(aPartFeature, GeomAPI_Shape.SOLID, [186])
+ model.testNbSubShapes(aPartFeature, GeomAPI_Shape.FACE, [4573])
+ model.testNbSubShapes(aPartFeature, GeomAPI_Shape.EDGE, [25474])
+ model.testNbSubShapes(aPartFeature, GeomAPI_Shape.VERTEX, [50980])
+ model.testResultsVolumes(aPartFeature, [2688153.285910513252])
mkdir -p ${BUILD_DIR}
cd ${BUILD_DIR}
-ctest --no-compress-output -T Test "$@"
+export DISPLAY="localhost:0.0"
+
+if [[ $# > 0 ]]; then
+ ctest --no-compress-output -T Test "$@" -R $1
+else
+ ctest --no-compress-output -T Test "$@"
+fi