1 // Copyright (C) 2007-2023 CEA, EDF
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // Lesser General Public License for more details.
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 // File : BLSURFPlugin_Hypothesis.cxx
22 // Authors : Francis KLOSS (OCC) & Patrick LAUG (INRIA) & Lioka RAZAFINDRAZAKA (CEA)
23 // Size maps developement: Nicolas GEIMER (OCC) & Gilles DAVID (EURIWARE)
26 #include "BLSURFPlugin_Hypothesis_i.hxx"
27 #include "BLSURFPlugin_BLSURF.hxx"
29 #include <SMESH_Gen.hxx>
30 #include <SMESH_Gen_i.hxx>
31 #include <SMESH_Group_i.hxx>
32 #include <SMESH_PythonDump.hxx>
34 #include <SALOMEDS_wrap.hxx>
35 #include <Utils_CorbaException.hxx>
36 #include <utilities.h>
40 #include <boost/regex.hpp>
46 //================================================================================
48 * \brief Return persistent ID of a mesh
49 * \param [in] mesh - the mesh
50 * \return int - -1 in case of failure
52 //================================================================================
54 int GetMeshPersistentId( SMESH::SMESH_Mesh_ptr mesh )
57 if ( SMESH_Mesh_i* mesh_i = SMESH::DownCast<SMESH_Mesh_i*>( mesh ))
58 id = mesh_i->GetImpl().GetMeshDS()->GetPersistentId();
62 //================================================================================
64 * \brief Return persistent ID of a group or sub-mesh
65 * \param [in] meshPart - the mesh part
66 * \param [out] isGroup - return true if meshPart is a group
67 * \return int - -1 in case if meshPart is neither a group nor a sub-mesh
69 //================================================================================
71 int GetMeshPartPersistentId( SMESH::SMESH_IDSource_ptr meshPart, bool & isGroup )
75 SMESH_GroupBase_i* group_i = SMESH::DownCast<SMESH_GroupBase_i*>( meshPart );
78 id = group_i->GetLocalID();
83 SMESH::SMESH_subMesh_var subMesh = SMESH::SMESH_subMesh::_narrow( meshPart );
84 if ( !subMesh->_is_nil() )
85 id = subMesh->GetId();
90 //================================================================================
92 * \brief Find a mesh in the study by mesh persistent ID
94 //================================================================================
96 SMESH::SMESH_Mesh_ptr FindMeshByID( int theMeshID )
98 SMESH::SMESH_Mesh_var mesh;
100 SMESH_Gen_i* gen = SMESH_Gen_i::GetSMESHGen();
101 CORBA::String_var compDataType = gen->ComponentDataType();
102 SALOMEDS::Study_var aStudy = gen->getStudyServant();
103 SALOMEDS::SComponent_wrap genSO = aStudy->FindComponent( compDataType.in() );
104 if ( !genSO->_is_nil() )
106 SALOMEDS::ChildIterator_wrap anIter = aStudy->NewChildIterator( genSO );
107 for ( ; anIter->More(); anIter->Next() )
109 SALOMEDS::SObject_wrap so = anIter->Value();
110 CORBA::Object_var obj = gen->SObjectToObject( so );
111 mesh = SMESH::SMESH_Mesh::_narrow( obj );
112 if ( !mesh->_is_nil() && GetMeshPersistentId( mesh ) == theMeshID )
114 mesh = SMESH::SMESH_Mesh::_nil();
120 //================================================================================
122 * \brief Return a group by its ID
124 //================================================================================
126 SMESH::SMESH_GroupBase_ptr GetGroupByID( SMESH::SMESH_Mesh_ptr mesh, int ID )
128 SMESH::SMESH_GroupBase_var group;
129 if ( !CORBA::is_nil( mesh ))
131 SMESH::ListOfGroups_var groups = mesh->GetGroups();
132 for ( CORBA::ULong i = 0; i < groups->length(); ++i )
133 if ( SMESH_GroupBase_i* group_i = SMESH::DownCast<SMESH_GroupBase_i*>( groups[i] ))
134 if ( group_i->GetLocalID() == ID )
136 group = SMESH::SMESH_GroupBase::_narrow( groups[i] );
140 return group._retn();
143 //================================================================================
145 * \brief Return a sub-mesh by sub-shape ID
147 //================================================================================
149 SMESH::SMESH_subMesh_ptr GetSubMeshByID( SMESH::SMESH_Mesh_ptr mesh,
151 CORBA::Long subMeshTag )
153 SMESH::SMESH_subMesh_var subMesh;
154 if ( !CORBA::is_nil( mesh ))
156 SMESH_Gen_i* gen = SMESH_Gen_i::GetSMESHGen();
157 SALOMEDS::SObject_wrap meshSO = gen->ObjectToSObject( mesh );
158 SALOMEDS::Study_var aStudy = gen->getStudyServant();
159 SALOMEDS::SObject_wrap subMeshRootSO;
160 if ( !meshSO->_is_nil() && meshSO->FindSubObject( subMeshTag, subMeshRootSO.inout() ))
162 SALOMEDS::ChildIterator_wrap anIter = aStudy->NewChildIterator( subMeshRootSO );
163 for ( ; anIter->More(); anIter->Next() )
165 SALOMEDS::SObject_wrap so = anIter->Value();
166 CORBA::Object_var obj = gen->SObjectToObject( so );
167 subMesh = SMESH::SMESH_subMesh::_narrow( obj );
168 if ( !subMesh->_is_nil() && subMesh->GetId() == shapeID )
170 subMesh = SMESH::SMESH_subMesh::_nil();
173 return subMesh._retn();
175 return subMesh._retn();
180 //=============================================================================
182 * BLSURFPlugin_Hypothesis_i::BLSURFPlugin_Hypothesis_i
186 //=============================================================================
187 BLSURFPlugin_Hypothesis_i::BLSURFPlugin_Hypothesis_i(PortableServer::POA_ptr thePOA,
188 ::SMESH_Gen* theGenImpl,
190 SALOME::GenericObj_i(thePOA), SMESH_Hypothesis_i(thePOA)
192 myBaseImpl = new ::BLSURFPlugin_Hypothesis(theGenImpl->GetANewId(),
198 //=============================================================================
200 * BLSURFPlugin_Hypothesis_i::~BLSURFPlugin_Hypothesis_i
204 //=============================================================================
205 BLSURFPlugin_Hypothesis_i::~BLSURFPlugin_Hypothesis_i()
209 //=============================================================================
211 * BLSURFPlugin_Hypothesis_i::GetMeshGemsVersion
213 * Get version of MeshGems suite.
215 //=============================================================================
216 char* BLSURFPlugin_Hypothesis_i::GetMeshGemsVersion()
218 return CORBA::string_dup( this->GetImpl()->GetMeshGemsVersion().c_str() );
221 //=============================================================================
223 * BLSURFPlugin_Hypothesis_i::SetPhysicalMesh
227 //=============================================================================
228 void BLSURFPlugin_Hypothesis_i::SetPhysicalMesh(CORBA::Long theValue)
231 this->GetImpl()->SetPhysicalMesh((::BLSURFPlugin_Hypothesis::PhysicalMesh) theValue);
232 SMESH::TPythonDump() << _this() << ".SetPhysicalMesh( " << theValue << " )";
235 //=============================================================================
237 * BLSURFPlugin_Hypothesis_i::GetPhysicalMesh
241 //=============================================================================
242 CORBA::Long BLSURFPlugin_Hypothesis_i::GetPhysicalMesh()
245 return this->GetImpl()->GetPhysicalMesh();
248 //=============================================================================
250 * BLSURFPlugin_Hypothesis_i::SetGeometricMesh
255 //=============================================================================
256 void BLSURFPlugin_Hypothesis_i::SetGeometricMesh(CORBA::Long theValue)
259 this->GetImpl()->SetGeometricMesh((::BLSURFPlugin_Hypothesis::GeometricMesh) theValue);
260 SMESH::TPythonDump() << _this() << ".SetGeometricMesh( " << theValue << " )";
263 //=============================================================================
265 * BLSURFPlugin_Hypothesis_i::GetGeometricMesh
269 //=============================================================================
270 CORBA::Long BLSURFPlugin_Hypothesis_i::GetGeometricMesh()
273 return this->GetImpl()->GetGeometricMesh();
276 //=============================================================================
278 * BLSURFPlugin_Hypothesis_i::SetPhySize
282 //=============================================================================
283 void BLSURFPlugin_Hypothesis_i::SetPhySize(CORBA::Double theValue)
286 this->GetImpl()->SetPhySize(theValue, false);
287 SMESH::TPythonDump() << _this() << ".SetPhySize( " << theValue << " )";
290 //=============================================================================
292 * BLSURFPlugin_Hypothesis_i::SetPhySizeRel
294 * Set Relative PhySize
296 //=============================================================================
297 void BLSURFPlugin_Hypothesis_i::SetPhySizeRel(CORBA::Double theValue)
300 this->GetImpl()->SetPhySize(theValue, true);
301 SMESH::TPythonDump() << _this() << ".SetPhySizeRel( " << theValue << " )";
304 //=============================================================================
306 * BLSURFPlugin_Hypothesis_i::GetPhySize
310 //=============================================================================
311 CORBA::Double BLSURFPlugin_Hypothesis_i::GetPhySize()
314 return this->GetImpl()->GetPhySize();
317 //=============================================================================
319 * BLSURFPlugin_Hypothesis_i::IsPhySizeRel
321 * Returns True if PhySize is relative
323 //=============================================================================
324 CORBA::Boolean BLSURFPlugin_Hypothesis_i::IsPhySizeRel()
327 return this->GetImpl()->IsPhySizeRel();
330 //=============================================================================
331 void BLSURFPlugin_Hypothesis_i::SetMinSize(CORBA::Double theMinSize)
333 if (IsMinSizeRel() || GetMinSize() != theMinSize ) {
334 this->GetImpl()->SetMinSize(theMinSize, false);
335 SMESH::TPythonDump() << _this() << ".SetMinSize( " << theMinSize << " )";
339 //=============================================================================
340 void BLSURFPlugin_Hypothesis_i::SetMinSizeRel(CORBA::Double theMinSize)
342 if ( !IsMinSizeRel() || (GetMinSize() != theMinSize) ) {
343 this->GetImpl()->SetMinSize(theMinSize, true);
344 SMESH::TPythonDump() << _this() << ".SetMinSizeRel( " << theMinSize << " )";
348 //=============================================================================
349 CORBA::Double BLSURFPlugin_Hypothesis_i::GetMinSize()
351 return this->GetImpl()->GetMinSize();
354 //=============================================================================
355 CORBA::Boolean BLSURFPlugin_Hypothesis_i::IsMinSizeRel()
357 return this->GetImpl()->IsMinSizeRel();
360 //=============================================================================
361 void BLSURFPlugin_Hypothesis_i::SetMaxSize(CORBA::Double theMaxSize)
363 if (IsMaxSizeRel() || GetMaxSize() != theMaxSize) {
364 this->GetImpl()->SetMaxSize(theMaxSize, false);
365 SMESH::TPythonDump() << _this() << ".SetMaxSize( " << theMaxSize << " )";
369 //=============================================================================
370 void BLSURFPlugin_Hypothesis_i::SetMaxSizeRel(CORBA::Double theMaxSize)
372 if ( !IsMaxSizeRel() || (GetMaxSize() != theMaxSize) ) {
373 this->GetImpl()->SetMaxSize(theMaxSize, true);
374 SMESH::TPythonDump() << _this() << ".SetMaxSizeRel( " << theMaxSize << " )";
378 //=============================================================================
379 CORBA::Double BLSURFPlugin_Hypothesis_i::GetMaxSize()
381 return this->GetImpl()->GetMaxSize();
384 //=============================================================================
385 CORBA::Boolean BLSURFPlugin_Hypothesis_i::IsMaxSizeRel()
387 return this->GetImpl()->IsMaxSizeRel();
391 //=============================================================================
393 * BLSURFPlugin_Hypothesis_i::SetUseGradation
397 //=============================================================================
398 void BLSURFPlugin_Hypothesis_i::SetUseGradation(CORBA::Boolean theValue)
400 if ( GetImpl()->GetUseGradation() != bool( theValue ))
402 this->GetImpl()->SetUseGradation(theValue);
403 std::string theValueStr = theValue ? "True" : "False";
404 SMESH::TPythonDump() << _this() << ".SetUseGradation( " << theValueStr.c_str() << " )";
408 //=============================================================================
410 * BLSURFPlugin_Hypothesis_i::GetUseGradation
414 //=============================================================================
415 CORBA::Boolean BLSURFPlugin_Hypothesis_i::GetUseGradation()
417 return this->GetImpl()->GetUseGradation();
420 //=============================================================================
422 * BLSURFPlugin_Hypothesis_i::SetGradation
426 //=============================================================================
427 void BLSURFPlugin_Hypothesis_i::SetGradation(CORBA::Double theValue)
429 this->GetImpl()->SetGradation(theValue);
432 SetUseGradation( false );
434 SMESH::TPythonDump() << _this() << ".SetGradation( " << theValue << " )";
437 //=============================================================================
439 * BLSURFPlugin_Hypothesis_i::GetGradation
443 //=============================================================================
444 CORBA::Double BLSURFPlugin_Hypothesis_i::GetGradation()
446 return this->GetImpl()->GetGradation();
449 //=============================================================================
451 * BLSURFPlugin_Hypothesis_i::SetUseVolumeGradation
455 //=============================================================================
456 void BLSURFPlugin_Hypothesis_i::SetUseVolumeGradation(CORBA::Boolean theValue)
458 if ( GetImpl()->GetUseVolumeGradation() != bool( theValue ))
460 this->GetImpl()->SetUseVolumeGradation(theValue);
461 std::string theValueStr = theValue ? "True" : "False";
462 SMESH::TPythonDump() << _this() << ".SetUseVolumeGradation( " << theValueStr.c_str() << " )";
466 //=============================================================================
468 * BLSURFPlugin_Hypothesis_i::GetUseVolumeGradation
472 //=============================================================================
473 CORBA::Boolean BLSURFPlugin_Hypothesis_i::GetUseVolumeGradation()
475 return this->GetImpl()->GetUseVolumeGradation();
478 //=============================================================================
480 * BLSURFPlugin_Hypothesis_i::SetVolumeGradation
482 * Set VolumeGradation
484 //=============================================================================
485 void BLSURFPlugin_Hypothesis_i::SetVolumeGradation(CORBA::Double theValue)
487 this->GetImpl()->SetVolumeGradation(theValue);
489 SetUseVolumeGradation( false );
491 SMESH::TPythonDump() << _this() << ".SetVolumeGradation( " << theValue << " )";
494 //=============================================================================
496 * BLSURFPlugin_Hypothesis_i::GetVolumeGradation
498 * Get VolumeGradation
500 //=============================================================================
501 CORBA::Double BLSURFPlugin_Hypothesis_i::GetVolumeGradation()
503 return this->GetImpl()->GetVolumeGradation();
506 //=============================================================================
508 * BLSURFPlugin_Hypothesis_i::SetQuadAllowed
512 * DEPRACATED, kept for python script compatibility
514 * TO be removed in Salome 9
516 //=============================================================================
517 void BLSURFPlugin_Hypothesis_i::SetQuadAllowed(CORBA::Boolean theValue)
519 ::BLSURFPlugin_Hypothesis::ElementType theElementType = theValue ?
520 ::BLSURFPlugin_Hypothesis::QuadrangleDominant : ::BLSURFPlugin_Hypothesis::Triangles;
521 this->GetImpl()->SetElementType(theElementType);
522 SMESH::TPythonDump() << _this() << ".SetElementType( " << theElementType << " )";
525 //=============================================================================
527 * BLSURFPlugin_Hypothesis_i::SetElementType
531 //=============================================================================
532 void BLSURFPlugin_Hypothesis_i::SetElementType(CORBA::Long theValue)
534 this->GetImpl()->SetElementType((::BLSURFPlugin_Hypothesis::ElementType) theValue);
535 SMESH::TPythonDump() << _this() << ".SetElementType( " << theValue << " )";
537 //=============================================================================
539 * BLSURFPlugin_Hypothesis_i::GetElementType
543 //=============================================================================
544 CORBA::Long BLSURFPlugin_Hypothesis_i::GetElementType()
546 return this->GetImpl()->GetElementType();
549 //=============================================================================
551 * BLSURFPlugin_Hypothesis_i::SetAngleMesh
555 //=============================================================================
556 void BLSURFPlugin_Hypothesis_i::SetAngleMesh(CORBA::Double theValue)
558 this->GetImpl()->SetAngleMesh(theValue);
559 SMESH::TPythonDump() << _this() << ".SetAngleMesh( " << theValue << " )";
562 //=============================================================================
564 * BLSURFPlugin_Hypothesis_i::GetAngleMesh
568 //=============================================================================
569 CORBA::Double BLSURFPlugin_Hypothesis_i::GetAngleMesh()
571 return this->GetImpl()->GetAngleMesh();
574 //=============================================================================
576 * BLSURFPlugin_Hypothesis_i::SetChordalError
580 //=============================================================================
581 void BLSURFPlugin_Hypothesis_i::SetChordalError(CORBA::Double theValue)
583 this->GetImpl()->SetChordalError(theValue);
584 SMESH::TPythonDump() << _this() << ".SetChordalError( " << theValue << " )";
587 //=============================================================================
589 * BLSURFPlugin_Hypothesis_i::GetChordalError
593 //=============================================================================
594 CORBA::Double BLSURFPlugin_Hypothesis_i::GetChordalError()
596 return this->GetImpl()->GetChordalError();
599 //=============================================================================
601 * BLSURFPlugin_Hypothesis_i::SetAnisotropic
605 //=============================================================================
606 void BLSURFPlugin_Hypothesis_i::SetAnisotropic(CORBA::Boolean theValue)
608 this->GetImpl()->SetAnisotropic(theValue);
609 std::string theValueStr = theValue ? "True" : "False";
610 SMESH::TPythonDump() << _this() << ".SetAnisotropic( " << theValueStr.c_str() << " )";
613 //=============================================================================
615 * BLSURFPlugin_Hypothesis_i::GetAnisotropic
619 //=============================================================================
620 CORBA::Boolean BLSURFPlugin_Hypothesis_i::GetAnisotropic()
622 return this->GetImpl()->GetAnisotropic();
625 //=============================================================================
627 * BLSURFPlugin_Hypothesis_i::SetAnisotropicRatio
629 * Set Anisotropic Ratio
631 //=============================================================================
632 void BLSURFPlugin_Hypothesis_i::SetAnisotropicRatio(CORBA::Double theValue)
634 this->GetImpl()->SetAnisotropicRatio(theValue);
635 SMESH::TPythonDump() << _this() << ".SetAnisotropicRatio( " << theValue << " )";
638 //=============================================================================
640 * BLSURFPlugin_Hypothesis_i::GetAnisotropicRatio
642 * Get Anisotropic Ratio
644 //=============================================================================
645 CORBA::Double BLSURFPlugin_Hypothesis_i::GetAnisotropicRatio()
647 return this->GetImpl()->GetAnisotropicRatio();
651 //=============================================================================
653 * BLSURFPlugin_Hypothesis_i::SetRemoveTinyEdges
657 //=============================================================================
658 void BLSURFPlugin_Hypothesis_i::SetRemoveTinyEdges(CORBA::Boolean theValue) {
660 this->GetImpl()->SetRemoveTinyEdges(theValue);
661 std::string theValueStr = theValue ? "True" : "False";
662 SMESH::TPythonDump() << _this() << ".SetRemoveTinyEdges( " << theValueStr.c_str() << " )";
665 //=============================================================================
667 * BLSURFPlugin_Hypothesis_i::GetRemoveTinyEdges
671 //=============================================================================
672 CORBA::Boolean BLSURFPlugin_Hypothesis_i::GetRemoveTinyEdges() {
674 return this->GetImpl()->GetRemoveTinyEdges();
677 //=============================================================================
679 * BLSURFPlugin_Hypothesis_i::SetTinyEdgeLength
681 * Set Tiny Edge Length
683 //=============================================================================
684 void BLSURFPlugin_Hypothesis_i::SetTinyEdgeLength(CORBA::Double theValue) {
686 this->GetImpl()->SetTinyEdgeLength(theValue);
687 SMESH::TPythonDump() << _this() << ".SetTinyEdgeLength( " << theValue << " )";
690 //=============================================================================
692 * BLSURFPlugin_Hypothesis_i::GetTinyEdgeLength
694 * Get Tiny Edge Length
696 //=============================================================================
697 CORBA::Double BLSURFPlugin_Hypothesis_i::GetTinyEdgeLength() {
699 return this->GetImpl()->GetTinyEdgeLength();
702 //=============================================================================
704 * BLSURFPlugin_Hypothesis_i::SetOptimiseTinyEdges
708 //=============================================================================
709 void BLSURFPlugin_Hypothesis_i::SetOptimiseTinyEdges(CORBA::Boolean theValue) {
711 this->GetImpl()->SetOptimiseTinyEdges(theValue);
712 std::string theValueStr = theValue ? "True" : "False";
713 SMESH::TPythonDump() << _this() << ".SetOptimiseTinyEdges( " << theValueStr.c_str() << " )";
716 //=============================================================================
718 * BLSURFPlugin_Hypothesis_i::GetOptimiseTinyEdges
722 //=============================================================================
723 CORBA::Boolean BLSURFPlugin_Hypothesis_i::GetOptimiseTinyEdges() {
725 return this->GetImpl()->GetOptimiseTinyEdges();
728 //=============================================================================
730 * BLSURFPlugin_Hypothesis_i::SetTinyEdgeOptimisationLength
732 * Set Tiny Edge OptimisationLength
734 //=============================================================================
735 void BLSURFPlugin_Hypothesis_i::SetTinyEdgeOptimisationLength(CORBA::Double theValue) {
737 this->GetImpl()->SetTinyEdgeOptimisationLength(theValue);
738 SMESH::TPythonDump() << _this() << ".SetTinyEdgeOptimisationLength( " << theValue << " )";
741 //=============================================================================
743 * BLSURFPlugin_Hypothesis_i::GetTinyEdgeOptimisationLength
745 * Get Tiny Edge OptimisationLength
747 //=============================================================================
748 CORBA::Double BLSURFPlugin_Hypothesis_i::GetTinyEdgeOptimisationLength() {
750 return this->GetImpl()->GetTinyEdgeOptimisationLength();
753 //=============================================================================
755 * BLSURFPlugin_Hypothesis_i::SetCorrectSurfaceIntersection
759 //=============================================================================
760 void BLSURFPlugin_Hypothesis_i::SetCorrectSurfaceIntersection(CORBA::Boolean theValue) {
762 this->GetImpl()->SetCorrectSurfaceIntersection(theValue);
763 std::string theValueStr = theValue ? "True" : "False";
764 SMESH::TPythonDump() << _this() << ".SetCorrectSurfaceIntersection( " << theValueStr.c_str() << " )";
767 //=============================================================================
769 * BLSURFPlugin_Hypothesis_i::GetCorrectSurfaceIntersection
773 //=============================================================================
774 CORBA::Boolean BLSURFPlugin_Hypothesis_i::GetCorrectSurfaceIntersection() {
776 return this->GetImpl()->GetCorrectSurfaceIntersection();
779 //=============================================================================
781 * BLSURFPlugin_Hypothesis_i::SetCorrectSurfaceIntersectionMaxCost
783 * Set Tiny Edge OptimisationLength
785 //=============================================================================
786 void BLSURFPlugin_Hypothesis_i::SetCorrectSurfaceIntersectionMaxCost(CORBA::Double theValue) {
788 this->GetImpl()->SetCorrectSurfaceIntersectionMaxCost(theValue);
789 SMESH::TPythonDump() << _this() << ".SetCorrectSurfaceIntersectionMaxCost( " << theValue << " )";
792 //=============================================================================
794 * BLSURFPlugin_Hypothesis_i::GetCorrectSurfaceIntersectionMaxCost
796 * Get Tiny Edge OptimisationLength
798 //=============================================================================
799 CORBA::Double BLSURFPlugin_Hypothesis_i::GetCorrectSurfaceIntersectionMaxCost() {
801 return this->GetImpl()->GetCorrectSurfaceIntersectionMaxCost();
804 //=============================================================================
806 * BLSURFPlugin_Hypothesis_i::SetBadElementRemoval
810 //=============================================================================
811 void BLSURFPlugin_Hypothesis_i::SetBadElementRemoval(CORBA::Boolean theValue) {
813 this->GetImpl()->SetBadElementRemoval(theValue);
814 std::string theValueStr = theValue ? "True" : "False";
815 SMESH::TPythonDump() << _this() << ".SetBadElementRemoval( " << theValueStr.c_str() << " )";
818 //=============================================================================
820 * BLSURFPlugin_Hypothesis_i::GetBadElementRemoval
824 //=============================================================================
825 CORBA::Boolean BLSURFPlugin_Hypothesis_i::GetBadElementRemoval() {
827 return this->GetImpl()->GetBadElementRemoval();
830 //=============================================================================
832 * BLSURFPlugin_Hypothesis_i::SetBadElementAspectRatio
834 * Set Bad Surface Element Aspect Ratio
836 //=============================================================================
837 void BLSURFPlugin_Hypothesis_i::SetBadElementAspectRatio(CORBA::Double theValue) {
839 this->GetImpl()->SetBadElementAspectRatio(theValue);
840 SMESH::TPythonDump() << _this() << ".SetBadElementAspectRatio( " << theValue << " )";
843 //=============================================================================
845 * BLSURFPlugin_Hypothesis_i::GetBadElementAspectRatio
847 * Get Bad Surface Element Aspect Ratio
849 //=============================================================================
850 CORBA::Double BLSURFPlugin_Hypothesis_i::GetBadElementAspectRatio() {
852 return this->GetImpl()->GetBadElementAspectRatio();
855 //=============================================================================
857 * BLSURFPlugin_Hypothesis_i::SetOptimizeMesh
861 //=============================================================================
862 void BLSURFPlugin_Hypothesis_i::SetOptimizeMesh(CORBA::Boolean theValue) {
864 this->GetImpl()->SetOptimizeMesh(theValue);
865 std::string theValueStr = theValue ? "True" : "False";
866 SMESH::TPythonDump() << _this() << ".SetOptimizeMesh( " << theValueStr.c_str() << " )";
869 //=============================================================================
871 * BLSURFPlugin_Hypothesis_i::GetOptimizeMesh
875 //=============================================================================
876 CORBA::Boolean BLSURFPlugin_Hypothesis_i::GetOptimizeMesh() {
878 return this->GetImpl()->GetOptimizeMesh();
881 //=============================================================================
883 * BLSURFPlugin_Hypothesis_i::SetQuadraticMesh
887 //=============================================================================
888 void BLSURFPlugin_Hypothesis_i::SetQuadraticMesh(CORBA::Boolean theValue) {
890 this->GetImpl()->SetQuadraticMesh(theValue);
891 std::string theValueStr = theValue ? "True" : "False";
892 SMESH::TPythonDump() << _this() << ".SetQuadraticMesh( " << theValueStr.c_str() << " )";
895 //=============================================================================
897 * BLSURFPlugin_Hypothesis_i::GetQuadraticMesh
901 //=============================================================================
902 CORBA::Boolean BLSURFPlugin_Hypothesis_i::GetQuadraticMesh() {
904 return this->GetImpl()->GetQuadraticMesh();
912 * BLSURFPlugin_Hypothesis_i::SetTopology
917 //=============================================================================
918 void BLSURFPlugin_Hypothesis_i::SetTopology(CORBA::Long theValue) {
920 this->GetImpl()->SetTopology((::BLSURFPlugin_Hypothesis::Topology) theValue);
921 SMESH::TPythonDump() << _this() << ".SetTopology( " << theValue << " )";
924 //=============================================================================
926 * BLSURFPlugin_Hypothesis_i::GetTopology
930 //=============================================================================
931 CORBA::Long BLSURFPlugin_Hypothesis_i::GetTopology() {
933 return this->GetImpl()->GetTopology();
936 //=============================================================================
938 * Activate/deactivate surface proximity computation
940 void BLSURFPlugin_Hypothesis_i::SetSurfaceProximity( CORBA::Boolean toUse )
942 if ( GetSurfaceProximity() != toUse )
944 this->GetImpl()->SetUseSurfaceProximity( toUse );
945 SMESH::TPythonDump() << _this() << ".SetSurfaceProximity( " << toUse << " )";
949 CORBA::Boolean BLSURFPlugin_Hypothesis_i::GetSurfaceProximity()
951 return this->GetImpl()->GetUseSurfaceProximity();
954 //=============================================================================
956 * Set number of surface element layers to be generated due to surface proximity
958 void BLSURFPlugin_Hypothesis_i::SetNbSurfaceProximityLayers( CORBA::Short nbLayers )
960 if ( GetNbSurfaceProximityLayers() != nbLayers )
962 this->GetImpl()->SetNbSurfaceProximityLayers( nbLayers );
963 SMESH::TPythonDump() << _this() << ".SetNbSurfaceProximityLayers( " << nbLayers << " )";
967 CORBA::Short BLSURFPlugin_Hypothesis_i::GetNbSurfaceProximityLayers()
969 return (CORBA::Short) this->GetImpl()->GetNbSurfaceProximityLayers();
972 //=============================================================================
974 * Set coefficient by which size of element refined due to surface proximity is increased
976 void BLSURFPlugin_Hypothesis_i::SetSurfaceProximityRatio( CORBA::Double ratio )
978 if ( GetSurfaceProximityRatio() != ratio )
980 this->GetImpl()->SetSurfaceProximityRatio( ratio );
981 SMESH::TPythonDump() << _this() << ".SetSurfaceProximityRatio( " << ratio << " )";
985 CORBA::Double BLSURFPlugin_Hypothesis_i::GetSurfaceProximityRatio()
987 return this->GetImpl()->GetSurfaceProximityRatio();
990 //=============================================================================
992 * Activate/deactivate volume proximity computation
994 void BLSURFPlugin_Hypothesis_i::SetVolumeProximity( CORBA::Boolean toUse )
996 if ( GetVolumeProximity() != toUse )
998 this->GetImpl()->SetUseVolumeProximity( toUse );
999 SMESH::TPythonDump() << _this() << ".SetVolumeProximity( " << toUse << " )";
1003 CORBA::Boolean BLSURFPlugin_Hypothesis_i::GetVolumeProximity()
1005 return this->GetImpl()->GetUseVolumeProximity();
1009 //=============================================================================
1011 * Set number of surface element layers to be generated due to volume proximity
1013 void BLSURFPlugin_Hypothesis_i::SetNbVolumeProximityLayers( CORBA::Short nbLayers )
1015 if ( GetNbVolumeProximityLayers() != nbLayers )
1017 this->GetImpl()->SetNbVolumeProximityLayers( nbLayers );
1018 SMESH::TPythonDump() << _this() << ".SetNbVolumeProximityLayers( " << nbLayers << " )";
1022 CORBA::Short BLSURFPlugin_Hypothesis_i::GetNbVolumeProximityLayers()
1024 return (CORBA::Short) this->GetImpl()->GetNbVolumeProximityLayers();
1027 //=============================================================================
1029 * Set coefficient by which size of element refined due to volume proximity is increased
1031 void BLSURFPlugin_Hypothesis_i::SetVolumeProximityRatio( CORBA::Double ratio )
1033 if ( GetVolumeProximityRatio() != ratio )
1035 this->GetImpl()->SetVolumeProximityRatio( ratio );
1036 SMESH::TPythonDump() << _this() << ".SetVolumeProximityRatio( " << ratio << " )";
1040 CORBA::Double BLSURFPlugin_Hypothesis_i::GetVolumeProximityRatio()
1042 return this->GetImpl()->GetVolumeProximityRatio();
1045 //=============================================================================
1046 void BLSURFPlugin_Hypothesis_i::SetVerbosity(CORBA::Short theVal) {
1048 if (theVal < 0 || theVal > 10)
1049 THROW_SALOME_CORBA_EXCEPTION( "Invalid verbosity level",SALOME::BAD_PARAM );
1050 this->GetImpl()->SetVerbosity(theVal);
1051 SMESH::TPythonDump() << _this() << ".SetVerbosity( " << theVal << " )";
1054 //=============================================================================
1056 CORBA::Short BLSURFPlugin_Hypothesis_i::GetVerbosity() {
1058 return (CORBA::Short) this->GetImpl()->GetVerbosity();
1062 //=============================================================================
1063 void BLSURFPlugin_Hypothesis_i::SetEnforcedMeshes(const BLSURFPlugin::EnforcedMeshesList& theMeshes )
1065 std::vector< ::BLSURFPlugin_Hypothesis::EnforcedMesh > enforcedMeshes;
1066 for ( CORBA::ULong i = 0; i < theMeshes.length(); ++i )
1068 const BLSURFPlugin::MG_EnforcedMesh1D & inEM = theMeshes[ i ];
1069 if ( CORBA::is_nil( inEM.mesh ))
1070 THROW_SALOME_CORBA_EXCEPTION( "NULL enforced mesh",SALOME::BAD_PARAM );
1072 SMESH::SMESH_Mesh_var mesh = inEM.mesh->GetMesh();
1073 if ( CORBA::is_nil( mesh ))
1074 THROW_SALOME_CORBA_EXCEPTION( "BAD enforced mesh",SALOME::BAD_PARAM );
1076 int meshID = GetMeshPersistentId( mesh );
1078 THROW_SALOME_CORBA_EXCEPTION( "BAD enforced mesh",SALOME::BAD_PARAM );
1080 bool isGroup = false;
1081 int partID = GetMeshPartPersistentId( inEM.mesh, isGroup );
1082 ::EnforcedMeshType partType = ENFORCED_MESH;
1084 partType = isGroup ? ENFORCED_GROUP : ENFORCED_SUBMESH;
1086 enforcedMeshes.push_back({ meshID, partID, partType, inEM.groupName.in() });
1089 if ( GetImpl()->GetEnforcedMeshes() == enforcedMeshes )
1092 this->GetImpl()->SetEnforcedMeshes( enforcedMeshes );
1096 SMESH::TPythonDump pyDump;
1097 pyDump << BLSURFPlugin::BLSURFPlugin_Hypothesis_var( _this() )
1098 << ".SetEnforcedMeshes([ ";
1100 for ( CORBA::ULong i = 0; i < theMeshes.length(); ++i )
1102 const BLSURFPlugin::MG_EnforcedMesh1D & inEM = theMeshes[ i ];
1103 pyDump << "BLSURFPlugin.MG_EnforcedMesh1D( " << inEM.mesh.in() << ", ";
1104 if ( inEM.groupName.in() && inEM.groupName.in()[0] )
1105 pyDump << "'" << inEM.groupName.in() << "'";
1108 pyDump << ")" << ( i + 1 < theMeshes.length() ? ", " : "");
1113 //=============================================================================
1115 BLSURFPlugin::EnforcedMeshesList* BLSURFPlugin_Hypothesis_i::GetEnforcedMeshes()
1117 const std::vector< ::BLSURFPlugin_Hypothesis::EnforcedMesh > & hypEnfMeshes =
1118 this->GetImpl()->GetEnforcedMeshes();
1120 BLSURFPlugin::EnforcedMeshesList_var outEnfMeshes = new BLSURFPlugin::EnforcedMeshesList();
1121 outEnfMeshes->length( hypEnfMeshes.size() );
1124 for ( size_t i = 0; i < hypEnfMeshes.size(); ++i )
1126 const ::BLSURFPlugin_Hypothesis::EnforcedMesh& enfMeshData = hypEnfMeshes[ i ];
1127 BLSURFPlugin::MG_EnforcedMesh1D & outEnfMesh = outEnfMeshes[ nbMeshes ];
1129 SMESH::SMESH_Mesh_var mesh = FindMeshByID( enfMeshData._meshID );
1130 switch ( enfMeshData._type ) {
1131 case ENFORCED_MESH :
1133 outEnfMesh.mesh = SMESH::SMESH_IDSource::_narrow( mesh );
1136 case ENFORCED_GROUP :
1138 SMESH::SMESH_GroupBase_var group = GetGroupByID( mesh, enfMeshData._subID );
1139 outEnfMesh.mesh = SMESH::SMESH_IDSource::_narrow( group );
1142 case ENFORCED_SUBMESH:
1144 SMESH::SMESH_subMesh_var subMesh;
1145 subMesh = GetSubMeshByID( mesh, enfMeshData._subID, SMESH::Tag_SubMeshOnEdge );
1146 if ( CORBA::is_nil( subMesh ))
1147 subMesh = GetSubMeshByID( mesh, enfMeshData._subID, SMESH::Tag_SubMeshOnCompound );
1149 outEnfMesh.mesh = SMESH::SMESH_IDSource::_narrow( subMesh );
1154 outEnfMesh.groupName = enfMeshData._groupName.c_str();
1156 nbMeshes += ( !CORBA::is_nil( outEnfMesh.mesh ));
1158 outEnfMeshes->length( nbMeshes );
1160 return outEnfMeshes._retn();
1163 //=============================================================================
1164 void BLSURFPlugin_Hypothesis_i::SetEnforceCadEdgesSize( CORBA::Boolean toEnforce )
1166 if ( GetEnforceCadEdgesSize() != toEnforce )
1168 this->GetImpl()->SetEnforceCadEdgesSize(toEnforce);
1169 SMESH::TPythonDump() << _this() << ".SetEnforceCadEdgesSize( " << toEnforce << " )";
1172 //=============================================================================
1173 CORBA::Boolean BLSURFPlugin_Hypothesis_i::GetEnforceCadEdgesSize()
1175 return this->GetImpl()->GetEnforceCadEdgesSize();
1177 //=============================================================================
1179 void BLSURFPlugin_Hypothesis_i::SetJacobianRectificationRespectGeometry( CORBA::Boolean allowRectification )
1181 if ( GetJacobianRectificationRespectGeometry() != allowRectification )
1183 this->GetImpl()->SetJacobianRectificationRespectGeometry(allowRectification);
1184 SMESH::TPythonDump() << _this() << ".SetJacobianRectificationRespectGeometry( " << allowRectification << " )";
1187 //=============================================================================
1188 CORBA::Boolean BLSURFPlugin_Hypothesis_i::GetJacobianRectificationRespectGeometry()
1190 return this->GetImpl()->GetJacobianRectificationRespectGeometry();
1192 //=============================================================================
1194 void BLSURFPlugin_Hypothesis_i::SetJacobianRectification( CORBA::Boolean allowRectification )
1196 if ( GetJacobianRectification() != allowRectification )
1198 this->GetImpl()->SetJacobianRectification(allowRectification);
1199 SMESH::TPythonDump() << _this() << ".SetJacobianRectification( " << allowRectification << " )";
1202 //=============================================================================
1203 CORBA::Boolean BLSURFPlugin_Hypothesis_i::GetJacobianRectification()
1205 return this->GetImpl()->GetJacobianRectification();
1207 //=============================================================================
1209 void BLSURFPlugin_Hypothesis_i::SetUseDeprecatedPatchMesher( CORBA::Boolean useDeprecatedPatchMesher )
1211 if ( GetUseDeprecatedPatchMesher() != useDeprecatedPatchMesher )
1213 this->GetImpl()->SetUseDeprecatedPatchMesher(useDeprecatedPatchMesher);
1214 SMESH::TPythonDump() << _this() << ".SetUseDeprecatedPatchMesher( " << useDeprecatedPatchMesher << " )";
1217 //=============================================================================
1218 CORBA::Boolean BLSURFPlugin_Hypothesis_i::GetUseDeprecatedPatchMesher()
1220 return this->GetImpl()->GetUseDeprecatedPatchMesher();
1222 //=============================================================================
1224 void BLSURFPlugin_Hypothesis_i::SetMaxNumberOfPointsPerPatch( CORBA::Long nb )
1226 if ( GetMaxNumberOfPointsPerPatch() != nb )
1229 this->GetImpl()->SetMaxNumberOfPointsPerPatch(nb);
1231 } catch (const std::invalid_argument& ex) {
1232 THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
1233 } catch (SALOME_Exception& ex) {
1234 THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
1236 SMESH::TPythonDump() << _this() << ".SetMaxNumberOfPointsPerPatch( " << nb << " )";
1239 //=============================================================================
1240 CORBA::Long BLSURFPlugin_Hypothesis_i::GetMaxNumberOfPointsPerPatch()
1242 return this->GetImpl()->GetMaxNumberOfPointsPerPatch();
1244 //=============================================================================
1246 void BLSURFPlugin_Hypothesis_i::SetMaxNumberOfThreads( CORBA::Long nb )
1248 if ( GetMaxNumberOfThreads() != nb )
1251 this->GetImpl()->SetMaxNumberOfThreads(nb);
1253 } catch (const std::invalid_argument& ex) {
1254 THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
1255 } catch (SALOME_Exception& ex) {
1256 THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
1258 SMESH::TPythonDump() << _this() << ".SetMaxNumberOfThreads( " << nb << " )";
1261 //=============================================================================
1262 CORBA::Long BLSURFPlugin_Hypothesis_i::GetMaxNumberOfThreads()
1264 return this->GetImpl()->GetMaxNumberOfThreads();
1266 //=============================================================================
1268 void BLSURFPlugin_Hypothesis_i::SetRespectGeometry( CORBA::Boolean toRespect )
1270 if ( GetRespectGeometry() != toRespect )
1272 this->GetImpl()->SetRespectGeometry(toRespect);
1273 SMESH::TPythonDump() << _this() << ".SetRespectGeometry( " << toRespect << " )";
1276 //=============================================================================
1277 CORBA::Boolean BLSURFPlugin_Hypothesis_i::GetRespectGeometry()
1279 return this->GetImpl()->GetRespectGeometry();
1281 //=============================================================================
1283 void BLSURFPlugin_Hypothesis_i::SetTinyEdgesAvoidSurfaceIntersections( CORBA::Boolean toAvoidIntersection )
1285 if ( GetTinyEdgesAvoidSurfaceIntersections() != toAvoidIntersection )
1287 this->GetImpl()->SetTinyEdgesAvoidSurfaceIntersections(toAvoidIntersection);
1288 SMESH::TPythonDump() << _this() << ".SetTinyEdgesAvoidSurfaceIntersections( " << toAvoidIntersection << " )";
1291 //=============================================================================
1292 CORBA::Boolean BLSURFPlugin_Hypothesis_i::GetTinyEdgesAvoidSurfaceIntersections()
1294 return this->GetImpl()->GetTinyEdgesAvoidSurfaceIntersections();
1296 //=============================================================================
1298 void BLSURFPlugin_Hypothesis_i::SetClosedGeometry( CORBA::Boolean isClosed )
1300 if ( GetClosedGeometry() != isClosed )
1302 this->GetImpl()->SetClosedGeometry(isClosed);
1303 SMESH::TPythonDump() << _this() << ".SetClosedGeometry( " << isClosed << " )";
1306 //=============================================================================
1307 CORBA::Boolean BLSURFPlugin_Hypothesis_i::GetClosedGeometry()
1309 return this->GetImpl()->GetClosedGeometry();
1311 //=============================================================================
1313 void BLSURFPlugin_Hypothesis_i::SetDebug( CORBA::Boolean isDebug )
1315 if ( GetDebug() != isDebug )
1317 this->GetImpl()->SetDebug(isDebug);
1318 SMESH::TPythonDump() << _this() << ".SetDebug( " << isDebug << " )";
1321 //=============================================================================
1322 bool BLSURFPlugin_Hypothesis_i::GetDebug()
1324 return this->GetImpl()->GetDebug();
1326 //=============================================================================
1328 void BLSURFPlugin_Hypothesis_i::SetPeriodicTolerance( CORBA::Double tol )
1331 if ( GetImpl()->GetPreCADOptionValue("periodic_tolerance",&isDefault) != SMESH_Comment( tol ))
1335 this->GetImpl()->SetPeriodicTolerance(tol);
1337 } catch (const std::invalid_argument& ex) {
1338 THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
1339 } catch (SALOME_Exception& ex) {
1340 THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
1342 SMESH::TPythonDump() << _this() << ".SetPeriodicTolerance( " << tol << " )";
1345 //=============================================================================
1346 double BLSURFPlugin_Hypothesis_i::GetPeriodicTolerance()
1349 return this->GetImpl()->GetPeriodicTolerance();
1351 } catch (const std::invalid_argument& ex) {
1352 THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
1353 } catch (SALOME_Exception& ex) {
1354 THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
1358 //=============================================================================
1360 void BLSURFPlugin_Hypothesis_i::SetRequiredEntities( const char* howToTreat )
1362 if ( GetImpl()->GetRequiredEntities() != howToTreat )
1365 this->GetImpl()->SetRequiredEntities(howToTreat);
1367 } catch (const std::invalid_argument& ex) {
1368 THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
1369 } catch (SALOME_Exception& ex) {
1370 THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
1372 SMESH::TPythonDump() << _this() << ".SetRequiredEntities( '" << howToTreat << "' )";
1375 //=============================================================================
1376 char* BLSURFPlugin_Hypothesis_i::GetRequiredEntities()
1378 return CORBA::string_dup( this->GetImpl()->GetRequiredEntities().c_str() );
1380 //=============================================================================
1382 void BLSURFPlugin_Hypothesis_i::SetSewingTolerance( CORBA::Double tol )
1385 if ( GetImpl()->GetPreCADOptionValue("sewing_tolerance",&isDefault) != SMESH_Comment( tol ))
1389 this->GetImpl()->SetSewingTolerance(tol);
1390 SMESH::TPythonDump() << _this() << ".SetSewingTolerance( " << tol << " )";
1392 } catch (const std::invalid_argument& ex) {
1393 THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
1394 } catch (SALOME_Exception& ex) {
1395 THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
1399 //=============================================================================
1400 CORBA::Double BLSURFPlugin_Hypothesis_i::GetSewingTolerance()
1404 return this->GetImpl()->GetSewingTolerance();
1406 } catch (const std::invalid_argument& ex) {
1407 THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
1408 } catch (SALOME_Exception& ex) {
1409 THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
1413 //=============================================================================
1415 void BLSURFPlugin_Hypothesis_i::SetTags( const char* howToTreat )
1417 if ( GetImpl()->GetTags() != howToTreat )
1420 this->GetImpl()->SetTags(howToTreat);
1422 catch (const std::invalid_argument& ex) {
1423 THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
1424 } catch (SALOME_Exception& ex) {
1425 THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
1428 SMESH::TPythonDump() << _this() << ".SetTags( '" << howToTreat << "' )";
1430 //=============================================================================
1431 char* BLSURFPlugin_Hypothesis_i::GetTags()
1433 return CORBA::string_dup( this->GetImpl()->GetTags().c_str() );
1436 //=============================================================================
1437 void BLSURFPlugin_Hypothesis_i::SetHyperPatches(const BLSURFPlugin::THyperPatchList& hpl)
1439 ::BLSURFPlugin_Hypothesis::THyperPatchList patchList( hpl.length() );
1440 SMESH_Comment hplDump;
1442 for ( CORBA::ULong i = 0; i < patchList.size(); ++i )
1445 BLSURFPlugin::THyperPatch tags = hpl[ i ];
1446 for ( CORBA::ULong j = 0; j < tags.length(); ++j )
1448 patchList[ i ].insert( tags[ j ]);
1449 hplDump << tags[ j ] << ( j+1 < tags.length() ? ", " : " ]" );
1451 hplDump << ( i+1 < patchList.size() ? "," : "]");
1453 if ( GetImpl()->GetHyperPatches() != patchList )
1455 GetImpl()->SetHyperPatches( ::BLSURFPlugin_Hypothesis::THyperPatchEntriesList() ); // erase entries
1456 GetImpl()->SetHyperPatches( patchList );
1457 SMESH::TPythonDump() << _this() << ".SetHyperPatches( " << hplDump << " )";
1461 //=============================================================================
1462 void BLSURFPlugin_Hypothesis_i::SetHyperPatchEntries(const BLSURFPlugin::THyperPatchEntriesList& hpe)
1464 ::BLSURFPlugin_Hypothesis::THyperPatchEntriesList patchList( hpe.length() );
1465 SMESH_Comment hpeDump;
1467 for ( CORBA::ULong i = 0; i < patchList.size(); ++i )
1470 const BLSURFPlugin::THyperPatchEntries& entryList = hpe[ i ];
1471 for ( CORBA::ULong j = 0; j < entryList.length(); ++j )
1473 patchList[ i ].insert( entryList[ j ].in() );
1474 hpeDump << entryList[ j ].in() << ( j+1 < entryList.length() ? ", " : " ]" );
1476 hpeDump << ( i+1 < patchList.size() ? "," : "]");
1478 if ( GetImpl()->GetHyperPatchEntries() != patchList )
1480 GetImpl()->SetHyperPatches( ::BLSURFPlugin_Hypothesis::THyperPatchList(), /*notify=*/false );
1481 GetImpl()->SetHyperPatches( patchList );
1482 // TPythonDump converts entries to objects
1483 SMESH::TPythonDump() << _this() << ".SetHyperPatchShapes( " << hpeDump << " )";
1487 //=============================================================================
1488 void BLSURFPlugin_Hypothesis_i::SetHyperPatchShapes(const BLSURFPlugin::THyperPatchShapesList& hpsl)
1490 BLSURFPlugin::THyperPatchEntriesList patchList;
1491 patchList.length( hpsl.length() );
1492 for ( CORBA::ULong i = 0; i < hpsl.length(); ++i )
1494 const GEOM::ListOfGO& shapeList = hpsl[ i ];
1495 BLSURFPlugin::THyperPatchEntries& entryList = patchList[ i ];
1496 entryList.length( shapeList.length() );
1497 for ( CORBA::ULong j = 0; j < shapeList.length(); ++j )
1499 CORBA::String_var entry = shapeList[ j ]->GetStudyEntry();
1500 if ( !entry.in() || !entry.in()[0] )
1501 THROW_SALOME_CORBA_EXCEPTION( "BLSURFPlugin_Hypothesis::SetHyperPatchShapes(), "
1502 "Not published hyper-patch shape", SALOME::BAD_PARAM );
1503 entryList[ j ] = CORBA::string_dup( entry );
1506 this->SetHyperPatchEntries( patchList );
1509 //=============================================================================
1510 BLSURFPlugin::THyperPatchList*
1511 BLSURFPlugin_Hypothesis_i::GetHyperPatches( GEOM::GEOM_Object_ptr mainShape )
1513 const ::BLSURFPlugin_Hypothesis::THyperPatchList& hpl = GetImpl()->GetHyperPatches();
1514 BLSURFPlugin::THyperPatchList* resHpl = new BLSURFPlugin::THyperPatchList();
1516 !CORBA::is_nil( mainShape ) &&
1517 !GetImpl()->GetHyperPatchEntries().empty() )
1519 // set IDs by entries
1520 SMESH_Gen_i* smeshGen = SMESH_Gen_i::GetSMESHGen();
1521 TopoDS_Shape S = smeshGen->GeomObjectToShape( mainShape );
1524 std::map< std::string, TopoDS_Shape > entryToShape;
1525 BLSURFPlugin_BLSURF::FillEntryToShape( GetImpl(), entryToShape );
1526 GetImpl()->SetHyperPatchIDsByEntry( S, entryToShape );
1529 resHpl->length((CORBA::ULong) hpl.size() );
1531 ::BLSURFPlugin_Hypothesis::THyperPatchList::const_iterator hpIt = hpl.begin();
1532 for ( int i = 0; hpIt != hpl.end(); ++hpIt, ++i )
1534 const ::BLSURFPlugin_Hypothesis::THyperPatchTags& hp = *hpIt;
1535 BLSURFPlugin::THyperPatch& resHp = (*resHpl)[ i ];
1536 resHp.length((CORBA::ULong) hp.size() );
1538 ::BLSURFPlugin_Hypothesis::THyperPatchTags::const_iterator tag = hp.begin();
1539 for ( int j = 0; tag != hp.end(); ++tag, ++j )
1545 //=============================================================================
1546 BLSURFPlugin::THyperPatchEntriesList* BLSURFPlugin_Hypothesis_i::GetHyperPatchShapes()
1548 const ::BLSURFPlugin_Hypothesis::THyperPatchEntriesList& hpel = GetImpl()->GetHyperPatchEntries();
1549 BLSURFPlugin::THyperPatchEntriesList* resHpl = new BLSURFPlugin::THyperPatchEntriesList();
1550 resHpl->length((CORBA::ULong) hpel.size() );
1552 ::BLSURFPlugin_Hypothesis::THyperPatchEntriesList::const_iterator hpIt = hpel.begin();
1553 for ( int i = 0; hpIt != hpel.end(); ++hpIt, ++i )
1555 const ::BLSURFPlugin_Hypothesis::THyperPatchEntries& hp = *hpIt;
1556 BLSURFPlugin::THyperPatchEntries& resHp = (*resHpl)[ i ];
1557 resHp.length((CORBA::ULong) hp.size() );
1559 ::BLSURFPlugin_Hypothesis::THyperPatchEntries::const_iterator entry = hp.begin();
1560 for ( int j = 0; entry != hp.end(); ++entry, ++j )
1561 resHp[ j ] = CORBA::string_dup( entry->c_str() );
1566 //=============================================================================
1568 * BLSURFPlugin_Hypothesis_i::SetPreCADMergeEdges
1572 //=============================================================================
1573 void BLSURFPlugin_Hypothesis_i::SetPreCADMergeEdges(CORBA::Boolean theValue) {
1575 this->GetImpl()->SetPreCADMergeEdges(theValue);
1576 std::string theValueStr = theValue ? "True" : "False";
1577 SMESH::TPythonDump() << _this() << ".SetPreCADMergeEdges( " << theValueStr.c_str() << " )";
1580 //=============================================================================
1582 * BLSURFPlugin_Hypothesis_i::GetPreCADMergeEdges
1586 //=============================================================================
1587 CORBA::Boolean BLSURFPlugin_Hypothesis_i::GetPreCADMergeEdges() {
1589 return this->GetImpl()->GetPreCADMergeEdges();
1592 //=============================================================================
1594 * BLSURFPlugin_Hypothesis_i::SetPreCADRemoveDuplicateCADFaces
1598 //=============================================================================
1599 void BLSURFPlugin_Hypothesis_i::SetPreCADRemoveDuplicateCADFaces(CORBA::Boolean theValue) {
1601 this->GetImpl()->SetPreCADRemoveDuplicateCADFaces(theValue);
1602 std::string theValueStr = theValue ? "True" : "False";
1603 SMESH::TPythonDump() << _this() << ".SetPreCADRemoveDuplicateCADFaces( " << theValueStr.c_str() << " )";
1606 //=============================================================================
1608 * BLSURFPlugin_Hypothesis_i::GetPreCADRemoveDuplicateCADFaces
1612 //=============================================================================
1613 CORBA::Boolean BLSURFPlugin_Hypothesis_i::GetPreCADRemoveDuplicateCADFaces() {
1615 return this->GetImpl()->GetPreCADRemoveDuplicateCADFaces();
1618 //=============================================================================
1620 * BLSURFPlugin_Hypothesis_i::SetPreCADProcess3DTopology
1624 //=============================================================================
1625 void BLSURFPlugin_Hypothesis_i::SetPreCADProcess3DTopology(CORBA::Boolean theValue) {
1627 this->GetImpl()->SetPreCADProcess3DTopology(theValue);
1628 std::string theValueStr = theValue ? "True" : "False";
1629 SMESH::TPythonDump() << _this() << ".SetPreCADProcess3DTopology( " << theValueStr.c_str() << " )";
1632 //=============================================================================
1634 * BLSURFPlugin_Hypothesis_i::GetPreCADProcess3DTopology
1638 //=============================================================================
1639 CORBA::Boolean BLSURFPlugin_Hypothesis_i::GetPreCADProcess3DTopology() {
1641 return this->GetImpl()->GetPreCADProcess3DTopology();
1644 //=============================================================================
1646 * BLSURFPlugin_Hypothesis_i::SetPreCADDiscardInput
1650 //=============================================================================
1651 void BLSURFPlugin_Hypothesis_i::SetPreCADDiscardInput(CORBA::Boolean theValue) {
1653 this->GetImpl()->SetPreCADDiscardInput(theValue);
1654 std::string theValueStr = theValue ? "True" : "False";
1655 SMESH::TPythonDump() << _this() << ".SetPreCADDiscardInput( " << theValueStr.c_str() << " )";
1658 //=============================================================================
1660 * BLSURFPlugin_Hypothesis_i::GetPreCADDiscardInput
1664 //=============================================================================
1665 CORBA::Boolean BLSURFPlugin_Hypothesis_i::GetPreCADDiscardInput() {
1667 return this->GetImpl()->GetPreCADDiscardInput();
1671 //=============================================================================
1673 void BLSURFPlugin_Hypothesis_i::SetOptionValue(const char* optionName, const char* optionValue)
1677 std::string name( optionName );
1678 if ( !optionValue || !optionValue[0] )
1679 UnsetOption( optionName );
1681 // basic options (visible in Advanced table)
1683 else if ( name == "enforce_cad_edge_sizes" )
1684 SetEnforceCadEdgesSize( GetImpl()->ToBool( optionValue ));
1686 else if ( name == "jacobian_rectification_respect_geometry" )
1687 SetJacobianRectificationRespectGeometry( GetImpl()->ToBool( optionValue ));
1689 else if ( name == "max_number_of_points_per_patch" )
1690 SetMaxNumberOfPointsPerPatch( GetImpl()->ToInt( optionValue ));
1692 else if ( name == "max_number_of_threads" )
1693 SetMaxNumberOfThreads( GetImpl()->ToInt( optionValue ));
1695 else if ( name == "rectify_jacobian" )
1696 SetJacobianRectification( GetImpl()->ToBool( optionValue ));
1698 else if ( name == "use_deprecated_patch_mesher" )
1699 SetUseDeprecatedPatchMesher( GetImpl()->ToBool( optionValue ));
1701 else if ( name == "respect_geometry" )
1702 SetRespectGeometry( GetImpl()->ToBool( optionValue ));
1704 else if ( name == "tiny_edge_avoid_surface_intersections" )
1705 SetTinyEdgesAvoidSurfaceIntersections( GetImpl()->ToBool( optionValue ));
1707 else if ( name == "closed_geometry" )
1708 SetClosedGeometry( GetImpl()->ToBool( optionValue ));
1710 else if ( name == "debug" )
1711 SetDebug( GetImpl()->ToBool( optionValue ));
1713 else if ( name == "discard_input_topology" )
1714 SetPreCADDiscardInput( GetImpl()->ToBool( optionValue ));
1716 else if ( name == "merge_edges" )
1717 SetPreCADMergeEdges( GetImpl()->ToBool( optionValue ));
1719 else if ( name == "periodic_tolerance" )
1720 SetPeriodicTolerance( GetImpl()->ToDbl( optionValue ));
1722 else if ( name == "remove_duplicate_cad_faces" )
1723 SetPreCADRemoveDuplicateCADFaces( GetImpl()->ToBool( optionValue ));
1725 else if ( name == "required_entities" )
1726 SetRequiredEntities( optionValue );
1728 else if ( name == "sewing_tolerance" )
1729 SetSewingTolerance( GetImpl()->ToDbl( optionValue ));
1731 else if ( name == "tags" )
1732 SetTags( optionValue );
1734 // other basic options with specific methods
1736 else if ( name == "correct_surface_intersections" )
1737 SetCorrectSurfaceIntersection( GetImpl()->ToBool( optionValue ));
1739 else if ( name == "optimise_tiny_edges" )
1740 SetOptimiseTinyEdges( GetImpl()->ToBool( optionValue ));
1742 else if ( name == "surface_intersections_processing_max_cost" )
1743 SetCorrectSurfaceIntersectionMaxCost( GetImpl()->ToDbl( optionValue ));
1745 else if ( name == "volume_gradation" )
1746 SetVolumeGradation( GetImpl()->ToDbl( optionValue ));
1748 else if ( name == "tiny_edge_optimisation_length" )
1749 SetTinyEdgeOptimisationLength( GetImpl()->ToDbl( optionValue ));
1751 else if ( name == "proximity" )
1752 SetVolumeProximity( GetImpl()->ToBool( optionValue ));
1754 else if ( name == "prox_ratio" )
1755 SetVolumeProximityRatio( GetImpl()->ToDbl( optionValue ));
1757 else if ( name == "prox_nb_layer" )
1758 SetNbVolumeProximityLayers((CORBA::Short) GetImpl()->ToInt( optionValue ));
1760 // advanced options (for backward compatibility)
1762 else if ( name == "create_tag_on_collision" ||
1763 name == "tiny_edge_respect_geometry" )
1764 AddOption( optionName, optionValue );
1768 valueChanged = ( this->GetImpl()->GetOptionValue( name ) != optionValue &&
1769 this->GetImpl()->GetOptionValue( name, &valueChanged ) != optionValue );
1772 this->GetImpl()->SetOptionValue(optionName, optionValue);
1773 SMESH::TPythonDump() << _this() << ".SetOptionValue( '" << optionName << "', '" << optionValue << "' )";
1776 } catch (const std::invalid_argument& ex) {
1777 THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
1778 } catch (SALOME_Exception& ex) {
1779 THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
1783 //=============================================================================
1785 void BLSURFPlugin_Hypothesis_i::SetPreCADOptionValue(const char* optionName, const char* optionValue)
1788 bool valueChanged = false;
1790 std::string name( optionName );
1791 if ( !optionValue || !optionValue[0] )
1792 UnsetOption( optionName );
1794 else if ( name == "closed_geometry" )
1795 SetClosedGeometry( GetImpl()->ToBool( optionValue ));
1797 else if ( name == "debug" )
1798 SetDebug( GetImpl()->ToBool( optionValue ));
1800 else if ( name == "discard_input_topology" )
1801 SetPreCADDiscardInput( GetImpl()->ToBool( optionValue ));
1803 else if ( name == "merge_edges" )
1804 SetPreCADMergeEdges( GetImpl()->ToBool( optionValue ));
1806 else if ( name == "periodic_tolerance" )
1807 SetPeriodicTolerance( GetImpl()->ToDbl( optionValue ));
1809 else if ( name == "remove_duplicate_cad_faces" )
1810 SetPreCADRemoveDuplicateCADFaces( GetImpl()->ToBool( optionValue ));
1812 else if ( name == "required_entities" )
1813 SetRequiredEntities( optionValue );
1815 else if ( name == "sewing_tolerance" )
1816 SetSewingTolerance( GetImpl()->ToDbl( optionValue ));
1818 else if ( name == "tags" )
1819 SetTags( optionValue );
1821 // other basic options with specific methods
1823 else if ( name == "correct_surface_intersections" )
1824 SetCorrectSurfaceIntersection( GetImpl()->ToBool( optionValue ));
1826 else if ( name == "optimise_tiny_edges" )
1827 SetOptimiseTinyEdges( GetImpl()->ToBool( optionValue ));
1829 else if ( name == "surface_intersections_processing_max_cost" )
1830 SetCorrectSurfaceIntersectionMaxCost( GetImpl()->ToDbl( optionValue ));
1832 else if ( name == "volume_gradation" )
1833 SetVolumeGradation( GetImpl()->ToDbl( optionValue ));
1835 else if ( name == "tiny_edge_optimisation_length" )
1836 SetTinyEdgeOptimisationLength( GetImpl()->ToDbl( optionValue ));
1838 else if ( name == "process_3d_topology" )
1839 SetPreCADProcess3DTopology( GetImpl()->ToBool( optionValue ));
1841 // advanced options (for backward compatibility)
1843 else if ( name == "create_tag_on_collision" ||
1844 name == "tiny_edge_respect_geometry" ||
1845 name == "remove_tiny_edges" ||
1846 name == "tiny_edge_length")
1847 AddPreCADOption( optionName, optionValue );
1850 valueChanged = (this->GetImpl()->GetPreCADOptionValue(optionName) != optionValue);
1852 this->GetImpl()->SetPreCADOptionValue(optionName, optionValue);
1854 } catch (const std::invalid_argument& ex) {
1855 THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
1856 } catch (SALOME_Exception& ex) {
1857 THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
1860 SMESH::TPythonDump() << _this() << ".SetPreCADOptionValue( '" << optionName << "', '" << optionValue << "' )";
1863 //=============================================================================
1865 char* BLSURFPlugin_Hypothesis_i::GetOptionValue(const char* optionName) {
1869 return CORBA::string_dup(this->GetImpl()->GetOptionValue(optionName,&isDefault).c_str());
1870 } catch (const std::invalid_argument& ex) {
1871 THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
1872 } catch (SALOME_Exception& ex) {
1873 THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
1878 //=============================================================================
1880 char* BLSURFPlugin_Hypothesis_i::GetPreCADOptionValue(const char* optionName) {
1884 return CORBA::string_dup(this->GetImpl()->GetPreCADOptionValue(optionName,&isDefault).c_str());
1885 } catch (const std::invalid_argument& ex) {
1886 THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
1887 } catch (SALOME_Exception& ex) {
1888 THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
1893 //=============================================================================
1895 void BLSURFPlugin_Hypothesis_i::UnsetOption(const char* optionName) {
1897 if ( !GetImpl()->GetOptionValue( optionName ).empty() )
1899 this->GetImpl()->ClearOption(optionName);
1900 SMESH::TPythonDump() << _this() << ".UnsetOption( '" << optionName << "' )";
1904 //=============================================================================
1906 void BLSURFPlugin_Hypothesis_i::UnsetPreCADOption(const char* optionName) {
1908 if ( !GetImpl()->GetPreCADOptionValue( optionName ).empty() )
1910 this->GetImpl()->ClearPreCADOption(optionName);
1911 SMESH::TPythonDump() << _this() << ".UnsetPreCADOption( '" << optionName << "' )";
1915 //=============================================================================
1917 BLSURFPlugin::string_array* BLSURFPlugin_Hypothesis_i::GetOptionValues() {
1919 BLSURFPlugin::string_array_var result = new BLSURFPlugin::string_array();
1921 const ::BLSURFPlugin_Hypothesis::TOptionValues & opts = this->GetImpl()->GetOptionValues();
1922 result->length((CORBA::ULong) opts.size());
1926 ::BLSURFPlugin_Hypothesis::TOptionValues::const_iterator opIt = opts.begin();
1927 for (; opIt != opts.end(); ++opIt, ++i) {
1928 string name_value_type = opIt->first;
1929 if (!opIt->second.empty()) {
1930 name_value_type += ":";
1931 name_value_type += GetImpl()->GetOptionValue( opIt->first, &isDefault );
1932 name_value_type += isDefault ? ":0" : ":1";
1934 result[i] = CORBA::string_dup(name_value_type.c_str());
1937 return result._retn();
1940 //=============================================================================
1942 BLSURFPlugin::string_array* BLSURFPlugin_Hypothesis_i::GetPreCADOptionValues() {
1944 BLSURFPlugin::string_array_var result = new BLSURFPlugin::string_array();
1946 const ::BLSURFPlugin_Hypothesis::TOptionValues & opts = this->GetImpl()->GetPreCADOptionValues();
1947 result->length((CORBA::ULong) opts.size());
1951 ::BLSURFPlugin_Hypothesis::TOptionValues::const_iterator opIt = opts.begin();
1952 for (; opIt != opts.end(); ++opIt, ++i) {
1953 string name_value_type = opIt->first;
1954 if (!opIt->second.empty()) {
1955 name_value_type += ":";
1956 name_value_type += GetImpl()->GetPreCADOptionValue( opIt->first, &isDefault );
1957 name_value_type += isDefault ? ":0" : ":1";
1959 result[i] = CORBA::string_dup(name_value_type.c_str());
1961 return result._retn();
1964 //=============================================================================
1966 BLSURFPlugin::string_array* BLSURFPlugin_Hypothesis_i::GetAdvancedOptionValues()
1968 BLSURFPlugin::string_array_var result = new BLSURFPlugin::string_array();
1970 const ::BLSURFPlugin_Hypothesis::TOptionValues & custom_opts = this->GetImpl()->GetCustomOptionValues();
1971 result->length((CORBA::ULong) custom_opts.size());
1974 ::BLSURFPlugin_Hypothesis::TOptionValues::const_iterator opIt = custom_opts.begin();
1975 for (; opIt != custom_opts.end(); ++opIt, ++i) {
1976 string name_value_type = opIt->first;
1977 if (!opIt->second.empty()) {
1978 name_value_type += ":";
1979 name_value_type += opIt->second;
1980 name_value_type += ":1"; // user defined
1982 result[i] = CORBA::string_dup(name_value_type.c_str());
1984 return result._retn();
1987 //=============================================================================
1989 void BLSURFPlugin_Hypothesis_i::SetOptionValues(const BLSURFPlugin::string_array& options)
1992 for (CORBA::ULong i = 0; i < options.length(); ++i) {
1993 string name_value_type = options[i].in();
1994 if(name_value_type.empty())
1996 size_t colonPos = name_value_type.find(':');
1998 if (colonPos == string::npos) // ':' not found
1999 name = name_value_type;
2001 name = name_value_type.substr(0, colonPos);
2002 if (colonPos < name_value_type.size() - 1 && name_value_type[colonPos] != ' ') {
2003 string value_type = name_value_type.substr(colonPos + 1);
2004 colonPos = value_type.find(':');
2005 value = value_type.substr(0, colonPos);
2006 if (colonPos < value_type.size() - 1 && value_type[colonPos] != ' ')
2007 if ( value_type.substr(colonPos + 1) == "0" ) // is default
2011 SetOptionValue(name.c_str(), value.c_str());
2015 //=============================================================================
2017 void BLSURFPlugin_Hypothesis_i::SetPreCADOptionValues(const BLSURFPlugin::string_array& options)
2020 for ( CORBA::ULong i = 0; i < options.length(); ++i) {
2021 string name_value_type = options[i].in();
2022 if(name_value_type.empty())
2024 size_t colonPos = name_value_type.find(':');
2026 if (colonPos == string::npos) // ':' not found
2027 name = name_value_type;
2029 name = name_value_type.substr(0, colonPos);
2030 if (colonPos < name_value_type.size() - 1 && name_value_type[colonPos] != ' ') {
2031 string value_type = name_value_type.substr(colonPos + 1);
2032 colonPos = value_type.find(':');
2033 value = value_type.substr(0, colonPos);
2034 if (colonPos < value_type.size() - 1 && value_type[colonPos] != ' ')
2035 if ( value_type.substr(colonPos + 1) == "0" ) // is default
2039 SetPreCADOptionValue(name.c_str(), value.c_str());
2043 //=============================================================================
2045 void BLSURFPlugin_Hypothesis_i::SetAdvancedOptionValues(const BLSURFPlugin::string_array& options)
2047 SMESH::TPythonDump dump;
2049 string optionsAndValues;
2050 for ( CORBA::ULong i = 0; i < options.length(); ++i) {
2051 string name_value_type = options[i].in();
2052 if(name_value_type.empty())
2054 size_t colonPos = name_value_type.find(':');
2056 if (colonPos == string::npos) // ':' not found
2057 name = name_value_type;
2059 name = name_value_type.substr(0, colonPos);
2060 if (colonPos < name_value_type.size() - 1 && name_value_type[colonPos] != ' ') {
2061 string value_type = name_value_type.substr(colonPos + 1);
2062 colonPos = value_type.find(':');
2063 value = value_type.substr(0, colonPos);
2066 AddOption(name.c_str(), value.c_str());
2068 optionsAndValues += name + " " + value + " ";
2071 if ( !optionsAndValues.empty() )
2072 dump << _this() << ".SetAdvancedOptions( '" << optionsAndValues.c_str() << "' )";
2075 //=============================================================================
2077 void BLSURFPlugin_Hypothesis_i::SetAdvancedOption(const char* optionsAndValues)
2079 if ( !optionsAndValues ) return;
2081 SMESH::TPythonDump dump;
2083 std::istringstream strm( optionsAndValues );
2084 std::istream_iterator<std::string> sIt( strm ), sEnd;
2085 while ( sIt != sEnd )
2087 std::string option = *sIt;
2088 if ( ++sIt != sEnd )
2090 std::string value = *sIt;
2092 AddOption( option.c_str(), value.c_str() );
2096 THROW_SALOME_CORBA_EXCEPTION( "Uneven number of options and values" ,SALOME::BAD_PARAM );
2099 dump << _this() << ".SetAdvancedOption( '" << optionsAndValues << "' )";
2102 //=============================================================================
2104 void BLSURFPlugin_Hypothesis_i::AddOption(const char* optionName, const char* optionValue)
2106 // backward compatibility
2108 std::string name( optionName );
2109 if ( name == "proximity" )
2110 SetVolumeProximity( GetImpl()->ToBool( optionValue ));
2112 else if ( name == "prox_ratio" )
2113 SetVolumeProximityRatio( GetImpl()->ToDbl( optionValue ));
2115 else if ( name == "prox_nb_layer" )
2116 SetNbVolumeProximityLayers( (CORBA::Short) GetImpl()->ToInt( optionValue ));
2118 bool valueChanged = (this->GetImpl()->GetOption(optionName) != optionValue);
2120 this->GetImpl()->AddOption(optionName, optionValue);
2121 SMESH::TPythonDump() << _this() << ".AddOption( '" << optionName << "', '" << optionValue << "' )";
2125 //=============================================================================
2127 void BLSURFPlugin_Hypothesis_i::AddPreCADOption(const char* optionName, const char* optionValue)
2130 bool valueChanged = (this->GetImpl()->GetPreCADOption(optionName) != optionValue);
2132 this->GetImpl()->AddPreCADOption(optionName, optionValue);
2133 SMESH::TPythonDump() << _this() << ".AddPreCADOption( '" << optionName << "', '" << optionValue << "' )";
2137 //=============================================================================
2139 char* BLSURFPlugin_Hypothesis_i::GetOption(const char* optionName)
2142 return CORBA::string_dup(this->GetImpl()->GetOption(optionName).c_str());
2145 //=============================================================================
2147 char* BLSURFPlugin_Hypothesis_i::GetPreCADOption(const char* optionName)
2150 return CORBA::string_dup(this->GetImpl()->GetPreCADOption(optionName).c_str());
2153 //=============================================================================
2155 void BLSURFPlugin_Hypothesis_i::SetSizeMapEntry(const char* entry, const char* sizeMap)
2158 if ( !entry || !entry[0] )
2159 THROW_SALOME_CORBA_EXCEPTION( "SetSizeMapEntry(): empty geom entry", SALOME::BAD_PARAM );
2160 bool valueChanged = false;
2162 valueChanged = (this->GetImpl()->GetSizeMapEntry(entry) != sizeMap);
2164 this->GetImpl()->SetSizeMapEntry(entry, sizeMap);
2165 } catch (const std::invalid_argument& ex) {
2166 SALOME::ExceptionStruct ExDescription;
2167 ExDescription.text = ex.what();
2168 ExDescription.type = SALOME::BAD_PARAM;
2169 ExDescription.sourceFile = "BLSURFPlugin_Hypothesis::SetSizeMapEntry(entry,sizemap)";
2170 ExDescription.lineNumber = 0;
2171 throw SALOME::SALOME_Exception(ExDescription);
2172 } catch (SALOME_Exception& ex) {
2173 THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
2176 SMESH::TPythonDump() << _this() << ".SetSizeMap(" << entry << ", '" << sizeMap << "' )";
2179 //=============================================================================
2181 void BLSURFPlugin_Hypothesis_i::SetConstantSizeMapEntry(const char* entry, GEOM::shape_type shapeType, CORBA::Double sizeMap)
2184 bool valueChanged = false;
2185 std::ostringstream sizeMapFunction;
2186 switch (shapeType) {
2187 case GEOM::FACE: sizeMapFunction << "def f(u,v): return " << sizeMap ; break;
2188 case GEOM::EDGE: sizeMapFunction << "def f(t): return " << sizeMap ; break;
2189 case GEOM::VERTEX: sizeMapFunction << "def f(): return " << sizeMap ; break;
2193 valueChanged = (this->GetImpl()->GetSizeMapEntry(entry) != sizeMapFunction.str());
2195 this->GetImpl()->SetSizeMapEntry(entry, sizeMapFunction.str());
2196 } catch (const std::invalid_argument& ex) {
2197 SALOME::ExceptionStruct ExDescription;
2198 ExDescription.text = ex.what();
2199 ExDescription.type = SALOME::BAD_PARAM;
2200 ExDescription.sourceFile = "BLSURFPlugin_Hypothesis::SetSizeMapEntry(entry,sizemap)";
2201 ExDescription.lineNumber = 0;
2202 throw SALOME::SALOME_Exception(ExDescription);
2203 } catch (SALOME_Exception& ex) {
2204 THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
2207 SMESH::TPythonDump() << _this() << ".SetConstantSizeMap(" << entry << ", " << sizeMap << " )";
2210 //=============================================================================
2212 void BLSURFPlugin_Hypothesis_i::SetAttractorEntry(const char* entry, const char* attractor)
2215 bool valueChanged = false;
2217 valueChanged = ( this->GetImpl()->GetAttractorEntry(entry) != attractor );
2218 if ( valueChanged ) {
2219 boost::regex re("^ATTRACTOR\\((?:(-?0(\\.\\d*)*|-?[1-9]+\\d*(\\.\\d*)*|-?\\.(\\d)+);){5}(True|False)(?:;(-?0(\\.\\d*)*|-?[1-9]+\\d*(\\.\\d*)*|-?\\.(\\d)+))?\\)$");
2220 if (!boost::regex_match(string(attractor), re))
2221 throw std::invalid_argument("Error: an attractor is defined with the following pattern: ATTRACTOR(xa;ya;za;a;b;True|False;d(opt.))");
2222 this->GetImpl()->SetAttractorEntry(entry, attractor);
2224 } catch (const std::invalid_argument& ex) {
2225 SALOME::ExceptionStruct ExDescription;
2226 ExDescription.text = ex.what();
2227 ExDescription.type = SALOME::BAD_PARAM;
2228 ExDescription.sourceFile = "BLSURFPlugin_Hypothesis::SetAttractorEntry(entry,attractor)";
2229 ExDescription.lineNumber = 0;
2230 throw SALOME::SALOME_Exception(ExDescription);
2231 } catch (SALOME_Exception& ex) {
2232 THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
2235 SMESH::TPythonDump() << _this() << ".SetAttractor(" << entry << ", '" << attractor << "' )";
2238 //=============================================================================
2240 void BLSURFPlugin_Hypothesis_i::SetClassAttractorEntry(const char* entry, const char* att_entry, CORBA::Double StartSize, CORBA::Double EndSize, CORBA::Double ActionRadius, CORBA::Double ConstantRadius) //TODO ?? finir
2243 //bool valueChanged = false;
2245 this->GetImpl()->SetClassAttractorEntry(entry, att_entry, StartSize, EndSize, ActionRadius, ConstantRadius);
2247 catch (const std::invalid_argument& ex) {
2248 SALOME::ExceptionStruct ExDescription;
2249 ExDescription.text = ex.what();
2250 ExDescription.type = SALOME::BAD_PARAM;
2251 ExDescription.sourceFile = "BLSURFPlugin_Hypothesis::SetClassAttractorEntry(entry, att_entry, StartSize, EndSize, ActionRadius, ConstantRadius)";
2252 ExDescription.lineNumber = 0;
2253 throw SALOME::SALOME_Exception(ExDescription);
2254 } catch (SALOME_Exception& ex) {
2255 THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
2257 //if ( valueChanged )
2258 SMESH::TPythonDump() << _this() << ".SetAttractorGeom( "
2259 << entry << ", " << att_entry << ", "<<StartSize<<", "<<EndSize<<", "<<ActionRadius<<", "<<ConstantRadius<<" )";
2262 //=============================================================================
2264 char* BLSURFPlugin_Hypothesis_i::GetSizeMapEntry(const char* entry) {
2267 return CORBA::string_dup(this->GetImpl()->GetSizeMapEntry(entry).c_str());
2268 } catch (const std::invalid_argument& ex) {
2269 SALOME::ExceptionStruct ExDescription;
2270 ExDescription.text = ex.what();
2271 ExDescription.type = SALOME::BAD_PARAM;
2272 ExDescription.sourceFile = "BLSURFPlugin_Hypothesis::GetSizeMapEntry(name)";
2273 ExDescription.lineNumber = 0;
2274 throw SALOME::SALOME_Exception(ExDescription);
2275 } catch (SALOME_Exception& ex) {
2276 THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
2281 //=============================================================================
2283 char* BLSURFPlugin_Hypothesis_i::GetAttractorEntry(const char* entry) {
2286 return CORBA::string_dup(this->GetImpl()->GetAttractorEntry(entry).c_str());
2287 } catch (const std::invalid_argument& ex) {
2288 SALOME::ExceptionStruct ExDescription;
2289 ExDescription.text = ex.what();
2290 ExDescription.type = SALOME::BAD_PARAM;
2291 ExDescription.sourceFile = "BLSURFPlugin_Hypothesis::GetAttractorEntry(name)";
2292 ExDescription.lineNumber = 0;
2293 throw SALOME::SALOME_Exception(ExDescription);
2294 } catch (SALOME_Exception& ex) {
2295 THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
2300 // //=============================================================================
2302 // // TODO coder cette fonction (utilis??e pour savoir si la valeur a chang??
2303 // // A finir pour le dump
2304 // char* BLSURFPlugin_Hypothesis_i::GetClassAttractorEntry(const char* entry)
2306 // ASSERT(myBaseImpl);
2308 // return CORBA::string_dup( this->GetImpl()->GetClassAttractorEntry(entry).c_str());
2310 // catch (const std::invalid_argument& ex) {
2311 // SALOME::ExceptionStruct ExDescription;
2312 // ExDescription.text = ex.what();
2313 // ExDescription.type = SALOME::BAD_PARAM;
2314 // ExDescription.sourceFile = "BLSURFPlugin_Hypothesis::GetClassAttractorEntry(name)";
2315 // ExDescription.lineNumber = 0;
2316 // throw SALOME::SALOME_Exception(ExDescription);
2318 // catch (SALOME_Exception& ex) {
2319 // THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
2324 //=============================================================================
2326 void BLSURFPlugin_Hypothesis_i::UnsetEntry(const char* entry) {
2328 this->GetImpl()->ClearEntry(entry);
2329 // SMESH::TPythonDump() << _this() << ".UnsetSizeMap( " << entry << " )";
2332 //=============================================================================
2334 BLSURFPlugin::string_array* BLSURFPlugin_Hypothesis_i::GetSizeMapEntries() {
2336 BLSURFPlugin::string_array_var result = new BLSURFPlugin::string_array();
2338 const ::BLSURFPlugin_Hypothesis::TSizeMap sizeMaps = this->GetImpl()->_GetSizeMapEntries();
2339 result->length((CORBA::ULong) sizeMaps.size());
2341 ::BLSURFPlugin_Hypothesis::TSizeMap::const_iterator smIt = sizeMaps.begin();
2342 for (int i = 0; smIt != sizeMaps.end(); ++smIt, ++i) {
2343 string entry_sizemap = smIt->first;
2344 if (!smIt->second.empty()) {
2345 entry_sizemap += "|";
2346 entry_sizemap += smIt->second;
2348 result[i] = CORBA::string_dup(entry_sizemap.c_str());
2350 return result._retn();
2353 //=============================================================================
2355 BLSURFPlugin::string_array* BLSURFPlugin_Hypothesis_i::GetAttractorEntries() {
2357 BLSURFPlugin::string_array_var result = new BLSURFPlugin::string_array();
2359 const ::BLSURFPlugin_Hypothesis::TSizeMap attractors = this->GetImpl()->_GetAttractorEntries();
2360 result->length((CORBA::ULong) attractors.size());
2362 ::BLSURFPlugin_Hypothesis::TSizeMap::const_iterator atIt = attractors.begin();
2363 for (int i = 0; atIt != attractors.end(); ++atIt, ++i) {
2364 string entry_attractor = atIt->first;
2365 if (!atIt->second.empty()) {
2366 entry_attractor += "|";
2367 entry_attractor += atIt->second;
2369 result[i] = CORBA::string_dup(entry_attractor.c_str());
2371 return result._retn();
2374 //=============================================================================
2376 BLSURFPlugin::TAttParamsMap* BLSURFPlugin_Hypothesis_i::GetAttractorParams()
2379 BLSURFPlugin::TAttParamsMap_var result = new BLSURFPlugin::TAttParamsMap();
2381 const ::BLSURFPlugin_Hypothesis::TAttractorMap attractors= this->GetImpl()->_GetClassAttractorEntries();
2382 result->length((CORBA::ULong) attractors.size() );
2384 ::BLSURFPlugin_Hypothesis::TAttractorMap::const_iterator atIt = attractors.begin();
2385 for ( int i = 0 ; atIt != attractors.end(); ++atIt, ++i ) {
2386 string faceEntry = atIt->first;
2388 double startSize=0., endSize=0., infDist=0., constDist=0.;
2389 if ( !atIt->second->Empty() ) {
2390 attEntry = atIt->second->GetAttractorEntry();
2391 std::vector<double> params = atIt->second->GetParameters();
2392 startSize = params[0];
2393 endSize = params[1];
2394 infDist = params[2];
2395 constDist = params[3];
2397 result[i].faceEntry = CORBA::string_dup(faceEntry.c_str());
2398 result[i].attEntry = CORBA::string_dup(attEntry.c_str());
2399 result[i].startSize = startSize;
2400 result[i].endSize = endSize;
2401 result[i].infDist = infDist;
2402 result[i].constDist = constDist;
2404 return result._retn();
2407 //=============================================================================
2409 void BLSURFPlugin_Hypothesis_i::SetSizeMapEntries(const BLSURFPlugin::string_array& sizeMaps)
2412 for ( CORBA::ULong i = 0; i < sizeMaps.length(); ++i) {
2413 string entry_sizemap = sizeMaps[i].in();
2414 size_t colonPos = entry_sizemap.find('|');
2415 string entry, sizemap;
2416 if (colonPos == string::npos) // '|' separator not found
2417 entry = entry_sizemap;
2419 entry = entry_sizemap.substr(0, colonPos);
2420 if (colonPos < entry_sizemap.size() - 1 && entry_sizemap[colonPos] != ' ')
2421 sizemap = entry_sizemap.substr(colonPos + 1);
2423 this->GetImpl()->SetSizeMapEntry(entry.c_str(), sizemap.c_str());
2427 //=============================================================================
2429 void BLSURFPlugin_Hypothesis_i::ClearSizeMaps() {
2431 this->GetImpl()->ClearSizeMaps();
2434 //=============================================================================
2436 void BLSURFPlugin_Hypothesis_i::SetSizeMap(const GEOM::GEOM_Object_ptr GeomObj, const char* sizeMap)
2440 entry = GeomObj->GetStudyEntry();
2441 SetSizeMapEntry(entry.c_str(), sizeMap);
2444 //=============================================================================
2446 void BLSURFPlugin_Hypothesis_i::SetConstantSizeMap(const GEOM::GEOM_Object_ptr GeomObj, CORBA::Double sizeMap) {
2448 string entry = GeomObj->GetStudyEntry();
2449 GEOM::shape_type shapeType = GeomObj->GetShapeType();
2450 if (shapeType == GEOM::COMPOUND)
2451 shapeType = GeomObj->GetMaxShapeType();
2452 SetConstantSizeMapEntry(entry.c_str(), shapeType, sizeMap);
2455 //=============================================================================
2456 void BLSURFPlugin_Hypothesis_i::UnsetSizeMap(const GEOM::GEOM_Object_ptr GeomObj) {
2459 entry = GeomObj->GetStudyEntry();
2460 UnsetEntry(entry.c_str());
2461 SMESH::TPythonDump() << _this() << ".UnsetSizeMap( " << entry.c_str() << " )";
2464 void BLSURFPlugin_Hypothesis_i::SetAttractor(GEOM::GEOM_Object_ptr GeomObj, const char* attractor) {
2467 entry = GeomObj->GetStudyEntry();
2468 SetAttractorEntry(entry.c_str(), attractor);
2471 void BLSURFPlugin_Hypothesis_i::UnsetAttractor(GEOM::GEOM_Object_ptr GeomObj) {
2474 entry = GeomObj->GetStudyEntry();
2475 UnsetEntry(entry.c_str());
2476 SMESH::TPythonDump() << _this() << ".UnsetAttractor( " << entry.c_str() << " )";
2479 void BLSURFPlugin_Hypothesis_i::SetAttractorGeom(GEOM::GEOM_Object_ptr theFace, GEOM::GEOM_Object_ptr theAttractor, CORBA::Double StartSize, CORBA::Double EndSize, CORBA::Double ActionRadius, CORBA::Double ConstantRadius)
2482 string theFaceEntry;
2484 theFaceEntry = theFace->GetStudyEntry();
2485 theAttEntry = theAttractor->GetStudyEntry();
2487 GEOM::GEOM_Gen_ptr geomGen = SMESH_Gen_i::GetGeomEngine( theFace );
2490 if (theFaceEntry.empty()) {
2492 aName += theFace->GetEntry();
2493 SALOMEDS::SObject_wrap theSFace = geomGen->PublishInStudy(NULL, theFace, aName.c_str());
2494 if (!theSFace->_is_nil())
2495 theFaceEntry = theSFace->GetID();
2497 if (theFaceEntry.empty())
2498 THROW_SALOME_CORBA_EXCEPTION( "Geom object is not published in study" ,SALOME::BAD_PARAM );
2500 if (theAttEntry.empty()) {
2501 if (theAttractor->GetShapeType() == GEOM::VERTEX)
2503 if (theAttractor->GetShapeType() == GEOM::EDGE)
2505 if (theAttractor->GetShapeType() == GEOM::WIRE)
2507 if (theAttractor->GetShapeType() == GEOM::COMPOUND)
2508 aName = "Compound_";
2509 aName += theAttractor->GetEntry();
2510 SALOMEDS::SObject_wrap theSAtt = geomGen->PublishInStudy(NULL, theAttractor, aName.c_str());
2511 if (!theSAtt->_is_nil())
2512 theAttEntry = theSAtt->GetID();
2514 if (theAttEntry.empty())
2515 THROW_SALOME_CORBA_EXCEPTION( "Geom object is not published in study" ,SALOME::BAD_PARAM );
2517 TopoDS_Face FaceShape = TopoDS::Face(SMESH_Gen_i::GetSMESHGen()->GeomObjectToShape( theFace ));
2518 TopoDS_Shape AttractorShape = SMESH_Gen_i::GetSMESHGen()->GeomObjectToShape( theAttractor );
2519 SetClassAttractorEntry( theFaceEntry.c_str(), theAttEntry.c_str(), StartSize, EndSize, ActionRadius, ConstantRadius);
2522 void BLSURFPlugin_Hypothesis_i::UnsetAttractorGeom(GEOM::GEOM_Object_ptr theFace,
2523 GEOM::GEOM_Object_ptr theAttractor)
2526 CORBA::String_var theFaceEntry = theFace->GetStudyEntry();
2527 CORBA::String_var theAttrEntry = theAttractor->GetStudyEntry();
2529 // GEOM::GEOM_Gen_ptr geomGen = SMESH_Gen_i::GetGeomEngine( theFace );
2532 // if (theFaceEntry.empty()) {
2534 // aName += theFace->GetEntry();
2535 // SALOMEDS::SObject_wrap theSFace = geomGen->PublishInStudy(NULL, theFace, aName.c_str());
2536 // if (!theSFace->_is_nil())
2537 // theFaceEntry = theSFace->GetID();
2539 if ( !theFaceEntry.in() || !theFaceEntry.in()[0] ||
2540 !theAttrEntry.in() || !theAttrEntry.in()[0] )
2541 THROW_SALOME_CORBA_EXCEPTION( "Geom object is not published in study" ,SALOME::BAD_PARAM );
2543 GetImpl()->ClearEntry( theFaceEntry.in(), theAttrEntry.in() );
2544 SMESH::TPythonDump() << _this() << ".UnsetAttractorGeom( "
2545 << theFace << ", " << theAttractor << " )";
2548 void BLSURFPlugin_Hypothesis_i::UnsetAttractorEntry(const char* faceEntry,
2549 const char* attractorEntry)
2551 GetImpl()->ClearEntry( faceEntry, attractorEntry );
2552 SMESH::TPythonDump() << _this() << ".UnsetAttractorEntry( '"
2553 << faceEntry << "', '" << attractorEntry << "' )";
2558 void BLSURFPlugin_Hypothesis_i::SetCustomSizeMap(GEOM::GEOM_Object_ptr GeomObj, const char* sizeMap)
2561 void BLSURFPlugin_Hypothesis_i::UnsetCustomSizeMap(GEOM::GEOM_Object_ptr GeomObj)
2564 void BLSURFPlugin_Hypothesis_i::SetCustomSizeMapEntry(const char* entry,const char* sizeMap )
2567 char* BLSURFPlugin_Hypothesis_i::GetCustomSizeMapEntry(const char* entry)
2570 void BLSURFPlugin_Hypothesis_i::UnsetCustomSizeMapEntry(const char* entry)
2573 this->GetImpl()->UnsetCustomSizeMap(entry);
2574 SMESH::TPythonDump() << _this() << ".UnsetCustomSizeMap( " << entry << " )";
2578 BLSURFPlugin::string_array* BLSURFPlugin_Hypothesis_i::GetCustomSizeMapEntries()
2583 // ///////////////////////
2584 // // ENFORCED VERTICES //
2585 // ///////////////////////
2589 * Returns the list of enforced vertices for a given Face entry
2590 * @return A map of Face entry / List of enforced vertices
2593 BLSURFPlugin::TFaceEntryEnfVertexListMap* BLSURFPlugin_Hypothesis_i::GetAllEnforcedVerticesByFace() {
2596 BLSURFPlugin::TFaceEntryEnfVertexListMap_var resultMap = new BLSURFPlugin::TFaceEntryEnfVertexListMap();
2598 const ::BLSURFPlugin_Hypothesis::TFaceEntryEnfVertexListMap faceEntryEnfVertexListMap =
2599 this->GetImpl()->_GetAllEnforcedVerticesByFace();
2600 resultMap->length((CORBA::ULong) faceEntryEnfVertexListMap.size());
2602 ::BLSURFPlugin_Hypothesis::TEnfVertexList _enfVertexList;
2603 ::BLSURFPlugin_Hypothesis::TFaceEntryEnfVertexListMap::const_iterator it_entry = faceEntryEnfVertexListMap.begin();
2604 for (int i = 0; it_entry != faceEntryEnfVertexListMap.end(); ++it_entry, ++i) {
2605 BLSURFPlugin::TFaceEntryEnfVertexListMapElement_var mapElement =
2606 new BLSURFPlugin::TFaceEntryEnfVertexListMapElement();
2607 mapElement->faceEntry = CORBA::string_dup(it_entry->first.c_str());
2609 _enfVertexList = it_entry->second;
2610 BLSURFPlugin::TEnfVertexList_var enfVertexList = new BLSURFPlugin::TEnfVertexList();
2611 enfVertexList->length((CORBA::ULong) _enfVertexList.size());
2613 ::BLSURFPlugin_Hypothesis::TEnfVertexList::const_iterator it_enfVertex = _enfVertexList.begin();
2614 ::BLSURFPlugin_Hypothesis::TEnfVertex *currentEnfVertex;
2615 for (int j = 0; it_enfVertex != _enfVertexList.end(); ++it_enfVertex, ++j) {
2616 currentEnfVertex = (*it_enfVertex);
2618 BLSURFPlugin::TEnfVertex_var enfVertex = new BLSURFPlugin::TEnfVertex();
2621 enfVertex->name = CORBA::string_dup(currentEnfVertex->name.c_str());
2624 enfVertex->geomEntry = CORBA::string_dup(currentEnfVertex->geomEntry.c_str());
2627 BLSURFPlugin::TEnfVertexCoords_var coords = new BLSURFPlugin::TEnfVertexCoords();
2628 coords->length((CORBA::ULong) currentEnfVertex->coords.size());
2629 for (CORBA::ULong i=0;i<coords->length();i++)
2630 coords[i] = currentEnfVertex->coords[i];
2631 enfVertex->coords = coords;
2634 enfVertex->grpName = CORBA::string_dup(currentEnfVertex->grpName.c_str());
2637 BLSURFPlugin::TEntryList_var faceEntryList = new BLSURFPlugin::TEntryList();
2638 faceEntryList->length((CORBA::ULong) currentEnfVertex->faceEntries.size());
2639 ::BLSURFPlugin_Hypothesis::TEntryList::const_iterator it_entry = currentEnfVertex->faceEntries.begin();
2640 for (int ind = 0; it_entry != currentEnfVertex->faceEntries.end();++it_entry, ++ind)
2641 faceEntryList[ind] = CORBA::string_dup((*it_entry).c_str());
2642 enfVertex->faceEntries = faceEntryList;
2645 msg << "Enforced vertex: \n"
2646 << "Name: " << enfVertex->name << "\n";
2647 if (coords->length())
2648 msg << "Coords: " << enfVertex->coords[0] << ", " << enfVertex->coords[1] << ", " << enfVertex->coords[2] << "\n";
2649 msg << "Geom entry: " << enfVertex->geomEntry << "\n"
2650 << "Group Name: " << enfVertex->grpName;
2652 enfVertexList[j] = enfVertex;
2654 mapElement->enfVertexList = enfVertexList;
2656 resultMap[i] = mapElement;
2659 return resultMap._retn();
2663 * Returns the list of all enforced vertices
2664 * @return a list of enforced vertices
2667 BLSURFPlugin::TEnfVertexList* BLSURFPlugin_Hypothesis_i::GetAllEnforcedVertices() {
2669 BLSURFPlugin::TEnfVertexList_var resultMap = new BLSURFPlugin::TEnfVertexList();
2670 const ::BLSURFPlugin_Hypothesis::TEnfVertexList enfVertexList = this->GetImpl()->_GetAllEnforcedVertices();
2671 resultMap->length((CORBA::ULong) enfVertexList.size());
2673 ::BLSURFPlugin_Hypothesis::TEnfVertexList::const_iterator evlIt = enfVertexList.begin();
2674 ::BLSURFPlugin_Hypothesis::TEnfVertex *currentEnfVertex;
2675 for (int i = 0; evlIt != enfVertexList.end(); ++evlIt, ++i) {
2676 currentEnfVertex = (*evlIt);
2677 BLSURFPlugin::TEnfVertex_var enfVertex = new BLSURFPlugin::TEnfVertex();
2679 enfVertex->name = CORBA::string_dup(currentEnfVertex->name.c_str());
2681 enfVertex->geomEntry = CORBA::string_dup(currentEnfVertex->geomEntry.c_str());
2683 BLSURFPlugin::TEnfVertexCoords_var coords = new BLSURFPlugin::TEnfVertexCoords();
2684 coords->length((CORBA::ULong) currentEnfVertex->coords.size());
2685 for (CORBA::ULong ind = 0; ind < coords->length(); ind++)
2686 coords[ind] = currentEnfVertex->coords[ind];
2687 enfVertex->coords = coords;
2689 enfVertex->grpName = CORBA::string_dup(currentEnfVertex->grpName.c_str());
2691 BLSURFPlugin::TEntryList_var faceEntryList = new BLSURFPlugin::TEntryList();
2692 faceEntryList->length((CORBA::ULong) currentEnfVertex->faceEntries.size());
2693 ::BLSURFPlugin_Hypothesis::TEntryList::const_iterator it_entry = currentEnfVertex->faceEntries.begin();
2694 for (int ind = 0; it_entry != currentEnfVertex->faceEntries.end();++it_entry, ++ind)
2695 faceEntryList[ind] = CORBA::string_dup((*it_entry).c_str());
2696 enfVertex->faceEntries = faceEntryList;
2699 msg << "Enforced vertex: \n"
2700 << "Name: " << enfVertex->name << "\n";
2701 if (coords->length())
2702 msg << "Coords: " << enfVertex->coords[0] << ", " << enfVertex->coords[1] << ", " << enfVertex->coords[2] << "\n";
2703 msg << "Geom entry: " << enfVertex->geomEntry << "\n"
2704 << "Group Name: " << enfVertex->grpName;
2706 resultMap[i] = enfVertex;
2708 return resultMap._retn();
2713 * Returns the list of enforced vertices coords for a given Face entry.
2714 * They are the coords of the "manual" enforced vertices.
2715 * @return A map of Face entry / List of enforced vertices coords
2718 BLSURFPlugin::TFaceEntryCoordsListMap* BLSURFPlugin_Hypothesis_i::GetAllCoordsByFace() {
2721 BLSURFPlugin::TFaceEntryCoordsListMap_var resultMap = new BLSURFPlugin::TFaceEntryCoordsListMap();
2723 const ::BLSURFPlugin_Hypothesis::TFaceEntryCoordsListMap entryCoordsListMap = this->GetImpl()->_GetAllCoordsByFace();
2724 resultMap->length((CORBA::ULong) entryCoordsListMap.size());
2726 ::BLSURFPlugin_Hypothesis::TEnfVertexCoordsList _coordsList;
2727 ::BLSURFPlugin_Hypothesis::TFaceEntryCoordsListMap::const_iterator it_entry = entryCoordsListMap.begin();
2728 for (int i = 0; it_entry != entryCoordsListMap.end(); ++it_entry, ++i) {
2729 BLSURFPlugin::TFaceEntryCoordsListMapElement_var mapElement = new BLSURFPlugin::TFaceEntryCoordsListMapElement();
2730 mapElement->faceEntry = CORBA::string_dup(it_entry->first.c_str());
2732 _coordsList = it_entry->second;
2733 BLSURFPlugin::TEnfVertexCoordsList_var coordsList = new BLSURFPlugin::TEnfVertexCoordsList();
2734 coordsList->length((CORBA::ULong) _coordsList.size());
2736 ::BLSURFPlugin_Hypothesis::TEnfVertexCoordsList::const_iterator it_coords = _coordsList.begin();
2737 for (int j = 0; it_coords != _coordsList.end(); ++it_coords, ++j) {
2738 BLSURFPlugin::TEnfVertexCoords_var coords = new BLSURFPlugin::TEnfVertexCoords();
2739 coords->length((CORBA::ULong) (*it_coords).size());
2740 for (CORBA::ULong i=0;i<coords->length();i++)
2741 coords[i] = (*it_coords)[i];
2742 coordsList[j] = coords;
2744 mapElement->coordsList = coordsList;
2746 resultMap[i] = mapElement;
2749 return resultMap._retn();
2753 * Returns a map of enforced vertices coords / enforced vertex.
2754 * They are the coords of the "manual" enforced vertices.
2756 BLSURFPlugin::TCoordsEnfVertexMap* BLSURFPlugin_Hypothesis_i::GetAllEnforcedVerticesByCoords() {
2759 BLSURFPlugin::TCoordsEnfVertexMap_var resultMap = new BLSURFPlugin::TCoordsEnfVertexMap();
2760 const ::BLSURFPlugin_Hypothesis::TCoordsEnfVertexMap coordsEnfVertexMap =
2761 this->GetImpl()->_GetAllEnforcedVerticesByCoords();
2762 resultMap->length((CORBA::ULong) coordsEnfVertexMap.size());
2764 ::BLSURFPlugin_Hypothesis::TCoordsEnfVertexMap::const_iterator it_coords = coordsEnfVertexMap.begin();
2765 ::BLSURFPlugin_Hypothesis::TEnfVertex *currentEnfVertex;
2766 for (int i = 0; it_coords != coordsEnfVertexMap.end(); ++it_coords, ++i) {
2767 currentEnfVertex = (it_coords->second);
2768 BLSURFPlugin::TCoordsEnfVertexElement_var mapElement = new BLSURFPlugin::TCoordsEnfVertexElement();
2769 BLSURFPlugin::TEnfVertexCoords_var coords = new BLSURFPlugin::TEnfVertexCoords();
2770 coords->length((CORBA::ULong) it_coords->first.size());
2771 for (CORBA::ULong ind=0;ind<coords->length();ind++)
2772 coords[ind] = it_coords->first[ind];
2773 mapElement->coords = coords;
2775 BLSURFPlugin::TEnfVertex_var enfVertex = new BLSURFPlugin::TEnfVertex();
2777 enfVertex->name = CORBA::string_dup(currentEnfVertex->name.c_str());
2779 enfVertex->geomEntry = CORBA::string_dup(currentEnfVertex->geomEntry.c_str());
2781 BLSURFPlugin::TEnfVertexCoords_var coords2 = new BLSURFPlugin::TEnfVertexCoords();
2782 coords2->length((CORBA::ULong) currentEnfVertex->coords.size());
2783 for (CORBA::ULong ind=0;ind<coords2->length();ind++)
2784 coords2[ind] = currentEnfVertex->coords[ind];
2785 enfVertex->coords = coords2;
2787 enfVertex->grpName = CORBA::string_dup(currentEnfVertex->grpName.c_str());
2789 BLSURFPlugin::TEntryList_var faceEntryList = new BLSURFPlugin::TEntryList();
2790 faceEntryList->length((CORBA::ULong) currentEnfVertex->faceEntries.size());
2791 ::BLSURFPlugin_Hypothesis::TEntryList::const_iterator it_entry = currentEnfVertex->faceEntries.begin();
2792 for (int ind = 0; it_entry != currentEnfVertex->faceEntries.end();++it_entry, ++ind)
2793 faceEntryList[ind] = CORBA::string_dup((*it_entry).c_str());
2794 enfVertex->faceEntries = faceEntryList;
2796 mapElement->enfVertex = enfVertex;
2798 msg << "Enforced vertex: \n"
2799 << "Name: " << enfVertex->name << "\n";
2800 if (coords->length())
2801 msg << "Coords: " << enfVertex->coords[0] << ", " << enfVertex->coords[1] << ", " << enfVertex->coords[2] << "\n";
2802 msg << "Geom entry: " << enfVertex->geomEntry << "\n"
2803 << "Group Name: " << enfVertex->grpName;
2805 resultMap[i] = mapElement;
2807 return resultMap._retn();
2811 * Returns the list of enforced vertices entries for a given Face entry.
2812 * They are the geom entries of the enforced vertices based on geom shape (vertex, compound, group).
2813 * @return A map of Face entry / List of enforced vertices geom entries
2816 BLSURFPlugin::TFaceEntryEnfVertexEntryListMap* BLSURFPlugin_Hypothesis_i::GetAllEnfVertexEntriesByFace() {
2819 BLSURFPlugin::TFaceEntryEnfVertexEntryListMap_var resultMap = new BLSURFPlugin::TFaceEntryEnfVertexEntryListMap();
2821 const ::BLSURFPlugin_Hypothesis::TFaceEntryEnfVertexEntryListMap entryEnfVertexEntryListMap =
2822 this->GetImpl()->_GetAllEnfVertexEntriesByFace();
2823 resultMap->length((CORBA::ULong) entryEnfVertexEntryListMap.size());
2825 ::BLSURFPlugin_Hypothesis::TEntryList _enfVertexEntryList;
2826 ::BLSURFPlugin_Hypothesis::TFaceEntryEnfVertexEntryListMap::const_iterator it_entry =
2827 entryEnfVertexEntryListMap.begin();
2828 for (int i = 0; it_entry != entryEnfVertexEntryListMap.end(); ++it_entry, ++i) {
2829 BLSURFPlugin::TFaceEntryEnfVertexEntryListMapElement_var mapElement =
2830 new BLSURFPlugin::TFaceEntryEnfVertexEntryListMapElement();
2831 mapElement->faceEntry = CORBA::string_dup(it_entry->first.c_str());
2833 _enfVertexEntryList = it_entry->second;
2834 BLSURFPlugin::TEntryList_var enfVertexEntryList = new BLSURFPlugin::TEntryList();
2835 enfVertexEntryList->length((CORBA::ULong) _enfVertexEntryList.size());
2837 ::BLSURFPlugin_Hypothesis::TEntryList::const_iterator it_enfVertexEntry = _enfVertexEntryList.begin();
2838 for (int j = 0; it_enfVertexEntry != _enfVertexEntryList.end(); ++it_enfVertexEntry, ++j) {
2839 enfVertexEntryList[j] = CORBA::string_dup((*it_enfVertexEntry).c_str());
2841 mapElement->enfVertexEntryList = enfVertexEntryList;
2843 resultMap[i] = mapElement;
2846 return resultMap._retn();
2850 * Returns a map of enforced vertices geom entry / enforced vertex.
2851 * They are the geom entries of the enforced vertices defined with geom shape (vertex, compound, group).
2853 BLSURFPlugin::TEnfVertexEntryEnfVertexMap* BLSURFPlugin_Hypothesis_i::GetAllEnforcedVerticesByEnfVertexEntry() {
2856 BLSURFPlugin::TEnfVertexEntryEnfVertexMap_var resultMap = new BLSURFPlugin::TEnfVertexEntryEnfVertexMap();
2857 const ::BLSURFPlugin_Hypothesis::TEnfVertexEntryEnfVertexMap enfVertexEntryEnfVertexMap =
2858 this->GetImpl()->_GetAllEnforcedVerticesByEnfVertexEntry();
2859 resultMap->length((CORBA::ULong) enfVertexEntryEnfVertexMap.size());
2861 ::BLSURFPlugin_Hypothesis::TEnfVertexEntryEnfVertexMap::const_iterator it_enfVertexEntry = enfVertexEntryEnfVertexMap.begin();
2862 ::BLSURFPlugin_Hypothesis::TEnfVertex *currentEnfVertex;
2863 for (int i = 0; it_enfVertexEntry != enfVertexEntryEnfVertexMap.end(); ++it_enfVertexEntry, ++i) {
2864 currentEnfVertex = it_enfVertexEntry->second;
2865 BLSURFPlugin::TEnfVertexEntryEnfVertexElement_var mapElement = new BLSURFPlugin::TEnfVertexEntryEnfVertexElement();
2866 mapElement->enfVertexEntry = CORBA::string_dup(it_enfVertexEntry->first.c_str());;
2868 BLSURFPlugin::TEnfVertex_var enfVertex = new BLSURFPlugin::TEnfVertex();
2870 enfVertex->name = CORBA::string_dup(currentEnfVertex->name.c_str());
2872 enfVertex->geomEntry = CORBA::string_dup(currentEnfVertex->geomEntry.c_str());
2874 BLSURFPlugin::TEnfVertexCoords_var coords = new BLSURFPlugin::TEnfVertexCoords();
2875 coords->length((CORBA::ULong) currentEnfVertex->coords.size());
2876 for (CORBA::ULong ind=0;ind<coords->length();ind++)
2877 coords[ind] = currentEnfVertex->coords[ind];
2878 enfVertex->coords = coords;
2880 enfVertex->grpName = CORBA::string_dup(currentEnfVertex->grpName.c_str());
2882 BLSURFPlugin::TEntryList_var faceEntryList = new BLSURFPlugin::TEntryList();
2883 faceEntryList->length((CORBA::ULong) currentEnfVertex->faceEntries.size());
2884 ::BLSURFPlugin_Hypothesis::TEntryList::const_iterator it_entry = currentEnfVertex->faceEntries.begin();
2885 for (int ind = 0; it_entry != currentEnfVertex->faceEntries.end();++it_entry, ++ind)
2886 faceEntryList[ind] = CORBA::string_dup((*it_entry).c_str());
2887 enfVertex->faceEntries = faceEntryList;
2890 msg << "Enforced vertex: \n"
2891 << "Name: " << enfVertex->name << "\n";
2892 if (coords->length())
2893 msg << "Coords: " << enfVertex->coords[0] << ", " << enfVertex->coords[1] << ", " << enfVertex->coords[2] << "\n";
2894 msg << "Geom entry: " << enfVertex->geomEntry << "\n"
2895 << "Group Name: " << enfVertex->grpName;
2897 mapElement->enfVertex = enfVertex;
2898 resultMap[i] = mapElement;
2900 return resultMap._retn();
2904 * Erase all enforced vertices
2906 void BLSURFPlugin_Hypothesis_i::ClearAllEnforcedVertices() {
2908 this->GetImpl()->ClearAllEnforcedVertices();
2909 SMESH::TPythonDump() << _this() << ".ClearAllEnforcedVertices()";
2913 * Set/get/unset an enforced vertex on face - OBSOLETE
2915 bool BLSURFPlugin_Hypothesis_i::SetEnforcedVertex(GEOM::GEOM_Object_ptr theFace, CORBA::Double x, CORBA::Double y,
2919 if ((theFace->GetShapeType() != GEOM::FACE) && (theFace->GetShapeType() != GEOM::COMPOUND)) {
2920 THROW_SALOME_CORBA_EXCEPTION("theFace shape type is not FACE or COMPOUND", SALOME::BAD_PARAM);
2923 string theFaceEntry = theFace->GetStudyEntry();
2925 if (theFaceEntry.empty()) {
2926 GEOM::GEOM_Gen_ptr geomGen = SMESH_Gen_i::GetGeomEngine( theFace );
2928 if (theFace->GetShapeType() == GEOM::FACE)
2930 if (theFace->GetShapeType() == GEOM::COMPOUND)
2931 aName = "Compound_";
2932 aName += theFace->GetEntry();
2933 SALOMEDS::SObject_wrap theSFace = geomGen->PublishInStudy(NULL, theFace, aName.c_str());
2934 if (!theSFace->_is_nil())
2935 theFaceEntry = theSFace->GetID();
2937 if (theFaceEntry.empty())
2938 THROW_SALOME_CORBA_EXCEPTION( "Geom object is not published in study" ,SALOME::BAD_PARAM );
2940 return SetEnforcedVertexEntry(theFaceEntry.c_str(), x, y, z);
2941 } catch (SALOME_Exception& ex) {
2942 THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
2947 * Set/get/unset an enforced vertex with name on face
2949 bool BLSURFPlugin_Hypothesis_i::SetEnforcedVertexNamed(GEOM::GEOM_Object_ptr theFace, CORBA::Double x, CORBA::Double y,
2950 CORBA::Double z, const char* theVertexName) {
2953 if ((theFace->GetShapeType() != GEOM::FACE) && (theFace->GetShapeType() != GEOM::COMPOUND)) {
2954 THROW_SALOME_CORBA_EXCEPTION("theFace shape type is not FACE or COMPOUND", SALOME::BAD_PARAM);
2957 string theFaceEntry = theFace->GetStudyEntry();
2959 if (theFaceEntry.empty()) {
2960 GEOM::GEOM_Gen_ptr geomGen = SMESH_Gen_i::GetGeomEngine( theFace );
2962 if (theFace->GetShapeType() == GEOM::FACE)
2964 if (theFace->GetShapeType() == GEOM::COMPOUND)
2965 aName = "Compound_";
2966 aName += theFace->GetEntry();
2967 SALOMEDS::SObject_wrap theSFace = geomGen->PublishInStudy(NULL, theFace, aName.c_str());
2968 if (!theSFace->_is_nil())
2969 theFaceEntry = theSFace->GetID();
2971 if (theFaceEntry.empty())
2972 THROW_SALOME_CORBA_EXCEPTION( "Geom object is not published in study" ,SALOME::BAD_PARAM );
2975 return SetEnforcedVertexEntry(theFaceEntry.c_str(), x, y, z, theVertexName);
2976 } catch (SALOME_Exception& ex) {
2977 THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
2982 * Set/get/unset an enforced vertex with geom object on face
2984 bool BLSURFPlugin_Hypothesis_i::SetEnforcedVertexGeom(GEOM::GEOM_Object_ptr theFace, GEOM::GEOM_Object_ptr theVertex)
2988 if ((theFace->GetShapeType() != GEOM::FACE) && (theFace->GetShapeType() != GEOM::COMPOUND)) {
2989 THROW_SALOME_CORBA_EXCEPTION("theFace shape type is not FACE or COMPOUND", SALOME::BAD_PARAM);
2992 if ((theVertex->GetShapeType() != GEOM::VERTEX) && (theVertex->GetShapeType() != GEOM::COMPOUND)) {
2993 THROW_SALOME_CORBA_EXCEPTION("theVertex shape type is not VERTEX or COMPOUND", SALOME::BAD_PARAM);
2996 // GEOM::GEOM_Gen_ptr geomGen = SMESH_Gen_i::GetGeomEngine( theFace );
2997 // GEOM::GEOM_IMeasureOperations_var measureOp = geomGen->GetIMeasureOperations();
2998 // if (CORBA::is_nil(measureOp))
3001 // CORBA::Double x, y, z;
3003 // measureOp->PointCoordinates(theVertex, x, y, z);
3005 string theFaceEntry = theFace->GetStudyEntry();
3006 string theVertexEntry = theVertex->GetStudyEntry();
3008 GEOM::GEOM_Gen_ptr geomGen = SMESH_Gen_i::GetGeomEngine( theFace );
3011 if (theFaceEntry.empty()) {
3012 if (theFace->GetShapeType() == GEOM::FACE)
3014 if (theFace->GetShapeType() == GEOM::COMPOUND)
3015 aName = "Compound_";
3016 aName += theFace->GetEntry();
3017 SALOMEDS::SObject_wrap theSFace = geomGen->PublishInStudy(NULL, theFace, aName.c_str());
3018 if (!theSFace->_is_nil())
3019 theFaceEntry = theSFace->GetID();
3021 if (theFaceEntry.empty())
3022 THROW_SALOME_CORBA_EXCEPTION( "Geom object is not published in study" ,SALOME::BAD_PARAM );
3024 if (theVertexEntry.empty()) {
3025 if (theVertex->GetShapeType() == GEOM::VERTEX)
3027 if (theVertex->GetShapeType() == GEOM::COMPOUND)
3028 aName = "Compound_";
3029 aName += theVertex->GetEntry();
3030 SALOMEDS::SObject_wrap theSVertex = geomGen->PublishInStudy(NULL, theVertex, aName.c_str());
3031 if (!theSVertex->_is_nil())
3032 theVertexEntry = theSVertex->GetID();
3034 if (theVertexEntry.empty())
3035 THROW_SALOME_CORBA_EXCEPTION( "Geom object is not published in study" ,SALOME::BAD_PARAM );
3037 string theVertexName = theVertex->GetName();
3039 return SetEnforcedVertexEntry(theFaceEntry.c_str(), 0, 0, 0, theVertexName.c_str(), theVertexEntry.c_str());
3040 } catch (SALOME_Exception& ex) {
3041 THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
3046 * Set an enforced vertex with group name on face
3048 bool BLSURFPlugin_Hypothesis_i::SetEnforcedVertexWithGroup(GEOM::GEOM_Object_ptr theFace, CORBA::Double x, CORBA::Double y, CORBA::Double z, const char* theGroupName)
3052 if ((theFace->GetShapeType() != GEOM::FACE) && (theFace->GetShapeType() != GEOM::COMPOUND)) {
3053 THROW_SALOME_CORBA_EXCEPTION("theFace shape type is not FACE or COMPOUND", SALOME::BAD_PARAM);
3056 string theFaceEntry = theFace->GetStudyEntry();
3058 if (theFaceEntry.empty()) {
3059 GEOM::GEOM_Gen_ptr geomGen = SMESH_Gen_i::GetGeomEngine( theFace );
3061 if (theFace->GetShapeType() == GEOM::FACE)
3063 if (theFace->GetShapeType() == GEOM::COMPOUND)
3064 aName = "Compound_";
3065 aName += theFace->GetEntry();
3066 SALOMEDS::SObject_wrap theSFace = geomGen->PublishInStudy(NULL, theFace, aName.c_str());
3067 if (!theSFace->_is_nil())
3068 theFaceEntry = theSFace->GetID();
3070 if (theFaceEntry.empty())
3071 THROW_SALOME_CORBA_EXCEPTION( "Geom object is not published in study" ,SALOME::BAD_PARAM );
3073 return SetEnforcedVertexEntry(theFaceEntry.c_str(), x, y, z, "", "", theGroupName);
3074 } catch (SALOME_Exception& ex) {
3075 THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
3080 * Set an enforced vertex with name and group name on face
3082 bool BLSURFPlugin_Hypothesis_i::SetEnforcedVertexNamedWithGroup(GEOM::GEOM_Object_ptr theFace, CORBA::Double x, CORBA::Double y, CORBA::Double z,
3083 const char* theVertexName, const char* theGroupName)
3087 if ((theFace->GetShapeType() != GEOM::FACE) && (theFace->GetShapeType() != GEOM::COMPOUND)) {
3088 THROW_SALOME_CORBA_EXCEPTION("theFace shape type is not FACE or COMPOUND", SALOME::BAD_PARAM);
3091 string theFaceEntry = theFace->GetStudyEntry();
3093 if (theFaceEntry.empty()) {
3094 GEOM::GEOM_Gen_ptr geomGen = SMESH_Gen_i::GetGeomEngine( theFace );
3096 if (theFace->GetShapeType() == GEOM::FACE)
3098 if (theFace->GetShapeType() == GEOM::COMPOUND)
3099 aName = "Compound_";
3100 aName += theFace->GetEntry();
3101 SALOMEDS::SObject_wrap theSFace = geomGen->PublishInStudy(NULL, theFace, aName.c_str());
3102 if (!theSFace->_is_nil())
3103 theFaceEntry = theSFace->GetID();
3105 if (theFaceEntry.empty())
3106 THROW_SALOME_CORBA_EXCEPTION( "Geom object is not published in study" ,SALOME::BAD_PARAM );
3108 return SetEnforcedVertexEntry(theFaceEntry.c_str(), x, y, z, theVertexName, "", theGroupName);
3109 } catch (SALOME_Exception& ex) {
3110 THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
3115 * Set an enforced vertex with geom entry and group name on face
3117 bool BLSURFPlugin_Hypothesis_i::SetEnforcedVertexGeomWithGroup(GEOM::GEOM_Object_ptr theFace, GEOM::GEOM_Object_ptr theVertex, const char* theGroupName)
3121 if ((theFace->GetShapeType() != GEOM::FACE) && (theFace->GetShapeType() != GEOM::COMPOUND)) {
3122 THROW_SALOME_CORBA_EXCEPTION("theFace shape type is not FACE or COMPOUND", SALOME::BAD_PARAM);
3125 if ((theVertex->GetShapeType() != GEOM::VERTEX) && (theVertex->GetShapeType() != GEOM::COMPOUND)) {
3126 THROW_SALOME_CORBA_EXCEPTION("theVertex shape type is not VERTEX or COMPOUND", SALOME::BAD_PARAM);
3129 string theFaceEntry = theFace->GetStudyEntry();
3130 string theVertexEntry = theVertex->GetStudyEntry();
3132 GEOM::GEOM_Gen_ptr geomGen = SMESH_Gen_i::GetGeomEngine( theFace );
3135 if (theFaceEntry.empty()) {
3136 if (theFace->GetShapeType() == GEOM::FACE)
3138 if (theFace->GetShapeType() == GEOM::COMPOUND)
3139 aName = "Compound_";
3140 aName += theFace->GetEntry();
3141 SALOMEDS::SObject_wrap theSFace = geomGen->PublishInStudy(NULL, theFace, aName.c_str());
3142 if (!theSFace->_is_nil())
3143 theFaceEntry = theSFace->GetID();
3145 if (theFaceEntry.empty())
3146 THROW_SALOME_CORBA_EXCEPTION( "Geom object is not published in study" ,SALOME::BAD_PARAM );
3148 if (theVertexEntry.empty()) {
3149 if (theVertex->GetShapeType() == GEOM::VERTEX)
3151 if (theVertex->GetShapeType() == GEOM::COMPOUND)
3152 aName = "Compound_";
3153 aName += theVertex->GetEntry();
3154 SALOMEDS::SObject_wrap theSVertex = geomGen->PublishInStudy(NULL, theVertex, aName.c_str());
3155 if (!theSVertex->_is_nil())
3156 theVertexEntry = theSVertex->GetID();
3158 if (theVertexEntry.empty())
3159 THROW_SALOME_CORBA_EXCEPTION( "Geom object is not published in study" ,SALOME::BAD_PARAM );
3161 string theVertexName = theVertex->GetName();
3163 return SetEnforcedVertexEntry(theFaceEntry.c_str(), 0, 0, 0, theVertexName.c_str(), theVertexEntry.c_str(), theGroupName);
3164 } catch (SALOME_Exception& ex) {
3165 THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
3169 //Enable internal enforced vertices on specific face if requested by user
3171 // * Are internal enforced vertices used for a face ?
3173 //CORBA::Boolean BLSURFPlugin_Hypothesis_i::GetInternalEnforcedVertex(GEOM::GEOM_Object_ptr theFace)
3175 // ASSERT(myBaseImpl);
3177 // if ((theFace->GetShapeType() != GEOM::FACE) && (theFace->GetShapeType() != GEOM::COMPOUND)) {
3178 // THROW_SALOME_CORBA_EXCEPTION("theFace shape type is not FACE or COMPOUND", SALOME::BAD_PARAM);
3181 // string theFaceEntry = theFace->GetStudyEntry();
3183 // if (theFaceEntry.empty()) {
3184 // GEOM::GEOM_Gen_ptr geomGen = SMESH_Gen_i::GetGeomEngine( theFace );
3186 // if (theFace->GetShapeType() == GEOM::FACE)
3188 // if (theFace->GetShapeType() == GEOM::COMPOUND)
3189 // aName = "Compound_";
3190 // aName += theFace->GetEntry();
3191 // SALOMEDS::SObject_wrap theSFace = geomGen->PublishInStudy(NULL, theFace, aName.c_str());
3192 // if (!theSFace->_is_nil())
3193 // theFaceEntry = theSFace->GetID();
3195 // if (theFaceEntry.empty())
3196 // THROW_SALOME_CORBA_EXCEPTION( "Geom object is not published in study" ,SALOME::BAD_PARAM );
3199 // return GetInternalEnforcedVertexEntry(theFaceEntry.c_str());
3200 // } catch (SALOME_Exception& ex) {
3201 // THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
3206 * Get the list of all enforced vertices
3208 BLSURFPlugin::TEnfVertexList* BLSURFPlugin_Hypothesis_i::GetEnforcedVertices(GEOM::GEOM_Object_ptr theFace)
3212 if ((theFace->GetShapeType() != GEOM::FACE) && (theFace->GetShapeType() != GEOM::COMPOUND)) {
3213 THROW_SALOME_CORBA_EXCEPTION("theFace shape type is not FACE or COMPOUND", SALOME::BAD_PARAM);
3216 string theFaceEntry = theFace->GetStudyEntry();
3218 if (theFaceEntry.empty()) {
3219 GEOM::GEOM_Gen_ptr geomGen = SMESH_Gen_i::GetGeomEngine( theFace );
3221 if (theFace->GetShapeType() == GEOM::FACE)
3223 if (theFace->GetShapeType() == GEOM::COMPOUND)
3224 aName = "Compound_";
3225 aName += theFace->GetEntry();
3226 SALOMEDS::SObject_wrap theSFace = geomGen->PublishInStudy(NULL, theFace, aName.c_str());
3227 if (!theSFace->_is_nil())
3228 theFaceEntry = theSFace->GetID();
3230 if (theFaceEntry.empty())
3231 THROW_SALOME_CORBA_EXCEPTION( "Geom object is not published in study" ,SALOME::BAD_PARAM );
3234 return GetEnforcedVerticesEntry(theFaceEntry.c_str());
3235 } catch (SALOME_Exception& ex) {
3236 THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
3240 bool BLSURFPlugin_Hypothesis_i::UnsetEnforcedVertex(GEOM::GEOM_Object_ptr theFace, CORBA::Double x, CORBA::Double y,
3244 if ((theFace->GetShapeType() != GEOM::FACE) && (theFace->GetShapeType() != GEOM::COMPOUND)) {
3245 THROW_SALOME_CORBA_EXCEPTION("theFace shape type is not FACE or COMPOUND", SALOME::BAD_PARAM);
3248 string theFaceEntry = theFace->GetStudyEntry();
3250 if (theFaceEntry.empty()) {
3251 GEOM::GEOM_Gen_ptr geomGen = SMESH_Gen_i::GetGeomEngine( theFace );
3253 if (theFace->GetShapeType() == GEOM::FACE)
3255 if (theFace->GetShapeType() == GEOM::COMPOUND)
3256 aName = "Compound_";
3257 aName += theFace->GetEntry();
3258 SALOMEDS::SObject_wrap theSFace = geomGen->PublishInStudy(NULL, theFace, aName.c_str());
3259 if (!theSFace->_is_nil())
3260 theFaceEntry = theSFace->GetID();
3262 if (theFaceEntry.empty())
3263 THROW_SALOME_CORBA_EXCEPTION( "Geom object is not published in study" ,SALOME::BAD_PARAM );
3266 return UnsetEnforcedVertexEntry(theFaceEntry.c_str(), x, y, z);
3267 } catch (SALOME_Exception& ex) {
3268 THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
3272 bool BLSURFPlugin_Hypothesis_i::UnsetEnforcedVertexGeom(GEOM::GEOM_Object_ptr theFace, GEOM::GEOM_Object_ptr theVertex)
3276 if ((theFace->GetShapeType() != GEOM::FACE) && (theFace->GetShapeType() != GEOM::COMPOUND)) {
3277 THROW_SALOME_CORBA_EXCEPTION("theFace shape type is not FACE or COMPOUND", SALOME::BAD_PARAM);
3279 if ((theVertex->GetShapeType() != GEOM::VERTEX) && (theVertex->GetShapeType() != GEOM::COMPOUND)) {
3280 THROW_SALOME_CORBA_EXCEPTION("theVertex shape type is not VERTEX or COMPOUND", SALOME::BAD_PARAM);
3283 // GEOM::GEOM_Gen_ptr geomGen = SMESH_Gen_i::GetGeomEngine( theFace );
3284 // GEOM::GEOM_IMeasureOperations_var measureOp = geomGen->GetIMeasureOperations();
3285 // if (CORBA::is_nil(measureOp))
3288 // CORBA::Double x, y, z;
3290 // measureOp->PointCoordinates(theVertex, x, y, z);
3292 std::string theFaceEntry = theFace->GetStudyEntry();
3293 std::string theVertexEntry = theVertex->GetStudyEntry();
3295 GEOM::GEOM_Gen_ptr geomGen = SMESH_Gen_i::GetGeomEngine( theFace );
3298 if (theFaceEntry.empty()) {
3299 if (theFace->GetShapeType() == GEOM::FACE)
3301 if (theFace->GetShapeType() == GEOM::COMPOUND)
3302 aName = "Compound_";
3303 aName += theFace->GetEntry();
3304 SALOMEDS::SObject_wrap theSFace = geomGen->PublishInStudy(NULL, theFace, aName.c_str());
3305 if (!theSFace->_is_nil())
3306 theFaceEntry = theSFace->GetID();
3308 if (theFaceEntry.empty())
3309 THROW_SALOME_CORBA_EXCEPTION( "Geom object is not published in study" ,SALOME::BAD_PARAM );
3311 if (theVertexEntry.empty()) {
3312 if (theVertex->GetShapeType() == GEOM::VERTEX)
3314 if (theVertex->GetShapeType() == GEOM::COMPOUND)
3315 aName = "Compound_";
3316 aName += theVertex->GetEntry();
3317 SALOMEDS::SObject_wrap theSVertex = geomGen->PublishInStudy(NULL, theVertex, aName.c_str());
3318 if (!theSVertex->_is_nil())
3319 theVertexEntry = theSVertex->GetID();
3321 if (theVertexEntry.empty())
3322 THROW_SALOME_CORBA_EXCEPTION( "Geom object is not published in study" ,SALOME::BAD_PARAM );
3326 return UnsetEnforcedVertexEntry(theFaceEntry.c_str(), 0, 0, 0, theVertexEntry.c_str());
3327 } catch (SALOME_Exception& ex) {
3328 THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
3332 bool BLSURFPlugin_Hypothesis_i::UnsetEnforcedVertices(GEOM::GEOM_Object_ptr theFace) {
3335 if ((theFace->GetShapeType() != GEOM::FACE) && (theFace->GetShapeType() != GEOM::COMPOUND)) {
3336 THROW_SALOME_CORBA_EXCEPTION("theFace shape type is not FACE or COMPOUND", SALOME::BAD_PARAM);
3339 string theFaceEntry = theFace->GetStudyEntry();
3341 if (theFaceEntry.empty()) {
3342 GEOM::GEOM_Gen_ptr geomGen = SMESH_Gen_i::GetGeomEngine( theFace );
3344 if (theFace->GetShapeType() == GEOM::FACE)
3346 if (theFace->GetShapeType() == GEOM::COMPOUND)
3347 aName = "Compound_";
3348 aName += theFace->GetEntry();
3349 SALOMEDS::SObject_wrap theSFace = geomGen->PublishInStudy(NULL, theFace, aName.c_str());
3350 if (!theSFace->_is_nil())
3351 theFaceEntry = theSFace->GetID();
3353 if (theFaceEntry.empty())
3354 THROW_SALOME_CORBA_EXCEPTION( "Geom object is not published in study" ,SALOME::BAD_PARAM );
3358 return UnsetEnforcedVerticesEntry(theFaceEntry.c_str());
3359 } catch (SALOME_Exception& ex) {
3360 THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
3365 * Set/get/unset an enforced vertex on face - NEW (no face)
3367 bool BLSURFPlugin_Hypothesis_i::AddEnforcedVertex(CORBA::Double x, CORBA::Double y, CORBA::Double z)
3372 return SetEnforcedVertexEntry("", x, y, z);
3373 } catch (SALOME_Exception& ex) {
3374 THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
3379 * Set/get/unset an enforced vertex with name on face
3381 bool BLSURFPlugin_Hypothesis_i::AddEnforcedVertexNamed(CORBA::Double x, CORBA::Double y, CORBA::Double z, const char* theVertexName)
3384 return SetEnforcedVertexEntry("", x, y, z, theVertexName);
3385 } catch (SALOME_Exception& ex) {
3386 THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
3391 * Set/get/unset an enforced vertex with geom object on face
3393 bool BLSURFPlugin_Hypothesis_i::AddEnforcedVertexGeom(GEOM::GEOM_Object_ptr theVertex)
3395 if ((theVertex->GetShapeType() != GEOM::VERTEX) && (theVertex->GetShapeType() != GEOM::COMPOUND)) {
3396 THROW_SALOME_CORBA_EXCEPTION("theVertex shape type is not VERTEX or COMPOUND", SALOME::BAD_PARAM);
3398 string theVertexEntry = theVertex->GetStudyEntry();
3400 GEOM::GEOM_Gen_ptr geomGen = SMESH_Gen_i::GetGeomEngine( theVertex );
3403 if (theVertexEntry.empty()) {
3404 if (theVertex->GetShapeType() == GEOM::VERTEX)
3406 if (theVertex->GetShapeType() == GEOM::COMPOUND)
3407 aName = "Compound_";
3408 aName += theVertex->GetEntry();
3409 SALOMEDS::SObject_wrap theSVertex = geomGen->PublishInStudy( NULL, theVertex, aName.c_str());
3410 if (!theSVertex->_is_nil())
3411 theVertexEntry = theSVertex->GetID();
3413 if (theVertexEntry.empty())
3414 THROW_SALOME_CORBA_EXCEPTION( "Geom object is not published in study" ,SALOME::BAD_PARAM );
3416 string theVertexName = theVertex->GetName();
3418 return SetEnforcedVertexEntry("", 0, 0, 0, theVertexName.c_str(), theVertexEntry.c_str());
3419 } catch (SALOME_Exception& ex) {
3420 THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
3425 * Set an enforced vertex with group name on face
3427 bool BLSURFPlugin_Hypothesis_i::AddEnforcedVertexWithGroup(CORBA::Double x, CORBA::Double y, CORBA::Double z, const char* theGroupName)
3432 return SetEnforcedVertexEntry("", x, y, z, "", "", theGroupName);
3433 } catch (SALOME_Exception& ex) {
3434 THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
3439 * Set an enforced vertex with name and group name on face
3441 bool BLSURFPlugin_Hypothesis_i::AddEnforcedVertexNamedWithGroup(CORBA::Double x, CORBA::Double y, CORBA::Double z,
3442 const char* theVertexName, const char* theGroupName)
3447 return SetEnforcedVertexEntry("", x, y, z, theVertexName, "", theGroupName);
3448 } catch (SALOME_Exception& ex) {
3449 THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
3454 * Set an enforced vertex with geom entry and group name on face
3456 bool BLSURFPlugin_Hypothesis_i::AddEnforcedVertexGeomWithGroup(GEOM::GEOM_Object_ptr theVertex, const char* theGroupName)
3458 if ((theVertex->GetShapeType() != GEOM::VERTEX) && (theVertex->GetShapeType() != GEOM::COMPOUND)) {
3459 THROW_SALOME_CORBA_EXCEPTION("theVertex shape type is not VERTEX or COMPOUND", SALOME::BAD_PARAM);
3462 string theVertexEntry = theVertex->GetStudyEntry();
3464 GEOM::GEOM_Gen_ptr geomGen = SMESH_Gen_i::GetGeomEngine( theVertex );
3467 if (theVertexEntry.empty()) {
3468 if (theVertex->GetShapeType() == GEOM::VERTEX)
3470 if (theVertex->GetShapeType() == GEOM::COMPOUND)
3471 aName = "Compound_";
3472 aName += theVertex->GetEntry();
3473 SALOMEDS::SObject_wrap theSVertex = geomGen->PublishInStudy( NULL, theVertex, aName.c_str());
3474 if (!theSVertex->_is_nil())
3475 theVertexEntry = theSVertex->GetID();
3477 if (theVertexEntry.empty())
3478 THROW_SALOME_CORBA_EXCEPTION( "Geom object is not published in study" ,SALOME::BAD_PARAM );
3480 string theVertexName = theVertex->GetName();
3482 return SetEnforcedVertexEntry("", 0, 0, 0, theVertexName.c_str(), theVertexEntry.c_str(), theGroupName);
3483 } catch (SALOME_Exception& ex) {
3484 THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
3488 bool BLSURFPlugin_Hypothesis_i::RemoveEnforcedVertex(CORBA::Double x, CORBA::Double y, CORBA::Double z)
3491 return UnsetEnforcedVertexEntry("", x, y, z);
3492 } catch (SALOME_Exception& ex) {
3493 THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
3497 bool BLSURFPlugin_Hypothesis_i::RemoveEnforcedVertexGeom(GEOM::GEOM_Object_ptr theVertex)
3499 if ((theVertex->GetShapeType() != GEOM::VERTEX) && (theVertex->GetShapeType() != GEOM::COMPOUND)) {
3500 THROW_SALOME_CORBA_EXCEPTION("theVertex shape type is not VERTEX or COMPOUND", SALOME::BAD_PARAM);
3502 std::string theVertexEntry = theVertex->GetStudyEntry();
3504 GEOM::GEOM_Gen_ptr geomGen = SMESH_Gen_i::GetGeomEngine( theVertex );
3507 if (theVertexEntry.empty()) {
3508 if (theVertex->GetShapeType() == GEOM::VERTEX)
3510 if (theVertex->GetShapeType() == GEOM::COMPOUND)
3511 aName = "Compound_";
3512 aName += theVertex->GetEntry();
3513 SALOMEDS::SObject_wrap theSVertex = geomGen->PublishInStudy( NULL, theVertex, aName.c_str());
3514 if (!theSVertex->_is_nil())
3515 theVertexEntry = theSVertex->GetID();
3517 if (theVertexEntry.empty())
3518 THROW_SALOME_CORBA_EXCEPTION( "Geom object is not published in study" ,SALOME::BAD_PARAM );
3521 return UnsetEnforcedVertexEntry("", 0, 0, 0, theVertexEntry.c_str());
3522 } catch (SALOME_Exception& ex) {
3523 THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
3527 bool BLSURFPlugin_Hypothesis_i::RemoveEnforcedVertices()
3530 return UnsetEnforcedVerticesEntry("");
3531 } catch (SALOME_Exception& ex) {
3532 THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
3537 * Set/get/unset an enforced vertex on geom object given by entry
3539 bool BLSURFPlugin_Hypothesis_i::SetEnforcedVertexEntry(const char* theFaceEntry,
3543 const char* theVertexName,
3544 const char* theVertexEntry,
3545 const char* theGroupName)
3547 bool newValue = false;
3548 if (string(theVertexEntry).empty()) {
3550 ::BLSURFPlugin_Hypothesis::TEnfVertexCoordsList coordsList =
3551 this->GetImpl()->GetEnfVertexCoordsList(theFaceEntry);
3552 ::BLSURFPlugin_Hypothesis::TEnfVertexCoords coords;
3553 coords.push_back(x);
3554 coords.push_back(y);
3555 coords.push_back(z);
3556 if (coordsList.find(coords) == coordsList.end()) {
3559 ::BLSURFPlugin_Hypothesis::TEnfVertex *enfVertex = this->GetImpl()->GetEnfVertex(coords);
3560 if ((enfVertex->name != theVertexName) || (enfVertex->grpName != theGroupName)) {
3564 } catch (const std::invalid_argument& ex) {
3565 // no enforced vertex for entry
3569 if (string(theVertexName).empty()) {
3570 if (string(theGroupName).empty())
3571 SMESH::TPythonDump() << _this() << ".AddEnforcedVertex(" << x << ", " << y << ", " << z << ")";
3573 SMESH::TPythonDump() << _this() << ".AddEnforcedVertexWithGroup(" << x << ", " << y << ", " << z << ", \"" << theGroupName << "\")";
3576 if (string(theGroupName).empty())
3577 SMESH::TPythonDump() << _this() << ".AddEnforcedVertexNamed(" << x << ", " << y << ", " << z << ", \"" << theVertexName << "\")";
3579 SMESH::TPythonDump() << _this() << ".AddEnforcedVertexNamedWithGroup(" << x << ", " << y << ", " << z << ", \""
3580 << theVertexName << "\", \"" << theGroupName << "\")";
3585 ::BLSURFPlugin_Hypothesis::TEntryList enfVertexEntryList = this->GetImpl()->GetEnfVertexEntryList(theFaceEntry);
3586 ::BLSURFPlugin_Hypothesis::TEntryList::const_iterator it = enfVertexEntryList.find(theVertexEntry);
3587 if ( it == enfVertexEntryList.end()) {
3591 ::BLSURFPlugin_Hypothesis::TEnfVertex *enfVertex = this->GetImpl()->GetEnfVertex((*it));
3592 if ((enfVertex->name != theVertexName) || (enfVertex->grpName != theGroupName)) {
3596 } catch (const std::invalid_argument& ex) {
3597 // no enforced vertex for entry
3601 if (string(theGroupName).empty())
3602 SMESH::TPythonDump() << _this() << ".AddEnforcedVertexGeom(" << theVertexEntry << ")";
3604 SMESH::TPythonDump() << _this() << ".AddEnforcedVertexGeomWithGroup(" << theVertexEntry << ", \"" << theGroupName << "\")";
3609 this->GetImpl()->SetEnforcedVertex(theFaceEntry, theVertexName, theVertexEntry, theGroupName, x, y, z);
3614 BLSURFPlugin::TEnfVertexList* BLSURFPlugin_Hypothesis_i::GetEnforcedVerticesEntry(const char* entry)
3617 BLSURFPlugin::TEnfVertexList_var vertexList = new BLSURFPlugin::TEnfVertexList();
3618 ::BLSURFPlugin_Hypothesis::TEnfVertexList _vList = this->GetImpl()->GetEnfVertexList(entry);
3619 vertexList->length((CORBA::ULong) _vList.size());
3620 ::BLSURFPlugin_Hypothesis::TEnfVertexList::const_iterator evlIt = _vList.begin();
3621 for (int i = 0; evlIt != _vList.end(); ++evlIt, ++i) {
3622 ::BLSURFPlugin_Hypothesis::TEnfVertex *_enfVertex = (*evlIt);
3624 BLSURFPlugin::TEnfVertex_var enfVertex = new BLSURFPlugin::TEnfVertex();
3627 enfVertex->name = CORBA::string_dup(_enfVertex->name.c_str());
3628 // Geom Vertex Entry
3629 enfVertex->geomEntry = CORBA::string_dup(_enfVertex->geomEntry.c_str());
3631 BLSURFPlugin::TEnfVertexCoords_var coords = new BLSURFPlugin::TEnfVertexCoords();
3632 coords->length((CORBA::ULong) _enfVertex->coords.size());
3633 for ( CORBA::ULong ind = 0; ind < coords->length(); ind++ )
3634 coords[ind] = _enfVertex->coords[ind];
3635 enfVertex->coords = coords;
3637 enfVertex->grpName = CORBA::string_dup(_enfVertex->grpName.c_str());
3639 BLSURFPlugin::TEntryList_var faceEntryList = new BLSURFPlugin::TEntryList();
3640 faceEntryList->length((CORBA::ULong) _enfVertex->faceEntries.size());
3641 ::BLSURFPlugin_Hypothesis::TEntryList::const_iterator it_entry = _enfVertex->faceEntries.begin();
3642 for (int ind = 0; it_entry != _enfVertex->faceEntries.end();++it_entry, ++ind)
3643 faceEntryList[ind] = CORBA::string_dup((*it_entry).c_str());
3644 enfVertex->faceEntries = faceEntryList;
3646 vertexList[i] = enfVertex;
3648 return vertexList._retn();
3649 } catch (const std::invalid_argument& ex) {
3650 SALOME::ExceptionStruct ExDescription;
3651 ExDescription.text = ex.what();
3652 ExDescription.type = SALOME::BAD_PARAM;
3653 ExDescription.sourceFile = "BLSURFPlugin_Hypothesis_i::GetEnforcedVerticesEntry(entry)";
3654 ExDescription.lineNumber = 1385;
3655 throw SALOME::SALOME_Exception(ExDescription);
3656 } catch (const std::exception& ex) {
3657 std::cout << "Exception: " << ex.what() << std::endl;
3658 THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
3662 bool BLSURFPlugin_Hypothesis_i::UnsetEnforcedVertexEntry(const char* theFaceEntry, CORBA::Double x, CORBA::Double y, CORBA::Double z, const char* theVertexEntry)
3668 res = this->GetImpl()->ClearEnforcedVertex(theFaceEntry, x, y, z, theVertexEntry);
3670 if (string(theVertexEntry).empty())
3671 SMESH::TPythonDump() << "isDone = " << _this() << ".RemoveEnforcedVertex(" << x << ", " << y << ", " << z
3674 SMESH::TPythonDump() << "isDone = " << _this() << ".RemoveEnforcedVertexGeom(" << theVertexEntry << ")";
3676 } catch (const std::invalid_argument& ex) {
3678 } catch (const std::exception& ex) {
3679 std::cout << "Exception: " << ex.what() << std::endl;
3680 THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
3685 bool BLSURFPlugin_Hypothesis_i::UnsetEnforcedVerticesEntry(const char* theFaceEntry)
3690 this->GetImpl()->ClearEnforcedVertices(theFaceEntry);
3691 SMESH::TPythonDump() << _this() << ".RemoveEnforcedVertices()";
3692 } catch (const std::invalid_argument& ex) {
3694 } catch (const std::exception& ex) {
3695 THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
3701 //=============================================================================
3703 * BLSURFPlugin_Hypothesis_i::SetInternalEnforcedVertexAllFaces
3707 //=============================================================================
3708 void BLSURFPlugin_Hypothesis_i::SetInternalEnforcedVertexAllFaces(CORBA::Boolean theValue)
3711 this->GetImpl()->SetInternalEnforcedVertexAllFaces(theValue);
3712 std::string theValueStr = theValue ? "True" : "False";
3713 SMESH::TPythonDump() << _this() << ".SetInternalEnforcedVertexAllFaces( " << theValueStr.c_str() << " )";
3716 //=============================================================================
3718 * BLSURFPlugin_Hypothesis_i::GetInternalEnforcedVertexAllFaces
3722 //=============================================================================
3723 CORBA::Boolean BLSURFPlugin_Hypothesis_i::GetInternalEnforcedVertexAllFaces()
3726 return this->GetImpl()->_GetInternalEnforcedVertexAllFaces();
3729 //=============================================================================
3731 * BLSURFPlugin_Hypothesis_i::SetInternalEnforcedVertexAllFacesGroup
3735 //=============================================================================
3736 void BLSURFPlugin_Hypothesis_i::SetInternalEnforcedVertexAllFacesGroup(const char* groupName)
3739 this->GetImpl()->SetInternalEnforcedVertexAllFacesGroup(groupName);
3740 SMESH::TPythonDump() << _this() << ".SetInternalEnforcedVertexAllFacesGroup( \"" << groupName << "\" )";
3743 //=============================================================================
3745 * BLSURFPlugin_Hypothesis_i::GetInternalEnforcedVertexAllFacesGroup
3749 //=============================================================================
3750 char* BLSURFPlugin_Hypothesis_i::GetInternalEnforcedVertexAllFacesGroup()
3753 return CORBA::string_dup(this->GetImpl()->_GetInternalEnforcedVertexAllFacesGroup().c_str());
3757 * Enable internal enforced vertices on specific face if requested by user
3759 void BLSURFPlugin_Hypothesis_i::SetInternalEnforcedVertex(GEOM::GEOM_Object_ptr theFace, CORBA::Boolean toEnforceInternalVertices)
3762 SetInternalEnforcedVertexWithGroup(theFace, toEnforceInternalVertices);
3763 } catch (SALOME_Exception& ex) {
3764 THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
3768 void BLSURFPlugin_Hypothesis_i::SetInternalEnforcedVertexWithGroup(GEOM::GEOM_Object_ptr theFace, CORBA::Boolean toEnforceInternalVertices, const char* theGroupName)
3770 if ((theFace->GetShapeType() != GEOM::FACE) && (theFace->GetShapeType() != GEOM::COMPOUND)) {
3771 THROW_SALOME_CORBA_EXCEPTION("theFace shape type is not FACE or COMPOUND", SALOME::BAD_PARAM);
3774 string theFaceEntry = theFace->GetStudyEntry();
3776 if (theFaceEntry.empty()) {
3777 GEOM::GEOM_Gen_ptr geomGen = SMESH_Gen_i::GetGeomEngine( theFace );
3778 SMESH_Gen_i *smeshGen = SMESH_Gen_i::GetSMESHGen();
3780 if (theFace->GetShapeType() == GEOM::FACE)
3782 if (theFace->GetShapeType() == GEOM::COMPOUND)
3783 aName = "Compound_";
3784 aName += theFace->GetEntry();
3785 SALOMEDS::SObject_wrap theSFace = geomGen->PublishInStudy(NULL, theFace, aName.c_str());
3786 if (!theSFace->_is_nil())
3787 theFaceEntry = theSFace->GetID();
3789 if (theFaceEntry.empty())
3790 THROW_SALOME_CORBA_EXCEPTION( "Geom object is not published in study" ,SALOME::BAD_PARAM );
3793 SetInternalEnforcedVertexEntry(theFaceEntry.c_str(), toEnforceInternalVertices, theGroupName);
3794 } catch (SALOME_Exception& ex) {
3795 THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
3799 void BLSURFPlugin_Hypothesis_i::SetInternalEnforcedVertexEntry(const char* theFaceEntry, CORBA::Boolean toEnforceInternalVertices, const char* theGroupName)
3803 this->GetImpl()->SetInternalEnforcedVertex(theFaceEntry, toEnforceInternalVertices, theGroupName);
3804 std::string theValueStr = toEnforceInternalVertices ? "True" : "False";
3805 if (string(theGroupName).empty())
3806 SMESH::TPythonDump() << _this() << ".SetInternalEnforcedVertex( " << theFaceEntry << ", " << theValueStr.c_str() << " )";
3808 SMESH::TPythonDump() << _this() << ".SetInternalEnforcedVertexWithGroup( " << theFaceEntry << ", " << theValueStr.c_str() << ", \"" << theGroupName << "\" )";
3809 } catch (const std::exception& ex) {
3810 std::cout << "Exception: " << ex.what() << std::endl;
3811 THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
3818 char* BLSURFPlugin_Hypothesis_i::GetEnforcedVertexGroupName(CORBA::Double x, CORBA::Double y, CORBA::Double z)
3823 return CORBA::string_dup( this->GetImpl()->GetEnforcedVertexGroupName(x, y, z).c_str());
3825 catch (const std::invalid_argument& ex) {
3826 SALOME::ExceptionStruct ExDescription;
3827 ExDescription.text = ex.what();
3828 ExDescription.type = SALOME::BAD_PARAM;
3829 ExDescription.sourceFile = "BLSURFPlugin_Hypothesis_i::GetEnforcedVertexGroupName(entry)";
3830 ExDescription.lineNumber = 1146;
3831 throw SALOME::SALOME_Exception(ExDescription);
3833 catch (SALOME_Exception& ex) {
3834 THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
3840 void BLSURFPlugin_Hypothesis_i::SetEnforcedVertexGroupName(CORBA::Double x, CORBA::Double y, CORBA::Double z, const char* groupName)
3844 this->GetImpl()->SetEnforcedVertexGroupName(x, y, z, groupName);
3846 catch (const std::invalid_argument& ex) {
3847 SALOME::ExceptionStruct ExDescription;
3848 ExDescription.text = ex.what();
3849 ExDescription.type = SALOME::BAD_PARAM;
3850 ExDescription.sourceFile = "BLSURFPlugin_Hypothesis::SetEnforcedVertexGroupName(x,y,z)";
3851 ExDescription.lineNumber = 1170;
3852 throw SALOME::SALOME_Exception(ExDescription);
3854 catch (SALOME_Exception& ex) {
3855 THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
3858 SMESH::TPythonDump() << _this() << ".SetEnforcedVertexGroupName("
3859 << x << ", " << y << ", " << z << ", '" << groupName << "' )";
3863 ///////////////////////
3865 ///////////////////////
3867 ///////////////////////
3870 std::string BLSURFPlugin_Hypothesis_i::ShapeTypeToString(GEOM::shape_type theShapeType)
3872 std::map<GEOM::shape_type, std::string> MapShapeTypeToString;
3873 MapShapeTypeToString[GEOM::COMPOUND] = std::string("COMPOUND");
3874 MapShapeTypeToString[GEOM::COMPSOLID] = std::string("COMPSOLID");
3875 MapShapeTypeToString[GEOM::SOLID] = std::string("SOLID");
3876 MapShapeTypeToString[GEOM::SHELL] = std::string("SHELL");
3877 MapShapeTypeToString[GEOM::FACE] = std::string("FACE");
3878 MapShapeTypeToString[GEOM::WIRE] = std::string("WIRE");
3879 MapShapeTypeToString[GEOM::EDGE] = std::string("EDGE");
3880 MapShapeTypeToString[GEOM::VERTEX] = std::string("VERTEX");
3881 MapShapeTypeToString[GEOM::SHAPE] = std::string("SHAPE");
3882 std::string txtShapeType = MapShapeTypeToString[theShapeType];
3883 return txtShapeType;
3886 void BLSURFPlugin_Hypothesis_i::CheckShapeTypes(GEOM::GEOM_Object_ptr shape, std::vector<GEOM::shape_type> theShapeTypes)
3888 // Check shape types
3890 std::stringstream typesTxt;
3891 for (std::size_t i=0; i<theShapeTypes.size(); i++)
3893 GEOM::shape_type theShapeType = theShapeTypes[i];
3894 if (shape->GetShapeType() == theShapeType)
3896 typesTxt << ShapeTypeToString(theShapeType);
3897 if (i < theShapeTypes.size()-1 )
3902 std::stringstream msg;
3903 msg << "shape type is not in" << typesTxt.str();
3904 THROW_SALOME_CORBA_EXCEPTION(msg.str().c_str(), SALOME::BAD_PARAM);
3908 void BLSURFPlugin_Hypothesis_i::CheckShapeType(GEOM::GEOM_Object_ptr shape, GEOM::shape_type theShapeType)
3911 if (shape->GetShapeType() != theShapeType) {
3912 std::stringstream msg;
3913 msg << "shape shape type is not " << ShapeTypeToString(theShapeType);
3914 THROW_SALOME_CORBA_EXCEPTION(msg.str().c_str(), SALOME::BAD_PARAM);
3918 std::string BLSURFPlugin_Hypothesis_i::PublishIfNeeded(GEOM::GEOM_Object_ptr shape, GEOM::shape_type theShapeType, std::string prefix)
3920 // Check shape is published in the object browser
3921 string shapeEntry = shape->GetStudyEntry();
3923 GEOM::GEOM_Gen_ptr geomGen = SMESH_Gen_i::GetGeomEngine( shape );
3926 // Publish shape if needed
3927 if (shapeEntry.empty()) {
3928 if (shape->GetShapeType() == theShapeType)
3930 aName += shape->GetEntry();
3931 SALOMEDS::SObject_wrap theSFace1 = geomGen->PublishInStudy(NULL, shape, aName.c_str());
3932 if (!theSFace1->_is_nil())
3933 shapeEntry = theSFace1->GetID();
3935 if (shapeEntry.empty())
3936 THROW_SALOME_CORBA_EXCEPTION( "Geom object is not published in study" ,SALOME::BAD_PARAM );
3940 // Format the output of two vectors to use it in MESSAGE and PythonDump
3941 std::string BLSURFPlugin_Hypothesis_i::FormatVerticesEntries(vector<string> &theSourceVerticesEntries, vector<string> &theTargetVerticesEntries)
3943 std::stringstream listEntriesTxt;
3945 if (!theSourceVerticesEntries.empty())
3947 listEntriesTxt << ", [" ;
3949 for (std::vector<std::string>::const_iterator it = theSourceVerticesEntries.begin(); it != theSourceVerticesEntries.end(); it++, i++)
3952 listEntriesTxt << ", ";
3953 listEntriesTxt << *it;
3956 listEntriesTxt << "], [" ;
3958 for (std::vector<std::string>::const_iterator it = theTargetVerticesEntries.begin(); it != theTargetVerticesEntries.end(); it++, i++)
3961 listEntriesTxt << ", ";
3962 listEntriesTxt << *it;
3964 listEntriesTxt << "]" ;
3966 return listEntriesTxt.str();
3970 * Erase all PreCad periodicity associations
3972 void BLSURFPlugin_Hypothesis_i::ClearPreCadPeriodicityVectors() {
3974 this->GetImpl()->ClearPreCadPeriodicityVectors();
3975 SMESH::TPythonDump() << _this() << ".ClearPreCadPeriodicityVectors()";
3978 BLSURFPlugin::TPeriodicityList* BLSURFPlugin_Hypothesis_i::GetPreCadFacesPeriodicityVector()
3980 const ::BLSURFPlugin_Hypothesis::TPreCadPeriodicityVector preCadPeriodicityVector =
3981 this->GetImpl()->_GetPreCadFacesPeriodicityVector();
3983 BLSURFPlugin::TPeriodicityList_var periodicityList = PreCadVectorToSequence(preCadPeriodicityVector);
3985 return periodicityList._retn();
3988 BLSURFPlugin::TPeriodicityList* BLSURFPlugin_Hypothesis_i::GetPreCadEdgesPeriodicityVector()
3990 const ::BLSURFPlugin_Hypothesis::TPreCadPeriodicityVector preCadPeriodicityVector =
3991 this->GetImpl()->_GetPreCadEdgesPeriodicityVector();
3993 BLSURFPlugin::TPeriodicityList_var periodicityList = PreCadVectorToSequence(preCadPeriodicityVector);
3995 return periodicityList._retn();
3998 // convert a vector preCadPeriodicityVector into TPeriodicityList Corba sequence
3999 BLSURFPlugin::TPeriodicityList* BLSURFPlugin_Hypothesis_i::PreCadVectorToSequence(const ::BLSURFPlugin_Hypothesis::TPreCadPeriodicityVector& preCadPeriodicityVector)
4001 BLSURFPlugin::TPeriodicityList_var periodicityList = new BLSURFPlugin::TPeriodicityList();
4003 periodicityList->length((CORBA::ULong) preCadPeriodicityVector.size());
4005 for ( CORBA::ULong i = 0; i<preCadPeriodicityVector.size(); i++)
4007 ::BLSURFPlugin_Hypothesis::TPreCadPeriodicity preCadPeriodicityVector_i = preCadPeriodicityVector[i];
4009 BLSURFPlugin::TPreCadPeriodicity_var myPreCadPeriodicity = new BLSURFPlugin::TPreCadPeriodicity();
4010 myPreCadPeriodicity->shape1Entry = CORBA::string_dup(preCadPeriodicityVector_i.shape1Entry.c_str());
4011 myPreCadPeriodicity->shape2Entry = CORBA::string_dup(preCadPeriodicityVector_i.shape2Entry.c_str());
4013 BLSURFPlugin::TEntryList_var sourceVertices = new BLSURFPlugin::TEntryList();
4014 if (! preCadPeriodicityVector_i.theSourceVerticesEntries.empty())
4016 sourceVertices->length((CORBA::ULong) preCadPeriodicityVector_i.theSourceVerticesEntries.size());
4017 for (CORBA::ULong j=0; j<preCadPeriodicityVector_i.theSourceVerticesEntries.size(); j++)
4018 sourceVertices[j]=CORBA::string_dup(preCadPeriodicityVector_i.theSourceVerticesEntries[j].c_str());
4021 myPreCadPeriodicity->theSourceVerticesEntries = sourceVertices;
4023 BLSURFPlugin::TEntryList_var targetVertices = new BLSURFPlugin::TEntryList();
4024 if (! preCadPeriodicityVector_i.theTargetVerticesEntries.empty())
4026 targetVertices->length((CORBA::ULong) preCadPeriodicityVector_i.theTargetVerticesEntries.size());
4027 for (CORBA::ULong j=0; j<preCadPeriodicityVector_i.theTargetVerticesEntries.size(); j++)
4028 targetVertices[j]=CORBA::string_dup(preCadPeriodicityVector_i.theTargetVerticesEntries[j].c_str());
4031 myPreCadPeriodicity->theTargetVerticesEntries = targetVertices;
4033 periodicityList[i] = myPreCadPeriodicity;
4037 return periodicityList._retn();
4041 void BLSURFPlugin_Hypothesis_i::AddPreCadFacesPeriodicity(GEOM::GEOM_Object_ptr theFace1, GEOM::GEOM_Object_ptr theFace2)
4044 const GEOM::ListOfGO theSourceVertices;
4045 const GEOM::ListOfGO theTargetVertices;
4046 AddPreCadFacesPeriodicityWithVertices(theFace1, theFace2, theSourceVertices, theTargetVertices);
4050 void BLSURFPlugin_Hypothesis_i::AddPreCadFacesPeriodicityWithVertices(GEOM::GEOM_Object_ptr theFace1, GEOM::GEOM_Object_ptr theFace2,
4051 const GEOM::ListOfGO& theSourceVertices, const GEOM::ListOfGO& theTargetVertices)
4055 size_t theLength = theSourceVertices.length();
4056 if (theLength != theTargetVertices.length())
4057 THROW_SALOME_CORBA_EXCEPTION( "The sizes of theSourceVertices and theTargetVertices must be the same" ,SALOME::BAD_PARAM );
4059 std::vector<GEOM::shape_type> allowedShapeTypes;
4060 allowedShapeTypes.push_back(GEOM::FACE);
4061 allowedShapeTypes.push_back(GEOM::COMPOUND);
4063 string prefix1 = "Source_face_";
4064 CheckShapeTypes(theFace1, allowedShapeTypes);
4065 string theFace1Entry = PublishIfNeeded(theFace1, GEOM::FACE, prefix1);
4067 string prefix2 = "Target_face_";
4068 CheckShapeTypes(theFace2, allowedShapeTypes);
4069 string theFace2Entry = PublishIfNeeded(theFace2, GEOM::FACE, prefix2);
4071 string prefix3 = "Source_vertex_";
4072 BLSURFPlugin::TEntryList_var theSourceVerticesEntries = new BLSURFPlugin::TEntryList();
4073 theSourceVerticesEntries->length((CORBA::ULong) theLength);
4074 GEOM::GEOM_Object_ptr theVtx_i;
4076 for (CORBA::ULong ind = 0; ind < theLength; ind++) {
4077 theVtx_i = theSourceVertices[ind];
4078 theEntry_i = PublishIfNeeded(theVtx_i, GEOM::VERTEX, prefix3);
4079 theSourceVerticesEntries[ind] = CORBA::string_dup(theEntry_i.c_str());
4082 string prefix4 = "Target_vertex_";
4083 BLSURFPlugin::TEntryList_var theTargetVerticesEntries = new BLSURFPlugin::TEntryList();
4084 theTargetVerticesEntries->length((CORBA::ULong) theLength);
4085 for ( CORBA::ULong ind = 0; ind < theLength; ind++) {
4086 theVtx_i = theTargetVertices[ind];
4087 theEntry_i = PublishIfNeeded(theVtx_i, GEOM::VERTEX, prefix4);
4088 theTargetVerticesEntries[ind] = CORBA::string_dup(theEntry_i.c_str());
4091 string theFace2Name = theFace2->GetName();
4093 AddPreCadFacesPeriodicityEntry(theFace1Entry.c_str(), theFace2Entry.c_str(),
4094 theSourceVerticesEntries, theTargetVerticesEntries);
4095 } catch (SALOME_Exception& ex) {
4096 THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
4101 void BLSURFPlugin_Hypothesis_i::AddPreCadFacesPeriodicityEntry(const char* theFace1Entry, const char* theFace2Entry,
4102 const BLSURFPlugin::TEntryList& theSourceVerticesEntriesCorba, const BLSURFPlugin::TEntryList& theTargetVerticesEntriesCorba)
4106 // Convert BLSURFPlugin::TEntryList to vector<string>
4107 vector<string> theSourceVerticesEntries, theTargetVerticesEntries;
4108 for ( CORBA::ULong ind = 0; ind < theSourceVerticesEntriesCorba.length(); ind++) {
4109 theSourceVerticesEntries.push_back(theSourceVerticesEntriesCorba[ind].in());
4110 theTargetVerticesEntries.push_back(theTargetVerticesEntriesCorba[ind].in());
4113 string listEntriesTxt = FormatVerticesEntries(theSourceVerticesEntries, theTargetVerticesEntries);
4116 this->GetImpl()->AddPreCadFacesPeriodicity(theFace1Entry, theFace2Entry,
4117 theSourceVerticesEntries, theTargetVerticesEntries);
4119 SMESH::TPythonDump pd;
4120 if (!theSourceVerticesEntries.empty())
4122 pd << _this() << ".AddPreCadFacesPeriodicityWithVertices(" << theFace1Entry << ", " << theFace2Entry;
4123 pd << listEntriesTxt.c_str();
4127 pd << _this() << ".AddPreCadFacesPeriodicity(" << theFace1Entry << ", " << theFace2Entry << ")";
4130 void BLSURFPlugin_Hypothesis_i::AddPreCadEdgesPeriodicity(GEOM::GEOM_Object_ptr theEdge1, GEOM::GEOM_Object_ptr theEdge2)
4133 const GEOM::ListOfGO theSourceVertices;
4134 const GEOM::ListOfGO theTargetVertices;
4135 AddPreCadEdgesPeriodicityWithVertices(theEdge1, theEdge2, theSourceVertices, theTargetVertices);
4138 void BLSURFPlugin_Hypothesis_i::AddPreCadEdgesPeriodicityWithVertices(GEOM::GEOM_Object_ptr theEdge1, GEOM::GEOM_Object_ptr theEdge2,
4139 const GEOM::ListOfGO& theSourceVertices, const GEOM::ListOfGO& theTargetVertices)
4143 size_t theLength = theSourceVertices.length();
4144 if (theLength != theTargetVertices.length())
4145 THROW_SALOME_CORBA_EXCEPTION( "The sizes of theSourceVertices and theTargetVertices must be the same" ,SALOME::BAD_PARAM );
4147 std::vector<GEOM::shape_type> allowedShapeTypes;
4148 allowedShapeTypes.push_back(GEOM::EDGE);
4149 allowedShapeTypes.push_back(GEOM::COMPOUND);
4151 string prefix1 = "Source_edge_";
4152 CheckShapeTypes(theEdge1, allowedShapeTypes);
4153 string theEdge1Entry = PublishIfNeeded(theEdge1, GEOM::EDGE, prefix1);
4155 string prefix2 = "Target_edge_";
4156 CheckShapeTypes(theEdge2, allowedShapeTypes);
4157 string theEdge2Entry = PublishIfNeeded(theEdge2, GEOM::EDGE, prefix2);
4159 string prefix3 = "Source_vertex_";
4160 BLSURFPlugin::TEntryList_var theSourceVerticesEntries = new BLSURFPlugin::TEntryList();
4161 theSourceVerticesEntries->length((CORBA::ULong) theLength);
4162 GEOM::GEOM_Object_ptr theVtx_i;
4164 for (CORBA::ULong ind = 0; ind < theLength; ind++) {
4165 theVtx_i = theSourceVertices[ind];
4166 theEntry_i = PublishIfNeeded(theVtx_i, GEOM::VERTEX, prefix3);
4167 theSourceVerticesEntries[ind] = CORBA::string_dup(theEntry_i.c_str());
4170 string prefix4 = "Target_vertex_";
4171 BLSURFPlugin::TEntryList_var theTargetVerticesEntries = new BLSURFPlugin::TEntryList();
4172 theTargetVerticesEntries->length((CORBA::ULong) theLength);
4173 for (CORBA::ULong ind = 0; ind < theLength; ind++) {
4174 theVtx_i = theTargetVertices[ind];
4175 theEntry_i = PublishIfNeeded(theVtx_i, GEOM::VERTEX, prefix4);
4176 theTargetVerticesEntries[ind] = CORBA::string_dup(theEntry_i.c_str());
4179 string theEdge2Name = theEdge2->GetName();
4181 AddPreCadEdgesPeriodicityEntry(theEdge1Entry.c_str(), theEdge2Entry.c_str(),
4182 theSourceVerticesEntries, theTargetVerticesEntries);
4183 } catch (SALOME_Exception& ex) {
4184 THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
4189 void BLSURFPlugin_Hypothesis_i::AddPreCadEdgesPeriodicityEntry(const char* theEdge1Entry, const char* theEdge2Entry,
4190 const BLSURFPlugin::TEntryList& theSourceVerticesEntriesCorba, const BLSURFPlugin::TEntryList& theTargetVerticesEntriesCorba)
4195 // Convert BLSURFPlugin::TEntryList to vector<string>
4196 vector<string> theSourceVerticesEntries, theTargetVerticesEntries;
4197 for (CORBA::ULong ind = 0; ind < theSourceVerticesEntriesCorba.length(); ind++) {
4198 theSourceVerticesEntries.push_back(theSourceVerticesEntriesCorba[ind].in());
4199 theTargetVerticesEntries.push_back(theTargetVerticesEntriesCorba[ind].in());
4202 string listEntriesTxt = FormatVerticesEntries(theSourceVerticesEntries, theTargetVerticesEntries);
4204 this->GetImpl()->AddPreCadEdgesPeriodicity(theEdge1Entry, theEdge2Entry,
4205 theSourceVerticesEntries, theTargetVerticesEntries);
4207 SMESH::TPythonDump pd;
4208 if (!theSourceVerticesEntries.empty())
4210 pd << _this() << ".AddPreCadEdgesPeriodicityWithVertices(" << theEdge1Entry << ", " << theEdge2Entry;
4211 pd << listEntriesTxt.c_str();
4215 pd << _this() << ".AddPreCadEdgesPeriodicity(" << theEdge1Entry << ", " << theEdge2Entry << ")";
4220 //================================================================================
4222 * \brief Sets the file for export resulting mesh in GMF format
4223 * \param theFileName - full name of the file (.mesh, .meshb)
4225 * After compute, export the resulting mesh in the given file with the GMF format (.mesh)
4227 //================================================================================
4228 // void BLSURFPlugin_Hypothesis_i::SetGMFFile(const char* theFileName, CORBA::Boolean isBinary) {
4229 void BLSURFPlugin_Hypothesis_i::SetGMFFile(const char* theFileName) {
4231 bool valueChanged/*, modeChanged*/ = false;
4233 valueChanged = (this->GetImpl()->GetGMFFile() != theFileName);
4234 // modeChanged = (this->GetImpl()->GetGMFFileMode() != isBinary);
4235 if (valueChanged)// or (!valueChanged && modeChanged))
4236 this->GetImpl()->SetGMFFile(theFileName);// ,isBinary);
4237 } catch (const std::exception& ex) {
4238 THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
4240 if (valueChanged)// or (!valueChanged && modeChanged))
4241 SMESH::TPythonDump() << _this() << ".SetGMFFile(\"" << theFileName << "\")"; //", " << isBinary << ")";
4244 //================================================================================
4246 * \brief Gets the file name for export resulting mesh in GMF format
4247 * \retval char* - The file name
4249 * Returns the GMF file name
4251 //================================================================================
4252 char* BLSURFPlugin_Hypothesis_i::GetGMFFile() {
4254 return CORBA::string_dup(this->GetImpl()->GetGMFFile().c_str());
4257 // //================================================================================
4259 // * \brief Gets the file mode for export resulting mesh in GMF format
4260 // * \retval CORBA::Boolean - TRUE if binary mode, FALSE if ascii mode
4262 // * Returns the GMF file mode
4264 // //================================================================================
4265 // CORBA::Boolean BLSURFPlugin_Hypothesis_i::GetGMFFileMode() {
4266 // ASSERT(myBaseImpl);
4267 // return this->GetImpl()->GetGMFFileMode();
4270 //=============================================================================
4272 * BLSURFPlugin_Hypothesis_i::GetImpl
4274 * Get implementation
4276 //=============================================================================
4277 ::BLSURFPlugin_Hypothesis* BLSURFPlugin_Hypothesis_i::GetImpl() {
4278 return (::BLSURFPlugin_Hypothesis*) myBaseImpl;
4281 //================================================================================
4283 * \brief Verify whether hypothesis supports given entity type
4284 * \param type - dimension (see SMESH::Dimension enumeration)
4285 * \retval CORBA::Boolean - TRUE if dimension is supported, FALSE otherwise
4287 * Verify whether hypothesis supports given entity type (see SMESH::Dimension enumeration)
4289 //================================================================================
4290 CORBA::Boolean BLSURFPlugin_Hypothesis_i::IsDimSupported(SMESH::Dimension type) {
4291 return type == SMESH::DIM_2D;
4295 //================================================================================
4297 * \brief Return geometry this hypothesis depends on. Return false if there is no geometry parameter
4299 //================================================================================
4302 BLSURFPlugin_Hypothesis_i::getObjectsDependOn( std::vector< std::string > & entryArray,
4303 std::vector< int > & subIDArray ) const
4305 typedef ::BLSURFPlugin_Hypothesis BH;
4306 const BH* impl = static_cast<const BH*>( myBaseImpl );
4309 const BH::TSizeMap& sizeMap = impl->_GetSizeMapEntries();
4310 BH::TSizeMap::const_iterator entry2size = sizeMap.cbegin();
4311 for ( ; entry2size != sizeMap.cend(); ++entry2size )
4312 entryArray.push_back( entry2size->first );
4315 const BH::TSizeMap& sizeMap = impl->_GetAttractorEntries();
4316 BH::TSizeMap::const_iterator entry2size = sizeMap.cbegin();
4317 for ( ; entry2size != sizeMap.cend(); ++entry2size )
4318 entryArray.push_back( entry2size->first );
4321 const BH::TAttractorMap& classAttractors = impl-> _GetClassAttractorEntries();
4322 BH::TAttractorMap::const_iterator entry2size = classAttractors.cbegin();
4323 for ( ; entry2size != classAttractors.cend(); ++entry2size )
4324 entryArray.push_back( entry2size->first );
4327 const BH::TFaceEntryEnfVertexListMap& faceEntryEnfVertexListMap = impl->_GetAllEnforcedVerticesByFace();
4328 BH::TFaceEntryEnfVertexListMap::const_iterator entry2evList = faceEntryEnfVertexListMap.cbegin();
4329 for ( ; entry2evList != faceEntryEnfVertexListMap.cend(); ++entry2evList )
4331 entryArray.push_back( entry2evList->first );
4333 const BH::TEnfVertexList& evList = entry2evList->second;
4334 BH::TEnfVertexList::const_iterator evIt = evList.cbegin();
4335 for ( ; evIt != evList.cend(); ++evIt )
4337 const BH::TEnfVertex* ev = *evIt;
4338 entryArray.push_back( ev->geomEntry );
4339 entryArray.insert( entryArray.end(), ev->faceEntries.cbegin(), ev->faceEntries.cend() );
4343 // { // duplicated data of faceEntryEnfVertexListMap
4344 // const BH::TEnfVertexList& enfVertexList = impl->_GetAllEnforcedVertices();
4345 // const BH::TFaceEntryCoordsListMap& faceEntryCoordsListMap = impl->_GetAllCoordsByFace();
4346 // const BH::TFaceEntryEnfVertexEntryListMap& faceEntryEnfVertexEntryListMap = impl->_GetAllEnfV // const BH::TEnfVertexEntryEnfVertexMap& enfVertexEntryEnfVertexMap = impl->_GetAllEnforcedVert // }
4348 const BH::TPreCadPeriodicityVector& preCadFacesPeriodicityVector = impl->_GetPreCadFacesPeriodicityVector();
4349 BH::TPreCadPeriodicityVector::const_iterator pcp = preCadFacesPeriodicityVector.cbegin();
4350 for ( ; pcp != preCadFacesPeriodicityVector.cend(); ++pcp )
4352 entryArray.push_back( pcp->shape1Entry );
4353 entryArray.push_back( pcp->shape2Entry );
4354 entryArray.insert( entryArray.end(),
4355 pcp->theSourceVerticesEntries.cbegin(),
4356 pcp->theSourceVerticesEntries.cend() );
4357 entryArray.insert( entryArray.end(),
4358 pcp->theTargetVerticesEntries.cbegin(),
4359 pcp->theTargetVerticesEntries.cend() );
4363 const BH::TPreCadPeriodicityVector& preCadEdgesPeriodicityVector = impl->_GetPreCadEdgesPeriodicityVector();
4364 BH::TPreCadPeriodicityVector::const_iterator pcp = preCadEdgesPeriodicityVector.cbegin();
4365 for ( ; pcp != preCadEdgesPeriodicityVector.cend(); ++pcp )
4367 entryArray.push_back( pcp->shape1Entry );
4368 entryArray.push_back( pcp->shape2Entry );
4369 entryArray.insert( entryArray.end(),
4370 pcp->theSourceVerticesEntries.cbegin(),
4371 pcp->theSourceVerticesEntries.cend() );
4372 entryArray.insert( entryArray.end(),
4373 pcp->theTargetVerticesEntries.cbegin(),
4374 pcp->theTargetVerticesEntries.cend() );
4378 const BH::THyperPatchList& hyperPatchList = impl->GetHyperPatches();
4379 BH::THyperPatchList::const_iterator idSet = hyperPatchList.cbegin();
4380 for ( ; idSet != hyperPatchList.cend(); ++idSet )
4382 subIDArray.insert( subIDArray.end(), idSet->cbegin(), idSet->cend() );
4388 //================================================================================
4390 * \brief Set new geometry instead of that returned by getObjectsDependOn()
4392 //================================================================================
4395 BLSURFPlugin_Hypothesis_i::setObjectsDependOn( std::vector< std::string > & entryArray,
4396 std::vector< int > & subIDArray )
4398 typedef ::BLSURFPlugin_Hypothesis BH;
4399 BH* impl = static_cast<BH*>( myBaseImpl );
4403 BH::TSizeMap& sizeMapNew = const_cast< BH::TSizeMap& >( impl->_GetSizeMapEntries() );
4404 BH::TSizeMap sizeMap;
4405 sizeMap.swap( sizeMapNew );
4406 BH::TSizeMap::const_iterator entry2size = sizeMap.cbegin();
4407 for ( ; entry2size != sizeMap.cend(); ++entry2size, ++iEnt )
4408 if ( entryArray[ iEnt ].empty() == entry2size->first.empty() )
4409 sizeMapNew[ entryArray[ iEnt ]] = entry2size->second;
4412 BH::TSizeMap& sizeMapNew = const_cast< BH::TSizeMap& >( impl->_GetAttractorEntries() );
4413 BH::TSizeMap sizeMap;
4414 sizeMap.swap( sizeMapNew );
4415 BH::TSizeMap::const_iterator entry2size = sizeMap.cbegin();
4416 for ( ; entry2size != sizeMap.cend(); ++entry2size, ++iEnt )
4417 if ( entryArray[ iEnt ].empty() == entry2size->first.empty() )
4418 sizeMapNew[ entryArray[ iEnt ]] = entry2size->second;
4421 BH::TAttractorMap& attrMapNew =
4422 const_cast< BH::TAttractorMap& > ( impl->_GetClassAttractorEntries() );
4423 BH::TAttractorMap attrMap;
4424 attrMap.swap( attrMapNew );
4425 BH::TAttractorMap::const_iterator entry2size = attrMap.cbegin();
4426 for ( ; entry2size != attrMap.cend(); ++entry2size, ++iEnt )
4427 if ( entryArray[ iEnt ].empty() == entry2size->first.empty() )
4428 attrMapNew.insert( std::make_pair( entryArray[ iEnt ], entry2size->second ));
4430 delete entry2size->second;
4433 BH::TFaceEntryEnfVertexListMap& faceEntryEnfVertexListMapNew =
4434 const_cast< BH::TFaceEntryEnfVertexListMap& >( impl->_GetAllEnforcedVerticesByFace() );
4435 BH::TFaceEntryEnfVertexListMap faceEntryEnfVertexListMap;
4436 faceEntryEnfVertexListMap.swap( faceEntryEnfVertexListMapNew );
4438 BH::TEnfVertexList& enfVertexList =
4439 const_cast< BH::TEnfVertexList& > ( impl->_GetAllEnforcedVertices() );
4440 enfVertexList.clear(); // avoid removal
4442 impl->ClearAllEnforcedVertices();
4444 BH::TFaceEntryEnfVertexListMap::iterator entry2evList = faceEntryEnfVertexListMap.begin();
4445 for ( ; entry2evList != faceEntryEnfVertexListMap.end(); ++entry2evList )
4447 const BH::TEntry& entry = entryArray[ iEnt++ ];
4448 bool faceOk = ( entry.empty() == entry2evList->first.empty() );
4450 BH::TEnfVertexList& evList = entry2evList->second;
4451 BH::TEnfVertexList::iterator evIt = evList.begin();
4452 for ( ; evIt != evList.end(); ++evIt )
4454 BH::TEnfVertex* ev = *evIt;
4455 bool ok = faceOk && ( ev->geomEntry.empty() != entryArray[ iEnt ].empty() );
4456 ev->geomEntry = entryArray[ iEnt++ ];
4457 BH::TEntryList faceEntriesNew;
4458 BH::TEntryList::iterator fEnt = ev->faceEntries.begin();
4459 for ( ; fEnt != ev->faceEntries.end(); ++fEnt, ++iEnt )
4461 if ( !entryArray[ iEnt ].empty() )
4462 faceEntriesNew.insert( entryArray[ iEnt ]);
4466 ev->faceEntries.swap( faceEntriesNew );
4467 impl->AddEnforcedVertex( entry, ev );
4477 BH::TPreCadPeriodicityVector& preCadPeriodicityVector =
4478 const_cast< BH::TPreCadPeriodicityVector&> ( impl->_GetPreCadFacesPeriodicityVector() );
4479 BH::TPreCadPeriodicityVector::iterator pcp = preCadPeriodicityVector.begin();
4480 for ( ; pcp != preCadPeriodicityVector.end(); ++pcp )
4482 pcp->shape1Entry = entryArray[ iEnt++ ];
4483 pcp->shape2Entry = entryArray[ iEnt++ ];
4484 for ( size_t i = 0; i < pcp->theSourceVerticesEntries.size(); ++i, iEnt++ )
4485 pcp->theSourceVerticesEntries[i] = entryArray[ iEnt ];
4487 for ( size_t i = 0; i < pcp->theTargetVerticesEntries.size(); ++i, iEnt++ )
4488 pcp->theTargetVerticesEntries[i] = entryArray[ iEnt ];
4492 BH::TPreCadPeriodicityVector& preCadPeriodicityVector =
4493 const_cast< BH::TPreCadPeriodicityVector&> ( impl->_GetPreCadEdgesPeriodicityVector() );
4494 BH::TPreCadPeriodicityVector::iterator pcp = preCadPeriodicityVector.begin();
4495 for ( ; pcp != preCadPeriodicityVector.end(); ++pcp )
4497 pcp->shape1Entry = entryArray[ iEnt++ ];
4498 pcp->shape2Entry = entryArray[ iEnt++ ];
4499 for ( size_t i = 0; i < pcp->theSourceVerticesEntries.size(); ++i, iEnt++ )
4500 pcp->theSourceVerticesEntries[i] = entryArray[ iEnt ];
4502 for ( size_t i = 0; i < pcp->theTargetVerticesEntries.size(); ++i, iEnt++ )
4503 pcp->theTargetVerticesEntries[i] = entryArray[ iEnt ];
4509 BH::THyperPatchList& hyperPatchListNew =
4510 const_cast< BH::THyperPatchList& >( impl->GetHyperPatches() );
4511 BH::THyperPatchList hyperPatchList;
4512 hyperPatchList.swap( hyperPatchListNew );
4513 BH::THyperPatchList::iterator idSet = hyperPatchList.begin();
4514 for ( ; idSet != hyperPatchList.end(); ++idSet )
4516 BH::THyperPatchTags& ids = *idSet;
4517 BH::THyperPatchTags idsNew;
4518 BH::THyperPatchTags::iterator i = ids.begin();
4519 for ( ; i != ids.end(); ++i, ++iID )
4520 if ( subIDArray[ iID ] > 0 )
4521 idsNew.insert( subIDArray[ iID ]);
4522 if ( !idsNew.empty() )
4523 hyperPatchListNew.push_back( idsNew );
4527 return ( iEnt == entryArray.size() && iID == subIDArray.size() );