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 development: Nicolas GEIMER (OCC) & Gilles DAVID (EURIWARE)
27 #include "BLSURFPlugin_Hypothesis.hxx"
28 #include "BLSURFPlugin_Attractor.hxx"
29 #include "SMESH_Gen_i.hxx"
30 #include <utilities.h>
36 #include "ShapeAnalysis.hxx"
39 #include CORBA_CLIENT_HEADER(SALOMEDS)
40 #include CORBA_CLIENT_HEADER(GEOM_Gen)
42 //=============================================================================
43 BLSURFPlugin_Hypothesis::BLSURFPlugin_Hypothesis(int hypId, int studyId, SMESH_Gen * gen) :
44 SMESH_Hypothesis(hypId, studyId, gen), _topology(GetDefaultTopology()),
45 _physicalMesh(GetDefaultPhysicalMesh()),
46 _phySize(GetDefaultPhySize()),
47 _phyMax(GetDefaultMaxSize()),
48 _phyMin(GetDefaultMinSize()),
49 _hgeoMax(GetDefaultMaxSize()),
50 _hgeoMin(GetDefaultMinSize()),
51 _geometricMesh(GetDefaultGeometricMesh()),
52 _angleMeshS(GetDefaultAngleMeshS()),
53 _angleMeshC(GetDefaultAngleMeshC()),
54 _gradation(GetDefaultGradation()),
55 _quadAllowed(GetDefaultQuadAllowed()),
56 _decimesh(GetDefaultDecimesh()),
57 _verb(GetDefaultVerbosity()),
58 _sizeMap(GetDefaultSizeMap()),
59 _attractors(GetDefaultSizeMap()),
60 _classAttractors(GetDefaultAttractorMap()),
61 _faceEntryEnfVertexListMap(GetDefaultFaceEntryEnfVertexListMap()),
62 _enfVertexList(GetDefaultEnfVertexList()),
63 _faceEntryCoordsListMap(GetDefaultFaceEntryCoordsListMap()),
64 _coordsEnfVertexMap(GetDefaultCoordsEnfVertexMap()),
65 _faceEntryEnfVertexEntryListMap(GetDefaultFaceEntryEnfVertexEntryListMap()),
66 _enfVertexEntryEnfVertexMap(GetDefaultEnfVertexEntryEnfVertexMap()),
67 _groupNameNodeIDMap(GetDefaultGroupNameNodeIDMap())
69 _groupNameEnfVertexListMap(GetDefaultGroupNameEnfVertexListMap()),
70 _enfVertexGroupNameMap(GetDefaultEnfVertexGroupNameMap())
73 _name = "BLSURF_Parameters";
76 // to disable writing boundaries
77 //_phyMin = _phyMax = _hgeoMin = _hgeoMax = undefinedDouble();
80 const char* intOptionNames[] = { "addsurf_ivertex", "background", "CheckAdjacentEdges", "CheckCloseEdges",
81 "CheckWellDefined", "coiter", "communication", "decim", "export_flag", "file_h", "frontal", "gridnu", "gridnv",
82 "hinterpol_flag", "hmean_flag", "intermedfile", "memory", "normals", "optim", "pardom_flag", "pinch", "refs",
83 "rigid", "surforient", "tconf", "topo_collapse", "" // mark of end
85 const char* doubleOptionNames[] = { "addsurf_angle", "addsurf_R", "addsurf_H", "addsurf_FG", "addsurf_r",
86 "addsurf_PA", "angle_compcurv", "angle_ridge", "CoefRectangle", "eps_collapse", "eps_ends", "eps_pardom", "LSS",
87 "topo_eps1", "topo_eps2", "" // mark of end
89 const char* charOptionNames[] = { "export_format", "export_option", "import_option", "prefix", "" // mark of end
93 while (intOptionNames[i][0])
94 _option2value[intOptionNames[i++]].clear();
97 while (doubleOptionNames[i][0]) {
98 _doubleOptions.insert(doubleOptionNames[i]);
99 _option2value[doubleOptionNames[i++]].clear();
102 while (charOptionNames[i][0]) {
103 _charOptions.insert(charOptionNames[i]);
104 _option2value[charOptionNames[i++]].clear();
109 _faceEntryEnfVertexListMap.clear();
110 _enfVertexList.clear();
111 _faceEntryCoordsListMap.clear();
112 _coordsEnfVertexMap.clear();
113 _faceEntryEnfVertexEntryListMap.clear();
114 _enfVertexEntryEnfVertexMap.clear();
115 _groupNameNodeIDMap.clear();
118 _groupNameEnfVertexListMap.clear();
119 _enfVertexGroupNameMap.clear();
123 TopoDS_Shape BLSURFPlugin_Hypothesis::entryToShape(std::string entry)
125 MESSAGE("BLSURFPlugin_Hypothesis::entryToShape "<<entry );
126 GEOM::GEOM_Object_var aGeomObj;
127 SMESH_Gen_i* smeshGen_i = SMESH_Gen_i::GetSMESHGen();
128 SALOMEDS::Study_ptr myStudy = smeshGen_i->GetCurrentStudy();
130 TopoDS_Shape S = TopoDS_Shape();
131 SALOMEDS::SObject_var aSObj = myStudy->FindObjectID( entry.c_str() );
132 SALOMEDS::GenericAttribute_var anAttr;
134 if (!aSObj->_is_nil() && aSObj->FindAttribute(anAttr, "AttributeIOR")) {
135 SALOMEDS::AttributeIOR_var anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
136 CORBA::String_var aVal = anIOR->Value();
137 CORBA::Object_var obj = myStudy->ConvertIORToObject(aVal);
138 aGeomObj = GEOM::GEOM_Object::_narrow(obj);
140 if ( !aGeomObj->_is_nil() )
141 S = smeshGen_i->GeomObjectToShape( aGeomObj.in() );
145 //=============================================================================
146 void BLSURFPlugin_Hypothesis::SetTopology(Topology theTopology) {
147 if (theTopology != _topology) {
148 _topology = theTopology;
149 NotifySubMeshesHypothesisModification();
153 //=============================================================================
154 void BLSURFPlugin_Hypothesis::SetPhysicalMesh(PhysicalMesh thePhysicalMesh) {
155 if (thePhysicalMesh != _physicalMesh) {
156 _physicalMesh = thePhysicalMesh;
157 switch (_physicalMesh) {
160 _phySize = GetDefaultPhySize();
161 _gradation = GetDefaultGradation();
164 NotifySubMeshesHypothesisModification();
168 //=============================================================================
169 void BLSURFPlugin_Hypothesis::SetPhySize(double theVal) {
170 if (theVal != _phySize) {
172 NotifySubMeshesHypothesisModification();
176 //=============================================================================
177 void BLSURFPlugin_Hypothesis::SetPhyMin(double theMinSize) {
178 if (theMinSize != _phyMin) {
179 _phyMin = theMinSize;
180 NotifySubMeshesHypothesisModification();
184 //=============================================================================
185 void BLSURFPlugin_Hypothesis::SetPhyMax(double theMaxSize) {
186 if (theMaxSize != _phyMax) {
187 _phyMax = theMaxSize;
188 NotifySubMeshesHypothesisModification();
192 //=============================================================================
193 void BLSURFPlugin_Hypothesis::SetGeoMin(double theMinSize) {
194 if (theMinSize != _hgeoMin) {
195 _hgeoMin = theMinSize;
196 NotifySubMeshesHypothesisModification();
200 //=============================================================================
201 void BLSURFPlugin_Hypothesis::SetGeoMax(double theMaxSize) {
202 if (theMaxSize != _hgeoMax) {
203 _hgeoMax = theMaxSize;
204 NotifySubMeshesHypothesisModification();
208 //=============================================================================
209 void BLSURFPlugin_Hypothesis::SetGeometricMesh(GeometricMesh theGeometricMesh) {
210 if (theGeometricMesh != _geometricMesh) {
211 _geometricMesh = theGeometricMesh;
212 switch (_geometricMesh) {
215 _angleMeshS = GetDefaultAngleMeshS();
216 _gradation = GetDefaultGradation();
219 NotifySubMeshesHypothesisModification();
223 //=============================================================================
224 void BLSURFPlugin_Hypothesis::SetAngleMeshS(double theVal) {
225 if (theVal != _angleMeshS) {
226 _angleMeshS = theVal;
227 NotifySubMeshesHypothesisModification();
231 //=============================================================================
232 void BLSURFPlugin_Hypothesis::SetAngleMeshC(double theVal) {
233 if (theVal != _angleMeshC) {
234 _angleMeshC = theVal;
235 NotifySubMeshesHypothesisModification();
239 //=============================================================================
240 void BLSURFPlugin_Hypothesis::SetGradation(double theVal) {
241 if (theVal != _gradation) {
243 NotifySubMeshesHypothesisModification();
247 //=============================================================================
248 void BLSURFPlugin_Hypothesis::SetQuadAllowed(bool theVal) {
249 if (theVal != _quadAllowed) {
250 _quadAllowed = theVal;
251 NotifySubMeshesHypothesisModification();
255 //=============================================================================
256 void BLSURFPlugin_Hypothesis::SetDecimesh(bool theVal) {
257 if (theVal != _decimesh) {
259 NotifySubMeshesHypothesisModification();
263 //=============================================================================
264 void BLSURFPlugin_Hypothesis::SetVerbosity(int theVal) {
265 if (theVal != _verb) {
267 NotifySubMeshesHypothesisModification();
270 //=============================================================================
271 void BLSURFPlugin_Hypothesis::SetOptionValue(const std::string& optionName, const std::string& optionValue)
272 throw (std::invalid_argument) {
273 TOptionValues::iterator op_val = _option2value.find(optionName);
274 if (op_val == _option2value.end()) {
275 std::string msg = "Unknown BLSURF option: '" + optionName + "'";
276 throw std::invalid_argument(msg);
278 if (op_val->second != optionValue) {
279 const char* ptr = optionValue.c_str();
280 // strip white spaces
281 while (ptr[0] == ' ')
284 while (i != 0 && ptr[i - 1] == ' ')
288 std::string typeName;
291 } else if (_charOptions.find(optionName) != _charOptions.end()) {
292 // do not check strings
293 } else if (_doubleOptions.find(optionName) != _doubleOptions.end()) {
294 // check if value is double
296 strtod(ptr, &endPtr);
297 typeOk = (ptr != endPtr);
300 // check if value is int
302 strtol(ptr, &endPtr, 10);
303 typeOk = (ptr != endPtr);
304 typeName = "integer";
307 std::string msg = "Advanced option '" + optionName + "' = '" + optionValue + "' but must be " + typeName;
308 throw std::invalid_argument(msg);
310 op_val->second = optionValue;
311 NotifySubMeshesHypothesisModification();
315 //=============================================================================
316 std::string BLSURFPlugin_Hypothesis::GetOptionValue(const std::string& optionName) throw (std::invalid_argument) {
317 TOptionValues::iterator op_val = _option2value.find(optionName);
318 if (op_val == _option2value.end()) {
319 std::string msg = "Unknown BLSURF option: <";
320 msg += optionName + ">";
321 throw std::invalid_argument(msg);
323 return op_val->second;
326 //=============================================================================
327 void BLSURFPlugin_Hypothesis::ClearOption(const std::string& optionName) {
328 TOptionValues::iterator op_val = _option2value.find(optionName);
329 if (op_val != _option2value.end())
330 op_val->second.clear();
333 //=======================================================================
334 //function : SetSizeMapEntry
335 //=======================================================================
336 void BLSURFPlugin_Hypothesis::SetSizeMapEntry(const std::string& entry, const std::string& sizeMap) {
337 if (_sizeMap[entry].compare(sizeMap) != 0) {
338 _sizeMap[entry] = sizeMap;
339 NotifySubMeshesHypothesisModification();
343 //=======================================================================
344 //function : GetSizeMapEntry
345 //=======================================================================
346 std::string BLSURFPlugin_Hypothesis::GetSizeMapEntry(const std::string& entry) {
347 TSizeMap::iterator it = _sizeMap.find(entry);
348 if (it != _sizeMap.end())
351 return "No_Such_Entry";
355 * \brief Return the size maps
357 BLSURFPlugin_Hypothesis::TSizeMap BLSURFPlugin_Hypothesis::GetSizeMapEntries(const BLSURFPlugin_Hypothesis* hyp) {
358 return hyp ? hyp->_GetSizeMapEntries() : GetDefaultSizeMap();
361 //=======================================================================
362 //function : SetAttractorEntry
363 //=======================================================================
364 void BLSURFPlugin_Hypothesis::SetAttractorEntry(const std::string& entry, const std::string& attractor) {
365 if (_attractors[entry].compare(attractor) != 0) {
366 _attractors[entry] = attractor;
367 NotifySubMeshesHypothesisModification();
371 //=======================================================================
372 //function : GetAttractorEntry
373 //=======================================================================
374 std::string BLSURFPlugin_Hypothesis::GetAttractorEntry(const std::string& entry) {
375 TSizeMap::iterator it = _attractors.find(entry);
376 if (it != _attractors.end())
379 return "No_Such_Entry";
383 * \brief Return the attractors
385 BLSURFPlugin_Hypothesis::TSizeMap BLSURFPlugin_Hypothesis::GetAttractorEntries(const BLSURFPlugin_Hypothesis* hyp) {
386 return hyp ? hyp->_GetAttractorEntries() : GetDefaultSizeMap();
389 //=======================================================================
390 //function : SetClassAttractorEntry
391 //=======================================================================
392 void BLSURFPlugin_Hypothesis::SetClassAttractorEntry(const std::string& entry, const std::string& attEntry, double StartSize, double EndSize, double ActionRadius, double ConstantRadius)
394 // The new attractor can't be defined on the same face as another sizemap
395 TSizeMap::iterator it = _sizeMap.find( entry );
396 if ( it != _sizeMap.end() ) {
398 NotifySubMeshesHypothesisModification();
401 TSizeMap::iterator itAt = _attractors.find( entry );
402 if ( itAt != _attractors.end() ) {
403 _attractors.erase(itAt);
404 NotifySubMeshesHypothesisModification();
408 const TopoDS_Shape AttractorShape = BLSURFPlugin_Hypothesis::entryToShape(attEntry);
409 const TopoDS_Face FaceShape = TopoDS::Face(BLSURFPlugin_Hypothesis::entryToShape(entry));
410 bool attExists = (_classAttractors.find(entry) != _classAttractors.end());
411 double u1,u2,v1,v2, diag;
413 if ( !attExists || (attExists && _classAttractors[entry]->GetAttractorEntry().compare(attEntry) != 0)){
414 ShapeAnalysis::GetFaceUVBounds(FaceShape,u1,u2,v1,v2);
415 diag = sqrt((u2 - u1) * (u2 - u1) + (v2 - v1) * (v2 - v1));
416 BLSURFPlugin_Attractor* myAttractor = new BLSURFPlugin_Attractor(FaceShape, AttractorShape, attEntry, 0.1 ); // test 0.002 * diag);
417 myAttractor->BuildMap();
418 myAttractor->SetParameters(StartSize, EndSize, ActionRadius, ConstantRadius);
419 _classAttractors[entry] = myAttractor;
420 NotifySubMeshesHypothesisModification();
423 _classAttractors[entry]->SetParameters(StartSize, EndSize, ActionRadius, ConstantRadius);
424 if (!_classAttractors[entry]->IsMapBuilt()){
425 _classAttractors[entry]->BuildMap();
427 NotifySubMeshesHypothesisModification();
432 //=======================================================================
433 //function : SetConstantSizeOnAdjacentFaces
434 //=======================================================================
435 // TODO uncomment and test (include the needed .hxx)
436 // SetConstantSizeOnAdjacentFaces(myShape, att_entry, startSize, endSize = user_size, const_dist ) {
437 // TopTools_IndexedMapOfShapListOdShape anEdge2FaceMap;
438 // TopExp::MapShapesAnAncestors(myShape,TopAbs_EDGE, TopAbs_FACE, anEdge2FaceMap);
439 // TopTools_IndexedMapOfShapListOdShape::iterator it;
440 // for (it = anEdge2FaceMap.begin();it != anEdge2FaceMap.end();it++){
441 // SetClassAttractorEntry((*it).first, att_entry, startSize, endSize, 0, const_dist)
449 //=======================================================================
450 //function : GetClassAttractorEntry
451 //=======================================================================
452 // BLSURFPlugin_Attractor& BLSURFPlugin_Hypothesis::GetClassAttractorEntry(const std::string& entry)
454 // TAttractorMap::iterator it = _classAttractors.find( entry );
455 // if ( it != _classAttractors.end() )
456 // return it->second;
458 // return "No_Such_Entry";
462 * \brief Return the map of attractor instances
464 BLSURFPlugin_Hypothesis::TAttractorMap BLSURFPlugin_Hypothesis::GetClassAttractorEntries(const BLSURFPlugin_Hypothesis* hyp)
466 return hyp ? hyp->_GetClassAttractorEntries():GetDefaultAttractorMap();
469 //=======================================================================
470 //function : ClearEntry
471 //=======================================================================
472 void BLSURFPlugin_Hypothesis::ClearEntry(const std::string& entry)
474 TSizeMap::iterator it = _sizeMap.find( entry );
476 if ( it != _sizeMap.end() ) {
478 NotifySubMeshesHypothesisModification();
481 TSizeMap::iterator itAt = _attractors.find( entry );
482 if ( itAt != _attractors.end() ) {
483 _attractors.erase(itAt);
484 NotifySubMeshesHypothesisModification();
487 TAttractorMap::iterator it_clAt = _classAttractors.find( entry );
488 if ( it_clAt != _classAttractors.end() ) {
489 _classAttractors.erase(it_clAt);
490 MESSAGE("_classAttractors.size() = "<<_classAttractors.size())
491 NotifySubMeshesHypothesisModification();
494 std::cout<<"No_Such_Entry"<<std::endl;
499 //=======================================================================
500 //function : ClearSizeMaps
501 //=======================================================================
502 void BLSURFPlugin_Hypothesis::ClearSizeMaps() {
505 _classAttractors.clear();
508 //=======================================================================
509 //function : SetEnforcedVertex
510 //=======================================================================
511 bool BLSURFPlugin_Hypothesis::SetEnforcedVertex(TEntry theFaceEntry, TEnfName theVertexName, TEntry theVertexEntry,
512 TEnfGroupName theGroupName, double x, double y, double z) {
514 MESSAGE("BLSURFPlugin_Hypothesis::SetEnforcedVertex("<< theFaceEntry << ", "
515 << x << ", " << y << ", " << z << ", " << theVertexName << ", " << theVertexEntry << ", " << theGroupName << ")");
517 // TEnfVertexList::iterator it;
518 bool toNotify = false;
519 bool toCreate = true;
521 TEnfVertex *oldEnVertex;
522 TEnfVertex *newEnfVertex = new TEnfVertex();
523 newEnfVertex->name = theVertexName;
524 newEnfVertex->geomEntry = theVertexEntry;
525 newEnfVertex->coords.clear();
526 if (theVertexEntry == "") {
527 newEnfVertex->coords.push_back(x);
528 newEnfVertex->coords.push_back(y);
529 newEnfVertex->coords.push_back(z);
531 newEnfVertex->grpName = theGroupName;
532 newEnfVertex->faceEntries.clear();
533 newEnfVertex->faceEntries.insert(theFaceEntry);
536 // update _enfVertexList
537 TEnfVertexList::iterator it = _enfVertexList.find(newEnfVertex);
538 if (it != _enfVertexList.end()) {
541 MESSAGE("Enforced Vertex was found => Update");
542 if (oldEnVertex->name != theVertexName) {
543 MESSAGE("Update name from \"" << oldEnVertex->name << "\" to \"" << theVertexName << "\"");
544 oldEnVertex->name = theVertexName;
547 if (oldEnVertex->grpName != theGroupName) {
548 MESSAGE("Update group name from \"" << oldEnVertex->grpName << "\" to \"" << theGroupName << "\"");
549 oldEnVertex->grpName = theGroupName;
552 TEntryList::iterator it_faceEntries = oldEnVertex->faceEntries.find(theFaceEntry);
553 if (it_faceEntries == oldEnVertex->faceEntries.end()) {
554 MESSAGE("Update face list by adding \"" << theFaceEntry << "\"");
555 oldEnVertex->faceEntries.insert(theFaceEntry);
556 _faceEntryEnfVertexListMap[theFaceEntry].insert(oldEnVertex);
560 // update map coords / enf vertex if needed
561 if (oldEnVertex->coords.size()) {
562 _coordsEnfVertexMap[oldEnVertex->coords] = oldEnVertex;
563 _faceEntryCoordsListMap[theFaceEntry].insert(oldEnVertex->coords);
566 // update map geom entry / enf vertex if needed
567 if (oldEnVertex->geomEntry != "") {
568 _enfVertexEntryEnfVertexMap[oldEnVertex->geomEntry] = oldEnVertex;
569 _faceEntryEnfVertexEntryListMap[theFaceEntry].insert(oldEnVertex->geomEntry);
574 // //////// CREATE ////////////
577 MESSAGE("Creating new enforced vertex");
578 _faceEntryEnfVertexListMap[theFaceEntry].insert(newEnfVertex);
579 _enfVertexList.insert(newEnfVertex);
580 if (theVertexEntry == "") {
581 _faceEntryCoordsListMap[theFaceEntry].insert(newEnfVertex->coords);
582 _coordsEnfVertexMap[newEnfVertex->coords] = newEnfVertex;
585 _faceEntryEnfVertexEntryListMap[theFaceEntry].insert(newEnfVertex->geomEntry);
586 _enfVertexEntryEnfVertexMap[newEnfVertex->geomEntry] = newEnfVertex;
591 NotifySubMeshesHypothesisModification();
593 MESSAGE("BLSURFPlugin_Hypothesis::SetEnforcedVertex END");
598 //=======================================================================
599 //function : GetEnforcedVertices
600 //=======================================================================
602 BLSURFPlugin_Hypothesis::TEnfVertexList BLSURFPlugin_Hypothesis::GetEnfVertexList(const TEntry& theFaceEntry)
603 throw (std::invalid_argument) {
605 if (_faceEntryEnfVertexListMap.count(theFaceEntry) > 0)
606 return _faceEntryEnfVertexListMap[theFaceEntry];
608 return GetDefaultEnfVertexList();
610 std::ostringstream msg;
611 msg << "No enforced vertex for face entry " << theFaceEntry;
612 throw std::invalid_argument(msg.str());
615 //=======================================================================
616 //function : GetEnfVertexCoordsList
617 //=======================================================================
619 BLSURFPlugin_Hypothesis::TEnfVertexCoordsList BLSURFPlugin_Hypothesis::GetEnfVertexCoordsList(
620 const TEntry& theFaceEntry) throw (std::invalid_argument) {
622 if (_faceEntryCoordsListMap.count(theFaceEntry) > 0)
623 return _faceEntryCoordsListMap[theFaceEntry];
625 std::ostringstream msg;
626 msg << "No enforced vertex coords for face entry " << theFaceEntry;
627 throw std::invalid_argument(msg.str());
630 //=======================================================================
631 //function : GetEnfVertexEntryList
632 //=======================================================================
634 BLSURFPlugin_Hypothesis::TEntryList BLSURFPlugin_Hypothesis::GetEnfVertexEntryList(const TEntry& theFaceEntry)
635 throw (std::invalid_argument) {
637 if (_faceEntryEnfVertexEntryListMap.count(theFaceEntry) > 0)
638 return _faceEntryEnfVertexEntryListMap[theFaceEntry];
640 std::ostringstream msg;
641 msg << "No enforced vertex entry for face entry " << theFaceEntry;
642 throw std::invalid_argument(msg.str());
645 //=======================================================================
646 //function : GetEnfVertex(TEnfVertexCoords coords)
647 //=======================================================================
649 BLSURFPlugin_Hypothesis::TEnfVertex* BLSURFPlugin_Hypothesis::GetEnfVertex(TEnfVertexCoords coords)
650 throw (std::invalid_argument) {
652 if (_coordsEnfVertexMap.count(coords) > 0)
653 return _coordsEnfVertexMap[coords];
655 std::ostringstream msg;
656 msg << "No enforced vertex with coords (" << coords[0] << ", " << coords[1] << ", " << coords[2] << ")";
657 throw std::invalid_argument(msg.str());
660 //=======================================================================
661 //function : GetEnfVertex(const TEntry& theEnfVertexEntry)
662 //=======================================================================
664 BLSURFPlugin_Hypothesis::TEnfVertex* BLSURFPlugin_Hypothesis::GetEnfVertex(const TEntry& theEnfVertexEntry)
665 throw (std::invalid_argument) {
667 if (_enfVertexEntryEnfVertexMap.count(theEnfVertexEntry) > 0)
668 return _enfVertexEntryEnfVertexMap[theEnfVertexEntry];
670 std::ostringstream msg;
671 msg << "No enforced vertex with entry " << theEnfVertexEntry;
672 throw std::invalid_argument(msg.str());
675 //=======================================================================
676 //function : ClearEnforcedVertex
677 //=======================================================================
679 bool BLSURFPlugin_Hypothesis::ClearEnforcedVertex(const TEntry& theFaceEntry, double x, double y, double z,
680 const TEntry& theVertexEntry) throw (std::invalid_argument) {
682 bool toNotify = false;
683 std::ostringstream msg;
684 TEnfVertex *oldEnfVertex;
685 TEnfVertexCoords coords;
691 // check that enf vertex with given enf vertex entry exists
692 TEnfVertexEntryEnfVertexMap::iterator it_enfVertexEntry = _enfVertexEntryEnfVertexMap.find(theVertexEntry);
693 if (it_enfVertexEntry != _enfVertexEntryEnfVertexMap.end()) {
695 MESSAGE("Found enforced vertex with geom entry " << theVertexEntry);
696 oldEnfVertex = it_enfVertexEntry->second;
698 _enfVertexEntryEnfVertexMap.erase(it_enfVertexEntry);
700 TEntryList& enfVertexEntryList = _faceEntryEnfVertexEntryListMap[theFaceEntry];
701 enfVertexEntryList.erase(theVertexEntry);
702 if (enfVertexEntryList.size() == 0)
703 _faceEntryEnfVertexEntryListMap.erase(theFaceEntry);
704 // TFaceEntryEnfVertexEntryListMap::iterator it_entry_entry = _faceEntryEnfVertexEntryListMap.find(theFaceEntry);
705 // TEntryList::iterator it_entryList = it_entry_entry->second.find(theVertexEntry);
706 // it_entry_entry->second.erase(it_entryList);
707 // if (it_entry_entry->second.size() == 0)
708 // _faceEntryEnfVertexEntryListMap.erase(it_entry_entry);
711 MESSAGE("Enforced vertex with geom entry " << theVertexEntry << " not found");
712 msg << "No enforced vertex with geom entry " << theVertexEntry;
713 // check that enf vertex with given coords exists
714 TCoordsEnfVertexMap::iterator it_coords_enf = _coordsEnfVertexMap.find(coords);
715 if (it_coords_enf != _coordsEnfVertexMap.end()) {
717 MESSAGE("Found enforced vertex with coords " << x << ", " << y << ", " << z);
718 oldEnfVertex = it_coords_enf->second;
720 _coordsEnfVertexMap.erase(it_coords_enf);
722 TEnfVertexCoordsList& enfVertexCoordsList = _faceEntryCoordsListMap[theFaceEntry];
723 enfVertexCoordsList.erase(coords);
724 if (enfVertexCoordsList.size() == 0)
725 _faceEntryCoordsListMap.erase(theFaceEntry);
726 // TFaceEntryCoordsListMap::iterator it_entry_coords = _faceEntryCoordsListMap.find(theFaceEntry);
727 // TEnfVertexCoordsList::iterator it_coordsList = it_entry_coords->second.find(coords);
728 // it_entry_coords->second.erase(it_coordsList);
729 // if (it_entry_coords->second.size() == 0)
730 // _faceEntryCoordsListMap.erase(it_entry_coords);
733 MESSAGE("Enforced vertex with coords " << x << ", " << y << ", " << z << " not found");
735 msg << "No enforced vertex at " << x << ", " << y << ", " << z;
736 throw std::invalid_argument(msg.str());
740 MESSAGE("Remove enf vertex from _enfVertexList");
742 // update _enfVertexList
743 TEnfVertexList::iterator it = _enfVertexList.find(oldEnfVertex);
744 if (it != _enfVertexList.end()) {
745 (*it)->faceEntries.erase(theFaceEntry);
746 if ((*it)->faceEntries.size() == 0){
747 _enfVertexList.erase(it);
753 // update _faceEntryEnfVertexListMap
754 TEnfVertexList& currentEnfVertexList = _faceEntryEnfVertexListMap[theFaceEntry];
755 currentEnfVertexList.erase(oldEnfVertex);
757 if (currentEnfVertexList.size() == 0) {
758 MESSAGE("Remove _faceEntryEnfVertexListMap[" << theFaceEntry <<"]");
759 _faceEntryEnfVertexListMap.erase(theFaceEntry);
764 NotifySubMeshesHypothesisModification();
769 //=======================================================================
770 //function : ClearEnforcedVertices
771 //=======================================================================
773 bool BLSURFPlugin_Hypothesis::ClearEnforcedVertices(const TEntry& theFaceEntry) throw (std::invalid_argument) {
775 bool toNotify = false;
776 TEnfVertex *oldEnfVertex;
778 TFaceEntryCoordsListMap::iterator it_entry_coords = _faceEntryCoordsListMap.find(theFaceEntry);
779 if (it_entry_coords != _faceEntryCoordsListMap.end()) {
781 TEnfVertexCoordsList coordsList = it_entry_coords->second;
782 TEnfVertexCoordsList::iterator it_coordsList = coordsList.begin();
783 for (; it_coordsList != coordsList.end(); ++it_coordsList) {
784 TEnfVertexCoords coords = (*it_coordsList);
785 oldEnfVertex = _coordsEnfVertexMap[coords];
786 _coordsEnfVertexMap.erase(coords);
787 // update _enfVertexList
788 TEnfVertexList::iterator it = _enfVertexList.find(oldEnfVertex);
789 if (it != _enfVertexList.end()) {
790 (*it)->faceEntries.erase(theFaceEntry);
791 if ((*it)->faceEntries.size() == 0){
792 _enfVertexList.erase(it);
798 _faceEntryCoordsListMap.erase(it_entry_coords);
799 _faceEntryEnfVertexListMap.erase(theFaceEntry);
802 TFaceEntryEnfVertexEntryListMap::iterator it_entry_entry = _faceEntryEnfVertexEntryListMap.find(theFaceEntry);
803 if (it_entry_entry != _faceEntryEnfVertexEntryListMap.end()) {
805 TEntryList enfVertexEntryList = it_entry_entry->second;
806 TEntryList::iterator it_enfVertexEntryList = enfVertexEntryList.begin();
807 for (; it_enfVertexEntryList != enfVertexEntryList.end(); ++it_enfVertexEntryList) {
808 TEntry enfVertexEntry = (*it_enfVertexEntryList);
809 oldEnfVertex = _enfVertexEntryEnfVertexMap[enfVertexEntry];
810 _enfVertexEntryEnfVertexMap.erase(enfVertexEntry);
811 // update _enfVertexList
812 TEnfVertexList::iterator it = _enfVertexList.find(oldEnfVertex);
813 if (it != _enfVertexList.end()) {
814 (*it)->faceEntries.erase(theFaceEntry);
815 if ((*it)->faceEntries.size() == 0){
816 _enfVertexList.erase(it);
822 _faceEntryEnfVertexEntryListMap.erase(it_entry_entry);
823 _faceEntryEnfVertexListMap.erase(theFaceEntry);
827 NotifySubMeshesHypothesisModification();
830 // std::ostringstream msg;
831 // msg << "No enforced vertex for " << theFaceEntry;
832 // throw std::invalid_argument(msg.str());
835 //=======================================================================
836 //function : ClearAllEnforcedVertices
837 //=======================================================================
838 void BLSURFPlugin_Hypothesis::ClearAllEnforcedVertices() {
839 _faceEntryEnfVertexListMap.clear();
840 _enfVertexList.clear();
841 _faceEntryCoordsListMap.clear();
842 _coordsEnfVertexMap.clear();
843 _faceEntryEnfVertexEntryListMap.clear();
844 _enfVertexEntryEnfVertexMap.clear();
845 NotifySubMeshesHypothesisModification();
848 //================================================================================
850 * \brief Return the enforced vertices
852 //================================================================================
855 BLSURFPlugin_Hypothesis::TFaceEntryEnfVertexListMap BLSURFPlugin_Hypothesis::GetAllEnforcedVerticesByFace(
856 const BLSURFPlugin_Hypothesis* hyp) {
857 return hyp ? hyp->_GetAllEnforcedVerticesByFace() : GetDefaultFaceEntryEnfVertexListMap();
860 BLSURFPlugin_Hypothesis::TEnfVertexList BLSURFPlugin_Hypothesis::GetAllEnforcedVertices(
861 const BLSURFPlugin_Hypothesis* hyp) {
862 return hyp ? hyp->_GetAllEnforcedVertices() : GetDefaultEnfVertexList();
865 BLSURFPlugin_Hypothesis::TFaceEntryCoordsListMap BLSURFPlugin_Hypothesis::GetAllCoordsByFace(
866 const BLSURFPlugin_Hypothesis* hyp) {
867 return hyp ? hyp->_GetAllCoordsByFace() : GetDefaultFaceEntryCoordsListMap();
870 BLSURFPlugin_Hypothesis::TCoordsEnfVertexMap BLSURFPlugin_Hypothesis::GetAllEnforcedVerticesByCoords(
871 const BLSURFPlugin_Hypothesis* hyp) {
872 return hyp ? hyp->_GetAllEnforcedVerticesByCoords() : GetDefaultCoordsEnfVertexMap();
875 BLSURFPlugin_Hypothesis::TFaceEntryEnfVertexEntryListMap BLSURFPlugin_Hypothesis::GetAllEnfVertexEntriesByFace(
876 const BLSURFPlugin_Hypothesis* hyp) {
877 return hyp ? hyp->_GetAllEnfVertexEntriesByFace() : GetDefaultFaceEntryEnfVertexEntryListMap();
880 BLSURFPlugin_Hypothesis::TEnfVertexEntryEnfVertexMap BLSURFPlugin_Hypothesis::GetAllEnforcedVerticesByEnfVertexEntry(
881 const BLSURFPlugin_Hypothesis* hyp) {
882 return hyp ? hyp->_GetAllEnforcedVerticesByEnfVertexEntry() : GetDefaultEnfVertexEntryEnfVertexMap();
885 std::set<int> BLSURFPlugin_Hypothesis::GetEnfVertexNodeIDs(TEnfGroupName theGroupName) throw (std::invalid_argument)
887 TGroupNameNodeIDMap::const_iterator it = _groupNameNodeIDMap.find(theGroupName);
888 if (it != _groupNameNodeIDMap.end()) {
891 std::ostringstream msg;
892 msg << "No group " << theGroupName;
893 throw std::invalid_argument(msg.str());
896 void BLSURFPlugin_Hypothesis::AddEnfVertexNodeID(TEnfGroupName theGroupName,int theNodeID)
898 _groupNameNodeIDMap[theGroupName].insert(theNodeID);
901 void BLSURFPlugin_Hypothesis::RemoveEnfVertexNodeID(TEnfGroupName theGroupName,int theNodeID) throw (std::invalid_argument)
903 TGroupNameNodeIDMap::iterator it = _groupNameNodeIDMap.find(theGroupName);
904 if (it != _groupNameNodeIDMap.end()) {
905 std::set<int>::iterator IDit = it->second.find(theNodeID);
906 if (IDit != it->second.end())
907 it->second.erase(IDit);
908 std::ostringstream msg;
909 msg << "No node IDs " << theNodeID << " for group " << theGroupName;
910 throw std::invalid_argument(msg.str());
912 std::ostringstream msg;
913 msg << "No group " << theGroupName;
914 throw std::invalid_argument(msg.str());
917 //=============================================================================
918 std::ostream & BLSURFPlugin_Hypothesis::SaveTo(std::ostream & save) {
919 save << " " << (int) _topology << " " << (int) _physicalMesh << " " << (int) _geometricMesh << " " << _phySize << " "
920 << _angleMeshS << " " << _gradation << " " << (int) _quadAllowed << " " << (int) _decimesh;
921 save << " " << _phyMin << " " << _phyMax << " " << _angleMeshC << " " << _hgeoMin << " " << _hgeoMax << " " << _verb;
923 TOptionValues::iterator op_val = _option2value.begin();
924 if (op_val != _option2value.end()) {
925 save << " " << "__OPTIONS_BEGIN__";
926 for (; op_val != _option2value.end(); ++op_val) {
927 if (!op_val->second.empty())
928 save << " " << op_val->first << " " << op_val->second << "%#"; // "%#" is a mark of value end
930 save << " " << "__OPTIONS_END__";
933 TSizeMap::iterator it_sm = _sizeMap.begin();
934 if (it_sm != _sizeMap.end()) {
935 save << " " << "__SIZEMAP_BEGIN__";
936 for (; it_sm != _sizeMap.end(); ++it_sm) {
937 save << " " << it_sm->first << " " << it_sm->second << "%#"; // "%#" is a mark of value end
939 save << " " << "__SIZEMAP_END__";
942 TSizeMap::iterator it_at = _attractors.begin();
943 if (it_at != _attractors.end()) {
944 save << " " << "__ATTRACTORS_BEGIN__";
945 for (; it_at != _attractors.end(); ++it_at) {
946 save << " " << it_at->first << " " << it_at->second << "%#"; // "%#" is a mark of value end
948 save << " " << "__ATTRACTORS_END__";
951 TAttractorMap::iterator it_At = _classAttractors.begin();
952 if (it_At != _classAttractors.end()) {
953 std::ostringstream test;
954 save << " " << "__NEW_ATTRACTORS_BEGIN__";
955 test << " " << "__NEW_ATTRACTORS_BEGIN__";
956 for (; it_At != _classAttractors.end(); ++it_At) {
957 std::vector<double> attParams;
958 attParams = it_At->second->GetParameters();
959 double step = it_At->second->GetStep();
960 save << " " << it_At->first;
961 save << " " << it_At->second->GetAttractorEntry();
962 save << " " << attParams[0] << " " << attParams[1] << " " << attParams[2] << " " << attParams[3];
964 test << " " << it_At->first;
965 test << " " << it_At->second->GetAttractorEntry();
966 test << " " << attParams[0] << " " << attParams[1] << " " << attParams[2] << " " << attParams[3];
969 save << " " << "__NEW_ATTRACTORS_END__";
970 test << " " << "__NEW_ATTRACTORS_END__";
971 MESSAGE(" Attractor hypothesis saved as "<<test.str())
974 TEnfVertexList::const_iterator it_enf = _enfVertexList.begin();
975 if (it_enf != _enfVertexList.end()) {
976 save << " " << "__ENFORCED_VERTICES_BEGIN__";
977 for (; it_enf != _enfVertexList.end(); ++it_enf) {
978 TEnfVertex *enfVertex = (*it_enf);
979 save << " " << "__BEGIN_VERTEX__";
980 if (!enfVertex->name.empty()) {
981 save << " " << "__BEGIN_NAME__";
982 save << " " << enfVertex->name;
983 save << " " << "__END_NAME__";
985 if (!enfVertex->geomEntry.empty()) {
986 save << " " << "__BEGIN_ENTRY__";
987 save << " " << enfVertex->geomEntry;
988 save << " " << "__END_ENTRY__";
990 if (!enfVertex->grpName.empty()) {
991 save << " " << "__BEGIN_GROUP__";
992 save << " " << enfVertex->grpName;
993 save << " " << "__END_GROUP__";
995 if (enfVertex->coords.size()) {
996 save << " " << "__BEGIN_COORDS__";
997 for (int i=0;i<enfVertex->coords.size();i++)
998 save << " " << enfVertex->coords[i];
999 save << " " << "__END_COORDS__";
1001 TEntryList::const_iterator faceEntriesIt = enfVertex->faceEntries.begin();
1002 bool hasFaces = false;
1003 if (faceEntriesIt != enfVertex->faceEntries.end()) {
1005 save << " " << "__BEGIN_FACELIST__";
1007 for (; faceEntriesIt != enfVertex->faceEntries.end(); ++faceEntriesIt)
1008 save << " " << (*faceEntriesIt);
1010 save << " " << "__END_FACELIST__";
1011 save << " " << "__END_VERTEX__";
1013 save << " " << "__ENFORCED_VERTICES_END__";
1019 //=============================================================================
1020 std::istream & BLSURFPlugin_Hypothesis::LoadFrom(std::istream & load) {
1027 _topology = (Topology) i;
1029 load.clear(std::ios::badbit | load.rdstate());
1033 _physicalMesh = (PhysicalMesh) i;
1035 load.clear(std::ios::badbit | load.rdstate());
1039 _geometricMesh = (GeometricMesh) i;
1041 load.clear(std::ios::badbit | load.rdstate());
1043 isOK = (load >> val);
1047 load.clear(std::ios::badbit | load.rdstate());
1049 isOK = (load >> val);
1053 load.clear(std::ios::badbit | load.rdstate());
1055 isOK = (load >> val);
1059 load.clear(std::ios::badbit | load.rdstate());
1063 _quadAllowed = (bool) i;
1065 load.clear(std::ios::badbit | load.rdstate());
1069 _decimesh = (bool) i;
1071 load.clear(std::ios::badbit | load.rdstate());
1073 isOK = (load >> val);
1077 load.clear(std::ios::badbit | load.rdstate());
1079 isOK = (load >> val);
1083 load.clear(std::ios::badbit | load.rdstate());
1085 isOK = (load >> val);
1089 load.clear(std::ios::badbit | load.rdstate());
1091 isOK = (load >> val);
1095 load.clear(std::ios::badbit | load.rdstate());
1097 isOK = (load >> val);
1101 load.clear(std::ios::badbit | load.rdstate());
1107 load.clear(std::ios::badbit | load.rdstate());
1109 std::string option_or_sm;
1110 bool hasOptions = false;
1111 bool hasSizeMap = false;
1112 bool hasAttractor = false;
1113 bool hasNewAttractor = false;
1114 bool hasEnforcedVertex = false;
1116 isOK = (load >> option_or_sm);
1118 if (option_or_sm == "__OPTIONS_BEGIN__")
1120 else if (option_or_sm == "__SIZEMAP_BEGIN__")
1122 else if (option_or_sm == "__ATTRACTORS_BEGIN__")
1123 hasAttractor = true;
1124 else if (option_or_sm == "__NEW_ATTRACTORS_BEGIN__")
1125 hasNewAttractor = true;
1126 else if (option_or_sm == "__ENFORCED_VERTICES_BEGIN__")
1127 hasEnforcedVertex = true;
1129 std::string optName, optValue;
1130 while (isOK && hasOptions) {
1131 isOK = (load >> optName);
1133 if (optName == "__OPTIONS_END__")
1135 isOK = (load >> optValue);
1138 std::string & value = _option2value[optName];
1140 int len = value.size();
1141 // continue reading until "%#" encountered
1142 while (value[len - 1] != '#' || value[len - 2] != '%') {
1143 isOK = (load >> optValue);
1152 value[len - 2] = '\0'; //cut off "%#"
1157 isOK = (load >> option_or_sm);
1159 if (option_or_sm == "__SIZEMAP_BEGIN__")
1161 else if (option_or_sm == "__ATTRACTORS_BEGIN__")
1162 hasAttractor = true;
1163 else if (option_or_sm == "__NEW_ATTRACTORS_BEGIN__")
1164 hasNewAttractor = true;
1165 else if (option_or_sm == "__ENFORCED_VERTICES_BEGIN__")
1166 hasEnforcedVertex = true;
1169 std::string smEntry, smValue;
1170 while (isOK && hasSizeMap) {
1171 isOK = (load >> smEntry);
1173 if (smEntry == "__SIZEMAP_END__")
1175 isOK = (load >> smValue);
1178 std::string & value2 = _sizeMap[smEntry];
1180 int len2 = value2.size();
1181 // continue reading until "%#" encountered
1182 while (value2[len2 - 1] != '#' || value2[len2 - 2] != '%') {
1183 isOK = (load >> smValue);
1187 len2 = value2.size();
1192 value2[len2 - 2] = '\0'; //cut off "%#"
1197 isOK = (load >> option_or_sm);
1199 if (option_or_sm == "__ATTRACTORS_BEGIN__")
1200 hasAttractor = true;
1201 if (option_or_sm == "__NEW_ATTRACTORS_BEGIN__")
1202 hasNewAttractor = true;
1203 else if (option_or_sm == "__ENFORCED_VERTICES_BEGIN__")
1204 hasEnforcedVertex = true;
1207 std::string atEntry, atValue;
1208 while (isOK && hasAttractor) {
1209 isOK = (load >> atEntry);
1211 if (atEntry == "__ATTRACTORS_END__")
1213 isOK = (load >> atValue);
1216 std::string & value3 = _attractors[atEntry];
1218 int len3 = value3.size();
1219 // continue reading until "%#" encountered
1220 while (value3[len3 - 1] != '#' || value3[len3 - 2] != '%') {
1221 isOK = (load >> atValue);
1225 len3 = value3.size();
1230 value3[len3 - 2] = '\0'; //cut off "%#"
1235 isOK = (load >> option_or_sm);
1237 if (option_or_sm == "__NEW_ATTRACTORS_BEGIN__")
1238 hasNewAttractor = true;
1239 else if (option_or_sm == "__ENFORCED_VERTICES_BEGIN__")
1240 hasEnforcedVertex = true;
1245 // Here is a example of the saved stream:
1246 // __ENFORCED_VERTICES_BEGIN__
1247 // __BEGIN_VERTEX__ => no name, no entry
1248 // __BEGIN_GROUP__ mon groupe __END_GROUP__
1249 // __BEGIN_COORDS__ 10 10 10 __END_COORDS__
1250 // __BEGIN_FACELIST__ 0:1:1:1:1 __END_FACELIST__
1252 // __BEGIN_VERTEX__ => no coords
1253 // __BEGIN_NAME__ mes points __END_NAME__
1254 // __BEGIN_ENTRY__ 0:1:1:4 __END_ENTRY__
1255 // __BEGIN_GROUP__ mon groupe __END_GROUP__
1256 // __BEGIN_FACELIST__ 0:1:1:1:3 __END_FACELIST__
1258 // __ENFORCED_VERTICES_END__
1261 std::string enfSeparator;
1262 std::string enfName;
1263 std::string enfGeomEntry;
1264 std::string enfGroup;
1265 TEntryList enfFaceEntryList;
1266 double enfCoords[3];
1267 bool hasCoords = false;
1269 _faceEntryEnfVertexListMap.clear();
1270 _enfVertexList.clear();
1271 _faceEntryCoordsListMap.clear();
1272 _coordsEnfVertexMap.clear();
1273 _faceEntryEnfVertexEntryListMap.clear();
1274 _enfVertexEntryEnfVertexMap.clear();
1277 while (isOK && hasEnforcedVertex) {
1278 isOK = (load >> enfSeparator); // __BEGIN_VERTEX__
1279 TEnfVertex *enfVertex = new TEnfVertex();
1280 // MESSAGE("enfSeparator: " <<enfSeparator);
1281 if (enfSeparator == "__ENFORCED_VERTICES_END__")
1282 break; // __ENFORCED_VERTICES_END__
1283 if (enfSeparator != "__BEGIN_VERTEX__")
1284 throw std::exception();
1287 isOK = (load >> enfSeparator);
1288 MESSAGE("enfSeparator: " <<enfSeparator);
1289 if (enfSeparator == "__END_VERTEX__") {
1291 enfVertex->name = enfName;
1292 enfVertex->geomEntry = enfGeomEntry;
1293 enfVertex->grpName = enfGroup;
1294 enfVertex->coords.clear();
1296 enfVertex->coords.assign(enfCoords,enfCoords+3);
1297 enfVertex->faceEntries = enfFaceEntryList;
1299 _enfVertexList.insert(enfVertex);
1301 if (enfVertex->coords.size()) {
1302 _coordsEnfVertexMap[enfVertex->coords] = enfVertex;
1303 for (TEntryList::const_iterator it = enfVertex->faceEntries.begin() ; it != enfVertex->faceEntries.end(); ++it) {
1304 _faceEntryCoordsListMap[(*it)].insert(enfVertex->coords);
1305 _faceEntryEnfVertexListMap[(*it)].insert(enfVertex);
1308 if (!enfVertex->geomEntry.empty()) {
1309 _enfVertexEntryEnfVertexMap[enfVertex->geomEntry] = enfVertex;
1310 for (TEntryList::const_iterator it = enfVertex->faceEntries.begin() ; it != enfVertex->faceEntries.end(); ++it) {
1311 _faceEntryEnfVertexEntryListMap[(*it)].insert(enfVertex->geomEntry);
1312 _faceEntryEnfVertexListMap[(*it)].insert(enfVertex);
1317 enfGeomEntry.clear();
1319 enfFaceEntryList.clear();
1321 break; // __END_VERTEX__
1324 if (enfSeparator == "__BEGIN_NAME__") { // __BEGIN_NAME__
1325 while (isOK && (enfSeparator != "__END_NAME__")) {
1326 isOK = (load >> enfSeparator);
1327 if (enfSeparator != "__END_NAME__") {
1328 if (!enfName.empty())
1330 enfName += enfSeparator;
1333 MESSAGE("enfName: " <<enfName);
1336 if (enfSeparator == "__BEGIN_ENTRY__") { // __BEGIN_ENTRY__
1337 isOK = (load >> enfGeomEntry);
1338 isOK = (load >> enfSeparator); // __END_ENTRY__
1339 if (enfSeparator != "__END_ENTRY__")
1340 throw std::exception();
1341 MESSAGE("enfGeomEntry: " <<enfGeomEntry);
1344 if (enfSeparator == "__BEGIN_GROUP__") { // __BEGIN_GROUP__
1345 while (isOK && (enfSeparator != "__END_GROUP__")) {
1346 isOK = (load >> enfSeparator);
1347 if (enfSeparator != "__END_GROUP__") {
1348 if (!enfGroup.empty())
1350 enfGroup += enfSeparator;
1353 MESSAGE("enfGroup: " <<enfGroup);
1356 if (enfSeparator == "__BEGIN_COORDS__") { // __BEGIN_COORDS__
1358 isOK = (load >> enfCoords[0] >> enfCoords[1] >> enfCoords[2]);
1359 isOK = (load >> enfSeparator); // __END_COORDS__
1360 if (enfSeparator != "__END_COORDS__")
1361 throw std::exception();
1362 MESSAGE("enfCoords: " << enfCoords[0] <<","<< enfCoords[1] <<","<< enfCoords[2]);
1365 if (enfSeparator == "__BEGIN_FACELIST__") { // __BEGIN_FACELIST__
1366 while (isOK && (enfSeparator != "__END_FACELIST__")) {
1367 isOK = (load >> enfSeparator);
1368 if (enfSeparator != "__END_FACELIST__") {
1369 enfFaceEntryList.insert(enfSeparator);
1370 MESSAGE(enfSeparator << " was inserted into enfFaceEntryList");
1380 //=============================================================================
1381 std::ostream & operator <<(std::ostream & save, BLSURFPlugin_Hypothesis & hyp) {
1382 return hyp.SaveTo(save);
1385 //=============================================================================
1386 std::istream & operator >>(std::istream & load, BLSURFPlugin_Hypothesis & hyp) {
1387 return hyp.LoadFrom(load);
1390 //================================================================================
1392 * \brief Does nothing
1394 //================================================================================
1396 bool BLSURFPlugin_Hypothesis::SetParametersByMesh(const SMESH_Mesh* theMesh, const TopoDS_Shape& theShape) {
1400 //=============================================================================
1402 * \brief Initialize my parameter values by default parameters.
1403 * \retval bool - true if parameter values have been successfully defined
1405 //=============================================================================
1407 bool BLSURFPlugin_Hypothesis::SetParametersByDefaults(const TDefaults& dflts, const SMESH_Mesh* theMesh) {
1408 return bool(_phySize = dflts._elemLength);
1411 //=============================================================================
1412 BLSURFPlugin_Hypothesis::Topology BLSURFPlugin_Hypothesis::GetDefaultTopology() {
1416 //=============================================================================
1417 BLSURFPlugin_Hypothesis::PhysicalMesh BLSURFPlugin_Hypothesis::GetDefaultPhysicalMesh() {
1418 return PhysicalUserDefined;
1421 //=============================================================================
1422 double BLSURFPlugin_Hypothesis::GetDefaultPhySize() {
1426 //======================================================================
1427 double BLSURFPlugin_Hypothesis::GetDefaultMaxSize() {
1428 return undefinedDouble(); // 1e+4;
1431 //======================================================================
1432 double BLSURFPlugin_Hypothesis::GetDefaultMinSize() {
1433 return undefinedDouble(); //1e-4;
1436 //======================================================================
1437 BLSURFPlugin_Hypothesis::GeometricMesh BLSURFPlugin_Hypothesis::GetDefaultGeometricMesh() {
1441 //=============================================================================
1442 double BLSURFPlugin_Hypothesis::GetDefaultAngleMeshS() {
1446 //=============================================================================
1447 double BLSURFPlugin_Hypothesis::GetDefaultGradation() {
1451 //=============================================================================
1452 bool BLSURFPlugin_Hypothesis::GetDefaultQuadAllowed() {
1456 //=============================================================================
1457 bool BLSURFPlugin_Hypothesis::GetDefaultDecimesh() {