-// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2007-2014 CEA/DEN, EDF R&D, OPEN CASCADE
//
// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
-// version 2.1 of the License.
+// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
#include "SMESH_Mesh_i.hxx"
#include "SMESH_PreMeshInfo.hxx"
#include "SMESH_PythonDump.hxx"
-//#include "memoire.h"
+#include "SMESH_TryCatch.hxx" // to include after OCC headers!
#include CORBA_SERVER_HEADER(SMESH_Group)
#include CORBA_SERVER_HEADER(SMESH_Filter)
if ( myShapeReader )
delete myShapeReader;
}
-
//=============================================================================
/*!
- * SMESH_Gen_i::createHypothesis
+ * SMESH_Gen_i::getHypothesisCreator
*
- * Create hypothesis of given type
+ * Get hypothesis creator
*/
//=============================================================================
-SMESH::SMESH_Hypothesis_ptr SMESH_Gen_i::createHypothesis(const char* theHypName,
- const char* theLibName)
+GenericHypothesisCreator_i* SMESH_Gen_i::getHypothesisCreator(const char* theHypName,
+ const char* theLibName,
+ std::string& thePlatformLibName)
throw (SALOME::SALOME_Exception)
{
- /* It's Need to tranlate lib name for WIN32 or X platform */
std::string aPlatformLibName;
+ /* It's Need to tranlate lib name for WIN32 or X platform */
if ( theLibName && theLibName[0] != '\0' )
{
int libNameLen = strlen(theLibName);
#endif
}
}
+ thePlatformLibName = aPlatformLibName;
Unexpect aCatch(SALOME_SalomeException);
if(MYDEBUG) MESSAGE( "Create Hypothesis <" << theHypName << "> from " << aPlatformLibName);
- // create a new hypothesis object servant
- SMESH_Hypothesis_i* myHypothesis_i = 0;
- SMESH::SMESH_Hypothesis_var hypothesis_i;
-
+ typedef GenericHypothesisCreator_i* (*GetHypothesisCreator)(const char* );
+ GenericHypothesisCreator_i* aCreator;
try
{
// check, if creator for this hypothesis type already exists
// get method, returning hypothesis creator
if(MYDEBUG) MESSAGE("Find GetHypothesisCreator() method ...");
- typedef GenericHypothesisCreator_i* (*GetHypothesisCreator)(const char* theHypName);
GetHypothesisCreator procHandle =
(GetHypothesisCreator)GetProc( libHandle, "GetHypothesisCreator" );
if (!procHandle)
// get hypothesis creator
if(MYDEBUG) MESSAGE("Get Hypothesis Creator for " << theHypName);
- GenericHypothesisCreator_i* aCreator = procHandle(theHypName);
+ aCreator = procHandle(theHypName);
if (!aCreator)
{
throw(SALOME_Exception(LOCALIZED("no such a hypothesis in this plugin")));
}
-
// map hypothesis creator to a hypothesis name
myHypCreatorMap[string(theHypName)] = aCreator;
+ return aCreator;
+ }
+ else
+ {
+ return myHypCreatorMap[string(theHypName)];
}
-
- // create a new hypothesis object, store its ref. in studyContext
- if(MYDEBUG) MESSAGE("Create Hypothesis " << theHypName);
- myHypothesis_i =
- myHypCreatorMap[string(theHypName)]->Create(myPoa, GetCurrentStudyID(), &myGen);
- myHypothesis_i->SetLibName(aPlatformLibName.c_str()); // for persistency assurance
}
catch (SALOME_Exception& S_ex)
{
THROW_SALOME_CORBA_EXCEPTION(S_ex.what(), SALOME::BAD_PARAM);
}
+ return aCreator;
+}
+
+//=============================================================================
+/*!
+ * SMESH_Gen_i::createHypothesis
+ *
+ * Create hypothesis of given type
+ */
+//=============================================================================
+SMESH::SMESH_Hypothesis_ptr SMESH_Gen_i::createHypothesis(const char* theHypName,
+ const char* theLibName)
+{
+ SMESH_Hypothesis_i* myHypothesis_i = 0;
+ SMESH::SMESH_Hypothesis_var hypothesis_i;
+ std::string aPlatformLibName;
+ typedef GenericHypothesisCreator_i* (*GetHypothesisCreator)(const char* );
+ GenericHypothesisCreator_i* aCreator = getHypothesisCreator(theHypName, theLibName, aPlatformLibName);
+ // create a new hypothesis object, store its ref. in studyContext
+ if(MYDEBUG) MESSAGE("Create Hypothesis " << theHypName);
+ myHypothesis_i =
+ myHypCreatorMap[string(theHypName)]->Create(myPoa, GetCurrentStudyID(), &myGen);
+ myHypothesis_i->SetLibName(aPlatformLibName.c_str()); // for persistency assurance
if (!myHypothesis_i)
return hypothesis_i._retn();
SALOMEDS::SObject_wrap so = anIter->Value();
CORBA::Object_var ior = SObjectToObject( so );
if ( SMESH_Mesh_i* mesh = SMESH::DownCast<SMESH_Mesh_i*>( ior ))
- mesh->CheckGeomGroupModif();
+ mesh->CheckGeomModif();
}
}
}
ASSERT( meshServant );
if ( meshServant ) {
// NPAL16168: "geometrical group edition from a submesh don't modifiy mesh computation"
- meshServant->CheckGeomGroupModif();
+ meshServant->CheckGeomModif();
// get local TopoDS_Shape
TopoDS_Shape myLocShape;
if(theMesh->HasShapeToMesh())
ASSERT( meshServant );
if ( meshServant ) {
// NPAL16168: "geometrical group edition from a submesh don't modifiy mesh computation"
- meshServant->CheckGeomGroupModif();
+ meshServant->CheckGeomModif();
// get local TopoDS_Shape
TopoDS_Shape myLocShape;
if(theMesh->HasShapeToMesh())
ASSERT( meshServant );
if ( meshServant ) {
// NPAL16168: "geometrical group edition from a submesh don't modifiy mesh computation"
- meshServant->CheckGeomGroupModif();
+ meshServant->CheckGeomModif();
// get local TopoDS_Shape
TopoDS_Shape myLocShape;
if(theMesh->HasShapeToMesh())
SMESH::array_of_ElementType_var srcElemTypes = meshPart->GetTypes();
if ( SMESH::DownCast<SMESH_Mesh_i*>( meshPart ))
{
+ srcMesh_i->Load();
srcElemIt = srcMeshDS->elementsIterator();
srcNodeIt = srcMeshDS->nodesIterator();
}
const SMDS_MeshElement * newElem;
switch ( elem->GetEntityType() ) {
case SMDSEntity_Polyhedra:
- newElem = editor.GetMeshDS()->
- AddPolyhedralVolumeWithID( nodes,
- static_cast<const SMDS_VtkVolume*>(elem)->GetQuantities(),
- ID);
+ if ( toKeepIDs )
+ newElem = editor.GetMeshDS()->
+ AddPolyhedralVolumeWithID( nodes,
+ static_cast<const SMDS_VtkVolume*>(elem)->GetQuantities(),
+ ID);
+ else
+ newElem = editor.GetMeshDS()->
+ AddPolyhedralVolume( nodes,
+ static_cast<const SMDS_VtkVolume*>(elem)->GetQuantities());
break;
case SMDSEntity_Ball:
newElem = editor.AddElement( nodes, SMDSAbs_Ball, false, ID,
useCaseBuilder->AppendTo( where, sobj ); // append to the end of list
}
}
+//=================================================================================
+// function : IsApplicable
+// purpose : Return true if algorithm can be applied
+//=================================================================================
+CORBA::Boolean SMESH_Gen_i::IsApplicable ( const char* theAlgoType,
+ const char* theLibName,
+ GEOM::GEOM_Object_ptr theGeomObject,
+ CORBA::Boolean toCheckAll)
+{
+ SMESH_TRY;
+
+ std::string aPlatformLibName;
+ typedef GenericHypothesisCreator_i* (*GetHypothesisCreator)(const char*);
+ GenericHypothesisCreator_i* aCreator = getHypothesisCreator(theAlgoType, theLibName, aPlatformLibName);
+ if (aCreator)
+ {
+ TopoDS_Shape shape = GeomObjectToShape( theGeomObject );
+ if ( !shape.IsNull() )
+ return aCreator->IsApplicable( shape, toCheckAll );
+ }
+ else
+ {
+ return false;
+ }
+
+ SMESH_CATCH( SMESH::doNothing );
+ return true;
+}
//=================================================================================
// function : importData
// purpose : imports mesh data file (the med one) into the SMESH internal data structure
//=================================================================================
-Engines::ListOfIdentifiers* SMESH_Gen_i::importData(
- CORBA::Long studyId, Engines::DataContainer_ptr data, const Engines::ListOfOptions& options)
+Engines::ListOfIdentifiers* SMESH_Gen_i::importData(CORBA::Long studyId,
+ Engines::DataContainer_ptr data,
+ const Engines::ListOfOptions& options)
{
Engines::ListOfIdentifiers_var aResultIds = new Engines::ListOfIdentifiers;
list<string> aResultList;