/* * NodeNurbsCurve2D.cpp * * Copyright (C) 2003 Th. Rothermel * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 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 General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program (see the file "COPYING" for details); if * not, write to the Free Software Foundation, Inc., 675 Mass Ave, * Cambridge, MA 02139, USA. */ #include #include #include #ifndef _WIN32 # include "stdlib.h" #endif #include "stdafx.h" #include "NodeNurbsCurve2D.h" #include "Scene.h" #include "FieldValue.h" #include "SFInt32.h" #include "MFFloat.h" #include "MFInt32.h" #include "MFVec2f.h" #include "MFVec3f.h" #include "SFNode.h" #include "SFBool.h" #include "SFVec3f.h" #include "Vec2f.h" #include "Vec3f.h" #include "RenderState.h" #include "DuneApp.h" #include "NurbsCurveDegreeElevate.h" #include "Util.h" ProtoNurbsCurve2D::ProtoNurbsCurve2D(Scene *scene) : Proto(scene, "NurbsCurve2D") { controlPoint.set( addExposedField(MFVEC2F, "controlPoint", new MFVec2f())); tessellation.set( addExposedField(SFINT32, "tessellation", new SFInt32(0))); weight.set( addExposedField(MFDOUBLE, "weight", new MFDouble(), new SFFloat(0.0f))); knot.set( addField(MFDOUBLE, "knot", new MFDouble())); order.set( addField(SFINT32, "order", new SFInt32(3), new SFInt32(2))); } Node * ProtoNurbsCurve2D::create(Scene *scene) { return new NodeNurbsCurve2D(scene, this); } NodeNurbsCurve2D::NodeNurbsCurve2D(Scene *scene, Proto *proto) : Node(scene, proto) { _chain.resize(0); _chainDirty = true; } void NodeNurbsCurve2D::setField(int index, FieldValue *value) { _chainDirty = true; Node::setField(index, value); } bool NodeNurbsCurve2D::writeEXTERNPROTO(int f) { RET_ONERROR( mywritestr(f ,"EXTERNPROTO NurbsCurve2D[\n") ) TheApp->incSelectionLinenumber(); RET_ONERROR( mywritestr(f ," exposedField MFVec2f controlPoint\n") ) TheApp->incSelectionLinenumber(); RET_ONERROR( mywritestr(f ," exposedField SFInt32 tessellation\n") ) TheApp->incSelectionLinenumber(); RET_ONERROR( mywritestr(f ," exposedField MFFloat weight\n") ) TheApp->incSelectionLinenumber(); RET_ONERROR( mywritestr(f ," field MFFloat knot\n") ) TheApp->incSelectionLinenumber(); RET_ONERROR( mywritestr(f ," field SFInt32 order\n") ) TheApp->incSelectionLinenumber(); RET_ONERROR( mywritestr(f ," ]\n") ) TheApp->incSelectionLinenumber(); RET_ONERROR( mywritestr(f ,"[\n") ) TheApp->incSelectionLinenumber(); RET_ONERROR( mywritestr(f ," \"urn:web3d:vrml97:node:NurbsCurve2D\",\n") ) TheApp->incSelectionLinenumber(); RET_ONERROR( mywritestr(f ," \"urn:inet:blaxxun.com:node:NurbsCurve2D\",\n") ) TheApp->incSelectionLinenumber(); RET_ONERROR( mywritestr(f ," \"urn:ParaGraph:NurbsCurve2D\",\n") ) TheApp->incSelectionLinenumber(); #ifdef HAVE_VRML97_AMENDMENT1_PROTO_URL RET_ONERROR( mywritestr(f ," \"") ) RET_ONERROR( mywritestr(f ,HAVE_VRML97_AMENDMENT1_PROTO_URL) ) RET_ONERROR( mywritestr(f ,"/NurbsCurve2DPROTO.wrl") ) RET_ONERROR( mywritestr(f ,"\"\n") ) TheApp->incSelectionLinenumber(); #else RET_ONERROR( mywritestr(f ," \"NurbsCurve2DPROTO.wrl\",\n") ) TheApp->incSelectionLinenumber(); #endif RET_ONERROR( mywritestr(f ," \"http://www.csv.ica.uni-stuttgart.de/vrml/dune/docs/vrml97Amendment1/NurbsCurve2DPROTO.wrl\"\n") ) TheApp->incSelectionLinenumber(); RET_ONERROR( mywritestr(f ,"]\n") ) TheApp->incSelectionLinenumber(); return true; } int NodeNurbsCurve2D::write(int filedes, int indent) { if (!_scene->isPureVRML97()) RET_ONERROR( NodeData::write(filedes, indent) ) return 0; } void NodeNurbsCurve2D::flip(int index) { if (controlPoint()) controlPoint()->flip(index); _chainDirty = true; }