Skip to content
Snippets Groups Projects
Commit a743e275 authored by Christophe Geuzaine's avatar Christophe Geuzaine
Browse files

OCC translate

parent 209efcf2
Branches
Tags
No related merge requests found
...@@ -654,12 +654,12 @@ void OCC_Internals::getBoundary(std::vector<int> inTags[4], ...@@ -654,12 +654,12 @@ void OCC_Internals::getBoundary(std::vector<int> inTags[4],
bool combined) bool combined)
{ {
for(unsigned int i = 0; i < inTags[3].size(); i++){ for(unsigned int i = 0; i < inTags[3].size(); i++){
TopExp_Explorer exp0, exp1;
if(!_tagSolid.IsBound(inTags[3][i])){ if(!_tagSolid.IsBound(inTags[3][i])){
Msg::Error("Unknown OpenCASCADE region with tag %d", inTags[3][i]); Msg::Error("Unknown OpenCASCADE region with tag %d", inTags[3][i]);
return; return;
} }
TopoDS_Solid solid = TopoDS::Solid(_tagSolid.Find(inTags[3][i])); TopoDS_Solid solid = TopoDS::Solid(_tagSolid.Find(inTags[3][i]));
TopExp_Explorer exp0, exp1;
for(exp0.Init(solid, TopAbs_SHELL); exp0.More(); exp0.Next()){ for(exp0.Init(solid, TopAbs_SHELL); exp0.More(); exp0.Next()){
TopoDS_Shell shell = TopoDS::Shell(exp0.Current()); TopoDS_Shell shell = TopoDS::Shell(exp0.Current());
for(exp1.Init(shell, TopAbs_FACE); exp1.More(); exp1.Next()){ for(exp1.Init(shell, TopAbs_FACE); exp1.More(); exp1.Next()){
...@@ -687,17 +687,38 @@ void OCC_Internals::getBoundary(std::vector<int> inTags[4], ...@@ -687,17 +687,38 @@ void OCC_Internals::getBoundary(std::vector<int> inTags[4],
} }
} }
/* void OCC_Internals::translate(std::vector<int> inTags[4],
void OCC_Internals::translate(std::std::vector<double> dx, int addToTheModel) double dx, double dy, double dz)
{
gp_Trsf t;
t.SetTranslation(gp_Pnt(0, 0, 0), gp_Pnt(dx, dy, dz));
BRepBuilderAPI_Transform tfo(t);
for(unsigned int i = 0; i < inTags[3].size(); i++){
if(!_tagSolid.IsBound(inTags[3][i])){
Msg::Error("Unknown OpenCASCADE region with tag %d", inTags[3][i]);
return;
}
TopoDS_Solid solid = TopoDS::Solid(_tagSolid.Find(inTags[3][i]));
tfo.Perform(solid, Standard_False);
if(!tfo.IsDone()){
Msg::Error("Could not apply translation");
return;
}
TopoDS_Solid result = TopoDS::Solid(tfo.Shape());
bind(result, inTags[3][i]);
}
if(inTags[2].size() || inTags[1].size() || inTags[0].size()){
Msg::Error("OCC TODO translation of surfaces, curves and vertices");
}
}
void OCC_Internals::copy(std::vector<int> inTags[4], std::vector<int> outTags[4])
{ {
gp_Trsf transformation;
transformation.SetTranslation(gp_Pnt(0,0,0), gp_Pnt(dx[0],dx[1],dx[2]));
BRepBuilderAPI_Transform aTransformation(gm->_occ_internals->getShape(),
transformation, Standard_False);
TopoDS_Shape temp = aTransformation.Shape();
} }
*/
void OCC_Internals::importShapes(const std::string &fileName, void OCC_Internals::importShapes(const std::string &fileName,
std::vector<int> outTags[4]) std::vector<int> outTags[4])
......
...@@ -71,6 +71,10 @@ class OCC_Internals { ...@@ -71,6 +71,10 @@ class OCC_Internals {
{ {
std::vector<int> tags[4]; importShapes(s, tags); std::vector<int> tags[4]; importShapes(s, tags);
} }
GVertex *addVertexToModel(GModel *model, TopoDS_Vertex v);
GEdge *addEdgeToModel(GModel *model, TopoDS_Edge e);
GFace *addFaceToModel(GModel *model, TopoDS_Face f);
GRegion *addRegionToModel(GModel *model, TopoDS_Solid r);
// *** FIXME end of stuff that will be removed *** // *** FIXME end of stuff that will be removed ***
public: public:
...@@ -125,6 +129,10 @@ class OCC_Internals { ...@@ -125,6 +129,10 @@ class OCC_Internals {
void getBoundary(std::vector<int> inTags[4], std::vector<int> outTags[4], void getBoundary(std::vector<int> inTags[4], std::vector<int> outTags[4],
bool combined=false); bool combined=false);
// apply transformations
void translate(std::vector<int> inTags[4], double dx, double dy, double dz);
void copy(std::vector<int> inTags[4], std::vector<int> outTags[4]);
// import shapes from file // import shapes from file
void importShapes(const std::string &fileName, std::vector<int> outTags[4]); void importShapes(const std::string &fileName, std::vector<int> outTags[4]);
...@@ -134,17 +142,14 @@ class OCC_Internals { ...@@ -134,17 +142,14 @@ class OCC_Internals {
// export all tagged shapes to file // export all tagged shapes to file
void exportShapes(const std::string &fileName); void exportShapes(const std::string &fileName);
// synchronize all shapes in maps with the given GModel // synchronize internal CAD data with the given GModel
void synchronize(GModel *model); void synchronize(GModel *model);
// get the GEntity corresponding to an OCC shape
GVertex *getOCCVertexByNativePtr(GModel *model, TopoDS_Vertex toFind); GVertex *getOCCVertexByNativePtr(GModel *model, TopoDS_Vertex toFind);
GEdge *getOCCEdgeByNativePtr(GModel *model, TopoDS_Edge toFind); GEdge *getOCCEdgeByNativePtr(GModel *model, TopoDS_Edge toFind);
GFace *getOCCFaceByNativePtr(GModel *model, TopoDS_Face toFind); GFace *getOCCFaceByNativePtr(GModel *model, TopoDS_Face toFind);
GRegion *getOCCRegionByNativePtr(GModel *model, TopoDS_Solid toFind); GRegion *getOCCRegionByNativePtr(GModel *model, TopoDS_Solid toFind);
GVertex *addVertexToModel(GModel *model, TopoDS_Vertex v);
GEdge *addEdgeToModel(GModel *model, TopoDS_Edge e);
GFace *addFaceToModel(GModel *model, TopoDS_Face f);
GRegion *addRegionToModel(GModel *model, TopoDS_Solid r);
}; };
#else #else
...@@ -174,6 +179,8 @@ public: ...@@ -174,6 +179,8 @@ public:
bool removeTool=true){} bool removeTool=true){}
void getBoundary(std::vector<int> inTags[4], std::vector<int> outTags[4], void getBoundary(std::vector<int> inTags[4], std::vector<int> outTags[4],
bool combined=false){} bool combined=false){}
void translate(std::vector<int> inTags[4], double dx, double dy, double dz){}
void copy(std::vector<int> inTags[4], std::vector<int> outTags[4]){}
void importShapes(const std::string &fileName, std::vector<int> outTags[4]){} void importShapes(const std::string &fileName, std::vector<int> outTags[4]){}
void exportShapes(const std::string &fileName){} void exportShapes(const std::string &fileName){}
void synchronize(GModel *model){} void synchronize(GModel *model){}
......
This diff is collapsed.
...@@ -2554,7 +2554,14 @@ Transform : ...@@ -2554,7 +2554,14 @@ Transform :
tTranslate VExpr '{' MultipleShape '}' tTranslate VExpr '{' MultipleShape '}'
{ {
if(factory == "OpenCASCADE" && GModel::current()->getOCCInternals()){ if(factory == "OpenCASCADE" && GModel::current()->getOCCInternals()){
Msg::Error("TODO OCC Translate"); std::vector<int> in[4];
Shape TheShape;
for(int i = 0; i < List_Nbr($4); i++){
List_Read($4, i, &TheShape);
int dim = TheShape.Type / 100 - 1;
if(dim >= 0 && dim <= 3) in[dim].push_back(TheShape.Num);
}
GModel::current()->getOCCInternals()->translate(in, $2[0], $2[1], $2[2]);
} }
else{ else{
TranslateShapes($2[0], $2[1], $2[2], $4); TranslateShapes($2[0], $2[1], $2[2], $4);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment