Skip to content
Snippets Groups Projects
Commit 178a07a3 authored by Guillaume Demesy's avatar Guillaume Demesy
Browse files

interface to OCC GTransform - prepare OCC dilate

parent aa5d75b2
No related branches found
No related tags found
No related merge requests found
......@@ -479,6 +479,7 @@ GFace *GeoFactory::_addPlanarFace(GModel *gm, const std::vector<std::vector<GEdg
#include <BRepBuilderAPI_MakeVertex.hxx>
#include <BRepBuilderAPI_MakeWire.hxx>
#include <BRepBuilderAPI_Transform.hxx>
#include <BRepBuilderAPI_GTransform.hxx>
#include <BRepCheck_Analyzer.hxx>
#include <BRepFilletAPI_MakeFillet.hxx>
#include <BRepGProp.hxx>
......@@ -573,6 +574,7 @@ GFace *GeoFactory::_addPlanarFace(GModel *gm, const std::vector<std::vector<GEdg
#include <gp_Pnt.hxx>
#include <gp_Pnt2d.hxx>
#include <gp_Trsf.hxx>
#include <gp_GTrsf.hxx>
#include <gp_Vec.hxx>
GVertex *OCCFactory::addVertex(GModel *gm, double x, double y, double z, double lc)
......@@ -1324,6 +1326,27 @@ void OCCFactory::rotate(GModel *gm, std::vector<double> p1, std::vector<double>
gm->_occ_internals->buildGModel(gm);
}
void OCCFactory::dilate(GModel *gm, std::vector<double> s, int addToTheModel)
{
if (!gm->_occ_internals)
gm->_occ_internals = new OCC_Internals;
const double a = s[0];
const double b = s[1];
const double c = s[2];
gp_GTrsf transformation;
transformation.SetVectorialPart(gp_Mat(a, 0, 0, 0, b, 0, 0, 0, c));
BRepBuilderAPI_GTransform aTransformation(gm->_occ_internals->getShape(),
transformation, Standard_False);
TopoDS_Shape temp = aTransformation.Shape();
if (!addToTheModel) gm->_occ_internals->loadShape(&temp);
else gm->_occ_internals->buildShapeFromLists(temp);
gm->destroy();
gm->_occ_internals->buildLists();
gm->_occ_internals->buildGModel(gm);
}
std::vector<GFace *> OCCFactory::addRuledFaces(GModel *gm,
std::vector< std::vector<GEdge *> > wires)
{
......
......@@ -276,6 +276,7 @@ class OCCFactory : public GModelFactory {
void translate(GModel *gm, std::vector<double> dx, int addToTheModel);
void rotate(GModel *gm, std::vector<double> p1,std::vector<double> p2,
double angle, int addToTheModel);
void dilate(GModel *gm, std::vector<double> s, int addToTheModel);
GModel *computeBooleanUnion(GModel *obj, GModel *tool, int createNewModel);
GModel *computeBooleanIntersection(GModel *obj, GModel *tool, int createNewModel);
GModel *computeBooleanDifference(GModel *obj, GModel *tool, int createNewModel);
......
......@@ -101,7 +101,8 @@ class GEO_Internals{
double x, double y, double z, double ax, double ay, double az,
double angle);
bool dilate(const std::vector<std::pair<int, int> > &dimTags,
double x, double y, double z, double a, double b, double c);
double x, double y, double z,
double a, double b, double c);
bool symmetry(const std::vector<std::pair<int, int> > &dimTags,
double a, double b, double c, double d);
......
......@@ -32,6 +32,7 @@
#include <BRepBuilderAPI_MakeWire.hxx>
#include <BRepBuilderAPI_Sewing.hxx>
#include <BRepBuilderAPI_Transform.hxx>
#include <BRepBuilderAPI_GTransform.hxx>
#include <BRepCheck_Analyzer.hxx>
#include <BRepFilletAPI_MakeFillet.hxx>
#include <BRepGProp.hxx>
......@@ -1897,6 +1898,27 @@ bool OCC_Internals::_transform(const std::vector<std::pair<int, int> > &inDimTag
return true;
}
bool OCC_Internals::_gtransform(const std::vector<std::pair<int, int> > &inDimTags,
BRepBuilderAPI_GTransform *gtfo)
{
for(unsigned int i = 0; i < inDimTags.size(); i++){
int dim = inDimTags[i].first;
int tag = inDimTags[i].second;
if(!isBound(dim, tag)){
Msg::Error("Unknown OpenCASCADE entity of dimension %d with tag %d",
dim, tag);
return false;
}
gtfo->Perform(find(dim, tag), Standard_False);
if(!gtfo->IsDone()){
Msg::Error("Could not apply transformation");
return false;
}
bind(gtfo->Shape(), dim, tag);
}
return true;
}
bool OCC_Internals::translate(const std::vector<std::pair<int, int> > &inDimTags,
double dx, double dy, double dz)
{
......@@ -1917,6 +1939,15 @@ bool OCC_Internals::rotate(const std::vector<std::pair<int, int> > &inDimTags,
return _transform(inDimTags, &tfo);
}
bool OCC_Internals::dilate(const std::vector<std::pair<int, int> > &inDimTags,
double a, double b, double c)
{
gp_GTrsf t;
t.SetVectorialPart(gp_Mat(a, 0, 0, 0, b, 0, 0, 0, c));
BRepBuilderAPI_GTransform gtfo(t);
return _gtransform(inDimTags, &gtfo);
}
bool OCC_Internals::copy(const std::vector<std::pair<int, int> > &inDimTags,
std::vector<std::pair<int, int> > &outDimTags)
{
......
......@@ -33,6 +33,7 @@ class ExtrudeParams;
class BRepSweep_Prism;
class BRepSweep_Revol;
class BRepBuilderAPI_Transform;
class BRepBuilderAPI_GTransform;
class OCC_Internals {
public:
......@@ -81,10 +82,14 @@ class OCC_Internals {
bool fixsmalledges, bool fixspotstripfaces, bool sewfaces,
bool makesolids=false, double scaling=0.0);
// apply a geometrical transformation
// apply a geometrical transformation (does not modify Shape)
bool _transform(const std::vector<std::pair<int, int> > &inDimTags,
BRepBuilderAPI_Transform *tfo);
// apply a G geometrical transformation (modifies Shape : affinity...)
bool _gtransform(const std::vector<std::pair<int, int> > &inDimTags,
BRepBuilderAPI_GTransform *gtfo);
// add circle or ellipse arc
bool _addArc(int tag, int startTag, int centerTag, int endTag, int mode);
......@@ -220,6 +225,10 @@ class OCC_Internals {
double x, double y, double z, double ax, double ay, double az,
double angle);
// apply gtransformations
bool dilate(const std::vector<std::pair<int, int> > &inDimTags,
double a, double b, double c);
// copy and remove
bool copy(const std::vector<std::pair<int, int> > &inDimTags,
std::vector<std::pair<int, int> > &outDimTags);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment