+const SMESHDS_Mesh* Controls::BelongToGeom::GetMeshDS() const
+{
+ return myMeshDS;
+}
+
+void Controls::BelongToGeom::SetTolerance (double theTolerance)
+{
+ myTolerance = theTolerance;
+ if (!myIsSubshape)
+ init();
+}
+
+double Controls::BelongToGeom::GetTolerance()
+{
+ return myTolerance;
+}
+
+/*
+ Class : LyingOnGeom
+ Description : Predicate for verifying whether entiy lying or partially lying on
+ specified geometrical support
+*/
+
+Controls::LyingOnGeom::LyingOnGeom()
+ : myMeshDS(NULL),
+ myType(SMDSAbs_All),
+ myIsSubshape(false),
+ myTolerance(Precision::Confusion())
+{}
+
+void Controls::LyingOnGeom::SetMesh( const SMDS_Mesh* theMesh )
+{
+ myMeshDS = dynamic_cast<const SMESHDS_Mesh*>(theMesh);
+ init();
+}
+
+void Controls::LyingOnGeom::SetGeom( const TopoDS_Shape& theShape )
+{
+ myShape = theShape;
+ init();
+}
+
+void Controls::LyingOnGeom::init()
+{
+ if (!myMeshDS || myShape.IsNull()) return;
+
+ // is subshape of main shape?
+ TopoDS_Shape aMainShape = myMeshDS->ShapeToMesh();
+ if (aMainShape.IsNull()) {
+ myIsSubshape = false;
+ }
+ else {
+ TopTools_IndexedMapOfShape aMap;
+ TopExp::MapShapes(aMainShape, aMap);
+ myIsSubshape = IsSubShape(aMap, myShape);
+ }
+
+ if (!myIsSubshape)
+ {
+ myElementsOnShapePtr.reset(new Controls::ElementsOnShape());
+ myElementsOnShapePtr->SetTolerance(myTolerance);
+ myElementsOnShapePtr->SetAllNodes(false); // lays on, while true means "belong"
+ myElementsOnShapePtr->SetMesh(myMeshDS);
+ myElementsOnShapePtr->SetShape(myShape, myType);
+ }
+}
+
+bool Controls::LyingOnGeom::IsSatisfy( long theId )
+{
+ if ( myMeshDS == 0 || myShape.IsNull() )
+ return false;
+
+ if (!myIsSubshape)
+ {
+ return myElementsOnShapePtr->IsSatisfy(theId);
+ }
+
+ // Case of submesh
+ if( myType == SMDSAbs_Node )
+ {
+ if( const SMDS_MeshNode* aNode = myMeshDS->FindNode( theId ) )
+ {
+ const SMDS_PositionPtr& aPosition = aNode->GetPosition();
+ SMDS_TypeOfPosition aTypeOfPosition = aPosition->GetTypeOfPosition();
+ switch( aTypeOfPosition )
+ {
+ case SMDS_TOP_VERTEX : return IsContains( myMeshDS,myShape,aNode,TopAbs_VERTEX );
+ case SMDS_TOP_EDGE : return IsContains( myMeshDS,myShape,aNode,TopAbs_EDGE );
+ case SMDS_TOP_FACE : return IsContains( myMeshDS,myShape,aNode,TopAbs_FACE );
+ case SMDS_TOP_3DSPACE: return IsContains( myMeshDS,myShape,aNode,TopAbs_SHELL );
+ }
+ }
+ }
+ else
+ {
+ if( const SMDS_MeshElement* anElem = myMeshDS->FindElement( theId ) )
+ {
+ if( myType == SMDSAbs_All )
+ {
+ return Contains( myMeshDS,myShape,anElem,TopAbs_EDGE ) ||
+ Contains( myMeshDS,myShape,anElem,TopAbs_FACE ) ||
+ Contains( myMeshDS,myShape,anElem,TopAbs_SHELL )||
+ Contains( myMeshDS,myShape,anElem,TopAbs_SOLID );
+ }
+ else if( myType == anElem->GetType() )
+ {
+ switch( myType )
+ {
+ case SMDSAbs_Edge : return Contains( myMeshDS,myShape,anElem,TopAbs_EDGE );
+ case SMDSAbs_Face : return Contains( myMeshDS,myShape,anElem,TopAbs_FACE );
+ case SMDSAbs_Volume: return Contains( myMeshDS,myShape,anElem,TopAbs_SHELL )||
+ Contains( myMeshDS,myShape,anElem,TopAbs_SOLID );
+ }
+ }
+ }
+ }
+
+ return false;
+}
+
+void Controls::LyingOnGeom::SetType( SMDSAbs_ElementType theType )
+{
+ myType = theType;
+ init();
+}
+
+SMDSAbs_ElementType Controls::LyingOnGeom::GetType() const
+{
+ return myType;
+}
+
+TopoDS_Shape Controls::LyingOnGeom::GetShape()
+{
+ return myShape;
+}
+
+const SMESHDS_Mesh* Controls::LyingOnGeom::GetMeshDS() const