X-Git-Url: http://git.salome-platform.org/gitweb/?p=modules%2Fsmesh.git;a=blobdiff_plain;f=src%2FTools%2FblocFissure%2Fgmu%2FrotTrans.py;h=fcdd25af79ea5da8dc9b160fae2ded56f302905c;hp=fc2d2a98e9ce48157abcc107fd2e7e98b198dfb0;hb=499f29d24922cec66e41b41a0039a954993bc6df;hpb=8d297d6698f361d4f2dde723050bcfbaea050920 diff --git a/src/Tools/blocFissure/gmu/rotTrans.py b/src/Tools/blocFissure/gmu/rotTrans.py index fc2d2a98e..fcdd25af7 100644 --- a/src/Tools/blocFissure/gmu/rotTrans.py +++ b/src/Tools/blocFissure/gmu/rotTrans.py @@ -1,16 +1,35 @@ # -*- coding: utf-8 -*- +# Copyright (C) 2014-2022 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 +# +"""Opérateur de rotation translation d'un objet centré à l'origine""" import logging +import math + from .geomsmesh import geompy from .geomsmesh import geomPublish -from .geomsmesh import geomPublishInFather + from . import initLog -import math + from .triedreBase import triedreBase -O, OX, OY, OZ = triedreBase() -# ----------------------------------------------------------------------------- -# --- operateur de rotation translation d'un objet centré à l'origine +O, OX, OY, OZ = triedreBase() def rotTrans(objet, orientation, point, normal, trace = False): """ @@ -23,33 +42,34 @@ def rotTrans(objet, orientation, point, normal, trace = False): @return trans : objet transformé (geomObject) """ logging.info("start") + planXY = geompy.MakePlaneLCS(None, 2000, 1) projXY = geompy.MakeProjection(normal, planXY) - [v1,v2] = geompy.ExtractShapes(projXY, geompy.ShapeType["VERTEX"], False) - xyz1 = geompy.PointCoordinates(v1) - xyz2 = geompy.PointCoordinates(v2) + + [v_1,v_2] = geompy.ExtractShapes(projXY, geompy.ShapeType["VERTEX"], False) + xyz1 = geompy.PointCoordinates(v_1) + xyz2 = geompy.PointCoordinates(v_2) x = xyz2[0] - xyz1[0] y = xyz2[1] - xyz1[1] sinalpha = y / math.sqrt(x*x + y*y) cosalpha = x / math.sqrt(x*x + y*y) alpha = math.asin(sinalpha) - if cosalpha < 0: + if ( cosalpha < 0. ): alpha = math.pi -alpha beta = geompy.GetAngleRadians(OZ, normal) - [v1,v2] = geompy.ExtractShapes(normal, geompy.ShapeType["VERTEX"], False) - xyz1 = geompy.PointCoordinates(v1) - xyz2 = geompy.PointCoordinates(v2) - z = xyz2[2] - xyz1[2] - if z < 0: + [v_1,v_2] = geompy.ExtractShapes(normal, geompy.ShapeType["VERTEX"], False) + xyz1 = geompy.PointCoordinates(v_1) + xyz2 = geompy.PointCoordinates(v_2) + if ( (xyz2[2] - xyz1[2]) < 0 ): beta = math.pi -beta rot0 = geompy.MakeRotation(objet, OX, orientation*math.pi/180.0) rot1 = geompy.MakeRotation(rot0, OZ, alpha) axe2 = geompy.MakeRotation(OY, OZ, alpha) rot2 = geompy.MakeRotation(rot1, axe2, beta -math.pi/2.) - logging.debug("alpha",alpha) - logging.debug("beta",beta) + logging.debug("alpha %f",alpha) + logging.debug("beta %f",beta) if trace: geomPublish(initLog.debug, rot1, 'rot1' ) geomPublish(initLog.debug, axe2, 'axe2' ) @@ -57,4 +77,5 @@ def rotTrans(objet, orientation, point, normal, trace = False): xyz = geompy.PointCoordinates(point) trans = geompy.MakeTranslation(rot2, xyz[0], xyz[1], xyz[2]) + return trans