-// Copyright (C) 2014-2019 CEA/DEN, EDF R&D
+// Copyright (C) 2014-2022 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
#include <ModelAPI_ResultBody.h>
#include <ModelAPI_Tools.h>
+#include <GeomAPI_Edge.h>
#include <GeomAPI_Shape.h>
#include <GeomAPI_ShapeExplorer.h>
+#include <GeomAPI_Wire.h>
+#include <GeomAPI_WireExplorer.h>
#include <map>
int aNbEdges = 0;
int anOriginalEdgeIndex = -THE_QUAD;
GeomShapePtr anOppositeEdge;
- GeomAPI_ShapeExplorer anExp(theFace, GeomAPI_Shape::EDGE);
+ GeomAPI_ShapeExplorer aWExp(theFace, GeomAPI_Shape::WIRE);
+ GeomWirePtr aWire = aWExp.current()->wire();
+ aWExp.next();
+ if (aWExp.more()) {
+ // face with a hole is not a quadrangle
+ return anOppositeEdge;
+ }
+
+ GeomAPI_WireExplorer anExp(aWire);
while (anExp.more()) {
if (anExp.current()->isSame(theEdge))
anOriginalEdgeIndex = aNbEdges;
else if (aNbEdges == anOriginalEdgeIndex + THE_QUAD / 2) {
- anOppositeEdge = anExp.current();
+ if (anOriginalEdgeIndex < THE_QUAD)
+ anOppositeEdge = anExp.current();
if (aNbEdges >= THE_QUAD)
break;
}
break;
}
if (!anOppositeEdge)
- anExp.reinit();
+ anExp.init(aWire);
}
}
return anOppositeEdge;
if (myCachedShapes.empty()) {
ResultBodyPtr aBaseResult = ModelAPI_Tools::bodyOwner(aList->context(), true);
- if (!aBaseResult.get())
- return false;
+ if (!aBaseResult.get()) {
+ aBaseResult = std::dynamic_pointer_cast<ModelAPI_ResultBody>(aList->context());
+ if (!aBaseResult.get())
+ return false;
+ }
cacheOppositeEdges(aBaseResult->shape(), anEdge,
const_cast<FiltersPlugin_OppositeToEdge*>(this)->myCachedShapes);
return myCachedShapes.find(theShape) != myCachedShapes.end();
}
-static std::string XMLRepresentation =
-"<filter id = \"OppositeToEdge\">"
-" <shape_selector id=\"OppositeToEdge__OppositeToEdge\""
-" label=\"Edge:\""
-" tooltip=\"Select edge.\""
-" shape_types=\"edges\">"
-" <validator id=\"GeomValidators_ShapeType\" parameters=\"line\"/>"
-" </shape_selector>"
-"</filter>";
-
-
std::string FiltersPlugin_OppositeToEdge::xmlRepresentation() const
{
- return XMLRepresentation;
+ return xmlFromFile("filter-OppositeToEdge.xml");
}
void FiltersPlugin_OppositeToEdge::initAttributes(ModelAPI_FiltersArgs& theArguments)