Skip to content

Commit

Permalink
OCC: curvature corrections
Browse files Browse the repository at this point in the history
  • Loading branch information
benoit128 committed Nov 27, 2024
1 parent e2c49c4 commit 18270ab
Show file tree
Hide file tree
Showing 10 changed files with 346 additions and 56 deletions.
34 changes: 17 additions & 17 deletions Cassiopee/CPlot/apps/tkCADFix.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,15 @@ def readCAD(event=None):
faces[2] = []
hook = OCC.readCAD(fileName, fileFmt)
# Previous hmax, hausd?
[hmax, hausd] = OCC.getCADcontainer(CTK.t)
[hmin, hmax, hausd] = OCC.getCADcontainer(CTK.t)
if hmax is None or (hmax < 0 and hausd < 0):
(hmax,hmin,hausd) = OCC.occ.analyseEdges(hook)
OCC._setCADcontainer(CTK.t, fileName, fileFmt, hmax, hausd)
CTK.CADHOOK = hook
# remesh and redisplay
CTK.setCursor(2, WIDGETS['frame'])
OCC._meshAllEdges(hook, CTK.t, hmax=hmax, hausd=hausd)
OCC._meshAllFacesTri(hook, CTK.t, hmax=hmax, hausd=hausd)
OCC._meshAllEdges(hook, CTK.t, hmin=hmin, hmax=hmax, hausd=hausd)
OCC._meshAllFacesTri(hook, CTK.t, hmin=hmin, hmax=hmax, hausd=hausd)
CTK.setCursor(0, WIDGETS['frame'])
CTK.display(CTK.t)
CTK.TXT.insert('START', 'CAD loaded from %s.\n'%fileName)
Expand All @@ -55,7 +55,7 @@ def sewCAD(event=None):
if CTK.CADHOOK is None: return
tol = CTK.varsFromWidget(VARS[2].get(), 1)[0]
hook = CTK.CADHOOK
[hmax, hausd] = OCC.getCADcontainer(CTK.t)
[hmin, hmax, hausd] = OCC.getCADcontainer(CTK.t)
faces = []
nzs = CPlot.getSelectedZones()
for nz in nzs:
Expand All @@ -79,8 +79,8 @@ def sewCAD(event=None):
edges[2] = []
faces = Internal.getNodeFromName1(CTK.t, 'FACES')
faces[2] = []
OCC._meshAllEdges(hook, CTK.t, hmax=hmax, hausd=hausd) # loose manual remeshing
OCC._meshAllFacesTri(hook, CTK.t, hmax=hmax, hausd=hausd)
OCC._meshAllEdges(hook, CTK.t, hmin=hmin, hmax=hmax, hausd=hausd) # loose manual remeshing
OCC._meshAllFacesTri(hook, CTK.t, hmin=hmin, hmax=hmax, hausd=hausd)

CTK.setCursor(0, WIDGETS['frame'])
CTK.setCursor(0, WIDGETS['sewingButton'])
Expand All @@ -99,7 +99,7 @@ def filletCAD(event=None):
if CTK.CADHOOK is None: return
radius = CTK.varsFromWidget(VARS[3].get(), 1)[0]
hook = CTK.CADHOOK
[hmax, hausd] = OCC.getCADcontainer(CTK.t)
[hmin, hmax, hausd] = OCC.getCADcontainer(CTK.t)
# Get selected edges
nzs = CPlot.getSelectedZones()
edges = []
Expand Down Expand Up @@ -128,8 +128,8 @@ def filletCAD(event=None):
edges[2] = []
faces = Internal.getNodeFromName1(CTK.t, 'FACES')
faces[2] = []
OCC._meshAllEdges(hook, CTK.t, hmax=hmax, hausd=hausd) # loose manual remeshing...
OCC._meshAllFacesTri(hook, CTK.t, hmax=hmax, hausd=hausd)
OCC._meshAllEdges(hook, CTK.t, hmin=hmin, hmax=hmax, hausd=hausd) # loose manual remeshing...
OCC._meshAllFacesTri(hook, CTK.t, hmin=hmin, hmax=hmax, hausd=hausd)
CTK.setCursor(0, WIDGETS['frame'])
CTK.setCursor(0, WIDGETS['filletButton'])

