--- /dev/null
+## Copyright (C) 2014-2017 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<mailto:webmaster.salome@opencascade.com>
+##
+
+from salome.shaper import model
+
+model.begin()
+partSet = model.moduleDocument()
+Part_1 = model.addPart(partSet)
+Part_1_doc = Part_1.document()
+Sketch_1 = model.addSketch(Part_1_doc, model.defaultPlane("XOY"))
+SketchCircle_1 = Sketch_1.addCircle(0.1822176134072968, -1.34047565209109, 35.08968954114807)
+model.do()
+Wire_1 = model.addWire(Part_1_doc, [model.selection("EDGE", "Sketch_1/Edge-SketchCircle_1_2")])
+Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("WIRE", "Wire_1_1")], model.selection(), 100, 0)
+Recover_1 = model.addRecover(Part_1_doc, Extrusion_1, [Wire_1.result()])
+Face_1 = model.addFace(Part_1_doc, [model.selection("WIRE", "Recover_1_1")])
+Wire_2 = model.addWire(Part_1_doc, [model.selection("EDGE", "Extrusion_1_1/To_Edge_1")])
+Face_2 = model.addFace(Part_1_doc, [model.selection("WIRE", "Wire_2_1")])
+model.end()
+
+from ModelAPI import *
+aFactory = ModelAPI_Session.get().validators()
+assert(aFactory.validate(Face_2.feature()))
+
+assert(model.checkPythonDump())
if (!theAreaToIndex.IsBound(aShape)) { // fill the list of curve indices
NCollection_List<int> aNewList;
TopExp_Explorer anEdgesExp(aShape, TopAbs_EDGE);
- for(; anEdgesExp.More(); anEdgesExp.Next()) {
+ for (; anEdgesExp.More(); anEdgesExp.Next()) {
double aFirst, aLast;
Handle(Geom_Curve) aCurve = BRep_Tool::Curve(
TopoDS::Edge(anEdgesExp.Current()), aFirst, aLast);
aNewList.Append(theCurveToIndex.Find(aCurve));
}
}
- NCollection_Array1<int> aNewArray(1, aNewList.Extent());
- NCollection_List<int>::Iterator aListIter(aNewList);
- for(int anIndex = 1; aListIter.More(); aListIter.Next(), anIndex++) {
- aNewArray.SetValue(anIndex, aListIter.Value());
+ if (aNewList.Extent()) {
+ NCollection_Array1<int> aNewArray(1, aNewList.Extent());
+ NCollection_List<int>::Iterator aListIter(aNewList);
+ for (int anIndex = 1; aListIter.More(); aListIter.Next(), anIndex++) {
+ aNewArray.SetValue(anIndex, aListIter.Value());
+ }
+ std::sort(aNewArray.begin(), aNewArray.end());
+ theAreaToIndex.Bind(aShape, aNewArray);
}
- std::sort(aNewArray.begin(), aNewArray.end());
- theAreaToIndex.Bind(aShape, aNewArray);
}
}
- // compare lists of indices one by one to find chich list indices are lower
- NCollection_Array1<int>::Iterator aFirstList(theAreaToIndex.ChangeFind(theFirst));
- NCollection_Array1<int>::Iterator aSecondList(theAreaToIndex.ChangeFind(theSecond));
- for(; aFirstList.More() && aSecondList.More(); aFirstList.Next(), aSecondList.Next()) {
- if (aFirstList.Value() < aSecondList.Value()) return true;
- if (aFirstList.Value() > aSecondList.Value()) return false;
+ bool isFirst;
+ bool aGeomCompare = !theAreaToIndex.IsBound(theFirst) || !theAreaToIndex.IsBound(theSecond);
+ if (!aGeomCompare) {
+ // compare lists of indices one by one to find chich list indices are lower
+ NCollection_Array1<int>::Iterator aFirstList(theAreaToIndex.ChangeFind(theFirst));
+ NCollection_Array1<int>::Iterator aSecondList(theAreaToIndex.ChangeFind(theSecond));
+ for (; aFirstList.More() && aSecondList.More(); aFirstList.Next(), aSecondList.Next()) {
+ if (aFirstList.Value() < aSecondList.Value()) return true;
+ if (aFirstList.Value() > aSecondList.Value()) return false;
+ }
+ aGeomCompare = !aFirstList.More() && !aSecondList.More();
+ isFirst = !aFirstList.More();
+ } else {
+ isFirst = !theAreaToIndex.IsBound(theFirst);
}
// if faces are identical by curves names (circle splitted by line in seam-point), use parameters
- if (!aFirstList.More() && !aSecondList.More()) {
+ if (aGeomCompare) {
GProp_GProps aGProps;
BRepGProp::SurfaceProperties(theFirst, aGProps);
gp_Pnt aCentre1 = aGProps.CentreOfMass();
return aCentre1.X() + aCentre1.Y() + aCentre1.Z() < aCentre2.X() + aCentre2.Y() + aCentre2.Z();
}
// if in first list there is no elements left, it is the first
- return !aFirstList.More();
+ return isFirst;
}
// sorts faces (in theAreas list) to make persistent order: by initial shapes edges
BOPAlgo_Builder aBB;
aBB.AddArgument(aPlnFace);
- BOPCol_ListOfShape anEdges;
- BOPCol_ListIteratorOfListOfShape aShapeIt;
+ NCollection_List<TopoDS_Shape> anEdges;
+ NCollection_List<TopoDS_Shape>::Iterator aShapeIt;
std::list<std::shared_ptr<GeomAPI_Shape> >::const_iterator aFeatIt = theFeatures.begin();
for (; aFeatIt != theFeatures.end(); aFeatIt++) {
std::shared_ptr<GeomAPI_Shape> aShape(*aFeatIt);