mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-08-24 13:50:49 +03:00
0024876: Add protection of shapes against modification of geometry
Added flag "locked" for protection of geometric data in the shapes (including tolerances). Modification test case to avoid regression.
This commit is contained in:
@@ -34,6 +34,7 @@
|
||||
#include <BRepTools_WireExplorer.hxx>
|
||||
#include <BRepTools_ShapeSet.hxx>
|
||||
#include <BRepAdaptor_Surface.hxx>
|
||||
#include <BRep_TEdge.hxx>
|
||||
#include <Precision.hxx>
|
||||
#include <Poly_Triangulation.hxx>
|
||||
#include <gp_Ax2.hxx>
|
||||
@@ -968,6 +969,112 @@ static Standard_Integer countshapes(Draw_Interpretor& di,
|
||||
return 0;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//
|
||||
//=======================================================================
|
||||
void setProp(TopoDS_Shape Sh, const char** a, Standard_Integer n)
|
||||
{
|
||||
Standard_Integer i;
|
||||
for(i = 2; i < n; i++) {
|
||||
if (strstr ( a[i], "free" )) {
|
||||
if(a[i][0] == '-') {
|
||||
Sh.Free(Standard_False);
|
||||
}
|
||||
else {
|
||||
Sh.Free(Standard_True);
|
||||
}
|
||||
}
|
||||
if (strstr ( a[i], "modified" )) {
|
||||
if(a[i][0] == '-') {
|
||||
Sh.Modified(Standard_False);
|
||||
}
|
||||
else {
|
||||
Sh.Modified(Standard_True);
|
||||
}
|
||||
}
|
||||
if (strstr ( a[i], "checked" )) {
|
||||
if(a[i][0] == '-') {
|
||||
Sh.Checked(Standard_False);
|
||||
}
|
||||
else {
|
||||
Sh.Checked(Standard_True);
|
||||
}
|
||||
}
|
||||
if (strstr ( a[i], "orientable" )) {
|
||||
if(a[i][0] == '-') {
|
||||
Sh.Orientable(Standard_False);
|
||||
}
|
||||
else {
|
||||
Sh.Orientable(Standard_True);
|
||||
}
|
||||
}
|
||||
if (strstr ( a[i], "closed" )) {
|
||||
if(a[i][0] == '-') {
|
||||
Sh.Closed(Standard_False);
|
||||
}
|
||||
else {
|
||||
Sh.Closed(Standard_True);
|
||||
}
|
||||
}
|
||||
if (strstr ( a[i], "infinite" )) {
|
||||
if(a[i][0] == '-') {
|
||||
Sh.Infinite(Standard_False);
|
||||
}
|
||||
else {
|
||||
Sh.Infinite(Standard_True);
|
||||
}
|
||||
}
|
||||
if (strstr ( a[i], "convex" )) {
|
||||
if(a[i][0] == '-') {
|
||||
Sh.Convex(Standard_False);
|
||||
}
|
||||
else {
|
||||
Sh.Convex(Standard_True);
|
||||
}
|
||||
}
|
||||
if (strstr ( a[i], "locked" )) {
|
||||
if(a[i][0] == '-') {
|
||||
Sh.Locked(Standard_False);
|
||||
}
|
||||
else {
|
||||
Sh.Locked(Standard_True);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//
|
||||
//=======================================================================
|
||||
static Standard_Integer setFlags(Draw_Interpretor& ,
|
||||
Standard_Integer n, const char** a)
|
||||
{
|
||||
if (n < 3) return 1;
|
||||
|
||||
TopExp_Explorer ex;
|
||||
TopoDS_Shape Sh = DBRep::Get(a[1]);
|
||||
|
||||
if (Sh.IsNull()) return 1;
|
||||
|
||||
setProp(Sh, a, n);
|
||||
for (ex.Init (Sh,TopAbs_VERTEX); ex.More(); ex.Next()) {
|
||||
TopoDS_Shape S = ex.Current();
|
||||
setProp(S, a, n);
|
||||
}
|
||||
|
||||
for (ex.Init (Sh,TopAbs_EDGE); ex.More(); ex.Next()) {
|
||||
TopoDS_Shape S = ex.Current();
|
||||
setProp(S, a, n);
|
||||
}
|
||||
|
||||
for (ex.Init (Sh,TopAbs_FACE); ex.More(); ex.Next()) {
|
||||
TopoDS_Shape S = ex.Current();
|
||||
setProp(S, a, n);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//memory management
|
||||
//=======================================================================
|
||||
@@ -1200,6 +1307,9 @@ void DBRep::BasicCommands(Draw_Interpretor& theCommands)
|
||||
__FILE__,nbshapes,g);
|
||||
theCommands.Add("numshapes","numshapes s; size of shape",__FILE__,numshapes,g);
|
||||
theCommands.Add("countshapes","countshapes s; count of shape",__FILE__,countshapes,g);
|
||||
theCommands.Add("setflags",
|
||||
"setflags shape_name flag1[flag2...]\n sets flags for shape(free, modidfied, checked, orientable, closed, infinite, convex, locked), for exmple <setflags a free> or <setflags a -free> if necessary unflag ",
|
||||
__FILE__,setFlags,g);
|
||||
|
||||
// theCommands.Add("dumpmmgt",
|
||||
// "dump le contenu du gestionnaire de memoire",__FILE__,dumpmmgt,g);
|
||||
|
Reference in New Issue
Block a user