Expand All @@ -143,7 +143,7 @@ def removeFaces(event=None):
import OCC.PyTree as OCC
if CTK.CADHOOK is None: return
hook = CTK.CADHOOK
[hmax, hausd] = OCC.getCADcontainer(CTK.t)
[hmin, hmax, hausd] = OCC.getCADcontainer(CTK.t)
# Get selected faces
nzs = CPlot.getSelectedZones()
faces = []
Expand Down Expand Up @@ -198,7 +198,7 @@ def fillHole(event=None):
import OCC.PyTree as OCC
if CTK.CADHOOK is None: return
hook = CTK.CADHOOK
[hmax, hausd] = OCC.getCADcontainer(CTK.t)
[hmin, hmax, hausd] = OCC.getCADcontainer(CTK.t)
# Get selected edges
nzs = CPlot.getSelectedZones()
edges = []
Expand Down Expand Up @@ -232,8 +232,8 @@ def fillHole(event=None):
edges[2] = []
faces = Internal.getNodeFromName1(CTK.t, 'FACES')
faces[2] = []
OCC._meshAllEdges(hook, CTK.t, hmax=hmax, hausd=hausd) # loose manual remeshing...
OCC._meshAllFacesTri(hook, CTK.t, hmax=hmax, hausd=hausd)
OCC._meshAllEdges(hook, CTK.t, hmin=hmin, hmax=hmax, hausd=hausd) # loose manual remeshing...
OCC._meshAllFacesTri(hook, CTK.t, hmin=hmin, hmax=hmax, hausd=hausd)
CTK.setCursor(0, WIDGETS['frame'])
CTK.setCursor(0, WIDGETS['fillHoleButton'])

Expand Down Expand Up @@ -267,15 +267,15 @@ def setTrimFace1():
no = Internal.getNodeFromName1(CAD, 'no')
no = Internal.getValue(no)
selected += str(no)+' '
print(selected, flush=True)
#print(selected, flush=True)
VARS[5].set(selected)

#==============================================================================
def trimFaces(event=None):
import OCC.PyTree as OCC
if CTK.CADHOOK is None: return
hook = CTK.CADHOOK
[hmax, hausd] = OCC.getCADcontainer(CTK.t)
[hmin, hmax, hausd] = OCC.getCADcontainer(CTK.t)
# Get selected faces
nzs = CPlot.getSelectedZones()
faces1 = []
Expand Down Expand Up @@ -316,8 +316,8 @@ def trimFaces(event=None):
edges[2] = []
faces = Internal.getNodeFromName1(CTK.t, 'FACES')
faces[2] = []
OCC._meshAllEdges(hook, CTK.t, hmax=hmax, hausd=hausd) # loose manual remeshing...
OCC._meshAllFacesTri(hook, CTK.t, hmax=hmax, hausd=hausd)
OCC._meshAllEdges(hook, CTK.t, hmin=hmin, hmax=hmax, hausd=hausd) # loose manual remeshing...
OCC._meshAllFacesTri(hook, CTK.t, hmin=hmin, hmax=hmax, hausd=hausd)

