From d5a7f2796accd81ecc7d23a1cc789ebca6f34b85 Mon Sep 17 00:00:00 2001 From: gdd Date: Fri, 18 Feb 2011 15:40:05 +0000 Subject: [PATCH] rnc : fully tested engine version --- idl/BLSURFPlugin_Algorithm.idl | 15 + src/BLSURFPlugin/BLSURFPlugin_Attractor.cxx | 264 ++++++------------ src/BLSURFPlugin/BLSURFPlugin_Attractor.hxx | 36 +-- src/BLSURFPlugin/BLSURFPlugin_BLSURF.cxx | 10 +- src/BLSURFPlugin/BLSURFPlugin_Hypothesis.cxx | 2 +- .../BLSURFPlugin_Hypothesis_i.cxx | 4 +- .../BLSURFPlugin_Hypothesis_i.hxx | 4 +- src/GUI/BLSURFPluginGUI_HypothesisCreator.cxx | 2 +- 8 files changed, 123 insertions(+), 214 deletions(-) diff --git a/idl/BLSURFPlugin_Algorithm.idl b/idl/BLSURFPlugin_Algorithm.idl index 1f577b4..291272a 100644 --- a/idl/BLSURFPlugin_Algorithm.idl +++ b/idl/BLSURFPlugin_Algorithm.idl @@ -272,6 +272,21 @@ module BLSURFPlugin string GetAttractorEntry(in string entry); string_array GetAttractorEntries(); + /*! + * Set/unset an attractor given as geom object on another geom object + */ + void SetAttractorGeom(in GEOM::GEOM_Object GeomObj, in GEOM::GEOM_Object AttractorShape, in double StartSize, in double EndSize, in double ActionRadius, in double ConstantRadius); + // void SetAttractorGeom(in GEOM::GEOM_Object theFace, in GEOM::GEOM_Object theAttractor, in string theParams, in long type); + void UnsetAttractorGeom(in GEOM::GEOM_Object GeomObj); + + /*! + * Set an attractor given by entry on a geom object given by entry + */ + // void SetClassAttractorEntry(in string entry, in string att_entry, in double StartSize, in double EndSize, in double ActionRadius, in double ConstantRadius ); +// void SetAttractorEntryGeom(in string theFaceEntry, in GEOM::GEOM_Object theAttractor, in string theParams, in long type); + // string GetAttractorEntry(in string entry); // TODO a coder + //string_array GetAttractorEntries(); + /* void SetCustomSizeMapEntry(in string entry, in string sizeMap); string GetCustomSizeMapEntry(in string entry); diff --git a/src/BLSURFPlugin/BLSURFPlugin_Attractor.cxx b/src/BLSURFPlugin/BLSURFPlugin_Attractor.cxx index 0a67798..bd8c055 100644 --- a/src/BLSURFPlugin/BLSURFPlugin_Attractor.cxx +++ b/src/BLSURFPlugin/BLSURFPlugin_Attractor.cxx @@ -54,58 +54,33 @@ BLSURFPlugin_Attractor::BLSURFPlugin_Attractor (const TopoDS_Face& Face, const T { _face = Face; _attractorShape = Attractor; - //_mapGrid = 200; init(); } bool BLSURFPlugin_Attractor::init(){ - MESSAGE("construction d'un attracteur"); Standard_Real u0,v0; - int i,j ; - //_known.clear(); + int i,j,i0,j0 ; + _known.clear(); _trial.clear(); Handle(Geom_Surface) aSurf = BRep_Tool::Surface(_face); - Trial_Pnt TPnt(3,0); //TPnt(0,0,0); - - // Discretization of the parameters - MESSAGE("Calcul des bornes de la surface : "); - //aSurf->Bounds(_u1, _u2, _v1, _v2); // unusable in the generic case because the surface may be infinite (ok for prototype on a Sphere) + Trial_Pnt TPnt(3,0); - // Calculation of the bounds for the generic case + // Calculation of the bounds of the face ShapeAnalysis::GetFaceUVBounds(_face,_u1,_u2,_v1,_v2); MESSAGE("u1 = "<<_u1<<" ,u2 = "<<_u2); MESSAGE("v1 = "<<_v1<<" ,v2 = "<<_v2); _gridU = floor (_u2 - _u1) / _step; _gridV = floor (_v2 - _v1) / _step; -// double Ustep = (_u2 - _u1) / _mapGrid; -// double Vstep = (_v2 - _v1) / _mapGrid; for (i=0; i<=_gridU; i++){ _vectU.push_back(_u1+i*(_u2-_u1)/_gridU) ; } for (j=0; j<=_gridV; j++){ _vectV.push_back(_v1+j*(_v2-_v1)/_gridV) ; } - - // Determination of the starting point - gp_Pnt P = BRep_Tool::Pnt(TopoDS::Vertex(_attractorShape)); - GeomAPI_ProjectPointOnSurf projector( P, aSurf ); - projector.LowerDistanceParameters(u0,v0); - MESSAGE("u0 = "< temp(_gridV+1,1.e+6); // Provisoirement infini = 10000 + // Initialization of _DMap and _known + std::vector temp(_gridV+1,std::numeric_limits::infinity()); // Set distance of all "far" points to Infinity for (i=0; i<=_gridU; i++){ _DMap.push_back(temp); } @@ -113,19 +88,46 @@ bool BLSURFPlugin_Attractor::init(){ for (i=0; i<=_gridU; i++){ _known.push_back(temp2); } - MESSAGE("DMap(0,0) : "<< _DMap[0][0]); - _DMap[i0][j0] = 0.; // Set distance of starting point to 0. - - // _buildMap(); // Computes the distance for all points of the discrete surface -} + // Determination of the starting points + if (_attractorShape.ShapeType() == TopAbs_VERTEX){ + gp_Pnt P = BRep_Tool::Pnt(TopoDS::Vertex(_attractorShape)); + GeomAPI_ProjectPointOnSurf projector( P, aSurf ); + projector.LowerDistanceParameters(u0,v0); + MESSAGE("u0 = "< 0 && count < 1000000){ - count++; - MESSAGE("boucle while : "<Ti;//static_cast((*min)[1]); - j0 = (*min)[2];//min->Tj;//static_cast((*min)[2]); - MESSAGE("i0 = "< probleme"); -// break; -// } -// _known.insert(Current_Pnt); // Move it to _known and remove it from _trial - _known[i0][j0] = true; // Move point to "Known" - //MESSAGE(Current_Pnt[0]<<" , "< 0 ){ + min = _trial.begin(); // Get trial point with min distance from start + i0 = (*min)[1]; + j0 = (*min)[2]; + _known[i0][j0] = true; // Move it to "Known" + _trial.erase(min); // Remove it from "Trial" + // Loop on neighbours of the trial min ---------------------------------------------------------------------- for (i=i0 - 1 ; i <= i0 + 1 ; i++){ - //MESSAGE("boucle for sur i"); - if (!aSurf->IsUPeriodic()){ // Periodic conditions in U - //MESSAGE("surface is not U periodique"); + if (!aSurf->IsUPeriodic()){ // Periodic conditions in U if (i > _gridU ){ break; } else if (i < 0){ i++; } } - ip = (i + _gridU + 1) % (_gridU+1); // We get a periodic index ip=modulo(i,N+2) so that i=-1->ip=N; i=0 -> ip=0 ; ... ; i=N+1 -> ip=0; + ip = (i + _gridU + 1) % (_gridU+1); // We get a periodic index ip=modulo(i,N+2) so that i=-1->ip=N; i=0 -> ip=0 ; ... ; i=N+1 -> ip=0; for (j=j0 - 1 ; j <= j0 + 1 ; j++){ - //MESSAGE("boucle for sur j"); - if (!aSurf->IsVPeriodic()){ // Periodic conditions in V . - //MESSAGE("surface is not V periodique"); + if (!aSurf->IsVPeriodic()){ // Periodic conditions in V . if (j > _gridV ){ break; } else if (j < 0){ j++; - if (j<0){ - MESSAGE("j = "<D1(_vectU[ip],_vectV[jp],P,D1U,D1V); // Calculate the metric at (i,j) - Guu = D1U.X()*D1U.X() + D1U.Y()*D1U.Y() + D1U.Z()*D1U.Z(); // Guu = ||dS/du||**2 G(i,j)= | ||dS/du||**2 * | - Gvv = D1V.X()*D1V.X() + D1V.Y()*D1V.Y() + D1V.Z()*D1V.Z(); // Gvv = ||dS/dv||**2 | ||dS/dv||**2 | + + if (!_known[ip][jp]){ // If the distance is not known yet + aSurf->D1(_vectU[ip],_vectV[jp],P,D1U,D1V); // Calculate the metric at (i,j) + // G(i,j) = | ||dS/du||**2 * | + // | ||dS/dv||**2 | + Guu = D1U.X()*D1U.X() + D1U.Y()*D1U.Y() + D1U.Z()*D1U.Z(); // Guu = ||dS/du||**2 + Gvv = D1V.X()*D1V.X() + D1V.Y()*D1V.Y() + D1V.Z()*D1V.Z(); // Gvv = ||dS/dv||**2 Guv = D1U.X()*D1V.X() + D1U.Y()*D1V.Y() + D1U.Z()*D1V.Z(); // Guv = Gvu = < dS/du,dS/dv > - //Guv = 0; // test - if (Guv > 1e-15){ - MESSAGE("WARNING : Guv != 0 ; Guv = "<IsUPeriodic()){ // Periodic conditions in U + if (!aSurf->IsUPeriodic()){ // Periodic conditions in U if(k > _gridU ){ - MESSAGE("Break"); break; } else if (k < 0){ k++; } } - kp = (k + _gridU + 1) % (_gridU+1); // periodic index - //MESSAGE(" k = "<IsVPeriodic()){ // Periodic conditions in V - if(n > _gridV){ - MESSAGE("Break"); + if (!aSurf->IsVPeriodic()){ // Periodic conditions in V + if(n > _gridV){ break; } else if (n < 0){ n++; } } - np = (n + _gridV + 1) % (_gridV+1); - //MESSAGE(" n = "< update ref. distance D_Ref = Dist; Dist_changed = true; - if (count == 2500) { - MESSAGE("du = "<(ip); - TPnt[2] = jp;//.Tj = jp;//[2] = static_cast(jp); - _DMap[ip][jp] = D_Ref; - //MESSAGE("TPnt[0] = "< result = _trial.insert(TPnt); -// if (result.second) { -// MESSAGE("Pnt : "<Empty()) + // MESSAGE("List of attractor is not empty") + // MESSAGE("Attractor empty : "<< FaceIndex2ClassAttractor[face_id]->Empty()) double result = FaceIndex2ClassAttractor[face_id]->GetSize(uv[0],uv[1]); *size = result; - MESSAGE("f(" << uv[0] << "," << uv[1] << ")" << " = " << result); + // MESSAGE("f(" << uv[0] << "," << uv[1] << ")" << " = " << result); } else { - MESSAGE("List of attractor is empty !!!") + // MESSAGE("List of attractor is empty !!!") *size = *((double*)user_data); } return STATUS_OK; diff --git a/src/BLSURFPlugin/BLSURFPlugin_Hypothesis.cxx b/src/BLSURFPlugin/BLSURFPlugin_Hypothesis.cxx index e1775c9..6f0dec0 100644 --- a/src/BLSURFPlugin/BLSURFPlugin_Hypothesis.cxx +++ b/src/BLSURFPlugin/BLSURFPlugin_Hypothesis.cxx @@ -451,7 +451,7 @@ void BLSURFPlugin_Hypothesis::SetClassAttractorEntry(const std::string& entry, if ( !attExists || (attExists && !_classAttractors[entry]->GetAttractorShape().IsSame(AttractorShape))){ ShapeAnalysis::GetFaceUVBounds(FaceShape,u1,u2,v1,v2); diag = sqrt((u2 - u1) * (u2 - u1) + (v2 - v1) * (v2 - v1)); - BLSURFPlugin_Attractor* myAttractor = new BLSURFPlugin_Attractor(FaceShape, AttractorShape, 0.005 * diag); //TODO calculer MapGrid + BLSURFPlugin_Attractor* myAttractor = new BLSURFPlugin_Attractor(FaceShape, AttractorShape, 0.002 * diag); //TODO calculer MapGrid myAttractor->BuildMap(); //MESSAGE("Step = "<SetParameters(StartSize, EndSize, ActionRadius, ConstantRadius); diff --git a/src/BLSURFPlugin/BLSURFPlugin_Hypothesis_i.cxx b/src/BLSURFPlugin/BLSURFPlugin_Hypothesis_i.cxx index 4e5a339..c4fca27 100644 --- a/src/BLSURFPlugin/BLSURFPlugin_Hypothesis_i.cxx +++ b/src/BLSURFPlugin/BLSURFPlugin_Hypothesis_i.cxx @@ -811,7 +811,7 @@ void BLSURFPlugin_Hypothesis_i::UnsetAttractor(GEOM::GEOM_Object_ptr GeomObj) } -void BLSURFPlugin_Hypothesis_i::SetAttractor_Geom(GEOM::GEOM_Object_ptr GeomObj, GEOM::GEOM_Object_ptr Attractor, double StartSize, double EndSize, double ActionRadius, double ConstantRadius) +void BLSURFPlugin_Hypothesis_i::SetAttractorGeom(GEOM::GEOM_Object_ptr GeomObj, GEOM::GEOM_Object_ptr Attractor, double StartSize, double EndSize, double ActionRadius, double ConstantRadius) { ASSERT(myBaseImpl); string entry; @@ -825,7 +825,7 @@ void BLSURFPlugin_Hypothesis_i::SetAttractor_Geom(GEOM::GEOM_Object_ptr GeomObj, SetClassAttractorEntry( entry.c_str(), FaceShape, AttractorShape, StartSize, EndSize, ActionRadius, ConstantRadius); } -void BLSURFPlugin_Hypothesis_i::UnsetAttractor_Geom(GEOM::GEOM_Object_ptr GeomObj) +void BLSURFPlugin_Hypothesis_i::UnsetAttractorGeom(GEOM::GEOM_Object_ptr GeomObj) { ASSERT(myBaseImpl); string entry; diff --git a/src/BLSURFPlugin/BLSURFPlugin_Hypothesis_i.hxx b/src/BLSURFPlugin/BLSURFPlugin_Hypothesis_i.hxx index 8c9e2a6..d3bce63 100644 --- a/src/BLSURFPlugin/BLSURFPlugin_Hypothesis_i.hxx +++ b/src/BLSURFPlugin/BLSURFPlugin_Hypothesis_i.hxx @@ -129,9 +129,9 @@ class BLSURFPlugin_Hypothesis_i: BLSURFPlugin::string_array* GetAttractorEntries(); - void SetAttractor_Geom(GEOM::GEOM_Object_ptr GeomObj, GEOM::GEOM_Object_ptr Attractor, double StartSize, double EndSize, double ActionRadius, double ConstantRadius ); + void SetAttractorGeom(GEOM::GEOM_Object_ptr GeomObj, GEOM::GEOM_Object_ptr Attractor, double StartSize, double EndSize, double ActionRadius, double ConstantRadius ); - void UnsetAttractor_Geom(GEOM::GEOM_Object_ptr GeomObj); + void UnsetAttractorGeom(GEOM::GEOM_Object_ptr GeomObj); void SetClassAttractorEntry(const char* entry,const TopoDS_Face& FaceShape, const TopoDS_Shape& AttractorShape, double StartSize, double EndSize, double ActionRadius, double ConstantRadius) throw (SALOME::SALOME_Exception); diff --git a/src/GUI/BLSURFPluginGUI_HypothesisCreator.cxx b/src/GUI/BLSURFPluginGUI_HypothesisCreator.cxx index da754af..824d2ac 100644 --- a/src/GUI/BLSURFPluginGUI_HypothesisCreator.cxx +++ b/src/GUI/BLSURFPluginGUI_HypothesisCreator.cxx @@ -1653,7 +1653,7 @@ bool BLSURFPluginGUI_HypothesisCreator::storeParamsToHypo( const BlsurfHypothesi } else if (sizeMap.startsWith("ATTRACTOR")) { // MESSAGE("SetAttractorEntry(" << entry.toStdString() << ")= " << sizeMap.toStdString()); - h->SetAttractorEntry( entry.toLatin1().constData(), sizeMap.toLatin1().constData() ); + h->SetAttractorEntry( entry.toLatin1().constData(), sizeMap.toLatin1().constData()); } else if (sizeMap.startsWith("def")) { // MESSAGE("SetCustomSizeMapEntry(" << entry.toStdString() << ")= " << sizeMap.toStdString()); -- 2.39.2