-// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org\r
-//\r
-//\r
-// File : BLSURFlugin_Mesher.cxx\r
-// Authors : Francis KLOSS (OCC) & Patrick LAUG (INRIA)\r
-// Date : 31/03/2006\r
-// Project : SALOME\r
-//=============================================================================\r
-// using namespace std;\r
-\r
-// #include "BLSURFPlugin_Mesher.hxx"\r
-// #include "BLSURFPlugin_Hypothesis.hxx"\r
-\r
-// #include <SMESHDS_Mesh.hxx>\r
-// #include <SMDS_MeshElement.hxx>\r
-// #include <SMDS_MeshNode.hxx>\r
-// #include <utilities.h>\r
-\r
-// #include <vector>\r
-\r
-// #include <BRep_Tool.hxx>\r
-// #include <TopExp.hxx>\r
-// #include <TopExp_Explorer.hxx>\r
-// #include <TopoDS.hxx>\r
-// #include <NCollection_Map.hxx>\r
-\r
-#include <iostream>\r
-#include <fstream>\r
-\r
-#include <Occ_utility.h>\r
-#include <TDataStd_Name.hxx>\r
-#include <TPrsStd_AISPresentation.hxx>\r
-#include <TNaming_NamedShape.hxx>\r
-#include <TopExp_Explorer.hxx>\r
-#include <AIS_InteractiveObject.hxx>\r
-#include <ShapeFix_Edge.hxx>\r
-#include <TopoDS.hxx>\r
-#include <TopLoc_Location.hxx>\r
-#include <Geom_Surface.hxx>\r
-#include <Handle_Geom_Surface.hxx>\r
-#include <BRep_Tool.hxx>\r
-#include <Geom_ElementarySurface.hxx>\r
-#include <Geom_BoundedSurface.hxx>\r
-#include <Geom_OffsetSurface.hxx>\r
-#include <Geom_SweptSurface.hxx>\r
-#include <Geom_RectangularTrimmedSurface.hxx>\r
-#include <Geom_BezierSurface.hxx>\r
-#include <GeomAPI_ProjectPointOnCurve.hxx>\r
-#include <GeomAPI_ProjectPointOnSurf.hxx>\r
-#include <Geom_ConicalSurface.hxx>\r
-#include <Geom_CylindricalSurface.hxx>\r
-#include <Geom_Plane.hxx>\r
-#include <Geom_SphericalSurface.hxx>\r
-#include <Geom_ToroidalSurface.hxx>\r
-#include <Geom_SurfaceOfLinearExtrusion.hxx>\r
-#include <Geom_SurfaceOfRevolution.hxx>\r
-#include <ShapeUpgrade_ClosedFaceDivide.hxx>\r
-#include <ShapeUpgrade_ShapeDivide.hxx>\r
-#include <TNaming_Builder.hxx>\r
-#include <TDataStd_Integer.hxx>\r
-#include <cad_occ.h>\r
-\r
-#include <GProp_GProps.hxx>\r
-#include <BRepGProp.hxx>\r
-#include <BRepAlgoAPI_Common.hxx>\r
-\r
-#include <BRep_ListIteratorOfListOfCurveRepresentation.hxx>\r
-#include <BRep_TEdge.hxx>\r
-#include <Handle_BRep_TEdge.hxx>\r
-#include <BRep_GCurve.hxx>\r
-#include <Handle_BRep_GCurve.hxx>\r
-#include <ShapeFix_Edge.hxx>\r
-#include <BRep_Tool.hxx>\r
-#include <TopoDS_Vertex.hxx>\r
-#include <TopoDS_Wire.hxx>\r
-#include <TopTools_IndexedMapOfShape.hxx>\r
-\r
-#define TSMO blw->bls_glo.tsmo\r
-\r
-bool BL_SURF::init(const TopoDS_Shape& _shape) {\r
- cout << "BLSURF_init: begin" << endl;\r
-\r
- if (_shape.ShapeType() == TopAbs_COMPOUND) {\r
- cout << "BLSURF_init: the shape is a COMPOUND" << endl;\r
- } else {\r
- cout << "BLSURF_init: the shape is UNKNOWN" << endl;\r
- }\r
-\r
- cout << "BLSURF_init: exploring faces and edges " << endl;\r
- int i=0;\r
- for (TopExp_Explorer expf(_shape, TopAbs_FACE); expf.More(); expf.Next()) {\r
- const TopoDS_Shape& face = expf.Current();\r
- i++;\r
- int j=0;\r
- for (TopExp_Explorer expe(face, TopAbs_EDGE); expe.More(); expe.Next()) {\r
- // const TopoDS_Shape& edge = expe.Current(); -> warning: unused variable 'edge'\r
- j++;\r
- }\r
- // cout << "BLSURF_init: face " << i << " has " << j << " edges" << endl;\r
- }\r
- cout << "BLSURF_init: total number of faces = " << i << endl;\r
-\r
- TopoDS_Shape the_shape;\r
- the_shape = _shape;\r
-\r
- // return(true);\r
- return(run(the_shape));\r
-}\r
-\r
-// #define TC2D blw.bls_glo.TC2dNew\r
-\r
-void BL_SURF::get_blw(blw_*& blw_param) {\r
- blw_param = &blw;\r
-}\r
-\r
-bool BL_SURF::end() {\r
- bls_free(&blw);\r
- if (blw.error[0]) {\r
- return(false);\r
- } else {\r
- return(true);\r
- }\r
-}\r
-\r
-double norm(vector<double> v)\r
-{\r
- double res=0.;\r
- for (int i=0;i<v.size();i++) res+=POW2(v[i]);\r
- return(sqrt(res));\r
-}\r
-\r
-vector<double> operator-(vector<double> v1, vector<double> v2)\r
-{\r
- assert(v1.size()==v2.size());\r
- vector<double> res(v1.size(),0.);\r
- for (int i=0;i<v1.size();i++) res[i]=v1[i]-v2[i];\r
- return(res);\r
-}\r
-\r
-bool BL_SURF::run(TopoDS_Shape &s)\r
-{\r
- the_object=s;\r
- return(run());\r
-}\r
-\r
-bool BL_SURF::run()\r
-{\r
- active_blsurf = this;\r
- build_surfaces(the_object);\r
- int ret = bls_main(&blw);\r
- active_blsurf = NULL;\r
- if (ret == 0) {\r
- return(true);\r
- } else {\r
- return(false);\r
- }\r
-}\r
-\r
-void BL_SURF::build_surfaces(TopoDS_Shape &shape)\r
-{\r
- int i, iface;\r
-\r
-//\r
-// Explore the whole shape to extract surfaces, and build BL objects\r
-//\r
-\r
- for (i=0;i<surfaces.size();i++) delete(surfaces[i]);\r
- surfaces.resize(0);\r
-\r
- TopTools_IndexedMapOfShape fmap;\r
- fmap.Clear();\r
- iface = 0;\r
- for (TopExp_Explorer ex_face(shape,TopAbs_FACE);ex_face.More();ex_face.Next()) {\r
- TopoDS_Face f=TopoDS::Face(ex_face.Current());\r
- if (fmap.FindIndex(f) <= 0) {\r
- fmap.Add(f);\r
- iface++;\r
- BL_SURFACE *bl_surface=new BL_SURFACE(f);\r
- if(bl_surface->build()) {\r
- surfaces.push_back(bl_surface);\r
- } else {\r
- cout<<"Weird surface detected !"<<endl;\r
- delete(bl_surface);\r
- }\r
- }\r
- }\r
-}\r
-\r
-BL_SURFACE::BL_SURFACE(TopoDS_Face &f) \r
-{ \r
- sizer=NULL;\r
- topology=f;\r
- geometry=BRep_Tool::Surface(f);\r
-}\r
-\r
-BL_SURFACE::~BL_SURFACE() \r
-{ \r
- for (int i=0;i<edges.size();i++) delete(edges[i]);\r
-}\r
-\r
-bool BL_SURFACE::build()\r
-{\r
-//\r
-// Explore the surface to extract all edges\r
-//\r
- for (TopExp_Explorer ex_face(topology,TopAbs_EDGE);ex_face.More();ex_face.Next()) {\r
- TopoDS_Edge e=TopoDS::Edge(ex_face.Current());\r
- if(!add(e)) return(false);\r
- }\r
- return(true);\r
-}\r
-\r
-void BL_SURFACE::add(double u, double v)\r
-{\r
- points.push_back(new BL_POINT(this,u,v));\r
-}\r
-\r
-bool BL_SURFACE::add(TopoDS_Edge &edge)\r
-{\r
-//\r
-// add an edge ( make some checks, and build the associated BL_EDGE object )\r
-//\r
- Handle(Geom2d_Curve) pargeo;\r
- double tmin,tmax;\r
-\r
- pargeo=BRep_Tool::CurveOnSurface(edge,topology,tmin,tmax);\r
-\r
- BL_EDGE *bl_edge=new BL_EDGE(edge,this,pargeo,tmin,tmax);\r
- edges.push_back(bl_edge);\r
- return(true);\r
-}\r
-\r
-BL_EDGE::BL_EDGE(TopoDS_Edge &ed,BL_SURFACE *b, Handle(Geom2d_Curve) pargeo, double tmin, double tmax)\r
-{\r
- sizer=NULL;\r
- refc=-1;\r
- typc=1;\r
- topology=ed; boss=b;\r
- parametric_geometry=pargeo;\r
- parametric_min=tmin; parametric_max=tmax;\r
-}\r
-\r
-BL_EDGE::~BL_EDGE() { }\r
-\r
-void BL_EDGE::method_curv0(const double &t, double *C)\r
-{\r
- gp_Pnt2d P;\r
-\r
- P=parametric_geometry->Value(t);\r
- C[0]=P.X(); C[1]=P.Y();\r
-}\r
-\r
-void BL_EDGE::method_curv1(const double &t, double *C)\r
-{\r
- gp_Vec2d V1;\r
-\r
- V1=parametric_geometry->DN(t,1);\r
- C[0]=V1.X(); C[1]=V1.Y();\r
-}\r
-\r
-void BL_EDGE::method_curv2(const double &t, double *C)\r
-{\r
- gp_Vec2d V2;\r
-\r
- V2=parametric_geometry->DN(t,2);\r
- C[0]=V2.X(); C[1]=V2.Y();\r
-}\r
-\r
-void BL_SURFACE::method_surf0(const double *UV, double *S)\r
-{\r
- gp_Pnt P;\r
-\r
- P=geometry->Value(UV[0],UV[1]); // S.D0(U,V,P);\r
- S[0]=P.X(); S[1]=P.Y(); S[2]=P.Z();\r
-}\r
-\r
-void BL_SURFACE::method_surf1(const double *UV, double *Su, double *Sv)\r
-{\r
- gp_Pnt P;\r
- gp_Vec D1U,D1V;\r
-\r
- geometry->D1(UV[0],UV[1],P,D1U,D1V);\r
- Su[0]=D1U.X(); Su[1]=D1U.Y(); Su[2]=D1U.Z();\r
- Sv[0]=D1V.X(); Sv[1]=D1V.Y(); Sv[2]=D1V.Z();\r
-} \r
-\r
-void BL_SURFACE::method_surf2(const double *UV, double *Suu, double *Suv, double *Svv)\r
-{\r
- gp_Pnt P;\r
- gp_Vec D1U,D1V;\r
- gp_Vec D2U,D2V,D2UV;\r
-\r
- geometry->D2(UV[0],UV[1],P,D1U,D1V,D2U,D2V,D2UV);\r
- Suu[0]=D2U.X(); Suu[1]=D2U.Y(); Suu[2]=D2U.Z();\r
- Suv[0]=D2UV.X(); Suv[1]=D2UV.Y(); Suv[2]=D2UV.Z();\r
- Svv[0]=D2V.X(); Svv[1]=D2V.Y(); Svv[2]=D2V.Z();\r
-}\r
-\r
-static vector<BL_SURFACE*> *current_list_of_faces=NULL;\r
-BL_SURF* BL_SURF::active_blsurf=NULL;\r
-\r
-void cad_surf0 (blw_ *blw, int *refs, double *uv, double *S)\r
-{\r
- BL_SURFACE *surf=(*current_list_of_faces)[*refs-1];\r
- surf->method_surf0(uv,S);\r
-}\r
-\r
-void cad_surf1 (blw_ *blw, int *refs, double *uv, double *Su, double *Sv)\r
-{\r
- BL_SURFACE *surf=(*current_list_of_faces)[*refs-1];\r
- surf->method_surf1(uv,Su,Sv);\r
-}\r
-\r
-// calcul discret\r
-// double du, dv, uvg[2], uvd[2], uvb[2], uvh[2], Sg[3], Sd[3], Sb[3], Sh[3];\r
-// double Sucont[3], Svcont[3];\r
-// if (*refs == 33) {\r
-// Sucont[0] = Su[0]; Sucont[1] = Su[1]; Sucont[2] = Su[2];\r
-// Svcont[0] = Sv[0]; Svcont[1] = Sv[1]; Svcont[2] = Sv[2];\r
-// BL_SURFACE *surf=(*current_list_of_faces)[*refs-1];\r
-// du = (TSMO[*refs].uvmax[0] - TSMO[*refs].uvmin[0]) * 0.08;\r
-// dv = (TSMO[*refs].uvmax[1] - TSMO[*refs].uvmin[1]) * 0.08;\r
-// uvg[0] = uv[0]-du;\r
-// uvg[1] = uv[1];\r
-// uvd[0] = uv[0]+du;\r
-// uvd[1] = uv[1];\r
-// uvb[0] = uv[0];\r
-// uvb[1] = uv[1]-dv;\r
-// uvh[0] = uv[0];\r
-// uvh[1] = uv[1]+dv;\r
-// if (uvg[0] < TSMO[*refs].uvmin[0]) uvg[0] = TSMO[*refs].uvmin[0];\r
-// if (uvd[0] > TSMO[*refs].uvmax[0]) uvd[0] = TSMO[*refs].uvmax[0];\r
-// if (uvb[1] < TSMO[*refs].uvmin[1]) uvb[1] = TSMO[*refs].uvmin[1];\r
-// if (uvh[1] > TSMO[*refs].uvmax[1]) uvh[1] = TSMO[*refs].uvmax[1];\r
-// surf->method_surf0(uvg,Sg);\r
-// surf->method_surf0(uvd,Sd);\r
-// surf->method_surf0(uvb,Sb);\r
-// surf->method_surf0(uvh,Sh);\r
-// du = uvd[0] - uvg[0];\r
-// dv = uvh[1] - uvb[1];\r
-// Su[0] = (Sd[0] - Sg[0]) / du;\r
-// Su[1] = (Sd[1] - Sg[1]) / du;\r
-// Su[2] = (Sd[2] - Sg[2]) / du;\r
-// Sv[0] = (Sh[0] - Sb[0]) / dv;\r
-// Sv[1] = (Sh[1] - Sb[1]) / dv;\r
-// Sv[2] = (Sh[2] - Sb[2]) / dv;\r
-// fprintf(blw->out, "Su cont %g %g %g\n", Sucont[0], Sucont[1], Sucont[2]);\r
-// fprintf(blw->out, "Su disc %g %g %g\n", Su[0], Su[1], Su[2]);\r
-// fprintf(blw->out, "Sv cont %g %g %g\n", Svcont[0], Svcont[1], Svcont[2]);\r
-// fprintf(blw->out, "Sv disc %g %g %g\n", Sv[0], Sv[1], Sv[2]);\r
-// }\r
-\r
-void cad_surf2 (blw_ *blw, int *refs, double uv[2], double Suu[3], double Suv[3], double Svv[3])\r
-{\r
- BL_SURFACE *surf=(*current_list_of_faces)[*refs-1];\r
- surf->method_surf2(uv,Suu,Suv,Svv);\r
-\r
-// // calcul discret\r
-// double du, dv, uvg[2], uvd[2], uvb[2], uvh[2], Sug[3], Sud[3], Sub[3], Suh[3], Svg[3], Svd[3], Svb[3], Svh[3];\r
-// double Suucont[3], Suvcont[3], Svvcont[3];\r
-// if (*refs >= 0) {\r
-// Suucont[0] = Suu[0]; Suucont[1] = Suu[1]; Suucont[2] = Suu[2];\r
-// Suvcont[0] = Suv[0]; Suvcont[1] = Suv[1]; Suvcont[2] = Suv[2];\r
-// Svvcont[0] = Svv[0]; Svvcont[1] = Svv[1]; Svvcont[2] = Svv[2];\r
-// du = (TSMO[*refs].uvmax[0] - TSMO[*refs].uvmin[0]) * 0.08;\r
-// dv = (TSMO[*refs].uvmax[1] - TSMO[*refs].uvmin[1]) * 0.08;\r
-// uvg[0] = uv[0]-du;\r
-// uvg[1] = uv[1];\r
-// uvd[0] = uv[0]+du;\r
-// uvd[1] = uv[1];\r
-// uvb[0] = uv[0];\r
-// uvb[1] = uv[1]-dv;\r
-// uvh[0] = uv[0];\r
-// uvh[1] = uv[1]+dv;\r
-// if (uvg[0] < TSMO[*refs].uvmin[0]) uvg[0] = TSMO[*refs].uvmin[0];\r
-// if (uvd[0] > TSMO[*refs].uvmax[0]) uvd[0] = TSMO[*refs].uvmax[0];\r
-// if (uvb[1] < TSMO[*refs].uvmin[1]) uvb[1] = TSMO[*refs].uvmin[1];\r
-// if (uvh[1] > TSMO[*refs].uvmax[1]) uvh[1] = TSMO[*refs].uvmax[1];\r
-// surf->method_surf1(uvg,Sug,Svg);\r
-// surf->method_surf1(uvd,Sud,Svd);\r
-// surf->method_surf1(uvb,Sub,Svb);\r
-// surf->method_surf1(uvh,Suh,Svh);\r
-// du = uvd[0] - uvg[0];\r
-// dv = uvh[1] - uvb[1];\r
-// Suu[0] = (Sud[0] - Sug[0]) / du;\r
-// Suu[1] = (Sud[1] - Sug[1]) / du;\r
-// Suu[2] = (Sud[2] - Sug[2]) / du;\r
-// Svv[0] = (Svh[0] - Svb[0]) / dv;\r
-// Svv[1] = (Svh[1] - Svb[1]) / dv;\r
-// Svv[2] = (Svh[2] - Svb[2]) / dv;\r
-// Suv[0] = ((Suh[0] - Sub[0]) / dv + (Svd[0] - Svg[0]) / du) * 0.5;\r
-// Suv[1] = ((Suh[1] - Sub[1]) / dv + (Svd[1] - Svg[1]) / du) * 0.5;\r
-// Suv[2] = ((Suh[2] - Sub[2]) / dv + (Svd[2] - Svg[2]) / du) * 0.5;\r
-// // fprintf(blw->out, "disc uv %g %g Suu %g %g %g\n", uv[0], uv[1], Suu[0], Suu[1], Suu[2]);\r
-// // fprintf(blw->out, "Suv disc %g %g %g\n", Suv[0], Suv[1], Suv[2]);\r
-// // fprintf(blw->out, "Svv disc %g %g %g\n", Svv[0], Svv[1], Svv[2]);\r
-// }\r
-}\r
-\r
-void cad_curvint (blw_ *blw, int *refs, int *ic, double *a, double *b)\r
-{\r
- *a=(*current_list_of_faces)[*refs-1]->edges[*ic-1]->parametric_min;\r
- *b=(*current_list_of_faces)[*refs-1]->edges[*ic-1]->parametric_max;\r
-}\r
-\r
-void cad_curv0 (blw_ *blw, int *refs, int *ic, double *t, double *C)\r
-{\r
- (*current_list_of_faces)[*refs-1]->edges[*ic-1]->method_curv0(*t,C);\r
-}\r
-\r
-void cad_curv1 (blw_ *blw, int *refs, int *ic, double *t, double *Ct)\r
-{\r
- (*current_list_of_faces)[*refs-1]->edges[*ic-1]->method_curv1(*t,Ct);\r
-}\r
-\r
-void cad_curv2 (blw_ *blw, int *refs, int *ic, double *t, double *Ctt)\r
-{\r
- (*current_list_of_faces)[*refs-1]->edges[*ic-1]->method_curv2(*t,Ctt);\r
-}\r
-\r
-void cad_hphys (blw_ *blw, int *refs, double *uv, double *h) {}\r
-void cad_hphyc (blw_ *blw, int *refs, int *ic, double *t, double *h) {}\r
-void cad_hphyp (blw_ *blw, int *refp, double *h) {}\r
-\r
-void cad_rads (blw_ *blw, int *refs, double *uv, double *rhos) {\r
- sprintf(blw->error, "cad_rads should not be called\n");\r
-}\r
-\r
-void cad_radc (blw_ *blw, int *refs, int *ic, double *t, double *rhoc) {\r
- sprintf(blw->error, "cad_radc should not be called");\r
-}\r
-\r
-void cad_hageos(blw_ *blw, int *refs, double uv[2], double hageos[6]) {\r
- sprintf(blw->error, "cad_hageos should not be called\n");\r
-}\r
-\r
-void cad_refphyc(blw_ *blw, int *refc, int *phyc) {\r
- *phyc = *refc;\r
-}\r
-\r
-void cad_refphyp(blw_ *blw, int *refp, int *phyp) {\r
- *phyp = *refp;\r
-}\r
-\r
-void cad_refphys(blw_ *blw, int *refs, int *phys) {\r
- *phys = *refs;\r
-}\r
-\r
-void cad_edgetag(blw_ *blw, int *refc, int *required) {\r
- *required = 1;\r
-}\r
-\r
-void cad_curvparam(blw_ *blw, int *refs, int *ic, int *n, double tab[]) {\r
- *n = 0;\r
-}\r
-\r
-void BL_SURF::init_tsmo(blw_ *blw) { /* cf. bls_read_pardom */\r
- int is, ns, ic, nc, j, igloP, igloQ, isurf;\r
- TopoDS_Vertex v;\r
- gp_Pnt p;\r
- double a, b, uv[2], xyz[3], xyzP[3], xyzQ[3];\r
-\r
- ns = surfaces.size();\r
- if (blw->env.verb >= 10) fprintf(blw->out, "\ninit_tsmo: %d surfaces\n", ns);\r
- if (ns <= 0) {\r
- TSMO = NULL;\r
- blw->bls_glo.number_of_patches = 0;\r
- return;\r
- }\r
-\r
- TopTools_IndexedMapOfShape fmap_edges;\r
- TopTools_IndexedMapOfShape fmap_points;\r
- fmap_edges.Clear();\r
- fmap_points.Clear();\r
- for (isurf=0; isurf<ns; isurf++) {\r
- TopoDS_Face face = surfaces[isurf]->topology;\r
- for (TopExp_Explorer ex_face(face ,TopAbs_EDGE); ex_face.More(); ex_face.Next()) {\r
- TopoDS_Edge e = TopoDS::Edge(ex_face.Current());\r
- if (fmap_edges.FindIndex(e) <= 0) { /* not found => FindIndex = 0, found => FindIndex > 0 */\r
- fmap_edges.Add(e);\r
- j = 0;\r
- for (TopExp_Explorer ex_edge(e ,TopAbs_VERTEX); ex_edge.More(); ex_edge.Next()) {\r
- v = TopoDS::Vertex(ex_edge.Current());\r
- ++j;\r
- if (fmap_points.FindIndex(v) <= 0) fmap_points.Add(v);\r
- }\r
- if (j != 2) {\r
- sprintf(blw->error, "init_tsmo: surface is=%d: an edge has %d != 2 extremities\n", isurf+1, j); return;\r
- }\r
- }\r
- }\r
- }\r
-\r
- MALLOC(surface_, TSMO, ns+1); if (blw->error[0]) return;\r
- blw->bls_glo.number_of_patches = ns;\r
- for (isurf=0; isurf<ns; isurf++) {\r
- is = isurf+1;\r
- nc = surfaces[isurf]->edges.size();\r
- if (blw->env.verb >= 70) fprintf(blw->out, "init_tsmo: surface is=%d: %d curves\n", is, nc);\r
-\r
- bls_init_surface(blw, &(TSMO[is]), nc);\r
- TSMO[is].iglos = is;\r
- TSMO[is].pardom_side = 0;\r
- TSMO[is].surforient = +1;\r
- for (int icurv=0;icurv<nc;icurv++) {\r
- ic = icurv+1;\r
- TSMO[is].TC[ic].typc = 1;\r
- BL_EDGE* curve = surfaces[isurf]->edges[icurv];\r
- TopoDS_Edge edge = curve->topology;\r
- TSMO[is].TC[ic].igloc = fmap_edges.FindIndex(edge);\r
-\r
- TopExp_Explorer ex_edge(edge, TopAbs_VERTEX);\r
- v = TopoDS::Vertex(ex_edge.Current());\r
- p = BRep_Tool::Pnt(v);\r
- xyzP[0] = p.X(); xyzP[1] = p.Y(); xyzP[2] = p.Z();\r
- igloP = fmap_points.FindIndex(v);\r
-\r
- ex_edge.Next();\r
- v = TopoDS::Vertex(ex_edge.Current());\r
- p = BRep_Tool::Pnt(v);\r
- xyzQ[0] = p.X(); xyzQ[1] = p.Y(); xyzQ[2] = p.Z();\r
- igloQ = fmap_points.FindIndex(v);\r
-\r
- cad_curvint (blw, &is, &ic, &a, &b);\r
- cad_curv0 (blw, &is, &ic, &a, uv);\r
- cad_surf0 (blw, &is, uv, xyz); \r
- xyzP[0] -= xyz[0]; xyzP[1] -= xyz[1]; xyzP[2] -= xyz[2];\r
- xyzQ[0] -= xyz[0]; xyzQ[1] -= xyz[1]; xyzQ[2] -= xyz[2];\r
- if (NORM3DPOW2(xyzP) <= NORM3DPOW2(xyzQ)) {\r
- TSMO[is].TC[ic].iglope[0] = igloP;\r
- TSMO[is].TC[ic].iglope[1] = igloQ;\r
- } else {\r
- TSMO[is].TC[ic].iglope[0] = igloQ;\r
- TSMO[is].TC[ic].iglope[1] = igloP;\r
- }\r
- }\r
- }\r
-}\r
-\r
-int BL_SURF::bls_main(blw_ *blw) {\r
- FILE *file;\r
-\r
- /* banner */\r
- blw->out = stdout;\r
- bls_banner(blw, 1);\r
- \r
- /* initialiser l'environnement de BLSURF */\r
- init_blsenv(blw);\r
-\r
- /* lire l'environnement de BLSURF */\r
- /* par defaut : strcpy(blw->dirname, ""); */\r
- /* sinon : strcpy(blw->dirname, "C:\\Documents and Settings\\xxx\\"); */\r
- sprintf(blw->filename, "%sblsurf.env", blw->dirname);\r
- FOPEN(file, "r");\r
- if (blw->error[0]) {\r
- fprintf(blw->out, "File blsurf.env not found. Default values will be used.\n");\r
- blw->error[0] = 0;\r
- } else {\r
- read_blsenv(blw, file);\r
- FCLOSE(file);\r
- if (blw->error[0]) goto error; /* read_blsenv: unknown keyword */\r
- }\r
-\r
- /* copier les variables communes entre "bl2denv" et blsenv (en particulier verb) */\r
- copy_common_env(blw);\r
-\r
- /* imprimer l'environnement de BLSURF */\r
- if (blw->env.verb >= 70) print_blsenv(blw);\r
-\r
- /* initialiser TSMO */\r
- current_list_of_faces = &surfaces;\r
- BL_SURF::init_tsmo(blw); if (blw->error[0]) goto error;\r
-\r
- /* generer le maillage surfacique */\r
- bls_init(blw); if (blw->error[0]) goto error;\r
- bls_mesh(blw); if (blw->error[0]) goto error;\r
- bls_surforient(blw); if (blw->error[0]) goto error;\r
- bls_export(blw); if (blw->error[0]) goto error;\r
- /* a voir : les tableaux pointes par current_list_of_faces sont liberes ? handles ? */\r
-\r
- bls_banner(blw, 2);\r
- return(0);\r
-\r
- error:\r
- fprintf(blw->out, "\nBLSURF ERROR MESSAGE:\n%s\n", blw->error);\r
- bls_banner(blw, 2);\r
- return(1);\r
-}\r