CTK.setCursor(0, WIDGETS['frame'])
CTK.setCursor(0, WIDGETS['trimFacesButton'])
Expand Down
2 changes: 1 addition & 1 deletion Cassiopee/Converter/Converter/PyTree.py
Original file line number Diff line number Diff line change
Expand Up @@ -1063,7 +1063,7 @@ def convertFile2PyTree(fileName, format=None, nptsCurve=20, nptsLine=2,
# auto setting
(hmin,hmax,hausd) = OCC.occ.analyseEdges(hook)
CTK.CADHOOK = hook
t = OCC.meshAll(hook, hmax, hmax, -1.) # constant hmax
t = OCC.meshAll(hook, hmax, hmax, hausd) # constant hmax
_upgradeTree(t)
return t

Expand Down
4 changes: 2 additions & 2 deletions Cassiopee/KCore/KCore/Nuga/include/DelaunayMath.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@ namespace K_LINEAR
{
public:
static void eigen_vectors
(E_Float a00, E_Float a11, E_Float a10, E_Float& lambda0, E_Float& lambda1, E_Float* v0, E_Float* v1) ;
(E_Float a00, E_Float a11, E_Float a10, E_Float& lambda0, E_Float& lambda1, E_Float* v0, E_Float* v1);

static void eigen_values
(E_Float a00, E_Float a11, E_Float a10, E_Float& lambda0, E_Float& lambda1) ;
(E_Float a00, E_Float a11, E_Float a10, E_Float& lambda0, E_Float& lambda1);

static void simultaneous_reduction
(const K_FLD::FloatArray& M1, const K_FLD::FloatArray& M2,
Expand Down
10 changes: 5 additions & 5 deletions Cassiopee/KCore/KCore/Nuga/include/Metric.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ namespace DELAUNAY{

VarMetric(K_FLD::FloatArray& pos, E_Float hmin, E_Float hmax, eInterpType interp_type = LINEAR);

virtual ~VarMetric(void){if (_interpol){delete _interpol; _interpol = 0;} }
virtual ~VarMetric(void){if (_interpol) {delete _interpol; _interpol=0;} }

VarMetric& operator=(const VarMetric& rhs) { _hmin = _hmax = -1; _field = rhs._field; _pos = rhs._pos; _interpol = nullptr; return *this; }

Expand Down Expand Up @@ -810,10 +810,10 @@ namespace DELAUNAY{
assert (isValidMetric(mj));
#endif

E_Float v[2]; E_Float vi[2]; E_Float vj[2];
//E_Float* v = _pta2;
//E_Float* vi = _ptb2;
//E_Float* vj = _ptc2;
E_Float v[3]; E_Float vi[3]; E_Float vj[3];
//E_Float* v = _pta3;
//E_Float* vi = _ptb3;
//E_Float* vj = _ptc3;

NUGA::diff<3> (_pos->col(Nj), _pos->col(Ni), v);

Expand Down
6 changes: 3 additions & 3 deletions Cassiopee/OCC/OCC/Atomic/analyse.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,12 +68,12 @@ PyObject* K_OCC::analyseEdges(PyObject* self, PyObject* args)
}
E_Float emean = ltot / edges.Extent();

// calcul hmax, hausd : 30 pts par edges moyen
E_Float hmax = emean / 30.;
// calcul hmax, hausd : 20 pts par edges moyen
E_Float hmax = emean / 20.;
// calcul du nbre de points sur la longueur totale
E_Int Np = ltot / hmax;
if (Np > 20000) hmax = ltot / 20000.;
E_Float hmin = emin / 30.;
E_Float hmin = emin / 20.;
E_Float hausd = hmax / 10.;
printf("INFO: suggested hmin=%g hmax=%g hausd=%g\n", hmin, hmax, hausd);
return Py_BuildValue("ddd", hmin, hmax, hausd);
Expand Down
10 changes: 5 additions & 5 deletions Cassiopee/OCC/OCC/Atomic/evalFace.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,17 +30,17 @@
void evalFace__(E_Int npts, E_Float* u, E_Float* v, const TopoDS_Face& F,
E_Float* x, E_Float* y, E_Float* z)
{
Handle(Geom_Surface) face = BRep_Tool::Surface(F);
Handle(Geom_Surface) face = BRep_Tool::Surface(F);
#pragma omp parallel
{
{
gp_Pnt Pt;
#pragma omp for
for (E_Int i = 0; i < npts; i++)
{
face->D0(u[i], v[i], Pt);
x[i] = Pt.X(); y[i] = Pt.Y(); z[i] = Pt.Z();
face->D0(u[i], v[i], Pt);
x[i] = Pt.X(); y[i] = Pt.Y(); z[i] = Pt.Z();
}
}
}
}

// evalFace
Expand Down
Loading

0 comments on commit 18270ab

Please sign in to comment.