Skip to content

Commit 2c268be

Browse files
committed
OCC: solve corner points
1 parent bb87424 commit 2c268be

File tree

8 files changed

+48
-28
lines changed

8 files changed

+48
-28
lines changed

Cassiopee/CPlot/CPlot/set.cpp

+3-6
Original file line numberDiff line numberDiff line change
@@ -631,8 +631,7 @@ PyObject* K_CPLOT::setSelectedZones(PyObject* self, PyObject* args)
631631

632632
if (PyList_Check(o) == 0)
633633
{
634-
PyErr_SetString(
635-
PyExc_TypeError,
634+
PyErr_SetString(PyExc_TypeError,
636635
"setSelectedZones: arg must be a list.");
637636
return NULL;
638637
}
@@ -645,15 +644,13 @@ PyObject* K_CPLOT::setSelectedZones(PyObject* self, PyObject* args)
645644
// tpl must be a tuple of two ints (no, 1)
646645
if (PyTuple_Check(tpl) == 0)
647646
{
648-
PyErr_SetString(
649-
PyExc_TypeError,
647+
PyErr_SetString(PyExc_TypeError,
650648
"setSelectedZones: arg must be a list of tuples (noz, 1).");
651649
return NULL;
652650
}
653651
if (PyTuple_Size(tpl) != 2)
654652
{
655-
PyErr_SetString(
656-
PyExc_TypeError,
653+
PyErr_SetString(PyExc_TypeError,
657654
"setSelectedZones: arg must be a list of tuples (noz, 1).");
658655
return NULL;
659656
}

Cassiopee/CPlot/apps/tkCADFix.py

+12-9
Original file line numberDiff line numberDiff line change
@@ -411,25 +411,28 @@ def checkWatertight(event=None):
411411
if CAD is not None:
412412
hmax = Internal.getNodeFromName1(CAD, 'hmax')
413413
hmax = Internal.getValue(hmax)
414-
tol = hmax/100.
414+
hmin = Internal.getNodeFromName1(CAD, 'hmin')
415+
hmin = Internal.getValue(hmin)
416+
tol = (hmin+hmax)*0.2
415417

416418
CTK.t = C.addBase2PyTree(CTK.t, 'LEAKS', 1)
417419
p = Internal.getNodeFromName1(CTK.t, 'LEAKS')
418420
gnob = C.getNobOfBase(p, CTK.t)
419421

420-
ef = OCC.getComponents(CTK.t, tol)
422+
ef = OCC.getComponents(CTK.t)
421423

422424
VARS[6].set('Components: %d'%(len(ef)))
423425

424426
isWatertight = False
425-
try:
426-
isWatertight = True
427-
for f in ef:
427+
#try:
428+
isWatertight = True
429+
for f in ef:
430+
try:
428431
ext = P.exteriorFaces(f)
429432
ext = T.splitConnexity(ext)
430433
for i in ext: CTK.add(CTK.t, gnob, -1, i)
431-
if len(ext) != 0: isWatertight = False
432-
except: isWatertight = True
434+
if len(ext) != 0: isWatertight = False; break
435+
except: isWatertight = True
433436

434437
(CTK.Nb, CTK.Nz) = CPlot.updateCPlotNumbering(CTK.t)
435438
CTK.TKTREE.updateApp()
@@ -468,7 +471,8 @@ def createApp(win):
468471
WIDGETS['frameMenu'] = FrameMenu
469472

470473
#- VARS -
471-
tol = 1.e-6
474+
tol = 1.e-6; NL = 0
475+
fileName = ''; fileFmt = 'fmt_step'
472476
if CTK.CADHOOK is not None:
473477
import OCC.PyTree as OCC
474478
fileName, fileFmt = OCC.getFileAndFormat(CTK.CADHOOK)
@@ -479,7 +483,6 @@ def createApp(win):
479483
tol = Internal.getValue(tol)
480484
power = math.floor(math.log10(abs(tol)))
481485
tol = round(tol, -power)
482-
else: fileName = ''; fileFmt = 'fmt_step'; NL = 0
483486

484487
# -0- CAD file name -
485488
V = TK.StringVar(win); V.set(fileName); VARS.append(V)

Cassiopee/Generator/Generator/closeBorders.cpp

-1
Original file line numberDiff line numberDiff line change
@@ -569,6 +569,5 @@ void K_GENERATOR::closeAllStructuredMeshes(
569569
}
570570
}
571571
}
572-
573572
} // tous les pts
574573
}

Cassiopee/OCC/OCC/Atomic/meshEdge2.cpp

+15-6
Original file line numberDiff line numberDiff line change
@@ -1070,6 +1070,11 @@ E_Int __meshEdgeByFace(const TopoDS_Edge& E, const TopoDS_Face& F,
10701070
E_Float* pu = coords.begin(4);
10711071
E_Float* pv = coords.begin(5);
10721072

1073+
E_Float* pex = fe.begin(1);
1074+
E_Float* pey = fe.begin(2);
1075+
E_Float* pez = fe.begin(3);
1076+
E_Float* peu = fe.begin(4);
1077+
10731078
// degenerated
10741079
if (BRep_Tool::Degenerated(E))
10751080
{
@@ -1084,12 +1089,14 @@ E_Int __meshEdgeByFace(const TopoDS_Edge& E, const TopoDS_Face& F,
10841089
pCurve->D0(u, Puv);
10851090
if (reverse)
10861091
{
1087-
px[nbPoints-i-1] = Pt.X(); py[nbPoints-i-1] = Pt.Y(); pz[nbPoints-i-1] = Pt.Z();
1092+
//px[nbPoints-i-1] = Pt.X(); py[nbPoints-i-1] = Pt.Y(); pz[nbPoints-i-1] = Pt.Z();
1093+
px[nbPoints-i-1] = pex[i]; py[nbPoints-i-1] = pey[i]; pz[nbPoints-i-1] = pez[i];
10881094
pu[nbPoints-i-1] = Puv.X(); pv[nbPoints-i-1] = Puv.Y();
10891095
}
10901096
else
10911097
{
1092-
px[i] = Pt.X(); py[i] = Pt.Y(); pz[i] = Pt.Z();
1098+
//px[i] = Pt.X(); py[i] = Pt.Y(); pz[i] = Pt.Z();
1099+
px[i] = pex[i]; py[i] = pey[i]; pz[i] = pez[i];
10931100
pu[i] = Puv.X(); pv[i] = Puv.Y();
10941101
}
10951102
}
@@ -1098,20 +1105,22 @@ E_Int __meshEdgeByFace(const TopoDS_Edge& E, const TopoDS_Face& F,
10981105

10991106
// non degenerated
11001107
{
1101-
gp_Pnt Pt; gp_Pnt2d Puv;
1108+
gp_Pnt Pt; gp_Pnt2d Puv; E_Float u;
11021109
for (E_Int i = 1; i <= nbPoints; i++)
11031110
{
1104-
E_Float u = fe(i-1,4);
1111+
u = peu[i-1];
11051112
C0.D0(u, Pt);
11061113
pCurve->D0(u, Puv);
11071114
if (reverse)
11081115
{
1109-
px[nbPoints-i] = Pt.X(); py[nbPoints-i] = Pt.Y(); pz[nbPoints-i] = Pt.Z();
1116+
//px[nbPoints-i] = Pt.X(); py[nbPoints-i] = Pt.Y(); pz[nbPoints-i] = Pt.Z();
1117+
px[nbPoints-i] = pex[i-1]; py[nbPoints-i] = pey[i-1]; pz[nbPoints-i] = pez[i-1];
11101118
pu[nbPoints-i] = Puv.X(); pv[nbPoints-i] = Puv.Y();
11111119
}
11121120
else
11131121
{
1114-
px[i-1] = Pt.X(); py[i-1] = Pt.Y(); pz[i-1] = Pt.Z();
1122+
//px[i-1] = Pt.X(); py[i-1] = Pt.Y(); pz[i-1] = Pt.Z();
1123+
px[i-1] = pex[i-1]; py[i-1] = pey[i-1]; pz[i-1] = pez[i-1];
11151124
pu[i-1] = Puv.X(); pv[i-1] = Puv.Y();
11161125
}
11171126
}

Cassiopee/OCC/OCC/Atomic/readCAD.cpp

+8
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,14 @@ PyObject* K_OCC::readCAD(PyObject* self, PyObject* args)
4242
char* fileName; char* fileFmt;
4343
if (!PyArg_ParseTuple(args, "ss", &fileName, &fileFmt)) return NULL;
4444

45+
FILE* ptrFile = fopen(fileName, "r");
46+
if (ptrFile == NULL)
47+
{
48+
PyErr_SetString(PyExc_TypeError, "readCAD: file not found.");
49+
return NULL;
50+
}
51+
fclose(ptrFile);
52+
4553
TopoDS_Shape* shp = new TopoDS_Shape();
4654

4755
TDocStd_Document* doc = NULL;

Cassiopee/OCC/OCC/OCC.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -542,6 +542,7 @@ def meshFaceWithMetric(hook, i, edges, hmin, hmax, hausd, mesh, FAILED):
542542
try:
543543
a = occ.trimesh(hook, edges, i, hmin, hmax, hausd, 1.1)
544544
_enforceEdgesInFace(a, edgesSav)
545+
a = Generator.close(a, 1.e-10) # needed for periodic faces
545546
if occ.getFaceOrientation(hook, i) == 0:
546547
a = Transform.reorder(a, (-1,))
547548
mesh.append(a)
@@ -572,6 +573,7 @@ def meshFaceInUV(hook, i, edges, grading, mesh, FAILED):
572573
_unscaleUV([a], T)
573574
o = occ.evalFace(hook, a, i)
574575
_enforceEdgesInFace(o, edgesSav)
576+
a = Generator.close(a, 1.e-10) # needed for periodic faces
575577
if occ.getFaceOrientation(hook, i) == 0:
576578
o = Transform.reorder(o, (-1,))
577579
mesh.append(o)
@@ -584,7 +586,7 @@ def meshFaceInUV(hook, i, edges, grading, mesh, FAILED):
584586

585587
return SUCCESS
586588

587-
# mesh all CAD edges with hmax, hausd
589+
# mesh all CAD edges with hmin, hmax, hausd
588590
def meshAllEdges(hook, hmin, hmax, hausd, N, edgeList=None):
589591
if edgeList is None:
590592
nbEdges = occ.getNbEdges(hook)
@@ -593,6 +595,7 @@ def meshAllEdges(hook, hmin, hmax, hausd, N, edgeList=None):
593595
for i in edgeList:
594596
e = occ.meshOneEdge(hook, i, hmin, hmax, hausd, N, None)
595597
dedges.append(e)
598+
dedges = Generator.zip(dedges, tol=hmax/100.) # safe and necessary for corner/seam points
596599
return dedges
597600

598601
#=================================================================

Cassiopee/OCC/OCC/PyTree.py

+4-3
Original file line numberDiff line numberDiff line change
@@ -1382,7 +1382,7 @@ def identifyTags__(a):
13821382
array = C.getFields(Internal.__FlowSolutionNodes__, a, "__tag__", api=3)[0]
13831383
return OCC.identifyTags__(array)
13841384

1385-
def getComponents(t, tol=1.e-10):
1385+
def getComponents(t):
13861386
"""Return the number of components in t, taggings faces with component number."""
13871387
import Transform.PyTree as T
13881388
# init FACES with a tag
@@ -1397,9 +1397,10 @@ def getComponents(t, tol=1.e-10):
13971397
C._initVars(z, '__tag__ = %d'%no)
13981398

13991399
# join all zones
1400-
a = G.zip(zones, tol)
1400+
G._zip(zones, 1.e-10) # volontairement in place, maybe useless
14011401
a = T.join(zones)
1402-
a = T.splitConnexity(a)
1402+
#a = T.splitConnexity(a)
1403+
a = T.splitManifold(a)
14031404

14041405
# Identify faces in component
14051406
tags = {}

Cassiopee/Post/Post/zipper.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ PyObject* K_POST::zipperF(PyObject* self, PyObject* args)
239239
}
240240

241241
//=============================================================================
242-
// Lecture des options et retourne les valeurs associées:
242+
// Lecture des options et retourne les valeurs associ�es:
243243
// geomTol: tolerance geometrique
244244
//=============================================================================
245245
void K_POST::readZipperOptions(PyObject* optionList, E_Float& overlapTol,
@@ -287,7 +287,7 @@ void K_POST::readZipperOptions(PyObject* optionList, E_Float& overlapTol,
287287
{
288288
printf("Warning: zipper: matchTol must be a float. Set to default value: 1.e-6.\n");
289289
}
290-
else matchTol = PyFloat_AsDouble(tpl2);
290+
else matchTol = PyFloat_AsDouble(tpl2);
291291
}
292292
else //autres
293293
{

0 commit comments

Comments
 (0)