Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions lrsplines2D/include/GoTools/lrsplines2D/BSplineUniLR.h
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,15 @@ class BSplineUniLR : public Streamable
return mesh_->kval(pardir_, kn);
}

/// All knot values
std::vector<double> getKnots() const
{
std::vector<double> knots(kvec_.size());
for (int ki=0; ki<(int)kvec_.size(); ++ki)
knots[ki] = mesh_->kval(pardir_, kvec_[ki]);
return knots;
}

/// Count multiplicity in the end of the B-spline
int endmult(bool atstart) const;

Expand Down
10 changes: 6 additions & 4 deletions lrsplines2D/src/LRSplineSurface.C
Original file line number Diff line number Diff line change
Expand Up @@ -1686,14 +1686,16 @@ Point LRSplineSurface::operator()(double u, double v, int u_deriv, int v_deriv)
// Distinguish between rational and non-rational to avoid
// making temporary storage in the non-rational case
double eps = 1.0e-12;
const bool u_on_end = (u >= mesh_.maxParam(XFIXED)-eps); //(u == (*b)->umax());
const bool v_on_end = (v >= mesh_.maxParam(YFIXED)-eps); // (v == (*b)->vmax());
// const bool u_on_end = (u >= mesh_.maxParam(XFIXED)-eps); //(u == (*b)->umax());
// const bool v_on_end = (v >= mesh_.maxParam(YFIXED)-eps); // (v == (*b)->vmax());

