-// Copyright (C) 2007-2014 CEA/DEN, EDF R&D
+// Copyright (C) 2007-2015 CEA/DEN, EDF R&D
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
_preCadFacesPeriodicityVector(GetDefaultPreCadFacesPeriodicityVector()),
_preCadEdgesPeriodicityVector(GetDefaultPreCadEdgesPeriodicityVector())
{
- _name = "BLSURF_Parameters";
+ _name = GetHypType();
_param_algo_dim = 2;
// _GMFFileMode = false; // GMF ascii mode
"proximity", // default = 0
"rectify_jacobian", // default = 1
"respect_geometry", // default = 1
+ "optimise_tiny_edges", // default = 0
+ "remove_duplicate_cad_faces", // default = 1
+ "tiny_edge_avoid_surface_intersections", // default = 1
+ "tiny_edge_respect_geometry", // default = 0
"" // mark of end
};
const char* doubleOptionNames[] = { "surface_intersections_processing_max_cost",// default = 15
"periodic_tolerance", // default = diag/100
"prox_ratio",
+ "volume_gradation",
+ "tiny_edge_optimisation_length", // default = diag * 1e-6
"" // mark of end
};
const char* charOptionNames[] = { "required_entities", // default = "respect"
throw (std::invalid_argument) {
TOptionValues::iterator op_val = _option2value.find(optionName);
if (op_val == _option2value.end()) {
- std::string msg = "Unknown BLSURF option: '" + optionName + "'";
+ std::string msg = "Unknown MG-CADSurf option: '" + optionName + "'";
throw std::invalid_argument(msg);
}
if (op_val->second != optionValue) {
throw (std::invalid_argument) {
TOptionValues::iterator op_val = _preCADoption2value.find(optionName);
if (op_val == _preCADoption2value.end()) {
- std::string msg = "Unknown BLSURF option: '" + optionName + "'";
+ std::string msg = "Unknown MG-CADSurf option: '" + optionName + "'";
throw std::invalid_argument(msg);
}
if (op_val->second != optionValue) {
std::string BLSURFPlugin_Hypothesis::GetOptionValue(const std::string& optionName) throw (std::invalid_argument) {
TOptionValues::iterator op_val = _option2value.find(optionName);
if (op_val == _option2value.end()) {
- std::string msg = "Unknown BLSURF option: <";
+ std::string msg = "Unknown MG-CADSurf option: <";
msg += optionName + ">";
throw std::invalid_argument(msg);
}
//=============================================================================
void BLSURFPlugin_Hypothesis::ClearOption(const std::string& optionName) {
- TOptionValues::iterator op_val = _option2value.find(optionName);
- if (op_val != _option2value.end())
- op_val->second.clear();
+ TOptionValues::iterator op_val = _customOption2value.find(optionName);
+ if (op_val != _customOption2value.end())
+ _customOption2value.erase(op_val);
+ else {
+ op_val = _option2value.find(optionName);
+ if (op_val != _option2value.end())
+ op_val->second.clear();
+ }
}
//=============================================================================
void BLSURFPlugin_Hypothesis::ClearPreCADOption(const std::string& optionName) {
+ TOptionValues::iterator op_val = _customPreCADOption2value.find(optionName);
+ if (op_val != _customPreCADOption2value.end())
+ _customPreCADOption2value.erase(op_val);
+ else {
+ op_val = _preCADoption2value.find(optionName);
+ if (op_val != _preCADoption2value.end())
+ op_val->second.clear();
+ }
+}
+
+//=============================================================================
+void BLSURFPlugin_Hypothesis::AddOption(const std::string& optionName, const std::string& optionValue)
+{
+ TOptionValues::iterator op_val = _option2value.find(optionName);
+ if (op_val != _option2value.end()) {
+ if (op_val->second != optionValue)
+ op_val->second = optionValue;
+ }
+ else {
+ op_val = _customOption2value.find(optionName);
+ if (op_val == _customOption2value.end())
+ _customOption2value[optionName] = optionValue;
+ else if (op_val->second != optionValue)
+ op_val->second = optionValue;
+ }
+ NotifySubMeshesHypothesisModification();
+}
+
+//=============================================================================
+void BLSURFPlugin_Hypothesis::AddPreCADOption(const std::string& optionName, const std::string& optionValue)
+{
TOptionValues::iterator op_val = _preCADoption2value.find(optionName);
- if (op_val != _preCADoption2value.end())
- op_val->second.clear();
+ if (op_val != _preCADoption2value.end()) {
+ if (op_val->second != optionValue)
+ op_val->second = optionValue;
+ }
+ else {
+ op_val = _customPreCADOption2value.find(optionName);
+ if (op_val == _customPreCADOption2value.end())
+ _customPreCADOption2value[optionName] = optionValue;
+ else if (op_val->second != optionValue)
+ op_val->second = optionValue;
+ }
+ NotifySubMeshesHypothesisModification();
+}
+
+//=============================================================================
+std::string BLSURFPlugin_Hypothesis::GetOption(const std::string& optionName)
+{
+ TOptionValues::iterator op_val = _customOption2value.find(optionName);
+ if (op_val != _customOption2value.end())
+ return op_val->second;
+ else
+ return "";
+}
+
+//=============================================================================
+std::string BLSURFPlugin_Hypothesis::GetPreCADOption(const std::string& optionName)
+{
+ TOptionValues::iterator op_val = _customPreCADOption2value.find(optionName);
+ if (op_val != _customPreCADOption2value.end())
+ return op_val->second;
+ else
+ return "";
}
//=======================================================================
const TopoDS_Shape AttractorShape = BLSURFPlugin_Hypothesis::entryToShape(attEntry);
const TopoDS_Face FaceShape = TopoDS::Face(BLSURFPlugin_Hypothesis::entryToShape(entry));
- bool attExists = (_classAttractors.find(entry) != _classAttractors.end());
- double u1,u2,v1,v2, diag;
-
- if ( !attExists || (attExists && _classAttractors[entry]->GetAttractorEntry().compare(attEntry) != 0)){
- ShapeAnalysis::GetFaceUVBounds(FaceShape,u1,u2,v1,v2);
-// diag = sqrt((u2 - u1) * (u2 - u1) + (v2 - v1) * (v2 - v1));
- BLSURFPlugin_Attractor* myAttractor = new BLSURFPlugin_Attractor(FaceShape, AttractorShape, attEntry);//, 0.1 ); // test 0.002 * diag);
- myAttractor->BuildMap();
- myAttractor->SetParameters(StartSize, EndSize, ActionRadius, ConstantRadius);
- _classAttractors[entry] = myAttractor;
- NotifySubMeshesHypothesisModification();
+ TAttractorMap::iterator attIt = _classAttractors.find(entry);
+ for ( ; attIt != _classAttractors.end(); ++attIt )
+ if ( attIt->first == entry &&
+ attIt->second->GetAttractorEntry() == attEntry )
+ break;
+ bool attExists = (attIt != _classAttractors.end());
+
+ BLSURFPlugin_Attractor* myAttractor;
+ if ( !attExists ) {
+ myAttractor = new BLSURFPlugin_Attractor(FaceShape, AttractorShape, attEntry);//, 0.1 );
+ _classAttractors.insert( make_pair( entry, myAttractor ));
}
else {
- _classAttractors[entry]->SetParameters(StartSize, EndSize, ActionRadius, ConstantRadius);
- if (!_classAttractors[entry]->IsMapBuilt()){
- _classAttractors[entry]->BuildMap();
- }
- NotifySubMeshesHypothesisModification();
+ myAttractor = attIt->second;
}
-
+ // if (!myAttractor->IsMapBuilt())
+ // myAttractor->BuildMap();
+ myAttractor->SetParameters(StartSize, EndSize, ActionRadius, ConstantRadius);
+
+ NotifySubMeshesHypothesisModification();
}
//=======================================================================
//=======================================================================
//function : ClearEntry
//=======================================================================
-void BLSURFPlugin_Hypothesis::ClearEntry(const std::string& entry)
+void BLSURFPlugin_Hypothesis::ClearEntry(const std::string& entry,
+ const char * attEntry/*=0*/)
{
TSizeMap::iterator it = _sizeMap.find( entry );
else {
TAttractorMap::iterator it_clAt = _classAttractors.find( entry );
if ( it_clAt != _classAttractors.end() ) {
- _classAttractors.erase(it_clAt);
+ do {
+ if ( !attEntry || it_clAt->second->GetAttractorEntry() == attEntry )
+ _classAttractors.erase( it_clAt++ );
+ else
+ ++it_clAt;
+ }
+ while ( it_clAt != _classAttractors.end() );
MESSAGE("_classAttractors.size() = "<<_classAttractors.size())
NotifySubMeshesHypothesisModification();
}
//=============================================================================
std::ostream & BLSURFPlugin_Hypothesis::SaveTo(std::ostream & save) {
// We must keep at least the same number of arguments when increasing the SALOME version
- // When BLSURF becomes CADMESH, some parameters were fused into a single one. Thus the same
+ // When MG-CADSurf becomes CADMESH, some parameters were fused into a single one. Thus the same
// parameter can be written several times to keep the old global number of parameters.
// Treat old options which are now in the advanced options
save << " " << "__OPTIONS_END__";
}
+ op_val = _customOption2value.begin();
+ if (op_val != _customOption2value.end()) {
+ save << " " << "__CUSTOM_OPTIONS_BEGIN__";
+ for (; op_val != _customOption2value.end(); ++op_val) {
+ if (!op_val->second.empty())
+ save << " " << op_val->first << " " << op_val->second << "%#"; // "%#" is a mark of value end
+ }
+ save << " " << "__CUSTOM_OPTIONS_END__";
+ }
+
op_val = _preCADoption2value.begin();
if (op_val != _preCADoption2value.end()) {
save << " " << "__PRECAD_OPTIONS_BEGIN__";
save << " " << "__PRECAD_OPTIONS_END__";
}
+ op_val = _customPreCADOption2value.begin();
+ if (op_val != _customPreCADOption2value.end()) {
+ save << " " << "__CUSTOM_PRECAD_OPTIONS_BEGIN__";
+ for (; op_val != _customPreCADOption2value.end(); ++op_val) {
+ if (!op_val->second.empty())
+ save << " " << op_val->first << " " << op_val->second << "%#"; // "%#" is a mark of value end
+ }
+ save << " " << "__CUSTOM_PRECAD_OPTIONS_END__";
+ }
+
TSizeMap::iterator it_sm = _sizeMap.begin();
if (it_sm != _sizeMap.end()) {
save << " " << "__SIZEMAP_BEGIN__";
bool hasCADSurfOptions = false;
bool hasOptions = false;
+ bool hasCustomOptions = false;
bool hasPreCADOptions = false;
+ bool hasCustomPreCADOptions = false;
bool hasSizeMap = false;
bool hasAttractor = false;
bool hasNewAttractor = false;
}
if (option_or_sm == "__OPTIONS_BEGIN__")
hasOptions = true;
+ else if (option_or_sm == "__CUSTOM_OPTIONS_BEGIN__")
+ hasCustomOptions = true;
else if (option_or_sm == "__PRECAD_OPTIONS_BEGIN__")
hasPreCADOptions = true;
+ else if (option_or_sm == "__CUSTOM_PRECAD_OPTIONS_BEGIN__")
+ hasCustomPreCADOptions = true;
else if (option_or_sm == "__SIZEMAP_BEGIN__")
hasSizeMap = true;
else if (option_or_sm == "__ATTRACTORS_BEGIN__")
if (isOK)
if (option_or_sm == "__OPTIONS_BEGIN__")
hasOptions = true;
+ else if (option_or_sm == "__CUSTOM_OPTIONS_BEGIN__")
+ hasCustomOptions = true;
else if (option_or_sm == "__PRECAD_OPTIONS_BEGIN__")
hasPreCADOptions = true;
+ else if (option_or_sm == "__CUSTOM_PRECAD_OPTIONS_BEGIN__")
+ hasCustomPreCADOptions = true;
else if (option_or_sm == "__SIZEMAP_BEGIN__")
hasSizeMap = true;
else if (option_or_sm == "__ATTRACTORS_BEGIN__")
}
if (hasOptions) {
+ isOK = (load >> option_or_sm);
+ if (isOK)
+ if (option_or_sm == "__CUSTOM_OPTIONS_BEGIN__")
+ hasCustomOptions = true;
+ else if (option_or_sm == "__PRECAD_OPTIONS_BEGIN__")
+ hasPreCADOptions = true;
+ else if (option_or_sm == "__CUSTOM_PRECAD_OPTIONS_BEGIN__")
+ hasCustomPreCADOptions = true;
+ else if (option_or_sm == "__SIZEMAP_BEGIN__")
+ hasSizeMap = true;
+ else if (option_or_sm == "__ATTRACTORS_BEGIN__")
+ hasAttractor = true;
+ else if (option_or_sm == "__NEW_ATTRACTORS_BEGIN__")
+ hasNewAttractor = true;
+ else if (option_or_sm == "__ENFORCED_VERTICES_BEGIN__")
+ hasEnforcedVertex = true;
+ else if (option_or_sm == "__PRECAD_FACES_PERIODICITY_BEGIN__")
+ hasPreCADFacesPeriodicity = true;
+ else if (option_or_sm == "__PRECAD_EDGES_PERIODICITY_BEGIN__")
+ hasPreCADEdgesPeriodicity = true;
+ else if (option_or_sm == "__FACES_PERIODICITY_BEGIN__")
+ hasFacesPeriodicity = true;
+ else if (option_or_sm == "__EDGES_PERIODICITY_BEGIN__")
+ hasEdgesPeriodicity = true;
+ else if (option_or_sm == "__VERTICES_PERIODICITY_BEGIN__")
+ hasVerticesPeriodicity = true;
+ }
+
+ while (isOK && hasCustomOptions) {
+ isOK = (load >> optName);
+ if (isOK) {
+ if (optName == "__CUSTOM_OPTIONS_END__")
+ break;
+ isOK = (load >> optValue);
+ }
+ if (isOK) {
+ std::string& value = optValue;
+ int len = value.size();
+ // continue reading until "%#" encountered
+ while (value[len - 1] != '#' || value[len - 2] != '%') {
+ isOK = (load >> optValue);
+ if (isOK) {
+ value += " ";
+ value += optValue;
+ len = value.size();
+ } else {
+ break;
+ }
+ }
+ _customOption2value[optName] = value.substr(0,len-2);
+ value[len - 2] = '\0'; //cut off "%#"
+ }
+ }
+
+ if (hasCustomOptions) {
isOK = (load >> option_or_sm);
if (isOK)
if (option_or_sm == "__PRECAD_OPTIONS_BEGIN__")
hasPreCADOptions = true;
+ else if (option_or_sm == "__CUSTOM_PRECAD_OPTIONS_BEGIN__")
+ hasCustomPreCADOptions = true;
else if (option_or_sm == "__SIZEMAP_BEGIN__")
hasSizeMap = true;
else if (option_or_sm == "__ATTRACTORS_BEGIN__")
}
if (hasPreCADOptions) {
+ isOK = (load >> option_or_sm);
+ if (isOK)
+ if (option_or_sm == "__CUSTOM_PRECAD_OPTIONS_BEGIN__")
+ hasCustomPreCADOptions = true;
+ else if (option_or_sm == "__SIZEMAP_BEGIN__")
+ hasSizeMap = true;
+ else if (option_or_sm == "__ATTRACTORS_BEGIN__")
+ hasAttractor = true;
+ else if (option_or_sm == "__NEW_ATTRACTORS_BEGIN__")
+ hasNewAttractor = true;
+ else if (option_or_sm == "__ENFORCED_VERTICES_BEGIN__")
+ hasEnforcedVertex = true;
+ else if (option_or_sm == "__PRECAD_FACES_PERIODICITY_BEGIN__")
+ hasPreCADFacesPeriodicity = true;
+ else if (option_or_sm == "__PRECAD_EDGES_PERIODICITY_BEGIN__")
+ hasPreCADEdgesPeriodicity = true;
+ else if (option_or_sm == "__FACES_PERIODICITY_BEGIN__")
+ hasFacesPeriodicity = true;
+ else if (option_or_sm == "__EDGES_PERIODICITY_BEGIN__")
+ hasEdgesPeriodicity = true;
+ else if (option_or_sm == "__VERTICES_PERIODICITY_BEGIN__")
+ hasVerticesPeriodicity = true;
+ }
+
+ while (isOK && hasCustomPreCADOptions) {
+ isOK = (load >> optName);
+ if (isOK) {
+ if (optName == "__CUSTOM_PRECAD_OPTIONS_END__")
+ break;
+ isOK = (load >> optValue);
+ }
+ if (isOK) {
+ std::string& value = optValue;
+ int len = value.size();
+ // continue reading until "%#" encountered
+ while (value[len - 1] != '#' || value[len - 2] != '%') {
+ isOK = (load >> optValue);
+ if (isOK) {
+ value += " ";
+ value += optValue;
+ len = value.size();
+ } else {
+ break;
+ }
+ }
+ _customPreCADOption2value[optName] = value.substr(0,len-2);
+ value[len - 2] = '\0'; //cut off "%#"
+ }
+ }
+
+ if (hasCustomPreCADOptions) {
isOK = (load >> option_or_sm);
if (isOK)
if (option_or_sm == "__SIZEMAP_BEGIN__")
double attParams[4];
double step;
while (isOK && hasNewAttractor) {
- std::cout<<"Load new attractor"<<std::endl;
+ //std::cout<<"Load new attractor"<<std::endl;
isOK = (load >> newAtFaceEntry);
if (isOK) {
if (newAtFaceEntry == "__NEW_ATTRACTORS_END__")
const TopoDS_Face faceShape = TopoDS::Face(BLSURFPlugin_Hypothesis::entryToShape(newAtFaceEntry));
BLSURFPlugin_Attractor* attractor = new BLSURFPlugin_Attractor(faceShape, attractorShape, newAtShapeEntry);//, step);
attractor->SetParameters(attParams[0], attParams[1], attParams[2], attParams[3]);
- attractor->BuildMap();
- _classAttractors[newAtFaceEntry]=attractor;
+ //attractor->BuildMap();
+ _classAttractors.insert( make_pair( newAtFaceEntry, attractor ));
}
}