#include <GeomAlgoAPI_XAOImport.h>
#include <GeomAPI_Shape.h>
+#include <GeomAPI_ShapeExplorer.h>
#include <ModelAPI_AttributeRefList.h>
#include <ModelAPI_AttributeSelectionList.h>
std::string aSelectionType =
ExchangePlugin_Tools::xaoDimension2selectionType(aDimensionString);
aSelectionList->setSelectionType(aSelectionType);
+ // limitation: now in XAO fields are related to everything, so, iterate all sub-shapes to fill
+ int aCountSelected = aXaoField->countElements();
+ int aResults = document()->size(ModelAPI_ResultBody::group());
+ for(int a = 0; a < aResults && aCountSelected; a++) {
+ ResultBodyPtr aBody = std::dynamic_pointer_cast<ModelAPI_ResultBody>(
+ document()->object(ModelAPI_ResultBody::group(), a));
+ if (!aBody.get())
+ continue;
+ // check that only results that were created before this field are used
+ FeaturePtr aResultFeature = document()->feature(aBody);
+ if (!aResultFeature.get())
+ continue;
+ GeomShapePtr aShape = aBody->shape();
+ if (!aShape.get() || aShape->isNull())
+ continue;
+ GeomAPI_ShapeExplorer anExp(aShape, GeomAPI_Shape::shapeTypeByStr(aSelectionType));
+ for(; anExp.more(); anExp.next()) {
+ aSelectionList->append(aBody, anExp.current());
+ aCountSelected--;
+ if (aCountSelected == 0)
+ break;
+ }
+ }
+
// conversion of type
XAO::Type aFieldType = aXaoField->getType();
std::string aTypeString = XAO::XaoUtils::fieldTypeToString(aFieldType);
assert modelAPI_ResultBody(anImportFeature.firstResult())
assert anImportFeature.firstResult().data().name() == "mygeom_1"
aCompositeFeature = featureToCompositeFeature(anImportFeature)
- assert aCompositeFeature.numberOfSubs(False) == 2
+ # Two groups and one field
+ assert aCompositeFeature.numberOfSubs(False) == 3
aFeature1 = aCompositeFeature.subFeature(0, False)
assert aFeature1.getKind() == "Group"
print aSelectionList.value(1).namingName("")
assert aSelectionList.value(1).namingName("") == "mygeom_1/Shape2"
+ aFeature3 = aCompositeFeature.subFeature(2, False)
+ assert aFeature3.getKind() == "Field"
+ assert aFeature3.name() == "color"
+ assert aFeature3.intArray("stamps").size() == 2
+ assert aFeature3.tables("values").rows() == 2
+ assert aFeature3.tables("values").columns() == 3
+ assert aFeature3.tables("values").tables() == 2
+ assert aFeature3.tables("values").type() == 1 # integer
+ assert aFeature3.selectionList("selected").size() == 1
+
if __name__ == '__main__':
#=========================================================================
# Create a shape imported from BREP
#=========================================================================
# Create a shape imported from XAO
#=========================================================================
- #testImportXAO()
+ testImportXAO()
#=========================================================================
# End of test
#=========================================================================
#include <NCollection_List.hxx>
#include <sstream>
+#include <algorithm> // for std::transform
#define MY_SHAPE implPtr<TopoDS_Shape>()
return aST;
}
+GeomAPI_Shape::ShapeType GeomAPI_Shape::shapeTypeByStr(std::string theType)
+{
+ std::transform(theType.begin(), theType.end(), theType.begin(), ::toupper);
+ if (theType == "COMPOUND")
+ return COMPOUND;
+ if (theType == "COMPSOLID")
+ return COMPSOLID;
+ if (theType == "SOLID")
+ return SOLID;
+ if (theType == "SHELL")
+ return SHELL;
+ if (theType == "FACE")
+ return FACE;
+ if (theType == "WIRE")
+ return WIRE;
+ if (theType == "EDGE")
+ return EDGE;
+ if (theType == "VERTEX")
+ return VERTEX;
+ return SHAPE; // default
+}
+
std::string GeomAPI_Shape::shapeTypeStr() const
{
ShapeType aShapeType = shapeType();
GEOMAPI_EXPORT
virtual ShapeType shapeType() const;
+ /// Returns the type enumeration by the string-type
+ GEOMAPI_EXPORT static ShapeType shapeTypeByStr(std::string theType);
+
/// \return the shape type as string.
GEOMAPI_EXPORT
virtual std::string shapeTypeStr() const;