From 5f77aa86a248695c2df5a887fb0009cb1ab181c3 Mon Sep 17 00:00:00 2001 From: bourcier Date: Mon, 5 Aug 2013 15:00:59 +0000 Subject: [PATCH] Periocity with PreCAD: - Add the ability to set the transformation with source vertices and target vertices --- idl/BLSURFPlugin_Algorithm.idl | 14 +- src/BLSURFPlugin/BLSURFPluginBuilder.py | 141 ++++--- src/BLSURFPlugin/BLSURFPlugin_BLSURF.cxx | 356 ++++++++++-------- src/BLSURFPlugin/BLSURFPlugin_BLSURF.hxx | 37 +- src/BLSURFPlugin/BLSURFPlugin_Hypothesis.cxx | 69 ++-- src/BLSURFPlugin/BLSURFPlugin_Hypothesis.hxx | 31 +- .../BLSURFPlugin_Hypothesis_i.cxx | 352 +++++++++++------ .../BLSURFPlugin_Hypothesis_i.hxx | 50 ++- 8 files changed, 619 insertions(+), 431 deletions(-) diff --git a/idl/BLSURFPlugin_Algorithm.idl b/idl/BLSURFPlugin_Algorithm.idl index 0549426..fe664b1 100644 --- a/idl/BLSURFPlugin_Algorithm.idl +++ b/idl/BLSURFPlugin_Algorithm.idl @@ -431,12 +431,14 @@ module BLSURFPlugin // PERIODICITY // /////////////////////// - void AddPreCadFacesPeriodicity(in GEOM::GEOM_Object faces1, in GEOM::GEOM_Object faces2, in string f_transf) raises (SALOME::SALOME_Exception); - void AddPreCadEdgesPeriodicity(in GEOM::GEOM_Object edges1, in GEOM::GEOM_Object edges2, in string f_transf) raises (SALOME::SALOME_Exception); - void AddFacePeriodicity(in GEOM::GEOM_Object face1, in GEOM::GEOM_Object face2) raises (SALOME::SALOME_Exception); - void AddEdgePeriodicity(in GEOM::GEOM_Object face1, in GEOM::GEOM_Object edge1, in GEOM::GEOM_Object face2, in GEOM::GEOM_Object edge2, in long edge_orientation) raises (SALOME::SALOME_Exception); - void AddEdgePeriodicityWithoutFaces(in GEOM::GEOM_Object edge1, in GEOM::GEOM_Object edge2, in long edge_orientation) raises (SALOME::SALOME_Exception); - void AddVertexPeriodicity(in GEOM::GEOM_Object edge1, in GEOM::GEOM_Object Vertex1, in GEOM::GEOM_Object edge2, in GEOM::GEOM_Object vertex2) raises (SALOME::SALOME_Exception); + void AddPreCadFacesPeriodicity(in GEOM::GEOM_Object theFace1, in GEOM::GEOM_Object theFace2) raises (SALOME::SALOME_Exception); + void AddPreCadFacesPeriodicityWithVertices(in GEOM::GEOM_Object theFace1, in GEOM::GEOM_Object theFace2, in GEOM::ListOfGO theSourceVertices, in GEOM::ListOfGO theTargetVertices) raises (SALOME::SALOME_Exception); + void AddPreCadEdgesPeriodicity(in GEOM::GEOM_Object theEdge1, in GEOM::GEOM_Object theEdge2) raises (SALOME::SALOME_Exception); + void AddPreCadEdgesPeriodicityWithVertices(in GEOM::GEOM_Object theEdge1, in GEOM::GEOM_Object theEdge2, in GEOM::ListOfGO theSourceVertices, in GEOM::ListOfGO theTargetVertices) raises (SALOME::SALOME_Exception); + void AddFacePeriodicity(in GEOM::GEOM_Object theFace1, in GEOM::GEOM_Object theFace2) raises (SALOME::SALOME_Exception); + void AddEdgePeriodicity(in GEOM::GEOM_Object theFace1, in GEOM::GEOM_Object theEdge1, in GEOM::GEOM_Object theFace2, in GEOM::GEOM_Object theEdge2, in long edge_orientation) raises (SALOME::SALOME_Exception); + void AddEdgePeriodicityWithoutFaces(in GEOM::GEOM_Object theEdge1, in GEOM::GEOM_Object theEdge2, in long edge_orientation) raises (SALOME::SALOME_Exception); + void AddVertexPeriodicity(in GEOM::GEOM_Object theEdge1, in GEOM::GEOM_Object theVertex1, in GEOM::GEOM_Object theEdge2, in GEOM::GEOM_Object theVertex2) raises (SALOME::SALOME_Exception); /////////////////////// diff --git a/src/BLSURFPlugin/BLSURFPluginBuilder.py b/src/BLSURFPlugin/BLSURFPluginBuilder.py index ca8aa42..bbf3b10 100644 --- a/src/BLSURFPlugin/BLSURFPluginBuilder.py +++ b/src/BLSURFPlugin/BLSURFPluginBuilder.py @@ -425,75 +425,92 @@ class BLSURF_Algorithm(Mesh_Algorithm): return self.params #----------------------------------------- - # Periodicity (BLSURF) + # Periodicity (BLSURF with PreCAD) #----------------------------------------- - ## Defines periodicity between two groups of faces - # @param faces1: group of faces to associate with faces2 - # @param faces2: group of faces associated with faces1 - # @param f_transf (optionnal): the transformation function from faces1 to faces2. - # If None, PreCAD tries to find a simple translation - - def AddPreCadFacesPeriodicity(self, faces1, faces2, f_transf= ""): - """calls preCad function: - status_t cad_add_face_multiple_periodicity_with_transformation_function(cad t *cad, - integer *fid1, integer size1, integer *fid2, integer size2, - periodicity_transformation_t transf, void *user data); - """ - self.Parameters().AddPreCadFacesPeriodicity(faces1, faces2, f_transf) - pass + ## Defines periodicity between two groups of faces, using PreCAD + # @param theFace1: GEOM face (or group, compound) to associate with theFace2 + # @param theFace2: GEOM face (or group, compound) associated with theFace1 + # @param theSourceVertices (optionnal): list of GEOM vertices on theFace1 defining the transformation from theFace1 to theFace2. + # If None, PreCAD tries to find a simple translation + # @param theTargetVertices (optionnal): list of GEOM vertices on theFace2 defining the transformation from theFace1 to theFace2. + # If None, PreCAD tries to find a simple translation + def AddPreCadFacesPeriodicity(self, theFace1, theFace2, theSourceVertices=[], theTargetVertices=[]): + """calls preCad function: + status_t cad_add_face_multiple_periodicity_with_transformation_function(cad t *cad, + integer *fid1, integer size1, integer *fid2, integer size2, + periodicity_transformation_t transf, void *user data); + """ + if theSourceVertices and theTargetVertices: + self.Parameters().AddPreCadFacesPeriodicityWithVertices(theFace1, theFace2, theSourceVertices, theTargetVertices) + else: + self.Parameters().AddPreCadFacesPeriodicity(theFace1, theFace2) + pass + + ## Defines periodicity between two groups of edges, using PreCAD + # @param theEdge1: GEOM edge (or group, compound) to associate with theEdge2 + # @param theEdge2: GEOM edge (or group, compound) associated with theEdge1 + # @param theSourceVertices (optionnal): list of GEOM vertices on theEdge1 defining the transformation from theEdge1 to theEdge2. + # If None, PreCAD tries to find a simple translation + # @param theTargetVertices (optionnal): list of GEOM vertices on theEdge2 defining the transformation from theEdge1 to theEdge2. + # If None, PreCAD tries to find a simple translation + def AddPreCadEdgesPeriodicity(self, theEdge1, theEdge2, theSourceVertices=[], theTargetVertices=[]): + """calls preCad function: + status_t cad_add_edge_multiple_periodicity_with_transformation_function(cad t *cad, + integer *eid1, integer size1, integer *eid2, integer size2, + periodicity_transformation_t transf, void *user data); + """ + if theSourceVertices and theTargetVertices: + self.Parameters().AddPreCadEdgesPeriodicityWithVertices(theEdge1, theEdge2, theSourceVertices, theTargetVertices) + else: + self.Parameters().AddPreCadEdgesPeriodicity(theEdge1, theEdge2) + pass - ## Defines periodicity between two groups of edges - # @param edges1: group of edges to associate with edges2 - # @param edges2: group of edges associated with edges1 - # @param f_transf (optionnal): the transformation function from edges1 to edges2. - # If None, PreCAD tries to find a simple translation - - def AddPreCadEdgesPeriodicity(self, edges1, edges2, f_transf= ""): - """calls preCad function: - status_t cad_add_edge_multiple_periodicity_with_transformation_function(cad t *cad, - integer *eid1, integer size1, integer *eid2, integer size2, - periodicity_transformation_t transf, void *user data); - """ - self.Parameters().AddPreCadEdgesPeriodicity(edges1, edges2, f_transf) - pass - ## Defines periodicity between two groups of faces. - # This macro defines periodicity with the CADSurf API on each sub face, sub edge and sub vertex. - # PreCAD is not needed. - # @param faces1: group of faces to associate with faces2 - # @param faces2: group of faces associated with faces1 - # @param f_transf: the transformation function from faces1 to faces2. - def AddAdvancedFacesPeriodicity(faces1, faces2, f_transf): - self.Parameters().AddAdvancedFacesPeriodicity(faces1, faces2, f_transf) - pass - + #----------------------------------------- + # Periodicity (BLSURF without PreCAD) + #----------------------------------------- - ## Defines periodicity between two faces - # User has to call AddEdgePeriodicity with the edges of the face - # and AddVertexPeriodicity with the vertices of each edge - def AddFacePeriodicity(self, face1, face2): - self.Parameters().AddFacePeriodicity(face1, face2) - pass - - ## Defines periodicity between two edges belonging to two periodic faces - # @param edge_orientation: -1 (reversed), 0 (unknown) or 1 (forward) - # User has to call AddVertexPeriodicity with the vertices of each edge - def AddEdgePeriodicity(self, face1, edge1, face2, edge2, edge_orientation=0): - self.Parameters().AddEdgePeriodicity(face1, edge1, face2, edge2, edge_orientation) - pass - ## Defines periodicity between two edges without face periodicity - # @param edge_orientation: -1 (reversed), 0 (unknown) or 1 (forward) - # User has to call AddVertexPeriodicity with the vertices of each edge - def AddEdgePeriodicityWithoutFaces(self, edge1, edge2, edge_orientation=0): - self.Parameters().AddEdgePeriodicityWithoutFaces(edge1, edge2, edge_orientation) - pass + ## Defines periodicity between two faces, without using PreCAD. + # User has to call AddEdgePeriodicity with the edges of the face, + # and AddVertexPeriodicity with the vertices of each edge. + # @param theFace1: GEOM face to associate with theFace2 + # @param theFace2: GEOM face associated with theFace1 + def AddFacePeriodicity(self, theFace1, theFace2): + self.Parameters().AddFacePeriodicity(theFace1, theFace2) + pass - ## Defines periodicity between two vertices - def AddVertexPeriodicity(self, edge1, vertex1, edge2, vertex2): - self.Parameters().AddVertexPeriodicity(edge1, vertex1, edge2, vertex2) - pass + ## Defines periodicity between two edges belonging to two periodic faces, without using PreCAD. + # To be used with AddFacePeriodicity. + # User has to call AddVertexPeriodicity with the vertices of each edge + # @param theFace1: GEOM face to associate with theFace2 + # @param theEdge1: GEOM edge to associate with theEdge2 + # @param theFace2: GEOM face associated with theFace1 + # @param theEdge2: GEOM edge associated with theEdge1 + # @param theEdgeOrientation: -1 (reversed), 0 (unknown) or 1 (forward) + def AddEdgePeriodicity(self, theFace1, theEdge1, theFace2, theEdge2, theEdgeOrientation=0): + self.Parameters().AddEdgePeriodicity(theFace1, theEdge1, theFace2, theEdge2, theEdgeOrientation) + pass + + ## Defines periodicity between two edges without face periodicity, without using PreCAD. + # User has to call AddVertexPeriodicity with the vertices of each edge. + # @param theEdge1: GEOM edge to associate with theEdge2 + # @param theEdge2: GEOM edge associated with theEdge1 + # @param theEdgeOrientation: -1 (reversed), 0 (unknown) or 1 (forward) + def AddEdgePeriodicityWithoutFaces(self, theEdge1, theEdge2, theEdgeOrientation=0): + self.Parameters().AddEdgePeriodicityWithoutFaces(theEdge1, theEdge2, theEdgeOrientation) + pass + + ## Defines periodicity between two vertices. + # To be used with AddFacePeriodicity and AddEdgePeriodicity. + # @param theEdge1: GEOM edge to associate with theEdge2 + # @param theVertex1: GEOM face to associate with theVertex2 + # @param theEdge2: GEOM edge associated with theEdge1 + # @param theVertex2: GEOM face associated with theVertex1 + def AddVertexPeriodicity(self, theEdge1, theVertex1, theEdge2, theVertex2): + self.Parameters().AddVertexPeriodicity(theEdge1, theVertex1, theEdge2, theVertex2) + pass #===================== diff --git a/src/BLSURFPlugin/BLSURFPlugin_BLSURF.cxx b/src/BLSURFPlugin/BLSURFPlugin_BLSURF.cxx index 721cb86..067cda4 100644 --- a/src/BLSURFPlugin/BLSURFPlugin_BLSURF.cxx +++ b/src/BLSURFPlugin/BLSURFPlugin_BLSURF.cxx @@ -716,71 +716,96 @@ BLSURFPlugin_BLSURF::TListOfIDs _getSubShapeIDsInMainShape(TopoDS_Shape theMainS return face_ids; } +void BLSURFPlugin_BLSURF::addCoordsFromVertex(BLSURFPlugin_Hypothesis::TEntry theVertexEntry, std::vector &theVerticesCoords) +{ + if (theVertexEntry!="") + { + TopoDS_Shape aShape = entryToShape(theVertexEntry); + + gp_Pnt aPnt = BRep_Tool::Pnt( TopoDS::Vertex( aShape ) ); + double theX, theY, theZ; + theX = aPnt.X(); + theY = aPnt.Y(); + theZ = aPnt.Z(); + + theVerticesCoords.push_back(theX); + theVerticesCoords.push_back(theY); + theVerticesCoords.push_back(theZ); + } +} ///////////////////////////////////////////////////////// -void BLSURFPlugin_BLSURF::createPreCadFacesPeriodicity(TopoDS_Shape theGeomShape, BLSURFPlugin_Hypothesis::TEntry faces1, - BLSURFPlugin_Hypothesis::TEntry faces2, const char* f_funct) +void BLSURFPlugin_BLSURF::createPreCadFacesPeriodicity(TopoDS_Shape theGeomShape, const BLSURFPlugin_Hypothesis::TPreCadPeriodicity &preCadPeriodicity) { MESSAGE("BLSURFPlugin_BLSURF::createFacesPeriodicity"); - TopoDS_Shape geomShape1 = entryToShape(faces1); - TopoDS_Shape geomShape2 = entryToShape(faces2); + TopoDS_Shape geomShape1 = entryToShape(preCadPeriodicity.shape1Entry); + TopoDS_Shape geomShape2 = entryToShape(preCadPeriodicity.shape2Entry); + + TListOfIDs theFace1_ids = _getSubShapeIDsInMainShape(theGeomShape, geomShape1, TopAbs_FACE); + TListOfIDs theFace2_ids = _getSubShapeIDsInMainShape(theGeomShape, geomShape2, TopAbs_FACE); - TListOfIDs faces1_ids = _getSubShapeIDsInMainShape(theGeomShape, geomShape1, TopAbs_FACE); - TListOfIDs faces2_ids = _getSubShapeIDsInMainShape(theGeomShape, geomShape2, TopAbs_FACE); + TPreCadPeriodicityIDs preCadFacesPeriodicityIDs; + preCadFacesPeriodicityIDs.shape1IDs = theFace1_ids; + preCadFacesPeriodicityIDs.shape2IDs = theFace2_ids; - TPreCadPeriodicityIDs preCaDFacesPeriodicityIDs; - preCaDFacesPeriodicityIDs.shape1IDs = faces1_ids; - preCaDFacesPeriodicityIDs.shape2IDs = faces2_ids; - preCaDFacesPeriodicityIDs.f_funct = f_funct; + for (size_t i = 0; i pairOfFacesID = std::make_pair(face1_id, face2_id); + std::pair pairOfFacesID = std::make_pair(theFace1_id, theFace2_id); _facesIDsPeriodicityVector.push_back(pairOfFacesID); MESSAGE("_facesIDsPeriodicityVector.size() = " << _facesIDsPeriodicityVector.size()); @@ -790,36 +815,36 @@ void BLSURFPlugin_BLSURF::createFacesPeriodicity(TopoDS_Shape theGeomShape, BLSU ///////////////////////////////////////////////////////// -void BLSURFPlugin_BLSURF::createEdgesPeriodicity(TopoDS_Shape theGeomShape, BLSURFPlugin_Hypothesis::TEntry face1, BLSURFPlugin_Hypothesis::TEntry edge1, - BLSURFPlugin_Hypothesis::TEntry face2, BLSURFPlugin_Hypothesis::TEntry edge2, int edge_orientation) +void BLSURFPlugin_BLSURF::createEdgesPeriodicity(TopoDS_Shape theGeomShape, BLSURFPlugin_Hypothesis::TEntry theFace1, BLSURFPlugin_Hypothesis::TEntry theEdge1, + BLSURFPlugin_Hypothesis::TEntry theFace2, BLSURFPlugin_Hypothesis::TEntry theEdge2, int edge_orientation) { MESSAGE("BLSURFPlugin_BLSURF::createEdgesPeriodicity"); TEdgePeriodicityIDs edgePeriodicityIDs; - if (face1 != "") + if (theFace1 != "") { - TopoDS_Shape GeomFace1 = entryToShape(face1); - TListOfIDs faces1_ids = _getSubShapeIDsInMainShape(theGeomShape, GeomFace1, TopAbs_FACE); + TopoDS_Shape GeomFace1 = entryToShape(theFace1); + TListOfIDs theFace1_ids = _getSubShapeIDsInMainShape(theGeomShape, GeomFace1, TopAbs_FACE); // Only one face id, since only a face can be selected - edgePeriodicityIDs.face1ID = faces1_ids[0]; + edgePeriodicityIDs.theFace1ID = theFace1_ids[0]; } else - edgePeriodicityIDs.face1ID = 0; - if (face2 != "") + edgePeriodicityIDs.theFace1ID = 0; + if (theFace2 != "") { - TopoDS_Shape GeomFace2 = entryToShape(face2); - TListOfIDs faces2_ids = _getSubShapeIDsInMainShape(theGeomShape, GeomFace2, TopAbs_FACE); - edgePeriodicityIDs.face2ID = faces2_ids[0]; + TopoDS_Shape GeomFace2 = entryToShape(theFace2); + TListOfIDs theFace2_ids = _getSubShapeIDsInMainShape(theGeomShape, GeomFace2, TopAbs_FACE); + edgePeriodicityIDs.theFace2ID = theFace2_ids[0]; } else - edgePeriodicityIDs.face2ID = 0; + edgePeriodicityIDs.theFace2ID = 0; - TopoDS_Shape GeomEdge1 = entryToShape(edge1); - TopoDS_Shape GeomEdge2 = entryToShape(edge2); + TopoDS_Shape GeomEdge1 = entryToShape(theEdge1); + TopoDS_Shape GeomEdge2 = entryToShape(theEdge2); - TListOfIDs edges1_ids = _getSubShapeIDsInMainShape(theGeomShape, GeomEdge1, TopAbs_EDGE); - TListOfIDs edges2_ids = _getSubShapeIDsInMainShape(theGeomShape, GeomEdge2, TopAbs_EDGE); + TListOfIDs theEdge1_ids = _getSubShapeIDsInMainShape(theGeomShape, GeomEdge1, TopAbs_EDGE); + TListOfIDs theEdge2_ids = _getSubShapeIDsInMainShape(theGeomShape, GeomEdge2, TopAbs_EDGE); if (edge_orientation == 0 and GeomEdge1.Closed()) { @@ -833,8 +858,8 @@ void BLSURFPlugin_BLSURF::createEdgesPeriodicity(TopoDS_Shape theGeomShape, BLSU } // Only one edge id, since only a edge can be selected - edgePeriodicityIDs.edge1ID = edges1_ids[0]; - edgePeriodicityIDs.edge2ID = edges2_ids[0]; + edgePeriodicityIDs.theEdge1ID = theEdge1_ids[0]; + edgePeriodicityIDs.theEdge2ID = theEdge2_ids[0]; edgePeriodicityIDs.edge_orientation = edge_orientation; _edgesIDsPeriodicityVector.push_back(edgePeriodicityIDs); @@ -845,27 +870,27 @@ void BLSURFPlugin_BLSURF::createEdgesPeriodicity(TopoDS_Shape theGeomShape, BLSU ///////////////////////////////////////////////////////// -void BLSURFPlugin_BLSURF::createVerticesPeriodicity(TopoDS_Shape theGeomShape, BLSURFPlugin_Hypothesis::TEntry edge1, BLSURFPlugin_Hypothesis::TEntry vertex1, - BLSURFPlugin_Hypothesis::TEntry edge2, BLSURFPlugin_Hypothesis::TEntry vertex2) +void BLSURFPlugin_BLSURF::createVerticesPeriodicity(TopoDS_Shape theGeomShape, BLSURFPlugin_Hypothesis::TEntry theEdge1, BLSURFPlugin_Hypothesis::TEntry theVertex1, + BLSURFPlugin_Hypothesis::TEntry theEdge2, BLSURFPlugin_Hypothesis::TEntry theVertex2) { MESSAGE("BLSURFPlugin_BLSURF::createVerticesPeriodicity"); - TopoDS_Shape GeomEdge1 = entryToShape(edge1); - TopoDS_Shape GeomVertex1 = entryToShape(vertex1); - TopoDS_Shape GeomEdge2 = entryToShape(edge2); - TopoDS_Shape GeomVertex2 = entryToShape(vertex2); + TopoDS_Shape GeomEdge1 = entryToShape(theEdge1); + TopoDS_Shape GeomVertex1 = entryToShape(theVertex1); + TopoDS_Shape GeomEdge2 = entryToShape(theEdge2); + TopoDS_Shape GeomVertex2 = entryToShape(theVertex2); - TListOfIDs edges1_ids = _getSubShapeIDsInMainShape(theGeomShape, GeomEdge1, TopAbs_EDGE); + TListOfIDs theEdge1_ids = _getSubShapeIDsInMainShape(theGeomShape, GeomEdge1, TopAbs_EDGE); TListOfIDs vertices1_ids = _getSubShapeIDsInMainShape(theGeomShape, GeomVertex1, TopAbs_VERTEX); - TListOfIDs edges2_ids = _getSubShapeIDsInMainShape(theGeomShape, GeomEdge2, TopAbs_EDGE); + TListOfIDs theEdge2_ids = _getSubShapeIDsInMainShape(theGeomShape, GeomEdge2, TopAbs_EDGE); TListOfIDs vertices2_ids = _getSubShapeIDsInMainShape(theGeomShape, GeomVertex2, TopAbs_VERTEX); // Only one vertex id, since only a vertex can be selected TVertexPeriodicityIDs vertexPeriodicityIDs; - vertexPeriodicityIDs.edge1ID = edges1_ids[0]; - vertexPeriodicityIDs.vertex1ID = vertices1_ids[0]; - vertexPeriodicityIDs.edge2ID = edges2_ids[0]; - vertexPeriodicityIDs.vertex2ID = vertices2_ids[0]; + vertexPeriodicityIDs.theEdge1ID = theEdge1_ids[0]; + vertexPeriodicityIDs.theVertex1ID = vertices1_ids[0]; + vertexPeriodicityIDs.theEdge2ID = theEdge2_ids[0]; + vertexPeriodicityIDs.theVertex2ID = vertices2_ids[0]; _verticesIDsPeriodicityVector.push_back(vertexPeriodicityIDs); MESSAGE("_verticesIDsPeriodicityVector.size() = " << _verticesIDsPeriodicityVector.size()); @@ -1385,12 +1410,20 @@ void BLSURFPlugin_BLSURF::SetParameters( } // PERIODICITY + + // reset vectors + _preCadFacesIDsPeriodicityVector.clear(); + _preCadEdgesIDsPeriodicityVector.clear(); + _facesIDsPeriodicityVector.clear(); + _edgesIDsPeriodicityVector.clear(); + _verticesIDsPeriodicityVector.clear(); + MESSAGE("SetParameters preCadFacesPeriodicityVector"); const BLSURFPlugin_Hypothesis::TPreCadPeriodicityVector preCadFacesPeriodicityVector = BLSURFPlugin_Hypothesis::GetPreCadFacesPeriodicityVector(hyp); for (std::size_t i = 0; iGetSubMeshDS() ); } - std::string aFileName = "fmap_vertex_"; - aFileName.append(to_string(*ip)); - aFileName.append(".brep"); - BRepTools::Write(v,aFileName.c_str()); +// std::string aFileName = "fmap_vertex_"; +// aFileName.append(to_string(*ip)); +// aFileName.append(".brep"); +// BRepTools::Write(v,aFileName.c_str()); if (HasSizeMapOnVertex){ vertexKey = VerticesWithSizeMap.FindIndex(v); @@ -2419,36 +2452,47 @@ bool BLSURFPlugin_BLSURF::compute(SMESH_Mesh& aMesh, if (! _preCadFacesIDsPeriodicityVector.empty()){ MESSAGE("INTO PRECAD FACES PERIODICITY"); for (std::size_t i=0; i < _preCadFacesIDsPeriodicityVector.size(); i++){ - std::vector faces1_ids = _preCadFacesIDsPeriodicityVector[i].shape1IDs; - std::vector faces2_ids = _preCadFacesIDsPeriodicityVector[i].shape2IDs; - // TODO: récupérer _preCadFacesIDsPeriodicityVector[i].f_funct - meshgems_cad_periodicity_transformation_t periodicity_transformation = NULL; - int* faces1_ids_c = &faces1_ids[0]; - int* faces2_ids_c = &faces2_ids[0]; + std::vector theFace1_ids = _preCadFacesIDsPeriodicityVector[i].shape1IDs; + std::vector theFace2_ids = _preCadFacesIDsPeriodicityVector[i].shape2IDs; + int* theFace1_ids_c = &theFace1_ids[0]; + int* theFace2_ids_c = &theFace2_ids[0]; std::ostringstream o; o << "_preCadFacesIDsPeriodicityVector[" << i << "] = ["; - for (std::size_t j=0; j < faces1_ids.size(); j++) - o << faces1_ids[j] << ", "; + for (std::size_t j=0; j < theFace1_ids.size(); j++) + o << theFace1_ids[j] << ", "; o << "], ["; - for (std::size_t j=0; j < faces2_ids.size(); j++) - o << faces2_ids[j] << ", "; + for (std::size_t j=0; j < theFace2_ids.size(); j++) + o << theFace2_ids[j] << ", "; o << "]"; MESSAGE(o.str()); - MESSAGE("faces1_ids.size(): " << faces1_ids.size()); - MESSAGE("faces2_ids.size(): " << faces2_ids.size()); - status = cad_add_face_multiple_periodicity_with_transformation_function(c, faces1_ids_c, faces1_ids.size(), - faces2_ids_c, faces2_ids.size(), periodicity_transformation, NULL); -// double p1[] = {0, 0, 0, 100, 0, 0, 0, 0, 100}; -// double p2[] = {0, 100, 0, 100, 100, 0, 0, 100, 100}; -// double (*ptr1)[9]; -// double (*ptr2)[9]; -// ptr1 = &p1; -// ptr2 = &p2; -// status = cad_add_face_multiple_periodicity_with_transformation_function_by_points(c, faces1_ids_c, faces1_ids.size(), -// faces2_ids_c, faces2_ids.size(), &p1[0], 3, &p2[0], 3); - if(status != STATUS_OK){ - cout << "cad_add_face_multiple_periodicity_with_transformation_function failed with error code " << status << "\n"; - } + MESSAGE("theFace1_ids.size(): " << theFace1_ids.size()); + MESSAGE("theFace2_ids.size(): " << theFace2_ids.size()); + if (_preCadFacesIDsPeriodicityVector[i].theSourceVerticesCoords.empty()) + { + // If no source points, call peridoicity without transformation function + MESSAGE("periodicity without transformation function"); + meshgems_cad_periodicity_transformation_t periodicity_transformation = NULL; + status = cad_add_face_multiple_periodicity_with_transformation_function(c, theFace1_ids_c, theFace1_ids.size(), + theFace2_ids_c, theFace2_ids.size(), periodicity_transformation, NULL); + if(status != STATUS_OK) + cout << "cad_add_face_multiple_periodicity_with_transformation_function failed with error code " << status << "\n"; + } + else + { + // get the transformation vertices + MESSAGE("periodicity with transformation vertices"); + double* theSourceVerticesCoords_c = &_preCadFacesIDsPeriodicityVector[i].theSourceVerticesCoords[0]; + double* theTargetVerticesCoords_c = &_preCadFacesIDsPeriodicityVector[i].theTargetVerticesCoords[0]; + int nbSourceVertices = _preCadFacesIDsPeriodicityVector[i].theSourceVerticesCoords.size()/3; + int nbTargetVertices = _preCadFacesIDsPeriodicityVector[i].theTargetVerticesCoords.size()/3; + + MESSAGE("nbSourceVertices: " << nbSourceVertices << ", nbTargetVertices: " << nbTargetVertices); + + status = cad_add_face_multiple_periodicity_with_transformation_function_by_points(c, theFace1_ids_c, theFace1_ids.size(), + theFace2_ids_c, theFace2_ids.size(), theSourceVerticesCoords_c, nbSourceVertices, theTargetVerticesCoords_c, nbTargetVertices); + if(status != STATUS_OK) + cout << "cad_add_face_multiple_periodicity_with_transformation_function_by_points failed with error code " << status << "\n"; + } } MESSAGE("END PRECAD FACES PERIODICITY"); @@ -2458,45 +2502,52 @@ bool BLSURFPlugin_BLSURF::compute(SMESH_Mesh& aMesh, if (! _preCadEdgesIDsPeriodicityVector.empty()){ MESSAGE("INTO PRECAD EDGES PERIODICITY"); for (std::size_t i=0; i < _preCadEdgesIDsPeriodicityVector.size(); i++){ - // TODO: plutôt que d'utiliser une paire edge1, edge2, utiliser un struct avec edge1, edge2 et f_transf - std::vector edges1_ids = _preCadEdgesIDsPeriodicityVector[i].shape1IDs; - std::vector edges2_ids = _preCadEdgesIDsPeriodicityVector[i].shape2IDs; - // TODO: récupérer _preCadEdgesIDsPeriodicityVector[i].f_funct - meshgems_cad_periodicity_transformation_t periodicity_transformation = NULL; + std::vector theEdge1_ids = _preCadEdgesIDsPeriodicityVector[i].shape1IDs; + std::vector theEdge2_ids = _preCadEdgesIDsPeriodicityVector[i].shape2IDs; // Use the address of the first element of the vector to initialise the array -// int* edges1_ids_c = &edges1_ids[0]; -// int* edges2_ids_c = &edges2_ids[0]; - - // Copy the vector into an array - int edges1_ids_c[edges1_ids.size()]; - std::copy(edges1_ids.begin(), edges1_ids.end(), edges1_ids_c); - int edges2_ids_c[edges2_ids.size()]; - std::copy(edges2_ids.begin(), edges2_ids.end(), edges2_ids_c); + int* theEdge1_ids_c = &theEdge1_ids[0]; + int* theEdge2_ids_c = &theEdge2_ids[0]; std::ostringstream o; o << "_preCadEdgesIDsPeriodicityVector[" << i << "] = ["; - for (std::size_t j=0; j < edges1_ids.size(); j++) - o << edges1_ids[j] << ", "; + for (std::size_t j=0; j < theEdge1_ids.size(); j++) + o << theEdge1_ids[j] << ", "; o << "], ["; - for (std::size_t j=0; j < edges2_ids.size(); j++) - o << edges2_ids[j] << ", "; + for (std::size_t j=0; j < theEdge2_ids.size(); j++) + o << theEdge2_ids[j] << ", "; o << "]"; MESSAGE(o.str()); - MESSAGE("edges1_ids.size(): " << edges1_ids.size()); - MESSAGE("edges2_ids.size(): " << edges2_ids.size()); - status = cad_add_edge_multiple_periodicity_with_transformation_function(c, edges1_ids_c, edges1_ids.size(), - edges2_ids_c, edges2_ids.size(), periodicity_transformation, NULL); -// double p1[] = {0, 0, 0, 100, 0, 0, 0, 0, 100}; -// double p2[] = {0, 100, 0, 100, 100, 0, 0, 100, 100}; -// double (*ptr1)[9]; -// double (*ptr2)[9]; -// ptr1 = &p1; -// ptr2 = &p2; -// status = cad_add_edge_multiple_periodicity_with_transformation_function_by_points(c, edges1_ids_c, edges1_ids.size(), -// edges2_ids_c, edges2_ids.size(), &p1[0], 3, &p2[0], 3); - if(status != STATUS_OK){ - cout << "cad_add_edge_multiple_periodicity_with_transformation_function failed with error code " << status << "\n"; - } + MESSAGE("theEdge1_ids.size(): " << theEdge1_ids.size()); + MESSAGE("theEdge2_ids.size(): " << theEdge2_ids.size()); + + if (_preCadEdgesIDsPeriodicityVector[i].theSourceVerticesCoords.empty()) + { + // If no source points, call peridoicity without transformation function + MESSAGE("periodicity without transformation function"); + meshgems_cad_periodicity_transformation_t periodicity_transformation = NULL; + status = cad_add_edge_multiple_periodicity_with_transformation_function(c, theEdge1_ids_c, theEdge1_ids.size(), + theEdge2_ids_c, theEdge2_ids.size(), periodicity_transformation, NULL); + if(status != STATUS_OK) + cout << "cad_add_edge_multiple_periodicity_with_transformation_function failed with error code " << status << "\n"; + } + else + { + // get the transformation vertices + MESSAGE("periodicity with transformation vertices"); + double* theSourceVerticesCoords_c = &_preCadEdgesIDsPeriodicityVector[i].theSourceVerticesCoords[0]; + double* theTargetVerticesCoords_c = &_preCadEdgesIDsPeriodicityVector[i].theTargetVerticesCoords[0]; + int nbSourceVertices = _preCadEdgesIDsPeriodicityVector[i].theSourceVerticesCoords.size()/3; + int nbTargetVertices = _preCadEdgesIDsPeriodicityVector[i].theTargetVerticesCoords.size()/3; + + MESSAGE("nbSourceVertices: " << nbSourceVertices << ", nbTargetVertices: " << nbTargetVertices); + + status = cad_add_edge_multiple_periodicity_with_transformation_function_by_points(c, theEdge1_ids_c, theEdge1_ids.size(), + theEdge2_ids_c, theEdge2_ids.size(), theSourceVerticesCoords_c, nbSourceVertices, theTargetVerticesCoords_c, nbTargetVertices); + if(status != STATUS_OK) + cout << "cad_add_edge_multiple_periodicity_with_transformation_function_by_points failed with error code " << status << "\n"; + else + MESSAGE("cad_add_edge_multiple_periodicity_with_transformation_function_by_points succeeded.\n"); + } } MESSAGE("END PRECAD EDGES PERIODICITY"); @@ -2505,10 +2556,10 @@ bool BLSURFPlugin_BLSURF::compute(SMESH_Mesh& aMesh, if (! _facesIDsPeriodicityVector.empty()){ MESSAGE("INTO FACE PERIODICITY"); for (std::size_t i=0; i < _facesIDsPeriodicityVector.size(); i++){ - int face1 = _facesIDsPeriodicityVector[i].first; - int face2 = _facesIDsPeriodicityVector[i].second; - MESSAGE("_facesIDsPeriodicityVector[" << i << "] = (" << face1 << ", " << face2 << ")"); - status = cad_add_face_periodicity(c, face1, face2); + int theFace1 = _facesIDsPeriodicityVector[i].first; + int theFace2 = _facesIDsPeriodicityVector[i].second; + MESSAGE("_facesIDsPeriodicityVector[" << i << "] = (" << theFace1 << ", " << theFace2 << ")"); + status = cad_add_face_periodicity(c, theFace1, theFace2); if(status != STATUS_OK){ cout << "cad_add_face_periodicity failed with error code " << status << "\n"; } @@ -2520,13 +2571,13 @@ bool BLSURFPlugin_BLSURF::compute(SMESH_Mesh& aMesh, if (! _edgesIDsPeriodicityVector.empty()){ MESSAGE("INTO EDGE PERIODICITY"); for (std::size_t i=0; i < _edgesIDsPeriodicityVector.size(); i++){ - int face1 = _edgesIDsPeriodicityVector[i].face1ID; - int edge1 = _edgesIDsPeriodicityVector[i].edge1ID; - int face2 = _edgesIDsPeriodicityVector[i].face2ID; - int edge2 = _edgesIDsPeriodicityVector[i].edge2ID; + int theFace1 = _edgesIDsPeriodicityVector[i].theFace1ID; + int theEdge1 = _edgesIDsPeriodicityVector[i].theEdge1ID; + int theFace2 = _edgesIDsPeriodicityVector[i].theFace2ID; + int theEdge2 = _edgesIDsPeriodicityVector[i].theEdge2ID; int edge_orientation = _edgesIDsPeriodicityVector[i].edge_orientation; - MESSAGE("_edgesIDsPeriodicityVector[" << i << "] = (" << face1 << ", " << edge1 << ", " << face2 << ", " << edge2 << ", " << edge_orientation << ")"); - status = cad_add_edge_periodicity(c, face1, edge1, face2, edge2, edge_orientation); + MESSAGE("_edgesIDsPeriodicityVector[" << i << "] = (" << theFace1 << ", " << theEdge1 << ", " << theFace2 << ", " << theEdge2 << ", " << edge_orientation << ")"); + status = cad_add_edge_periodicity(c, theFace1, theEdge1, theFace2, theEdge2, edge_orientation); if(status != STATUS_OK){ cout << "cad_add_edge_periodicity failed with error code " << status << "\n"; } @@ -2537,12 +2588,12 @@ bool BLSURFPlugin_BLSURF::compute(SMESH_Mesh& aMesh, if (! _verticesIDsPeriodicityVector.empty()){ MESSAGE("INTO VERTEX PERIODICITY"); for (std::size_t i=0; i < _verticesIDsPeriodicityVector.size(); i++){ - int edge1 = _verticesIDsPeriodicityVector[i].edge1ID; - int vertex1 = _verticesIDsPeriodicityVector[i].vertex1ID; - int edge2 = _verticesIDsPeriodicityVector[i].edge2ID; - int vertex2 = _verticesIDsPeriodicityVector[i].vertex2ID; - MESSAGE("_verticesIDsPeriodicityVector[" << i << "] = (" << edge1 << ", " << vertex1 << ", " << edge2 << ", " << vertex2 << ")"); - status = cad_add_point_periodicity(c, edge1, vertex1, edge2, vertex2); + int theEdge1 = _verticesIDsPeriodicityVector[i].theEdge1ID; + int theVertex1 = _verticesIDsPeriodicityVector[i].theVertex1ID; + int theEdge2 = _verticesIDsPeriodicityVector[i].theEdge2ID; + int theVertex2 = _verticesIDsPeriodicityVector[i].theVertex2ID; + MESSAGE("_verticesIDsPeriodicityVector[" << i << "] = (" << theEdge1 << ", " << theVertex1 << ", " << theEdge2 << ", " << theVertex2 << ")"); + status = cad_add_point_periodicity(c, theEdge1, theVertex1, theEdge2, theVertex2); if(status != STATUS_OK){ cout << "cad_add_vertex_periodicity failed with error code " << status << "\n"; } @@ -2557,7 +2608,10 @@ bool BLSURFPlugin_BLSURF::compute(SMESH_Mesh& aMesh, /* Now launch the PreCAD process */ status = precad_process(pcs); if(status != STATUS_OK){ + // TODO: raise an error if status < 0. + cout << "================ WARNING =================== \n"; cout << "PreCAD processing failed with error code " << status << "\n"; + cout << "============================================ \n"; } else { // retrieve the pre-processed CAD object diff --git a/src/BLSURFPlugin/BLSURFPlugin_BLSURF.hxx b/src/BLSURFPlugin/BLSURFPlugin_BLSURF.hxx index 8e667bf..dd6c55b 100644 --- a/src/BLSURFPlugin/BLSURFPlugin_BLSURF.hxx +++ b/src/BLSURFPlugin/BLSURFPlugin_BLSURF.hxx @@ -101,29 +101,27 @@ class BLSURFPlugin_BLSURF: public SMESH_2D_Algo { struct TPreCadPeriodicityIDs { TListOfIDs shape1IDs; TListOfIDs shape2IDs; - const char* f_funct; + std::vector theSourceVerticesCoords; + std::vector theTargetVerticesCoords; }; // Edge periodicity struct TEdgePeriodicityIDs { - int face1ID; - int edge1ID; - int face2ID; - int edge2ID; + int theFace1ID; + int theEdge1ID; + int theFace2ID; + int theEdge2ID; int edge_orientation; }; // Vertex periodicity struct TVertexPeriodicityIDs { - int edge1ID; - int vertex1ID; - int edge2ID; - int vertex2ID; + int theEdge1ID; + int theVertex1ID; + int theEdge2ID; + int theVertex2ID; }; - // pair of shapes - typedef std::pair TPairOfShapes; - typedef std::pair TPairOfListOfIDs; // Vector of pairs of ids typedef std::vector< TPreCadPeriodicityIDs > TPreCadIDsPeriodicityVector; typedef std::vector< std::pair > TShapesIDsPeriodicityVector; @@ -152,14 +150,15 @@ class BLSURFPlugin_BLSURF: public SMESH_2D_Algo { const char * option_value); TopoDS_Shape entryToShape(std::string entry); + void addCoordsFromVertex(BLSURFPlugin_Hypothesis::TEntry theVertexEntry, std::vector &theVerticesCoords); void createEnforcedVertexOnFace(TopoDS_Shape FaceShape, BLSURFPlugin_Hypothesis::TEnfVertexList enfVertexList); - void createPreCadFacesPeriodicity(TopoDS_Shape theGeomShape, BLSURFPlugin_Hypothesis::TEntry faces1, BLSURFPlugin_Hypothesis::TEntry faces2, const char* f_funct = ""); - void createPreCadEdgesPeriodicity(TopoDS_Shape theGeomShape, BLSURFPlugin_Hypothesis::TEntry edges1, BLSURFPlugin_Hypothesis::TEntry edges2, const char* f_funct = ""); - void createFacesPeriodicity(TopoDS_Shape theGeomShape, BLSURFPlugin_Hypothesis::TEntry face1, BLSURFPlugin_Hypothesis::TEntry face2); - void createEdgesPeriodicity(TopoDS_Shape theGeomShape, BLSURFPlugin_Hypothesis::TEntry face1, BLSURFPlugin_Hypothesis::TEntry edge1, - BLSURFPlugin_Hypothesis::TEntry face2, BLSURFPlugin_Hypothesis::TEntry edge2, int edge_orientation = 0); - void createVerticesPeriodicity(TopoDS_Shape theGeomShape, BLSURFPlugin_Hypothesis::TEntry edge1, BLSURFPlugin_Hypothesis::TEntry vertex1, - BLSURFPlugin_Hypothesis::TEntry edge2, BLSURFPlugin_Hypothesis::TEntry vertex2); + void createPreCadFacesPeriodicity(TopoDS_Shape theGeomShape, const BLSURFPlugin_Hypothesis::TPreCadPeriodicity &preCadPeriodicity); + void createPreCadEdgesPeriodicity(TopoDS_Shape theGeomShape, const BLSURFPlugin_Hypothesis::TPreCadPeriodicity &preCadPeriodicity); + void createFacesPeriodicity(TopoDS_Shape theGeomShape, BLSURFPlugin_Hypothesis::TEntry theFace1, BLSURFPlugin_Hypothesis::TEntry theFace2); + void createEdgesPeriodicity(TopoDS_Shape theGeomShape, BLSURFPlugin_Hypothesis::TEntry theFace1, BLSURFPlugin_Hypothesis::TEntry theEdge1, + BLSURFPlugin_Hypothesis::TEntry theFace2, BLSURFPlugin_Hypothesis::TEntry theEdge2, int edge_orientation = 0); + void createVerticesPeriodicity(TopoDS_Shape theGeomShape, BLSURFPlugin_Hypothesis::TEntry theEdge1, BLSURFPlugin_Hypothesis::TEntry theVertex1, + BLSURFPlugin_Hypothesis::TEntry theEdge2, BLSURFPlugin_Hypothesis::TEntry theVertex2); void Set_NodeOnEdge(SMESHDS_Mesh* meshDS, SMDS_MeshNode* node, const TopoDS_Shape& ed); void BRepClass_FaceClassifierPerform(BRepClass_FaceClassifier* fc, const TopoDS_Face& face, const gp_Pnt& P, const Standard_Real Tol); diff --git a/src/BLSURFPlugin/BLSURFPlugin_Hypothesis.cxx b/src/BLSURFPlugin/BLSURFPlugin_Hypothesis.cxx index 2111730..94a2695 100644 --- a/src/BLSURFPlugin/BLSURFPlugin_Hypothesis.cxx +++ b/src/BLSURFPlugin/BLSURFPlugin_Hypothesis.cxx @@ -1238,102 +1238,81 @@ BLSURFPlugin_Hypothesis::TVerticesPeriodicityVector BLSURFPlugin_Hypothesis::Get //======================================================================= //function : AddPreCadFacesPeriodicity //======================================================================= -void BLSURFPlugin_Hypothesis::AddPreCadFacesPeriodicity(TEntry faces1Entry, TEntry faces2Entry, const char* f_funct) { - - MESSAGE("BLSURFPlugin_Hypothesis::AddPreCadFacesPeriodicity("<< faces1Entry << ", " - << faces2Entry << ", " << f_funct << ")"); +void BLSURFPlugin_Hypothesis::AddPreCadFacesPeriodicity(TEntry theFace1Entry, TEntry theFace2Entry, + vector &theSourceVerticesEntries, vector &theTargetVerticesEntries) { TPreCadPeriodicity preCadFacesPeriodicity; - preCadFacesPeriodicity.shape1Entry = faces1Entry; - preCadFacesPeriodicity.shape2Entry = faces2Entry; - preCadFacesPeriodicity.f_funct = f_funct; + preCadFacesPeriodicity.shape1Entry = theFace1Entry; + preCadFacesPeriodicity.shape2Entry = theFace2Entry; + preCadFacesPeriodicity.theSourceVerticesEntries = theSourceVerticesEntries; + preCadFacesPeriodicity.theTargetVerticesEntries = theTargetVerticesEntries; _preCadFacesPeriodicityVector.push_back(preCadFacesPeriodicity); NotifySubMeshesHypothesisModification(); - - MESSAGE("BLSURFPlugin_Hypothesis::AddPreCadFacesPeriodicity END"); } //======================================================================= //function : AddPreCadEdgesPeriodicity //======================================================================= -void BLSURFPlugin_Hypothesis::AddPreCadEdgesPeriodicity(TEntry edges1Entry, TEntry edges2Entry, const char* f_funct) { - - MESSAGE("BLSURFPlugin_Hypothesis::AddPreCadEdgesPeriodicity("<< edges1Entry << ", " - << edges2Entry << ", " << f_funct << ")"); +void BLSURFPlugin_Hypothesis::AddPreCadEdgesPeriodicity(TEntry theEdge1Entry, TEntry theEdge2Entry, + vector &theSourceVerticesEntries, vector &theTargetVerticesEntries) { TPreCadPeriodicity preCadEdgesPeriodicity; - preCadEdgesPeriodicity.shape1Entry = edges1Entry; - preCadEdgesPeriodicity.shape2Entry = edges2Entry; - preCadEdgesPeriodicity.f_funct = f_funct; + preCadEdgesPeriodicity.shape1Entry = theEdge1Entry; + preCadEdgesPeriodicity.shape2Entry = theEdge2Entry; + preCadEdgesPeriodicity.theSourceVerticesEntries = theSourceVerticesEntries; + preCadEdgesPeriodicity.theTargetVerticesEntries = theTargetVerticesEntries; _preCadEdgesPeriodicityVector.push_back(preCadEdgesPeriodicity); NotifySubMeshesHypothesisModification(); - - MESSAGE("BLSURFPlugin_Hypothesis::AddPreCadEdgesPeriodicity END"); } //======================================================================= //function : AddFacePeriodicity //======================================================================= -void BLSURFPlugin_Hypothesis::AddFacePeriodicity(TEntry face1Entry, TEntry face2Entry) { - - MESSAGE("BLSURFPlugin_Hypothesis::AddFacePeriodicity("<< face1Entry << ", " - << face2Entry << ")"); +void BLSURFPlugin_Hypothesis::AddFacePeriodicity(TEntry theFace1Entry, TEntry theFace2Entry) { - std::pair< TEntry, TEntry > pairOfFacesEntries = std::make_pair(face1Entry, face2Entry); + std::pair< TEntry, TEntry > pairOfFacesEntries = std::make_pair(theFace1Entry, theFace2Entry); _facesPeriodicityVector.push_back(pairOfFacesEntries); NotifySubMeshesHypothesisModification(); - - MESSAGE("BLSURFPlugin_Hypothesis::AddFacePeriodicity END"); } //======================================================================= //function : AddEdgePeriodicity //======================================================================= -void BLSURFPlugin_Hypothesis::AddEdgePeriodicity(TEntry face1Entry, TEntry edge1Entry, TEntry face2Entry, TEntry edge2Entry, int edge_orientation) { - - MESSAGE("BLSURFPlugin_Hypothesis::AddEdgePeriodicity("<< edge1Entry << ", " - << edge2Entry << ")"); +void BLSURFPlugin_Hypothesis::AddEdgePeriodicity(TEntry theFace1Entry, TEntry theEdge1Entry, TEntry theFace2Entry, TEntry theEdge2Entry, int edge_orientation) { TEdgePeriodicity edgePeriodicity; - edgePeriodicity.face1Entry = face1Entry; - edgePeriodicity.edge1Entry = edge1Entry; - edgePeriodicity.face2Entry = face2Entry; - edgePeriodicity.edge2Entry = edge2Entry; + edgePeriodicity.theFace1Entry = theFace1Entry; + edgePeriodicity.theEdge1Entry = theEdge1Entry; + edgePeriodicity.theFace2Entry = theFace2Entry; + edgePeriodicity.theEdge2Entry = theEdge2Entry; edgePeriodicity.edge_orientation = edge_orientation; _edgesPeriodicityVector.push_back(edgePeriodicity); NotifySubMeshesHypothesisModification(); - - MESSAGE("BLSURFPlugin_Hypothesis::AddEdgePeriodicity END"); } //======================================================================= //function : AddVertexPeriodicity //======================================================================= -void BLSURFPlugin_Hypothesis::AddVertexPeriodicity(TEntry edge1Entry, TEntry vertex1Entry, TEntry edge2Entry, TEntry vertex2Entry) { - - MESSAGE("BLSURFPlugin_Hypothesis::AddVertexPeriodicity("<< vertex1Entry << ", " - << vertex2Entry << ")"); +void BLSURFPlugin_Hypothesis::AddVertexPeriodicity(TEntry theEdge1Entry, TEntry theVertex1Entry, TEntry theEdge2Entry, TEntry theVertex2Entry) { TVertexPeriodicity vertexPeriodicity; - vertexPeriodicity.edge1Entry = edge1Entry; - vertexPeriodicity.vertex1Entry = vertex1Entry; - vertexPeriodicity.edge2Entry = edge2Entry; - vertexPeriodicity.vertex2Entry = vertex2Entry; + vertexPeriodicity.theEdge1Entry = theEdge1Entry; + vertexPeriodicity.theVertex1Entry = theVertex1Entry; + vertexPeriodicity.theEdge2Entry = theEdge2Entry; + vertexPeriodicity.theVertex2Entry = theVertex2Entry; _verticesPeriodicityVector.push_back(vertexPeriodicity); NotifySubMeshesHypothesisModification(); - - MESSAGE("BLSURFPlugin_Hypothesis::AddVertexPeriodicity END"); } //============================================================================= diff --git a/src/BLSURFPlugin/BLSURFPlugin_Hypothesis.hxx b/src/BLSURFPlugin/BLSURFPlugin_Hypothesis.hxx index 2ad4eaf..ae1f40c 100644 --- a/src/BLSURFPlugin/BLSURFPlugin_Hypothesis.hxx +++ b/src/BLSURFPlugin/BLSURFPlugin_Hypothesis.hxx @@ -220,24 +220,25 @@ public: struct TPreCadPeriodicity { TEntry shape1Entry; TEntry shape2Entry; - const char* f_funct; + std::vector theSourceVerticesEntries; + std::vector theTargetVerticesEntries; }; // Edge periodicity struct TEdgePeriodicity { - TEntry face1Entry; - TEntry edge1Entry; - TEntry face2Entry; - TEntry edge2Entry; + TEntry theFace1Entry; + TEntry theEdge1Entry; + TEntry theFace2Entry; + TEntry theEdge2Entry; int edge_orientation; }; // Vertex periodicity struct TVertexPeriodicity { - TEntry edge1Entry; - TEntry vertex1Entry; - TEntry edge2Entry; - TEntry vertex2Entry; + TEntry theEdge1Entry; + TEntry theVertex1Entry; + TEntry theEdge2Entry; + TEntry theVertex2Entry; }; typedef std::pair< TEntry, TEntry > TFacesPeriodicity; @@ -406,12 +407,14 @@ public: const TVerticesPeriodicityVector _GetVerticesPeriodicityVector() const { return _verticesPeriodicityVector; } static TVerticesPeriodicityVector GetVerticesPeriodicityVector(const BLSURFPlugin_Hypothesis* hyp); - void AddPreCadFacesPeriodicity(TEntry faces1Entry, TEntry faces2Entry, const char* f_funct); - void AddPreCadEdgesPeriodicity(TEntry edges1Entry, TEntry edges2Entry, const char* f_funct); + void AddPreCadFacesPeriodicity(TEntry theFace1Entry, TEntry theFace2Entry, + std::vector &theSourceVerticesEntries, std::vector &theTargetVerticesEntries); + void AddPreCadEdgesPeriodicity(TEntry theEdge1Entry, TEntry theEdge2Entry, + std::vector &theSourceVerticesEntries, std::vector &theTargetVerticesEntries); - void AddFacePeriodicity(TEntry face1Entry, TEntry face2Entry); - void AddEdgePeriodicity(TEntry face1Entry, TEntry edge1Entry, TEntry face2Entry, TEntry edge2Entry, int edge_orientation = 0); - void AddVertexPeriodicity(TEntry edge1Entry, TEntry vertex1Entry, TEntry edge2Entry, TEntry vertex2Entry); + void AddFacePeriodicity(TEntry theFace1Entry, TEntry theFace2Entry); + void AddEdgePeriodicity(TEntry theFace1Entry, TEntry theEdge1Entry, TEntry theFace2Entry, TEntry theEdge2Entry, int edge_orientation = 0); + void AddVertexPeriodicity(TEntry theEdge1Entry, TEntry theVertex1Entry, TEntry theEdge2Entry, TEntry theVertex2Entry); static double undefinedDouble() { return -1.0; } diff --git a/src/BLSURFPlugin/BLSURFPlugin_Hypothesis_i.cxx b/src/BLSURFPlugin/BLSURFPlugin_Hypothesis_i.cxx index 303c360..066021e 100644 --- a/src/BLSURFPlugin/BLSURFPlugin_Hypothesis_i.cxx +++ b/src/BLSURFPlugin/BLSURFPlugin_Hypothesis_i.cxx @@ -2662,110 +2662,228 @@ std::string BLSURFPlugin_Hypothesis_i::PublishIfNeeded(GEOM::GEOM_Object_ptr sha return shapeEntry; } -void BLSURFPlugin_Hypothesis_i::AddPreCadFacesPeriodicity(GEOM::GEOM_Object_ptr faces1, GEOM::GEOM_Object_ptr faces2, const char* f_transf) +// Format the output of two vectors to use it in MESSAGE and PythonDump +std::string BLSURFPlugin_Hypothesis_i::FormatVerticesEntries(vector &theSourceVerticesEntries, vector &theTargetVerticesEntries) +{ + std::stringstream listEntriesTxt; + + if (!theSourceVerticesEntries.empty()) + { + listEntriesTxt << ", [" ; + for (size_t i = 0; i0) + listEntriesTxt << ", "; + listEntriesTxt << theSourceVerticesEntries[i]; + } + + listEntriesTxt << "], [" ; + for (size_t i = 0; i0) + listEntriesTxt << ", "; + listEntriesTxt << theTargetVerticesEntries[i]; + } + listEntriesTxt << "]" ; + } + return listEntriesTxt.str(); +} + + +void BLSURFPlugin_Hypothesis_i::AddPreCadFacesPeriodicity(GEOM::GEOM_Object_ptr theFace1, GEOM::GEOM_Object_ptr theFace2) throw (SALOME::SALOME_Exception) { ASSERT(myBaseImpl); + const GEOM::ListOfGO theSourceVertices; + const GEOM::ListOfGO theTargetVertices; + AddPreCadFacesPeriodicityWithVertices(theFace1, theFace2, theSourceVertices, theTargetVertices); +} + + +void BLSURFPlugin_Hypothesis_i::AddPreCadFacesPeriodicityWithVertices(GEOM::GEOM_Object_ptr theFace1, GEOM::GEOM_Object_ptr theFace2, + const GEOM::ListOfGO& theSourceVertices, const GEOM::ListOfGO& theTargetVertices) +throw (SALOME::SALOME_Exception) +{ + ASSERT(myBaseImpl); + + size_t theLength = theSourceVertices.length(); + if (theLength != theTargetVertices.length()) + THROW_SALOME_CORBA_EXCEPTION( "The sizes of theSourceVertices and theTargetVertices must be the same" ,SALOME::BAD_PARAM ); std::vector allowedShapeTypes; allowedShapeTypes.push_back(GEOM::FACE); allowedShapeTypes.push_back(GEOM::COMPOUND); string prefix1 = "Source_face_"; - CheckShapeTypes(faces1, allowedShapeTypes); - string faces1Entry = PublishIfNeeded(faces1, GEOM::FACE, prefix1); - string prefix2 = "Target_face_"; - CheckShapeTypes(faces2, allowedShapeTypes); - string faces2Entry = PublishIfNeeded(faces2, GEOM::FACE, prefix2); + CheckShapeTypes(theFace1, allowedShapeTypes); + string theFace1Entry = PublishIfNeeded(theFace1, GEOM::FACE, prefix1); - string faces2Name = faces2->GetName(); - MESSAGE("IDL : faces1->GetName : " << faces1->GetName()); - MESSAGE("IDL : faces2->GetName : " << faces2->GetName()); - MESSAGE("IDL : AddPreCadFacesPeriodicity( "<< faces1Entry << ", " << faces2Entry << ", " << f_transf << ")"); + string prefix2 = "Target_face_"; + CheckShapeTypes(theFace2, allowedShapeTypes); + string theFace2Entry = PublishIfNeeded(theFace2, GEOM::FACE, prefix2); + + string prefix3 = "Source_vertex_"; + vector theSourceVerticesEntries (theLength) ; + GEOM::GEOM_Object_ptr theVtx_i; + string theEntry_i; + for (size_t ind = 0; ind < theLength; ind++) { + theVtx_i = theSourceVertices[ind]; + theEntry_i = PublishIfNeeded(theVtx_i, GEOM::VERTEX, prefix3); + theSourceVerticesEntries[ind] = theEntry_i; + } + + string prefix4 = "Target_vertex_"; + vector theTargetVerticesEntries (theLength) ; + for (size_t ind = 0; ind < theLength; ind++) { + theVtx_i = theTargetVertices[ind]; + theEntry_i = PublishIfNeeded(theVtx_i, GEOM::VERTEX, prefix4); + theTargetVerticesEntries[ind] = theEntry_i; + } + + string theFace2Name = theFace2->GetName(); + MESSAGE("IDL : theFace1->GetName : " << theFace1->GetName()); + MESSAGE("IDL : theFace2->GetName : " << theFace2->GetName()); + MESSAGE("IDL : AddPreCadFacesPeriodicity( "<< theFace1Entry << ", " << theFace2Entry << ")"); try { - AddPreCadFacesPeriodicityEntry(faces1Entry.c_str(), faces2Entry.c_str(), f_transf); + AddPreCadFacesPeriodicityEntry(theFace1Entry.c_str(), theFace2Entry.c_str(), + theSourceVerticesEntries, theTargetVerticesEntries); } catch (SALOME_Exception& ex) { THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM ); } } -void BLSURFPlugin_Hypothesis_i::AddPreCadFacesPeriodicityEntry(const char* faces1Entry, const char* faces2Entry, const char* f_transf) + +void BLSURFPlugin_Hypothesis_i::AddPreCadFacesPeriodicityEntry(const char* theFace1Entry, const char* theFace2Entry, + vector &theSourceVerticesEntries, vector &theTargetVerticesEntries) throw (SALOME::SALOME_Exception) { ASSERT(myBaseImpl); - MESSAGE("IDL : AddPreCadFacesPeriodicityEntry(" << faces1Entry << ", " << faces2Entry << ", \"" << f_transf << "\")"); - this->GetImpl()->AddPreCadFacesPeriodicity(faces1Entry, faces2Entry, f_transf); + string listEntriesTxt = FormatVerticesEntries(theSourceVerticesEntries, theTargetVerticesEntries); + + MESSAGE("IDL : AddPreCadFacesPeriodicityEntry(" << theFace1Entry << ", " << theFace2Entry << listEntriesTxt.c_str() << ")"); + + this->GetImpl()->AddPreCadFacesPeriodicity(theFace1Entry, theFace2Entry, + theSourceVerticesEntries, theTargetVerticesEntries); + SMESH::TPythonDump pd; - pd << _this() << ".AddPreCadFacesPeriodicity(" << faces1Entry << ", " << faces2Entry; - if (f_transf != "") - pd << ", \"" << f_transf << "\""; - pd << ")"; + if (!theSourceVerticesEntries.empty()) + { + pd << _this() << ".AddPreCadFacesPeriodicityWithVertices(" << theFace1Entry << ", " << theFace2Entry; + pd << listEntriesTxt.c_str(); + pd << ")"; + } + else + pd << _this() << ".AddPreCadFacesPeriodicity(" << theFace1Entry << ", " << theFace2Entry << ")"; MESSAGE("IDL : AddPreCadFacesPeriodicityEntry END"); } -void BLSURFPlugin_Hypothesis_i::AddPreCadEdgesPeriodicity(GEOM::GEOM_Object_ptr edges1, GEOM::GEOM_Object_ptr edges2, const char* f_transf) +void BLSURFPlugin_Hypothesis_i::AddPreCadEdgesPeriodicity(GEOM::GEOM_Object_ptr theEdge1, GEOM::GEOM_Object_ptr theEdge2) + throw (SALOME::SALOME_Exception) +{ + ASSERT(myBaseImpl); + const GEOM::ListOfGO theSourceVertices; + const GEOM::ListOfGO theTargetVertices; + AddPreCadEdgesPeriodicityWithVertices(theEdge1, theEdge2, theSourceVertices, theTargetVertices); +} + +void BLSURFPlugin_Hypothesis_i::AddPreCadEdgesPeriodicityWithVertices(GEOM::GEOM_Object_ptr theEdge1, GEOM::GEOM_Object_ptr theEdge2, + const GEOM::ListOfGO& theSourceVertices, const GEOM::ListOfGO& theTargetVertices) throw (SALOME::SALOME_Exception) { ASSERT(myBaseImpl); + size_t theLength = theSourceVertices.length(); + if (theLength != theTargetVertices.length()) + THROW_SALOME_CORBA_EXCEPTION( "The sizes of theSourceVertices and theTargetVertices must be the same" ,SALOME::BAD_PARAM ); + std::vector allowedShapeTypes; allowedShapeTypes.push_back(GEOM::EDGE); allowedShapeTypes.push_back(GEOM::COMPOUND); string prefix1 = "Source_edge_"; - CheckShapeTypes(edges1, allowedShapeTypes); - string edges1Entry = PublishIfNeeded(edges1, GEOM::EDGE, prefix1); - string prefix2 = "Target_edge_"; - CheckShapeTypes(edges2, allowedShapeTypes); - string edges2Entry = PublishIfNeeded(edges2, GEOM::EDGE, prefix2); + CheckShapeTypes(theEdge1, allowedShapeTypes); + string theEdge1Entry = PublishIfNeeded(theEdge1, GEOM::EDGE, prefix1); - string edges2Name = edges2->GetName(); - MESSAGE("IDL : edges1->GetName : " << edges1->GetName()); - MESSAGE("IDL : edges2->GetName : " << edges2->GetName()); - MESSAGE("IDL : AddPreCadEdgesPeriodicity( "<< edges1Entry << ", " << edges2Entry << ", " << f_transf << ")"); + string prefix2 = "Target_edge_"; + CheckShapeTypes(theEdge2, allowedShapeTypes); + string theEdge2Entry = PublishIfNeeded(theEdge2, GEOM::EDGE, prefix2); + + string prefix3 = "Source_vertex_"; + vector theSourceVerticesEntries (theLength) ; + GEOM::GEOM_Object_ptr theVtx_i; + string theEntry_i; + for (size_t ind = 0; ind < theLength; ind++) { + theVtx_i = theSourceVertices[ind]; + theEntry_i = PublishIfNeeded(theVtx_i, GEOM::VERTEX, prefix3); + theSourceVerticesEntries[ind] = theEntry_i; + } + + string prefix4 = "Target_vertex_"; + vector theTargetVerticesEntries (theLength) ; + for (size_t ind = 0; ind < theLength; ind++) { + theVtx_i = theTargetVertices[ind]; + theEntry_i = PublishIfNeeded(theVtx_i, GEOM::VERTEX, prefix4); + theTargetVerticesEntries[ind] = theEntry_i; + } + + string theEdge2Name = theEdge2->GetName(); + MESSAGE("IDL : theEdge1->GetName : " << theEdge1->GetName()); + MESSAGE("IDL : theEdge2->GetName : " << theEdge2->GetName()); + MESSAGE("IDL : AddPreCadEdgesPeriodicity( "<< theEdge1Entry << ", " << theEdge2Entry << ")"); try { - AddPreCadEdgesPeriodicityEntry(edges1Entry.c_str(), edges2Entry.c_str(), f_transf); + AddPreCadEdgesPeriodicityEntry(theEdge1Entry.c_str(), theEdge2Entry.c_str(), + theSourceVerticesEntries, theTargetVerticesEntries); } catch (SALOME_Exception& ex) { THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM ); } } -void BLSURFPlugin_Hypothesis_i::AddPreCadEdgesPeriodicityEntry(const char* edges1Entry, const char* edges2Entry, const char* f_transf) +void BLSURFPlugin_Hypothesis_i::AddPreCadEdgesPeriodicityEntry(const char* theEdge1Entry, const char* theEdge2Entry, + vector &theSourceVerticesEntries, vector &theTargetVerticesEntries) throw (SALOME::SALOME_Exception) { ASSERT(myBaseImpl); - MESSAGE("IDL : AddPreCadEdgesPeriodicityEntry(" << edges1Entry << ", " << edges2Entry << ", \"" << f_transf << "\")"); - this->GetImpl()->AddPreCadEdgesPeriodicity(edges1Entry, edges2Entry, f_transf); + string listEntriesTxt = FormatVerticesEntries(theSourceVerticesEntries, theTargetVerticesEntries); + + MESSAGE("IDL : AddPreCadEdgesPeriodicityEntry(" << theEdge1Entry << ", " << theEdge2Entry << listEntriesTxt.c_str() << ")"); + this->GetImpl()->AddPreCadEdgesPeriodicity(theEdge1Entry, theEdge2Entry, + theSourceVerticesEntries, theTargetVerticesEntries); + SMESH::TPythonDump pd; - pd << _this() << ".AddPreCadEdgesPeriodicity(" << edges1Entry << ", " << edges2Entry; - if (f_transf != "") - pd << ", \"" << f_transf << "\""; - pd << ")"; + if (!theSourceVerticesEntries.empty()) + { + pd << _this() << ".AddPreCadEdgesPeriodicityWithVertices(" << theEdge1Entry << ", " << theEdge2Entry; + pd << listEntriesTxt.c_str(); + pd << ")"; + } + else + pd << _this() << ".AddPreCadEdgesPeriodicity(" << theEdge1Entry << ", " << theEdge2Entry << ")"; + MESSAGE("IDL : AddPreCadEdgesPeriodicityEntry END"); } -void BLSURFPlugin_Hypothesis_i::AddFacePeriodicity(GEOM::GEOM_Object_ptr face1, GEOM::GEOM_Object_ptr face2) +void BLSURFPlugin_Hypothesis_i::AddFacePeriodicity(GEOM::GEOM_Object_ptr theFace1, GEOM::GEOM_Object_ptr theFace2) throw (SALOME::SALOME_Exception) { ASSERT(myBaseImpl); string prefix1 = "Source_face_"; - CheckShapeType(face1, GEOM::FACE); - string face1Entry = PublishIfNeeded(face1, GEOM::FACE, prefix1); + CheckShapeType(theFace1, GEOM::FACE); + string theFace1Entry = PublishIfNeeded(theFace1, GEOM::FACE, prefix1); string prefix2 = "Target_face_"; - CheckShapeType(face2, GEOM::FACE); - string face2Entry = PublishIfNeeded(face2, GEOM::FACE, prefix2); + CheckShapeType(theFace2, GEOM::FACE); + string theFace2Entry = PublishIfNeeded(theFace2, GEOM::FACE, prefix2); - MESSAGE("IDL : face1->GetName : " << face1->GetName()); - MESSAGE("IDL : face2->GetName : " << face2->GetName()); - MESSAGE("IDL : AddFacePeriodicity( "<< face1Entry << ", " << face2Entry << ")"); + MESSAGE("IDL : theFace1->GetName : " << theFace1->GetName()); + MESSAGE("IDL : theFace2->GetName : " << theFace2->GetName()); + MESSAGE("IDL : AddFacePeriodicity( "<< theFace1Entry << ", " << theFace2Entry << ")"); try { - AddFacePeriodicityEntry(face1Entry.c_str(), face2Entry.c_str()); + AddFacePeriodicityEntry(theFace1Entry.c_str(), theFace2Entry.c_str()); } catch (SALOME_Exception& ex) { THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM ); } @@ -2773,45 +2891,45 @@ void BLSURFPlugin_Hypothesis_i::AddFacePeriodicity(GEOM::GEOM_Object_ptr face1, } -void BLSURFPlugin_Hypothesis_i::AddFacePeriodicityEntry(const char* face1Entry, const char* face2Entry) +void BLSURFPlugin_Hypothesis_i::AddFacePeriodicityEntry(const char* theFace1Entry, const char* theFace2Entry) throw (SALOME::SALOME_Exception){ ASSERT(myBaseImpl); - MESSAGE("IDL : AddFacePeriodicityEntry(" << face1Entry << ", " << face2Entry << ")"); - this->GetImpl()->AddFacePeriodicity(face1Entry, face2Entry); + MESSAGE("IDL : AddFacePeriodicityEntry(" << theFace1Entry << ", " << theFace2Entry << ")"); + this->GetImpl()->AddFacePeriodicity(theFace1Entry, theFace2Entry); SMESH::TPythonDump pd; - pd << _this() << ".AddFacePeriodicity(" << face1Entry << ", " << face2Entry << ")"; + pd << _this() << ".AddFacePeriodicity(" << theFace1Entry << ", " << theFace2Entry << ")"; MESSAGE("IDL : AddFacePeriodicityEntry END"); } -void BLSURFPlugin_Hypothesis_i::AddEdgePeriodicity(GEOM::GEOM_Object_ptr face1, GEOM::GEOM_Object_ptr edge1, - GEOM::GEOM_Object_ptr face2, GEOM::GEOM_Object_ptr edge2, int edge_orientation) +void BLSURFPlugin_Hypothesis_i::AddEdgePeriodicity(GEOM::GEOM_Object_ptr theFace1, GEOM::GEOM_Object_ptr theEdge1, + GEOM::GEOM_Object_ptr theFace2, GEOM::GEOM_Object_ptr theEdge2, int edge_orientation) throw (SALOME::SALOME_Exception){ ASSERT(myBaseImpl); - string prefix_face1 = "Source_face_"; - CheckShapeType(face1, GEOM::FACE); - string face1Entry = PublishIfNeeded(face1, GEOM::FACE, prefix_face1); - string prefix_face2 = "Target_face_"; - CheckShapeType(face2, GEOM::FACE); - string face2Entry = PublishIfNeeded(face2, GEOM::FACE, prefix_face2); - - string prefix_edge1 = "Source_edge_"; - CheckShapeType(edge1, GEOM::EDGE); - string edge1Entry = PublishIfNeeded(edge1, GEOM::EDGE, prefix_edge1); - string prefix_edge2 = "Target_edge_"; - CheckShapeType(edge2, GEOM::EDGE); - string edge2Entry = PublishIfNeeded(edge2, GEOM::EDGE, prefix_edge2); - - MESSAGE("IDL : face1->GetName : " << face1->GetName()); - MESSAGE("IDL : edge1->GetName : " << edge1->GetName()); - MESSAGE("IDL : face2->GetName : " << face2->GetName()); - MESSAGE("IDL : edge2->GetName : " << edge2->GetName()); - MESSAGE("IDL : AddEdgePeriodicity( "<< face1Entry << ", " << edge1Entry << ", " << face2Entry << ", " << edge2Entry << ", " << edge_orientation << ")"); + string prefix_theFace1 = "Source_face_"; + CheckShapeType(theFace1, GEOM::FACE); + string theFace1Entry = PublishIfNeeded(theFace1, GEOM::FACE, prefix_theFace1); + string prefix_theFace2 = "Target_face_"; + CheckShapeType(theFace2, GEOM::FACE); + string theFace2Entry = PublishIfNeeded(theFace2, GEOM::FACE, prefix_theFace2); + + string prefix_theEdge1 = "Source_edge_"; + CheckShapeType(theEdge1, GEOM::EDGE); + string theEdge1Entry = PublishIfNeeded(theEdge1, GEOM::EDGE, prefix_theEdge1); + string prefix_theEdge2 = "Target_edge_"; + CheckShapeType(theEdge2, GEOM::EDGE); + string theEdge2Entry = PublishIfNeeded(theEdge2, GEOM::EDGE, prefix_theEdge2); + + MESSAGE("IDL : theFace1->GetName : " << theFace1->GetName()); + MESSAGE("IDL : theEdge1->GetName : " << theEdge1->GetName()); + MESSAGE("IDL : theFace2->GetName : " << theFace2->GetName()); + MESSAGE("IDL : theEdge2->GetName : " << theEdge2->GetName()); + MESSAGE("IDL : AddEdgePeriodicity( "<< theFace1Entry << ", " << theEdge1Entry << ", " << theFace2Entry << ", " << theEdge2Entry << ", " << edge_orientation << ")"); try { - AddEdgePeriodicityEntry(face1Entry.c_str(), edge1Entry.c_str(), face2Entry.c_str(), edge2Entry.c_str(), edge_orientation); + AddEdgePeriodicityEntry(theFace1Entry.c_str(), theEdge1Entry.c_str(), theFace2Entry.c_str(), theEdge2Entry.c_str(), edge_orientation); } catch (SALOME_Exception& ex) { THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM ); } @@ -2819,26 +2937,26 @@ void BLSURFPlugin_Hypothesis_i::AddEdgePeriodicity(GEOM::GEOM_Object_ptr face1, } -void BLSURFPlugin_Hypothesis_i::AddEdgePeriodicityWithoutFaces(GEOM::GEOM_Object_ptr edge1, - GEOM::GEOM_Object_ptr edge2, int edge_orientation) +void BLSURFPlugin_Hypothesis_i::AddEdgePeriodicityWithoutFaces(GEOM::GEOM_Object_ptr theEdge1, + GEOM::GEOM_Object_ptr theEdge2, int edge_orientation) throw (SALOME::SALOME_Exception){ ASSERT(myBaseImpl); - string face1Entry = ""; - string face2Entry = ""; + string theFace1Entry = ""; + string theFace2Entry = ""; - string prefix_edge1 = "Source_edge_"; - CheckShapeType(edge1, GEOM::EDGE); - string edge1Entry = PublishIfNeeded(edge1, GEOM::EDGE, prefix_edge1); - string prefix_edge2 = "Target_edge_"; - CheckShapeType(edge2, GEOM::EDGE); - string edge2Entry = PublishIfNeeded(edge2, GEOM::EDGE, prefix_edge2); + string prefix_theEdge1 = "Source_edge_"; + CheckShapeType(theEdge1, GEOM::EDGE); + string theEdge1Entry = PublishIfNeeded(theEdge1, GEOM::EDGE, prefix_theEdge1); + string prefix_theEdge2 = "Target_edge_"; + CheckShapeType(theEdge2, GEOM::EDGE); + string theEdge2Entry = PublishIfNeeded(theEdge2, GEOM::EDGE, prefix_theEdge2); - MESSAGE("IDL : edge1->GetName : " << edge1->GetName()); - MESSAGE("IDL : edge2->GetName : " << edge2->GetName()); - MESSAGE("IDL : AddEdgePeriodicity( "<< face1Entry << ", " << edge1Entry << ", " << face2Entry << ", " << edge2Entry << ", " << edge_orientation << ")"); + MESSAGE("IDL : theEdge1->GetName : " << theEdge1->GetName()); + MESSAGE("IDL : theEdge2->GetName : " << theEdge2->GetName()); + MESSAGE("IDL : AddEdgePeriodicity( "<< theFace1Entry << ", " << theEdge1Entry << ", " << theFace2Entry << ", " << theEdge2Entry << ", " << edge_orientation << ")"); try { - AddEdgePeriodicityEntry(face1Entry.c_str(), edge1Entry.c_str(), face2Entry.c_str(), edge2Entry.c_str(), edge_orientation); + AddEdgePeriodicityEntry(theFace1Entry.c_str(), theEdge1Entry.c_str(), theFace2Entry.c_str(), theEdge2Entry.c_str(), edge_orientation); } catch (SALOME_Exception& ex) { THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM ); } @@ -2846,47 +2964,47 @@ void BLSURFPlugin_Hypothesis_i::AddEdgePeriodicityWithoutFaces(GEOM::GEOM_Object } -void BLSURFPlugin_Hypothesis_i::AddEdgePeriodicityEntry(const char* face1Entry, const char* edge1Entry, const char* face2Entry, const char* edge2Entry, const int edge_orientation) +void BLSURFPlugin_Hypothesis_i::AddEdgePeriodicityEntry(const char* theFace1Entry, const char* theEdge1Entry, const char* theFace2Entry, const char* theEdge2Entry, const int edge_orientation) throw (SALOME::SALOME_Exception){ ASSERT(myBaseImpl); - MESSAGE("IDL : AddEdgePeriodicityEntry(" << face1Entry << ", " << edge1Entry << ", " << face2Entry << ", " << edge2Entry << ", " << edge_orientation << ")"); - this->GetImpl()->AddEdgePeriodicity(face1Entry, edge1Entry, face2Entry, edge2Entry, edge_orientation); + MESSAGE("IDL : AddEdgePeriodicityEntry(" << theFace1Entry << ", " << theEdge1Entry << ", " << theFace2Entry << ", " << theEdge2Entry << ", " << edge_orientation << ")"); + this->GetImpl()->AddEdgePeriodicity(theFace1Entry, theEdge1Entry, theFace2Entry, theEdge2Entry, edge_orientation); SMESH::TPythonDump pd; - if (face1Entry) - pd << _this() << ".AddEdgePeriodicity(" << face1Entry << ", " << edge1Entry << ", " << face2Entry << ", " << edge2Entry << ", " << edge_orientation <<")"; + if (theFace1Entry) + pd << _this() << ".AddEdgePeriodicity(" << theFace1Entry << ", " << theEdge1Entry << ", " << theFace2Entry << ", " << theEdge2Entry << ", " << edge_orientation <<")"; else - pd << _this() << ".AddEdgePeriodicityWithoutFaces(" << edge1Entry << ", " << edge2Entry << ", " << edge_orientation <<")"; + pd << _this() << ".AddEdgePeriodicityWithoutFaces(" << theEdge1Entry << ", " << theEdge2Entry << ", " << edge_orientation <<")"; MESSAGE("IDL : AddEdgePeriodicityEntry END"); } -void BLSURFPlugin_Hypothesis_i::AddVertexPeriodicity(GEOM::GEOM_Object_ptr edge1, GEOM::GEOM_Object_ptr vertex1, - GEOM::GEOM_Object_ptr edge2, GEOM::GEOM_Object_ptr vertex2) +void BLSURFPlugin_Hypothesis_i::AddVertexPeriodicity(GEOM::GEOM_Object_ptr theEdge1, GEOM::GEOM_Object_ptr theVertex1, + GEOM::GEOM_Object_ptr theEdge2, GEOM::GEOM_Object_ptr theVertex2) throw (SALOME::SALOME_Exception){ ASSERT(myBaseImpl); - string prefix_edge1 = "Source_edge_"; - CheckShapeType(edge1, GEOM::EDGE); - string edge1Entry = PublishIfNeeded(edge1, GEOM::EDGE, prefix_edge1); - string prefix_edge2 = "Target_edge_"; - CheckShapeType(edge2, GEOM::EDGE); - string edge2Entry = PublishIfNeeded(edge2, GEOM::EDGE, prefix_edge2); - - string prefix_vertex1 = "Source_vertex_"; - CheckShapeType(vertex1, GEOM::VERTEX); - string vertex1Entry = PublishIfNeeded(vertex1, GEOM::VERTEX, prefix_vertex1); - string prefix_vertex2 = "Target_vertex_"; - CheckShapeType(vertex2, GEOM::VERTEX); - string vertex2Entry = PublishIfNeeded(vertex2, GEOM::VERTEX, prefix_vertex2); - - MESSAGE("IDL : edge1->GetName : " << edge1->GetName()); - MESSAGE("IDL : vertex1->GetName : " << vertex1->GetName()); - MESSAGE("IDL : edge2->GetName : " << edge2->GetName()); - MESSAGE("IDL : vertex2->GetName : " << vertex2->GetName()); - MESSAGE("IDL : AddVertexPeriodicity( "<< edge1Entry << ", " << vertex1Entry << ", " << edge2Entry << ", " << vertex2Entry << ")"); + string prefix_theEdge1 = "Source_edge_"; + CheckShapeType(theEdge1, GEOM::EDGE); + string theEdge1Entry = PublishIfNeeded(theEdge1, GEOM::EDGE, prefix_theEdge1); + string prefix_theEdge2 = "Target_edge_"; + CheckShapeType(theEdge2, GEOM::EDGE); + string theEdge2Entry = PublishIfNeeded(theEdge2, GEOM::EDGE, prefix_theEdge2); + + string prefix_theVertex1 = "Source_vertex_"; + CheckShapeType(theVertex1, GEOM::VERTEX); + string theVertex1Entry = PublishIfNeeded(theVertex1, GEOM::VERTEX, prefix_theVertex1); + string prefix_theVertex2 = "Target_vertex_"; + CheckShapeType(theVertex2, GEOM::VERTEX); + string theVertex2Entry = PublishIfNeeded(theVertex2, GEOM::VERTEX, prefix_theVertex2); + + MESSAGE("IDL : theEdge1->GetName : " << theEdge1->GetName()); + MESSAGE("IDL : theVertex1->GetName : " << theVertex1->GetName()); + MESSAGE("IDL : theEdge2->GetName : " << theEdge2->GetName()); + MESSAGE("IDL : theVertex2->GetName : " << theVertex2->GetName()); + MESSAGE("IDL : AddVertexPeriodicity( "<< theEdge1Entry << ", " << theVertex1Entry << ", " << theEdge2Entry << ", " << theVertex2Entry << ")"); try { - AddVertexPeriodicityEntry(edge1Entry.c_str(), vertex1Entry.c_str(), edge2Entry.c_str(), vertex2Entry.c_str()); + AddVertexPeriodicityEntry(theEdge1Entry.c_str(), theVertex1Entry.c_str(), theEdge2Entry.c_str(), theVertex2Entry.c_str()); } catch (SALOME_Exception& ex) { THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM ); } @@ -2894,15 +3012,15 @@ void BLSURFPlugin_Hypothesis_i::AddVertexPeriodicity(GEOM::GEOM_Object_ptr edge1 } -void BLSURFPlugin_Hypothesis_i::AddVertexPeriodicityEntry(const char* edge1Entry, const char* vertex1Entry, const char* edge2Entry, const char* vertex2Entry) +void BLSURFPlugin_Hypothesis_i::AddVertexPeriodicityEntry(const char* theEdge1Entry, const char* theVertex1Entry, const char* theEdge2Entry, const char* theVertex2Entry) throw (SALOME::SALOME_Exception){ ASSERT(myBaseImpl); - MESSAGE("IDL : AddVertexPeriodicityEntry(" << edge1Entry << ", " << vertex1Entry << ", " << edge2Entry << ", " << vertex2Entry << ")"); - this->GetImpl()->AddVertexPeriodicity(edge1Entry, vertex1Entry, edge2Entry, vertex2Entry); + MESSAGE("IDL : AddVertexPeriodicityEntry(" << theEdge1Entry << ", " << theVertex1Entry << ", " << theEdge2Entry << ", " << theVertex2Entry << ")"); + this->GetImpl()->AddVertexPeriodicity(theEdge1Entry, theVertex1Entry, theEdge2Entry, theVertex2Entry); SMESH::TPythonDump pd; - pd << _this() << ".AddVertexPeriodicity(" << edge1Entry << ", " << vertex1Entry << ", " << edge2Entry << ", " << vertex2Entry << ")"; + pd << _this() << ".AddVertexPeriodicity(" << theEdge1Entry << ", " << theVertex1Entry << ", " << theEdge2Entry << ", " << theVertex2Entry << ")"; MESSAGE("IDL : AddVertexPeriodicityEntry END"); } diff --git a/src/BLSURFPlugin/BLSURFPlugin_Hypothesis_i.hxx b/src/BLSURFPlugin/BLSURFPlugin_Hypothesis_i.hxx index fe46de2..c34d82a 100644 --- a/src/BLSURFPlugin/BLSURFPlugin_Hypothesis_i.hxx +++ b/src/BLSURFPlugin/BLSURFPlugin_Hypothesis_i.hxx @@ -258,44 +258,49 @@ public: // PERIODICITY // /////////////////////// - std::string ShapeTypeToString(GEOM::shape_type theShapeType); - void CheckShapeType(GEOM::GEOM_Object_ptr shape, GEOM::shape_type theShapeType); - void CheckShapeTypes(GEOM::GEOM_Object_ptr shape, std::vector theShapeTypes); - std::string PublishIfNeeded(GEOM::GEOM_Object_ptr shape, GEOM::shape_type theShapeType, std::string prefix); + void AddPreCadFacesPeriodicity(GEOM::GEOM_Object_ptr theFace1, GEOM::GEOM_Object_ptr theFace2) + throw (SALOME::SALOME_Exception); + + void AddPreCadFacesPeriodicityWithVertices(GEOM::GEOM_Object_ptr theFace1, GEOM::GEOM_Object_ptr theFace2, + const GEOM::ListOfGO& theSourceVertices, const GEOM::ListOfGO& theTargetVertices) + throw (SALOME::SALOME_Exception); - void AddPreCadFacesPeriodicity(GEOM::GEOM_Object_ptr faces1, GEOM::GEOM_Object_ptr faces2, const char* f_transf = "") + void AddPreCadFacesPeriodicityEntry(const char* theFace1Entry, const char* theFace2Entry, + vector &theSourceVerticesEntries, vector &theTargetVerticesEntries) throw (SALOME::SALOME_Exception); - void AddPreCadFacesPeriodicityEntry(const char* faces1Entry, const char* faces2Entry, const char* f_transf = "") + void AddPreCadEdgesPeriodicity(GEOM::GEOM_Object_ptr theEdge1, GEOM::GEOM_Object_ptr theEdge2) throw (SALOME::SALOME_Exception); - void AddPreCadEdgesPeriodicity(GEOM::GEOM_Object_ptr edges1, GEOM::GEOM_Object_ptr edges2, const char* f_transf = "") + void AddPreCadEdgesPeriodicityWithVertices(GEOM::GEOM_Object_ptr theEdge1, GEOM::GEOM_Object_ptr theEdge2, + const GEOM::ListOfGO& theSourceVertices, const GEOM::ListOfGO& theTargetVertices) throw (SALOME::SALOME_Exception); - void AddPreCadEdgesPeriodicityEntry(const char* edges1Entry, const char* edges2Entry, const char* f_transf = "") + void AddPreCadEdgesPeriodicityEntry(const char* theEdge1Entry, const char* theEdge2Entry, + vector &theSourceVerticesEntries, vector &theTargetVerticesEntries) throw (SALOME::SALOME_Exception); - void AddFacePeriodicity(GEOM::GEOM_Object_ptr face1, GEOM::GEOM_Object_ptr face2) + void AddFacePeriodicity(GEOM::GEOM_Object_ptr theFace1, GEOM::GEOM_Object_ptr theFace2) throw (SALOME::SALOME_Exception); - void AddFacePeriodicityEntry(const char* face1Entry, const char* face2Entry) + void AddFacePeriodicityEntry(const char* theFace1Entry, const char* theFace2Entry) throw (SALOME::SALOME_Exception); - void AddEdgePeriodicity(GEOM::GEOM_Object_ptr face1, GEOM::GEOM_Object_ptr edge1, - GEOM::GEOM_Object_ptr face2, GEOM::GEOM_Object_ptr edge2, int edge_orientation = 0) + void AddEdgePeriodicity(GEOM::GEOM_Object_ptr theFace1, GEOM::GEOM_Object_ptr theEdge1, + GEOM::GEOM_Object_ptr theFace2, GEOM::GEOM_Object_ptr theEdge2, int edge_orientation = 0) throw (SALOME::SALOME_Exception); - void AddEdgePeriodicityWithoutFaces(GEOM::GEOM_Object_ptr edge1, GEOM::GEOM_Object_ptr edge2, int edge_orientation = 0) + void AddEdgePeriodicityWithoutFaces(GEOM::GEOM_Object_ptr theEdge1, GEOM::GEOM_Object_ptr theEdge2, int edge_orientation = 0) throw (SALOME::SALOME_Exception); - void AddEdgePeriodicityEntry(const char* face1Entry, const char* edge1Entry, const char* face2Entry, const char* edge2Entry, int edge_orientation = 0) + void AddEdgePeriodicityEntry(const char* theFace1Entry, const char* theEdge1Entry, const char* theFace2Entry, const char* theEdge2Entry, int edge_orientation = 0) throw (SALOME::SALOME_Exception); - void AddVertexPeriodicity(GEOM::GEOM_Object_ptr edge1, GEOM::GEOM_Object_ptr vertex1, - GEOM::GEOM_Object_ptr edge2, GEOM::GEOM_Object_ptr vertex2) + void AddVertexPeriodicity(GEOM::GEOM_Object_ptr theEdge1, GEOM::GEOM_Object_ptr theVertex1, + GEOM::GEOM_Object_ptr theEdge2, GEOM::GEOM_Object_ptr theVertex2) throw (SALOME::SALOME_Exception); - void AddVertexPeriodicityEntry(const char* edge1Entry, const char* vertex1Entry, const char* edge2Entry, const char* vertex2Entry) + void AddVertexPeriodicityEntry(const char* theEdge1Entry, const char* theVertex1Entry, const char* theEdge2Entry, const char* theVertex2Entry) throw (SALOME::SALOME_Exception); /////////////////////// @@ -336,6 +341,17 @@ public: CORBA::Boolean GetPreCADRemoveNanoEdges(); void SetPreCADEpsNano(CORBA::Double epsNano); CORBA::Double GetPreCADEpsNano(); + +private: + /////////////////////// + // PERIODICITY // + /////////////////////// + std::string ShapeTypeToString(GEOM::shape_type theShapeType); + void CheckShapeType(GEOM::GEOM_Object_ptr shape, GEOM::shape_type theShapeType); + void CheckShapeTypes(GEOM::GEOM_Object_ptr shape, std::vector theShapeTypes); + std::string PublishIfNeeded(GEOM::GEOM_Object_ptr shape, GEOM::shape_type theShapeType, std::string prefix); + std::string FormatVerticesEntries(vector &theSourceVerticesEntries, vector &theTargetVerticesEntries); + }; #endif -- 2.39.2