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

cleanup

parent b3f144d1
No related branches found
No related tags found
No related merge requests found
...@@ -82,7 +82,7 @@ geometryContextWindow::geometryContextWindow(int deltaFontSize) ...@@ -82,7 +82,7 @@ geometryContextWindow::geometryContextWindow(int deltaFontSize)
input[3]->value("0"); input[3]->value("0");
input[4] = new Fl_Input(2 * WB, 2 * WB + 3 * BH, IW, BH, "Z coordinate"); input[4] = new Fl_Input(2 * WB, 2 * WB + 3 * BH, IW, BH, "Z coordinate");
input[4]->value("0"); input[4]->value("0");
input[5] = new Fl_Input(2 * WB, 2 * WB + 4 * BH, IW, BH, "Prescribed element size at point"); input[5] = new Fl_Input(2 * WB, 2 * WB + 4 * BH, IW, BH, "Prescribed mesh element size at point");
input[5]->value("1.0"); input[5]->value("1.0");
for(int i = 2; i < 6; i++) { for(int i = 2; i < 6; i++) {
input[i]->align(FL_ALIGN_RIGHT); input[i]->align(FL_ALIGN_RIGHT);
......
...@@ -352,13 +352,13 @@ class GModel ...@@ -352,13 +352,13 @@ class GModel
// mesh the model // mesh the model
int mesh(int dimension); int mesh(int dimension);
// glue entities in the model // glue entities in the model (assume a tolerance eps and merge
// assume a tolerance eps and merge vertices that are too close, // vertices that are too close, then merge edges, faces and
// then merge edges, faces and regions. // regions). Warning: the gluer changes the geometric model, so that
// the gluer changes the geometric model, so that some pointers // some pointers could become invalid. FIXME: using references to
// could become invalid !! I think that using references to some // some tables of pointers for bindings e.g. could be better.
// tables of pointers for bindings e.g. could be better. FIXME !!
void glue(double eps); void glue(double eps);
// change the entity creation factory // change the entity creation factory
void setFactory(std::string name); void setFactory(std::string name);
...@@ -373,7 +373,8 @@ class GModel ...@@ -373,7 +373,8 @@ class GModel
std::vector<double> knots, std::vector<double> knots,
std::vector<double> weights, std::vector<double> weights,
std::vector<int> mult); std::vector<int> mult);
GEntity *revolve(GEntity *e, std::vector<double> p1, std::vector<double> p2, double angle); GEntity *revolve(GEntity *e, std::vector<double> p1, std::vector<double> p2,
double angle);
GEntity *extrude(GEntity *e, std::vector<double> p1, std::vector<double> p2); GEntity *extrude(GEntity *e, std::vector<double> p1, std::vector<double> p2);
// create solid geometry primitives using the factory // create solid geometry primitives using the factory
...@@ -390,13 +391,6 @@ class GModel ...@@ -390,13 +391,6 @@ class GModel
GModel *computeBooleanIntersection(GModel *tool, int createNewModel); GModel *computeBooleanIntersection(GModel *tool, int createNewModel);
GModel *computeBooleanDifference(GModel *tool, int createNewModel); GModel *computeBooleanDifference(GModel *tool, int createNewModel);
// glue entities in the model (i.e., assume a tolerance eps and
// merge vertices that are too close, then merge edges, faces and
// regions). Warning: the gluer changes the geometric model, so that
// some pointers could become invalid! I think that using references
// to some tables of pointers for bindings e.g. could be better
void glue(const double &eps);
// build a new GModel by cutting the elements crossed by the levelset ls // build a new GModel by cutting the elements crossed by the levelset ls
// if cutElem is set to false, split the model without cutting the elements // if cutElem is set to false, split the model without cutting the elements
GModel *buildCutGModel(gLevelset *ls, bool cutElem = true); GModel *buildCutGModel(gLevelset *ls, bool cutElem = true);
......
...@@ -65,9 +65,9 @@ GEdge *OCCFactory::addLine(GModel *gm, GVertex *start, GVertex *end) ...@@ -65,9 +65,9 @@ GEdge *OCCFactory::addLine(GModel *gm, GVertex *start, GVertex *end)
} }
GEdge *OCCFactory::addCircleArc(GModel *gm, const arcCreationMethod &method, GEdge *OCCFactory::addCircleArc(GModel *gm, const arcCreationMethod &method,
GVertex *start, GVertex *start, GVertex *end,
GVertex *end, const SPoint3 &aPoint)
const SPoint3 &aPoint) { {
if (!gm->_occ_internals) if (!gm->_occ_internals)
gm->_occ_internals = new OCC_Internals; gm->_occ_internals = new OCC_Internals;
...@@ -82,7 +82,8 @@ GEdge *OCCFactory::addCircleArc (GModel *gm, const arcCreationMethod &method, ...@@ -82,7 +82,8 @@ GEdge *OCCFactory::addCircleArc (GModel *gm, const arcCreationMethod &method,
if (method == GModelFactory::THREE_POINTS){ if (method == GModelFactory::THREE_POINTS){
GC_MakeArcOfCircle arc(aP1, aP2, aP3); GC_MakeArcOfCircle arc(aP1, aP2, aP3);
if (occv1 && occv2) if (occv1 && occv2)
occEdge = BRepBuilderAPI_MakeEdge(arc,occv1->getShape(),occv2->getShape()).Edge(); occEdge = BRepBuilderAPI_MakeEdge(arc,occv1->getShape(),
occv2->getShape()).Edge();
else else
occEdge = BRepBuilderAPI_MakeEdge(arc).Edge(); occEdge = BRepBuilderAPI_MakeEdge(arc).Edge();
} }
...@@ -95,7 +96,8 @@ GEdge *OCCFactory::addCircleArc (GModel *gm, const arcCreationMethod &method, ...@@ -95,7 +96,8 @@ GEdge *OCCFactory::addCircleArc (GModel *gm, const arcCreationMethod &method,
Handle(Geom_Circle) C = new Geom_Circle(Circ); Handle(Geom_Circle) C = new Geom_Circle(Circ);
Handle(Geom_TrimmedCurve) arc = new Geom_TrimmedCurve(C, Alpha1, Alpha2, false); Handle(Geom_TrimmedCurve) arc = new Geom_TrimmedCurve(C, Alpha1, Alpha2, false);
if (occv1 && occv2) if (occv1 && occv2)
occEdge = BRepBuilderAPI_MakeEdge(arc,occv1->getShape(),occv2->getShape()).Edge(); occEdge = BRepBuilderAPI_MakeEdge(arc, occv1->getShape(),
occv2->getShape()).Edge();
else else
occEdge = BRepBuilderAPI_MakeEdge(arc).Edge(); occEdge = BRepBuilderAPI_MakeEdge(arc).Edge();
} }
...@@ -135,30 +137,26 @@ GEdge *OCCFactory::addSpline(GModel *gm, const splineType &type, ...@@ -135,30 +137,26 @@ GEdge *OCCFactory::addSpline(GModel *gm, const splineType &type,
} }
GEdge *OCCFactory::addNURBS(GModel *gm, GEdge *OCCFactory::addNURBS(GModel *gm, GVertex *start, GVertex *end,
GVertex *start, GVertex *end,
std::vector<std::vector<double> > points, std::vector<std::vector<double> > points,
std::vector<double> knots, std::vector<double> knots,
std::vector<double> weights, std::vector<double> weights,
std::vector<int> mult){ std::vector<int> mult)
{
try{ try{
if (!gm->_occ_internals) if (!gm->_occ_internals)
gm->_occ_internals = new OCC_Internals; gm->_occ_internals = new OCC_Internals;
OCCVertex *occv1 = dynamic_cast<OCCVertex*>(start); OCCVertex *occv1 = dynamic_cast<OCCVertex*>(start);
OCCVertex *occv2 = dynamic_cast<OCCVertex*>(end); OCCVertex *occv2 = dynamic_cast<OCCVertex*>(end);
int nbControlPoints = points.size() + 2; int nbControlPoints = points.size() + 2;
TColgp_Array1OfPnt ctrlPoints(1, nbControlPoints); TColgp_Array1OfPnt ctrlPoints(1, nbControlPoints);
TColStd_Array1OfReal _knots(1, knots.size()); TColStd_Array1OfReal _knots(1, knots.size());
TColStd_Array1OfReal _weights(1, weights.size()); TColStd_Array1OfReal _weights(1, weights.size());
TColStd_Array1OfInteger _mult(1, mult.size()); TColStd_Array1OfInteger _mult(1, mult.size());
for (int i = 0; i < knots.size(); i++) { for (int i = 0; i < knots.size(); i++) {
_knots.SetValue(i+1, knots[i]); _knots.SetValue(i+1, knots[i]);
} }
...@@ -172,7 +170,8 @@ GEdge *OCCFactory::addNURBS(GModel *gm, ...@@ -172,7 +170,8 @@ GEdge *OCCFactory::addNURBS(GModel *gm,
} }
const int degree = totKnots - nbControlPoints - 1; const int degree = totKnots - nbControlPoints - 1;
printf("creation of a nurbs of degree %d with %d control points\n",degree,nbControlPoints); printf("creation of a nurbs of degree %d with %d control points\n",
degree,nbControlPoints);
int index = 1; int index = 1;
ctrlPoints.SetValue(index++, gp_Pnt(start->x(), start->y(), start->z())); ctrlPoints.SetValue(index++, gp_Pnt(start->x(), start->y(), start->z()));
...@@ -181,7 +180,8 @@ GEdge *OCCFactory::addNURBS(GModel *gm, ...@@ -181,7 +180,8 @@ GEdge *OCCFactory::addNURBS(GModel *gm,
ctrlPoints.SetValue(index++, aP); ctrlPoints.SetValue(index++, aP);
} }
ctrlPoints.SetValue(index++, gp_Pnt(end->x(), end->y(), end->z())); ctrlPoints.SetValue(index++, gp_Pnt(end->x(), end->y(), end->z()));
Handle(Geom_BSplineCurve) NURBS = new Geom_BSplineCurve(ctrlPoints,_weights,_knots,_mult,degree,false); Handle(Geom_BSplineCurve) NURBS = new Geom_BSplineCurve
(ctrlPoints, _weights, _knots, _mult, degree, false);
TopoDS_Edge occEdge; TopoDS_Edge occEdge;
if (occv1 && occv2) if (occv1 && occv2)
occEdge = BRepBuilderAPI_MakeEdge(NURBS,occv1->getShape(),occv2->getShape()).Edge(); occEdge = BRepBuilderAPI_MakeEdge(NURBS,occv1->getShape(),occv2->getShape()).Edge();
...@@ -197,7 +197,8 @@ GEdge *OCCFactory::addNURBS(GModel *gm, ...@@ -197,7 +197,8 @@ GEdge *OCCFactory::addNURBS(GModel *gm,
GEntity *OCCFactory::revolve(GModel *gm, GEntity* base, GEntity *OCCFactory::revolve(GModel *gm, GEntity* base,
std::vector<double> p1, std::vector<double> p1,
std::vector<double> p2, double angle){ std::vector<double> p2, double angle)
{
if (!gm->_occ_internals) if (!gm->_occ_internals)
gm->_occ_internals = new OCC_Internals; gm->_occ_internals = new OCC_Internals;
...@@ -229,7 +230,8 @@ GEntity *OCCFactory::revolve (GModel *gm, GEntity* base, ...@@ -229,7 +230,8 @@ GEntity *OCCFactory::revolve (GModel *gm, GEntity* base,
} }
GEntity *OCCFactory::extrude(GModel *gm, GEntity* base, GEntity *OCCFactory::extrude(GModel *gm, GEntity* base,
std::vector<double> p1, std::vector<double> p2){ std::vector<double> p1, std::vector<double> p2)
{
if (!gm->_occ_internals) if (!gm->_occ_internals)
gm->_occ_internals = new OCC_Internals; gm->_occ_internals = new OCC_Internals;
...@@ -396,7 +398,9 @@ GEntity *OCCFactory::addBlock(GModel *gm, std::vector<double> p1, ...@@ -396,7 +398,9 @@ GEntity *OCCFactory::addBlock(GModel *gm, std::vector<double> p1,
return getOCCRegionByNativePtr(gm,TopoDS::Solid(shape)); return getOCCRegionByNativePtr(gm,TopoDS::Solid(shape));
} }
GModel *OCCFactory::computeBooleanUnion (GModel* obj, GModel* tool, int createNewModel){ GModel *OCCFactory::computeBooleanUnion(GModel* obj, GModel* tool,
int createNewModel)
{
try{ try{
OCC_Internals *occ_obj = obj->getOCCInternals(); OCC_Internals *occ_obj = obj->getOCCInternals();
OCC_Internals *occ_tool = tool->getOCCInternals(); OCC_Internals *occ_tool = tool->getOCCInternals();
...@@ -409,7 +413,8 @@ GModel *OCCFactory::computeBooleanUnion (GModel* obj, GModel* tool, int createNe ...@@ -409,7 +413,8 @@ GModel *OCCFactory::computeBooleanUnion (GModel* obj, GModel* tool, int createNe
temp->_occ_internals->addShapeToLists(occ_obj->getShape()); temp->_occ_internals->addShapeToLists(occ_obj->getShape());
obj = temp; obj = temp;
} }
obj->_occ_internals->applyBooleanOperator(occ_tool->getShape(),OCC_Internals::Fuse); obj->_occ_internals->applyBooleanOperator(occ_tool->getShape(),
OCC_Internals::Fuse);
obj->destroy(); obj->destroy();
obj->_occ_internals->buildLists(); obj->_occ_internals->buildLists();
obj->_occ_internals->buildGModel(obj); obj->_occ_internals->buildGModel(obj);
...@@ -421,7 +426,9 @@ GModel *OCCFactory::computeBooleanUnion (GModel* obj, GModel* tool, int createNe ...@@ -421,7 +426,9 @@ GModel *OCCFactory::computeBooleanUnion (GModel* obj, GModel* tool, int createNe
return obj; return obj;
} }
GModel *OCCFactory::computeBooleanDifference (GModel* obj, GModel* tool, int createNewModel){ GModel *OCCFactory::computeBooleanDifference(GModel* obj, GModel* tool,
int createNewModel)
{
try{ try{
OCC_Internals *occ_obj = obj->getOCCInternals(); OCC_Internals *occ_obj = obj->getOCCInternals();
OCC_Internals *occ_tool = tool->getOCCInternals(); OCC_Internals *occ_tool = tool->getOCCInternals();
...@@ -434,7 +441,8 @@ GModel *OCCFactory::computeBooleanDifference (GModel* obj, GModel* tool, int cre ...@@ -434,7 +441,8 @@ GModel *OCCFactory::computeBooleanDifference (GModel* obj, GModel* tool, int cre
temp->_occ_internals->addShapeToLists(occ_obj->getShape()); temp->_occ_internals->addShapeToLists(occ_obj->getShape());
obj = temp; obj = temp;
} }
obj->getOCCInternals()->applyBooleanOperator(occ_tool->getShape(),OCC_Internals::Cut); obj->getOCCInternals()->applyBooleanOperator(occ_tool->getShape(),
OCC_Internals::Cut);
obj->destroy(); obj->destroy();
obj->_occ_internals->buildLists(); obj->_occ_internals->buildLists();
obj->_occ_internals->buildGModel(obj); obj->_occ_internals->buildGModel(obj);
...@@ -445,12 +453,13 @@ GModel *OCCFactory::computeBooleanDifference (GModel* obj, GModel* tool, int cre ...@@ -445,12 +453,13 @@ GModel *OCCFactory::computeBooleanDifference (GModel* obj, GModel* tool, int cre
return obj; return obj;
} }
GModel *OCCFactory::computeBooleanIntersection (GModel* obj, GModel* tool, int createNewModel){ GModel *OCCFactory::computeBooleanIntersection(GModel* obj, GModel* tool,
int createNewModel)
{
try{ try{
OCC_Internals *occ_obj = obj->getOCCInternals(); OCC_Internals *occ_obj = obj->getOCCInternals();
OCC_Internals *occ_tool = tool->getOCCInternals(); OCC_Internals *occ_tool = tool->getOCCInternals();
if (!occ_obj || !occ_tool)return NULL; if (!occ_obj || !occ_tool)return NULL;
if (createNewModel){ if (createNewModel){
...@@ -459,7 +468,8 @@ GModel *OCCFactory::computeBooleanIntersection (GModel* obj, GModel* tool, int c ...@@ -459,7 +468,8 @@ GModel *OCCFactory::computeBooleanIntersection (GModel* obj, GModel* tool, int c
temp->_occ_internals->addShapeToLists(occ_obj->getShape()); temp->_occ_internals->addShapeToLists(occ_obj->getShape());
obj = temp; obj = temp;
} }
obj->getOCCInternals()->applyBooleanOperator(occ_tool->getShape(),OCC_Internals::Intersection); obj->getOCCInternals()->applyBooleanOperator(occ_tool->getShape(),
OCC_Internals::Intersection);
obj->destroy(); obj->destroy();
obj->_occ_internals->buildLists(); obj->_occ_internals->buildLists();
obj->_occ_internals->buildGModel(obj); obj->_occ_internals->buildGModel(obj);
...@@ -470,7 +480,8 @@ GModel *OCCFactory::computeBooleanIntersection (GModel* obj, GModel* tool, int c ...@@ -470,7 +480,8 @@ GModel *OCCFactory::computeBooleanIntersection (GModel* obj, GModel* tool, int c
return obj; return obj;
} }
void OCCFactory::fillet (GModel *gm, std::vector<int> edges, double radius){ void OCCFactory::fillet(GModel *gm, std::vector<int> edges, double radius)
{
try{ try{
std::vector<TopoDS_Edge> edgesToFillet; std::vector<TopoDS_Edge> edgesToFillet;
for (int i=0;i<edges.size();i++){ for (int i=0;i<edges.size();i++){
...@@ -480,7 +491,7 @@ void OCCFactory::fillet (GModel *gm, std::vector<int> edges, double radius){ ...@@ -480,7 +491,7 @@ void OCCFactory::fillet (GModel *gm, std::vector<int> edges, double radius){
if (occed)edgesToFillet.push_back(occed->getTopoDS_Edge()); if (occed)edgesToFillet.push_back(occed->getTopoDS_Edge());
} }
} }
gm->_occ_internals->Fillet(edgesToFillet,radius); gm->_occ_internals->fillet(edgesToFillet,radius);
gm->destroy(); gm->destroy();
gm->_occ_internals->buildLists(); gm->_occ_internals->buildLists();
gm->_occ_internals->buildGModel(gm); gm->_occ_internals->buildGModel(gm);
...@@ -490,10 +501,12 @@ void OCCFactory::fillet (GModel *gm, std::vector<int> edges, double radius){ ...@@ -490,10 +501,12 @@ void OCCFactory::fillet (GModel *gm, std::vector<int> edges, double radius){
} }
} }
void OCCFactory::translate (GModel *gm, std::vector<double> dx, int addToTheModel){ void OCCFactory::translate(GModel *gm, std::vector<double> dx, int addToTheModel)
{
gp_Trsf transformation; gp_Trsf transformation;
transformation.SetTranslation(gp_Pnt (0,0,0),gp_Pnt (dx[0],dx[1],dx[2])); 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); BRepBuilderAPI_Transform aTransformation(gm->_occ_internals->getShape(),
transformation, Standard_False);
TopoDS_Shape temp = aTransformation.Shape(); TopoDS_Shape temp = aTransformation.Shape();
if (!addToTheModel)gm->_occ_internals->loadShape(& temp); if (!addToTheModel)gm->_occ_internals->loadShape(& temp);
else gm->_occ_internals->buildShapeFromLists(temp); else gm->_occ_internals->buildShapeFromLists(temp);
...@@ -502,7 +515,9 @@ void OCCFactory::translate (GModel *gm, std::vector<double> dx, int addToTheMode ...@@ -502,7 +515,9 @@ void OCCFactory::translate (GModel *gm, std::vector<double> dx, int addToTheMode
gm->_occ_internals->buildGModel(gm); gm->_occ_internals->buildGModel(gm);
} }
void OCCFactory::rotate (GModel *gm, std::vector<double> p1,std::vector<double> p2, double angle, int addToTheModel){ void OCCFactory::rotate(GModel *gm, std::vector<double> p1,std::vector<double> p2,
double angle, int addToTheModel)
{
const double x1 =p1[0]; const double x1 =p1[0];
const double y1 =p1[1]; const double y1 =p1[1];
const double z1 =p1[2]; const double z1 =p1[2];
...@@ -518,7 +533,8 @@ void OCCFactory::rotate (GModel *gm, std::vector<double> p1,std::vector<double> ...@@ -518,7 +533,8 @@ void OCCFactory::rotate (GModel *gm, std::vector<double> p1,std::vector<double>
gp_Vec direction (gp_Pnt (x1,y1,z1),gp_Pnt (x2,y2,z2)); gp_Vec direction (gp_Pnt (x1,y1,z1),gp_Pnt (x2,y2,z2));
gp_Ax1 axisOfRevolution (gp_Pnt (x1,y1,z1),direction); gp_Ax1 axisOfRevolution (gp_Pnt (x1,y1,z1),direction);
transformation.SetRotation(axisOfRevolution, angle); transformation.SetRotation(axisOfRevolution, angle);
BRepBuilderAPI_Transform aTransformation(gm->_occ_internals->getShape(), transformation, Standard_False); BRepBuilderAPI_Transform aTransformation(gm->_occ_internals->getShape(),
transformation, Standard_False);
TopoDS_Shape temp = aTransformation.Shape(); TopoDS_Shape temp = aTransformation.Shape();
if (!addToTheModel)gm->_occ_internals->loadShape(& temp); if (!addToTheModel)gm->_occ_internals->loadShape(& temp);
else gm->_occ_internals->buildShapeFromLists(temp); else gm->_occ_internals->buildShapeFromLists(temp);
...@@ -527,6 +543,4 @@ void OCCFactory::rotate (GModel *gm, std::vector<double> p1,std::vector<double> ...@@ -527,6 +543,4 @@ void OCCFactory::rotate (GModel *gm, std::vector<double> p1,std::vector<double>
gm->_occ_internals->buildGModel(gm); gm->_occ_internals->buildGModel(gm);
} }
#endif #endif
...@@ -21,6 +21,7 @@ class GModelFactory { ...@@ -21,6 +21,7 @@ class GModelFactory {
public: public:
GModelFactory (){} GModelFactory (){}
virtual ~GModelFactory(){} virtual ~GModelFactory(){}
// brep primitives // brep primitives
enum arcCreationMethod {THREE_POINTS=1, CENTER_START_END=2}; enum arcCreationMethod {THREE_POINTS=1, CENTER_START_END=2};
enum splineType {BEZIER=1, BSPLINE=2}; enum splineType {BEZIER=1, BSPLINE=2};
...@@ -64,12 +65,15 @@ class GModelFactory { ...@@ -64,12 +65,15 @@ class GModelFactory {
// rigid body motions // rigid body motions
virtual void translate(GModel *gm, std::vector<double> dx, int addToTheModel) = 0; virtual void translate(GModel *gm, std::vector<double> dx, int addToTheModel) = 0;
virtual void rotate (GModel *gm, std::vector<double> p1,std::vector<double> p2, double angle, int addToTheModel) = 0; virtual void rotate(GModel *gm, std::vector<double> p1,std::vector<double> p2,
double angle, int addToTheModel) = 0;
// boolean operators acting on 2 GEntities // boolean operators acting on 2 GModels
virtual GModel *computeBooleanUnion(GModel *obj, GModel*tool, int createNewModel) = 0; virtual GModel *computeBooleanUnion(GModel *obj, GModel*tool, int createNewModel) = 0;
virtual GModel * computeBooleanIntersection (GModel *obj, GModel*tool, int createNewModel) = 0; virtual GModel *computeBooleanIntersection(GModel *obj, GModel*tool,
virtual GModel * computeBooleanDifference (GModel *obj, GModel*tool, int createNewModel) = 0; int createNewModel) = 0;
virtual GModel *computeBooleanDifference(GModel *obj, GModel*tool,
int createNewModel) = 0;
}; };
#if defined(HAVE_OCC) #if defined(HAVE_OCC)
...@@ -80,12 +84,10 @@ class OCCFactory : public GModelFactory { ...@@ -80,12 +84,10 @@ class OCCFactory : public GModelFactory {
GVertex *addVertex (GModel *gm,double x, double y, double z, double lc); GVertex *addVertex (GModel *gm,double x, double y, double z, double lc);
virtual GEdge *addLine (GModel *gm,GVertex *v1, GVertex *v2); virtual GEdge *addLine (GModel *gm,GVertex *v1, GVertex *v2);
GEdge *addCircleArc (GModel *gm,const arcCreationMethod &method, GEdge *addCircleArc (GModel *gm,const arcCreationMethod &method,
GVertex *start, GVertex *start, GVertex *end,
GVertex *end,
const SPoint3 &aPoint); const SPoint3 &aPoint);
GEdge *addSpline (GModel *gm,const splineType &type, GEdge *addSpline (GModel *gm,const splineType &type,
GVertex *start, GVertex *start, GVertex *end,
GVertex *end,
std::vector<std::vector<double> > controlPoints); std::vector<std::vector<double> > controlPoints);
GEdge *addNURBS(GModel *gm, GEdge *addNURBS(GModel *gm,
GVertex *start, GVertex *end, GVertex *start, GVertex *end,
...@@ -93,25 +95,24 @@ class OCCFactory : public GModelFactory { ...@@ -93,25 +95,24 @@ class OCCFactory : public GModelFactory {
std::vector<double> knots, std::vector<double> knots,
std::vector<double> weights, std::vector<double> weights,
std::vector<int> multiplicity); std::vector<int> multiplicity);
GEntity *revolve(GModel *gm, GEntity*,std::vector<double> p1,
GEntity* revolve (GModel *gm, GEntity*,std::vector<double> p1,std::vector<double> p2, double angle); std::vector<double> p2, double angle);
GEntity* extrude (GModel *gm, GEntity*,std::vector<double> p1,std::vector<double> p2); GEntity *extrude (GModel *gm, GEntity*,std::vector<double> p1,
std::vector<double> p2);
GEntity *addSphere(GModel *gm,double cx, double cy, double cz, double radius); GEntity *addSphere(GModel *gm,double cx, double cy, double cz, double radius);
GEntity *addCylinder(GModel *gm,std::vector<double> p1, std::vector<double> p2, GEntity *addCylinder(GModel *gm,std::vector<double> p1, std::vector<double> p2,
double radius); double radius);
GEntity *addTorus(GModel *gm,std::vector<double> p1, std::vector<double> p2, GEntity *addTorus(GModel *gm,std::vector<double> p1, std::vector<double> p2,
double radius1, double radius2); double radius1, double radius2);
GEntity *addBlock(GModel *gm,std::vector<double> p1, std::vector<double> p2); GEntity *addBlock(GModel *gm,std::vector<double> p1, std::vector<double> p2);
GEntity * addCone (GModel *gm,std::vector<double> p1, std::vector<double> p2, double radius1, double radius2); GEntity *addCone(GModel *gm,std::vector<double> p1, std::vector<double> p2,
// rigid body motions double radius1, double radius2);
void translate(GModel *gm, std::vector<double> dx, int addToTheModel); 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 rotate(GModel *gm, std::vector<double> p1,std::vector<double> p2,
// booleans double angle, int addToTheModel);
GModel *computeBooleanUnion(GModel *obj, GModel *tool, int createNewModel); GModel *computeBooleanUnion(GModel *obj, GModel *tool, int createNewModel);
GModel *computeBooleanIntersection(GModel *obj, GModel *tool, int createNewModel); GModel *computeBooleanIntersection(GModel *obj, GModel *tool, int createNewModel);
GModel *computeBooleanDifference(GModel *obj, GModel *tool, int createNewModel); GModel *computeBooleanDifference(GModel *obj, GModel *tool, int createNewModel);
// advanced
void fillet(GModel *gm, std::vector<int> edges, double radius); void fillet(GModel *gm, std::vector<int> edges, double radius);
}; };
......
// Gmsh - Copyright (C) 1997-2010 C. Geuzaine, J.-F. Remacle
//
// See the LICENSE.txt file for license information. Please report all
// bugs and problems to <gmsh@geuz.org>.
#include "GmshConfig.h" #include "GmshConfig.h"
#include "GModel.h" #include "GModel.h"
#include "GmshMessage.h" #include "GmshMessage.h"
...@@ -6,9 +11,6 @@ ...@@ -6,9 +11,6 @@
#include "ACISEdge.h" #include "ACISEdge.h"
#if defined(HAVE_ACIS) #if defined(HAVE_ACIS)
#define MacX 1
#define mac 1
#define ANSI 1
#include <acis.hxx> #include <acis.hxx>
#include <base.hxx> #include <base.hxx>
...@@ -21,7 +23,6 @@ ...@@ -21,7 +23,6 @@
#include <lists.hxx> #include <lists.hxx>
#include <acistype.hxx> #include <acistype.hxx>
class ACIS_Internals { class ACIS_Internals {
public: public:
ENTITY_LIST entities; ENTITY_LIST entities;
...@@ -33,25 +34,28 @@ public: ...@@ -33,25 +34,28 @@ public:
// void addFaces(GModel *gm, ENTITY_LIST &l); // void addFaces(GModel *gm, ENTITY_LIST &l);
}; };
ACIS_Internals::ACIS_Internals() { ACIS_Internals::ACIS_Internals()
{
// put your acis unlock string here... // put your acis unlock string here...
#include "ACISLICENSE.h" #include "ACISLICENSE.h"
spa_unlock_result out = spa_unlock_products(unlock_str); spa_unlock_result out = spa_unlock_products(unlock_str);
outcome prout = api_start_modeller(0); outcome prout = api_start_modeller(0);
if (!prout.ok()){ if (!prout.ok()){
Msg::Error("Unable to start ACIS"); Msg::Error("Unable to start ACIS");
} }
} }
ACIS_Internals::~ACIS_Internals(){
ACIS_Internals::~ACIS_Internals()
{
outcome prout = api_stop_modeller(); outcome prout = api_stop_modeller();
if (!prout.ok()){ if (!prout.ok()){
Msg::Error("Unable to stop ACIS"); Msg::Error("Unable to stop ACIS");
} }
} }
void ACIS_Internals :: addVertices (GModel *gm, ENTITY_LIST &l){ void ACIS_Internals::addVertices (GModel *gm, ENTITY_LIST &l)
{
l.init(); l.init();
ENTITY *e; ENTITY *e;
while(e = l.next()){ while(e = l.next()){
...@@ -64,7 +68,8 @@ void ACIS_Internals :: addVertices (GModel *gm, ENTITY_LIST &l){ ...@@ -64,7 +68,8 @@ void ACIS_Internals :: addVertices (GModel *gm, ENTITY_LIST &l){
} }
} }
void ACIS_Internals :: addEdges (GModel *gm, ENTITY_LIST &l){ void ACIS_Internals::addEdges (GModel *gm, ENTITY_LIST &l)
{
l.init(); l.init();
ENTITY *e; ENTITY *e;
while(e = l.next()){ while(e = l.next()){
...@@ -79,8 +84,10 @@ void ACIS_Internals :: addEdges (GModel *gm, ENTITY_LIST &l){ ...@@ -79,8 +84,10 @@ void ACIS_Internals :: addEdges (GModel *gm, ENTITY_LIST &l){
} }
} }
} }
/* /*
void ACIS_Internals :: addFaces (GModel *gm, ENTITY_LIST &l){ void ACIS_Internals::addFaces (GModel *gm, ENTITY_LIST &l)
{
l.init(); l.init();
ENTITY *e; ENTITY *e;
while(e = l.next()){ while(e = l.next()){
...@@ -97,7 +104,8 @@ void ACIS_Internals :: addFaces (GModel *gm, ENTITY_LIST &l){ ...@@ -97,7 +104,8 @@ void ACIS_Internals :: addFaces (GModel *gm, ENTITY_LIST &l){
} }
*/ */
void ACIS_Internals::loadSAT (std::string fileName, GModel *gm) { void ACIS_Internals::loadSAT(std::string fileName, GModel *gm)
{
FILE *f = fopen (fileName.c_str(), "r"); FILE *f = fopen (fileName.c_str(), "r");
if (!f){ if (!f){
return; return;
...@@ -139,11 +147,14 @@ int GModel::readACISSAT(const std::string &fn) ...@@ -139,11 +147,14 @@ int GModel::readACISSAT(const std::string &fn)
_acis_internals->loadSAT(fn,this); _acis_internals->loadSAT(fn,this);
return 1; return 1;
} }
#else #else
int GModel::readACISSAT(const std::string &fn) int GModel::readACISSAT(const std::string &fn)
{ {
Msg::Error("Gmsh must be compiled with ACIS support to load '%s'", Msg::Error("Gmsh must be compiled with ACIS support to load '%s'",
fn.c_str()); fn.c_str());
return 0; return 0;
} }
#endif #endif
...@@ -743,7 +743,7 @@ void OCC_Internals::applyBooleanOperator(TopoDS_Shape tool, const BooleanOperato ...@@ -743,7 +743,7 @@ void OCC_Internals::applyBooleanOperator(TopoDS_Shape tool, const BooleanOperato
} }
} }
void OCC_Internals::Fillet(std::vector<TopoDS_Edge> &edgesToFillet, void OCC_Internals::fillet(std::vector<TopoDS_Edge> &edgesToFillet,
double Radius) double Radius)
{ {
// create a tool for fillet // create a tool for fillet
......
...@@ -47,18 +47,7 @@ class OCC_Internals { ...@@ -47,18 +47,7 @@ class OCC_Internals {
GEdge *addEdgeToModel(GModel *model, TopoDS_Edge e); GEdge *addEdgeToModel(GModel *model, TopoDS_Edge e);
GFace *addFaceToModel(GModel *model, TopoDS_Face f); GFace *addFaceToModel(GModel *model, TopoDS_Face f);
GRegion *addRegionToModel(GModel *model, TopoDS_Solid r); GRegion *addRegionToModel(GModel *model, TopoDS_Solid r);
void fillet(std::vector<TopoDS_Edge> &shapes, double radius);
void Box(const SPoint3 &p1, const SPoint3 &p2, const BooleanOperator &op);
void Sphere(const SPoint3 &center, const double &radius, const BooleanOperator &op);
void Cylinder(const SPoint3 &bottom_center, const SVector3 &dir, double R, double H,
const BooleanOperator &op);
void Cone(const SPoint3 &bottom_center, const SVector3 &dir, double R1, double R2,
double H, const BooleanOperator &op);
void Torus(const SPoint3 &bottom_center, const SVector3 &dir, double R1, double R2,
const BooleanOperator &op);
void Torus(const SPoint3 &bottom_center, const SVector3 &dir, double R1, double R2,
double angle, const BooleanOperator &op);
void Fillet(std::vector<TopoDS_Edge> &shapes, double radius);
void applyBooleanOperator(TopoDS_Shape tool, const BooleanOperator &op); void applyBooleanOperator(TopoDS_Shape tool, const BooleanOperator &op);
}; };
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment