00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033 #ifndef _PARAMSURFACEINT_H
00034 #define _PARAMSURFACEINT_H
00035
00036
00037 #include "ParamGeomInt.h"
00038 #include "ParamSurface.h"
00039
00040
00041 namespace Go {
00044
00045
00046
00047 class AlgObj3DInt;
00048 class ImplicitizeSurfaceAlgo;
00049 class RotatedBox;
00050
00051
00054
00055 class ParamSurfaceInt : public ParamGeomInt {
00056 public:
00061 explicit ParamSurfaceInt(boost::shared_ptr<ParamSurface> surf,
00062 ParamGeomInt* parent = 0);
00063
00065 virtual ~ParamSurfaceInt();
00066
00071 virtual void point(Point& pt, const double* tpar) const
00072 { surf_->point(pt, tpar[0], tpar[1]); }
00073
00085 virtual void point(std::vector<Point>& pt,
00086 const double* tpar,
00087 int derivs,
00088 const bool* from_right = 0,
00089 double resolution = 1.0e-12) const
00090 {
00091 if (from_right) {
00092 surf_->point(pt, tpar[0], tpar[1], derivs, from_right[0],
00093 from_right[1], resolution);
00094 } else {
00095 surf_->point(pt, tpar[0], tpar[1], derivs, true, true,
00096 resolution);
00097 }
00098 }
00099
00102 virtual ParamSurfaceInt* getParamSurfaceInt();
00103
00104
00105
00106
00107
00108
00112 boost::shared_ptr<ParamSurface> getParamSurface()
00113 { return surf_; }
00114
00118 boost::shared_ptr<const ParamSurface> getParamSurface() const
00119 { return surf_;}
00120
00127 boost::shared_ptr<ParamSurface> getParentParamSurface(RectDomain& domain);
00128
00133 boost::shared_ptr<ParamSurface> getParentParamSurface();
00134
00139 virtual boost::shared_ptr<ParamSurfaceInt>
00140 makeIntObject(boost::shared_ptr<ParamSurface> surf);
00141
00147 virtual boost::shared_ptr<ParamCurveInt>
00148 makeIntCurve(boost::shared_ptr<ParamCurve> crv, ParamGeomInt* parent);
00149
00151 virtual int numParams() const
00152 { return 2;}
00153
00154
00155
00156
00157
00166 boost::shared_ptr<ParamCurve>
00167 getIsoCurve(double param_start, double param_end,
00168 double isoval, bool pardir_is_u) const;
00169
00175 boost::shared_ptr<ParamCurve>
00176 getConstantParameterCurve(int dir, double par);
00177
00178 boost::shared_ptr<ParamCurve>
00179 getConstantParameterCurve(int dir, double par, double tmin, double tmax);
00180
00181 void
00182 minimumAlongCurve(int dir, double par, double tmin, double tmax,
00183 Point& pnt, double& minpar, Point& minval,
00184 double& mindist);
00185
00193 virtual void getLengthAndWiggle(double *length, double *wiggle);
00194
00199 virtual bool hasInnerKnots(int pardir) const;
00200
00205 virtual bool hasCriticalVals(int pardir) const;
00206
00211 virtual bool hasCriticalValsOrKnots(int pardir) const;
00212
00216 virtual bool canDivide(int pardir);
00217
00218 virtual bool canDivideTinyTriang(int pardir);
00219
00224 virtual std::vector<double> getCriticalVals(int pardir) const;
00225
00230 virtual std::vector<double> getInnerKnotVals(int pardir,
00231 bool sort = false) const;
00232
00237 virtual std::vector<double> getCriticalValsAndKnots(int pardir) const;
00238
00243 virtual int getMeshSize(int dir);
00244
00250 virtual double paramFromMesh(int dir, int idx);
00251
00253 virtual std::vector<double>::iterator getMesh();
00254
00258 virtual double startParam(int pardir) const;
00259
00263 virtual double endParam(int pardir) const;
00264
00270 virtual bool boundaryPoint(const double* par, double eps) const;
00271
00275 std::vector<double> getMima() const;
00276
00282 virtual bool inCorner(const double *par, double epspar) const;
00283
00284 bool atDegenerateBd(const double *par, double epsge, double epspar);
00285
00295 virtual void
00296 subdivide(int pardir, double par,
00297 std::vector<boost::shared_ptr<ParamGeomInt> >& subdiv_objs,
00298 std::vector<boost::shared_ptr<ParamGeomInt> >& bd_objs);
00299
00313 virtual std::vector<boost::shared_ptr<ParamSurfaceInt> >
00314 subSurfaces(double from_upar, double from_vpar,
00315 double to_upar, double to_vpar,
00316 double fuzzy);
00317
00320 virtual CompositeBox compositeBox() const;
00321
00324 virtual DirectionCone directionCone() const;
00325
00328 virtual void
00329 getBoundaryObjects(std::vector<boost::
00330 shared_ptr<BoundaryGeomInt> >& bd_objs);
00331
00343 virtual int checkPeriodicity(int pardir) const;
00344
00346 virtual int dimension() const
00347 { return dim_; }
00348
00351 virtual const RectDomain& getDomain() const
00352 { return domain_;}
00353
00357 const RectDomain& getDegDomain(double epsge);
00358
00363 virtual bool isSimple();
00364
00367 virtual bool isSpline();
00368
00371 virtual bool isIsoParametric(ParamCurveInt *curve, int dir, double par,
00372 double ptol, double tol)
00373 { return false; }
00374
00382 virtual double getOptimizedConeAngle(Point& axis1, Point& axis2);
00383
00392 virtual void knotIntervalFuzzy(double& u, double&v,
00393 double utol, double vtol) const;
00394
00404 virtual double nextSegmentVal(int dir, double par,
00405 bool forward, double tol) const;
00406
00407
00410 bool isDegenerate(double epsge);
00411
00416 virtual int isDegenerate(double epsge, int dir);
00417
00424 virtual bool isDegenerate(double epsge, int dir, double *par);
00425
00434 double isolateDegPar(int dir, int deg_edge, double threshold, double *deg_factor=NULL);
00435
00438 void setDegTriang()
00439 { deg_triang_ = true; }
00440
00443 bool getDegTriang()
00444 { return deg_triang_; }
00445
00453 double getParOffBd(int dir, bool atstart, double tol) const;
00454
00467 void first_fund_form(double u,
00468 double v,
00469 bool u_from_right,
00470 bool v_from_right,
00471 double& E,
00472 double& F,
00473 double& G) const
00474 {
00475
00476 surf_->point(temp_point_array_, u, v, 1,
00477 u_from_right, v_from_right);
00478
00479 E = temp_point_array_[1] * temp_point_array_[1];
00480 F = temp_point_array_[1] * temp_point_array_[2];
00481 G = temp_point_array_[2] * temp_point_array_[2];
00482 }
00483
00498 void second_fund_form(double u,
00499 double v,
00500 bool u_from_right,
00501 bool v_from_right,
00502 double& L,
00503 double& M,
00504 double& N) const
00505 {
00506
00507 surf_->point(temp_point_array_, u, v, 2,
00508 u_from_right, v_from_right);
00509
00510
00511 surf_->normal(temp_point_array_[0], u, v);
00512
00513
00514
00515 L = temp_point_array_[3] * temp_point_array_[0];
00516 M = temp_point_array_[4] * temp_point_array_[0];
00517 N = temp_point_array_[5] * temp_point_array_[0];
00518 }
00519
00531 void derivs(double u,
00532 double v,
00533 Point& deriv_u,
00534 Point& deriv_v,
00535 bool from_right_1 = true,
00536 bool from_right_2 = true) const
00537 {
00538 surf_->point(temp_point_array_, u, v, 1,
00539 from_right_1, from_right_2);
00540 deriv_u = temp_point_array_[1];
00541 deriv_v = temp_point_array_[2];
00542 }
00543
00554 void normal(double u,
00555 double v,
00556 Point& normal,
00557 bool from_right_1 = true,
00558 bool from_right_2 = true) const
00559 {
00560 surf_->point(temp_point_array_, u, v, 1,
00561 from_right_1, from_right_2);
00562 normal = temp_point_array_[1] % temp_point_array_[2];
00563 }
00564
00571 virtual RotatedBox getRotatedBox(std::vector<Point>& axis) const;
00572
00573
00574
00575
00576
00577
00578
00582 void axisFromCorners(Point& axis1, Point& axis2) const;
00583
00588 virtual void splitAtG0(double angtol,
00589 std::vector<boost::
00590 shared_ptr<ParamSurfaceInt> >& subG1);
00591
00599 void getSingularity(double eps, double sing_par[], Point& sing_pt,
00600 double& sing_val, double *seed);
00601
00605 bool canSelfIntersect(double epsge) const;
00606
00610 virtual boost::shared_ptr<ParamSurfaceInt> getNormalSurface() const
00611 {
00612 boost::shared_ptr<ParamSurfaceInt> dummy;
00613 return dummy;
00614 }
00615
00619 virtual bool canImplicitize()
00620 { return false; }
00621
00625 virtual bool implicitize(double tol)
00626 { return false; }
00627
00637
00638 virtual bool getImplicit(double tol, double& tol2,
00639 AlgObj3DInt& alg_obj_3d_int)
00640 { return false; }
00641
00642
00643
00644
00645
00646
00647
00648
00649
00650
00651
00652
00653
00654
00655 void maxCurvatures(bool dir_is_u, int nmb_params, double iso_from,
00656 double iso_to, double guess_param,
00657 std::vector<double>& max_curv_params,
00658 std::vector<double>& max_curvatures);
00659
00660
00661 protected:
00662
00663 boost::shared_ptr<ParamSurface> surf_;
00664 int dim_;
00665 double deg_tol_;
00666 bool deg_triang_;
00667
00668 std::vector<std::pair<double, int> > segment_[2];
00669
00670
00671 bool bd_deg_[4];
00672 RectDomain domain_;
00673 RectDomain deg_domain_;
00674
00675
00676 mutable int nmesh_[2];
00677 mutable std::vector<double> mesh_;
00678
00679 mutable DirectionCone cone_;
00680
00681 mutable bool lw_set_;
00682 mutable double length_[2], wiggle_[2];
00683
00684
00685
00686
00687
00688
00689
00690
00691 mutable std::vector<Point> temp_point_array_;
00692
00693
00694 boost::shared_ptr<ImplicitizeSurfaceAlgo> impl_sf_algo_;
00695 double implicit_tol_;
00696
00697 int impl_deg_;
00698 boost::shared_ptr<AlgObj3DInt> implicit_obj_;
00699 double implicit_err_;
00700
00701
00702 private:
00703 void makeMesh(int size1, int size2) const;
00704
00705 void computeDegDomain(double aepsge);
00706
00707 };
00708
00709
00711 }
00712
00713
00714 #endif // _PARAMSURFACEINT_H
00715