/* * Project Info: http://jcae.sourceforge.net * * This program is free software; you can redistribute it and/or modify it under * the terms of the GNU Lesser General Public License as published by the Free * Software Foundation; either version 2.1 of the License, or (at your option) * any later version. * * This program 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 Lesser General Public License for more * details. * * You should have received a copy of the GNU Lesser General Public License * along with this program; if not, write to the Free Software Foundation, Inc., * 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. * * (C) Copyright 2011, by EADS France */ package org.jcae.opencascade.jni; import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; import java.util.List; import java.util.Map; import org.jcae.opencascade.Shape; /** * Trim a sphere with square and mesh it. * The square TopoDS_Wire is refined into more than 4 TopoDS_Edge. * The created geometry is converted to nurbs to mesh both nurbified and * original shapes. * @see http://www.opencascade.org/org/forum/thread_22070/ * @see http://github.com/tpaviot/oce/issues/143 * @author Jerome Robert */ public class TrimmedSphere { private static class Shape extends org.jcae.opencascade.Shape { private final static Factory FACTORY=new Factory() { public Shape create(TopoDS_Shape shape, Map map, Shape[] parents) { return new Shape(shape, map, parents); } public Shape[] createArray(int length) { return new Shape[length]; } }; public Shape(TopoDS_Shape shape) { this(shape, new HashMap(), new Shape[0]); } protected Shape(TopoDS_Shape shape, Map map, Shape[] parents) { super(shape, map, parents); } @Override protected Factory getFactory() { return FACTORY; } @Override protected Shape getDerived() { return this; } public TopoDS_Shape getImpl() { return impl; } } private static List createMeshEdge(double[] p1, double[] p2, int n) { TopoDS_Vertex[] toReturn = new TopoDS_Vertex[n]; double[] pp1 = new double[3]; for(int i = 0; i vertices = new ArrayList(); for(int i = 0; i