if (!rational_)
{
for (auto b = covering_B_functions.begin();
b != covering_B_functions.end(); ++b, ++ki)
{
const bool u_on_end = (u >= (*b)->umax()-eps);
const bool v_on_end = (v >= (*b)->vmax()-eps);
// The b-function contains the coefficient.
result += (*b)->eval(u,
v,
Expand All @@ -1714,8 +1716,8 @@ Point LRSplineSurface::operator()(double u, double v, int u_deriv, int v_deriv)
for (auto b = covering_B_functions.begin();
b != covering_B_functions.end(); ++b, ++ki)
{
// const bool u_on_end = (u == (*b)->umax());
// const bool v_on_end = (v == (*b)->vmax());
const bool u_on_end = (u == (*b)->umax());
const bool v_on_end = (v == (*b)->vmax());

// The b-function contains the coefficient.
double basis_val_pos = (*b)->evalBasisFunction(u,
Expand Down
7 changes: 5 additions & 2 deletions lrsplines2D/src/LRSplineUtils.C
Original file line number Diff line number Diff line change
Expand Up @@ -1273,8 +1273,11 @@ LRSplineUtils::refine_mesh(Direction2D d, double fixed_val, double start,
// check that the proposed multiplicity modification is legal
for (int i = start_ix; i < end_ix; ++i) {
const int cur_m = mesh.nu(d, fixed_ix, i, i+1);
if (absolute && (cur_m > mult))
THROW("Cannot decrease multiplicity.");
if (absolute && (cur_m > mult))
{
//THROW("Cannot decrease multiplicity.");
mult = cur_m;
}
else if (!absolute && (cur_m+mult > spline_degree + 1))
THROW("Cannot increase multiplicity.");
}
Expand Down
74 changes: 74 additions & 0 deletions viewlib/app/vol_and_lr/testLRtesselation.C
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
/*
* Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF ICT,
* Applied Mathematics, Norway.
*
* Contact information: E-mail: tor.dokken@sintef.no
* SINTEF ICT, Department of Applied Mathematics,
* P.O. Box 124 Blindern,
* 0314 Oslo, Norway.
*
* This file is part of GoTools.
*
* GoTools is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* GoTools is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public
* License along with GoTools. If not, see
* <http://www.gnu.org/licenses/>.
*
* In accordance with Section 7(b) of the GNU Affero General Public
* License, a covered work must retain the producer line in every data
* file that is created or manipulated using GoTools.
*
* Other Usage
* You can be released from the requirements of the license by purchasing
* a commercial license. Buying such a license is mandatory as soon as you
* develop commercial activities involving the GoTools library without
* disclosing the source code of your own applications.
*
* This file may be used in accordance with the terms contained in a
* written agreement between you and SINTEF ICT.
*/

#include "GoTools/viewlib/vol_and_lr/LRSurfaceTesselator.h"
#include "GoTools/lrsplines2D/LRSplineSurface.h"
#include "GoTools/geometry/ObjectHeader.h"
#include "GoTools/tesselator/GenericTriMesh.h"
#include <fstream>

using namespace std;
using namespace Go;

int main( int argc, char* argv[] )
{
if (argc != 4) {
std::cout << "Input parameters : Input file, n, m" << std::endl;
exit(-1);
}

// Read input arguments
std::ifstream file1(argv[1]);
ALWAYS_ERROR_IF(file1.bad(), "Input file not found or file corrupt");

int n = atoi(argv[2]);
int m = atoi(argv[3]);

// Read lrspline surface
ObjectHeader header;
header.read(file1);
shared_ptr<LRSplineSurface> surf(new LRSplineSurface());
surf->read(file1);

LRSurfaceTesselator tess(*surf);
tess.changeRes(n, m);
tess.tesselate();

int stop_break = 1;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
/*
* Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF ICT,
* Applied Mathematics, Norway.
*
* Contact information: E-mail: tor.dokken@sintef.no
* SINTEF ICT, Department of Applied Mathematics,
* P.O. Box 124 Blindern,
* 0314 Oslo, Norway.
*
* This file is part of GoTools.
*
* GoTools is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* GoTools is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public
* License along with GoTools. If not, see
* <http://www.gnu.org/licenses/>.
*
* In accordance with Section 7(b) of the GNU Affero General Public
* License, a covered work must retain the producer line in every data
* file that is created or manipulated using GoTools.
*
* Other Usage
* You can be released from the requirements of the license by purchasing
* a commercial license. Buying such a license is mandatory as soon as you
* develop commercial activities involving the GoTools library without
* disclosing the source code of your own applications.
*
* This file may be used in accordance with the terms contained in a
* written agreement between you and SINTEF ICT.
*/

#ifndef _LRSURFACEPROPERTYSHEET_H
#define _LRSURFACEPROPERTYSHEET_H


#include "GoTools/viewlib/gvPropertySheet.h"
#include "GoTools/viewlib/ui_RectangularSurfacePropertySheet_form.h"
#include "GoTools/geometry/ParamSurface.h"
#include "GoTools/viewlib/vol_and_lr/gvLRSurfacePaintable.h"
#include "GoTools/viewlib/vol_and_lr/LRSurfaceTesselator.h"

#include <QObject>

class gvData;
//class LRSurfaceTesselator;
//class gvLRSurfacePaintable;

/** Documentation ...
etc
*/

class LRSurfacePropertySheet : public QObject, public gvPropertySheet
{

Q_OBJECT

public:
LRSurfacePropertySheet()
{}

LRSurfacePropertySheet(Go::LRSurfaceTesselator* tess,
gvLRSurfacePaintable* pable,
shared_ptr<Go::ParamSurface>& surf)
: tess_(tess), pable_(pable), form_(0), obs_(0), surf_(surf)
{}

virtual ~LRSurfacePropertySheet();

virtual void createSheet(QWidget* parent, gvObserver* obs);

public slots:
void apply();


private:
Go::LRSurfaceTesselator* tess_;
gvLRSurfacePaintable* pable_;
Ui::RectangularSurfacePropertySheet_form* form_;
gvObserver* obs_;
shared_ptr<Go::ParamSurface> surf_;
};


#endif // _PARAMETRICSURFACEPROPERTYSHEET_H

165 changes: 165 additions & 0 deletions viewlib/include/GoTools/viewlib/vol_and_lr/LRSurfaceTesselator.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,165 @@
/*
* Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF ICT,
* Applied Mathematics, Norway.
*
* Contact information: E-mail: tor.dokken@sintef.no
* SINTEF ICT, Department of Applied Mathematics,
* P.O. Box 124 Blindern,
* 0314 Oslo, Norway.
*
* This file is part of GoTools.
*
* GoTools is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* GoTools is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public
* License along with GoTools. If not, see
* <http://www.gnu.org/licenses/>.
*
* In accordance with Section 7(b) of the GNU Affero General Public
* License, a covered work must retain the producer line in every data
* file that is created or manipulated using GoTools.
*
* Other Usage
* You can be released from the requirements of the license by purchasing
* a commercial license. Buying such a license is mandatory as soon as you
* develop commercial activities involving the GoTools library without
* disclosing the source code of your own applications.
*
* This file may be used in accordance with the terms contained in a
* written agreement between you and SINTEF ICT.
*/

#ifndef LRSURFACETESSELATOR_H
#define LRSURFACETESSELATOR_H

#include "GoTools/tesselator/Tesselator.h"
#include "GoTools/tesselator/RegularMesh.h"
#include "GoTools/geometry/ParamSurface.h"
#include "GoTools/geometry/RectDomain.h"
#include "GoTools/utils/BoundingBox.h"
#include "GoTools/tesselator/GenericTriMesh.h"
#include <memory>
#include "GoTools/utils/config.h"

namespace Go
{

/** LRSurfaceTesselator: create a mesh for an LR surface with a suitable
triangulation. Trimmed surfaces are currently not supported.
*/
class Element2D;
class LRSplineSurface;

class GO_API LRSurfaceTesselator : public Tesselator
{

public:
/// Constructor. Surface and mesh size are given. The mesh size relates to
/// the underlying surface in the case of bounded surfaces.
LRSurfaceTesselator(const ParamSurface& surf)
: surf_(surf), m_(20), n_(20)
{
mesh_ = shared_ptr<GenericTriMesh>(new GenericTriMesh(0,0,true,true));
}

virtual ~LRSurfaceTesselator();

virtual void tesselate();

// virtual GeneralMesh* getMesh()
// {
// return mesh_.get();
// }

/// Fetch the resulting mesh
shared_ptr<GenericTriMesh> getMesh()
{
return mesh_;
}

/// Change mesh size
void changeRes(int n, int m);

/// Fetch info about mesh size
void getRes(int& n, int& m)
{
m = m_;
n = n_;
}

private:
const ParamSurface& surf_;
shared_ptr<GenericTriMesh> mesh_;
int m_;
int n_;

void identifyNearTriangles(std::pair<Point,Point> gap_par,
std::vector<Point>& vx_par,
std::vector<unsigned int>& tri,
double del,
std::vector<size_t>& tri_near,
std::vector<BoundingBox>& bb_near);

void identifyJointTriangles(const Point& joint,
std::vector<Point>& vx_par,
std::vector<unsigned int>& tri,
double del,
std::vector<size_t>& tri_near,
std::vector<BoundingBox>& bb_near);

void updateVertex(Point& par, const LRSplineSurface* lrsf,
RectDomain& dom, Point& vertex_par,
Point& vertex, Point& vertex_norm,
Point& vertex_tex, Element2D *elem=0);


double edgeDist(Point curr, Point pa, Point pb, Point& pp);

bool isInsideTri(Point par, Point pa, Point pb, Point pc);

void getNextTriangle(int start_ix1, int start_ix2,
Point par1, Point par2,
std::vector<size_t>& tri_near,
std::vector<unsigned int>& tri,
std::vector<Point>& vx_par, double pdel,
int& tri_ix1, int& tri_ix2, Point& pp, int& vx_ix,
int& next_ix1, int& next_ix2);

int parConfiguration(const Point& param,
std::vector<Point>& vx_par,
std::vector<unsigned int>& tri,
double del,
std::vector<size_t>& tri_near,
int& ix1, int& ix2,
int edge[], Point& pp);

void sortAndConnect(std::vector<Point>& vx_par, std::vector<int>& vx_ix,
std::vector<unsigned int*> triangle);

void jointSplitAtEdge(const Point& joint,
std::vector<Point>& pvx,
std::vector<int>& vx_at,
double del, std::vector<Point>& par,
std::vector<int>& par_at,
std::vector<std::pair<int, int> >& parquart);

void writeGapTri(std::ofstream& oftg, std::vector<Point>& vertex,
unsigned int ix1, unsigned int ix2,
unsigned int ix3);
};

} // namespace Go




#endif // LRSURFACETESSELATOR_H

Loading
Loading