1 // Copyright (C) 2007-2010 CEA/DEN, EDF R&D
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.
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 // & Aurelien ALLEAUME (DISTENE)
24 // Size maps developement: Nicolas GEIMER (OCC) & Gilles DAVID (EURIWARE)
27 #include "BLSURFPlugin_Hypothesis.hxx"
28 #include <utilities.h>
33 //=============================================================================
34 BLSURFPlugin_Hypothesis::BLSURFPlugin_Hypothesis (int hypId, int studyId,
36 : SMESH_Hypothesis(hypId, studyId, gen),
37 _topology(GetDefaultTopology()),
38 _physicalMesh(GetDefaultPhysicalMesh()),
39 _phySize(GetDefaultPhySize()),
40 _phyMax(GetDefaultMaxSize()),
41 _phyMin(GetDefaultMinSize()),
42 _hgeoMax(GetDefaultMaxSize()),
43 _hgeoMin(GetDefaultMinSize()),
44 _geometricMesh(GetDefaultGeometricMesh()),
45 _angleMeshS(GetDefaultAngleMeshS()),
46 _angleMeshC(GetDefaultAngleMeshC()),
47 _gradation(GetDefaultGradation()),
48 _quadAllowed(GetDefaultQuadAllowed()),
49 _decimesh(GetDefaultDecimesh()),
50 _verb( GetDefaultVerbosity() ),
51 _sizeMap(GetDefaultSizeMap()),
52 _attractors(GetDefaultSizeMap()),
53 _enfVertexList(GetDefaultEnfVertexList()),
54 _entryEnfVertexListMap(GetDefaultEntryEnfVertexListMap())
56 _groupNameEnfVertexListMap(GetDefaultGroupNameEnfVertexListMap()),
57 _enfVertexGroupNameMap(GetDefaultEnfVertexGroupNameMap())
60 _name = "BLSURF_Parameters";
63 // to desable writing boundaries
64 //_phyMin = _phyMax = _hgeoMin = _hgeoMax = undefinedDouble();
67 const char* intOptionNames[] = {
96 const char* doubleOptionNames[] = {
114 const char* charOptionNames[] = {
123 while ( intOptionNames[i][0] )
124 _option2value[ intOptionNames[i++] ].clear();
127 while ( doubleOptionNames[i][0] ) {
128 _doubleOptions.insert( doubleOptionNames[i] );
129 _option2value[ doubleOptionNames[i++] ].clear();
132 while ( charOptionNames[i][0] ) {
133 _charOptions.insert( charOptionNames[i] );
134 _option2value[ charOptionNames[i++] ].clear();
139 _enfVertexList.clear();
140 _entryEnfVertexListMap.clear();
142 _groupNameEnfVertexListMap.clear();
143 _enfVertexGroupNameMap.clear();
147 //=============================================================================
148 void BLSURFPlugin_Hypothesis::SetTopology(Topology theTopology)
150 if (theTopology != _topology) {
151 _topology = theTopology;
152 NotifySubMeshesHypothesisModification();
156 //=============================================================================
157 void BLSURFPlugin_Hypothesis::SetPhysicalMesh(PhysicalMesh thePhysicalMesh)
159 if (thePhysicalMesh != _physicalMesh) {
160 _physicalMesh = thePhysicalMesh;
161 switch( _physicalMesh ) {
164 _phySize = GetDefaultPhySize();
165 _gradation = GetDefaultGradation();
168 NotifySubMeshesHypothesisModification();
172 //=============================================================================
173 void BLSURFPlugin_Hypothesis::SetPhySize(double theVal)
175 if (theVal != _phySize) {
177 NotifySubMeshesHypothesisModification();
181 //=============================================================================
182 void BLSURFPlugin_Hypothesis::SetPhyMin(double theMinSize)
184 if (theMinSize != _phyMin) {
185 _phyMin = theMinSize;
186 NotifySubMeshesHypothesisModification();
190 //=============================================================================
191 void BLSURFPlugin_Hypothesis::SetPhyMax(double theMaxSize)
193 if (theMaxSize != _phyMax) {
194 _phyMax = theMaxSize;
195 NotifySubMeshesHypothesisModification();
200 //=============================================================================
201 void BLSURFPlugin_Hypothesis::SetGeoMin(double theMinSize)
203 if (theMinSize != _hgeoMin) {
204 _hgeoMin = theMinSize;
205 NotifySubMeshesHypothesisModification();
209 //=============================================================================
210 void BLSURFPlugin_Hypothesis::SetGeoMax(double theMaxSize)
212 if (theMaxSize != _hgeoMax) {
213 _hgeoMax = theMaxSize;
214 NotifySubMeshesHypothesisModification();
218 //=============================================================================
219 void BLSURFPlugin_Hypothesis::SetGeometricMesh(GeometricMesh theGeometricMesh)
221 if (theGeometricMesh != _geometricMesh) {
222 _geometricMesh = theGeometricMesh;
223 switch( _geometricMesh ) {
226 _angleMeshS = GetDefaultAngleMeshS();
227 _gradation = GetDefaultGradation();
230 NotifySubMeshesHypothesisModification();
234 //=============================================================================
235 void BLSURFPlugin_Hypothesis::SetAngleMeshS(double theVal)
237 if (theVal != _angleMeshS) {
238 _angleMeshS = theVal;
239 NotifySubMeshesHypothesisModification();
243 //=============================================================================
244 void BLSURFPlugin_Hypothesis::SetAngleMeshC(double theVal)
246 if (theVal != _angleMeshC) {
247 _angleMeshC = theVal;
248 NotifySubMeshesHypothesisModification();
252 //=============================================================================
253 void BLSURFPlugin_Hypothesis::SetGradation(double theVal)
255 if (theVal != _gradation) {
257 NotifySubMeshesHypothesisModification();
261 //=============================================================================
262 void BLSURFPlugin_Hypothesis::SetQuadAllowed(bool theVal)
264 if (theVal != _quadAllowed) {
265 _quadAllowed = theVal;
266 NotifySubMeshesHypothesisModification();
270 //=============================================================================
271 void BLSURFPlugin_Hypothesis::SetDecimesh(bool theVal)
273 if (theVal != _decimesh) {
275 NotifySubMeshesHypothesisModification();
279 //=============================================================================
280 void BLSURFPlugin_Hypothesis::SetVerbosity(int theVal)
282 if (theVal != _verb) {
284 NotifySubMeshesHypothesisModification();
287 //=============================================================================
288 void BLSURFPlugin_Hypothesis::SetOptionValue(const std::string& optionName,
289 const std::string& optionValue)
290 throw (std::invalid_argument)
292 TOptionValues::iterator op_val = _option2value.find( optionName );
293 if ( op_val == _option2value.end() ) {
294 std::string msg = "Unknown BLSURF option: '" + optionName + "'";
295 throw std::invalid_argument(msg);
297 if ( op_val->second != optionValue ) {
298 const char* ptr = optionValue.c_str();
299 // strip white spaces
300 while ( ptr[0] == ' ' )
302 int i = strlen( ptr );
303 while ( i != 0 && ptr[i-1] == ' ')
307 std::string typeName;
311 else if ( _charOptions.find( optionName ) != _charOptions.end() ) {
312 // do not check strings
314 else if ( _doubleOptions.find( optionName ) != _doubleOptions.end() ) {
315 // check if value is double
317 strtod(ptr, &endPtr);
318 typeOk = ( ptr != endPtr );
322 // check if value is int
324 strtol(ptr, &endPtr,10);
325 typeOk = ( ptr != endPtr );
326 typeName = "integer";
329 std::string msg = "Advanced option '" + optionName + "' = '" + optionValue +
330 "' but must be " + typeName;
331 throw std::invalid_argument(msg);
333 op_val->second = optionValue;
334 NotifySubMeshesHypothesisModification();
338 //=============================================================================
339 std::string BLSURFPlugin_Hypothesis::GetOptionValue(const std::string& optionName)
340 throw (std::invalid_argument)
342 TOptionValues::iterator op_val = _option2value.find( optionName );
343 if ( op_val == _option2value.end() ) {
344 std::string msg = "Unknown BLSURF option: <";
345 msg += optionName + ">";
346 throw std::invalid_argument(msg);
348 return op_val->second;
351 //=============================================================================
352 void BLSURFPlugin_Hypothesis::ClearOption(const std::string& optionName)
354 TOptionValues::iterator op_val = _option2value.find( optionName );
355 if ( op_val != _option2value.end() )
356 op_val->second.clear();
359 //=======================================================================
360 //function : SetSizeMapEntry
361 //=======================================================================
362 void BLSURFPlugin_Hypothesis::SetSizeMapEntry(const std::string& entry,const std::string& sizeMap)
364 if (_sizeMap[entry].compare(sizeMap) != 0) {
365 _sizeMap[entry]=sizeMap;
366 NotifySubMeshesHypothesisModification();
370 //=======================================================================
371 //function : GetSizeMapEntry
372 //=======================================================================
373 std::string BLSURFPlugin_Hypothesis::GetSizeMapEntry(const std::string& entry)
375 TSizeMap::iterator it = _sizeMap.find( entry );
376 if ( it != _sizeMap.end() )
379 return "No_Such_Entry";
383 * \brief Return the size maps
385 BLSURFPlugin_Hypothesis::TSizeMap BLSURFPlugin_Hypothesis::GetSizeMapEntries(const BLSURFPlugin_Hypothesis* hyp)
387 return hyp ? hyp->_GetSizeMapEntries():GetDefaultSizeMap();
390 //=======================================================================
391 //function : SetAttractorEntry
392 //=======================================================================
393 void BLSURFPlugin_Hypothesis::SetAttractorEntry(const std::string& entry,const std::string& attractor)
395 if (_attractors[entry].compare(attractor) != 0) {
396 _attractors[entry]=attractor;
397 NotifySubMeshesHypothesisModification();
401 //=======================================================================
402 //function : GetAttractorEntry
403 //=======================================================================
404 std::string BLSURFPlugin_Hypothesis::GetAttractorEntry(const std::string& entry)
406 TSizeMap::iterator it = _attractors.find( entry );
407 if ( it != _attractors.end() )
410 return "No_Such_Entry";
414 * \brief Return the attractors
416 BLSURFPlugin_Hypothesis::TSizeMap BLSURFPlugin_Hypothesis::GetAttractorEntries(const BLSURFPlugin_Hypothesis* hyp)
418 return hyp ? hyp->_GetAttractorEntries():GetDefaultSizeMap();
421 //=======================================================================
422 //function : ClearEntry
423 //=======================================================================
424 void BLSURFPlugin_Hypothesis::ClearEntry(const std::string& entry)
426 TSizeMap::iterator it = _sizeMap.find( entry );
427 if ( it != _sizeMap.end() ) {
429 NotifySubMeshesHypothesisModification();
432 TSizeMap::iterator itAt = _attractors.find( entry );
433 if ( itAt != _attractors.end() ) {
434 _attractors.erase(itAt);
435 NotifySubMeshesHypothesisModification();
438 std::cout<<"No_Such_Entry"<<std::endl;
442 //=======================================================================
443 //function : ClearSizeMaps
444 //=======================================================================
445 void BLSURFPlugin_Hypothesis::ClearSizeMaps()
453 //=======================================================================
454 //function : SetEnforcedVertex
455 //=======================================================================
457 void BLSURFPlugin_Hypothesis::SetEnforcedVertex(const TEnfEntry& entry,
458 double x, double y, double z,
459 const TEnfGroupName& groupName)
461 void BLSURFPlugin_Hypothesis::SetEnforcedVertex(const TEnfEntry& entry,
462 double x, double y, double z)
465 MESSAGE("BLSURFPlugin_Hypothesis::SetEnforcedVertex START - entry: " << entry << " vertex: " << x << " " << y << " " << z << " group name: " << groupName);
467 MESSAGE("BLSURFPlugin_Hypothesis::SetEnforcedVertex START - entry: " << entry << " vertex: " << x << " " << y << " " << z);
468 TEnfVertex enfVertex;
469 enfVertex.push_back(x);
470 enfVertex.push_back(y);
471 enfVertex.push_back(z);
473 bool toNotify = false;
474 if (_entryEnfVertexListMap.count(entry)>0)
475 if (_entryEnfVertexListMap[entry].count(enfVertex)==0)
480 _enfVertexList.insert(enfVertex);
481 // _entryEnfVertexListMap[entry].insert(enfVertex);
482 TEnfVertexList& entryEnfVertexList = _entryEnfVertexListMap[entry];
483 entryEnfVertexList.insert(enfVertex);
486 bool toNotify2 = _setEnfVertexWithGroup(x,y,z,groupName);
488 if (toNotify || toNotify2)
489 NotifySubMeshesHypothesisModification();
492 NotifySubMeshesHypothesisModification();
494 MESSAGE("BLSURFPlugin_Hypothesis::SetEnforcedVertex END");
498 bool BLSURFPlugin_Hypothesis::_setEnfVertexWithGroup(double x, double y, double z, const std::string groupName) throw (std::invalid_argument)
500 bool isModified = false;
501 std::vector<double> enfVertex;
502 enfVertex.push_back(x);
503 enfVertex.push_back(y);
504 enfVertex.push_back(z);
505 if (_enfVertexList.find(enfVertex) != _enfVertexList.end()) {
506 TEnfGroupName oldGroupName = _enfVertexGroupNameMap[enfVertex];
507 _enfVertexGroupNameMap[enfVertex] = groupName;
508 if ((groupName != "") && (groupName != oldGroupName)) {
509 MESSAGE("Group name is not empty");
510 TEnfVertexList& enfVertexList = _groupNameEnfVertexListMap[groupName];
511 enfVertexList.insert(enfVertex);
515 if (oldGroupName != "") {
516 // groupName = "" => remove group name
517 TGroupNameEnfVertexListMap::iterator it = _groupNameEnfVertexListMap.find(oldGroupName);
518 if (it != _groupNameEnfVertexListMap.end()) {
519 _groupNameEnfVertexListMap[oldGroupName].erase(enfVertex);
520 if (_groupNameEnfVertexListMap[oldGroupName].size() == 0)
521 _groupNameEnfVertexListMap.erase(oldGroupName);
529 std::ostringstream msg ;
530 msg << "No enforced vertex at (" << x << "," << y << "," << z << ")" ;
531 throw std::invalid_argument(msg.str());
534 //=======================================================================
535 //function : SetEnforcedVertexGroupName
536 //=======================================================================
537 void BLSURFPlugin_Hypothesis::SetEnforcedVertexGroupName(double x, double y, double z,
538 const TEnfGroupName& groupName)
539 throw (std::invalid_argument)
541 bool toNotify = _setEnfVertexWithGroup(x,y,z,groupName);
543 NotifySubMeshesHypothesisModification();
544 // bool toNotify = false;
545 // TEnfVertex enfVertex;
546 // enfVertex.push_back(x);
547 // enfVertex.push_back(y);
548 // enfVertex.push_back(z);
550 // if (_enfVertexList.find(enfVertex) != _enfVertexList.end()) {
551 // TEnfGroupName oldGroupName = _enfVertexGroupNameMap[enfVertex];
552 // _enfVertexGroupNameMap[enfVertex] = groupName;
553 // if ((groupName != "") && (groupName != oldGroupName)) {
554 // MESSAGE("Group name is not empty");
555 // TEnfVertexList& enfVertexList = _groupNameEnfVertexListMap[groupName];
556 // enfVertexList.insert(enfVertex);
560 // if (oldGroupName != "") {
561 // // groupName = "" => remove group name
562 // TGroupNameEnfVertexListMap::iterator it = _groupNameEnfVertexListMap.find(oldGroupName);
563 // if (it != _groupNameEnfVertexListMap.end()) {
564 // _groupNameEnfVertexListMap[oldGroupName].erase(enfVertex);
565 // if (_groupNameEnfVertexListMap[oldGroupName].size() == 0)
566 // _groupNameEnfVertexListMap.erase(oldGroupName);
572 // NotifySubMeshesHypothesisModification();
576 // // std::ostringstream msg ;
577 // // msg << "No enforced vertex at (" << x << "," << y << "," << z << ")" ;
578 // // throw std::invalid_argument(msg.str());
582 //=======================================================================
583 //function : GetEnforcedVertexGroupName
584 //=======================================================================
585 BLSURFPlugin_Hypothesis::TEnfGroupName BLSURFPlugin_Hypothesis::GetEnforcedVertexGroupName(double x, double y, double z)
586 throw (std::invalid_argument)
588 TEnfVertex enfVertex;
589 enfVertex.push_back(x);
590 enfVertex.push_back(y);
591 enfVertex.push_back(z);
593 if (_enfVertexGroupNameMap.find(enfVertex) != _enfVertexGroupNameMap.end())
594 return _enfVertexGroupNameMap[enfVertex];
596 std::ostringstream msg ;
597 msg << "No enforced vertex at (" << x << "," << y << "," << z << ")" ;
598 throw std::invalid_argument(msg.str());
603 //=======================================================================
604 //function : SetEnforcedVertexList
605 //=======================================================================
607 void BLSURFPlugin_Hypothesis::SetEnforcedVertexList(const TEnfEntry& entry,
608 const TEnfVertexList vertexList)
610 TEnfVertexList::const_iterator it;
611 bool toNotify = false;
612 for(it = vertexList.begin();it!=vertexList.end();++it) {
613 if (_entryEnfVertexListMap.count(entry)>0)
614 if (_entryEnfVertexListMap[entry].count(*it)==0)
618 _entryEnfVertexListMap[entry].insert(*it);
619 _enfVertexList.insert(*it);
622 NotifySubMeshesHypothesisModification();
626 //=======================================================================
627 //function : GetEnforcedVertices
628 //=======================================================================
630 BLSURFPlugin_Hypothesis::TEnfVertexList BLSURFPlugin_Hypothesis::GetEnforcedVertices(const TEnfEntry& entry)
631 throw (std::invalid_argument)
633 if (_entryEnfVertexListMap.count(entry)>0)
634 return _entryEnfVertexListMap[entry];
635 std::ostringstream msg ;
636 msg << "No enforced vertex for entry " << entry ;
637 throw std::invalid_argument(msg.str());
640 //=======================================================================
641 //function : ClearEnforcedVertex
642 //=======================================================================
644 void BLSURFPlugin_Hypothesis::ClearEnforcedVertex(const TEnfEntry& entry, double x, double y, double z)
645 throw (std::invalid_argument)
647 std::ostringstream msg ;
649 TEnfVertex enfVertex;
650 enfVertex.push_back(x);
651 enfVertex.push_back(y);
652 enfVertex.push_back(z);
654 // check that enf vertex with given coords exists
655 if (_enfVertexList.count(enfVertex) == 0) {
656 msg << "No enforced vertex for " << entry;
657 throw std::invalid_argument(msg.str());
661 TEntryEnfVertexListMap::iterator it_enf = _entryEnfVertexListMap.find(entry);
662 if (it_enf != _entryEnfVertexListMap.end()) {
663 bool toNotify = false;
664 TEnfVertexList::iterator it = _entryEnfVertexListMap[entry].find(enfVertex);
665 if (it != _entryEnfVertexListMap[entry].end()) {
668 // Update entry2enfList map
669 _entryEnfVertexListMap[entry].erase(it);
670 if (_entryEnfVertexListMap[entry].size() == 0)
671 _entryEnfVertexListMap.erase(it_enf);
674 // Update groupName2enfCoord map
675 TEnfGroupName groupName = _enfVertexGroupNameMap[enfVertex];
676 if (groupName != "") {
677 TGroupNameEnfVertexListMap::iterator it_grp =_groupNameEnfVertexListMap.find(groupName);
678 if (it_grp != _groupNameEnfVertexListMap.end()) {
679 _groupNameEnfVertexListMap[groupName].erase(enfVertex);
680 if (_groupNameEnfVertexListMap[groupName].size() == 0)
681 _groupNameEnfVertexListMap.erase(it_grp);
685 // Update _enfVertexGroupNameMap
686 _enfVertexGroupNameMap.erase(enfVertex);
689 // Update _enfVertexList
690 _enfVertexList.erase(enfVertex);
694 NotifySubMeshesHypothesisModification();
698 msg << "No enforced vertex for " << entry;
699 throw std::invalid_argument(msg.str());
702 //=======================================================================
703 //function : ClearEnforcedVertexList
704 //=======================================================================
706 void BLSURFPlugin_Hypothesis::ClearEnforcedVertexList(const std::string& entry, TEnfVertexList vertexList)
707 throw (std::invalid_argument)
710 TEnfVertexList::const_iterator it_toRemove;
711 TEnfVertexList::iterator it;
712 bool toNotify = false;
714 TEntryEnfVertexListMap::iterator it_enf = _entryEnfVertexListMap.find(entry);
715 if (it_enf != _entryEnfVertexListMap.end()) {
716 for (it_toRemove = vertexList.begin() ; it_toRemove != vertexList.end() ; ++it_toRemove) {
717 coord = *it_toRemove;
718 it = _entryEnfVertexListMap[entry].find(coord);
719 if (it != _entryEnfVertexListMap[entry].end()) {
721 _entryEnfVertexListMap[entry].erase(it);
722 _enfVertexList.erase(it);
725 if (_entryEnfVertexListMap[entry].size() == 0) {
727 _entryEnfVertexListMap.erase(it_enf);
730 NotifySubMeshesHypothesisModification();
734 std::ostringstream msg ;
735 msg << "No enforced vertex for " << entry;
736 throw std::invalid_argument(msg.str());
739 //=======================================================================
740 //function : ClearEnforcedVertices
741 //=======================================================================
743 void BLSURFPlugin_Hypothesis::ClearEnforcedVertices(const TEnfEntry& entry)
744 throw (std::invalid_argument)
746 TEntryEnfVertexListMap::iterator it_enf = _entryEnfVertexListMap.find(entry);
747 if (it_enf != _entryEnfVertexListMap.end()) {
748 TEnfVertexList enfList = it_enf->second;
749 TEnfVertexList::iterator it;
750 for(it = enfList.begin();it!=enfList.end();++it) {
752 TEnfGroupName groupName = _enfVertexGroupNameMap[*it];
753 if (groupName != "") {
754 TGroupNameEnfVertexListMap::iterator it_grp =_groupNameEnfVertexListMap.find(groupName);
755 if (it_grp != _groupNameEnfVertexListMap.end()) {
756 _groupNameEnfVertexListMap[groupName].erase(it);
757 if (_groupNameEnfVertexListMap[groupName].size() == 0)
758 _groupNameEnfVertexListMap.erase(it_grp);
761 _enfVertexGroupNameMap.erase(*it);
763 _enfVertexList.erase(it);
765 _entryEnfVertexListMap.erase(it_enf);
766 NotifySubMeshesHypothesisModification();
770 std::ostringstream msg ;
771 msg << "No enforced vertex for " << entry;
772 throw std::invalid_argument(msg.str());
775 //=======================================================================
776 //function : ClearAllEnforcedVertices
777 //=======================================================================
778 void BLSURFPlugin_Hypothesis::ClearAllEnforcedVertices()
780 _enfVertexList.clear();
781 _entryEnfVertexListMap.clear();
783 _groupNameEnfVertexListMap.clear();
784 _enfVertexGroupNameMap.clear();
786 NotifySubMeshesHypothesisModification();
789 //================================================================================
791 * \brief Return the enforced vertices
793 //================================================================================
795 BLSURFPlugin_Hypothesis::TEntryEnfVertexListMap BLSURFPlugin_Hypothesis::GetAllEnforcedVertices(const BLSURFPlugin_Hypothesis* hyp)
797 return hyp ? hyp->_GetAllEnforcedVertices():GetDefaultEntryEnfVertexListMap();
802 //=============================================================================
803 std::ostream & BLSURFPlugin_Hypothesis::SaveTo(std::ostream & save)
805 save << " " << (int)_topology
806 << " " << (int)_physicalMesh
807 << " " << (int)_geometricMesh
809 << " " << _angleMeshS
811 << " " << (int)_quadAllowed
812 << " " << (int)_decimesh;
813 save << " " << _phyMin
815 << " " << _angleMeshC
820 TOptionValues::iterator op_val = _option2value.begin();
821 if (op_val != _option2value.end()) {
822 save << " " << "__OPTIONS_BEGIN__";
823 for ( ; op_val != _option2value.end(); ++op_val ) {
824 if ( !op_val->second.empty() )
825 save << " " << op_val->first
826 << " " << op_val->second << "%#"; // "%#" is a mark of value end
828 save << " " << "__OPTIONS_END__";
831 TSizeMap::iterator it_sm = _sizeMap.begin();
832 if (it_sm != _sizeMap.end()) {
833 save << " " << "__SIZEMAP_BEGIN__";
834 for ( ; it_sm != _sizeMap.end(); ++it_sm ) {
835 save << " " << it_sm->first
836 << " " << it_sm->second << "%#"; // "%#" is a mark of value end
838 save << " " << "__SIZEMAP_END__";
841 TSizeMap::iterator it_at = _attractors.begin();
842 if (it_at != _attractors.end()) {
843 save << " " << "__ATTRACTORS_BEGIN__";
844 for ( ; it_at != _attractors.end(); ++it_at ) {
845 save << " " << it_at->first
846 << " " << it_at->second << "%#"; // "%#" is a mark of value end
848 save << " " << "__ATTRACTORS_END__";
851 TEntryEnfVertexListMap::const_iterator it_enf = _entryEnfVertexListMap.begin();
852 if (it_enf != _entryEnfVertexListMap.end()) {
853 save << " " << "__ENFORCED_VERTICES_BEGIN__";
854 for ( ; it_enf != _entryEnfVertexListMap.end(); ++it_enf ) {
855 save << " " << it_enf->first;
856 TEnfVertexList evl = it_enf->second;
857 TEnfVertexList::const_iterator it_evl = evl.begin();
858 for ( ; it_evl != evl.end() ; ++it_evl) {
859 save << " " << (*it_evl)[0];
860 save << " " << (*it_evl)[1];
861 save << " " << (*it_evl)[2];
863 TEnfVertexGroupNameMap::const_iterator it_enfGroup = _enfVertexGroupNameMap.find(*it_evl);
864 if (it_enfGroup != _enfVertexGroupNameMap.end()) {
865 save << " " << "__ENF_GROUP_BEGIN__";
866 save << " " << it_enfGroup->second ;
867 save << " " << "__ENF_GROUP_END__";
870 save << " " << "$"; // "$" is a mark of enforced vertex end
872 save << "#"; // "#" is a mark of enforced shape end
874 save << " " << "__ENFORCED_VERTICES_END__";
880 //=============================================================================
881 std::istream & BLSURFPlugin_Hypothesis::LoadFrom(std::istream & load)
889 _topology = (Topology) i;
891 load.clear(std::ios::badbit | load.rdstate());
895 _physicalMesh = (PhysicalMesh) i;
897 load.clear(std::ios::badbit | load.rdstate());
901 _geometricMesh = (GeometricMesh) i;
903 load.clear(std::ios::badbit | load.rdstate());
905 isOK = (load >> val);
909 load.clear(std::ios::badbit | load.rdstate());
911 isOK = (load >> val);
915 load.clear(std::ios::badbit | load.rdstate());
917 isOK = (load >> val);
921 load.clear(std::ios::badbit | load.rdstate());
925 _quadAllowed = (bool) i;
927 load.clear(std::ios::badbit | load.rdstate());
931 _decimesh = (bool) i;
933 load.clear(std::ios::badbit | load.rdstate());
935 isOK = (load >> val);
939 load.clear(std::ios::badbit | load.rdstate());
941 isOK = (load >> val);
945 load.clear(std::ios::badbit | load.rdstate());
947 isOK = (load >> val);
951 load.clear(std::ios::badbit | load.rdstate());
953 isOK = (load >> val);
957 load.clear(std::ios::badbit | load.rdstate());
959 isOK = (load >> val);
963 load.clear(std::ios::badbit | load.rdstate());
969 load.clear(std::ios::badbit | load.rdstate());
971 std::string option_or_sm;
972 bool hasOptions = false;
973 bool hasSizeMap = false;
974 bool hasAttractor = false;
975 bool hasEnforcedVertex = false;
977 isOK = (load >> option_or_sm);
979 if (option_or_sm == "__OPTIONS_BEGIN__")
981 else if (option_or_sm == "__SIZEMAP_BEGIN__")
983 else if (option_or_sm == "__ATTRACTORS_BEGIN__")
985 else if (option_or_sm == "__ENFORCED_VERTICES_BEGIN__")
986 hasEnforcedVertex = true;
988 std::string optName, optValue;
989 while (isOK && hasOptions) {
990 isOK = (load >> optName);
992 if (optName == "__OPTIONS_END__")
994 isOK = (load >> optValue);
997 std::string & value = _option2value[ optName ];
999 int len = value.size();
1000 // continue reading until "%#" encountered
1001 while ( value[len-1] != '#' || value[len-2] != '%' )
1003 isOK = (load >> optValue);
1013 value[ len-2 ] = '\0'; //cut off "%#"
1018 isOK = (load >> option_or_sm);
1020 if (option_or_sm == "__SIZEMAP_BEGIN__")
1022 else if (option_or_sm == "__ATTRACTORS_BEGIN__")
1023 hasAttractor = true;
1024 else if (option_or_sm == "__ENFORCED_VERTICES_BEGIN__")
1025 hasEnforcedVertex = true;
1028 std::string smEntry, smValue;
1029 while (isOK && hasSizeMap) {
1030 isOK = (load >> smEntry);
1032 if (smEntry == "__SIZEMAP_END__")
1034 isOK = (load >> smValue);
1037 std::string & value2 = _sizeMap[ smEntry ];
1039 int len2= value2.size();
1040 // continue reading until "%#" encountered
1041 while ( value2[len2-1] != '#' || value2[len2-2] != '%' )
1043 isOK = (load >> smValue);
1047 len2 = value2.size();
1053 value2[ len2-2 ] = '\0'; //cut off "%#"
1058 isOK = (load >> option_or_sm);
1060 if (option_or_sm == "__ATTRACTORS_BEGIN__")
1061 hasAttractor = true;
1062 else if (option_or_sm == "__ENFORCED_VERTICES_BEGIN__")
1063 hasEnforcedVertex = true;
1066 std::string atEntry, atValue;
1067 while (isOK && hasAttractor) {
1068 isOK = (load >> atEntry);
1070 if (atEntry == "__ATTRACTORS_END__")
1072 isOK = (load >> atValue);
1075 std::string & value3 = _attractors[ atEntry ];
1077 int len3= value3.size();
1078 // continue reading until "%#" encountered
1079 while ( value3[len3-1] != '#' || value3[len3-2] != '%' )
1081 isOK = (load >> atValue);
1085 len3 = value3.size();
1091 value3[ len3-2 ] = '\0'; //cut off "%#"
1096 isOK = (load >> option_or_sm);
1098 if (option_or_sm == "__ENFORCED_VERTICES_BEGIN__")
1099 hasEnforcedVertex = true;
1102 std::string enfEntry, enfValue, enfGroup, trace;
1103 std::ostringstream oss;
1104 while (isOK && hasEnforcedVertex) {
1105 isOK = (load >> enfEntry);
1107 MESSAGE("enfEntry: " <<enfEntry);
1108 if (enfEntry == "__ENFORCED_VERTICES_END__")
1112 bool hasGroup = false;
1115 int len4 = enfValue.size();
1117 TEnfVertexList & evl = _entryEnfVertexListMap[enfEntry];
1119 TEnfVertex enfVertex;
1121 // continue reading until "#" encountered
1122 while ( enfValue[len4-1] != '#') {
1125 while ( enfValue[len4-1] != '$') {
1126 isOK = (load >> enfValue);
1128 MESSAGE("enfValue: " <<enfValue);
1129 len4 = enfValue.size();
1130 // End of vertex list
1131 if (enfValue[len4-1] == '#')
1134 if (enfValue == "__ENF_GROUP_BEGIN__") {
1136 isOK = (load >> enfGroup);
1137 MESSAGE("enfGroup: " <<enfGroup);
1138 TEnfGroupName& groupName = _enfVertexGroupNameMap[ enfVertex ];
1139 groupName = enfGroup;
1141 isOK = (load >> enfGroup);
1143 MESSAGE("enfGroup: " <<enfGroup);
1144 if (enfGroup == "__ENF_GROUP_END__")
1147 groupName += enfGroup;
1153 enfVertex.push_back(atof(enfValue.c_str()));
1156 if (enfValue[len4-1] != '$') {
1158 enfVertex.push_back(atof(enfValue.c_str()));
1164 if (enfValue[len4-1] == '$') {
1165 MESSAGE("enfValue is $");
1166 enfValue[len4-1] = '\0'; //cut off "$"
1169 MESSAGE("no group: remove $");
1170 // Remove '$' and add to vertex
1171 // enfValue[len4-1] = '\0'; //cut off "$#"
1172 enfVertex.push_back(atof(enfValue.c_str()));
1175 enfValue[len4-1] = '\0'; //cut off "$#"
1176 enfVertex.push_back(atof(enfValue.c_str()));
1177 MESSAGE("Add vertex to list");
1178 // Add vertex to list of vertex
1179 evl.insert(enfVertex);
1182 if (enfValue[len4-1] == '#') {
1185 // Remove '$#' and add to vertex
1186 enfValue[len4-2] = '\0'; //cut off "$#"
1187 enfVertex.push_back(atof(enfValue.c_str()));
1190 // Remove '$#' and add to vertex
1191 enfValue[len4-2] = '\0'; //cut off "$#"
1192 enfVertex.push_back(atof(enfValue.c_str()));
1193 // Add vertex to list of vertex
1194 evl.insert(enfVertex);
1204 //=============================================================================
1205 std::ostream & operator <<(std::ostream & save, BLSURFPlugin_Hypothesis & hyp)
1207 return hyp.SaveTo( save );
1210 //=============================================================================
1211 std::istream & operator >>(std::istream & load, BLSURFPlugin_Hypothesis & hyp)
1213 return hyp.LoadFrom( load );
1216 //================================================================================
1218 * \brief Does nothing
1220 //================================================================================
1222 bool BLSURFPlugin_Hypothesis::SetParametersByMesh(const SMESH_Mesh* theMesh,
1223 const TopoDS_Shape& theShape)
1228 //=============================================================================
1230 * \brief Initialize my parameter values by default parameters.
1231 * \retval bool - true if parameter values have been successfully defined
1233 //=============================================================================
1235 bool BLSURFPlugin_Hypothesis::SetParametersByDefaults(const TDefaults& dflts,
1236 const SMESH_Mesh* theMesh)
1238 return bool( _phySize = dflts._elemLength );
1241 //=============================================================================
1242 BLSURFPlugin_Hypothesis::Topology BLSURFPlugin_Hypothesis::GetDefaultTopology()
1247 //=============================================================================
1248 BLSURFPlugin_Hypothesis::PhysicalMesh BLSURFPlugin_Hypothesis::GetDefaultPhysicalMesh()
1250 return PhysicalUserDefined;
1253 //=============================================================================
1254 double BLSURFPlugin_Hypothesis::GetDefaultPhySize()
1259 //======================================================================
1260 double BLSURFPlugin_Hypothesis::GetDefaultMaxSize()
1262 return undefinedDouble(); // 1e+4;
1265 //======================================================================
1266 double BLSURFPlugin_Hypothesis::GetDefaultMinSize()
1268 return undefinedDouble(); //1e-4;
1271 //======================================================================
1272 BLSURFPlugin_Hypothesis::GeometricMesh BLSURFPlugin_Hypothesis::GetDefaultGeometricMesh()
1277 //=============================================================================
1278 double BLSURFPlugin_Hypothesis::GetDefaultAngleMeshS()
1283 //=============================================================================
1284 double BLSURFPlugin_Hypothesis::GetDefaultGradation()
1289 //=============================================================================
1290 bool BLSURFPlugin_Hypothesis::GetDefaultQuadAllowed()
1295 //=============================================================================
1296 bool BLSURFPlugin_Hypothesis::GetDefaultDecimesh()