essai formalisation niveaux de debug

This commit is contained in:
Paul RASCLE 2014-11-28 14:35:10 +01:00
parent 77b224bfc9
commit b016dcf830
3 changed files with 31 additions and 23 deletions

View File

@ -2,7 +2,7 @@
import logging import logging
logging.info('start') logging.info('start')
from initLog import getLogLevel import initLog
import salome import salome
salome.salome_init() salome.salome_init()
@ -15,11 +15,11 @@ smesh = smeshBuilder.New(salome.myStudy)
logging.debug("initialisation de geompy et smesh OK") logging.debug("initialisation de geompy et smesh OK")
def geomPublishDebug(aShape, aName): def geomPublish(level,aShape, aName):
if getLogLevel() <= 1: if initLog.getLogLevel() <= level:
geompy.addToStudy(aShape, aName) geompy.addToStudy(aShape, aName)
def geomPublishDebugInFather(aFather, aShape, aName): def geomPublishInFather(level, aFather, aShape, aName):
if getLogLevel() <= 1: if initLog.getLogLevel() <= level:
geompy.addToStudyInFather(aFather, aShape, aName) geompy.addToStudyInFather(aFather, aShape, aName)

View File

@ -3,8 +3,9 @@
import logging import logging
from geomsmesh import geompy from geomsmesh import geompy
from geomsmesh import geomPublishDebug from geomsmesh import geomPublish
from geomsmesh import geomPublishDebugInFather from geomsmesh import geomPublishInFather
import initLog
from substractSubShapes import substractSubShapes from substractSubShapes import substractSubShapes
@ -39,13 +40,13 @@ def identifieEdgesPeau(edgesFissExtPipe,verticesPipePeau, facePeau, facesPeauSor
nameEdge = "edgeRadFacePipePeau%d"%i nameEdge = "edgeRadFacePipePeau%d"%i
facesPipePeau[i] = face facesPipePeau[i] = face
endsEdgeFond[i] = sharedVertices[0] endsEdgeFond[i] = sharedVertices[0]
geomPublishDebug(face, nameFace) geomPublish(initLog.debug, face, nameFace)
geomPublishDebug(sharedVertices[0], nameVert) geomPublish(initLog.debug, sharedVertices[0], nameVert)
edgesFace = geompy.ExtractShapes(face, geompy.ShapeType["EDGE"], True) edgesFace = geompy.ExtractShapes(face, geompy.ShapeType["EDGE"], True)
for edge in edgesFace: for edge in edgesFace:
if geompy.MinDistance(edge, sharedVertices[0]) < 1e-3: if geompy.MinDistance(edge, sharedVertices[0]) < 1e-3:
edgeRadFacePipePeau[i] = edge edgeRadFacePipePeau[i] = edge
geomPublishDebug(edge, nameEdge) geomPublish(initLog.debug, edge, nameEdge)
break break
pass pass
pass pass
@ -62,14 +63,14 @@ def identifieEdgesPeau(edgesFissExtPipe,verticesPipePeau, facePeau, facesPeauSor
geompy.UnionList(grpEdgesCirc, edges) geompy.UnionList(grpEdgesCirc, edges)
edgesCircPeau[i] = grpEdgesCirc edgesCircPeau[i] = grpEdgesCirc
name = "edgeCirc%d"%i name = "edgeCirc%d"%i
geomPublishDebugInFather(facePeau, grpEdgesCirc, name) geomPublishInFather(initLog.debug, facePeau, grpEdgesCirc, name)
edgesListees = edgesListees + edges edgesListees = edgesListees + edges
vertices = geompy.GetSharedShapesMulti([facePeau, fcirc], geompy.ShapeType["VERTEX"]) vertices = geompy.GetSharedShapesMulti([facePeau, fcirc], geompy.ShapeType["VERTEX"])
grpVertCircPeau = geompy.CreateGroup(facePeau, geompy.ShapeType["VERTEX"]) grpVertCircPeau = geompy.CreateGroup(facePeau, geompy.ShapeType["VERTEX"])
geompy.UnionList(grpVertCircPeau, vertices) geompy.UnionList(grpVertCircPeau, vertices)
verticesCircPeau[i] = grpVertCircPeau verticesCircPeau[i] = grpVertCircPeau
name = "pointEdgeCirc%d"%i name = "pointEdgeCirc%d"%i
geomPublishDebugInFather(facePeau, grpVertCircPeau, name) geomPublishInFather(initLog.debug, facePeau, grpVertCircPeau, name)
pass pass
pass # --- au moins une extrémité du pipe sur cette face de peau pass # --- au moins une extrémité du pipe sur cette face de peau
@ -80,7 +81,7 @@ def identifieEdgesPeau(edgesFissExtPipe,verticesPipePeau, facePeau, facesPeauSor
for i, edge in enumerate(edgesFilling): for i, edge in enumerate(edgesFilling):
edgepeau = geompy.GetInPlace(facePeau, edge) edgepeau = geompy.GetInPlace(facePeau, edge)
name = "edgepeau%d"%i name = "edgepeau%d"%i
geomPublishDebugInFather(facePeau,edgepeau, name) geomPublishInFather(initLog.debug, facePeau,edgepeau, name)
logging.debug("edgepeau %s", geompy.ShapeInfo(edgepeau)) logging.debug("edgepeau %s", geompy.ShapeInfo(edgepeau))
if geompy.ShapeInfo(edgepeau)['EDGE'] > 1: if geompy.ShapeInfo(edgepeau)['EDGE'] > 1:
logging.debug(" EDGES multiples") logging.debug(" EDGES multiples")
@ -97,7 +98,7 @@ def identifieEdgesPeau(edgesFissExtPipe,verticesPipePeau, facePeau, facesPeauSor
if aretesVivesC is not None: if aretesVivesC is not None:
bordsVifs = geompy.GetInPlace(facePeau, aretesVivesC) bordsVifs = geompy.GetInPlace(facePeau, aretesVivesC)
if bordsVifs is not None: if bordsVifs is not None:
geomPublishDebugInFather(facePeau, bordsVifs, "bordsVifs") geomPublishInFather(initLog.debug, facePeau, bordsVifs, "bordsVifs")
groupEdgesBordPeau = geompy.CutGroups(groupEdgesBordPeau, bordsVifs) groupEdgesBordPeau = geompy.CutGroups(groupEdgesBordPeau, bordsVifs)
grptmp = None grptmp = None
if len(aretesVivesCoupees) > 0: if len(aretesVivesCoupees) > 0:
@ -111,7 +112,7 @@ def identifieEdgesPeau(edgesFissExtPipe,verticesPipePeau, facePeau, facesPeauSor
edv = geompy.ExtractShapes(grpnew, geompy.ShapeType["EDGE"], False) edv = geompy.ExtractShapes(grpnew, geompy.ShapeType["EDGE"], False)
aretesVivesCoupees += edv aretesVivesCoupees += edv
logging.debug("aretesVivesCoupees %s",aretesVivesCoupees) logging.debug("aretesVivesCoupees %s",aretesVivesCoupees)
geomPublishDebugInFather(facePeau, groupEdgesBordPeau , "EdgesBords") geomPublishInFather(initLog.debug, facePeau, groupEdgesBordPeau , "EdgesBords")
# --- edges de la face de peau partagées avec la face de fissure # --- edges de la face de peau partagées avec la face de fissure
@ -125,7 +126,7 @@ def identifieEdgesPeau(edgesFissExtPipe,verticesPipePeau, facePeau, facesPeauSor
if (geompy.MinDistance(grpVert, edge) < 1.e-3) and (edge not in edgesFissurePeau): if (geompy.MinDistance(grpVert, edge) < 1.e-3) and (edge not in edgesFissurePeau):
edgesFissurePeau[i] = edge edgesFissurePeau[i] = edge
name = "edgeFissurePeau%d"%i name = "edgeFissurePeau%d"%i
geomPublishDebugInFather(facePeau, edge, name) geomPublishInFather(initLog.debug, facePeau, edge, name)
for edge in edges: # on ajoute après les edges manquantes for edge in edges: # on ajoute après les edges manquantes
if edge not in edgesFissurePeau: if edge not in edgesFissurePeau:
edgesFissurePeau.append(edge) edgesFissurePeau.append(edge)
@ -133,7 +134,7 @@ def identifieEdgesPeau(edgesFissExtPipe,verticesPipePeau, facePeau, facesPeauSor
for i, edge in enumerate(edges): for i, edge in enumerate(edges):
edgesFissurePeau.append(edge) edgesFissurePeau.append(edge)
name = "edgeFissurePeau%d"%i name = "edgeFissurePeau%d"%i
geomPublishDebugInFather(facePeau, edge, name) geomPublishInFather(initLog.debug, facePeau, edge, name)
return (endsEdgeFond, facesPipePeau, edgeRadFacePipePeau, return (endsEdgeFond, facesPipePeau, edgeRadFacePipePeau,
edgesCircPeau, verticesCircPeau, groupEdgesBordPeau, edgesCircPeau, verticesCircPeau, groupEdgesBordPeau,

View File

@ -1,41 +1,48 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
import logging import logging
loglevel = 3
debug = 10
info = 20
warning = 30
error = 40
critical = 50
loglevel = warning
def setDebug(): def setDebug():
global loglevel global loglevel
logging.basicConfig(format='%(relativeCreated)d %(funcName)s[%(lineno)d] %(message)s', logging.basicConfig(format='%(relativeCreated)d %(funcName)s[%(lineno)d] %(message)s',
level=logging.DEBUG) level=logging.DEBUG)
loglevel = 1 loglevel = debug
logging.info('start Debug %s', loglevel) logging.info('start Debug %s', loglevel)
def setVerbose(): def setVerbose():
global loglevel global loglevel
logging.basicConfig(format='%(relativeCreated)d %(funcName)s[%(lineno)d] %(message)s', logging.basicConfig(format='%(relativeCreated)d %(funcName)s[%(lineno)d] %(message)s',
level=logging.INFO) level=logging.INFO)
loglevel = 2 loglevel = info
logging.info('start Verbose %s', loglevel) logging.info('start Verbose %s', loglevel)
def setRelease(): def setRelease():
global loglevel global loglevel
logging.basicConfig(format='%(funcName)s[%(lineno)d] %(message)s', logging.basicConfig(format='%(funcName)s[%(lineno)d] %(message)s',
level=logging.WARNING) level=logging.WARNING)
loglevel = 3 loglevel = warning
logging.warning('start Release %s', loglevel) logging.warning('start Release %s', loglevel)
def setUnitTests(): def setUnitTests():
global loglevel global loglevel
logging.basicConfig(format='%(funcName)s[%(lineno)d] %(message)s', logging.basicConfig(format='%(funcName)s[%(lineno)d] %(message)s',
level=logging.CRITICAL) level=logging.CRITICAL)
loglevel = 4 loglevel = critical
logging.critical('start UnitTests %s', loglevel) logging.critical('start UnitTests %s', loglevel)
def setPerfTests(): def setPerfTests():
global loglevel global loglevel
logging.basicConfig(format='%(relativeCreated)d %(funcName)s[%(lineno)d] %(message)s', logging.basicConfig(format='%(relativeCreated)d %(funcName)s[%(lineno)d] %(message)s',
level=logging.CRITICAL) level=logging.CRITICAL)
loglevel = 5 loglevel = critical
logging.info('start PerfTests %s', loglevel) logging.info('start PerfTests %s', loglevel)
def getLogLevel(): def getLogLevel():