# -*- coding: iso-8859-1 -*-
-# Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE
+# Copyright (C) 2007-2020 CEA/DEN, EDF R&D, OPEN CASCADE
#
# Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
# CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
# 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.
+# 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
# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
#
-# GEOM_SWIG : binding of C++ implementaion with Python
+# GEOM_SWIG : binding of C++ implementation with Python
# File : GEOM_TestHealing.py
# Author : Julia DOROVSKIKH
# Module : GEOM
theShape = geompy.MakePrismVecH(face, edge, 130)
#Check shape
- print "Before ProcessShape:"
+ print("Before ProcessShape:")
isValid = geompy.CheckShape(theShape)
if isValid == 0:
- print "The shape is not valid"
+ print("The shape is not valid")
else:
- print "The shape seems to be valid"
+ print("The shape seems to be valid")
#Process Shape
Operators = ["FixShape"]
PS = geompy.ProcessShape(theShape, Operators, Parameters, Values)
#Check shape
- print "After ProcessShape:"
+ print("After ProcessShape:")
isValid = geompy.CheckShape(PS)
if isValid == 0:
- print "The shape is not valid"
- raise RuntimeError, "It seems, that the ProcessShape() has failed"
+ print("The shape is not valid")
+ raise RuntimeError("It seems, that the ProcessShape() has failed")
else:
- print "The shape seems to be valid"
+ print("The shape seems to be valid")
#Add In Study
Id_Shape = geompy.addToStudy(theShape, "Invalid Shape")
nbw1 = nbw1 + 1
if nbw1 != 2:
- raise RuntimeError, "GetFreeBoundary(f12) must return 2 closed wires, but returned ", nbw1
+ raise RuntimeError("GetFreeBoundary(f12) must return 2 closed wires, but returned ").with_traceback(nbw1)
#SuppressInternalWires
face = geompy.SuppressInternalWires(f12, [])
nbw2 = nbw2 + 1
if nbw2 != 1:
- print "GetFreeBoundary(face) must return 1 closed wires, but returned ", nbw2
- raise RuntimeError, "SuppressInternalWires() works not correctly"
+ print("GetFreeBoundary(face) must return 1 closed wires, but returned ", nbw2)
+ raise RuntimeError("SuppressInternalWires() works not correctly")
#Add In Study
Id_face = geompy.addToStudy(face, "Face without internal wires")
Shape = geompy.MakePolyline([p0, pz, py, p200])
#Check shape
- print "Before closing contour:"
+ print("Before closing contour:")
isValid = geompy.CheckShape(Shape)
if isValid == 0:
- print "The shape is not valid"
+ print("The shape is not valid")
else:
- print "The shape seems to be valid"
+ print("The shape seems to be valid")
#Close Contour
IsCommonVertex = 0 # false
CC = geompy.CloseContour(Shape, Wires, IsCommonVertex)
#Check shape
- print "After closing contour:"
+ print("After closing contour:")
isValid = geompy.CheckShape(CC)
if isValid == 0:
- print "The shape is not valid"
- raise RuntimeError, "It seems, that the contour was not closed"
+ print("The shape is not valid")
+ raise RuntimeError("It seems, that the contour was not closed")
else:
- print "The shape seems to be valid"
+ print("The shape seems to be valid")
#Add In Study
Id_Shape = geompy.addToStudy(Shape, "Shape with open wire")
f_id = geompy.addToStudyInFather(Cut, face, f_name)
f_glob_id = geompy.GetSubShapeID(Cut, face)
- print "face ", ind, " global index = ", f_glob_id
+ print("face ", ind, " global index = ", f_glob_id)
ind = ind + 1
f_glob_id_0 = geompy.GetSubShapeID(Cut, faces[0])
f_id = geompy.addToStudyInFather(cut_without_f_0, face, f_name)
f_glob_id = geompy.GetSubShapeID(cut_without_f_0, face)
- print "face ", ind, " global index = ", f_glob_id
+ print("face ", ind, " global index = ", f_glob_id)
ind = ind + 1
f_glob_id_3 = geompy.GetSubShapeID(cut_without_f_0, faces1[3])
w_id = geompy.addToStudyInFather(cut_without_f_0_3, wire, w_name)
w_glob_id = geompy.GetSubShapeID(cut_without_f_0_3, wire)
- print "wire ", ind, " global index = ", w_glob_id
+ print("wire ", ind, " global index = ", w_glob_id)
ind = ind + 1
w_3 = geompy.GetSubShapeID(cut_without_f_0_3, wires[3])
Id_Box = geompy.addToStudy(Box, "Box")
Id_Divide = geompy.addToStudy(Divide, "Box with Divided Edge")
+ # using geompy.DivideEdgeByPoint()
+ p = geompy.MakeVertex( 30, -5, 10, theName="Point to project" )
+ edge = geompy.GetEdgeNearPoint( Box, p, theName="Edge to split")
+ div = geompy.DivideEdgeByPoint( Box, edge, p, theName="Box (edge divided)")
+ assert geompy.NumberOfEdges( Box ) == geompy.NumberOfEdges( div ) - 1
+
def TestFuseEdges (geompy):
# create vertices
Joined_1 = geompy.RemoveInternalFaces(Partition_1)
geompy.addToStudy(Joined_1, 'Joined_1')
+def TestSewGluing(geompy):
+
+ import GEOM
+ box1 = geompy.MakeBox(0,0,0, 1,1,1)
+ box2 = geompy.MakeBox(1,0,0, 2,1,1)
+ comp = geompy.MakeCompound( [box1, box2] )
+
+ # no sewing with AllowNonManifold=False
+ sew1 = geompy.MakeSewing( [box1,box2], 1e-5, AllowNonManifold=False)
+ assert not sew1
+ sew2 = geompy.MakeSewing( comp, 1e-5, AllowNonManifold=False)
+ assert not sew2
+ sew3 = geompy.MakeSewing( [comp], 1e-5, AllowNonManifold=False)
+ assert not sew3
+ sew1 = geompy.Sew( [box1,box2], 1e-5, AllowNonManifold=False)
+ assert not sew1
+ sew2 = geompy.Sew( comp, 1e-5, AllowNonManifold=False)
+ assert not sew2
+ sew3 = geompy.Sew( [comp], 1e-5, AllowNonManifold=False)
+ assert not sew3
+
+ # check MakeSewing()
+ sew1 = geompy.MakeSewing( [box1,box2], 1e-5, AllowNonManifold=True)
+ assert sew1.GetShapeType() == GEOM.SHELL
+ assert geompy.NumberOfFaces( sew1 ) == geompy.NumberOfFaces( comp )
+ assert geompy.NumberOfEdges( sew1 ) == geompy.NumberOfEdges( comp ) - 4
+ sew2 = geompy.MakeSewing( comp, 1e-5, AllowNonManifold=True)
+ assert sew2.GetShapeType() == GEOM.SHELL
+ assert geompy.NumberOfFaces( sew2 ) == geompy.NumberOfFaces( comp )
+ assert geompy.NumberOfEdges( sew2 ) == geompy.NumberOfEdges( comp ) - 4
+ sew3 = geompy.MakeSewing( [comp], 1e-5, AllowNonManifold=True)
+ assert sew3.GetShapeType() == GEOM.SHELL
+ assert geompy.NumberOfFaces( sew3 ) == geompy.NumberOfFaces( comp )
+ assert geompy.NumberOfEdges( sew3 ) == geompy.NumberOfEdges( comp ) - 4
+ # check Sew()
+ sew1 = geompy.Sew( [box1,box2], 1e-5, AllowNonManifold=True)
+ assert sew1.GetShapeType() == GEOM.SHELL
+ assert geompy.NumberOfFaces( sew1 ) == geompy.NumberOfFaces( comp )
+ assert geompy.NumberOfEdges( sew1 ) == geompy.NumberOfEdges( comp ) - 4
+ sew2 = geompy.Sew( comp, 1e-5, AllowNonManifold=True)
+ assert sew2.GetShapeType() == GEOM.SHELL
+ assert geompy.NumberOfFaces( sew2 ) == geompy.NumberOfFaces( comp )
+ assert geompy.NumberOfEdges( sew2 ) == geompy.NumberOfEdges( comp ) - 4
+ sew3 = geompy.Sew( [comp], 1e-5, AllowNonManifold=True)
+ assert sew3.GetShapeType() == GEOM.SHELL
+ assert geompy.NumberOfFaces( sew3 ) == geompy.NumberOfFaces( comp )
+ assert geompy.NumberOfEdges( sew3 ) == geompy.NumberOfEdges( comp ) - 4
+
+ # check MakeGlueFaces()
+ glueF1 = geompy.MakeGlueFaces( [box1,box2], 1e-5)
+ assert glueF1.GetShapeType() == GEOM.COMPOUND
+ assert geompy.NumberOfFaces( glueF1 ) == geompy.NumberOfFaces( comp ) - 1
+ assert geompy.NumberOfEdges( glueF1 ) == geompy.NumberOfEdges( comp ) - 4
+ glueF2 = geompy.MakeGlueFaces( [comp], 1e-5)
+ assert glueF2.GetShapeType() == GEOM.COMPOUND
+ assert geompy.NumberOfFaces( glueF2 ) == geompy.NumberOfFaces( comp ) - 1
+ assert geompy.NumberOfEdges( glueF2 ) == geompy.NumberOfEdges( comp ) - 4
+ glueF3 = geompy.MakeGlueFaces( comp, 1e-5)
+ assert glueF3.GetShapeType() == GEOM.COMPOUND
+ assert geompy.NumberOfFaces( glueF3 ) == geompy.NumberOfFaces( comp ) - 1
+ assert geompy.NumberOfEdges( glueF3 ) == geompy.NumberOfEdges( comp ) - 4
+
+ # check GetGlueFaces()
+ glueFF1 = geompy.GetGlueFaces( [box1,box2], 1e-5)
+ assert len( glueFF1 ) == 1 and glueFF1[0].GetShapeType() == GEOM.FACE
+ glueFF2 = geompy.GetGlueFaces( [comp], 1e-5)
+ assert len( glueFF2 ) == 1 and glueFF2[0].GetShapeType() == GEOM.FACE
+ glueFF3 = geompy.GetGlueFaces( comp, 1e-5)
+ assert len( glueFF3 ) == 1 and glueFF3[0].GetShapeType() == GEOM.FACE
+
+ #check MakeGlueFacesByList()
+ glueF1 = geompy.MakeGlueFacesByList( [box1,box2], 1e-5, glueFF1)
+ assert glueF1.GetShapeType() == GEOM.COMPOUND
+ assert geompy.NumberOfFaces( glueF1 ) == geompy.NumberOfFaces( comp ) - 1
+ assert geompy.NumberOfEdges( glueF1 ) == geompy.NumberOfEdges( comp ) - 4
+ glueF2 = geompy.MakeGlueFacesByList( [comp], 1e-5, glueFF2)
+ assert glueF2.GetShapeType() == GEOM.COMPOUND
+ assert geompy.NumberOfFaces( glueF2 ) == geompy.NumberOfFaces( comp ) - 1
+ assert geompy.NumberOfEdges( glueF2 ) == geompy.NumberOfEdges( comp ) - 4
+ glueF3 = geompy.MakeGlueFacesByList( comp, 1e-5, glueFF3 )
+ assert glueF3.GetShapeType() == GEOM.COMPOUND
+ assert geompy.NumberOfFaces( glueF3 ) == geompy.NumberOfFaces( comp ) - 1
+ assert geompy.NumberOfEdges( glueF3 ) == geompy.NumberOfEdges( comp ) - 4
+
+ # check MakeGlueEdges()
+ glueE1 = geompy.MakeGlueEdges( [box1,box2], 1e-5)
+ assert glueE1.GetShapeType() == GEOM.COMPOUND
+ assert geompy.NumberOfEdges( glueE1 ) == geompy.NumberOfEdges( comp ) - 4
+ glueE2 = geompy.MakeGlueEdges( [comp], 1e-5)
+ assert glueE2.GetShapeType() == GEOM.COMPOUND
+ assert geompy.NumberOfEdges( glueE2 ) == geompy.NumberOfEdges( comp ) - 4
+ glueE3 = geompy.MakeGlueEdges( comp, 1e-5)
+ assert glueE3.GetShapeType() == GEOM.COMPOUND
+ assert geompy.NumberOfEdges( glueE3 ) == geompy.NumberOfEdges( comp ) - 4
+
+ # check GetGlueEdges()
+ glueEE1 = geompy.GetGlueEdges( [box1,box2], 1e-5)
+ assert len( glueEE1 ) == 4 and glueEE1[0].GetShapeType() == GEOM.EDGE
+ glueEE2 = geompy.GetGlueEdges( [comp], 1e-5)
+ assert len( glueEE2 ) == 4 and glueEE2[0].GetShapeType() == GEOM.EDGE
+ glueEE3 = geompy.GetGlueEdges( comp, 1e-5)
+ assert len( glueEE3 ) == 4 and glueEE3[0].GetShapeType() == GEOM.EDGE
+
+ #check MakeGlueEdgesByList()
+ glueEL1 = geompy.MakeGlueEdgesByList( [box1,box2], 1e-5, glueEE1)
+ assert glueEL1.GetShapeType() == GEOM.COMPOUND
+ assert geompy.NumberOfEdges( glueEL1 ) == geompy.NumberOfEdges( comp ) - 4
+ glueEL2 = geompy.MakeGlueEdgesByList( [comp], 1e-5, glueEE2)
+ assert glueEL2.GetShapeType() == GEOM.COMPOUND
+ assert geompy.NumberOfEdges( glueEL2 ) == geompy.NumberOfEdges( comp ) - 4
+ glueEL3 = geompy.MakeGlueEdgesByList( comp, 1e-5, glueEE3 )
+ assert glueEL3.GetShapeType() == GEOM.COMPOUND
+ assert geompy.NumberOfEdges( glueEL3 ) == geompy.NumberOfEdges( comp ) - 4
+
+ # check GetSharedShapesMulti()
+ sharedEE = geompy.GetSharedShapesMulti( glueEL3, geompy.ShapeType["EDGE"])
+ assert len( sharedEE ) == 4
+ assert sharedEE[0].GetShapeType() == GEOM.EDGE
+ assert sharedEE[1].GetShapeType() == GEOM.EDGE
+ assert sharedEE[2].GetShapeType() == GEOM.EDGE
+ assert sharedEE[3].GetShapeType() == GEOM.EDGE
+
+ return
+
def TestHealingOperations (geompy, math):
+ TestSewGluing(geompy)
TestMakeSewing(geompy, math)
TestDivideEdge(geompy)
TestSuppressHoles(geompy)